File: //opt/netdata/usr/local/local/share/netdata/web/v3/7817.c757415996f1423573e8.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:"dfd13842659c4417dbfb2d0927d2e87ce02ac822"};var t=(new e.Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="e29ce3a6-154b-4722-aefe-c4209af76379",e._sentryDebugIdIdentifier="sentry-dbid-e29ce3a6-154b-4722-aefe-c4209af76379")}catch(e){}}(),(self.webpackChunkcloud_frontend=self.webpackChunkcloud_frontend||[]).push([[7817],{37817(e,t,n){n.r(t),n.d(t,{default:()=>en});var r=n(64467),i=(n(98992),n(54520),n(3949),n(62953),n(79997)),o=n(41344),s=n(74848);const a=e=>{let{Sidebar:t,children:n}=e;return t?(0,s.jsxs)(i._V,{"data-testid":"insights-layout-container",children:[(0,s.jsx)(t,{}),n]}):n};var c=n(55024);const l=()=>(0,s.jsx)(i.p6,{"data-testid":"insights-sidebar-labels",padding:[1,1,0,0],children:(0,s.jsx)(c.A,{showBelowRemainingCredits:3})});var d=n(30413);const u=()=>(0,s.jsxs)(i.oe,{"data-testid":"insights-sidebar-container",children:[(0,s.jsx)(l,{}),(0,s.jsx)(d.A,{})]});var p=n(80045),g=n(96540),h=n(42358),m=n(46587),f=n(81685);const b=()=>(0,s.jsxs)(h.Flex,{"data-testid":"insights-overview-header-container",column:!0,gap:2,children:[(0,s.jsx)(h.TextBig,{color:"menuItem",children:"Insights and investigations"}),(0,s.jsxs)(h.Text,{color:"menuItem",lineHeight:1.5,children:["Use Al to run automated investigations and generate insights.",(0,s.jsx)("br",{}),"Make better decisions, faster, without sifting through dashboards or writing complicated queries."]})]});n(81454);var x=n(51510);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}const y=(0,x.default)(h.Box).attrs((e=>function(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}({},e))).withConfig({displayName:"styled__OverviewGrid",componentId:"sc-wl3070-0"})(["display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:8px;"]);var v=n(27805),O=(n(89463),n(18121)),w=n(54521),P=n(25383);const k=["id","icon","color","bg","title","description","Component"];function C(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 S(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?C(Object(n),!0).forEach((function(t){(0,r.A)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):C(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}const I="panelBg",A=e=>{let{id:t,icon:n,color:r,bg:i=I,title:o,description:a,Component:c}=e,l=(0,p.A)(e,k);const{loaded:d,onButtonClick:u}=(0,P.A)(),[m,f]=(0,O.useHovered)({},[d]),b=(0,g.useCallback)((()=>{u(t)}),[t,u]);return(0,s.jsxs)(w.I0,S(S({ref:m,"data-testid":"insights-overview-report-item-card-container",gap:3,background:f?i:I,justifyContent:"between",border:{side:"all",color:f?r:"mainBackground"},cursor:"pointer",onClick:b},l),{},{children:[(0,s.jsxs)(h.Flex,{column:!0,gap:3,children:[(0,s.jsxs)(h.Flex,{alignItem:"center",gap:2,children:[(0,s.jsx)(h.Icon,{name:n}),(0,s.jsx)(h.TextBig,{color:r,children:o})]}),(0,s.jsx)(h.Flex,{justifyContent:"center",children:c?(0,s.jsx)(c,{}):null}),(0,s.jsx)(h.Flex,{children:(0,s.jsx)(h.Text,{color:"menuItem",children:a})})]}),(0,s.jsx)(h.Flex,{justifyContent:"end",children:(0,s.jsx)(h.Text,{color:"primary",children:"Generate report"})})]}))};function D(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 T(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?D(Object(n),!0).forEach((function(t){(0,r.A)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):D(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}const F=()=>{const{insights:e,investigations:t}=(0,v.A)();return(0,s.jsxs)(y,{"data-testid":"insights-overview-grid-container",children:[e.map((e=>(0,s.jsx)(A,T({},e),e.id))),t.map(((e,t)=>(0,s.jsx)(A,T(T({},e),{},{start:2*t+1,span:2}),e.id)))]})},M=()=>(0,s.jsxs)(h.Flex,{"data-testid":"insights-overview-container",column:!0,gap:4,padding:[4],children:[(0,s.jsx)(b,{}),(0,s.jsx)(F,{})]});n(72577);var B=n(17702);n(8872);const E=["size"];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}const R={tiny:h.Text,default:h.TextBig},z=e=>{let{size:t}=e,n=(0,p.A)(e,E);const i=R[t]||R.default;return(0,s.jsx)(i,function(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,r.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}({},n))};var N=n(74891);const q=["iconProps"],_=["selectedItems","placeholder","ref","size","isDisabled","dataTestId","clickOnIcon","iconProps","onClick"];function L(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 K(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?L(Object(n),!0).forEach((function(t){(0,r.A)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):L(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}const W=(0,N.A)(h.Icon),H=(U=(0,g.memo)((e=>{let{selectedItems:t=[],placeholder:n,size:r}=e;const i=(0,g.useMemo)((()=>t.filter(Boolean)),[t]),o=(0,g.useMemo)((()=>({size:r,truncate:!0,style:{maxWidth:1===i.length?"300px":"150px"}})),[r,i.length]);return i&&i.length?(0,s.jsxs)(h.Flex,{gap:1,alignItems:"center",children:[(0,s.jsx)(z,K(K({},o),{},{children:i[0].label})),t.length>1?(0,s.jsxs)(z,{size:r,whiteSpace:"nowrap",children:["and ",t.length-1," more"]}):null]}):(0,s.jsx)(z,{size:r,color:"placeholder",children:n})})),e=>{let{iconProps:t={}}=e,n=(0,p.A)(e,q);return t.name?(0,s.jsxs)(h.Flex,{alignItems:"center",gap:2,children:[(0,s.jsx)(W,K({noWrapper:!0},t)),(0,s.jsx)(U,K({},n))]}):(0,s.jsx)(U,K({},n))});var U;const G=e=>{let{selectedItems:t,placeholder:n,ref:r,size:i,isDisabled:o,dataTestId:a,clickOnIcon:c,iconProps:l,onClick:d}=e,u=(0,p.A)(e,_);const m=(0,g.useMemo)((()=>o?{opacity:.8}:c?{}:{onClick:d,cursor:"pointer"}),[o,c,d]),f=(0,g.useMemo)((()=>!o&&c?{onClick:d,cursor:"pointer"}:{}),[o,c,d]);return(0,s.jsxs)(h.Flex,K(K(K({ref:r,gap:2,height:"24px",padding:[1,2],alignItems:"center",justifyContent:"between",background:"inputBg",round:.5,"data-testid":"multi-select-container-".concat(a)},m),u),{},{children:[(0,s.jsx)(H,{size:i,selectedItems:t,placeholder:n,iconProps:l}),(0,s.jsx)(h.Icon,K({color:"textLite",name:"chevron_right",rotate:1,width:"24px"},f))]}))},J=(0,g.memo)(G);var $=n(64007);const Q=["value","maxNumberOfSelectedItems","makeItemProps","item","onItemClick","itemProps"];function Y(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 Z(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Y(Object(n),!0).forEach((function(t){(0,r.A)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Y(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}const X=(0,N.A)(h.Checkbox),ee=e=>{let{group:t,label:n,isParent:r}=e;return(0,s.jsxs)(h.Flex,{gap:2,alignItems:"center",padding:[0,0,0,1],children:[(0,s.jsx)(h.Text,{truncate:!0,style:{maxWidth:"200px"},color:t?"textLite":"text",children:n}),r?(0,s.jsx)(h.Pill,{size:"small",flavour:"success",hollow:!0,children:"parent"}):null]})},te=()=>{},ne=e=>{let{value:t,maxNumberOfSelectedItems:n,makeItemProps:r,item:i,onItemClick:o,itemProps:a}=e,c=(0,p.A)(e,Q);const{group:l,allSelected:d,someSelected:u,value:m,label:f,isParent:b}=i,{makeItemContainerProps:x=te,makeCheckboxProps:j=te}=r||{},y=(0,g.useMemo)((()=>x(Z({value:t,maxNumberOfSelectedItems:n,item:i},c))),[x]),v=(0,g.useMemo)((()=>j(Z({value:t,maxNumberOfSelectedItems:n,item:i},c))),[j]),O=(0,g.useMemo)((()=>l?d:t.includes(m)),[l,d,t,m]),w=(0,g.useMemo)((()=>!!n&&(!l&&!O&&t.length===n)),[l,O,t,n]),P=(0,g.useCallback)((e=>{o(Z({checked:e},l?{group:l}:{node:i}))}),[l,i,o]);return(0,s.jsx)($.b1,Z(Z(Z(Z({"aria-selected":!1,selected:!1,disabled:!1},c),a),{},{"data-testid":"multi-select-item-".concat(f),multi:!0,padding:[1,l?0:2]},y),{},{children:(0,s.jsx)(h.Flex,{gap:2,alignItems:"center",flex:!0,children:(0,s.jsx)(X,Z({checked:O,onChange:P,label:(0,s.jsx)(ee,{group:l,label:f,isParent:b}),indeterminate:!!l&&u,disabled:w},v))})}))},re={group:!0,label:"Select all"},ie=e=>{let{selectedItems:t,setSelectedItems:n,options:r=[],maxNumberOfSelectedItems:i,allSelectedValue:o,hasSearch:a,makeItemProps:c,dataTestId:l}=e;const d=(0,g.useMemo)((()=>t.map((e=>{let{value:t}=e;return t}))),[t]),u=(0,g.useMemo)((()=>d.length===r.length),[d,r]),p=(0,g.useMemo)((()=>d.length&&!u),[d,u]),m=(0,g.useMemo)((()=>i&&r.length>i),[r,i]),f=(0,g.useMemo)((()=>{const e=r.find((e=>{let{value:t}=e;return t===o})),t=Z(Z({},re),m?{label:"Select top ".concat(i)}:e?{label:e.label}:{});return[Z(Z({},t),{},{allSelected:u,someSelected:p}),...r]}),[r,o,u,p,m]),b=(0,g.useCallback)((e=>{let{group:i,node:o,checked:s}=e;i?n(u?[]:r):s?t.find((e=>e.value===o.value))||n([...t,o]):n(t.filter((e=>e.value!==o.value)))}),[r,t,n,u]);return(0,s.jsx)(h.Flex,{column:!0,gap:2,padding:[2,3],children:(0,s.jsx)($.V$,{items:f,Item:e=>(0,s.jsx)(ne,Z({maxNumberOfSelectedItems:i,makeItemProps:c},e)),onItemClick:b,value:d,hasSearch:a,height:{max:"400px"},searchMargin:[0,0,2,0],"data-testid":"multi-select-checkboxes-".concat(l)})})};var oe=n(6304);function se(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 ae(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?se(Object(n),!0).forEach((function(t){(0,r.A)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):se(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}const ce={makeItemContainerProps:()=>{},makeCheckboxProps:()=>{}},le=(0,g.memo)((e=>{let{label:t,value:n,allSelectedValue:r,placeholder:i="Select...",options:o=[],maxNumberOfSelectedItems:a,styles:c={},onChange:l,isDisabled:d,hasSearch:u=!0,clickOnIcon:p,containerProps:m={},accessorProps:f={},dropProps:b={},makeItemProps:x={},dataTestId:j="",iconProps:y}=e;const v=(0,g.useRef)(),{size:O}=c,[w,,P,k]=(0,oe.A)(!1),[C,S]=(0,g.useState)([]),I=(0,g.useMemo)((()=>ae(ae({},ce),x)),[x]),A=(0,g.useMemo)((()=>o.find((e=>{let{value:t}=e;return t===r}))),[o,r]),D=(0,g.useMemo)((()=>o.filter((e=>{let{value:t}=e;return t!==r}))),[o,r]),T=(0,g.useCallback)((()=>{k();const e=A&&C.length===D.length?[A]:C;l(e)}),[A,C,l,k]),F=(0,g.useCallback)((()=>{d||(w?T():P())}),[d,w,P,T]);return(0,g.useEffect)((()=>{let e=n?Array.isArray(n)?n:[n]:[];r&&(Array.isArray(n)&&n.find((e=>e.value===r))||n===r)&&(e=D),S(e)}),[n,r,D]),(0,s.jsxs)(h.Flex,ae(ae({flex:"1",column:!0,gap:1},m),{},{children:[t?(0,s.jsx)(z,{size:O,children:t}):null,(0,s.jsx)(J,ae({ref:v,placeholder:i,selectedItems:C,size:O,isDisabled:d,dataTestId:j,clickOnIcon:p,iconProps:y,onClick:F},f)),w&&v.current?(0,s.jsx)(h.Drop,ae(ae({target:v.current,align:{top:"bottom",left:"left"},background:"modalBackground",margin:[2,0,0],round:.5,close:T,onClickOutside:T,onEsc:T},b),{},{children:(0,s.jsx)(ie,{selectedItems:C,setSelectedItems:S,options:D,allSelectedValue:r,hasSearch:u,dataTestId:j,maxNumberOfSelectedItems:a,makeItemProps:I})})):null]}))})),de=le;var ue=n(21996),pe=n(99094);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 he(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,r.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 me="".concat(pe.Nn,"px"),fe=e=>{let{definitionId:t,variable:n,variables:r=[],index:i,containerProps:o={},componentProps:a={}}=e;const{onVariableChange:c}=(0,f.g0)(),{id:l,value:d,isMulti:u,fieldPrefix:p,maxLength:m}=n,b=(0,g.useMemo)((()=>{var e;if(0===i)return!0;const t=null===(e=r[i-1])||void 0===e?void 0:e.value;return Array.isArray(t)?!!t.length:!!t}),[r,i]),x=(0,g.useMemo)((()=>function(){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return 0===e?{}:(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).slice(0,e).reduce(((e,t)=>{let{id:n,value:r}=t;return he(he({},e),{},{[n]:r.value})}),{})}(r,i)),[r,i]),{loaded:j,options:y,error:v}=(0,f._R)({definitionId:t,variableId:l,variables:x}),O="nodes"===n.id,w=!!m,P=m?ue.A:u?de:h.Select,k=(0,g.useMemo)((()=>O?((null===y||void 0===y?void 0:y.values)||[]).filter((e=>{let{value:t}=e;return t!==pe.Gr})):[]),[O,y]),C=(0,g.useMemo)((()=>he(he({hasSearch:O},w?{width:"100%",rows:3,fontSize:"12px",maxLength:m,placeholder:"Type your query"}:{}),a)),[O,k.length,w,m,a]),S=(0,g.useCallback)((e=>{c({id:l,value:e})}),[l,c]);return v?null:(0,s.jsxs)(s.Fragment,{children:[p?(0,s.jsx)(h.Text,{children:n.fieldPrefix}):null,(0,s.jsx)(h.Flex,he(he({"data-testid":"insights-query-field-container",width:{min:w?80:me,max:w?80:50},padding:[2,1]},o),{},{children:(0,s.jsx)(P,he({options:(null===y||void 0===y?void 0:y.values)||[],allSelectedValue:pe.Gr,value:d,onChange:S,isMulti:u,isDisabled:!j||!b,styles:{minWidth:me,size:"tiny"},dropProps:{width:70}},C))}))]})};var be=n(85702),xe=n(23117),je=n(49074);const ye=e=>{let{onDismiss:t}=e;return(0,s.jsxs)(h.Flex,{column:!0,gap:4,children:[(0,s.jsxs)(h.Flex,{alignItems:"center",gap:1,children:[(0,s.jsx)(h.Icon,{name:"ai",color:"primaryAI"}),(0,s.jsx)(h.H3,{color:"primaryAI",children:"Schedule report"})]}),(0,s.jsx)(h.TextBig,{children:"Did you know you can schedule this report to automatically run at a time and date of your choice?"}),(0,s.jsx)(h.Flex,{children:(0,s.jsx)(B.A,{label:"OK, don't show again.",flavour:"hollow",small:!0,onClick:t,icon:""})})]})},ve=(0,je.A)(be.A),Oe=e=>{let{definitionId:t,variables:n=[]}=e;const{tooltip:r,isDisabled:i}=(0,xe.J)(),{insights:o=[]}=(0,v.A)(),{title:a,description:c,icon:l,Component:d}=o.find((e=>{let{id:n}=e;return n===t}))||{},u=(0,g.useMemo)((()=>({recurrenceValue:pe.tC[t]||pe.tC.default})),[t]);return(0,s.jsxs)(h.Flex,{"data-testid":"insights-default-query-container",column:!0,alignItems:"center",gap:15,padding:[10,4,0,4],children:[(0,s.jsxs)(h.Flex,{alignItems:"center",column:!0,gap:6,children:[(0,s.jsxs)(h.Flex,{alignItems:"center",column:!0,gap:2,children:[(0,s.jsxs)(h.Flex,{alignItems:"center",gap:1,children:[(0,s.jsx)(h.Icon,{name:l}),(0,s.jsx)(h.TextBig,{color:"menuItem",children:a})]}),(0,s.jsx)(h.Text,{color:"menuItem",children:c})]}),d?(0,s.jsx)(d,{}):null]}),(0,s.jsxs)(h.Flex,{"data-testid":"insights-default-query-fields-container",column:!0,gap:4,padding:[4],background:"panelBg",border:{side:"all",color:"border"},round:!0,children:[(0,s.jsx)(h.Flex,{alignItems:"center",justifyContent:"center",gap:1,flexWrap:!0,height:{min:"30px"},children:n.map(((e,r)=>(0,s.jsx)(fe,{variable:e,definitionId:t,variables:n,index:r},e.id)))}),(0,s.jsxs)(h.Flex,{alignItems:"center",justifyContent:"end",gap:2,children:[(0,s.jsx)(ve,{initialSchedulerState:u,PopoverContent:ye,tooltip:r,disabled:i,small:!0,dropContainerProps:{iconContainerProps:{position:"relative",left:"40%"}},popoverProps:{timeout:200,localStorageKey:"dissmiss-report-scheduler-promotion"}}),(0,s.jsx)(xe.A,{small:!0})]})]})]})};var we=n(43252);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}const ke="Something went wrong",Ce=e=>{let{message:t=ke}=e;return(0,s.jsx)(h.Flex,{"data-testid":"insights-investigation-chat-item-error",children:(0,s.jsx)(i.qm,{children:(0,s.jsxs)(h.TextBig,{color:"error",children:["Error: ",t]})})})},Se=e=>{let{type:t,question:n,response:r,error:o}=e;const{message:a}=(0,g.useMemo)((()=>(e=>{var t;return e?"string"===typeof e?{message:e}:{message:(null===(t=e.response)||void 0===t||null===(t=t.data)||void 0===t?void 0:t.errorMessage)||(null===e||void 0===e?void 0:e.message)||ke}:{}})(o)),[o]);return t===we.$p.error?(0,s.jsx)(Ce,{message:a}):(0,s.jsxs)(h.Flex,{column:!0,gap:2,children:[n?(0,s.jsx)(h.Flex,{"data-testid":"insights-investigation-chat-item-question",children:(0,s.jsx)(i.qm,{children:(0,s.jsx)(h.TextBig,{children:n})})}):null,r?(0,s.jsx)(h.Flex,{justifyContent:"end","data-testid":"insights-investigation-chat-item-response",children:(0,s.jsx)(i.qm,{background:"inputBg",children:(0,s.jsx)(h.TextBig,{children:r})})}):null]})},Ie=function(){let{chat:e=[]}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=(0,g.useRef)();return(0,g.useEffect)((()=>{null!==t&&void 0!==t&&t.current&&t.current.scrollIntoView({behavior:"smooth"})}),[e,null===t||void 0===t?void 0:t.current]),(0,s.jsxs)(s.Fragment,{children:[e.map((e=>(0,s.jsx)(Se,function(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,r.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}({},e),e.id))),(0,s.jsx)("div",{ref:t})]})},Ae=e=>{let{id:t,title:n,onClick:r}=e;const[i,o]=(0,O.useHovered)({},[]),a=(0,g.useCallback)((()=>{"function"===typeof r&&r({id:t})}),[t,r]);return(0,s.jsx)(h.Flex,{ref:i,cursor:"pointer",onClick:a,padding:[2,3],border:{side:"all",color:o?"primary":"border"},children:(0,s.jsx)(h.Text,{color:o?"primary":"menuItem",children:n})})};function De(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 Te=e=>{let{title:t,items:n=[],onItemClick:i}=e;return(0,s.jsxs)(h.Flex,{column:!0,gap:4,padding:[4],background:"panelBg",children:[(0,s.jsx)(h.TextBig,{color:"menuItem",children:t}),n.map((e=>(0,s.jsx)(Ae,function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?De(Object(n),!0).forEach((function(t){(0,r.A)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):De(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({onClick:i},e),e.id)))]})},Fe=[{id:"troubleshoot-problem",title:"Troubleshoot a problem",items:[{id:"checkout-pods-crashing",title:"Why are my checkout-service pods crashing repeatedly?",content:'Why are my checkout-service pods crashing repeatedly?\n\nContext:\n- Started after: [deployment at 14:00 UTC of version 2.3.1]\n- Impact: [Customer checkout failures, lost revenue ~$X/hour]\n- Recent changes: [Updated payment gateway integration, increased worker threads from 10 to 20]\n- Error pattern in logs: ["connection refused to payment-service:8080", "Java heap space"]\n\nEnvironment: production / eks-prod-us-east-1\nRelated services: payment-service, inventory-service, redis-session-store'},{id:"root-cause-increased-5xx-errors",title:"Find root cause of increased 5xx errors in API gateway",content:'Find root cause of increased 5xx errors in API gateway\n\nweb_log_1m_unmatched and web_log_1m_bad_requests are spiking. Context:\n- Affected endpoints: [/api/v2/checkout, /api/v2/inventory/check]\n- Started when: [Right after payments-service v1.5.0 deployment]\n- External factors: [Marketing campaign launched, 3x normal traffic, new payment provider integration went live]\n- Customer impact: [Cart abandonment up 40%, support tickets about "payment errors"]'},{id:"high-memory-usage",title:"What's causing high memory usage on node web-prod-03?",content:"What's causing high memory usage on node web-prod-03?\n\nThe system.ram utilization alert triggered. Additional context:\n- Recent changes: [Deployed new caching strategy, increased Node.js heap size to 4GB]\n- This node runs: [customer-facing API, websocket connections for live chat]\n- Business impact: [Customer complaints about slow page loads, chat disconnections]\n- Different from other nodes because: [Only node running the legacy monolith alongside microservices]"},{id:"microservices-causing-latency",title:"Which microservices are causing latency in user requests?",content:'Which microservices are causing latency in user requests?\n\nUser experience context:\n- Customer complaints: [Mobile app "freezing" during checkout, web pages taking 5+ seconds to load]\n- Started: [After microservices migration last week]\n- Critical user journeys affected: [Login \u2192 Browse \u2192 Add to Cart \u2192 Checkout]\n\nArchitecture context:\n- Total microservices: [23 services in production]\n- Recent changes: [Split monolith into user, catalog, and order services]\n- Service mesh: [Using Istio with mTLS enabled]\n- Tracing: [Jaeger deployed but only 10% sampling]\n\nSpecific issues observed:\n- [Cascading timeouts during peak hours]\n- [Checkout service calling 7 different services synchronously]\n- [No circuit breakers implemented yet]\n\nBusiness impact: [Cart abandonment up 25%, mobile app store rating dropped to 3.2 stars]'}]},{id:"analyze-change",title:"Analyze a change",items:[{id:"compare-system-metrics",title:"Compare system metrics before and after recent deployment",content:"Compare system metrics before and after recent deployment\n\nDeployment details:\n- Service: user-authentication-service v2.2.0\n- Deployed: 2025-01-24 09:00 UTC\n- Changes: [Switched from JWT to Redis sessions, added Argon2 password hashing, implemented rate limiting]\n\nSpecific concerns:\n- [Users reporting intermittent logouts]\n- [Session persistence issues after pod restarts]\n- [Suspicious increase in redis_connected_clients]\n\nTime windows: 24h before deployment vs 24h after"},{id:"redis-affect-cache-performance",title:"How did the Redis upgrade affect cache performance?",content:"How did the Redis upgrade affect cache performance?\n\nUpgrade: Redis 6.2.7 \u2192 7.2.0 on 2025-01-22 02:00 UTC\n\nBusiness context:\n- [Product catalog cache serving Black Friday traffic prep]\n- [Concerns about new Redis features overhead]\n- [Need to validate investment in upgrade was worthwhile]\n\nSpecific checks needed:\n- Impact on our Node.js connection pooling\n- Whether new eviction policies are better for our use case\n- Any compatibility issues with our caching library"},{id:"impact-of-scaling-from-3-to-5",title:"Show impact of scaling from 3 to 5 replicas on user-service",content:"Show impact of scaling from 3 to 5 replicas on user-service\n\nScaling event: 2025-01-23 15:00 UTC (HPA triggered by cpu.utilization > 80%)\n\nBusiness context:\n- [New feature launch driving 30% more traffic]\n- [Customer complaints about slow profile pages]\n- [Preparing for Super Bowl Sunday traffic spike]\n\nSpecific concerns:\n- [Database connection pool exhaustion errors in logs]\n- [Uneven load distribution despite round-robin LB]\n- [Session affinity issues after scaling]"},{id:"what-changed-in-network-traffic-patterns-this-week",title:"What changed in network traffic patterns this week?",content:"What changed in network traffic patterns this week?\n\nContext for unusual patterns:\n- [Launched new mobile app on Tuesday]\n- [CDN configuration changed Thursday - moved static assets to new domain]\n- [Office VPN migration might be affecting internal traffic]\n- [New customer in Asia significantly increasing APAC traffic]\n\nSpecific concerns:\n- [20% increase in AWS bandwidth costs]\n- [European users reporting latency issues]\n- [Suspicious traffic spike from specific IP ranges]\n\nInfrastructure: AWS multi-region with Istio service mesh"}]},{id:"optimize-performance",title:"Optimize performance",items:[{id:"additional-resources",title:"Which services would benefit most from additional resources?",content:"Which services would benefit most from additional resources?\n\nBusiness context:\n- Budget: [Additional $5K/month approved for scaling]\n- Growth: [20% MoM traffic increase, Black Friday prep needed]\n- New features coming: [Real-time inventory, ML-based recommendations]\n\nCurrent pain points:\n- [Payment service timeouts during flash sales]\n- [Search service degradation when catalog updates run]\n- [Batch processing jobs failing due to OOM kills]\n\nSLA requirements:\n- API 95th percentile < 200ms\n- Search results < 500ms\n- Payment processing < 2s\n\nHelp prioritize which services to scale first for maximum business impact."},{id:"identify-underutilized-nodes-for-cost-optimization",title:"Identify underutilized nodes for cost optimization",content:"Identify underutilized nodes for cost optimization\n\nContext:\n- Monthly AWS bill: [$12K for compute]\n- Environment: Mixed workloads (prod + staging on same cluster)\n- Constraints: [Need 2 nodes per AZ for HA, GPU nodes must stay for ML workloads]\n\nKnown issues:\n- [Dev environments running 24/7 but only used 9-5]\n- [Batch processing nodes idle 20h/day]\n- [Overprovisioned after last Black Friday, traffic never reached expected levels]\n\nGoal: Find $2-3K/month in savings without impacting reliability"},{id:"analyze-container-resource-limits-vs-actual-usage",title:"Analyze container resource limits vs actual usage",content:"Analyze container resource limits vs actual usage\n\nCurrent state:\n- Total pods: [150 across production]\n- Resource requests/limits set: [Only 60% have proper limits defined]\n- Recent OOMKills: [12 in the last week]\n\nProblem indicators:\n- [Some pods using 10% of requested resources (overprovisioned)]\n- [Others constantly hitting CPU throttling]\n- [Memory limits based on old load tests from 2023]\n- [Java apps with -Xmx not aligned with container limits]\n\nBusiness impact:\n- [Wasting ~$3K/month on overprovisioned resources]\n- [Critical services getting throttled during peak hours]\n- [Unpredictable performance affecting SLAs]\n\nRecent changes:\n- [Migrated from VMs to containers 6 months ago]\n- [Copied VM resource allocations without optimization]\n- [Traffic patterns changed significantly after new feature launch]\n\nGoal: Right-size all containers for optimal performance and cost"},{id:"predict-capacity-needs-for-black-friday-traffic",title:"Predict capacity needs for Black Friday traffic",content:"Predict capacity needs for Black Friday traffic\n\nLast year's data:\n- Peak: 50K concurrent users, 2K orders/minute\n- Growth rate: 40% YoY\n- Multiplier: 8-10x normal traffic\n\nCurrent limitations:\n- Payment gateway: 100 TPS rate limit\n- Database connections: 200 max\n- Redis memory: 32GB per node\n- CDN: 100TB monthly quota\n\nBusiness requirements:\n- Zero downtime\n- <500ms response time during peak\n- Handle 3K orders/minute\n- Support new livestream shopping feature\n\nWhat's our scaling strategy and when should we start provisioning?"}]}];function Me(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 Be=e=>{let{isNarrow:t,onItemClick:n}=e;return(0,s.jsxs)(h.Flex,{column:!0,gap:4,padding:[2,0,0,0],children:[(0,s.jsx)(h.Flex,{column:!0,gap:2,children:(0,s.jsx)(h.TextBig,{color:"textLite",children:"These examples provide starting templates\u2014customize them with your specific context. Netdata understands any investigation query, not just these categories."})}),(0,s.jsx)(h.Flex,{column:t,gap:4,children:Fe.map((e=>(0,s.jsx)(Te,function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Me(Object(n),!0).forEach((function(t){(0,r.A)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Me(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({onItemClick:n},e),e.id)))})]})};n(46449),n(93514),n(37550);var Ee=n(1011);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 Re(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,r.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 ze=e=>{var t;let{state:n,query:r,variableIds:i}=e;return n&&r?n.clarificationId?((null===(t=r.variables.find((e=>{let{id:t}=e;return t===i.clarifications})))||void 0===t?void 0:t.value)||[]).map((e=>e.id===n.clarificationId?Re(Re({},e),{},{response:n.textValue}):e)):n.textValue:""},Ne=e=>({id:(0,Ee.A)(),type:we.$p.response,response:e.textValue}),qe=e=>{let{query:t,variableIds:n}=e;return Re(Re({},t),{},{variables:t.variables.filter((e=>!(e.id===n.clarifications&&!Array.isArray(e.value))))})},_e=()=>!1,Le={textValue:"",textPlaceHolder:"Describe your investigation. Include context like when it started, what changed, impact, and what you've already tried...",variableId:we.Vs.reportDescription,clarificationId:null,clarifications:[],chat:[],error:null},Ke=e=>{let{variables:t,textRef:n,parentRef:r,schedulerState:i}=e;const{query:o,onVariableChange:s}=(0,f.g0)(),a=(0,f.fT)(),[,c]=(0,f.W5)(),[l,d]=(0,g.useState)(Le),{textValue:u,textPlaceHolder:p,chat:h}=l,m=(0,g.useCallback)((()=>{d((e=>Re(Re({},e),{},{textValue:Le.textValue})))}),[Le,d]),b=(0,g.useCallback)((e=>{let{isScheduled:t}=e;null!==n&&void 0!==n&&n.current&&n.current.focus(),t?a():(c(),m())}),[n,c,m,a]),x=(0,g.useCallback)((e=>{var t;if(422===(null===e||void 0===e||null===(t=e.response)||void 0===t?void 0:t.status)){var r;const t=null===e||void 0===e||null===(r=e.response)||void 0===r||null===(r=r.data)||void 0===r||null===(r=r.details)||void 0===r?void 0:r.clarification_questions;Array.isArray(t)&&(d((e=>{var n;const r=t.filter((t=>!e.clarifications.map((e=>{let{id:t}=e;return t})).includes(t.id)));return Re(Re({},e),{},{variableId:we.Vs.clarifications,textPlaceHolder:"Type your answer",clarificationId:null===(n=r[0])||void 0===n?void 0:n.id,clarifications:[...e.clarifications,...r],chat:[...e.chat,r[0]]})})),m())}else d((t=>Re(Re({},t),{},{chat:[...t.chat,{id:(0,Ee.A)(),type:we.$p.error,error:e}]})));null!==n&&void 0!==n&&n.current&&n.current.focus()}),[n,d,m]),{isLoading:j,onGenerate:y}=(0,xe.J)({query:qe({query:o,variableIds:we.Vs}),onSuccess:b,onError:x,checkErrorNotification:_e,schedulerState:i}),{maxLength:v}=(0,g.useMemo)((()=>t.find((e=>{let{id:t}=e;return t===we.Vs.reportDescription}))),[t]),{items:O}=(0,g.useMemo)((()=>t.find((e=>{let{id:t}=e;return t===we.Vs.clarifications}))),[t]),w=(0,g.useMemo)((()=>{var e;return(null===O||void 0===O||null===(e=O.properties)||void 0===e||null===(e=e.find((e=>{let{id:t}=e;return"response"===t})))||void 0===e?void 0:e.max_length)||1e3}),[O]),P=(0,g.useMemo)((()=>l.clarificationId?w||we.Gt:v||we.Gt),[l,v,w]),k=(0,g.useMemo)((()=>l.clarifications.some((e=>{let{response:t}=e;return!t}))),[l]),C=(0,g.useMemo)((()=>l.clarifications.map((e=>{let{id:t}=e;return t})).indexOf(l.clarificationId)===l.clarifications.length-1),[l]),S=(0,g.useMemo)((()=>j?"Loading...":null!==u&&void 0!==u&&u.length?null:"Please type something"),[j,u]),I=(0,g.useMemo)((()=>!(null===u||void 0===u||!u.length)),[u]),A=(0,g.useCallback)((e=>{d((t=>Re(Re({},t),{},{textValue:e})))}),[d]),D=(0,g.useCallback)((()=>{const e=ze({state:l,query:o,variableIds:we.Vs});s({id:l.variableId,value:e})}),[l,o,s]),T=(0,g.useCallback)((e=>{if(k){const{clarificationId:e,clarifications:t,pendingClarification:n}=(e=>{let t=e.clarificationId;const n=e.clarifications.map(((n,r)=>{var i;return n.id===e.clarificationId?(t=null===(i=e.clarifications[r+1])||void 0===i?void 0:i.id,Re(Re({},n),{},{response:e.textValue})):n})),r=n.find((e=>{let{response:t}=e;return!t}));return{clarificationId:t,clarifications:n,pendingClarification:r}})(l);if(C){const e=Re(Re({},o),{},{variables:o.variables.map((e=>e.id===we.Vs.clarifications?Re(Re({},e),{},{value:t}):e))});d((e=>Re(Re({},e),{},{chat:[...e.chat,Ne(e)]}))),y(e)}else d((r=>Re(Re({},r),{},{textValue:Le.textValue,clarificationId:e,clarifications:t,chat:[...r.chat,Ne(r),n]})))}else d((e=>Re(Re({},e),{},{chat:[...e.chat,Ne(e)]}))),y(e)}),[l,Le,o,k,C,y]),F=(0,g.useCallback)((()=>{I&&T()}),[I,T]),M=(0,g.useCallback)((e=>{if("Enter"===e.key&&!e.shiftKey&&I){e.preventDefault(),l.variableId===we.Vs.reportDescription&&s({id:l.variableId,value:l.textValue});const t=ze({state:l,query:o,variableIds:we.Vs}),n=Re(Re({},o),{},{variables:o.variables.map((e=>e.id===l.variableId?Re(Re({},e),{},{value:t}):e))});T(qe({query:n,variableIds:we.Vs}))}}),[l,o,I,s,T]),B=(0,g.useCallback)((e=>{let{id:t}=e;const n=(e=>Fe.map((e=>[...e.items])).flat().find((t=>t.id===e)))(t);n&&(d((e=>Re(Re({},e),{},{textValue:n.content}))),s({id:we.Vs.reportDescription,value:n.content}),null!==r&&void 0!==r&&r.current&&r.current.scrollTo({top:0,behavior:"smooth"}))}),[d,s,r]);return{isLoading:j,chat:h,submitButtonToootip:S,canSubmit:I,textValue:u,textPlaceHolder:p,textMaxLength:P,onTextChange:A,onTextBlur:D,onKeyDown:M,onSubmit:F,onExampleItemClick:B}},We=["canSubmit","isLoading","isActive"];function He(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 Ue(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?He(Object(n),!0).forEach((function(t){(0,r.A)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):He(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}const Ge=(0,N.A)(h.Button),Je=e=>{let{canSubmit:t,isLoading:n,isActive:r}=e,i=(0,p.A)(e,We);const o=(0,g.useMemo)((()=>!t||n?{}:{tooltip:r?"Report is scheduled":"Schedule report",tooltipProps:{align:"bottom"}}),[r,t,n]);return(0,s.jsx)(Ge,Ue(Ue({flavour:"hollow",disabled:!t||n,padding:[1,2],label:r?"Scheduled":"Schedule",icon:"clock_hollow",neutral:!r},o),i))},$e=e=>{let{flavour:t,variables:n,parentRef:r}=e;const o=(0,g.useRef)(),a=t===we.Rh.troubleshooter,[c,l]=(0,g.useState)(),{isLoading:d,chat:u,submitButtonToootip:p,canSubmit:m,textValue:f,textPlaceHolder:b,textMaxLength:x,onTextChange:j,onTextBlur:y,onKeyDown:v,onSubmit:O,onExampleItemClick:w}=Ke({variables:n,textRef:o,parentRef:r,schedulerState:c}),P=!!u.length,k=(0,g.useCallback)((e=>{const{name:t,rrule:n,recipientIds:r}=e||{};l({name:t,rrule:n,recipientIds:r})}),[l]),C=c?()=>l():void 0,S=(0,g.useCallback)((e=>(0,s.jsx)(Je,Ue({canSubmit:m,isLoading:d,isActive:!!c},e))),[m,d,c]);return(0,s.jsxs)(h.Flex,{"data-testid":"insights-custom-investigation-container",width:"100%",column:!0,gap:2,padding:[4,4,0,4],children:[P?null:(0,s.jsx)(h.TextBig,{color:"menuItem",children:"Start a New Investigation"}),(0,s.jsxs)(h.Flex,{"data-testid":"insights-investigation-container",width:"100%",alignItems:"center",column:!0,gap:2,children:[P?(0,s.jsx)(h.Flex,{"data-testid":"insights-investigation-chat-container",width:"100%",height:"calc(100vh - 570px)",overflow:{vertical:"auto"},column:!0,gap:2,padding:[2,2,2,0],children:(0,s.jsx)(Ie,{chat:u})}):null,(0,s.jsx)(h.Flex,{"data-testid":"insights-investigation-prompt-container",width:"100%",column:!0,gap:4,alignItems:"center",justifyContent:"center",children:(0,s.jsxs)(h.Flex,{"data-testid":"insights-investigation-prompt-input-container",width:"100%",position:"relative",children:[(0,s.jsx)(ue.A,{ref:o,tabIndex:"0","data-testid":"insights-investigation-prompt-input",width:"100%",maxLength:x,rows:3,placeholder:b,value:f,onChange:j,onBlur:y,onKeyDown:v,autoFocus:"autofocus",disabled:d,round:"2px"}),(0,s.jsxs)(h.Flex,{alignItems:"center",gap:2,position:"absolute",right:"8px",bottom:"8px",children:[(0,s.jsx)(be.A,{Accessor:S,onSubmit:k,onPause:C}),(0,s.jsx)(Ge,{onClick:O,disabled:!m||d,tooltip:p,padding:[.5,1.5],children:(0,s.jsx)(i.AQ,{isBlinking:d,name:"arrow_left",rotate:1})})]})]})})]}),P?null:(0,s.jsx)(Be,{isNarrow:a,onItemClick:w})]})};var Qe=n(62718),Ye=n(41588),Ze=(n(53921),n(41716)),Xe=n(56473);const et=()=>{const[e,t]=(0,g.useState)({}),n=(0,Ze.s)("loaded"),r=!!(0,Ze.s)("ids").length,i=(0,Xe.QD)({extraKey:"alerts"}),{onVariableChange:o}=(0,f.g0)(),s=(0,g.useCallback)((n=>{const r=Object.keys(n||{}),i=Object.keys(e||{}),s=1===r.length?r:r.filter((e=>!i.includes(e))),a=Object.fromEntries(s.map((e=>[e,!0])));o({id:"alert_transition",value:(null===s||void 0===s?void 0:s[0])||""}),t(a)}),[e,t,o]);return{rowSelection:e,onRowSelectionChange:s,loaded:n,hasAlerts:r,alerts:i}};var tt=n(61841),nt=n(24013),rt=n(75894),it=n(42376),ot=n(3527),st=n(74518),at=n(79748),ct=n(93997),lt=n(14681);const dt=e=>{let{row:t,value:n}=e;const{info:r}=t.original;return(0,s.jsx)(at.A,{Component:h.Text,flavour:"tableLink",cursor:"pointer",showToolTip:!0,content:r,children:n})},ut=e=>{let{row:t,nodeName:n}=e;const{id:r,nodeId:i}=t.original,o=(0,nt.d3)(i,{alertId:r});return(0,s.jsx)(lt.A,{nodeId:i,extraKey:"alerts",onClick:o,"data-testid":"alertsTableSchema-nodeName-".concat(n),"data-ga":"alerts-table::click-node::alerts-view::".concat(n),children:n})},pt=e=>{let{row:t,value:n}=e;const{id:r,nodeId:i,instanceName:o}=t.original,a=(0,nt.d3)(i,{alertId:r}),c='Go to the chart for instance "'.concat(o,'" to view the alert');return(0,s.jsx)(st.A,{flavour:"tableLink",onClick:a,TextComponent:at.A,text:o,"data-testid":"alertsTableSchema-chart-id-".concat(n),"data-ga":"alerts-table::click-chartId::alerts-view::".concat(n),showToolTip:!0,content:c})},gt={critical:1,warning:2,clear:3},ht=[{id:"status",accessorKey:"status",header:"Status",cell:e=>{let{getValue:t}=e;return(0,s.jsx)(h.Flex,{padding:[0,2],justifyContent:"center",flex:!0,children:(0,s.jsx)(rt.A,{flavour:t(),"data-testid":"alertsTable-alertPill","data-ga":"alerts-table::click-status::alerts-view::".concat(t()),children:t()})})},size:100,sortingFn:(e,t)=>gt[e.original.status]-gt[t.original.status]},{id:"summary",accessorKey:"summary",header:"Alert",cell:e=>{let{row:t,getValue:n}=e;return(0,s.jsx)(dt,{row:t,value:n()})},fullWidth:!0,size:300},{id:"displayName",accessorKey:"displayName",header:"Name",cell:e=>{let{row:t,getValue:n}=e;return(0,s.jsx)(dt,{row:t,value:n()})},size:100},{id:"context",accessorKey:"context",header:"Context",cell:e=>{let{getValue:t}=e;const n=(0,o.Zp)(),r=t(),[,i]=(0,ct.sK)(),a="Go to ".concat(r," context in charts overview"),[c,l]=(0,tt.Ay)(),d=(0,g.useCallback)((()=>{i(r),n("/spaces/".concat(c,"/rooms/").concat(l,"/overview"))}),[r,i,n,c,l]);return(0,s.jsx)(st.A,{flavour:"tableLink",onClick:d,TextComponent:at.A,text:r,"data-testid":"alertsTableSchema-alertContext-".concat(r),"data-ga":"alerts-table::click-chartId::alerts-view::".concat(r),showToolTip:!0,content:a})},size:100},{id:"instance",header:"Instance",accessorKey:"instance",cell:e=>{let{row:t,getValue:n}=e;return(0,s.jsx)(pt,{row:t,value:n()})},size:150},{id:"nodeName",header:"Node",accessorKey:"nodeName",cell:e=>{let{row:t,getValue:n}=e;return(0,s.jsx)(ut,{row:t,nodeName:n()})},size:100},{id:"value",header:"Latest value",accessorKey:"value",cell:e=>{let{row:t,getValue:n}=e;const{status:r,units:i}=t.original;return(0,s.jsx)(h.Flex,{padding:[0,2],justifyContent:"end",children:(0,s.jsx)(ot.A,{loaded:!0,status:r,units:i,value:n(),"data-testid":"alertsTableSchema-alertValue","data-ga":"alerts-table::click-alert-value::alerts-view"})})},size:150},{id:"lastUpdated",header:"Updated at",accessorKey:"lastUpdated",cell:e=>{let{getValue:t}=e;return(0,s.jsx)(it.A,{rawTime:t(),secs:!0,"data-testid":"alertsTableSchema-latestUpdated"})},size:100},{id:"lastStatusChangeValue",header:"Triggered value",accessorKey:"lastStatusChangeValue",cell:e=>{let{row:t,getValue:n}=e;const{status:r,units:i}=t.original;return(0,s.jsx)(h.Flex,{padding:[0,2],justifyContent:"end",children:(0,s.jsx)(ot.A,{loaded:!0,status:r,units:i,value:n(),"data-testid":"alertsTableSchema-triggeredValue","data-ga":"alerts-table::click-triggered-value::alerts-view"})})},size:100},{id:"lastStatusChange",header:"Triggered at",accessorKey:"lastStatusChange",cell:e=>{let{getValue:t}=e;return(0,s.jsx)(it.A,{rawTime:t(),secs:!0,"data-testid":"alertsTableSchema-lastStatusChange"})},size:100}],mt=e=>{let{rowSelection:t,alerts:n=[],onRowSelectionChange:r}=e;return(0,s.jsx)(h.Flex,{width:{max:"calc(100vw - 640px)"},height:{max:"calc(100vh - 540px)"},children:(0,s.jsx)(h.Table,{rowSelection:t,enableSorting:!0,enableSelection:!0,singleRowSelection:!0,getRowId:e=>{let{id:t}=e;return t},onRowSelectionChange:r,data:n,dataColumns:ht,enableColumnPinning:!0,enableResizing:!0,meta:{searchStyles:{width:"350px"}}})})},ft=()=>{const{rowSelection:e,onRowSelectionChange:t,loaded:n,hasAlerts:r,alerts:i}=et();return n?r?(0,s.jsxs)(h.Flex,{"data-testid":"insights-alert-investigation-container",width:"100%",column:!0,gap:4,padding:[4,0,0,0],children:[(0,s.jsx)(h.Text,{children:"Select an alert to start an investigation."}),(0,s.jsx)(mt,{rowSelection:e,alerts:i,onRowSelectionChange:t}),(0,s.jsx)(h.Flex,{justifyContent:"center",children:(0,s.jsx)(xe.A,{label:"Troubleshoot selected alert",incompleteQueryMessage:"First select an alert and then generate a report."})})]}):(0,s.jsx)(Ye.A,{}):(0,s.jsx)(Qe.$n,{})};n(26910);const bt=(0,x.default)(h.Box).withConfig({displayName:"loader__Loader",componentId:"sc-1s7ni28-0"})(["width:60px;aspect-ratio:2;--dot:no-repeat radial-gradient(circle closest-side,"," 90%,#0000);background:var(--dot) 0% 50%,var(--dot) 50% 50%,var(--dot) 100% 50%;background-size:calc(100% / 3) 50%;animation:movingDots 1s infinite linear;@keyframes movingDots{20%{background-position:0% 0%,50% 50%,100% 50%;}40%{background-position:0% 100%,50% 0%,100% 50%;}60%{background-position:0% 50%,50% 100%,100% 0%;}80%{background-position:0% 50%,50% 50%,100% 100%;}}"],(0,h.getColor)("textLite"));var xt=n(3941);function jt(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 yt=(0,x.default)(h.TextBigger).attrs((e=>function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?jt(Object(n),!0).forEach((function(t){(0,r.A)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):jt(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({lineHeight:2,textAlign:"center",color:"primary"},e))).withConfig({displayName:"quotes__QuoteText",componentId:"sc-xo7l3k-0"})(["font-family:monospace;"]),vt=pe.a_.sort((()=>Math.random()-.5)),Ot=e=>{let{frequency:t=60}=e;const[n,r]=(0,g.useState)(t),[i,o]=(0,g.useState)(0),[a,c]=(0,g.useState)(0),l=(0,g.useCallback)((()=>{i>=100&&c((e=>e===vt.length-1?0:e+1)),o((e=>i>=100?0:e+.2))}),[i,o,c,r]);return(0,xt.A)(l,n),(0,s.jsxs)(h.Flex,{width:{max:"50%"},column:!0,gap:12,alignItems:"center",children:[(0,s.jsx)(yt,{children:vt[a].text}),(0,s.jsx)(bt,{})]})},wt=()=>(0,s.jsxs)(h.Flex,{column:!0,gap:20,flex:"grow",justifyContent:"center",children:[(0,s.jsx)(h.Flex,{width:"100%",alignItems:"center",justifyContent:"center",children:(0,s.jsx)(Ot,{})}),(0,s.jsx)(h.Flex,{width:"100%",alignItems:"center",justifyContent:"center",children:(0,s.jsx)(h.TextBigger,{color:"textLite",children:"Your report is being generated. This may take a few minutes. You will be notified when it is ready."})})]}),Pt=["containerRef"];function kt(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 Ct(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?kt(Object(n),!0).forEach((function(t){(0,r.A)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):kt(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}const St=(0,N.A)(h.Icon),It=()=>{const{query:e}=(0,f.g0)(),t=(0,f.fT)();return null!==e&&void 0!==e&&e.definitionId?(0,s.jsx)(h.Flex,{position:"absolute",top:2,right:2,children:(0,s.jsx)(St,{name:"x",color:"menuItem",cursor:"pointer",onClick:t,tooltip:"Back to overview",tooltipProps:{align:"bottom"},noWrapper:!0})}):null},At=e=>{let{containerRef:t}=e,n=(0,p.A)(e,Pt);const[r,i]=(0,g.useState)(),o=(0,g.useMemo)((()=>({width:"100%",height:"".concat(r,"px"),overflow:{vertical:"auto"}})),[r]);return(0,g.useEffect)((()=>{var e;null!==t&&void 0!==t&&t.current&&i((null===(e=t.current.getBoundingClientRect())||void 0===e?void 0:e.height)-60)}),[t,i]),(0,s.jsx)(h.Flex,Ct(Ct({},o),{},{children:(0,s.jsx)($e,Ct({},n))}))},Dt=(e=>t=>{const n=(0,g.useRef)();return(0,s.jsxs)(h.Flex,{position:"relative",flex:"grow",justifyContent:"center",ref:n,"data-testid":"insights-query-generator-container",children:[(0,s.jsx)(It,{}),(0,s.jsx)(e,Ct(Ct({},t),{},{containerRef:n}))]})})((e=>{let{definitionId:t,definitionName:n,variables:r=[],containerRef:i}=e;const o=(0,m.uW)("isAnonymous"),[a]=(0,f.W5)(),c=(0,g.useMemo)((()=>({[pe.oG.investigation]:{Component:At,props:{variables:r,containerRef:i}},[pe.oG.alertInvestigation]:{Component:ft,props:{}},default:{Component:Oe,props:{definitionId:t,definitionName:n,variables:r}}})),[t,n,r,i]),{Component:l,props:d}=(0,g.useMemo)((()=>c[t]||c.default),[t,c]);return o?null:a?(0,s.jsx)(wt,{}):t?(0,s.jsx)(l,Ct({},d)):(0,s.jsx)(M,{})}));var Tt=n(74090),Ft=n(24868),Mt=n(99728),Bt=n(76375),Et=n(98157),Vt=n(50100);function Rt(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 zt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Rt(Object(n),!0).forEach((function(t){(0,r.A)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Rt(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}const Nt=e=>{let{id:t}=e;const n=(0,f.CF)({id:t}),[r,i]=(0,O.useHovered)({},[]),{goToReport:o}=(0,Vt.A)(),a=(0,g.useCallback)((()=>{o(t)}),[t,o]);return null!==n&&void 0!==n&&n.name?(0,s.jsx)(h.Flex,zt(zt({ref:r,padding:[2,4],round:!0,cursor:"pointer"},i?{background:"panelBg"}:{}),{},{onClick:a,children:(0,s.jsx)(h.Text,{color:"menuItem",children:n.name})})):null};var qt=n(10444);const _t=(0,x.default)(h.ModalContent).attrs((e=>{let{isMobile:t}=e;return{width:t?{base:"95vw"}:{base:100}}})).withConfig({displayName:"modal__StyledModalContent",componentId:"sc-1tq9d73-0"})([""]),Lt=e=>{let{ids:t,onClose:n}=e;const r=(0,qt.J)();return(0,s.jsx)(h.Modal,{backdropProps:{backdropBlur:!0},onClickOutside:n,onEsc:n,children:(0,s.jsxs)(_t,{"data-testid":"unread-reports-modal",isMobile:r,children:[(0,s.jsxs)(h.ModalHeader,{children:[(0,s.jsx)(h.H4,{children:"Unread Reports"}),(0,s.jsx)(h.ModalCloseButton,{onClose:n})]}),(0,s.jsxs)(h.ModalBody,{gap:3,children:[(0,s.jsx)(h.TextBig,{children:"Which report would you like to open?"}),(0,s.jsx)(h.Flex,{column:!0,gap:2,padding:[2,0],children:t.map((e=>(0,s.jsx)(Nt,{id:e},e)))})]})]})})},Kt=e=>{let{ids:t,open:n}=e;const{goToReport:r}=(0,Vt.A)(),i=(0,g.useCallback)((()=>{null!==t&&void 0!==t&&t.length&&(1===t.length?r(t[0]):n())}),[t,n,r]);return null!==t&&void 0!==t&&t.length?1===t.length?(0,s.jsxs)(h.TextBig,{children:["There is one unread report."," ",(0,s.jsx)(at.A,{Component:h.TextBig,onClick:i,children:"View it"})]}):(0,s.jsxs)(h.TextBig,{children:["There are ",t.length," unread reports."," ",(0,s.jsx)(at.A,{Component:h.TextBig,onClick:i,children:"View them"})]}):null},Wt=()=>{const[e,,t,n]=(0,oe.A)(),[r]=(0,f.x)();return null!==r&&void 0!==r&&r.length?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(h.Flex,{alignItems:"center",gap:2,padding:[2,4],background:"panelBg",children:[(0,s.jsx)(h.Icon,{name:"warning_triangle",color:"warning"}),(0,s.jsx)(Kt,{ids:r,open:t})]}),e?(0,s.jsx)(Lt,{ids:r,onClose:n}):null]}):null};var Ht=n(29022),Ut=n(47090);function Gt(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 Jt=e=>{let{title:t,message:n}=e;return(0,s.jsx)(Ht.A,{title:t,children:(0,s.jsx)(h.TextBig,{children:n})})},$t=e=>{let{title:t="Error",error:n}=e;if(!n)return(0,s.jsx)(Jt,{title:t,message:"Something went wromg"});const i=pe.sO[null===n||void 0===n?void 0:n.errorMsgKey];if(i)return(0,s.jsx)(Jt,function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Gt(Object(n),!0).forEach((function(t){(0,r.A)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Gt(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({},i));const o="string"===typeof n?n:(0,Ut.o)(null===n||void 0===n?void 0:n.errorMsgKey,null)||(null===n||void 0===n?void 0:n.errorMessage)||Ut.B.get("default");return(0,s.jsx)(Jt,{title:t,message:o})};var Qt=n(4204);function Yt(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 Zt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Yt(Object(n),!0).forEach((function(t){(0,r.A)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Yt(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}const Xt=()=>{const e=(0,Mt.JT)("insights:ReadReport"),{loaded:t,error:n}=(0,f.A_)(),[r]=(0,f.rQ)(),{loaded:c,isPaid:l}=(0,Bt.A)();return t&&c?e?n?(0,s.jsx)($t,{error:n}):(0,s.jsx)(a,{Sidebar:u,children:(0,s.jsxs)(i.J3,{"data-testid":"insights-main-container",children:[(0,s.jsx)(Wt,{}),(0,s.jsxs)(o.BV,{children:[(0,s.jsx)(o.qh,{path:"report-preview/:reportId",element:(0,s.jsx)(Tt.A,{})}),(0,s.jsx)(o.qh,{path:"*",element:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(Dt,Zt({},r)),(0,s.jsx)(Ft.A,{collapsed:!(null!==r&&void 0!==r&&r.definitionId)},null===r||void 0===r?void 0:r.definitionId)]})})]})]})}):l?(0,s.jsx)($t,{error:{errorMsgKey:"ErrForbidden"}}):(0,s.jsx)(Et.A,{}):(0,s.jsx)(Qe.BJ,{})},en=()=>Qt.ei?(0,s.jsx)(Et.A,{}):(0,s.jsx)(Xt,{})}}]);