File: //opt/netdata/usr/local/local/share/netdata/web/v3/4835.b4a6066632977c8c6b74.chunk.js
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"9170653e16c97eceaa1ad9e3f6f38e5725ee9d53"};var t=(new e.Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="30ceedf7-eb66-42e5-9938-265c4acee05c",e._sentryDebugIdIdentifier="sentry-dbid-30ceedf7-eb66-42e5-9938-265c4acee05c")}catch(e){}}(),(self.webpackChunkcloud_frontend=self.webpackChunkcloud_frontend||[]).push([[4835],{57738(e,t,n){n.d(t,{L:()=>w});var r=n(64467),o=n(80045),l=(n(98992),n(54520),n(3949),n(8872),n(62953),n(96540)),s=n(41344),a=n(30569),i=n(63872),c=n(19186),d=n(10602),u=n(24609),h=n(30731),x=n(92726),g=n(67294),p=n(45706),f=n(3319);const b=["pristine","data","columns","aggregations","aggregatedView","acceptedParams","requiredParams"];function j(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function m(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?j(Object(n),!0).forEach((function(t){(0,r.A)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):j(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}const v=e=>"function"===e.type&&"feed"===e.flavour,y=(e,t)=>{const n=t[0]||null;return Object.entries(e).reduce(((e,t)=>{let[r,l]=t;const{pristine:s,data:a,columns:i,aggregations:c,aggregatedView:d,acceptedParams:u,requiredParams:h}=l,x=(0,o.A)(l,b);return"chart"===x.type?e[r]=m(m({},x),{},{nodesScope:[]}):(e=>"function"===e.type&&!v(e))(x)?e[r]=m(m({},x),{},{selectedNodeIds:n?[n]:[]}):v(x)?e[r]=m(m({},x),{},{selectedNodeIds:[]}):e[r]="selectedNodeIds"in x?m(m({},x),{},{selectedNodeIds:[]}):x,e}),{})},w=()=>{const e=(0,s.Zp)(),[t,n]=(0,i.A)(),r=(0,u.vt)(),o=(0,c.ID)(),b=(0,u.bq)(),j=(0,c.QW)(),v=(0,d.CK)(),w=(0,d.nj)(),{sendLog:O}=(0,f.A)();return(0,a.yF)((0,l.useCallback)((async(l,s,a)=>{if(w)try{const{data:n}=await(0,h.f7)(r,o,a),{layout:l,containerIds:i,containers:c,cards:d,dashboard:u}=(0,p.S)(n),f=y(d,v),w="Copy of ".concat(u.name),{data:I}=await(0,h.k9)(r,o,{name:w}),C={version:I.version+1||2,snapshot:{uiState:{layout:l,containerIds:i,containers:c,cards:f,respectNodesScope:u.respectNodesScope,duplicate:{id:a}}}};await(0,h.mQ)(r,o,I.id,C),s((0,x._d)(I.id),m(m(m({name:w},C),{},{spaceId:r,roomId:o},I),{},{loaded:!0})),s((0,g.hZ)(o),m(m({},I),{},{spaceId:r,roomId:o})),O({feature:"DuplicatedCustomDashboard",isSuccess:!0,dashboardId:I.id}),t({header:"Dashboards",text:"Dashboard duplicated!"}),e("/spaces/".concat(b,"/rooms/").concat(j,"/dashboards/").concat(I.slug),{state:{showDuplicateWizard:!0}})}catch(i){n(i)}else n({header:"Dashboards",text:"Please wait for nodes to finish loading."})}),[r,o,b,j,v,w,e,t,n,O]))}},69645(e,t,n){n.d(t,{J:()=>Gr,A:()=>qr});n(62953);var r=n(96540),o=n(42358),l=n(41344),s=n(98591),a=n(85660),i=n(92726),c=n(78385),d=n(57068),u=n(6393),h=n(19186),x=n(87083),g=n(24013),p=n(64467),f=n(80045),b=(n(98992),n(54520),n(3949),n(82418)),j=n(74848);const m=["compact"];function v(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function y(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?v(Object(n),!0).forEach((function(t){(0,p.A)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):v(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}const w=e=>{let{compact:t}=e,n=(0,f.A)(e,m);const[,r]=(0,s.A)("addChartModal"),l=(0,g.TG)().length>0;return(0,j.jsxs)(o.Flex,y(y({column:!0,alignItems:"center",justifyContent:"center",overflow:{vertical:"auto"},flex:!0,basis:0,"data-testid":"dashboardBlankSlate"},n),{},{children:[!t&&(0,j.jsx)(o.Flex,{as:"img",src:b.$,height:"35%"}),(0,j.jsx)(o.H3,{margin:[6,0,2],children:"Empty Dashboard"}),l?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(o.Text,{textAlign:"center",children:"Let\u2019s fill your dashboard."}),(0,j.jsx)(o.Text,{textAlign:"center",children:"Go to a node view or node list and add one chart to this Dashboard or just use"})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(o.Text,{textAlign:"center",children:"You don't have any available node to retrieve charts from."}),(0,j.jsx)(o.Text,{textAlign:"center",children:"Please verify your nodes' state and/or connect a new node to Netdata"})]}),!t&&(0,j.jsx)(o.Button,{margin:[8,0,0,0],onClick:r,disabled:!l,label:"Add chart","data-testid":"dashboardBlankSlate-addChart"})]}))};var O=n(51510);function I(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}const C="20px",S=(0,O.css)(["background-image:radial-gradient( circle,"," ",",transparent "," );background-size:"," ",";background-position:center center;"],(0,o.getColor)("borderSecondary"),"1px","1px",C,C),k=(0,O.default)(o.Flex).attrs((e=>{let{active:t}=e;return function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?I(Object(n),!0).forEach((function(t){(0,p.A)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):I(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({width:"100%",flex:!0,overflow:"hidden"},t&&{background:"mainBackground"})})).withConfig({displayName:"gridBackground__GridBackground",componentId:"sc-86s97v-0"})(["",""],(e=>{let{active:t}=e;return t&&S})),F=k;n(26910),n(72577),n(81454);var A=n(32788),P=n(29263),T=n(47410),N=n(10602),D=n(23226),E=n(24609),L=n(5907),M=n(77814),z=n(21e3),B=n(87733),R=n(67012),G=n(28657),q=n(87398),_=n(13752),V=n(92815),W=n(72582),H=n(78072),K=n(91832),U=n(23565),Q=n(52795),J=n(54251),Y=n(45087);const Z=()=>(0,j.jsxs)(o.Flex,{column:!0,width:"300px",gap:1,children:[(0,j.jsx)(o.TextSmall,{strong:!0,children:"Not finding a chart?"}),(0,j.jsxs)(o.TextSmall,{children:["When selecting",(0,j.jsx)(o.TextSmall,{strong:!0,margin:[0,1],children:"All Nodes"}),"you search and add charts using their context. The outcome will be a composite chart over All Nodes, like on the Overview tab."]}),(0,j.jsxs)(o.TextSmall,{children:["When you select a",(0,j.jsx)(o.TextSmall,{strong:!0,margin:[0,1],children:"specific Node"}),"you search and add charts using their name. The result is a specific chart over the node selected, like on Single Node tab."]})]}),$=()=>(0,j.jsx)(Y.A,{isBasic:!0,plain:!0,content:Z,align:"bottom",children:(0,j.jsx)(o.Icon,{name:"question",color:"textDescription",size:"small"})});function X(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function ee(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?X(Object(n),!0).forEach((function(t){(0,p.A)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):X(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}const te=e=>{let{spaceId:t,roomId:n,value:l,onChange:s,options:a,testid:i,selectedNodeIds:c,metadata:d}=e;const[u,h]=(0,r.useState)(),x=null===l||void 0===l?void 0:l.value,g=(0,q.eg)(),p=(0,U.CS)({type:"chart",entity:x,path:"/"}),f=(0,B.K)({spaceId:t,roomId:n}),b=(0,r.useMemo)((()=>{g.getNodes({id:"newDashboardChart"}).forEach((e=>e.destroy()));const{info:e,valueRange:t,height:r,colors:o}=(0,z.Ay)(d),l=g.makeChart({attributes:ee(ee({id:"newDashboardChart",contextScope:[x],host:f,roomId:n,info:e,valueRange:t,height:r+207,enabledNavigation:!1,nodesScope:c},o&&{colors:o}),{},{toolboxElements:[H.default,W.default,_.default,V.default,K.A]})});g.getRoot().appendChild(l),h((0,Q.A)(l.getAttributes()));const s=l.getAttribute("chartLibrary");return l.setAttributes(ee(ee({},u),(0,Q.A)(p,!0))),(0,J.A)(l,s,l.getAttribute("chartLibrary")),l}),[g,x]);return(0,R.A)((()=>{if(!b||!p)return;const e=b.getAttribute("chartLibrary");b.updateAttributes(ee(ee({},u),(0,Q.A)(p,!0))),(0,J.A)(b,e,b.getAttribute("chartLibrary")),b.trigger("fetch")}),[b,n,x,p,u]),(0,r.useLayoutEffect)((()=>()=>b.destroy()),[]),(0,j.jsxs)(o.Flex,{gap:6,column:!0,children:[(0,j.jsxs)(o.Flex,{gap:2,column:!0,"data-testid":i,children:[(0,j.jsxs)(o.Flex,{gap:2,children:[(0,j.jsx)(o.H5,{children:"Chart context"}),(0,j.jsx)($,{})]}),(0,j.jsx)(o.Select,{options:a,value:l,onChange:s,isClearable:!0,form:i})]}),l&&(0,j.jsx)(o.Flex,{height:{min:"320px"},column:!0,children:(0,j.jsx)(G.A,{chart:b,margin:[2,0,0]})})]})};var ne=n(43116);const re={label:"All Nodes",value:"all-nodes"},oe={label:"All Nodes (no reachable nodes)",value:"all-nodes",isDisabled:!0},le=e=>{let{id:t,isLive:n,nodeStatus:r,name:o}=e;return{label:n?o:"".concat(o," (").concat(r,")"),value:t,isDisabled:!n}},se=e=>({value:e,label:e}),ae=e=>{let{id:t,onClose:n}=e;const l=(0,E.vt)(),s=(0,h.ID)(),a=(0,i.fz)(t,"name"),c=(0,h.XA)("name"),d=(0,N.CK)(),u=(0,g.BU)().length>0,x=(0,N.nj)(),p=(0,g.Gt)(d),f=(0,L.nM)(t),b=u?re:oe,[m,v]=(0,r.useState)(b.value),[y,w]=(0,r.useState)(null),O=(0,r.useMemo)((()=>[b,...p.map(le)]),[p]),I=(0,r.useMemo)((()=>O.find((e=>{let{value:t}=e;return t===m}))),[O,m]),C=(0,r.useCallback)((e=>{v((null===e||void 0===e?void 0:e.value)||b.value),w(null)}),[]),S=(0,r.useMemo)((()=>m===b.value?[]:[m]),[m]),{charts:k,error:F}=(0,M.A)(l,s,S),z=(0,r.useMemo)((()=>Object.keys(k).sort(((e,t)=>e.localeCompare(t,void 0,{sensitivity:"accent",ignorePunctuation:!0}))).map(se)),[k]);(0,r.useEffect)((()=>{z.length&&I&&w((e=>e||z[0].value))}),[y,z,I]);const B=(0,r.useMemo)((()=>y&&se(y)),[y]),R=(0,r.useCallback)((e=>w(null===e||void 0===e?void 0:e.value)),[]),G=k[y],_=(0,q.eg)(),V=(0,r.useCallback)((()=>{const e=_.getNode({id:"newDashboardChart"}),t=(0,Q.h)(e.getAttributes());f(t.contextScope,t,(()=>setTimeout(n)))}),[m,G]),W=!y,[,H]=(0,D.A)();return(0,r.useEffect)((()=>(H(!0),()=>H(!1)))),(0,j.jsx)(A.GO,{onClose:n,children:F?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(P.z,{onClose:n,title:"Add Chart to Dashboard"}),(0,j.jsx)(A.Yv,{height:"100%",padding:[0,8],children:(0,j.jsx)(ne.A,{error:F})})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(P.z,{onClose:n,title:"Add Chart to Dashboard",children:(0,j.jsx)(o.Button,{label:"Add chart",icon:"plus",onClick:V,disabled:W,"data-testid":"addChartModal-addChart-button"})}),(0,j.jsxs)(T.U,{children:["Add Charts to ",a]}),(0,j.jsx)(A.Yv,{overflow:"visible",children:(0,j.jsxs)(o.Flex,{gap:6,column:!0,children:[(0,j.jsxs)(o.Flex,{gap:2,column:!0,"data-testid":"addChartModal-selectNodes",children:[(0,j.jsxs)(o.H5,{children:["Nodes in ",c]}),(0,j.jsx)(o.Select,{options:O,value:I,onChange:C,isLoading:!x,isClearable:!0,form:"addChartModal-selectNodes"})]}),B&&(0,j.jsx)(te,{id:t,spaceId:l,roomId:s,value:B,onChange:R,options:z,testid:"addChartModal-selectChart",selectedNodeIds:S,metadata:k[y]})]})})]})})};var ie=n(30569),ce=n(28864),de=n(44245),ue=n(63872);n(37550);const he=e=>"function"===e.type&&"feed"!==e.flavour,xe=e=>"chart"===e.type||("function"===e.type&&"feed"===e.flavour||"function"!==e.type&&"selectedNodeIds"in e),ge=e=>{const t=(0,u._S)(e);return(0,r.useMemo)((()=>(e=>{const t=Object.values(e),n=t.some(xe),r=t.filter(he),o=[{type:"global",hasNodeFilter:n}];return r.forEach((e=>{o.push({type:"singleNode",cardId:e.id,cardTitle:e.customTitle||e.displayName||e.id,flavour:e.flavour})})),o})(t||{})),[t])};var pe=n(38757),fe=n(42721);const be=e=>{let{name:t,setName:n,isNameValid:r,setIsNameValid:l,globalNodeIds:s,setGlobalNodeIds:a,hasNodeFilter:i}=e;const c=(0,N.CK)();return(0,j.jsxs)(o.Flex,{column:!0,gap:4,children:[(0,j.jsx)(pe.A,{value:t,label:"Dashboard Name",onChange:e=>n(e.target.value),isValid:r,setIsValid:l,"data-testid":"duplicateWizard-name-input"}),i&&(0,j.jsxs)(o.Flex,{column:!0,gap:2,children:[(0,j.jsx)(o.Text,{strong:!0,children:"Select Nodes"}),(0,j.jsx)(fe.A,{nodeIds:c,selectedNodeIds:s,setSelectedNodeIds:a})]})]})},je={fn:"Function",logs:"Logs",function:"Function"},me=e=>{let{cardTitle:t,flavour:n,selectedNodeId:r,setSelectedNodeId:l}=e;const s=(0,N.CK)();return(0,j.jsxs)(o.Flex,{column:!0,gap:4,children:[(0,j.jsxs)(o.Flex,{column:!0,gap:1,children:[(0,j.jsx)(o.Text,{strong:!0,children:t}),(0,j.jsxs)(o.Text,{color:"textLite",children:[je[n]||"Function"," card"]})]}),(0,j.jsxs)(o.Flex,{column:!0,gap:2,children:[(0,j.jsx)(o.Text,{strong:!0,children:"Select Node"}),(0,j.jsx)(fe.A,{nodeIds:s,selectedNodeIds:r?[r]:[],setSelectedNodeIds:e=>l(e[0]||null),multi:!1})]})]})};function ve(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function ye(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ve(Object(n),!0).forEach((function(t){(0,p.A)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ve(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}const we=e=>{let{dashboardId:t,onClose:n}=e;const{name:s,slug:a}=(0,i.fz)(t),c=(0,N.CK)(),d=ge(t),x=(0,l.Zp)(),g=(0,h.r9)(),p=(0,de.DF)(),[f,b]=(0,r.useState)(0),[m,v]=(0,r.useState)(s),[y,w]=(0,r.useState)(!0),[O,I]=(0,r.useState)([]),[C,S]=(0,r.useState)((()=>{const e={};return d.forEach((t=>{"singleNode"===t.type&&(e[t.cardId]=c[0]||null)})),e})),k=(0,ce.DH)(t),F=d[f],T=f===d.length-1,D=0===f,[E,L]=(0,r.useState)(!1),[,M]=(0,ue.A)(),z=(0,ie.yF)((0,r.useCallback)(((e,n)=>{const r=e((0,u.nG)({id:t}));Object.entries(r).forEach((e=>{let[r,o]=e;"chart"===o.type&&O.length>0?n((0,u.nG)({id:t,resourceId:r}),(e=>ye(ye({},e),{},{nodesScope:O}))):"function"===o.type&&"feed"!==o.flavour&&C[r]?n((0,u.nG)({id:t,resourceId:r}),(e=>ye(ye({},e),{},{selectedNodeIds:[C[r]]}))):("function"===o.type&&"feed"===o.flavour&&O.length>0||"selectedNodeIds"in o&&O.length>0)&&n((0,u.nG)({id:t,resourceId:r}),(e=>ye(ye({},e),{},{selectedNodeIds:O})))})),n((0,i.Qx)({id:t}),(e=>ye(ye({},e),{},{duplicate:null},m!==s?{name:m}:{})))}),[t,O,C,m,s])),B=(0,ie.yF)((0,r.useCallback)(((e,n)=>{n((0,i.Qx)({id:t}),(e=>ye(ye({},e),{},{duplicate:null})))}),[t])),R=(0,r.useCallback)((async()=>{L(!0),z();try{const{data:e}=await k(),{slug:r}=e;if(r!==a){const e="".concat(g,"/dashboards/").concat(r);p({id:t,slug:r,path:e}),x(e,{replace:!0})}n()}catch(e){M(e),L(!1)}}),[z,k,n,M,a,g,p,t,x]),G=(0,r.useCallback)((async()=>{L(!0),B();try{await k(),n()}catch(e){M(e),L(!1)}}),[B,k,n,M]),q=(0,r.useCallback)((()=>{T?R():b((e=>e+1))}),[T,R]),_=(0,r.useCallback)((()=>{b((e=>Math.max(0,e-1)))}),[]);return(0,j.jsxs)(A.GO,{onClose:n,"data-testid":"duplicateWizard-modal",children:[(0,j.jsx)(P.z,{onClose:n,title:"Set Up Duplicate",children:(0,j.jsx)(o.Flex,{gap:2,children:(0,j.jsx)(o.Button,{label:"Skip, I'll keep it as is",flavour:"hollow",onClick:G,disabled:E,"data-testid":"duplicateWizard-skip"})})}),(0,j.jsx)(A.Yv,{children:(0,j.jsxs)(o.Flex,{column:!0,gap:4,children:[(0,j.jsxs)(o.Text,{color:"textLite",children:["Step ",f+1," of ",d.length]}),"global"===F.type&&(0,j.jsx)(be,{name:m,setName:v,isNameValid:y,setIsNameValid:w,globalNodeIds:O,setGlobalNodeIds:I,hasNodeFilter:F.hasNodeFilter}),"singleNode"===F.type&&(0,j.jsx)(me,{cardTitle:F.cardTitle,flavour:F.flavour,selectedNodeId:C[F.cardId],setSelectedNodeId:e=>S((t=>ye(ye({},t),{},{[F.cardId]:e})))}),(0,j.jsxs)(o.Flex,{justifyContent:"between",gap:2,children:[!D&&(0,j.jsx)(o.Button,{label:"Back",flavour:"hollow",onClick:_,"data-testid":"duplicateWizard-back"}),(0,j.jsx)(o.Flex,{flex:!0}),(0,j.jsx)(o.Button,{label:T?"Complete":"Next",onClick:q,disabled:!y||E,isLoading:E,"data-testid":"duplicateWizard-next"})]})]})})]})};var Oe=n(88255),Ie=n(65380),Ce=n(42790),Se=n(83330),ke=n(60908),Fe=(n(8872),n(85163)),Ae=n(71123);function Pe(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Te(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Pe(Object(n),!0).forEach((function(t){(0,p.A)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Pe(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}const Ne=function(e,t){let{containerIds:n,containers:r,layout:o}=e,{extraKey:l}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const s={},a=n.reduce(((e,n)=>{const a=(0,Ae.bj)(o[n],"vertical");return e[n]=Te(Te({},r[n]),{},{level:0,id:n,subMenuIds:a.reduce(((e,r)=>{let{id:o}=r;return"text"!==t(o).type&&e.push("".concat(n,"|").concat(o)),e}),[]),subMenuChartIds:[],link:"".concat((0,Fe.A)("menu_".concat(n))),forceVisibility:!0,arFlavour:"anomaly",extraKey:l}),a.forEach((e=>{const r="".concat(n,"|").concat(e.id),o=t(e.id);"text"!==o.type&&(s[r]={name:o.title,level:1,id:r,menuId:n,chartIds:[],link:"".concat((0,Fe.A)("menu_".concat(n,"_submenu_").concat(r))),arFlavour:"anomaly",showAR:!1,extraKey:l})})),e}),{});return{menuIds:n,menuById:a,subMenuById:s}};var De=n(6304),Ee=n(57738),Le=n(99728),Me=n(67294),ze=n(51262),Be=n(39175);const Re=e=>{let{id:t}=e;const[n,l]=(0,i.TN)({id:t,key:"name"}),[s,a]=(0,r.useState)(n||"");(0,r.useEffect)((()=>{a(n||"")}),[n]);const c=(0,r.useCallback)((e=>{a(e.target.value)}),[]),d=(0,r.useCallback)((()=>{s!==n&&l(s||"Untitled Dashboard")}),[s,n,l]);return(0,j.jsx)(o.TextInput,{value:s,onChange:c,onBlur:d,placeholder:"Untitled Dashboard","data-testid":"dashboardHeader-title-input",width:"180px"})};function Ge(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function qe(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Ge(Object(n),!0).forEach((function(t){(0,p.A)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ge(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}const _e=function(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];!function(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];const{navigator:n}=(0,r.useContext)(l._3),o=(0,l.zy)();(0,r.useEffect)((()=>{if(!t)return;const r=n.block((t=>{const n=qe(qe({},t),{},{retry(){r(),t.retry()}});e(n)}));return r}),[n,e,t,o])}((0,r.useCallback)((t=>{"REPLACE"!==t.action?window.confirm(e)&&t.retry():t.retry()}),[e]),t)},Ve="Are you sure you want to leave this dashboard?\nChanges will be lost.";var We=n(51571);const He=e=>{let{id:t}=e;const[,n]=(0,ue.A)(),r=(0,ce.DH)(t,{onFail:n}),o=(0,i.fz)(t,"processing"),l=(0,i.fz)(t,"isOwner"),s=(0,i.zN)(t);return(0,j.jsx)(We.A,{permission:l?"dashboard:UpdateSelf":"dashboard:Update",label:"Save",onClick:()=>r(),disabled:s,isLoading:o,"data-testid":"dashboardHeaderActionBar-save-button","data-ga":"action-bar::click-save::cust-dashboard"})},Ke=e=>{let{id:t}=e;const n=(e=>{const t=(0,i.zN)(e),n=(0,ce.Cb)(e),o=(0,c.x3)();return(0,r.useCallback)((()=>{if(!t){if(!window.confirm(Ve))return;n()}o(!1)}),[t,n,o])})(t);return(0,j.jsxs)(o.Flex,{gap:2,alignItems:"center",children:[(0,j.jsx)(He,{id:t}),(0,j.jsx)(o.Button,{label:"Exit",flavour:"hollow",onClick:n,"data-testid":"dashboardHeaderActionBar-exit-button","data-ga":"action-bar::click-exit::cust-dashboard"})]})},Ue=(0,r.memo)(Ke),Qe=["id"];function Je(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Ye(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Je(Object(n),!0).forEach((function(t){(0,p.A)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Je(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}const Ze=e=>{let{id:t}=e,n=(0,f.A)(e,Qe);const[l,s]=(0,i.TN)({id:t,key:"respectNodesScope"}),a=(0,ce.DH)(t),c=(0,r.useCallback)((()=>{s(!l),a()}),[l,s]);return(0,j.jsx)(o.Toggle,Ye(Ye({},n),{},{colored:!0,onChange:c,checked:!l,margin:[0],labelRight:"Apply global filters"}))};n(27495),n(48408);var $e=n(67916),Xe=n(12273),et=n(81214);const tt=e=>{let{dashboardId:t,spaceId:n,roomId:l,onClose:s}=e;const[a,i]=(0,r.useState)(!1),[c,d]=(0,r.useState)(null),[u,h]=(0,r.useState)(!1),[{after:x,before:g}]=(0,Ce.N9)();return(0,j.jsx)(o.Modal,{backdropProps:{backdropBlur:!0},onClickOutside:s,onEsc:s,children:(0,j.jsxs)(o.ModalContent,{width:"600px",children:[(0,j.jsxs)(o.ModalHeader,{children:["TV Mode URL",(0,j.jsx)(o.ModalCloseButton,{onClose:s})]}),(0,j.jsx)(o.ModalBody,{column:!0,gap:4,children:c?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(Xe.FU,{children:c}),(0,j.jsxs)(o.Flex,{alignItems:"center",background:"warningBackground",gap:4,padding:[3,3],round:!0,children:[(0,j.jsx)(o.Text,{color:"warning",children:"\u26a0\ufe0f"}),(0,j.jsx)(o.Text,{children:"This URL contains a unique access token. Keep it secure and only share with trusted users."})]})]}):(0,j.jsx)(o.Text,{children:"Generate a shareable TV mode URL for this dashboard. A new access token will be created automatically."})}),(0,j.jsxs)(o.ModalFooter,{gap:2,children:[(0,j.jsx)(o.Button,{flavour:"hollow",onClick:s,children:"Cancel"}),c?(0,j.jsx)(o.Button,{onClick:async()=>{if(c)try{await(0,et.A)(c)&&(h(!0),setTimeout((()=>h(!1)),2e3))}catch(e){console.error("Failed to copy URL:",e)}},children:u?"Copied!":"Copy URL"}):(0,j.jsx)(o.Button,{onClick:async()=>{i(!0);try{const e=function(e,t,n,r){let o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,l=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0;const s=window.location.origin,a=new URLSearchParams(location.search).get("agent"),i=a?"&agent=".concat(a):"";return"".concat(s,"/webviews/dashboards/").concat(t,"?space_id=").concat(n,"&room_id=").concat(r).concat(i,"#token=").concat(e,"&after=").concat(o,"&before=").concat(l)}((await(0,$e.Ey)({description:"TV Mode - Dashboard ".concat(t),scope:"scope:all"})).data.token,t,n,l,x,g);d(e)}catch(e){console.error("Failed to create token:",e)}finally{i(!1)}},disabled:a,children:a?"Generating...":"Generate a new URL"})]})]})})};var nt=n(46587);const rt=(0,n(74891).A)(o.Button),ot=e=>{let{dashboardId:t,spaceId:n,roomId:l,iconOnly:s,small:a}=e;const i=(0,nt.uW)("isAnonymous"),[c,d]=(0,r.useState)(!1),u=(0,r.useMemo)((()=>i?"Sign in first to generate a TV mode URL":"Generate TV Mode URL"),[i]);return(0,j.jsxs)(j.Fragment,{children:[s?(0,j.jsx)(o.IconButton,{icon:"monitoring",tooltip:u,flavour:"hollow",small:a,onClick:()=>d(!0),"data-testid":"tv-button",disabled:i}):(0,j.jsx)(rt,{flavour:"hollow",icon:"monitoring",tooltip:u,onClick:()=>d(!0),"data-testid":"tv-button",textTransform:"none",disabled:i,noWrapper:!0,children:"TV mode"}),c&&(0,j.jsx)(tt,{dashboardId:t,spaceId:n,roomId:l,onClose:()=>d(!1)})]})},lt=e=>{let{id:t,onOpenDuplicateWizard:n}=e;const{name:l,spaceId:s,roomId:a,duplicate:d}=(0,i.fz)(t),u=(0,c.x3)(),h=(0,Ee.L)(),x=(0,Le.JT)("dashboard:Create"),g=(0,Me.q)(),{hasLimitations:p,maxDashboards:f}=(0,ze.A)(),b=g.some((e=>e===Be.LA)),m=x&&!(p&&g.length-(b?1:0)>=f),[v,,y,w]=(0,De.A)(),O=(0,r.useCallback)((()=>{w(),h(t)}),[t,h,w]);return(0,j.jsxs)(o.Flex,{justifyContent:"between",alignItems:"center",padding:[4,0],"data-testid":"dashboardHeader",children:[(0,j.jsx)(o.Text,{color:"text",children:l||"Untitled Dashboard"}),(0,j.jsxs)(o.Flex,{gap:2,alignItems:"center",children:[d&&(0,j.jsx)(o.IconButton,{icon:"gear",tooltip:"Set up duplicate",flavour:"hollow",small:!0,onClick:n,"data-testid":"dashboardHeader-updateDuplicate-button","data-ga":"header::click-update-duplicate::cust-dashboard"}),(0,j.jsx)(o.IconButton,{icon:"settings",tooltip:"Edit dashboard",flavour:"hollow",small:!0,onClick:()=>u(!0),"data-testid":"dashboardHeader-edit-button","data-ga":"header::click-edit::cust-dashboard"}),(0,j.jsx)(o.IconButton,{icon:"copy",tooltip:m?"Duplicate dashboard":"Cannot duplicate",flavour:"hollow",small:!0,onClick:y,disabled:!m,"data-testid":"dashboardHeader-duplicate-button","data-ga":"header::click-duplicate::cust-dashboard"}),(0,j.jsx)(ot,{dashboardId:t,spaceId:s,roomId:a,iconOnly:!0,small:!0})]}),v&&(0,j.jsx)(o.ConfirmationDialog,{title:"Duplicate dashboard",message:'A new dashboard named "Copy of '.concat(l||"Untitled Dashboard",'" will be created in this room with the same layout and card configuration. Node selections will be reset so you can configure them for the new dashboard.'),confirmLabel:"Duplicate",handleConfirm:O,handleDecline:w,isConfirmPositive:!0,hideIcon:!0,"data-testid":"dashboardHeader-duplicate-confirm","data-ga":"header::confirm-duplicate::cust-dashboard"})]})},st=e=>{let{id:t}=e;return(0,j.jsxs)(o.Flex,{justifyContent:"between",alignItems:"center",padding:[4,0],"data-testid":"dashboardHeader",children:[(0,j.jsx)(Re,{id:t}),(0,j.jsxs)(o.Flex,{gap:4,alignItems:"center",children:[(0,j.jsx)(Ze,{id:t}),(0,j.jsx)(Ue,{id:t})]})]})},at=e=>{let{id:t,isEditMode:n,onOpenDuplicateWizard:r}=e;return n?(0,j.jsx)(st,{id:t}):(0,j.jsx)(lt,{id:t,onOpenDuplicateWizard:r})},it=(0,r.memo)(at);var ct=n(85877);const dt="typography",ut="metrics",ht="functions",xt="logs",gt="feed",pt="infrastructure",ft="roomOverview",bt=[{id:dt,icon:"text_add",tooltip:"Typography"},{id:ut,icon:"room_overview",tooltip:"Metrics"},{id:ht,icon:"live",tooltip:"Live"},{id:xt,icon:"logs",tooltip:"Logs"},{id:gt,icon:"feed",tooltip:"Events"},{id:pt,icon:"nodes_hollow",tooltip:"Infrastructure"},{id:ft,icon:"room_home",tooltip:"Room Overview"}],jt=(0,O.default)(o.Flex).attrs((e=>{let{$active:t}=e;return{alignItems:"center",justifyContent:"center",cursor:"pointer",padding:[3,4],round:.5,border:{side:"all",color:"primary"},background:t?"primary":"transparent",_hover:t?{background:"primary"}:{background:"primary",backgroundOpacity:.1},zIndex:51}})).withConfig({displayName:"toolbar__ToolbarButtonContainer",componentId:"sc-18uufnr-0"})(["transition:background 0.15s;"]),mt=e=>{let{id:t,icon:n,tooltip:r,isActive:l,onClick:s}=e;return(0,j.jsx)(jt,{"data-testid":"toolbar-button-".concat(t),$active:l,onClick:s,title:r,children:(0,j.jsx)(o.Icon,{name:n,color:l?"mainBackground":"primary",width:"16px",height:"16px"})})},vt=()=>{const e=(0,c.wz)(),t=(0,c.ww)();return(0,j.jsx)(o.Flex,{"data-testid":"palette-toolbar",column:!0,alignItems:"center",justifyContent:"center",padding:[0,2],gap:6,height:"100%",children:bt.map((n=>(0,j.jsx)(mt,{id:n.id,icon:n.icon,tooltip:n.tooltip,isActive:e===n.id,onClick:()=>t(n.id)},n.id)))})};var yt=n(25616);function wt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Ot(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?wt(Object(n),!0).forEach((function(t){(0,p.A)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):wt(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}const It=e=>{let{item:t}=e;const{context:n,metadata:l,nodeIds:s}=t,a=(0,q.eg)(),i=(0,E.vt)(),c=(0,h.ID)(),d=(0,B.K)({spaceId:i,roomId:c}),u="preview-".concat(n),x=(0,r.useMemo)((()=>{a.getNodes({id:u}).forEach((e=>e.destroy()));const{info:e,valueRange:t,height:r,colors:o}=(0,z.Ay)(l),i=a.makeChart({attributes:Ot({id:u,contextScope:[n],host:d,roomId:c,info:e,valueRange:t,height:(r||0)+207,enabledNavigation:!1,nodesScope:s},o&&{colors:o})});return a.getRoot().appendChild(i),i}),[a,n,u,d,c,l,s]);return(0,r.useLayoutEffect)((()=>()=>x.destroy()),[x]),(0,j.jsx)(o.Flex,{height:{min:"320px"},column:!0,children:(0,j.jsx)(G.A,{chart:x,margin:[2,0,0]})})};var Ct=n(31522),St=n(65067),kt=n(56452);const Ft=e=>{let{item:t}=e;const{selectedNodeIds:n,groupBy:r=[],colorBy:l=Ct.jZ}=t.config,s=(0,N.CK)(),a=(0,N.nj)(),i=null!==n&&void 0!==n&&n.length?n:s,c=(0,g.Gt)(i);return(0,j.jsxs)(St.A,{column:!0,overflow:"hidden",background:"elementBackground",border:{side:"all",color:"borderSecondary"},children:[(0,j.jsx)(o.Flex,{padding:[2,3],children:(0,j.jsx)(o.Text,{strong:!0,children:"Node Grid"})}),(0,j.jsx)(o.Flex,{flex:!0,overflow:"auto",children:(0,j.jsx)(kt.A,{nodes:c,groupBy:r,colorBy:l,loaded:a})})]})};var At=n(49181),Pt=n(59092);const Tt={nodeStatus:e=>(0,At.GM)(e.state),alertStatus:e=>{if((e.alerts_critical||0)>0)return"Critical";return(e.alerts_warning||0)>0?"Warning":"No alerts"}},Nt=e=>{let{item:t}=e;const{selectedNodeIds:n,groupBy:l}=t.config,s=(0,N.CK)(),a=(0,N.nj)(),i=null!==n&&void 0!==n&&n.length?n:s,c=(0,g.Gt)(i),d=(0,r.useMemo)((()=>(e=>{const t={reachable:0,stale:1,unreachable:2,created:3};return[...e].sort(((e,n)=>{var r,o;return(null!==(r=t[e.state])&&void 0!==r?r:4)-(null!==(o=t[n.state])&&void 0!==o?o:4)}))})(c)),[c]),u=(0,r.useMemo)((()=>{const e=Tt[l];if(!e)return null;const t={};return d.forEach((n=>{const r=e(n);t[r]||(t[r]=[]),t[r].push(n)})),Object.entries(t)}),[d,l]);return(0,j.jsxs)(St.A,{column:!0,overflow:"hidden",background:"elementBackground",border:{side:"all",color:"borderSecondary"},children:[(0,j.jsx)(o.Flex,{padding:[2,3],children:(0,j.jsx)(o.Text,{strong:!0,children:"Node List (".concat(c.length,")")})}),(0,j.jsx)(o.Flex,{flex:!0,column:!0,overflow:"auto",children:(0,j.jsx)(Pt.A,{nodes:d,groupedNodes:u,loaded:a,nodeCount:c.length})})]})};n(25509),n(65223),n(60321),n(41927),n(11632),n(64377),n(66771),n(12516),n(68931),n(52514),n(35694),n(52774),n(49536),n(21926),n(94483),n(16215);var Dt=n(41716),Et=n(19075),Lt=n(94230);const Mt=e=>{let{item:t}=e;const{selectedNodeIds:n}=t.config,l=(0,Dt.s)("ids")||[],s=(0,Dt.s)("loaded"),a=(0,Et.Gq)(l),i=(0,r.useMemo)((()=>null!==n&&void 0!==n&&n.length?new Set(n):null),[n]),{critical:c,warning:d}=(0,r.useMemo)((()=>(i?a.filter((e=>i.has(e.nodeId))):a).reduce(((e,t)=>{let{status:n}=t;return e[n]=(e[n]||0)+1,e}),{critical:0,warning:0,clear:0})),[a,i]);return(0,j.jsxs)(St.A,{column:!0,overflow:"hidden",background:"elementBackground",border:{side:"all",color:"borderSecondary"},children:[(0,j.jsx)(o.Flex,{padding:[2,3],children:(0,j.jsx)(o.Text,{strong:!0,children:"Alert Status"})}),(0,j.jsx)(o.Flex,{flex:!0,column:!0,overflow:"hidden",children:(0,j.jsx)(Lt.A,{critical:c,warning:d,loaded:s})})]})};var zt=n(95760);const Bt=e=>{let{item:t}=e;const{selectedNodeIds:n}=t.config,l=(0,N.CK)(),s=null!==n&&void 0!==n&&n.length?n:l,a=(0,g.Gt)(s),i=(0,N.nj)(),c=(0,Dt.s)("ids")||[],d=(0,Dt.s)("loaded"),u=(0,Et.Gq)(c),h=i&&d,x=(0,r.useMemo)((()=>{const e={};return u.forEach((t=>{var n;if(!t.nodeId)return;e[t.nodeId]||(e[t.nodeId]={critical:[],warning:[]});const r=null===(n=t.status)||void 0===n?void 0:n.toLowerCase();"critical"===r?e[t.nodeId].critical.push(t):"warning"===r&&e[t.nodeId].warning.push(t)})),a.map((t=>{var n,r;return{node:t,criticalAlerts:(null===(n=e[t.id])||void 0===n?void 0:n.critical)||[],warningAlerts:(null===(r=e[t.id])||void 0===r?void 0:r.warning)||[]}})).filter((e=>{let{criticalAlerts:t,warningAlerts:n}=e;return t.length>0||n.length>0})).sort(((e,t)=>{const n=1e3*e.criticalAlerts.length+e.warningAlerts.length;return 1e3*t.criticalAlerts.length+t.warningAlerts.length-n}))}),[a,u]);return(0,j.jsxs)(St.A,{column:!0,overflow:"hidden",background:"elementBackground",border:{side:"all",color:"borderSecondary"},children:[(0,j.jsx)(o.Flex,{padding:[2,3],children:(0,j.jsx)(o.Text,{strong:!0,children:"Alerts Per Node"})}),(0,j.jsx)(o.Flex,{flex:!0,column:!0,overflow:"auto",children:(0,j.jsx)(zt.A,{nodesWithAlerts:x,nodeCount:a.length,loaded:h})})]})};var Rt=n(52346);const Gt=72e5,qt=3e5,_t=e=>{let{item:t}=e;const{selectedNodeIds:n}=t.config,l=(0,Dt.s)("ids")||[],s=(0,Dt.s)("loaded"),a=(0,Et.Gq)(l),i=(0,N.CK)(),c=null!==n&&void 0!==n&&n.length?n:i,{buckets:d,maxTotal:u,totalAlerts:h}=(0,r.useMemo)((()=>{const e=Date.now(),t=e-Gt,r=Array.from({length:24},((e,n)=>({ts:t+n*qt,critical:0,warning:0}))),o=null!==n&&void 0!==n&&n.length?a.filter((e=>c.includes(e.nodeId))):a;o.forEach((n=>{var o;if(!n.lastUpdated)return;const l=1e3*n.lastUpdated;if(l<t||l>e)return;const s=Math.floor((l-t)/qt);if(s<0||s>=24)return;const a=null===(o=n.status)||void 0===o?void 0:o.toLowerCase();"critical"===a?r[s].critical++:"warning"===a&&r[s].warning++}));const l=Math.max(...r.map((e=>e.critical+e.warning)),1),s=o.filter((n=>{var r;const o=null===(r=n.status)||void 0===r?void 0:r.toLowerCase();if("critical"!==o&&"warning"!==o)return!1;if(!n.lastUpdated)return!1;const l=1e3*n.lastUpdated;return l>=t&&l<=e})).length;return{buckets:r,maxTotal:l,totalAlerts:s}}),[a,n,c]);return(0,j.jsxs)(St.A,{column:!0,overflow:"hidden",background:"elementBackground",border:{side:"all",color:"borderSecondary"},children:[(0,j.jsx)(o.Flex,{padding:[2,3],children:(0,j.jsx)(o.Text,{strong:!0,children:"Alerts by Hour (".concat(h,")")})}),(0,j.jsx)(o.Flex,{flex:!0,column:!0,overflow:"hidden",padding:[2],children:(0,j.jsx)(Rt.A,{buckets:d,maxTotal:u,totalAlerts:h,loaded:s})})]})};var Vt=n(77125);const Wt=e=>{let{item:t}=e;const{selectedNodeIds:n,visibleItems:l}=t.config,s=(0,N.CK)(),a=null!==n&&void 0!==n&&n.length?n:s,i=(0,g.Gt)(a),c=(0,N.nj)(),d=(0,Dt.s)("ids")||[],u=(0,Dt.s)("loaded"),h=(0,Et.Gq)(d),x=c&&u,p=(0,r.useMemo)((()=>new Set(a)),[a]),f=(0,r.useMemo)((()=>{const e={Live:0,Stale:0,Offline:0,Unseen:0};return i.forEach((t=>{const n=(0,At.GM)(t.state);e[n]=(e[n]||0)+1})),e}),[i]),{critical:b,warning:m,clear:v}=(0,r.useMemo)((()=>(null!==n&&void 0!==n&&n.length?h.filter((e=>p.has(e.nodeId))):h).reduce(((e,t)=>{let{status:n}=t;return e[n]=(e[n]||0)+1,e}),{critical:0,warning:0,clear:0})),[h,n,p]);return(0,j.jsxs)(St.A,{column:!0,overflow:"hidden",background:"elementBackground",border:{side:"all",color:"borderSecondary"},children:[(0,j.jsx)(o.Flex,{padding:[2,3],children:(0,j.jsx)(o.Text,{strong:!0,children:"Nodes (".concat(Object.values(f).reduce(((e,t)=>e+t),0),")")})}),(0,j.jsx)(o.Flex,{flex:!0,column:!0,overflow:"auto",children:(0,j.jsx)(Vt.A,{statusCounts:f,critical:b,warning:m,clear:v,visibleItems:l,loaded:x})})]})};var Ht=n(58533),Kt=n(87242);const Ut=[],Qt=e=>{let{item:t}=e;const{visibleItems:n}=t.config||{},{loaded:l,metricsCollected:s=0}=(0,Ht.VH)(),a=(0,E.vt)(),i=(0,h.ID)(),{charts:c,loaded:d,error:u}=(0,M.A)(a,i,Ut),x=Object.keys(c).length,{loaded:g,value:p}=(0,Et.oU)(),f=(null===p||void 0===p?void 0:p.length)||0,b=(0,r.useMemo)((()=>[{id:"metrics",label:"Metrics available",value:s,loaded:l},{id:"charts",label:"Charts visualized",value:x,loaded:d&&!u},{id:"alerts",label:"Alerts configured",value:f,loaded:g}].filter((e=>!n||n.includes(e.id)))),[s,l,x,d,u,f,g,n]);return(0,j.jsxs)(St.A,{column:!0,overflow:"hidden",background:"elementBackground",border:{side:"all",color:"borderSecondary"},children:[(0,j.jsx)(o.Flex,{padding:[2,3],children:(0,j.jsx)(o.Text,{strong:!0,children:"Stats Overview"})}),(0,j.jsx)(o.Flex,{flex:!0,alignItems:"center",justifyContent:"center",gap:4,children:(0,j.jsx)(Kt.A,{stats:b})})]})};var Jt=n(46025);const Yt=e=>{let{item:t}=e;const{dataRetention:n,loaded:r}=(0,Ht.VH)();return(0,j.jsxs)(St.A,{column:!0,overflow:"hidden",background:"elementBackground",border:{side:"all",color:"borderSecondary"},children:[(0,j.jsx)(o.Flex,{padding:[2,3],children:(0,j.jsx)(o.Text,{strong:!0,children:"Data Retention per Node"})}),(0,j.jsx)(o.Flex,{flex:!0,overflow:"hidden",padding:[2,3,3],children:r?null!==n&&void 0!==n&&n.length?(0,j.jsx)(Jt.A,{dataRetention:n}):(0,j.jsx)(o.Flex,{flex:!0,alignItems:"center",justifyContent:"center",children:(0,j.jsx)(o.Text,{color:"textLite",children:"No retention data"})}):(0,j.jsx)(o.Flex,{flex:!0,alignItems:"center",justifyContent:"center",children:(0,j.jsx)(o.Text,{color:"textLite",children:"Loading..."})})})]})};var Zt=n(7761),$t=n(39431);const Xt=e=>{let{item:t}=e;const{visibleItems:n}=t.config||{},r=(0,Zt.jg)();return(0,j.jsxs)(St.A,{column:!0,overflow:"hidden",background:"transparent",border:{side:"all",color:"borderSecondary"},children:[(0,j.jsx)(o.Flex,{padding:[2,3],children:(0,j.jsx)(o.Text,{strong:!0,children:"Nodes with most alerts (24h)"})}),(0,j.jsx)(o.Flex,{flex:!0,column:!0,overflow:"auto",gap:3,children:(0,j.jsx)($t.A,{alertsStats:r,visibleItems:n,loaded:r.loaded})})]})};var en=n(19529);const tn=e=>{let{item:t}=e;const{visibleItems:n}=t.config||{},{loaded:l,totalParents:s,totalChildren:a,totalStandalone:i,replicationFactor:c}=(0,Zt.c8)(),d=(0,r.useMemo)((()=>[{label:"Parents",value:s,color:["blue","indigo"],id:"parents"},{label:"Children",value:a,color:["purple","lilac"],id:"children"},{label:"Standalone",value:i,color:["yellow","yellow120"],id:"standalone"}].filter((e=>!n||n.includes(e.id)))),[s,a,i,n]),u=(0,r.useMemo)((()=>[{label:"None",value:(null===c||void 0===c?void 0:c.r_1)||0,color:Ct.q5.r_1,id:"none"},{label:"Single",value:(null===c||void 0===c?void 0:c.r_2)||0,color:Ct.q5.r_2,id:"single"},{label:"Multi",value:(null===c||void 0===c?void 0:c["r_*"])||0,color:Ct.q5["r_*"],id:"multi"}].filter((e=>!n||n.includes(e.id)))),[c,n]);return(0,j.jsxs)(St.A,{column:!0,overflow:"hidden",background:"elementBackground",border:{side:"all",color:"borderSecondary"},children:[(0,j.jsx)(o.Flex,{padding:[2,3],children:(0,j.jsx)(o.Text,{strong:!0,children:"Replication"})}),(0,j.jsx)(o.Flex,{flex:!0,column:!0,overflow:"auto",gap:3,children:(0,j.jsx)(en.A,{topologyData:d,replicationData:u,loaded:l})})]})};var nn=n(81989),rn=n(44252),on=n(13607),ln=n(40580),sn=n(81445),an=n(71488);function cn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function dn(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?cn(Object(n),!0).forEach((function(t){(0,p.A)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):cn(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}const un=e=>{let{item:t}=e;const{selectedFn:n,flavour:l,visibleItems:s,nodeIds:a,fnType:i,acceptedParams:c,functionParamsFilters:d,defaultCharts:u,displayName:h}=t.config,{loading:x,loaded:g,data:p,columns:f,error:b,sortedColumns:m,sortColumn:v,sortDirection:y,columnVisibility:w,pinnedColumns:O,groupByColumns:I,manualSorting:C,charts:S,onRefresh:k,histogram:F,availableHistograms:A,customCharts:P}=(0,ln.A)({selectedFn:n,selectedNodeIds:a,fnType:i,acceptedParams:c,functionParamsFilters:d}),T=!s||s.includes("charts"),N=!s||s.includes("table"),D=T&&!(null===u||void 0===u||!u.length),E=T&&!!F,L=T&&!!P,M="feed"===l,z=(0,r.useCallback)((()=>{}),[]);return(0,j.jsxs)(St.A,{column:!0,overflow:"hidden",background:"transparent",border:{side:"all",color:"borderSecondary"},children:[(0,j.jsx)(o.Flex,{padding:[2,3],children:(0,j.jsx)(o.Text,{strong:!0,children:h||n||"Function"})}),(0,j.jsxs)(o.Flex,{flex:!0,column:!0,overflow:"hidden",children:[!g&&x&&(0,j.jsx)(o.Flex,{flex:!0,alignItems:"center",justifyContent:"center",children:(0,j.jsx)(o.Text,{color:"textLite",children:"Loading..."})}),b&&(0,j.jsx)(o.Flex,{padding:[2,3],alignItems:"center",children:(0,j.jsx)(o.Text,{color:"error",children:"string"===typeof b?b:b.errorMessage||"Error"})}),g&&(D||N||E||L)&&(0,j.jsxs)(o.Flex,{flex:!0,column:!0,overflow:"hidden",gap:2,children:[E&&(0,j.jsx)(nn.A,dn(dn({},N&&{height:"380px"}),{},{histogram:F,availableHistograms:A,data:p,histogramId:null===F||void 0===F?void 0:F.id,filters:(d||{})[null===F||void 0===F?void 0:F.id]||null,onFiltersChange:z,toolboxReload:e=>{let{disabled:t}=e;return(0,j.jsx)(on.A,{onRefresh:k,loading:x,testId:"preview-function-histogram",dataGa:"preview-function-histogram"})},hideToolbox:!0,nodeIds:a,fn:n})),D&&(0,j.jsx)(an.A,{defaultCharts:u,charts:S,data:p,columns:f,groupByColumns:I,loaded:g,selectedFn:n,onRefresh:k,loading:x,compact:N,hideToolbox:!0}),L&&(0,j.jsx)(rn.A,{customCharts:P,data:p,containerWidth:0,paramsKey:{extraKey:"preview"}}),N&&(0,j.jsx)(sn.A,{title:(0,j.jsx)(on.A,{onRefresh:k,loading:x,testId:"preview-function-table",dataGa:"preview-function-table"}),data:p,columns:f,sortedColumns:m,sortColumn:v,sortDirection:y,columnVisibility:w,pinnedColumns:O,groupByColumns:I,loaded:g,manualSorting:C,isFeed:M})]}),g&&!D&&!N&&!E&&!L&&(0,j.jsx)(o.Flex,{flex:!0,alignItems:"center",justifyContent:"center",children:(0,j.jsx)(o.Text,{color:"textLite",children:T?"No chart data":"No table data"})})]})]})},hn={chart:It,text:null,nodeGrid:Ft,nodeList:Nt,alertStatus:Mt,alertsPerNode:Bt,hourlyAlerts:_t,nodeStats:Wt,statsOverview:Qt,dataRetention:Yt,alertNodes:Xt,replicationStats:tn,function:un},xn=e=>{let{item:t}=e;const n=hn[t.type];return n?(0,j.jsx)(yt.Ay,{fallback:(0,j.jsx)(yt.dK,{canRetry:!1}),children:(0,j.jsx)(n,{item:t})}):null},gn=e=>{let{items:t}=e;return(0,j.jsx)(o.Flex,{column:!0,gap:3,overflow:"auto",width:"100%",children:t.map((e=>{var t,n;return(0,j.jsx)(xn,{item:e},e.type+"-"+(e.context||(null===(t=e.config)||void 0===t?void 0:t.textType)||(null===(n=e.config)||void 0===n?void 0:n.selectedFn)||""))}))})},pn=e=>{let{title:t}=e;return(0,j.jsx)(o.Text,{color:"text",fontSize:"12px",lineHeight:"16px",children:t})},fn=e=>{let{label:t="Import",onClick:n,disabled:r}=e;return(0,j.jsx)(o.Flex,{justifyContent:"end",padding:[4,0],children:(0,j.jsx)(o.Button,{label:t,onClick:n,disabled:r})})};function bn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function jn(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?bn(Object(n),!0).forEach((function(t){(0,p.A)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):bn(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}const mn={title:!1,subtitle:!1,body:!1},vn={title:o.H1,subtitle:o.H4,body:o.TextBig},yn=e=>{let{type:t,label:n,preview:r,checked:l,onToggle:s}=e;const a=vn[t];return(0,j.jsxs)(o.Flex,{column:!0,gap:2,padding:[2,3],border:{side:"all",color:"border"},width:"100%",height:{min:"78px"},children:[(0,j.jsxs)(o.Flex,{alignItems:"center",gap:1,children:[(0,j.jsx)(o.Checkbox,{checked:l,onChange:s}),(0,j.jsx)(o.Text,{color:"text",children:n})]}),(0,j.jsx)(a,{color:"textFocus",children:r})]})},wn=e=>{let{dashboardId:t,onPreviewChange:n}=e;const[l,s]=(0,r.useState)(mn),a=(0,L.Kv)(t),i=(0,c.WM)(),d=e=>s((t=>jn(jn({},t),{},{[e]:!t[e]})));(0,r.useEffect)((()=>{if(!n)return;const e=[];l.title&&e.push({type:"text",config:{textType:"title"}}),l.subtitle&&e.push({type:"text",config:{textType:"subtitle"}}),l.body&&e.push({type:"text",config:{textType:"body"}}),n(e)}),[l,n]);const u=l.title||l.subtitle||l.body;return(0,j.jsxs)(o.Flex,{column:!0,gap:2,flex:!0,children:[(0,j.jsx)(pn,{title:"Titles and text"}),(0,j.jsxs)(o.Flex,{column:!0,gap:2.5,children:[(0,j.jsx)(yn,{type:"title",label:"Title",preview:"Heading 1",checked:l.title,onToggle:()=>d("title")}),(0,j.jsx)(yn,{type:"subtitle",label:"Subtitle",preview:"Heading 2",checked:l.subtitle,onToggle:()=>d("subtitle")}),(0,j.jsx)(yn,{type:"body",label:"Body",preview:"Lorem Ipsum",checked:l.body,onToggle:()=>d("body")})]}),(0,j.jsx)(fn,{label:"Import components",onClick:()=>{let e=null;l.title&&(e=a({dashboardId:t,textType:"title"})),l.subtitle&&(e=a({dashboardId:t,textType:"subtitle"})),l.body&&(e=a({dashboardId:t,textType:"body"})),s(mn),i(null),e&&requestAnimationFrame((()=>{requestAnimationFrame((()=>{const t=document.querySelector('[data-id="'.concat(e,'"]'));t&&t.scrollIntoView({behavior:"smooth",block:"nearest"})}))}))},disabled:!u})]})};n(25440),n(23215);var On=n(50694),In=n(58243),Cn=n(41061);const Sn=(e,t,n)=>{const o=(0,g.Gt)(e),l=(0,h.ID)(),s=(0,On.Jk)(l);return(0,r.useMemo)((()=>{if((null===t||void 0===t?void 0:t.length)>0)return t;const e=n?Object.entries(n).filter((e=>{let[,t]=e;return(null===t||void 0===t?void 0:t.length)>0})):[];if(0===e.length)return[];return o.filter((t=>e.every((e=>{let[n,r]=e;if("selectedGroups"===n)return r.some((e=>{const n=Cn.E9.find((t=>t.id===e));if(n)return n.showFn(t);const r=null===s||void 0===s?void 0:s.find((t=>t.id===e));return!!r&&(0,In.BW)(t,r.filters,r.selectedNodeIds)}));if("nodeStatuses"===n)return r.includes(t.nodeStatus);if("nodeVersions"===n)return r.includes(t.version);if("nodeCapabilities"===n)return r.some((e=>t.capabilities&&e in t.capabilities));var o;if("os.nm"===n)return r.includes(null===(o=t.os)||void 0===o?void 0:o.nm);if(n.startsWith("label.")){const e=n.replace("label.","");return t.labels&&r.some((n=>{const[,r]=n.includes("|")?n.split("|",2):[e,n];return t.labels[e]===r}))}return!0})))).map((e=>e.id))}),[o,t,n,s])},kn=e=>{let{label:t}=e;return(0,j.jsx)(o.Text,{color:"textLite",fontSize:"11px",lineHeight:"14px",children:t})};var Fn=n(98054),An=n(33099),Pn=n(47427);const Tn=["children"];function Nn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Dn(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Nn(Object(n),!0).forEach((function(t){(0,p.A)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Nn(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}const En=e=>{let{children:t}=e,n=(0,f.A)(e,Tn);return(0,j.jsx)(o.Flex,Dn(Dn({alignItems:"center",gap:2,padding:[1,2],cursor:"pointer",_hover:{background:"borderSecondary"}},n),{},{children:t}))},Ln=e=>{let{dashboardId:t,onPreviewChange:n}=e;const[l,s]=(0,r.useState)(new Set),[a,i]=(0,r.useState)(null),[d,u]=(0,r.useState)(null),[h,x]=(0,r.useState)([]),[g,p]=(0,r.useState)({}),f=(0,N.CK)(),b=Sn(f,h,g),{menuIds:m,menuById:v,roomCharts:y}=(0,An.A)(b),w=(0,L.nM)(t),O=(0,c.WM)(),I=(0,q.eg)();(0,r.useEffect)((()=>{if(!n)return;const e=setTimeout((()=>{const e=Array.from(l).filter((e=>y[e])).map((e=>({type:"chart",context:e,metadata:y[e],nodeIds:b})));n(e)}),150);return()=>clearTimeout(e)}),[l,b,y,n]);const C=(0,r.useMemo)((()=>d?m.filter((e=>{var t;const n=v[e];return!!n&&(null===(t=n.contexts)||void 0===t?void 0:t.some((e=>d.has(e))))})):m),[m,v,d]),S=(0,r.useMemo)((()=>{if(!a||!v[a])return[];const e=(v[a].contexts||[]).filter((e=>y[e])).map((e=>({id:e,context:e,title:y[e].title||e})));return d?e.filter((e=>d.has(e.context))):e}),[a,v,y,d]),k=(0,r.useCallback)((e=>{s((t=>{const n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}))}),[]),F=(0,r.useCallback)((()=>{const e=b.length>0?{nodesScope:b}:{},t=Array.from(l),n=t.length;let r=null;t.forEach(((t,o)=>{const l=1===n||3===n&&2===o?12:6;let s={};const a=I.getNode({id:"preview-".concat(t)});a&&(s=(0,Q.h)(a.getAttributes())),w([t],Dn(Dn(Dn({},e),s),{},{itemLayout:{width:l}}),(e=>{r=e.id}))})),s(new Set),O(null),r&&requestAnimationFrame((()=>{requestAnimationFrame((()=>{const e=document.querySelector('[data-id="'.concat(r,'"]'));e&&e.scrollIntoView({behavior:"smooth",block:"nearest"})}))}))}),[l,w,b,O,I]),A=(0,r.useCallback)((e=>{var t;return null===(t=e.contexts)||void 0===t?void 0:t.some((e=>y[e]))}),[y]),P=l.size>0,T=m.length>0;return(0,j.jsxs)(o.Flex,{column:!0,height:"100%",gap:1,overflow:"hidden",children:[(0,j.jsx)(pn,{title:"Metrics"}),(0,j.jsx)(kn,{label:"Select Nodes"}),(0,j.jsx)(fe.A,{nodeIds:f,selectedNodeIds:h,setSelectedNodeIds:x,filters:g,setFilters:p}),(0,j.jsx)(kn,{label:"Select Metrics"}),(0,j.jsx)(Pn.A,{onFilteredContextIdsChange:u}),(0,j.jsxs)(o.Flex,{height:"100%",overflow:"hidden",children:[(0,j.jsx)(o.Flex,{column:!0,width:"280px",overflow:{vertical:"auto"},padding:[2,0],border:{side:"right",color:"borderSecondary"},children:T?(0,j.jsx)(Fn.A,{menuIds:C,menuById:v,selectedId:a,onSelect:i,isItemVisible:A}):(0,j.jsx)(o.Flex,{padding:[4],justifyContent:"center",children:(0,j.jsx)(o.Text,{color:"textLite",children:"Loading categories..."})})}),(0,j.jsxs)(o.Flex,{column:!0,flex:!0,overflow:{vertical:"auto"},padding:[2,0],children:[!a&&(0,j.jsx)(o.Flex,{padding:[4],justifyContent:"center",children:(0,j.jsx)(o.Text,{color:"textLite",children:"Select a category"})}),a&&0===S.length&&(0,j.jsx)(o.Flex,{padding:[4],justifyContent:"center",children:(0,j.jsx)(o.Text,{color:"textLite",children:"No metrics in this category"})}),S.map((e=>(0,j.jsxs)(En,{onClick:()=>k(e.context),children:[(0,j.jsx)(o.Checkbox,{checked:l.has(e.context),onChange:t=>{t.stopPropagation(),k(e.context)}}),(0,j.jsx)(o.Text,{ellipsis:!0,children:e.title})]},e.id)))]})]}),(0,j.jsx)(fn,{label:P?"Import (".concat(l.size,")"):"Import",onClick:F,disabled:!P})]})};var Mn=n(16373);const zn=e=>{let{value:t,onChange:n}=e;return(0,j.jsx)(o.TextInput,{value:t,onChange:e=>n(e.target.value),placeholder:"Search functions...",iconLeft:(0,j.jsx)(o.Icon,{name:"magnify",color:"textLite",size:"small"}),width:"100%",height:"32px"})};var Bn=n(15744);const Rn=(e,t)=>(0,r.useMemo)((()=>{const n=t?e.filter((e=>e.name.toLowerCase().includes(t.toLowerCase()))):e,r={},o=[],l=new Set;Bn.A.forEach((e=>{const t=e.id||e.title.toLowerCase(),s=n.filter((t=>{return n=t.name,!!(null===(r=e.match)||void 0===r?void 0:r.some((e=>n===e||n.startsWith(e+"-")||n.startsWith(e))))&&(l.add(t.slug),!0);var n,r}));if(!s.length)return;o.push(t);const a=s.map((e=>e.slug));r[t]={name:e.title,icon:e.icon,childrenIds:a,descendantIds:a},s.forEach((e=>{r[e.slug]={name:e.name,slug:e.slug,isFunction:!0}}))}));const s=n.filter((e=>!l.has(e.slug)));if(s.length)if(s.forEach((e=>{r[e.slug]={name:e.name,slug:e.slug,isFunction:!0}})),o.length>0){o.push("other");const e=s.map((e=>e.slug));r.other={name:"Other",childrenIds:e,descendantIds:e}}else s.forEach((e=>o.push(e.slug)));return{menuIds:o,menuById:r}}),[e,t]);var Gn=n(1011),qn=n(84103);function _n(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Vn(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?_n(Object(n),!0).forEach((function(t){(0,p.A)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):_n(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}const Wn={type:"table"},Hn=(e,t,n)=>{const[o,l]=(0,r.useState)({loading:!1,data:null,error:null}),s=(0,h.ID)(),a=(0,g.yN)(t),i=(0,r.useRef)(!1);return(0,r.useEffect)((()=>{if(!e)return void l({loading:!1,data:null,error:null});if("feed"===n)return void l({loading:!1,data:Wn,error:null});if(null===t||void 0===t||!t.length)return void l({loading:!1,data:null,error:null});i.current=!1,l((e=>Vn(Vn({},e),{},{loading:!0,error:null})));const r=Date.now();return(0,qn.JJ)({roomId:s,cloudNodeIds:a,nodeIds:t,fn:e,after:r-9e5,before:r,transactionId:(0,Gn.A)()}).then((e=>{if(i.current)return;const t=(null===e||void 0===e?void 0:e.data)||e;l({loading:!1,data:t,error:null})})).catch((e=>{i.current||l({loading:!1,data:null,error:e})})),()=>{i.current=!0}}),[e,s,null===t||void 0===t?void 0:t.length,null===a||void 0===a?void 0:a[0]]),o};var Kn=n(7414),Un=n(380);const Qn=e=>{let{flavour:t,visibleItems:n,onToggle:r,defaultCharts:o}=e;const l=(0,Kn.nV)({defaultCharts:o},t);return l.length<=1?null:(0,j.jsx)(Un.A,{items:l,selected:n,onChange:r})},Jn={fn:"Live",logs:"Logs",feed:"Events"},Yn={fn:"Select Function",logs:"Logs Viewer",feed:"Select Event"},Zn=e=>{var t,n;let{flavour:l,dashboardId:s,onPreviewChange:a}=e;const[i,d]=(0,r.useState)([]),[u,h]=(0,r.useState)({}),[x,g]=(0,r.useState)(""),[p,f]=(0,r.useState)(null),[b,m]=(0,r.useState)(["charts","table"]),[v,y]=(0,r.useState)({}),w="feed"===l,O=(0,N.CK)();(0,r.useEffect)((()=>{!w&&0===i.length&&O.length>0&&d([O[0]])}),[w,O]);const I=Sn(O,i,u),{loaded:C,value:S}=(0,Mn.vx)({},l),k=(0,r.useMemo)((()=>I.length?S.filter((e=>I.some((t=>{var n;return null===(n=e.nodes)||void 0===n?void 0:n[t]})))):S),[S,I]),{menuIds:F,menuById:A}=Rn(k,x),P=F.length>1||!(null===(t=A[F[0]])||void 0===t||null===(t=t.childrenIds)||void 0===t||!t.length);(0,r.useEffect)((()=>{if(!p||!A[p]){for(const t of F){var e;const n=A[t];if(null!==n&&void 0!==n&&n.isFunction)return void f(t);if(null!==n&&void 0!==n&&null!==(e=n.childrenIds)&&void 0!==e&&e.length)return void f(n.childrenIds[0])}f(null)}}),[F,A]);const T=(0,L.VI)(s),D=(0,c.WM)(),E="feed"!==l,M=I.length>0,z=M?I:E?[]:O,{loading:B,data:R}=Hn(p,z,l);(0,r.useEffect)((()=>{var e;a&&a(p&&!B&&R?[{type:"function",config:{selectedFn:p,flavour:l,visibleItems:b,nodeIds:z,fnType:R.type||"",displayName:(null===(e=A[p])||void 0===e?void 0:e.name)||"",defaultCharts:R.defaultCharts||[],acceptedParams:R.acceptedParams||[],functionParamsFilters:v}}]:[])}),[p,b,v,z,R,B,a,l,A]);const G=(0,r.useCallback)((e=>{f((t=>t===e?null:e)),m(["charts","table"]),y({})}),[]),q=!!p&&!!R&&!B&&(!E||M),_=(0,r.useCallback)((()=>{var e;if(!q)return;const t=T({dashboardId:s,flavour:l,selectedFn:p,displayName:(null===(e=A[p])||void 0===e?void 0:e.name)||"",selectedNodeIds:z,visibleItems:b,fnType:R.type||"",defaultCharts:R.defaultCharts||[],acceptedParams:R.acceptedParams||[],requiredParams:R.requiredParams||[],columns:R.columns||{},functionParamsFilters:v});D(null),t&&requestAnimationFrame((()=>{requestAnimationFrame((()=>{const e=document.querySelector('[data-id="'.concat(t,'"]'));e&&e.scrollIntoView({behavior:"smooth",block:"nearest"})}))}))}),[q,T,s,l,p,A,z,b,R,v,D]);return E&&!M?(0,j.jsxs)(o.Flex,{column:!0,height:"100%",gap:1,overflow:"hidden",children:[(0,j.jsx)(pn,{title:Jn[l]||"Live"}),(0,j.jsx)(kn,{label:"Select Node"}),(0,j.jsx)(fe.A,{nodeIds:O,selectedNodeIds:i,setSelectedNodeIds:d,filters:u,setFilters:h,multi:!1}),(0,j.jsx)(o.Flex,{flex:!0,alignItems:"center",justifyContent:"center",children:(0,j.jsx)(o.Text,{color:"textLite",children:"Select a node to see available functions"})})]}):(0,j.jsxs)(o.Flex,{column:!0,height:"100%",gap:1,overflow:"hidden",children:[(0,j.jsx)(pn,{title:Jn[l]||"Live"}),"feed"!==l&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(kn,{label:w?"Select Nodes":"Select Node"}),(0,j.jsx)(fe.A,{nodeIds:O,selectedNodeIds:i,setSelectedNodeIds:d,filters:u,setFilters:h,multi:w})]}),!w&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(kn,{label:"Search"}),(0,j.jsx)(zn,{value:x,onChange:g})]}),(0,j.jsxs)(o.Flex,{height:"100%",overflow:"hidden",children:[P&&(0,j.jsxs)(o.Flex,{column:!0,width:"280px",overflow:{vertical:"auto"},padding:[2,0],border:{side:"right",color:"borderSecondary"},children:[(0,j.jsx)(kn,{label:Yn[l]||"Select Function"}),F.length>0?(0,j.jsx)(Fn.A,{menuIds:F,menuById:A,selectedId:p,onSelect:G}):(0,j.jsx)(o.Flex,{padding:[4],justifyContent:"center",children:(0,j.jsx)(o.Text,{color:"textLite",children:C?"No functions available":"Loading functions..."})})]}),(0,j.jsxs)(o.Flex,{column:!0,flex:!0,overflow:{vertical:"auto"},padding:[2],children:[!p&&(0,j.jsx)(o.Flex,{padding:[4],justifyContent:"center",children:(0,j.jsx)(o.Text,{color:"textLite",children:C?"No functions available":"Loading functions..."})}),p&&B&&(0,j.jsx)(o.Flex,{padding:[4],justifyContent:"center",children:(0,j.jsx)(o.Text,{color:"textLite",children:"Loading function info..."})}),p&&!B&&R&&(0,j.jsxs)(o.Flex,{column:!0,gap:2,children:[(0,j.jsx)(o.Text,{strong:!0,children:(null===(n=A[p])||void 0===n?void 0:n.name)||p}),(0,j.jsx)(Qn,{flavour:l,visibleItems:b,onToggle:m,defaultCharts:null===R||void 0===R?void 0:R.defaultCharts})]})]})]}),(0,j.jsx)(fn,{label:"Import",onClick:_,disabled:!q})]})};n(78350),n(30237),n(30670),n(71517),n(11379),n(93777),n(14190),n(12359),n(86097),n(17273),n(27415),n(19929),n(37583),n(55122),n(20230),n(57268),n(79733);const $n=["children"];function Xn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function er(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Xn(Object(n),!0).forEach((function(t){(0,p.A)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Xn(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}const tr=e=>{let{children:t}=e,n=(0,f.A)(e,$n);return(0,j.jsx)(o.Flex,er(er({column:!0,round:1,overflow:"hidden",border:{side:"all",color:"borderSecondary"},background:"mainBackground"},n),{},{children:t}))},nr=["children"];function rr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function or(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?rr(Object(n),!0).forEach((function(t){(0,p.A)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):rr(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}const lr="nodeGrid",sr="nodeList",ar="alertStatus",ir="alertsPerNode",cr="hourlyAlerts",dr={Live:"success",Stale:"warning",Offline:"textLite",Unseen:"textDescription"},ur=e=>{let{nodeStatusCounts:t}=e;if(0===Object.values(t).reduce(((e,t)=>e+t),0))return(0,j.jsx)(tr,{padding:[2],children:(0,j.jsx)(o.Text,{color:"textLite",fontSize:"10px",children:"No nodes"})});const n=Object.entries(t).flatMap((e=>{let[t,n]=e;return Array.from({length:n},((e,n)=>({key:"".concat(t,"-").concat(n),color:dr[t]})))}));return(0,j.jsx)(tr,{padding:[2],children:(0,j.jsx)(o.Flex,{gap:1,flexWrap:!0,children:n.slice(0,96).map((e=>{let{key:t,color:n}=e;return(0,j.jsx)(o.Flex,{width:"8px",height:"8px",round:"50%",background:n},t)}))})})},hr=e=>{let{nodes:t}=e;const n=t.slice(0,4);return 0===n.length?(0,j.jsx)(tr,{children:(0,j.jsx)(o.Text,{color:"textLite",fontSize:"10px",padding:[1],children:"No nodes"})}):(0,j.jsxs)(tr,{children:[n.map(((e,t)=>(0,j.jsxs)(o.Flex,{alignItems:"center",padding:[1],gap:2,border:t<n.length-1?{side:"bottom",color:"borderSecondary"}:void 0,children:[(0,j.jsx)(o.Text,{fontSize:"10px",flex:!0,truncate:!0,children:e.name}),(0,j.jsx)(o.Flex,{flex:!0}),(0,j.jsx)(o.Flex,{width:"8px",height:"8px",round:"50%",background:dr[(0,At.GM)(e.state)]})]},e.id))),t.length>4&&(0,j.jsx)(o.Flex,{padding:[1],justifyContent:"center",children:(0,j.jsxs)(o.Text,{fontSize:"9px",color:"textLite",children:["+",t.length-4," more"]})})]})},xr=e=>{let{alertCounts:t}=e;return(0,j.jsx)(tr,{children:(0,j.jsxs)(o.Flex,{children:[(0,j.jsxs)(o.Flex,{column:!0,alignItems:"center",justifyContent:"center",padding:[2],flex:!0,background:"error",backgroundOpacity:.2,children:[(0,j.jsx)(o.Text,{fontSize:"10px",color:"error",children:"Critical"}),(0,j.jsx)(o.Text,{fontSize:"20px",strong:!0,color:"error",children:t.critical})]}),(0,j.jsxs)(o.Flex,{column:!0,alignItems:"center",justifyContent:"center",padding:[2],flex:!0,background:"warning",backgroundOpacity:.2,children:[(0,j.jsx)(o.Text,{fontSize:"10px",color:"warning",children:"Warning"}),(0,j.jsx)(o.Text,{fontSize:"20px",strong:!0,color:"warning",children:t.warning})]})]})})},gr=e=>{let{alertsByNode:t}=e;const n=t.slice(0,3);return 0===n.length?(0,j.jsx)(tr,{padding:[2],children:(0,j.jsx)(o.Text,{color:"textLite",fontSize:"10px",children:"No alerts"})}):(0,j.jsxs)(tr,{padding:[2],children:[n.map((e=>(0,j.jsxs)(o.Flex,{alignItems:"center",gap:2,margin:[0,0,1,0],children:[(0,j.jsx)(o.Text,{fontSize:"11px",truncate:!0,flex:!0,children:e.name}),(0,j.jsxs)(o.Flex,{gap:1,alignItems:"center",children:[e.critical>0&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(o.Flex,{width:"6px",height:"6px",round:"50%",background:"error"}),(0,j.jsx)(o.Text,{fontSize:"10px",color:"textLite",children:e.critical})]}),e.warning>0&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(o.Flex,{width:"6px",height:"6px",round:"50%",background:"warning"}),(0,j.jsx)(o.Text,{fontSize:"10px",color:"textLite",children:e.warning})]})]})]},e.nodeId))),t.length>3&&(0,j.jsxs)(o.Text,{fontSize:"9px",color:"textLite",children:["+",t.length-3," more"]})]})},pr=e=>{let{buckets:t}=e;const n=Math.max(1,...t.map((e=>e.critical+e.warning)));return(0,j.jsx)(tr,{padding:[2],children:(0,j.jsx)(o.Flex,{alignItems:"end",justifyContent:"center",gap:1,height:"50px",children:t.map(((e,t)=>{const r=e.critical+e.warning,l=Math.max(2,Math.round(r/n*48)),s=e.critical>0?"error":e.warning>0?"warning":"mainBackgroundDisabled";return(0,j.jsx)(o.Flex,{width:"6px",height:"".concat(l,"px"),background:s,round:1},t)}))})})},fr=e=>{let{nodeStatusCounts:t}=e;const n=Object.values(t).reduce(((e,t)=>e+t),0);return(0,j.jsxs)(tr,{padding:[2],children:[(0,j.jsx)(o.Flex,{justifyContent:"space-around",children:Object.entries(dr).map((e=>{let[n,r]=e;return(0,j.jsxs)(o.Flex,{column:!0,alignItems:"center",gap:0,children:[(0,j.jsx)(o.Flex,{width:"8px",height:"8px",round:"50%",background:r}),(0,j.jsx)(o.Text,{fontSize:"10px",children:t[n]||0})]},n)}))}),n>0&&(0,j.jsx)(o.Flex,{justifyContent:"center",margin:[1,0,0,0],children:(0,j.jsxs)(o.Text,{fontSize:"9px",color:"textLite",children:[n," nodes"]})})]})},br=e=>{let{children:t}=e,n=(0,f.A)(e,nr);return(0,j.jsx)(o.Flex,or(or({column:!0,gap:2,flex:!0,width:{min:0}},n),{},{children:t}))},jr=e=>{let{label:t,checked:n,onToggle:r}=e;return(0,j.jsx)(o.Checkbox,{checked:n,onChange:r,label:t})},mr=e=>{let{dashboardId:t,onPreviewChange:n}=e;const[l,s]=(0,r.useState)([]),[a,i]=(0,r.useState)({}),[d,u]=(0,r.useState)(new Set),[h,x]=(0,r.useState)({nodeStats:[]}),p=(0,N.CK)(),f=Sn(p,l,a),b=(0,g.Gt)(p),m=(0,Dt.s)("ids")||[],v=(0,Et.Gq)(m),y=(0,r.useMemo)((()=>{if(0===f.length)return b;const e=new Set(f);return b.filter((t=>e.has(t.id)))}),[b,f]),w=(0,r.useMemo)((()=>{const e={Live:0,Stale:0,Offline:0,Unseen:0};return y.forEach((t=>{const n=(0,At.GM)(t.state);e[n]=(e[n]||0)+1})),e}),[y]),O=(0,r.useMemo)((()=>{if(0===f.length)return v;const e=new Set(f);return v.filter((t=>e.has(t.nodeId)))}),[v,f]),I=(0,r.useMemo)((()=>{const e={critical:0,warning:0,clear:0};return O.forEach((t=>{void 0!==e[t.status]&&e[t.status]++})),e}),[O]),C=(0,r.useMemo)((()=>{const e={};O.forEach((t=>{e[t.nodeId]||(e[t.nodeId]={critical:0,warning:0}),"critical"===t.status&&e[t.nodeId].critical++,"warning"===t.status&&e[t.nodeId].warning++}));const t=new Map(y.map((e=>[e.id,e.name])));return Object.entries(e).map((e=>{let[n,r]=e;return or({nodeId:n,name:t.get(n)||n},r)})).sort(((e,t)=>1e3*t.critical+t.warning-(1e3*e.critical+e.warning)))}),[O,y]),S=(0,r.useMemo)((()=>{const e=Array.from({length:24},(()=>({critical:0,warning:0})));return O.forEach((t=>{if(!t.lastUpdated)return;const n=new Date(1e3*t.lastUpdated).getHours();"critical"===t.status&&e[n].critical++,"warning"===t.status&&e[n].warning++})),e}),[O]),k=(0,c.WM)(),F=(0,L.hu)(t),A=(0,L.Pp)(t),P=(0,L.Rt)(t),T=(0,L.HR)(t),D=(0,L.h$)(t),E=(0,L.Qv)(t),M=(0,r.useCallback)((e=>{u((t=>{const n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}))}),[]),z=(0,r.useCallback)(((e,t)=>{x((n=>or(or({},n),{},{[e]:t})))}),[]),B=(0,r.useCallback)((()=>{const e=f.length>0?{selectedNodeIds:f}:{};let t=null;d.forEach((n=>{switch(n){case lr:t=F(e);break;case sr:t=A(e);break;case ar:t=P(e);break;case ir:t=T(e);break;case cr:t=D(e)}})),h.nodeStats.length>0&&(t=E(or(or({},e),{},{visibleItems:h.nodeStats}))),u(new Set),x({nodeStats:[]}),k(null),t&&requestAnimationFrame((()=>{requestAnimationFrame((()=>{const e=document.querySelector('[data-id="'.concat(t,'"]'));e&&e.scrollIntoView({behavior:"smooth",block:"nearest"})}))}))}),[d,h,f,k,F,A,P,T,D,E]),R=d.size>0||h.nodeStats.length>0;return(0,r.useEffect)((()=>{if(!n)return;if(!R)return void n([]);const e=[...d].map((e=>({type:e,config:{selectedNodeIds:f}})));h.nodeStats.length>0&&e.push({type:"nodeStats",config:{selectedNodeIds:f,visibleItems:h.nodeStats}}),n(e)}),[R,d,h,f,n]),(0,j.jsxs)(o.Flex,{column:!0,height:"100%",overflow:"hidden",children:[(0,j.jsx)(pn,{title:"Infrastructure"}),(0,j.jsxs)(o.Flex,{column:!0,flex:!0,overflow:"auto",padding:[3],gap:4,children:[(0,j.jsx)(fe.A,{nodeIds:p,selectedNodeIds:l,setSelectedNodeIds:s,filters:a,setFilters:i}),(0,j.jsxs)(o.Flex,{gap:3,children:[(0,j.jsxs)(br,{children:[(0,j.jsx)(jr,{label:"Node grid",checked:d.has(lr),onToggle:()=>M(lr)}),(0,j.jsx)(ur,{nodeStatusCounts:w})]}),(0,j.jsxs)(br,{children:[(0,j.jsx)(jr,{label:"Node List",checked:d.has(sr),onToggle:()=>M(sr)}),(0,j.jsx)(hr,{nodes:y})]})]}),(0,j.jsxs)(o.Flex,{column:!0,gap:3,children:[(0,j.jsx)(o.Text,{strong:!0,children:"Alerts"}),(0,j.jsxs)(o.Flex,{gap:3,children:[(0,j.jsxs)(br,{children:[(0,j.jsx)(jr,{label:"Alert Status",checked:d.has(ar),onToggle:()=>M(ar)}),(0,j.jsx)(xr,{alertCounts:I})]}),(0,j.jsxs)(br,{children:[(0,j.jsx)(jr,{label:"Alerts per Node",checked:d.has(ir),onToggle:()=>M(ir)}),(0,j.jsx)(gr,{alertsByNode:C})]})]}),(0,j.jsxs)(br,{children:[(0,j.jsx)(jr,{label:"Hourly Alerts",checked:d.has(cr),onToggle:()=>M(cr)}),(0,j.jsx)(pr,{buckets:S})]})]}),(0,j.jsx)(Un.f,{label:"Node Stats",items:Kn.Qu.nodeStats,selected:h.nodeStats,onChange:e=>z("nodeStats",e),children:(0,j.jsx)(fr,{nodeStatusCounts:w})})]}),(0,j.jsx)(fn,{label:"Import",onClick:B,disabled:!R})]})},vr=["children"];function yr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function wr(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?yr(Object(n),!0).forEach((function(t){(0,p.A)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):yr(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}const Or="dataRetention",Ir=()=>(0,j.jsx)(tr,{padding:[2],children:(0,j.jsxs)(o.Flex,{justifyContent:"space-around",children:[(0,j.jsxs)(o.Flex,{column:!0,alignItems:"center",children:[(0,j.jsx)(o.Text,{fontSize:"8px",color:"textLite",children:"Metrics"}),(0,j.jsx)(o.Text,{fontSize:"14px",strong:!0,children:"1.2K"})]}),(0,j.jsxs)(o.Flex,{column:!0,alignItems:"center",children:[(0,j.jsx)(o.Text,{fontSize:"8px",color:"textLite",children:"Charts"}),(0,j.jsx)(o.Text,{fontSize:"14px",strong:!0,children:"340"})]}),(0,j.jsxs)(o.Flex,{column:!0,alignItems:"center",children:[(0,j.jsx)(o.Text,{fontSize:"8px",color:"textLite",children:"Alerts"}),(0,j.jsx)(o.Text,{fontSize:"14px",strong:!0,children:"52"})]})]})}),Cr=e=>{let{alertsByNode:t}=e;const n=t.slice(0,3);return(0,j.jsxs)(tr,{padding:[2],children:[(0,j.jsx)(o.Flex,{alignItems:"end",justifyContent:"center",gap:1,height:"30px",children:n.map((e=>{const t=e.critical+e.warning,r=Math.max(1,...n.map((e=>e.critical+e.warning))),l=Math.max(4,Math.round(t/r*28));return(0,j.jsxs)(o.Flex,{width:"12px",height:"".concat(l,"px"),round:1,children:[e.critical>0&&(0,j.jsx)(o.Flex,{flex:!0,background:"error",round:1}),e.warning>0&&(0,j.jsx)(o.Flex,{flex:!0,background:"warning",round:1})]},e.nodeId)}))}),0===n.length&&(0,j.jsx)(o.Text,{fontSize:"10px",color:"textLite",children:"No alerts"})]})},Sr=()=>(0,j.jsx)(tr,{padding:[2],children:(0,j.jsx)(o.Flex,{alignItems:"end",justifyContent:"center",gap:2,height:"30px",children:[18,24,12,20,8].map(((e,t)=>(0,j.jsx)(o.Flex,{width:"8px",height:"".concat(e,"px"),background:"primary",round:1},t)))})}),kr=()=>(0,j.jsx)(tr,{padding:[2],children:(0,j.jsxs)(o.Flex,{justifyContent:"space-around",children:[(0,j.jsxs)(o.Flex,{column:!0,alignItems:"center",children:[(0,j.jsx)(o.Text,{fontSize:"8px",color:"textLite",children:"Parents"}),(0,j.jsx)(o.Text,{fontSize:"12px",strong:!0,children:"P"})]}),(0,j.jsxs)(o.Flex,{column:!0,alignItems:"center",children:[(0,j.jsx)(o.Text,{fontSize:"8px",color:"textLite",children:"Children"}),(0,j.jsx)(o.Text,{fontSize:"12px",strong:!0,children:"C"})]}),(0,j.jsxs)(o.Flex,{column:!0,alignItems:"center",children:[(0,j.jsx)(o.Text,{fontSize:"8px",color:"textLite",children:"Standalone"}),(0,j.jsx)(o.Text,{fontSize:"12px",strong:!0,children:"S"})]})]})}),Fr=e=>{let{children:t}=e,n=(0,f.A)(e,vr);return(0,j.jsx)(o.Flex,wr(wr({column:!0,gap:2,flex:!0,width:{min:0}},n),{},{children:t}))},Ar=e=>{let{label:t,checked:n,onToggle:r}=e;return(0,j.jsx)(o.Checkbox,{checked:n,onChange:r,label:t})},Pr=e=>{let{dashboardId:t,onPreviewChange:n}=e;const[l,s]=(0,r.useState)(new Set),[a,i]=(0,r.useState)({statsOverview:[],alertNodes:[],replicationStats:[]}),d=(0,N.CK)(),u=(0,g.Gt)(d),h=(0,Dt.s)("ids")||[],x=(0,Et.Gq)(h),p=(0,r.useMemo)((()=>{const e={};x.forEach((t=>{e[t.nodeId]||(e[t.nodeId]={critical:0,warning:0}),"critical"===t.status&&e[t.nodeId].critical++,"warning"===t.status&&e[t.nodeId].warning++}));const t=new Map(u.map((e=>[e.id,e.name])));return Object.entries(e).map((e=>{let[n,r]=e;return wr({nodeId:n,name:t.get(n)||n},r)})).sort(((e,t)=>1e3*t.critical+t.warning-(1e3*e.critical+e.warning)))}),[x,u]),f=(0,c.WM)(),b=(0,L.fM)(t),m=(0,L.Vs)(t),v=(0,L.ez)(t),y=(0,L.cj)(t),w=(0,r.useCallback)((e=>{s((t=>{const n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}))}),[]),O=(0,r.useCallback)(((e,t)=>{i((n=>wr(wr({},n),{},{[e]:t})))}),[]),I=Object.values(a).some((e=>e.length>0)),C=l.size>0||I;(0,r.useEffect)((()=>{if(!n)return;if(!C)return void n([]);const e=Array.from(l).map((e=>({type:e,config:{}})));Object.entries(a).forEach((t=>{let[n,r]=t;r.length>0&&e.push({type:n,config:{visibleItems:r}})})),n(e)}),[C,l,a,n]);const S=(0,r.useCallback)((()=>{let e=null;l.forEach((t=>{if(t===Or)e=m({})})),Object.entries(a).forEach((t=>{let[n,r]=t;if(0===r.length)return;const o={statsOverview:b,alertNodes:v,replicationStats:y}[n];o&&(e=o({visibleItems:r}))})),s(new Set),i({statsOverview:[],alertNodes:[],replicationStats:[]}),f(null),e&&requestAnimationFrame((()=>{requestAnimationFrame((()=>{const t=document.querySelector('[data-id="'.concat(e,'"]'));t&&t.scrollIntoView({behavior:"smooth",block:"nearest"})}))}))}),[l,a,f,b,m,v,y]);return(0,j.jsxs)(o.Flex,{column:!0,height:"100%",overflow:"hidden",children:[(0,j.jsx)(pn,{title:"Room Overview"}),(0,j.jsxs)(o.Flex,{column:!0,flex:!0,overflow:"auto",padding:[3],gap:4,children:[(0,j.jsx)(Un.f,{label:"Stats Overview",items:Kn.Qu.statsOverview,selected:a.statsOverview,onChange:e=>O("statsOverview",e),children:(0,j.jsx)(Ir,{})}),(0,j.jsx)(Un.f,{label:"Alert Nodes",items:Kn.Qu.alertNodes,selected:a.alertNodes,onChange:e=>O("alertNodes",e),children:(0,j.jsx)(Cr,{alertsByNode:p})}),(0,j.jsxs)(Fr,{children:[(0,j.jsx)(Ar,{label:"Data Retention",checked:l.has(Or),onToggle:()=>w(Or)}),(0,j.jsx)(Sr,{})]}),(0,j.jsx)(Un.f,{label:"Replication",items:Kn.Qu.replicationStats,selected:a.replicationStats,onChange:e=>O("replicationStats",e),children:(0,j.jsx)(kr,{})})]}),(0,j.jsx)(fn,{label:"Import",onClick:S,disabled:!C})]})};function Tr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Nr(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Tr(Object(n),!0).forEach((function(t){(0,p.A)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Tr(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}const Dr={[dt]:wn,[ut]:Ln,[ht]:e=>(0,j.jsx)(Zn,Nr(Nr({},e),{},{flavour:"fn"})),[xt]:e=>(0,j.jsx)(Zn,Nr(Nr({},e),{},{flavour:"logs"})),[gt]:e=>(0,j.jsx)(Zn,Nr(Nr({},e),{},{flavour:"feed"})),[pt]:mr,[ft]:Pr},Er={[dt]:718,[ut]:680,[ht]:680,[xt]:680,[gt]:680,[pt]:680,[ft]:680},Lr={top:"top",left:"right"},Mr=(0,O.default)(o.Flex).withConfig({displayName:"palette__AnimatedContainer",componentId:"sc-112dxl5-0"})(["transition:width 0.2s ease-out;max-width:calc(100vw - 200px);"]),zr=e=>{let{panelId:t,dashboardId:n,targetRef:l,onClose:s}=e;const[a,i]=(0,r.useState)([]),c=(0,r.useMemo)((()=>Dr[t]),[t]),d=Er[t]||680,u=a.length>0,h=u?d+420:d;return c&&l.current?(0,j.jsx)(o.Drop,{align:Lr,target:l.current,onEsc:s,onClickOutside:s,dataDrop:"palette-panel-drop",zIndex:68,backdrop:!0,backdropProps:{background:["transparent","full"],zIndex:50},margin:[2,0,0,2],children:(0,j.jsxs)(Mr,{width:"".concat(h,"px"),height:{max:"80vh"},background:"panelBg",overflow:"hidden",children:[(0,j.jsx)(o.Flex,{width:"".concat(d,"px"),padding:[4],children:(0,j.jsx)(c,{dashboardId:n,onPreviewChange:i})}),u&&(0,j.jsx)(o.Flex,{flex:!0,padding:[4],border:{side:"left",color:"borderSecondary"},overflow:"auto",background:"panelBg",children:(0,j.jsx)(gn,{items:a})})]})}):null},Br=e=>{let{dashboardId:t}=e;const n=(0,c.wz)(),l=(0,c.WM)(),s=(0,r.useRef)(null),a=(0,r.useCallback)((()=>l(null)),[]);return(0,j.jsxs)(o.Flex,{ref:s,height:"100%",children:[(0,j.jsx)(vt,{}),n&&(0,j.jsx)(zr,{panelId:n,dashboardId:t,targetRef:s,onClose:a},n)]})},Rr=()=>((0,Ie.A)(),null),Gr=(0,r.memo)((e=>{let{id:t,roomId:n,nodeIds:o=[],isOnTV:h}=e;const[x,,,g]=(0,s.A)("addChartModal"),{fullyLoaded:p,cardIds:f,name:b}=(0,i.fz)(t),m=(0,c.tD)(),v=(0,c.x3)(),y=(0,r.useRef)(!1);(0,r.useEffect)((()=>{p&&!y.current&&(y.current=!0,v(0===f.length))}),[p,f.length,v]);const O=(0,l.zy)(),I=(0,l.Zp)(),[C,S]=(0,r.useState)(!1);(0,r.useEffect)((()=>{var e;p&&null!==(e=O.state)&&void 0!==e&&e.showDuplicateWizard&&(S(!0),I(O.pathname,{replace:!0,state:{}}))}),[p]);const k=(0,r.useCallback)((()=>S(!0)),[]),A=(0,r.useCallback)((()=>S(!1)),[]);(e=>{const t=(0,i.zN)(e),n=(0,c.tD)();_e(Ve,n&&!t)})(t);const[P,{width:T}]=(0,a.A)(),[N,D]=(0,Ce.N9)("chartName",{key:n,extraKey:t,flavour:"val"}),E=(0,d.Xc)(t),L=(0,u.T6)(t);return(0,j.jsx)(ke.Ay,{feature:"custom-dashboard",children:(0,j.jsx)(Ht.Ay,{children:(0,j.jsxs)(Se.A,{getObject:L,ids:E,getMenu:Ne,extraKey:t,children:[(0,j.jsx)(Rr,{}),!h&&m&&(0,j.jsx)(Br,{dashboardId:t}),(0,j.jsxs)(Oe.A,{ref:P,overflow:"hidden",background:"mainBackground",padding:[0,4],children:[!h&&(0,j.jsx)(it,{id:t,isEditMode:m,onOpenDuplicateWizard:k}),p&&f.length>0&&(0,j.jsx)(F,{active:m&&!h,children:(0,j.jsx)(ct.A,{id:t,containerWidth:T,initialChartName:N,onChartNameChange:D,isOnTV:h})}),p&&0===f.length&&!h&&(0,j.jsx)(F,{active:!0,children:(0,j.jsx)(w,{})}),x&&!h&&(0,j.jsx)(ae,{id:t,onClose:g}),C&&(0,j.jsx)(we,{dashboardId:t,onClose:A})]})]})})})})),qr=(0,r.memo)((e=>{let{id:t,isOnTV:n}=e;const r=(0,h.ID)(),o=(0,x.w7)({extraKey:"dashboard",merge:!1,scoped:!0}),l=(0,g.TG)(o);return(0,j.jsx)(Gr,{id:t,roomId:r,nodeIds:l,isOnTV:n})}))},1623(e,t,n){n.d(t,{A:()=>l});var r=n(63474),o=n(74848);const l=()=>(0,o.jsx)(r.O2,{"data-testid":"dashboardLoading"})},15744(e,t,n){n.d(t,{A:()=>o});var r=n(66188);const o=[{title:"System",icon:r.G06,grouping:!0,match:["block-devices","ipmi-sensors","mount-points","network-connections","network-interfaces","processes","systemd-list-units","systemd-services"]},{title:"Containers",icon:"serviceContainer",grouping:!0,match:["containers-vms"]},{id:"docker",title:"Docker",icon:"serviceDockerHubPress",flatten:!0,grouping:!0},{id:"snmp",title:"SNMP",icon:r.fKj,flatten:!0,grouping:!0},{title:"Databases",icon:r.hem,grouping:!0,match:["clickhouse","cockroachdb","couchbase","elasticsearch","mongodb","mssql","mysql","oracledb","postgres","proxysql","redis","rethinkdb","sql","yugabytedb"]},{title:"Netdata",icon:r.$Fj,match:["netdata"]}]}}]);