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