"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[4140],{29270(Q,I,s){s.r(I),s.d(I,{NotificationsPage:()=>A,default:()=>L});var i=s(14553),M=s(5246),f=s(22803),T=s(55501),R=s(94701),g=s(52358),C=s(49439),Y=s(58807),z=s(33100),X=s(23946),F=s(45270),Z=s(52365),E=s(75156),P=s(92516),O=s(1108),$=s(5305),H=s(96054),v=s(61501),K=s(71696),G=s(91349);function W(e,c,l){const u=(0,P.q)(),a=l?.locale??u.locale??E.c,p=2520,r=(0,H.z)(e,c);if(isNaN(r))throw new RangeError("Invalid time value");const n=Object.assign({},l,{addSuffix:l?.addSuffix,comparison:r}),[m,h]=(0,$.x)(l?.in,...r>0?[c,e]:[e,c]),t=(0,G.O)(h,m),x=((0,O.G)(h)-(0,O.G)(m))/1e3,o=Math.round((t-x)/60);let D;if(o<2)return l?.includeSeconds?t<5?a.formatDistance("lessThanXSeconds",5,n):t<10?a.formatDistance("lessThanXSeconds",10,n):t<20?a.formatDistance("lessThanXSeconds",20,n):t<40?a.formatDistance("halfAMinute",0,n):t<60?a.formatDistance("lessThanXMinutes",1,n):a.formatDistance("xMinutes",1,n):o===0?a.formatDistance("lessThanXMinutes",1,n):a.formatDistance("xMinutes",o,n);if(o<45)return a.formatDistance("xMinutes",o,n);if(o<90)return a.formatDistance("aboutXHours",1,n);if(o<v.F6){const d=Math.round(o/60);return a.formatDistance("aboutXHours",d,n)}else{if(o<p)return a.formatDistance("xDays",1,n);if(o<v.Nw){const d=Math.round(o/v.F6);return a.formatDistance("xDays",d,n)}else if(o<v.Nw*2)return D=Math.round(o/v.Nw),a.formatDistance("aboutXMonths",D,n)}if(D=(0,K.W)(h,m),D<12){const d=Math.round(o/v.Nw);return a.formatDistance("xMonths",d,n)}else{const d=D%12,j=Math.trunc(D/12);return d<3?a.formatDistance("aboutXYears",j,n):d<9?a.formatDistance("overXYears",j,n):a.formatDistance("almostXYears",j+1,n)}}const b=null;function B(e,c){return W(e,(0,Z.A)(e),c)}const k=null;var y=s(10470);const U=({children:e,className:c,isSelected:l,onClick:u,severity:a="error",title:p,traceId:r,timestamp:n})=>{const m=(0,C.$j)(),h=V(m);return(0,i.jsxs)(y.Z,{noMargin:!0,className:c,children:[(0,i.jsx)(y.Z.Heading,{children:p}),(0,i.jsx)(y.Z.Description,{children:e}),(0,i.jsx)(y.Z.Figure,{children:(0,i.jsx)(X.S,{onChange:u,value:l,"aria-label":(0,g.t)("notifications.select-notification","Select {{title}}",{title:p})})}),(0,i.jsxs)(y.Z.Tags,{className:h.trace,children:[r&&(0,i.jsx)("span",{children:`Trace ID: ${r}`}),n&&B(n,{addSuffix:!0})]})]})},V=e=>({trace:(0,f.css)({alignItems:"flex-end",alignSelf:"flex-end",color:e.colors.text.secondary,display:"flex",flexDirection:"column",fontSize:e.typography.pxToRem(10),justifySelf:"flex-end"})});var N=s(15195),S=s(96694);function w(){const e=(0,S.wA)(),c=(0,S.d4)(t=>(0,N.qN)(t.appNotifications)),[l,u]=(0,T.useState)([]),a=c.every(t=>l.includes(t.id)),p=(0,T.useRef)((0,S.d4)(t=>(0,N.$K)(t.appNotifications))),r=(0,C.of)(J);(0,R.A)(()=>{e((0,N.oF)(Date.now()))});const n=()=>{a?e((0,N.XC)()):l.forEach(t=>{e((0,N.XR)(t))}),u([])},m=t=>{u(t?c.map(x=>x.id):[])},h=t=>{u(x=>x.includes(t)?x.filter(o=>o!==t):[...x,t])};return c.length===0?(0,i.jsx)(Y.p,{variant:"completed",message:(0,g.t)("notifications.empty-state.title","You're all caught up!"),children:(0,i.jsx)(g.x6,{i18nKey:"notifications.empty-state.description",children:"Notifications you have received will appear here"})}):(0,i.jsxs)("div",{className:r.wrapper,children:[(0,i.jsx)(z.F,{severity:"info",title:(0,g.t)("notifications.stored-notifications.title-alert","This page displays past errors and warnings. Once dismissed, they cannot be retrieved.")}),(0,i.jsxs)("div",{className:r.topRow,children:[(0,i.jsx)(X.S,{value:a,"aria-label":(0,g.t)("notifications.select-all","Select all notifications"),onChange:t=>m(t.target.checked)}),(0,i.jsx)(F.$n,{disabled:l.length===0,onClick:n,children:(0,i.jsx)(g.x6,{i18nKey:"notifications.stored-notifications.dismiss-notifications",children:"Dismiss notifications"})})]}),(0,i.jsx)("ul",{className:r.list,children:c.map(t=>(0,i.jsx)("li",{className:r.listItem,children:(0,i.jsx)(U,{className:(0,f.cx)({[r.newItem]:t.timestamp>p.current}),isSelected:l.includes(t.id),onClick:()=>h(t.id),severity:t.severity,title:t.title,timestamp:t.timestamp,traceId:t.traceId,children:(0,i.jsx)("span",{children:t.text})})},t.id))})]})}function J(e){return{topRow:(0,f.css)({alignItems:"center",display:"flex",gap:e.spacing(2)}),list:(0,f.css)({display:"flex",flexDirection:"column"}),listItem:(0,f.css)({alignItems:"center",display:"flex",gap:e.spacing(2),listStyle:"none",position:"relative"}),newItem:(0,f.css)({"&::before":{content:'""',height:"100%",position:"absolute",left:"-7px",top:0,background:e.colors.gradients.brandVertical,width:e.spacing(.5),borderRadius:e.shape.radius.default}}),noNotifsWrapper:(0,f.css)({display:"flex",flexDirection:"column",alignItems:"center",gap:e.spacing(1)}),wrapper:(0,f.css)({display:"flex",flexDirection:"column",gap:e.spacing(2)})}}const A=()=>(0,i.jsx)(M.Y,{navId:"profile/notifications",children:(0,i.jsx)(M.Y.Contents,{children:(0,i.jsx)(w,{})})}),L=A}}]);

//# sourceMappingURL=NotificationsPage-react19.6a3dafbb24aa320645a8.js.map