"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[743],{86992:(ne,T,s)=>{s.r(T),s.d(T,{NotificationsPage:()=>A,default:()=>q});var a=s(68404),y=s(79396),d=s(9892),H=s(58252),M=s(72648),P=s(39904),W=s(45253),Z=s(58255),U=s(31403),Y=s(10929),L=s(68900),j=s(53069),F=s(86230),J=s(93552),x=s(85719);function O(n,i){if(n==null)throw new TypeError("assign requires that input parameter not be null or undefined");for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(n[r]=i[r]);return n}function $(n){return O({},n)}var X=s(8679),C=s(29122),R=1440,b=2520,D=43200,w=86400;function V(n,i,r){var f,v;(0,C.Z)(2,arguments);var N=(0,Y.j)(),t=(f=(v=r?.locale)!==null&&v!==void 0?v:N.locale)!==null&&f!==void 0?f:J.Z;if(!t.formatDistance)throw new RangeError("locale must contain formatDistance property");var m=(0,L.Z)(n,i);if(isNaN(m))throw new RangeError("Invalid time value");var l=O($(r),{addSuffix:Boolean(r?.addSuffix),comparison:m}),u,e;m>0?(u=(0,x.Z)(i),e=(0,x.Z)(n)):(u=(0,x.Z)(n),e=(0,x.Z)(i));var c=(0,F.Z)(e,u),I=((0,X.Z)(e)-(0,X.Z)(u))/1e3,o=Math.round((c-I)/60),g;if(o<2)return r!=null&&r.includeSeconds?c<5?t.formatDistance("lessThanXSeconds",5,l):c<10?t.formatDistance("lessThanXSeconds",10,l):c<20?t.formatDistance("lessThanXSeconds",20,l):c<40?t.formatDistance("halfAMinute",0,l):c<60?t.formatDistance("lessThanXMinutes",1,l):t.formatDistance("xMinutes",1,l):o===0?t.formatDistance("lessThanXMinutes",1,l):t.formatDistance("xMinutes",o,l);if(o<45)return t.formatDistance("xMinutes",o,l);if(o<90)return t.formatDistance("aboutXHours",1,l);if(o<R){var _=Math.round(o/60);return t.formatDistance("aboutXHours",_,l)}else{if(o<b)return t.formatDistance("xDays",1,l);if(o<D){var ee=Math.round(o/R);return t.formatDistance("xDays",ee,l)}else if(o<w)return g=Math.round(o/D),t.formatDistance("aboutXMonths",g,l)}if(g=(0,j.Z)(e,u),g<12){var te=Math.round(o/D);return t.formatDistance("xMonths",te,l)}else{var z=g%12,S=Math.floor(g/12);return z<3?t.formatDistance("aboutXYears",S,l):z<9?t.formatDistance("overXYears",S,l):t.formatDistance("almostXYears",S+1,l)}}function B(n,i){return(0,C.Z)(1,arguments),V(n,Date.now(),i)}var h=s(72948);const G=({children:n,className:i,isSelected:r,onClick:f,severity:v="error",title:N,traceId:t,timestamp:m})=>{const l=(0,M.l4)(),u=K(l);return a.createElement(h.Z,{className:i,onClick:f},a.createElement(h.Z.Heading,null,N),a.createElement(h.Z.Description,null,n),a.createElement(h.Z.Figure,null,a.createElement(Z.X,{onChange:f,tabIndex:-1,value:r})),a.createElement(h.Z.Tags,{className:u.trace},t&&a.createElement("span",null,`Trace ID: ${t}`),m&&B(m,{addSuffix:!0})))},K=n=>({trace:(0,d.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 p=s(98864),E=s(81168);function Q(){const n=(0,E.useDispatch)(),i=(0,E.useSelector)(e=>(0,p.mE)(e.appNotifications)),[r,f]=(0,a.useState)([]),v=i.every(e=>r.includes(e.id)),N=(0,a.useRef)((0,E.useSelector)(e=>(0,p.Av)(e.appNotifications))),t=(0,M.wW)(k);(0,H.Z)(()=>{n((0,p.Jk)(Date.now()))});const m=()=>{v?n((0,p.F6)()):r.forEach(e=>{n((0,p.hS)(e))}),f([])},l=e=>{f(e?i.map(c=>c.id):[])},u=e=>{f(c=>c.includes(e)?c.filter(I=>I!==e):[...c,e])};return i.length===0?a.createElement("div",{className:t.noNotifsWrapper},a.createElement(P.J,{name:"bell",size:"xxl"}),a.createElement("span",null,"Notifications you have received will appear here.")):a.createElement("div",{className:t.wrapper},a.createElement(W.b,{severity:"info",title:"This page displays past errors and warnings. Once dismissed, they cannot be retrieved."}),a.createElement("div",{className:t.topRow},a.createElement(Z.X,{value:v,onChange:e=>l(e.target.checked)}),a.createElement(U.zx,{disabled:r.length===0,onClick:m},"Dismiss notifications")),a.createElement("ul",{className:t.list},i.map(e=>a.createElement("li",{key:e.id,className:t.listItem},a.createElement(G,{className:(0,d.cx)({[t.newItem]:e.timestamp>N.current}),isSelected:r.includes(e.id),onClick:()=>u(e.id),severity:e.severity,title:e.title,timestamp:e.timestamp,traceId:e.traceId},a.createElement("span",null,e.text))))))}function k(n){return{topRow:(0,d.css)({alignItems:"center",display:"flex",gap:n.spacing(2)}),list:(0,d.css)({display:"flex",flexDirection:"column"}),listItem:(0,d.css)({alignItems:"center",display:"flex",gap:n.spacing(2),listStyle:"none",position:"relative"}),newItem:(0,d.css)({"&::before":{content:'""',height:"100%",position:"absolute",left:"-7px",top:0,background:n.colors.gradients.brandVertical,width:n.spacing(.5),borderRadius:n.shape.borderRadius(1)}}),noNotifsWrapper:(0,d.css)({display:"flex",flexDirection:"column",alignItems:"center",gap:n.spacing(1)}),wrapper:(0,d.css)({display:"flex",flexDirection:"column",gap:n.spacing(2)})}}const A=()=>a.createElement(y.T,{navId:"profile/notifications"},a.createElement(y.T.Contents,null,a.createElement(Q,null))),q=A}}]);

//# sourceMappingURL=NotificationsPage.bf926a5fbfcf2b839d62.js.map