i)?-1:1})):e}),[m,t,c,d,o]),_=(0,r.useMemo)((function(){return y.some((function(e){return e.copyValue}))}),[y]),b=function(e){return function(){!function(e){h((function(t){return"asc"===t&&c===e?"desc":"asc"})),s(e)}(e)}};return y.length?Kt("div",{className:Jr()({"vm-table-view":!0,"vm-table-view_mobile":i}),children:Kt("table",{className:"vm-table",ref:l,children:[Kt("thead",{className:"vm-table-header",children:Kt("tr",{className:"vm-table__row vm-table__row_header",children:[m.map((function(e,t){return Kt("td",{className:"vm-table-cell vm-table-cell_header vm-table-cell_sort",onClick:b(e.key),children:Kt("div",{className:"vm-table-cell__content",children:[e.key,Kt("div",{className:Jr()({"vm-table__sort-icon":!0,"vm-table__sort-icon_active":c===e.key,"vm-table__sort-icon_desc":"desc"===d&&c===e.key}),children:Kt(vr,{})})]})},t)})),Kt("td",{className:"vm-table-cell vm-table-cell_header vm-table-cell_right vm-table-cell_sort",onClick:b("Value"),children:Kt("div",{className:"vm-table-cell__content",children:[Kt("div",{className:Jr()({"vm-table__sort-icon":!0,"vm-table__sort-icon_active":"Value"===c,"vm-table__sort-icon_desc":"desc"===d}),children:Kt(vr,{})}),"Value"]})}),_&&Kt("td",{className:"vm-table-cell vm-table-cell_header"})]})}),Kt("tbody",{className:"vm-table-body",children:y.map((function(e,t){return Kt("tr",{className:"vm-table__row",children:[e.metadata.map((function(e,n){return Kt("td",{className:Jr()({"vm-table-cell vm-table-cell_no-wrap":!0,"vm-table-cell_gray":y[t-1]&&y[t-1].metadata[n]===e}),children:e},n)})),Kt("td",{className:"vm-table-cell vm-table-cell_right vm-table-cell_no-wrap",children:e.values.length?e.values.map((function(e){return Kt("p",{children:e},e)})):e.value}),_&&Kt("td",{className:"vm-table-cell vm-table-cell_right",children:e.copyValue&&Kt("div",{className:"vm-table-cell__content",children:Kt(qa,{title:"Copy row",children:Kt(Pa,{variant:"text",color:"gray",size:"small",startIcon:Kt(Or,{}),onClick:(n=e.copyValue,si(ui().mark((function e(){return ui().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,a(n,"Row has been copied");case 2:case"end":return e.stop()}}),e)})))),ariaLabel:"copy row"})})})})]},t);var n}))})]})}):Kt(Ea,{variant:"warning",children:"No data to show"})},eh=function(e){var t,n=e.checked,r=void 0!==n&&n,a=e.disabled,i=void 0!==a&&a,o=e.label,l=e.color,u=void 0===l?"secondary":l,c=e.onChange;return Kt("div",{className:Jr()((ct(t={"vm-checkbox":!0,"vm-checkbox_disabled":i,"vm-checkbox_active":r},"vm-checkbox_".concat(u,"_active"),r),ct(t,"vm-checkbox_".concat(u),u),t)),onClick:function(){i||c(!r)},children:[Kt("div",{className:"vm-checkbox-track",children:Kt("div",{className:"vm-checkbox-track__thumb",children:Kt(Nr,{})})}),o&&Kt("span",{className:"vm-checkbox__label",children:o})]})},th="Table settings",nh=function(e){var t=e.columns,n=e.defaultColumns,a=void 0===n?[]:n,i=e.tableCompact,o=e.onChangeColumns,l=e.toggleTableCompact,u=xa().isMobile,c=(0,r.useRef)(null),s=Ia(!1),f=s.value,d=s.toggle,h=s.setFalse,m=(0,r.useMemo)((function(){return!t.length}),[t]),p=function(e){return function(){!function(e){o(a.includes(e)?a.filter((function(t){return t!==e})):[].concat(y(a),[e]))}(e)}};return(0,r.useEffect)((function(){ed(t,a)||o(t)}),[t]),Kt("div",{className:"vm-table-settings",children:[Kt(qa,{title:th,children:Kt("div",{ref:c,children:Kt(Pa,{variant:"text",startIcon:Kt(lr,{}),onClick:d,disabled:m,ariaLabel:"table settings"})})}),Kt(Ra,{open:f,onClose:h,placement:"bottom-right",buttonRef:c,title:th,children:Kt("div",{className:Jr()({"vm-table-settings-popper":!0,"vm-table-settings-popper_mobile":u}),children:[Kt("div",{className:"vm-table-settings-popper-list vm-table-settings-popper-list_first",children:Kt(Kf,{label:"Compact view",value:i,onChange:l})}),Kt("div",{className:"vm-table-settings-popper-list",children:[Kt("div",{className:"vm-table-settings-popper-list-header",children:[Kt("h3",{className:"vm-table-settings-popper-list-header__title",children:"Display columns"}),Kt(qa,{title:"Reset to default",children:Kt(Pa,{color:"primary",variant:"text",size:"small",onClick:function(){h(),o(t)},startIcon:Kt(cr,{}),ariaLabel:"reset columns"})})]}),t.map((function(e){return Kt("div",{className:"vm-table-settings-popper-list__item",children:Kt(eh,{checked:a.includes(e),onChange:p(e),label:e,disabled:i})},e)}))]})]})})]})},rh=function(e){var t=e.liveData,n=e.controlsRef,a=pa().tableCompact,i=va(),o=v((0,r.useState)(),2),l=o[0],u=o[1],c=(0,r.useMemo)((function(){return Gd(t||[]).map((function(e){return e.key}))}),[t]),s=Kt(nh,{columns:c,defaultColumns:l,onChangeColumns:u,tableCompact:a,toggleTableCompact:function(){i({type:"TOGGLE_TABLE_COMPACT"})}});return Kt(Zt.HY,{children:[n.current&&(0,r.createPortal)(s,n.current),Kt(Xd,{data:t,displayColumns:l})]})},ah=function(e){var t=e.graphData,n=e.liveData,r=e.isHistogram,a=e.displayType,i=e.controlsRef;return a===Rt.code&&n?Kt(Zd,{data:n}):a===Rt.table&&n?Kt(rh,{liveData:n,controlsRef:i}):a===Rt.chart&&t?Kt(Qd,{graphData:t,isHistogram:r,controlsRef:i}):null},ih=[Kt(Zt.HY,{children:[Kt("p",{children:"Filename - specify the name for your report file."}),Kt("p",{children:["Default format: ",Kt("code",{children:["vmui_report_$",ln,".json"]}),"."]}),Kt("p",{children:"This name will be used when saving your report on your device."})]}),Kt(Zt.HY,{children:[Kt("p",{children:"Comment (optional) - add a comment to your report."}),Kt("p",{children:"This can be any additional information that will be useful when reviewing the report later."})]}),Kt(Zt.HY,{children:[Kt("p",{children:"Query trace - enable this option to include a query trace in your report."}),Kt("p",{children:"This will assist in analyzing and diagnosing the query processing."})]}),Kt(Zt.HY,{children:[Kt("p",{children:"Generate Report - click this button to generate and save your report. "}),Kt("p",{children:["After creation, the report can be downloaded and examined on the ",Kt(rt,{to:yt.queryAnalyzer,target:"_blank",rel:"noreferrer",className:"vm-link vm-link_underlined",children:gt[yt.queryAnalyzer].title})," page."]})]})],oh=function(){return"vmui_report_".concat(i()().utc().format(ln))},lh=function(e){var t=e.fetchUrl,n=tr().query,a=v((0,r.useState)(oh()),2),i=a[0],o=a[1],l=v((0,r.useState)(""),2),u=l[0],c=l[1],s=v((0,r.useState)(!0),2),f=s[0],d=s[1],h=v((0,r.useState)(),2),m=h[0],p=h[1],g=v((0,r.useState)(!1),2),y=g[0],_=g[1],b=(0,r.useRef)(null),w=(0,r.useRef)(null),k=(0,r.useRef)(null),D=(0,r.useRef)(null),x=[b,w,k,D],C=v((0,r.useState)(0),2),E=C[0],S=C[1],A=Ia(!1),N=A.value,M=A.toggle,T=A.setFalse,F=Ia(!1),O=F.value,L=F.toggle,P=F.setFalse,I=(0,r.useMemo)((function(){if(t)return t.map((function(e,t){var n=new URL(e);return f?n.searchParams.set("trace","1"):n.searchParams.delete("trace"),{id:t,url:n}}))}),[t,f]),R=(0,r.useCallback)((function(e){var t=JSON.stringify(e,null,2),n=new Blob([t],{type:"application/json"}),r=URL.createObjectURL(n),a=document.createElement("a");a.href=r,a.download="".concat(i||oh(),".json"),document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(r),T()}),[i]),B=(0,r.useCallback)(si(ui().mark((function e(){var t,n,r,a,i,o,l,c,s,f,d,h;return ui().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(I){e.next=3;break}return p(Bt.validQuery),e.abrupt("return");case 3:p(""),_(!0),e.prev=5,t=[],n=!1,r=!1,e.prev=9,i=ud(I);case 11:return e.next=13,i.next();case 13:if(!(n=!(o=e.sent).done)){e.next=25;break}return l=o.value,c=l.url,s=l.id,e.next=17,fetch(c);case 17:return f=e.sent,e.next=20,f.json();case 20:d=e.sent,f.ok?(d.vmui={id:s,comment:u,params:Nt().parse(new URL(c).search.replace(/^\?/,""))},t.push(d)):(h=d.errorType?"".concat(d.errorType,"\r\n"):"",p("".concat(h).concat((null===d||void 0===d?void 0:d.error)||(null===d||void 0===d?void 0:d.message)||"unknown error")));case 22:n=!1,e.next=11;break;case 25:e.next=31;break;case 27:e.prev=27,e.t0=e.catch(9),r=!0,a=e.t0;case 31:if(e.prev=31,e.prev=32,!n||null==i.return){e.next=36;break}return e.next=36,i.return();case 36:if(e.prev=36,!r){e.next=39;break}throw a;case 39:return e.finish(36);case 40:return e.finish(31);case 41:t.length&&R(t),e.next=47;break;case 44:e.prev=44,e.t1=e.catch(5),e.t1 instanceof Error&&"AbortError"!==e.t1.name&&p("".concat(e.t1.name,": ").concat(e.t1.message));case 47:return e.prev=47,_(!1),e.finish(47);case 50:case"end":return e.stop()}}),e,null,[[5,44,47,50],[9,27,31,41],[32,,36,40]])}))),[I,u,R,n]),z=function(e){return function(){S((function(t){return t+e}))}};return(0,r.useEffect)((function(){p(""),o(oh()),c("")}),[N]),(0,r.useEffect)((function(){S(0)}),[O]),Kt(Zt.HY,{children:[Kt(qa,{title:"Export query",children:Kt(Pa,{variant:"text",startIcon:Kt(Gr,{}),onClick:M,ariaLabel:"export query"})}),N&&Kt(Ya,{title:"Export query",onClose:T,isOpen:N,children:Kt("div",{className:"vm-download-report",children:[Kt("div",{className:"vm-download-report-settings",children:[Kt("div",{ref:b,children:Kt(wi,{label:"Filename",value:i,onChange:o})}),Kt("div",{ref:w,children:Kt(wi,{type:"textarea",label:"Comment",value:u,onChange:c})}),Kt("div",{ref:k,children:Kt(eh,{checked:f,onChange:d,label:"Include query trace"})})]}),m&&Kt(Ea,{variant:"error",children:m}),Kt("div",{className:"vm-download-report__buttons",children:[Kt(Pa,{variant:"text",onClick:L,children:"Help"}),Kt("div",{ref:D,children:Kt(Pa,{onClick:B,disabled:y,children:y?"Loading data...":"Generate Report"})})]}),Kt(Ra,{open:O,buttonRef:x[E],placement:"top-left",variant:"dark",onClose:P,children:Kt("div",{className:"vm-download-report-helper",children:[Kt("div",{className:"vm-download-report-helper__description",children:ih[E]}),Kt("div",{className:"vm-download-report-helper__buttons",children:[0!==E&&Kt(Pa,{onClick:z(-1),size:"small",color:"white",children:"Prev"}),Kt(Pa,{onClick:E===x.length-1?P:z(1),size:"small",color:"white",variant:"text",children:E===x.length-1?"Close":"Next"})]})]})})]})})]})},uh=function(){!function(){var e=Xt().tenantId,t=pa().displayType,n=tr().query,a=Vn(),i=a.duration,o=a.relativeTime,l=a.period,u=l.date,c=l.step,s=ba().customStep,f=v(ut(),2)[1],d=function(){var r={};n.forEach((function(n,a){var l,f="g".concat(a);r["".concat(f,".expr")]=n,r["".concat(f,".range_input")]=i,r["".concat(f,".end_input")]=u,r["".concat(f,".tab")]=(null===(l=la.find((function(e){return e.value===t})))||void 0===l?void 0:l.prometheusCode)||0,r["".concat(f,".relative_time")]=o,r["".concat(f,".tenantID")]=e,c!==s&&s&&(r["".concat(f,".step_input")]=s)})),f(md(r))};(0,r.useEffect)(d,[e,t,n,i,o,u,c,s]),(0,r.useEffect)(d,[])}();var e=xa().isMobile,t=pa().displayType,n=tr().query,a=ba().customStep,i=wa(),o=v((0,r.useState)([]),2),l=o[0],u=o[1],c=v((0,r.useState)(!n[0]),2),s=c[0],f=c[1],d=v((0,r.useState)(!1),2),h=d[0],m=d[1],p=(0,r.useRef)(null),g=dd({visible:!0,customStep:a,hideQuery:l,showAllSeries:h}),y=g.fetchUrl,_=g.isLoading,b=g.liveData,w=g.graphData,k=g.error,D=g.queryErrors,x=g.setQueryErrors,C=g.queryStats,E=g.warning,S=g.traces,A=g.isHistogram,N=!(null!==b&&void 0!==b&&b.length)&&t!==Rt.chart,M=!s&&k;return aa("popstate",(function(){return window.location.reload()})),(0,r.useEffect)((function(){i({type:"SET_IS_HISTOGRAM",payload:A})}),[w]),Kt("div",{className:Jr()({"vm-custom-panel":!0,"vm-custom-panel_mobile":e}),children:[Kt(ld,{queryErrors:s?[]:D,setQueryErrors:x,setHideError:f,stats:C,onHideQuery:function(e){u(e)},onRunQuery:function(){f(!1)}}),Kt(xd,{traces:S,displayType:t}),_&&Kt(hd,{}),M&&Kt(Ea,{variant:"error",children:k}),N&&Kt(Ea,{variant:"info",children:Kt(_d,{})}),E&&Kt(Cd,{warning:E,query:n,onChange:m}),Kt("div",{className:Jr()({"vm-custom-panel-body":!0,"vm-custom-panel-body_mobile":e,"vm-block":!0,"vm-block_mobile":e}),children:[Kt("div",{className:"vm-custom-panel-body-header",ref:p,children:[Kt("div",{className:"vm-custom-panel-body-header__tabs",children:Kt(ua,{})}),(w||b)&&Kt(lh,{fetchUrl:y})]}),Kt(ah,{graphData:w,liveData:b,isHistogram:A,displayType:t,controlsRef:p})]})]})},ch=function(e){var t=e.title,n=e.description,a=e.unit,i=e.expr,o=e.showLegend,l=e.filename,u=e.alias,c=xa().isMobile,s=Vn().period,f=ba().customStep,d=Un(),h=(0,r.useRef)(null),m=v((0,r.useState)(!1),2),p=m[0],g=m[1],y=v((0,r.useState)({limits:{enable:!1,range:{1:[0,0]}}}),2),_=y[0],b=y[1],w=(0,r.useMemo)((function(){return Array.isArray(i)&&i.every((function(e){return e}))}),[i]),k=dd({predefinedQuery:w?i:[],display:Rt.chart,visible:p,customStep:f}),D=k.isLoading,x=k.graphData,C=k.error,E=k.warning,S=function(e){var t=ft({},_);t.limits.range=e,b(t)};return(0,r.useEffect)((function(){var e=new IntersectionObserver((function(e){e.forEach((function(e){return g(e.isIntersecting)}))}),{threshold:.1});return h.current&&e.observe(h.current),function(){h.current&&e.unobserve(h.current)}}),[h]),w?Kt("div",{className:"vm-predefined-panel",ref:h,children:[Kt("div",{className:"vm-predefined-panel-header",children:[Kt(qa,{title:Kt((function(){return Kt("div",{className:"vm-predefined-panel-header__description vm-default-styles",children:[n&&Kt(Zt.HY,{children:[Kt("div",{children:[Kt("span",{children:"Description:"}),Kt("div",{dangerouslySetInnerHTML:{__html:$f.parse(n)}})]}),Kt("hr",{})]}),Kt("div",{children:[Kt("span",{children:"Queries:"}),Kt("div",{children:i.map((function(e,t){return Kt("div",{children:e},"".concat(t,"_").concat(e))}))})]})]})}),{}),children:Kt("div",{className:"vm-predefined-panel-header__info",children:Kt(sr,{})})}),Kt("h3",{className:"vm-predefined-panel-header__title",children:t||""}),Kt(Wd,{yaxis:_,setYaxisLimits:S,toggleEnableLimits:function(){var e=ft({},_);e.limits.enable=!e.limits.enable,b(e)}})]}),Kt("div",{className:"vm-predefined-panel-body",children:[D&&Kt(hd,{}),C&&Kt(Ea,{variant:"error",children:C}),E&&Kt(Ea,{variant:"warning",children:E}),x&&Kt(Ud,{data:x,period:s,customStep:f,query:i,yaxis:_,unit:a,alias:u,showLegend:o,setYaxisLimits:S,setPeriod:function(e){var t=e.from,n=e.to;d({type:"SET_PERIOD",payload:{from:t,to:n}})},fullWidth:!1,height:c?.5*window.innerHeight:500})]})]}):Kt(Ea,{variant:"error",children:[Kt("code",{children:'"expr"'})," not found. Check the configuration file ",Kt("b",{children:l}),"."]})},sh=function(e){var t=e.index,n=e.title,a=e.panels,i=e.filename,o=ia(),l=(0,r.useMemo)((function(){return o.width/12}),[o]),u=v((0,r.useState)(!t),2),c=u[0],s=u[1],f=v((0,r.useState)([]),2),d=f[0],h=f[1];(0,r.useEffect)((function(){h(a&&a.map((function(e){return e.width||12})))}),[a]);var m=v((0,r.useState)({start:0,target:0,enable:!1}),2),p=m[0],g=m[1],y=(0,r.useCallback)((function(e){if(p.enable){var t=p.start,n=Math.ceil((t-e.clientX)/l);if(!(Math.abs(n)>=12)){var r=d.map((function(e,t){return e-(t===p.target?n:0)}));h(r)}}}),[p,l]),_=(0,r.useCallback)((function(){g(ft(ft({},p),{},{enable:!1}))}),[p]),b=function(e){return function(t){!function(e,t){g({start:e.clientX,target:t,enable:!0})}(t,e)}};return aa("mousemove",y),aa("mouseup",_),Kt("div",{className:"vm-predefined-dashboard",children:Kt(Ji,{defaultExpanded:c,onChange:function(e){return s(e)},title:Kt((function(){return Kt("div",{className:Jr()({"vm-predefined-dashboard-header":!0,"vm-predefined-dashboard-header_open":c}),children:[(n||i)&&Kt("span",{className:"vm-predefined-dashboard-header__title",children:n||"".concat(t+1,". ").concat(i)}),a&&Kt("span",{className:"vm-predefined-dashboard-header__count",children:["(",a.length," panels)"]})]})}),{}),children:Kt("div",{className:"vm-predefined-dashboard-panels",children:Array.isArray(a)&&a.length?a.map((function(e,t){return Kt("div",{className:"vm-predefined-dashboard-panels-panel vm-block vm-block_empty-padding",style:{gridColumn:"span ".concat(d[t])},children:[Kt(ch,{title:e.title,description:e.description,unit:e.unit,expr:e.expr,alias:e.alias,filename:i,showLegend:e.showLegend}),Kt("button",{className:"vm-predefined-dashboard-panels-panel__resizer",onMouseDown:b(t),"aria-label":"resize the panel"})]},t)})):Kt("div",{className:"vm-predefined-dashboard-panels-panel__alert",children:Kt(Ea,{variant:"error",children:[Kt("code",{children:'"panels"'})," not found. Check the configuration file ",Kt("b",{children:i}),"."]})})})})})},fh=function(){!function(){var e=Vn(),t=e.duration,n=e.relativeTime,a=e.period.date,i=ba().customStep,o=Vi().setSearchParamsFromKeys,l=function(){var e,r=md((ct(e={},"g0.range_input",t),ct(e,"g0.end_input",a),ct(e,"g0.step_input",i),ct(e,"g0.relative_time",n),e));o(r)};(0,r.useEffect)(l,[t,n,a,i]),(0,r.useEffect)(l,[])}();var e=xa().isMobile,t=Ta(),n=t.dashboardsSettings,a=t.dashboardsLoading,i=t.dashboardsError,o=v((0,r.useState)(0),2),l=o[0],u=o[1],c=(0,r.useMemo)((function(){return n.map((function(e,t){return{label:e.title||"",value:t}}))}),[n]),s=(0,r.useMemo)((function(){return n[l]||{}}),[n,l]),f=(0,r.useMemo)((function(){return null===s||void 0===s?void 0:s.rows}),[s]),d=(0,r.useMemo)((function(){return s.title||s.filename||""}),[s]),h=(0,r.useMemo)((function(){return Array.isArray(f)&&!!f.length}),[f]),m=function(e){return function(){!function(e){u(e)}(e)}};return Kt("div",{className:"vm-predefined-panels",children:[a&&Kt(hd,{}),!n.length&&i&&Kt(Ea,{variant:"error",children:i}),!n.length&&Kt(Ea,{variant:"info",children:"Dashboards not found"}),c.length>1&&Kt("div",{className:Jr()({"vm-predefined-panels-tabs":!0,"vm-predefined-panels-tabs_mobile":e}),children:c.map((function(e){return Kt("div",{className:Jr()({"vm-predefined-panels-tabs__tab":!0,"vm-predefined-panels-tabs__tab_active":e.value==l}),onClick:m(e.value),children:e.label},e.value)}))}),Kt("div",{className:"vm-predefined-panels__dashboards",children:[h&&f.map((function(e,t){return Kt(sh,{index:t,filename:d,title:e.title,panels:e.panels},"".concat(l,"_").concat(t))})),!!n.length&&!h&&Kt(Ea,{variant:"error",children:[Kt("code",{children:'"rows"'})," not found. Check the configuration file ",Kt("b",{children:d}),"."]})]})]})},dh=function(e,t){var n=t.match?"&match[]="+encodeURIComponent(t.match):"",r=t.focusLabel?"&focusLabel="+encodeURIComponent(t.focusLabel):"";return"".concat(e,"/api/v1/status/tsdb?topN=").concat(t.topN,"&date=").concat(t.date).concat(n).concat(r)},hh=function(){function e(){_(this,e),this.tsdbStatus=void 0,this.tabsNames=void 0,this.isPrometheus=void 0,this.tsdbStatus=this.defaultTSDBStatus,this.tabsNames=["table","graph"],this.isPrometheus=!1,this.getDefaultState=this.getDefaultState.bind(this)}return D(e,[{key:"tsdbStatusData",get:function(){return this.tsdbStatus},set:function(e){this.isPrometheus=!(null===e||void 0===e||!e.headStats),this.tsdbStatus=e}},{key:"defaultTSDBStatus",get:function(){return{totalSeries:0,totalSeriesPrev:0,totalSeriesByAll:0,totalLabelValuePairs:0,seriesCountByMetricName:[],seriesCountByLabelName:[],seriesCountByFocusLabelValue:[],seriesCountByLabelValuePair:[],labelValueCountByLabelName:[]}}},{key:"isPrometheusData",get:function(){return this.isPrometheus}},{key:"keys",value:function(e,t){var n=e&&/__name__=".+"/.test(e),r=e&&/{.+=".+"}/g.test(e),a=e&&/__name__=".+", .+!=""/g.test(e),i=[];return i=t||a?i.concat("seriesCountByFocusLabelValue"):n?i.concat("labelValueCountByLabelName"):r?i.concat("seriesCountByMetricName","seriesCountByLabelName"):i.concat("seriesCountByMetricName","seriesCountByLabelName","seriesCountByLabelValuePair","labelValueCountByLabelName"),i}},{key:"getDefaultState",value:function(e,t){var n=this;return this.keys(e,t).reduce((function(e,t){return ft(ft({},e),{},{tabs:ft(ft({},e.tabs),{},ct({},t,n.tabsNames)),containerRefs:ft(ft({},e.containerRefs),{},ct({},t,(0,r.useRef)(null)))})}),{tabs:{},containerRefs:{}})}},{key:"sectionsTitles",value:function(e){return{seriesCountByMetricName:"Metric names with the highest number of series",seriesCountByLabelName:"Labels with the highest number of series",seriesCountByFocusLabelValue:'Values for "'.concat(e,'" label with the highest number of series'),seriesCountByLabelValuePair:"Label=value pairs with the highest number of series",labelValueCountByLabelName:"Labels with the highest number of unique values"}}},{key:"sectionsTips",get:function(){return{seriesCountByMetricName:"\n \n This table returns a list of metrics with the highest cardinality.\n The cardinality of a metric is the number of time series associated with that metric,\n where each time series is defined as a unique combination of key-value label pairs.\n
\n \n When looking to reduce the number of active series in your data source,\n you can start by inspecting individual metrics with high cardinality\n (i.e. that have lots of active time series associated with them),\n since that single metric contributes a large fraction of the series that make up your total series count.\n
",seriesCountByLabelName:"\n \n This table returns a list of the labels with the highest number of series.\n
\n \n Use this table to identify labels that are storing dimensions with high cardinality\n (many different label values).\n
\n \n It is recommended to choose labels such that they have a finite set of values,\n since every unique combination of key-value label pairs creates a new time series\n and therefore can dramatically increase the number of time series in your system.\n
",seriesCountByFocusLabelValue:"\n \n This table returns a list of unique label values per selected label.\n
\n \n Use this table to identify label values that are storing per each selected series.\n
",labelValueCountByLabelName:"\n \n This table returns a list of labels with the highest number of the unique values.\n
\n ",seriesCountByLabelValuePair:"\n \n This table returns a list of the label values pairs with the highest number of series.\n
\n \n Use this table to identify unique label values pairs. This helps to identify same labels \n is applied to count timeseries in your system, since every unique combination of key-value label pairs \n creates a new time series and therefore can dramatically increase the number of time series in your system\n
"}}},{key:"tablesHeaders",get:function(){return{seriesCountByMetricName:mh,seriesCountByLabelName:ph,seriesCountByFocusLabelValue:vh,seriesCountByLabelValuePair:gh,labelValueCountByLabelName:yh}}},{key:"totalSeries",value:function(e){return"labelValueCountByLabelName"===e?-1:arguments.length>1&&void 0!==arguments[1]&&arguments[1]?this.tsdbStatus.totalSeriesPrev:this.tsdbStatus.totalSeries}}]),e}(),mh=[{id:"name",label:"Metric name"},{id:"value",label:"Number of series"},{id:"percentage",label:"Share in total",info:"Shows the share of a metric to the total number of series"},{id:"action",label:""}],ph=[{id:"name",label:"Label name"},{id:"value",label:"Number of series"},{id:"percentage",label:"Share in total",info:"Shows the share of the label to the total number of series"},{id:"action",label:""}],vh=[{id:"name",label:"Label value"},{id:"value",label:"Number of series"},{id:"percentage",label:"Share in total"},{disablePadding:!1,id:"action",label:"",numeric:!1}],gh=[{id:"name",label:"Label=value pair"},{id:"value",label:"Number of series"},{id:"percentage",label:"Share in total",info:"Shows the share of the label value pair to the total number of series"},{id:"action",label:""}],yh=[{id:"name",label:"Label name"},{id:"value",label:"Number of unique values"},{id:"action",label:""}],_h={seriesCountByMetricName:function(e){var t=e.query;return bh("__name__",t)},seriesCountByLabelName:function(e){var t=e.query;return"{".concat(t,'!=""}')},seriesCountByFocusLabelValue:function(e){var t=e.query,n=e.focusLabel;return bh(n,t)},seriesCountByLabelValuePair:function(e){var t=e.query.split("="),n=t[0],r=t.slice(1).join("=");return bh(n,r)},labelValueCountByLabelName:function(e){var t=e.query,n=e.match;return""===n?"{".concat(t,'!=""}'):"".concat(n.replace("}",""),", ").concat(t,'!=""}')}},bh=function(e,t){return e?"{"+e+"="+JSON.stringify(t)+"}":""},wh=function(e){var t,n=e.totalSeries,r=void 0===n?0:n,a=e.totalSeriesPrev,i=void 0===a?0:a,o=e.totalSeriesAll,l=void 0===o?0:o,u=e.seriesCountByMetricName,c=void 0===u?[]:u,s=e.isPrometheus,f=xa().isMobile,d=v(ut(),1)[0],h=d.get("match"),m=d.get("focusLabel"),p=/__name__/.test(h||""),g=(null===(t=c[0])||void 0===t?void 0:t.value)/l*100,y=r-i,_=Math.abs(y)/i*100,b=[{title:"Total series",value:r.toLocaleString("en-US"),dynamic:r&&i&&!s?"".concat(_.toFixed(2),"%"):"",display:!m,info:'The total number of active time series. \n A time series is uniquely identified by its name plus a set of its labels. \n For example, temperature{city="NY",country="US"} and temperature{city="SF",country="US"} \n are two distinct series, since they differ by the city label.'},{title:"Percentage from total",value:isNaN(g)?"-":"".concat(g.toFixed(2),"%"),display:p,info:"The share of these series in the total number of time series."}].filter((function(e){return e.display}));return b.length?Kt("div",{className:Jr()({"vm-cardinality-totals":!0,"vm-cardinality-totals_mobile":f}),children:b.map((function(e){var t=e.title,n=e.value,r=e.info,a=e.dynamic;return Kt("div",{className:"vm-cardinality-totals-card",children:[Kt("h4",{className:"vm-cardinality-totals-card__title",children:[t,r&&Kt(qa,{title:Kt("p",{className:"vm-cardinality-totals-card__tooltip",children:r}),children:Kt("div",{className:"vm-cardinality-totals-card__info-icon",children:Kt(sr,{})})})]}),Kt("span",{className:"vm-cardinality-totals-card__value",children:n}),!!a&&Kt(qa,{title:"in relation to the previous day: ".concat(i.toLocaleString("en-US")),children:Kt("span",{className:Jr()({"vm-dynamic-number":!0,"vm-dynamic-number_positive vm-dynamic-number_down":y<0,"vm-dynamic-number_negative vm-dynamic-number_up":y>0}),children:a})})]},t)}))}):null},kh=function(e,t){var n=v(ut(),1)[0],a=n.get(t)?n.get(t):e,i=v((0,r.useState)(a),2),o=i[0],l=i[1];return(0,r.useEffect)((function(){a!==o&&l(a)}),[a]),[o,l]},Dh=["isPrometheus","isCluster"],xh=function(e){var t=e.isPrometheus,n=e.isCluster,a=Xr(e,Dh),i=xa().isMobile,o=v(ut(),1)[0],l=Vi().setSearchParamsFromKeys,u=o.get("tips")||"",c=v(kh("","match"),2),s=c[0],f=c[1],d=v(kh("","focusLabel"),2),h=d[0],m=d[1],p=v(kh(10,"topN"),2),g=p[0],y=p[1],_=(0,r.useMemo)((function(){return g<0?"Number must be bigger than zero":""}),[g]),b=function(){l({match:s,topN:g,focusLabel:h})};return(0,r.useEffect)((function(){var e=o.get("match"),t=+(o.get("topN")||10),n=o.get("focusLabel");e!==s&&f(e||""),t!==g&&y(t),n!==h&&m(n||"")}),[o]),Kt("div",{className:Jr()({"vm-cardinality-configurator":!0,"vm-cardinality-configurator_mobile":i,"vm-block":!0,"vm-block_mobile":i}),children:[Kt("div",{className:"vm-cardinality-configurator-controls",children:[Kt("div",{className:"vm-cardinality-configurator-controls__query",children:Kt(wi,{label:"Time series selector",type:"string",value:s,onChange:f,onEnter:b})}),Kt("div",{className:"vm-cardinality-configurator-controls__item",children:Kt(wi,{label:"Focus label",type:"text",value:h||"",onChange:m,onEnter:b,endIcon:Kt(qa,{title:Kt("div",{children:Kt("p",{children:"To identify values with the highest number of series for the selected label."})}),children:Kt(Br,{})})})}),Kt("div",{className:"vm-cardinality-configurator-controls__item vm-cardinality-configurator-controls__item_limit",children:Kt(wi,{label:"Limit entries",type:"number",value:t?10:g,error:_,disabled:t,helperText:t?"not available for Prometheus":"",onChange:function(e){var t=+e;y(isNaN(t)?0:t)},onEnter:b})})]}),Kt("div",{className:"vm-cardinality-configurator-bottom",children:[Kt(wh,ft({isPrometheus:t,isCluster:n},a)),n&&Kt("div",{className:"vm-cardinality-configurator-bottom-helpful",children:Kt(vd,{href:"https://docs.victoriametrics.com/Single-server-VictoriaMetrics.html#cardinality-explorer-statistic-inaccuracy",withIcon:!0,children:[Kt(Ir,{}),"Statistic inaccuracy explanation"]})}),Kt("div",{className:"vm-cardinality-configurator-bottom-helpful",children:Kt(vd,{href:"https://docs.victoriametrics.com/#cardinality-explorer",withIcon:!0,children:[Kt(Ir,{}),"Documentation"]})}),Kt("div",{className:"vm-cardinality-configurator-bottom__execute",children:[Kt(qa,{title:u?"Hide tips":"Show tips",children:Kt(Pa,{variant:"text",color:u?"warning":"gray",startIcon:Kt($r,{}),onClick:function(){var e=o.get("tips")||"";l({tips:e?"":"true"})},ariaLabel:"visibility tips"})}),Kt(Pa,{variant:"text",startIcon:Kt(cr,{}),onClick:function(){l({match:"",focusLabel:""})},children:"Reset"}),Kt(Pa,{startIcon:Kt(wr,{}),onClick:b,children:"Execute Query"})]})]})]})};function Ch(e){var t=e.order,n=e.orderBy,r=e.onRequestSort,a=e.headerCells;return Kt("thead",{className:"vm-table-header vm-cardinality-panel-table__header",children:Kt("tr",{className:"vm-table__row vm-table__row_header",children:a.map((function(e){return Kt("th",{className:Jr()({"vm-table-cell vm-table-cell_header":!0,"vm-table-cell_sort":"action"!==e.id&&"percentage"!==e.id,"vm-table-cell_right":"action"===e.id}),onClick:(a=e.id,function(e){r(e,a)}),children:Kt("div",{className:"vm-table-cell__content",children:[e.info?Kt(qa,{title:e.info,children:[Kt("div",{className:"vm-metrics-content-header__tip-icon",children:Kt(sr,{})}),e.label]}):Kt(Zt.HY,{children:e.label}),"action"!==e.id&&"percentage"!==e.id&&Kt("div",{className:Jr()({"vm-table__sort-icon":!0,"vm-table__sort-icon_active":n===e.id,"vm-table__sort-icon_desc":"desc"===t&&n===e.id}),children:Kt(vr,{})})]})},e.id);var a}))})})}var Eh=["date","timestamp","time"];function Sh(e,t,n){var r=e[n],a=t[n],o=Eh.includes("".concat(n))?i()("".concat(r)).unix():r,l=Eh.includes("".concat(n))?i()("".concat(a)).unix():a;return lo?1:0}function Ah(e,t){return"desc"===e?function(e,n){return Sh(e,n,t)}:function(e,n){return-Sh(e,n,t)}}function Nh(e,t){var n=e.map((function(e,t){return[e,t]}));return n.sort((function(e,n){var r=t(e[0],n[0]);return 0!==r?r:e[1]-n[1]})),n.map((function(e){return e[0]}))}var Mh=function(e){var t=e.rows,n=e.headerCells,a=e.defaultSortColumn,i=e.tableCells,o=v((0,r.useState)("desc"),2),l=o[0],u=o[1],c=v((0,r.useState)(a),2),s=c[0],f=c[1],d=Nh(t,Ah(l,s));return Kt("table",{className:"vm-table vm-cardinality-panel-table",children:[Kt(Ch,{order:l,orderBy:s,onRequestSort:function(e,t){u(s===t&&"asc"===l?"desc":"asc"),f(t)},rowCount:t.length,headerCells:n}),Kt("tbody",{className:"vm-table-header",children:d.map((function(e){return Kt("tr",{className:"vm-table__row",children:i(e)},e.name)}))})]})},Th=function(e){var t=e.row,n=e.totalSeries,r=e.totalSeriesPrev,a=e.onActionClick,i=n>0?t.value/n*100:-1,o=r>0?t.valuePrev/r*100:-1,l=[i,o].some((function(e){return-1===e})),u=i-o,c=l?"":"".concat(u.toFixed(2),"%"),s=function(){a(t.name)};return Kt(Zt.HY,{children:[Kt("td",{className:"vm-table-cell",children:Kt("span",{className:"vm-link vm-link_colored",onClick:s,children:t.name})},t.name),Kt("td",{className:"vm-table-cell",children:[t.value,!!t.diff&&Kt(qa,{title:"in relation to the previous day: ".concat(t.valuePrev),children:Kt("span",{className:Jr()({"vm-dynamic-number":!0,"vm-dynamic-number_positive":t.diff<0,"vm-dynamic-number_negative":t.diff>0}),children:["\xa0",t.diff>0?"+":"",t.diff]})})]},t.value),i>0&&Kt("td",{className:"vm-table-cell",children:Kt("div",{className:"vm-cardinality-panel-table__progress",children:[Kt(bd,{value:i}),c&&Kt(qa,{title:"in relation to the previous day",children:Kt("span",{className:Jr()({"vm-dynamic-number":!0,"vm-dynamic-number_positive vm-dynamic-number_down":u<0,"vm-dynamic-number_negative vm-dynamic-number_up":u>0}),children:c})})]})},t.progressValue),Kt("td",{className:"vm-table-cell vm-table-cell_right",children:Kt("div",{className:"vm-table-cell__content",children:Kt(qa,{title:"Filter by ".concat(t.name),children:Kt(Pa,{variant:"text",size:"small",onClick:s,children:Kt(kr,{})})})})},"action")]})},Fh=function(e){var t=e.data,n=v((0,r.useState)([]),2),a=n[0],i=n[1],o=v((0,r.useState)([0,0]),2),l=o[0],u=o[1];return(0,r.useEffect)((function(){var e=t.sort((function(e,t){return t.value-e.value})),n=function(e){var t=e.map((function(e){return e.value})),n=Math.ceil(t[0]||1),r=n/9;return new Array(11).fill(n+r).map((function(e,t){return Math.round(e-r*t)}))}(e);u(n),i(e.map((function(e){return ft(ft({},e),{},{percentage:e.value/n[0]*100})})))}),[t]),Kt("div",{className:"vm-simple-bar-chart",children:[Kt("div",{className:"vm-simple-bar-chart-y-axis",children:l.map((function(e){return Kt("div",{className:"vm-simple-bar-chart-y-axis__tick",children:e},e)}))}),Kt("div",{className:"vm-simple-bar-chart-data",children:a.map((function(e){var t=e.name,n=e.value,r=e.percentage;return Kt(qa,{title:"".concat(t,": ").concat(n),placement:"top-center",children:Kt("div",{className:"vm-simple-bar-chart-data-item",style:{maxHeight:"".concat(r||0,"%")}})},"".concat(t,"_").concat(n))}))})]})},Oh=function(e){var t=e.rows,n=e.tabs,a=void 0===n?[]:n,i=e.chartContainer,o=e.totalSeries,l=e.totalSeriesPrev,u=e.onActionClick,c=e.sectionTitle,s=e.tip,f=e.tableHeaderCells,d=e.isPrometheus,h=xa().isMobile,m=v((0,r.useState)("table"),2),p=m[0],g=m[1],y=d&&!t.length,_=(0,r.useMemo)((function(){return a.map((function(e,t){return{value:e,label:e,icon:Kt(0===t?xr:Dr,{})}}))}),[a]);return Kt("div",{className:Jr()({"vm-metrics-content":!0,"vm-metrics-content_mobile":h,"vm-block":!0,"vm-block_mobile":h}),children:[Kt("div",{className:"vm-metrics-content-header vm-section-header",children:[Kt("h5",{className:Jr()({"vm-metrics-content-header__title":!0,"vm-section-header__title":!0,"vm-section-header__title_mobile":h}),children:[!h&&s&&Kt(qa,{title:Kt("p",{dangerouslySetInnerHTML:{__html:s},className:"vm-metrics-content-header__tip"}),children:Kt("div",{className:"vm-metrics-content-header__tip-icon",children:Kt(sr,{})})}),c]}),Kt("div",{className:"vm-section-header__tabs",children:Kt(oa,{activeItem:p,items:_,onChange:g})})]}),y&&Kt("div",{className:"vm-metrics-content-prom-data",children:[Kt("div",{className:"vm-metrics-content-prom-data__icon",children:Kt(sr,{})}),Kt("h3",{className:"vm-metrics-content-prom-data__title",children:"Prometheus Data Limitation"}),Kt("p",{className:"vm-metrics-content-prom-data__text",children:["Due to missing data from your Prometheus source, some tables may appear empty.",Kt("br",{}),"This does not indicate an issue with your system or our tool."]})]}),!y&&"table"===p&&Kt("div",{ref:i,className:Jr()({"vm-metrics-content__table":!0,"vm-metrics-content__table_mobile":h}),children:Kt(Mh,{rows:t,headerCells:f,defaultSortColumn:"value",tableCells:function(e){return Kt(Th,{row:e,totalSeries:o,totalSeriesPrev:l,onActionClick:u})}})}),!y&&"graph"===p&&Kt("div",{className:"vm-metrics-content__chart",children:Kt(Fh,{data:t.map((function(e){return{name:e.name,value:e.value}}))})})]})},Lh=function(e){var t=e.title,n=e.children;return Kt("div",{className:"vm-cardinality-tip",children:[Kt("div",{className:"vm-cardinality-tip-header",children:[Kt("div",{className:"vm-cardinality-tip-header__tip-icon",children:Kt($r,{})}),Kt("h4",{className:"vm-cardinality-tip-header__title",children:t||"Tips"})]}),Kt("p",{className:"vm-cardinality-tip__description",children:n})]})},Ph=function(){return Kt(Lh,{title:"Metrics with a high number of series",children:Kt("ul",{children:[Kt("li",{children:["Identify and eliminate labels with frequently changed values to reduce their\xa0",Kt(vd,{href:"https://docs.victoriametrics.com/FAQ.html#what-is-high-cardinality",children:"cardinality"}),"\xa0and\xa0",Kt(vd,{href:"https://docs.victoriametrics.com/FAQ.html#what-is-high-churn-rate",children:"high churn rate"})]}),Kt("li",{children:["Find unused time series and\xa0",Kt(vd,{href:"https://docs.victoriametrics.com/relabeling.html",children:"drop entire metrics"})]}),Kt("li",{children:["Aggregate time series before they got ingested into the database via\xa0",Kt(vd,{href:"https://docs.victoriametrics.com/stream-aggregation.html",children:"streaming aggregation"})]})]})})},Ih=function(){return Kt(Lh,{title:"Labels with a high number of unique values",children:Kt("ul",{children:[Kt("li",{children:"Decrease the number of unique label values to reduce cardinality"}),Kt("li",{children:["Drop the label entirely via\xa0",Kt(vd,{href:"https://docs.victoriametrics.com/relabeling.html",children:"relabeling"})]}),Kt("li",{children:"For volatile label values (such as URL path, user session, etc.) consider printing them to the log file instead of adding to time series"})]})})},Rh=function(){return Kt(Lh,{title:"Dashboard of a single metric",children:[Kt("p",{children:"This dashboard helps to understand the cardinality of a single metric."}),Kt("p",{children:"Each time series is a unique combination of key-value label pairs. Therefore a label key with many values can create a lot of time series for a particular metric. If you\u2019re trying to decrease the cardinality of a metric, start by looking at the labels with the highest number of values."}),Kt("p",{children:"Use the series selector at the top of the page to apply additional filters."})]})},Bh=function(){return Kt(Lh,{title:"Dashboard of a label",children:[Kt("p",{children:"This dashboard helps you understand the count of time series per label."}),Kt("p",{children:"Use the selector at the top of the page to pick a label name you\u2019d like to inspect. For the selected label name, you\u2019ll see the label values that have the highest number of series associated with them. So if you\u2019ve chosen `instance` as your label name, you may see that `657` time series have value \u201chost-1\u201d attached to them and `580` time series have value `host-2` attached to them."}),Kt("p",{children:"This can be helpful in allowing you to determine where the bulk of your time series are coming from. If the label \u201cinstance=host-1\u201d was applied to 657 series and the label \u201cinstance=host-2\u201d was only applied to 580 series, you\u2019d know, for example, that host-01 was responsible for sending the majority of the time series."})]})},zh=function(){var e=xa().isMobile,t=v(ut(),1)[0],n=Vi().setSearchParamsFromKeys,a=t.get("tips")||"",o=t.get("match")||"",l=t.get("focusLabel")||"",u=function(){var e=new hh,t=v(ut(),1)[0],n=t.get("match"),a=t.get("focusLabel"),o=+(t.get("topN")||10),l=t.get("date")||i()().tz().format(nn),u=Ei(l),c=Xt().serverUrl,s=v((0,r.useState)(!1),2),f=s[0],d=s[1],h=v((0,r.useState)(),2),m=h[0],p=h[1],g=v((0,r.useState)(e.defaultTSDBStatus),2),y=g[0],_=g[1],b=v((0,r.useState)(!1),2),w=b[0],k=b[1],D=function(){var e=si(ui().mark((function e(t){var n;return ui().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,fetch(t);case 2:if(!(n=e.sent).ok){e.next=7;break}return e.next=6,n.json();case 6:return e.abrupt("return",e.sent);case 7:throw new Error("Request failed with status ".concat(n.status));case 8:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),x=function(e,t){Object.keys(e).forEach((function(n){var r=n,a=e[r],i=t[r];Array.isArray(a)&&Array.isArray(i)&&a.forEach((function(e){var t,n=null===(t=i.find((function(t){return t.name===e.name})))||void 0===t?void 0:t.value;e.diff=n?e.value-n:0,e.valuePrev=n||0}))}))},C=function(){var t=si(ui().mark((function t(r){var a,o,s,f,h,m,g,b,w,k,C,E,S,A,N,M,T,F,O,L,P,I,R;return ui().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(c){t.next=2;break}return t.abrupt("return");case 2:return p(""),d(!0),_(e.defaultTSDBStatus),a=ft(ft({},r),{},{date:r.date,topN:0,match:"",focusLabel:""}),o=ft(ft({},r),{},{date:i()(r.date).subtract(1,"day").tz().format(nn)}),s=[dh(c,r),dh(c,o)],u!==l&&s.push(dh(c,a)),t.prev=9,t.next=12,Promise.all(s.map(D));case 12:A=t.sent,N=v(A,3),M=N[0],T=N[1],F=N[2],O=void 0===F?{}:F,L=ft({},T.data),P=O.data,I=ft(ft({},M.data),{},{totalSeries:(null===(f=M.data)||void 0===f?void 0:f.totalSeries)||(null===(h=M.data)||void 0===h||null===(m=h.headStats)||void 0===m?void 0:m.numSeries)||0,totalLabelValuePairs:(null===(g=M.data)||void 0===g?void 0:g.totalLabelValuePairs)||(null===(b=M.data)||void 0===b||null===(w=b.headStats)||void 0===w?void 0:w.numLabelValuePairs)||0,seriesCountByLabelName:(null===(k=M.data)||void 0===k?void 0:k.seriesCountByLabelName)||[],seriesCountByFocusLabelValue:(null===(C=M.data)||void 0===C?void 0:C.seriesCountByFocusLabelValue)||[],totalSeriesByAll:(null===P||void 0===P?void 0:P.totalSeries)||(null===P||void 0===P||null===(E=P.headStats)||void 0===E?void 0:E.numSeries)||y.totalSeriesByAll||0,totalSeriesPrev:(null===L||void 0===L?void 0:L.totalSeries)||(null===L||void 0===L||null===(S=L.headStats)||void 0===S?void 0:S.numSeries)||0}),R=null===n||void 0===n?void 0:n.replace(/[{}"]/g,""),I.seriesCountByLabelValuePair=I.seriesCountByLabelValuePair.filter((function(e){return e.name!==R})),x(I,L),_(I),d(!1),t.next=32;break;case 28:t.prev=28,t.t0=t.catch(9),d(!1),t.t0 instanceof Error&&p("".concat(t.t0.name,": ").concat(t.t0.message));case 32:case"end":return t.stop()}}),t,null,[[9,28]])})));return function(e){return t.apply(this,arguments)}}();return(0,r.useEffect)((function(){C({topN:o,match:n,date:l,focusLabel:a})}),[c,n,a,o,l]),(0,r.useEffect)((function(){m&&(_(e.defaultTSDBStatus),d(!1))}),[m]),(0,r.useEffect)((function(){var e=Dt(c);k(!!e)}),[c]),e.tsdbStatusData=y,{isLoading:f,appConfigurator:e,error:m,isCluster:w}}(),c=u.isLoading,s=u.appConfigurator,f=u.error,d=u.isCluster,h=s.tsdbStatusData,m=s.getDefaultState,p=s.tablesHeaders,g=s.sectionsTips,y=m(o,l);return Kt("div",{className:Jr()({"vm-cardinality-panel":!0,"vm-cardinality-panel_mobile":e}),children:[c&&Kt(hd,{message:"Please wait while cardinality stats is calculated. \n This may take some time if the db contains big number of time series."}),Kt(xh,{isPrometheus:s.isPrometheusData,totalSeries:h.totalSeries,totalSeriesPrev:h.totalSeriesPrev,totalSeriesAll:h.totalSeriesByAll,totalLabelValuePairs:h.totalLabelValuePairs,seriesCountByMetricName:h.seriesCountByMetricName,isCluster:d}),a&&Kt("div",{className:"vm-cardinality-panel-tips",children:[!o&&!l&&Kt(Ph,{}),o&&!l&&Kt(Rh,{}),!o&&!l&&Kt(Ih,{}),l&&Kt(Bh,{})]}),f&&Kt(Ea,{variant:"error",children:f}),s.keys(o,l).map((function(e){return Kt(Oh,{sectionTitle:s.sectionsTitles(l)[e],tip:g[e],rows:h[e],onActionClick:(t=e,function(e){var r={match:_h[t]({query:e,focusLabel:l,match:o})};"labelValueCountByLabelName"!==t&&"seriesCountByLabelName"!=t||(r.focusLabel=e),"seriesCountByFocusLabelValue"==t&&(r.focusLabel=""),n(r)}),tabs:y.tabs[e],chartContainer:y.containerRefs[e],totalSeriesPrev:s.totalSeries(e,!0),totalSeries:s.totalSeries(e),tableHeaderCells:p[e],isPrometheus:s.isPrometheusData},e);var t}))]})},Hh=function(e){return["topByAvgDuration","topByCount","topBySumDuration"].forEach((function(t){var n=e[t];Array.isArray(n)&&n.forEach((function(e){var t=Cn(1e3*e.timeRangeSeconds);e.url=function(e,t){var n,r=e.query,a=e.timeRangeSeconds,i=["g0.expr=".concat(encodeURIComponent(r))],o=null===(n=Sn.find((function(e){return e.duration===t})))||void 0===n?void 0:n.id;return o&&i.push("g0.relative_time=".concat(o)),a&&i.push("g0.range_input=".concat(t)),"".concat(yt.home,"?").concat(i.join("&"))}(e,t),e.timeRange=t}))})),e},jh=function(e){var t=e.topN,n=e.maxLifetime,a=Xt().serverUrl,i=Vi().setSearchParamsFromKeys,o=v((0,r.useState)(null),2),l=o[0],u=o[1],c=v((0,r.useState)(!1),2),s=c[0],f=c[1],d=v((0,r.useState)(),2),h=d[0],m=d[1],p=(0,r.useMemo)((function(){return function(e,t,n){return"".concat(e,"/api/v1/status/top_queries?topN=").concat(t||"","&maxLifetime=").concat(n||"")}(a,t,n)}),[a,t,n]),g=function(){var e=si(ui().mark((function e(){var r,a;return ui().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return f(!0),i({topN:t,maxLifetime:n}),e.prev=2,e.next=5,fetch(p);case 5:return r=e.sent,e.next=8,r.json();case 8:a=e.sent,u(r.ok?Hh(a):null),m(String(a.error||"")),e.next=16;break;case 13:e.prev=13,e.t0=e.catch(2),e.t0 instanceof Error&&"AbortError"!==e.t0.name&&m("".concat(e.t0.name,": ").concat(e.t0.message));case 16:f(!1);case 17:case"end":return e.stop()}}),e,null,[[2,13]])})));return function(){return e.apply(this,arguments)}}();return{data:l,error:h,loading:s,fetch:g}},$h=function(e){var t=e.rows,n=e.columns,a=e.defaultOrderBy,i=td(),o=v((0,r.useState)(a||"count"),2),l=o[0],u=o[1],c=v((0,r.useState)("desc"),2),s=c[0],f=c[1],d=(0,r.useMemo)((function(){return Nh(t,Ah(s,l))}),[t,l,s]),h=function(e){return function(){var t;t=e,f((function(e){return"asc"===e&&l===t?"desc":"asc"})),u(t)}},m=function(e){var t=e.query;return si(ui().mark((function e(){return ui().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,i(t,"Query has been copied");case 2:case"end":return e.stop()}}),e)})))};return Kt("table",{className:"vm-table",children:[Kt("thead",{className:"vm-table-header",children:Kt("tr",{className:"vm-table__row vm-table__row_header",children:[n.map((function(e){return Kt("th",{className:"vm-table-cell vm-table-cell_header vm-table-cell_sort",onClick:h(e.sortBy||e.key),children:Kt("div",{className:"vm-table-cell__content",children:[e.title||e.key,Kt("div",{className:Jr()({"vm-table__sort-icon":!0,"vm-table__sort-icon_active":l===e.key,"vm-table__sort-icon_desc":"desc"===s&&l===e.key}),children:Kt(vr,{})})]})},e.key)})),Kt("th",{className:"vm-table-cell vm-table-cell_header"})," "]})}),Kt("tbody",{className:"vm-table-body",children:d.map((function(e,t){return Kt("tr",{className:"vm-table__row",children:[n.map((function(t){return Kt("td",{className:"vm-table-cell",children:e[t.key]||"-"},t.key)})),Kt("td",{className:"vm-table-cell vm-table-cell_no-padding",children:Kt("div",{className:"vm-top-queries-panels__table-actions",children:[e.url&&Kt(qa,{title:"Execute query",children:Kt(rt,{to:e.url,target:"_blank",rel:"noreferrer","aria-disabled":!0,children:Kt(Pa,{variant:"text",size:"small",startIcon:Kt(kr,{}),ariaLabel:"execute query"})})}),Kt(qa,{title:"Copy query",children:Kt(Pa,{variant:"text",size:"small",startIcon:Kt(Or,{}),onClick:m(e),ariaLabel:"copy query"})})]})})]},t)}))})]})},Vh=["table","JSON"].map((function(e,t){return{value:String(t),label:e,icon:Kt(0===t?xr:Cr,{})}})),Uh=function(e){var t=e.rows,n=e.title,a=e.columns,i=e.defaultOrderBy,o=xa().isMobile,l=v((0,r.useState)(0),2),u=l[0],c=l[1];return Kt("div",{className:Jr()({"vm-top-queries-panel":!0,"vm-block":!0,"vm-block_mobile":o}),children:[Kt("div",{className:Jr()({"vm-top-queries-panel-header":!0,"vm-section-header":!0,"vm-top-queries-panel-header_mobile":o}),children:[Kt("h5",{className:Jr()({"vm-section-header__title":!0,"vm-section-header__title_mobile":o}),children:n}),Kt("div",{className:"vm-section-header__tabs",children:Kt(oa,{activeItem:String(u),items:Vh,onChange:function(e){c(+e)}})})]}),Kt("div",{className:Jr()({"vm-top-queries-panel__table":!0,"vm-top-queries-panel__table_mobile":o}),children:[0===u&&Kt($h,{rows:t,columns:a,defaultOrderBy:i}),1===u&&Kt(Zd,{data:t})]})]})},Yh=function(){var e=xa().isMobile,t=v(kh(10,"topN"),2),n=t[0],a=t[1],o=v(kh("10m","maxLifetime"),2),l=o[0],u=o[1],c=jh({topN:n,maxLifetime:l}),s=c.data,f=c.error,d=c.loading,h=c.fetch,m=(0,r.useMemo)((function(){var e=l.trim().split(" ").reduce((function(e,t){var n=_n(t);return n?ft(ft({},e),n):ft({},e)}),{});return!!i().duration(e).asMilliseconds()}),[l]),p=(0,r.useMemo)((function(){return!!n&&n<1}),[n]),g=(0,r.useMemo)((function(){return p?"Number must be bigger than zero":""}),[p]),y=(0,r.useMemo)((function(){return m?"":"Invalid duration value"}),[m]),_=function(e){if(!s)return e;var t=s[e];return"number"===typeof t?Do(t,t,t):t||e},b=function(e){"Enter"===e.key&&h()};return(0,r.useEffect)((function(){s&&(n||a(+s.topN),l||u(s.maxLifetime))}),[s]),(0,r.useEffect)((function(){return h(),window.addEventListener("popstate",h),function(){window.removeEventListener("popstate",h)}}),[]),Kt("div",{className:Jr()({"vm-top-queries":!0,"vm-top-queries_mobile":e}),children:[d&&Kt(hd,{containerStyles:{height:"500px"}}),Kt("div",{className:Jr()({"vm-top-queries-controls":!0,"vm-block":!0,"vm-block_mobile":e}),children:[Kt("div",{className:"vm-top-queries-controls-fields",children:[Kt("div",{className:"vm-top-queries-controls-fields__item",children:Kt(wi,{label:"Max lifetime",value:l,error:y,helperText:"For example ".concat("30ms, 15s, 3d4h, 1y2w"),onChange:function(e){u(e)},onKeyDown:b})}),Kt("div",{className:"vm-top-queries-controls-fields__item",children:Kt(wi,{label:"Number of returned queries",type:"number",value:n||"",error:g,onChange:function(e){a(+e)},onKeyDown:b})})]}),Kt("div",{className:Jr()({"vm-top-queries-controls-bottom":!0,"vm-top-queries-controls-bottom_mobile":e}),children:[Kt("div",{className:"vm-top-queries-controls-bottom__info",children:["VictoriaMetrics tracks the last\xa0",Kt(qa,{title:"search.queryStats.lastQueriesCount",children:Kt("b",{children:_("search.queryStats.lastQueriesCount")})}),"\xa0queries with durations at least\xa0",Kt(qa,{title:"search.queryStats.minQueryDuration",children:Kt("b",{children:_("search.queryStats.minQueryDuration")})})]}),Kt("div",{className:"vm-top-queries-controls-bottom__button",children:Kt(Pa,{startIcon:Kt(wr,{}),onClick:h,children:"Execute"})})]})]}),f&&Kt(Ea,{variant:"error",children:f}),s&&Kt(Zt.HY,{children:Kt("div",{className:"vm-top-queries-panels",children:[Kt(Uh,{rows:s.topBySumDuration,title:"Queries with most summary time to execute",columns:[{key:"query"},{key:"sumDurationSeconds",title:"sum duration, sec"},{key:"timeRange",sortBy:"timeRangeSeconds",title:"query time interval"},{key:"count"}],defaultOrderBy:"sumDurationSeconds"}),Kt(Uh,{rows:s.topByAvgDuration,title:"Most heavy queries",columns:[{key:"query"},{key:"avgDurationSeconds",title:"avg duration, sec"},{key:"timeRange",sortBy:"timeRangeSeconds",title:"query time interval"},{key:"count"}],defaultOrderBy:"avgDurationSeconds"}),Kt(Uh,{rows:s.topByCount,title:"Most frequently executed queries",columns:[{key:"query"},{key:"timeRange",sortBy:"timeRangeSeconds",title:"query time interval"},{key:"count"}]})]})})]})},qh={"color-primary":"#589DF6","color-secondary":"#316eca","color-error":"#e5534b","color-warning":"#c69026","color-info":"#539bf5","color-success":"#57ab5a","color-background-body":"#22272e","color-background-block":"#2d333b","color-background-tooltip":"rgba(22, 22, 22, 0.8)","color-text":"#cdd9e5","color-text-secondary":"#768390","color-text-disabled":"#636e7b","box-shadow":"rgba(0, 0, 0, 0.16) 1px 2px 6px","box-shadow-popper":"rgba(0, 0, 0, 0.2) 0px 2px 8px 0px","border-divider":"1px solid rgba(99, 110, 123, 0.5)","color-hover-black":"rgba(0, 0, 0, 0.12)"},Wh={"color-primary":"#3F51B5","color-secondary":"#E91E63","color-error":"#FD080E","color-warning":"#FF8308","color-info":"#03A9F4","color-success":"#4CAF50","color-background-body":"#FEFEFF","color-background-block":"#FFFFFF","color-background-tooltip":"rgba(80,80,80,0.9)","color-text":"#110f0f","color-text-secondary":"#706F6F","color-text-disabled":"#A09F9F","box-shadow":"rgba(0, 0, 0, 0.08) 1px 2px 6px","box-shadow-popper":"rgba(0, 0, 0, 0.1) 0px 2px 8px 0px","border-divider":"1px solid rgba(0, 0, 0, 0.15)","color-hover-black":"rgba(0, 0, 0, 0.06)"},Qh=function(){var e=v((0,r.useState)(Vt()),2),t=e[0],n=e[1],a=function(e){n(e.matches)};return(0,r.useEffect)((function(){var e=window.matchMedia("(prefers-color-scheme: dark)");return e.addEventListener("change",a),function(){return e.removeEventListener("change",a)}}),[]),t},Zh=["primary","secondary","error","warning","info","success"],Gh=function(e){var t,n=e.onLoaded,a=bt(),i=_t().palette,o=void 0===i?{}:i,l=Xt().theme,u=Qh(),c=en(),s=ia(),f=v((0,r.useState)((ct(t={},zt.dark,qh),ct(t,zt.light,Wh),ct(t,zt.system,Vt()?qh:Wh),t)),2),d=f[0],h=f[1],m=function(){var e=window,t=e.innerWidth,n=e.innerHeight,r=document.documentElement,a=r.clientWidth,i=r.clientHeight;$t("scrollbar-width","".concat(t-a,"px")),$t("scrollbar-height","".concat(n-i,"px")),$t("vh","".concat(.01*n,"px"))},p=function(){Zh.forEach((function(e,t){var r=function(e){var t=e.replace("#","").trim();if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6!==t.length)throw new Error("Invalid HEX color.");return(299*parseInt(t.slice(0,2),16)+587*parseInt(t.slice(2,4),16)+114*parseInt(t.slice(4,6),16))/1e3>=128?"#000000":"#FFFFFF"}(jt("color-".concat(e)));$t("".concat(e,"-text"),r),t===Zh.length-1&&(c({type:"SET_DARK_THEME"}),n(!0))}))},g=function(){var e=Ct("THEME")||zt.system,t=d[e];Object.entries(t).forEach((function(e){var t=v(e,2),n=t[0],r=t[1];$t(n,r)})),p(),a&&(Zh.forEach((function(e){var t=o[e];t&&$t("color-".concat(e),t)})),p())};return(0,r.useEffect)((function(){m(),g()}),[d]),(0,r.useEffect)(m,[s]),(0,r.useEffect)((function(){var e=Vt()?qh:Wh;d[zt.system]!==e?h((function(t){return ft(ft({},t),{},ct({},zt.system,e))})):g()}),[l,u]),(0,r.useEffect)((function(){a&&c({type:"SET_THEME",payload:zt.light})}),[]),null},Kh=function(){var e=v((0,r.useState)([]),2),t=e[0],n=e[1],a=v((0,r.useState)(!1),2),i=a[0],o=a[1],l=(0,r.useRef)(document.body),u=function(e){e.preventDefault(),e.stopPropagation(),"dragenter"===e.type||"dragover"===e.type?o(!0):"dragleave"===e.type&&o(!1)};return aa("dragenter",u,l),aa("dragleave",u,l),aa("dragover",u,l),aa("drop",(function(e){var t;e.preventDefault(),e.stopPropagation(),o(!1),null!==e&&void 0!==e&&null!==(t=e.dataTransfer)&&void 0!==t&&t.files&&e.dataTransfer.files[0]&&function(e){var t=Array.from(e||[]);n(t)}(e.dataTransfer.files)}),l),aa("paste",(function(e){var t,r=null===(t=e.clipboardData)||void 0===t?void 0:t.items;if(r){var a=Array.from(r).filter((function(e){return"application/json"===e.type})).map((function(e){return e.getAsFile()})).filter((function(e){return null!==e}));n(a)}}),l),{files:t,dragging:i}},Jh=function(e){var t=e.onOpenModal,n=e.onChange;return Kt("div",{className:"vm-upload-json-buttons",children:[Kt(Pa,{variant:"outlined",onClick:t,children:"Paste JSON"}),Kt(Pa,{children:["Upload Files",Kt("input",{id:"json",type:"file",accept:"application/json",multiple:!0,title:" ",onChange:n})]})]})},Xh=function(){var e=v((0,r.useState)([]),2),t=e[0],n=e[1],a=v((0,r.useState)([]),2),i=a[0],o=a[1],l=(0,r.useMemo)((function(){return!!t.length}),[t]),u=Ia(!1),c=u.value,s=u.setTrue,f=u.setFalse,d=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";o((function(n){return[{filename:t,text:": ".concat(e.message)}].concat(y(n))}))},h=function(e,t){try{var r=JSON.parse(e),a=r.trace||r;if(!a.duration_msec)return void d(new Error(Bt.traceNotFound),t);var i=new fd(a,t);n((function(e){return[i].concat(y(e))}))}catch(o){o instanceof Error&&d(o,t)}},m=function(e){e.map((function(e){var t=new FileReader,n=(null===e||void 0===e?void 0:e.name)||"";t.onload=function(e){var t,r=String(null===(t=e.target)||void 0===t?void 0:t.result);h(r,n)},t.readAsText(e)}))},p=function(e){o([]);var t=Array.from(e.target.files||[]);m(t),e.target.value=""},g=function(e){return function(){!function(e){o((function(t){return t.filter((function(t,n){return n!==e}))}))}(e)}},_=Kh(),b=_.files,w=_.dragging;return(0,r.useEffect)((function(){m(b)}),[b]),Kt("div",{className:"vm-trace-page",children:[Kt("div",{className:"vm-trace-page-header",children:[Kt("div",{className:"vm-trace-page-header-errors",children:i.map((function(e,t){return Kt("div",{className:"vm-trace-page-header-errors-item",children:[Kt(Ea,{variant:"error",children:[Kt("b",{className:"vm-trace-page-header-errors-item__filename",children:e.filename}),Kt("span",{children:e.text})]}),Kt(Pa,{className:"vm-trace-page-header-errors-item__close",startIcon:Kt(ur,{}),variant:"text",color:"error",onClick:g(t)})]},"".concat(e,"_").concat(t))}))}),Kt("div",{children:l&&Kt(Jh,{onOpenModal:s,onChange:p})})]}),l&&Kt("div",{children:Kt(Dd,{jsonEditor:!0,traces:t,onDeleteClick:function(e){var r=t.filter((function(t){return t.idValue!==e.idValue}));n(y(r))}})}),!l&&Kt("div",{className:"vm-trace-page-preview",children:[Kt("p",{className:"vm-trace-page-preview__text",children:["Please, upload file with JSON response content.","\n","The file must contain tracing information in JSON format.","\n","In order to use tracing please refer to the doc:\xa0",Kt("a",{className:"vm-link vm-link_colored",href:"https://docs.victoriametrics.com/#query-tracing",target:"_blank",rel:"help noreferrer",children:"https://docs.victoriametrics.com/#query-tracing"}),"\n","Tracing graph will be displayed after file upload.","\n","Attach files by dragging & dropping, selecting or pasting them."]}),Kt(Jh,{onOpenModal:s,onChange:p})]}),c&&Kt(Ya,{title:"Paste JSON",onClose:f,children:Kt(kd,{editable:!0,displayTitle:!0,defaultTile:"JSON ".concat(t.length+1),onClose:f,onUpload:h})}),w&&Kt("div",{className:"vm-trace-page__dropzone"})]})},em=function(e){var t=Xt().serverUrl,n=Vn().period,a=v((0,r.useState)([]),2),i=a[0],o=a[1],l=v((0,r.useState)(!1),2),u=l[0],c=l[1],s=v((0,r.useState)(),2),f=s[0],d=s[1],h=(0,r.useMemo)((function(){return function(e,t,n){var r="{job=".concat(JSON.stringify(n),"}");return"".concat(e,"/api/v1/label/instance/values?match[]=").concat(encodeURIComponent(r),"&start=").concat(t.start,"&end=").concat(t.end)}(t,n,e)}),[t,n,e]);return(0,r.useEffect)((function(){if(e){var t=function(){var e=si(ui().mark((function e(){var t,n,r;return ui().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return c(!0),e.prev=1,e.next=4,fetch(h);case 4:return t=e.sent,e.next=7,t.json();case 7:n=e.sent,r=n.data||[],o(r.sort((function(e,t){return e.localeCompare(t)}))),t.ok?d(void 0):d("".concat(n.errorType,"\r\n").concat(null===n||void 0===n?void 0:n.error)),e.next=16;break;case 13:e.prev=13,e.t0=e.catch(1),e.t0 instanceof Error&&d("".concat(e.t0.name,": ").concat(e.t0.message));case 16:c(!1);case 17:case"end":return e.stop()}}),e,null,[[1,13]])})));return function(){return e.apply(this,arguments)}}();t().catch(console.error)}}),[h]),{instances:i,isLoading:u,error:f}},tm=function(e,t){var n=Xt().serverUrl,a=Vn().period,i=v((0,r.useState)([]),2),o=i[0],l=i[1],u=v((0,r.useState)(!1),2),c=u[0],s=u[1],f=v((0,r.useState)(),2),d=f[0],h=f[1],m=(0,r.useMemo)((function(){return function(e,t,n,r){var a=Object.entries({job:n,instance:r}).filter((function(e){return e[1]})).map((function(e){var t=v(e,2),n=t[0],r=t[1];return"".concat(n,"=").concat(JSON.stringify(r))})).join(","),i="{".concat(a,"}");return"".concat(e,"/api/v1/label/__name__/values?match[]=").concat(encodeURIComponent(i),"&start=").concat(t.start,"&end=").concat(t.end)}(n,a,e,t)}),[n,a,e,t]);return(0,r.useEffect)((function(){if(e){var t=function(){var e=si(ui().mark((function e(){var t,n,r;return ui().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s(!0),e.prev=1,e.next=4,fetch(m);case 4:return t=e.sent,e.next=7,t.json();case 7:n=e.sent,r=n.data||[],l(r.sort((function(e,t){return e.localeCompare(t)}))),t.ok?h(void 0):h("".concat(n.errorType,"\r\n").concat(null===n||void 0===n?void 0:n.error)),e.next=16;break;case 13:e.prev=13,e.t0=e.catch(1),e.t0 instanceof Error&&h("".concat(e.t0.name,": ").concat(e.t0.message));case 16:s(!1);case 17:case"end":return e.stop()}}),e,null,[[1,13]])})));return function(){return e.apply(this,arguments)}}();t().catch(console.error)}}),[m]),{names:o,isLoading:c,error:d}},nm=function(e){var t=e.name,n=e.job,a=e.instance,i=e.rateEnabled,o=e.isBucket,l=e.height,u=xa().isMobile,c=ba(),s=c.customStep,f=c.yaxis,d=Vn().period,h=wa(),m=Un(),p=wn(d.end-d.start),g=bn(s),y=Cn(10*g*1e3),_=v((0,r.useState)(!1),2),b=_[0],w=_[1],k=v((0,r.useState)(!1),2),D=k[0],x=k[1],C=b&&s===p?y:s,E=(0,r.useMemo)((function(){var e=Object.entries({job:n,instance:a}).filter((function(e){return e[1]})).map((function(e){var t=v(e,2),n=t[0],r=t[1];return"".concat(n,"=").concat(JSON.stringify(r))}));e.push("__name__=".concat(JSON.stringify(t))),"node_cpu_seconds_total"==t&&e.push('mode!="idle"');var r="{".concat(e.join(","),"}");if(o)return"sum(rate(".concat(r,")) by (vmrange, le)");var l=i?"rollup_rate(".concat(r,")"):"rollup(".concat(r,")");return"\nwith (q = ".concat(l,') (\n alias(min(label_match(q, "rollup", "min")), "min"),\n alias(max(label_match(q, "rollup", "max")), "max"),\n alias(avg(label_match(q, "rollup", "avg")), "avg"),\n)')}),[t,n,a,i,o]),S=dd({predefinedQuery:[E],visible:!0,customStep:C,showAllSeries:D}),A=S.isLoading,N=S.graphData,M=S.error,T=S.queryErrors,F=S.warning,O=S.isHistogram;return(0,r.useEffect)((function(){w(O)}),[O]),Kt("div",{className:Jr()({"vm-explore-metrics-graph":!0,"vm-explore-metrics-graph_mobile":u}),children:[A&&Kt(hd,{}),M&&Kt(Ea,{variant:"error",children:M}),T[0]&&Kt(Ea,{variant:"error",children:T[0]}),F&&Kt(Cd,{warning:F,query:[E],onChange:x}),N&&d&&Kt(Ud,{data:N,period:d,customStep:C,query:[E],yaxis:f,setYaxisLimits:function(e){h({type:"SET_YAXIS_LIMITS",payload:e})},setPeriod:function(e){var t=e.from,n=e.to;m({type:"SET_PERIOD",payload:{from:t,to:n}})},showLegend:!1,height:l,isHistogram:O})]})},rm=function(e){var t=e.name,n=e.index,r=e.length,a=e.isBucket,i=e.rateEnabled,o=e.onChangeRate,l=e.onRemoveItem,u=e.onChangeOrder,c=xa().isMobile,s=Ia(!1),f=s.value,d=s.setTrue,h=s.setFalse,m=function(){l(t)},p=function(){u(t,n,n+1)},v=function(){u(t,n,n-1)};return Kt("div",c?{className:"vm-explore-metrics-item-header vm-explore-metrics-item-header_mobile",children:[Kt("div",{className:"vm-explore-metrics-item-header__name",children:t}),Kt(Pa,{variant:"text",size:"small",startIcon:Kt(Hr,{}),onClick:d,ariaLabel:"open panel settings"}),f&&Kt(Ya,{title:t,onClose:h,children:Kt("div",{className:"vm-explore-metrics-item-header-modal",children:[Kt("div",{className:"vm-explore-metrics-item-header-modal-order",children:[Kt(Pa,{startIcon:Kt(Ar,{}),variant:"outlined",onClick:v,disabled:0===n,ariaLabel:"move graph up"}),Kt("p",{children:["position:",Kt("span",{className:"vm-explore-metrics-item-header-modal-order__index",children:["#",n+1]})]}),Kt(Pa,{endIcon:Kt(Sr,{}),variant:"outlined",onClick:p,disabled:n===r-1,ariaLabel:"move graph down"})]}),!a&&Kt("div",{className:"vm-explore-metrics-item-header-modal__rate",children:[Kt(Kf,{label:Kt("span",{children:["enable ",Kt("code",{children:"rate()"})]}),value:i,onChange:o,fullWidth:!0}),Kt("p",{children:"calculates the average per-second speed of metrics change"})]}),Kt(Pa,{startIcon:Kt(ur,{}),color:"error",variant:"outlined",onClick:m,fullWidth:!0,children:"Remove graph"})]})})]}:{className:"vm-explore-metrics-item-header",children:[Kt("div",{className:"vm-explore-metrics-item-header-order",children:[Kt(qa,{title:"move graph up",children:Kt(Pa,{className:"vm-explore-metrics-item-header-order__up",startIcon:Kt(pr,{}),variant:"text",color:"gray",size:"small",onClick:v,ariaLabel:"move graph up"})}),Kt("div",{className:"vm-explore-metrics-item-header__index",children:["#",n+1]}),Kt(qa,{title:"move graph down",children:Kt(Pa,{className:"vm-explore-metrics-item-header-order__down",startIcon:Kt(pr,{}),variant:"text",color:"gray",size:"small",onClick:p,ariaLabel:"move graph down"})})]}),Kt("div",{className:"vm-explore-metrics-item-header__name",children:t}),!a&&Kt("div",{className:"vm-explore-metrics-item-header__rate",children:Kt(qa,{title:"calculates the average per-second speed of metric's change",children:Kt(Kf,{label:Kt("span",{children:["enable ",Kt("code",{children:"rate()"})]}),value:i,onChange:o})})}),Kt("div",{className:"vm-explore-metrics-item-header__close",children:Kt(qa,{title:"close graph",children:Kt(Pa,{startIcon:Kt(ur,{}),variant:"text",color:"gray",size:"small",onClick:m,ariaLabel:"close graph"})})})]})},am=function(e){var t=e.name,n=e.job,a=e.instance,i=e.index,o=e.length,l=e.size,u=e.onRemoveItem,c=e.onChangeOrder,s=(0,r.useMemo)((function(){return/_sum?|_total?|_count?/.test(t)}),[t]),f=(0,r.useMemo)((function(){return/_bucket?/.test(t)}),[t]),d=v((0,r.useState)(s),2),h=d[0],m=d[1],p=ia(),g=(0,r.useMemo)(l.height,[l,p]);return(0,r.useEffect)((function(){m(s)}),[n]),Kt("div",{className:"vm-explore-metrics-item vm-block vm-block_empty-padding",children:[Kt(rm,{name:t,index:i,length:o,isBucket:f,rateEnabled:h,size:l.id,onChangeRate:m,onRemoveItem:u,onChangeOrder:c}),Kt(nm,{name:t,job:n,instance:a,rateEnabled:h,isBucket:f,height:g},"".concat(t,"_").concat(n,"_").concat(a,"_").concat(h))]})},im=function(e){var t=e.values,n=e.onRemoveItem,r=xa().isMobile;return r?Kt("span",{className:"vm-select-input-content__counter",children:["selected ",t.length]}):Kt(Zt.HY,{children:t.map((function(e){return Kt("div",{className:"vm-select-input-content__selected",children:[Kt("span",{children:e}),Kt("div",{onClick:(t=e,function(e){n(t),e.stopPropagation()}),children:Kt(ur,{})})]},e);var t}))})},om=function(e){var t=e.value,n=e.list,a=e.label,i=e.placeholder,o=e.noOptionsText,l=e.clearable,u=void 0!==l&&l,c=e.searchable,s=void 0!==c&&c,f=e.autofocus,d=e.disabled,h=e.onChange,m=Xt().isDarkTheme,p=xa().isMobile,g=v((0,r.useState)(""),2),y=g[0],_=g[1],b=(0,r.useRef)(null),w=v((0,r.useState)(!1),2),k=w[0],D=w[1],x=(0,r.useRef)(null),C=Array.isArray(t),E=Array.isArray(t)?t:void 0,S=p&&C&&!(null===E||void 0===E||!E.length),A=(0,r.useMemo)((function(){return k?y:Array.isArray(t)?"":t}),[t,y,k,C]),N=(0,r.useMemo)((function(){return k?y||"(.+)":""}),[y,k]),M=function(){x.current&&x.current.blur()},T=function(e){h(e),C||(D(!1),M()),C&&x.current&&x.current.focus()};return(0,r.useEffect)((function(){_(""),k&&x.current&&x.current.focus(),k||M()}),[k,x]),(0,r.useEffect)((function(){f&&x.current&&!p&&x.current.focus()}),[f,x]),aa("keyup",(function(e){x.current!==e.target&&D(!1)})),Kt("div",{className:Jr()({"vm-select":!0,"vm-select_dark":m,"vm-select_disabled":d}),children:[Kt("div",{className:"vm-select-input",onClick:function(e){e.target instanceof HTMLInputElement||d||D((function(e){return!e}))},ref:b,children:[Kt("div",{className:"vm-select-input-content",children:[!(null===E||void 0===E||!E.length)&&Kt(im,{values:E,onRemoveItem:T}),!S&&Kt("input",{value:A,type:"text",placeholder:i,onInput:function(e){_(e.target.value)},onFocus:function(){d||D(!0)},ref:x,readOnly:p||!s})]}),a&&Kt("span",{className:"vm-text-field__label",children:a}),u&&t&&Kt("div",{className:"vm-select-input__icon",onClick:function(e){return function(t){T(e),t.stopPropagation()}}(""),children:Kt(ur,{})}),Kt("div",{className:Jr()({"vm-select-input__icon":!0,"vm-select-input__icon_open":k}),children:Kt(vr,{})})]}),Kt(fo,{label:a,value:N,options:n.map((function(e){return{value:e}})),anchor:b,selected:E,minLength:1,fullWidth:!0,noOptionsText:o,onSelect:T,onOpenAutocomplete:D})]})},lm=Ot.map((function(e){return e.id})),um=function(e){var t=e.jobs,n=e.instances,a=e.names,i=e.job,o=e.instance,l=e.size,u=e.selectedMetrics,c=e.onChangeJob,s=e.onChangeInstance,f=e.onToggleMetric,d=e.onChangeSize,h=(0,r.useMemo)((function(){return i?"":"No instances. Please select job"}),[i]),m=(0,r.useMemo)((function(){return i?"":"No metric names. Please select job"}),[i]),p=xa().isMobile,v=Ia("false"!==Ct("EXPLORE_METRICS_TIPS")),g=v.value,y=v.toggle,_=v.setFalse;return(0,r.useEffect)((function(){xt("EXPLORE_METRICS_TIPS","".concat(g))}),[g]),Kt(Zt.HY,{children:[Kt("div",{className:Jr()({"vm-explore-metrics-header":!0,"vm-explore-metrics-header_mobile":p,"vm-block":!0,"vm-block_mobile":p}),children:[Kt("div",{className:"vm-explore-metrics-header__job",children:Kt(om,{value:i,list:t,label:"Job",placeholder:"Please select job",onChange:c,autofocus:!i&&!!t.length&&!p,searchable:!0})}),Kt("div",{className:"vm-explore-metrics-header__instance",children:Kt(om,{value:o,list:n,label:"Instance",placeholder:"Please select instance",onChange:s,noOptionsText:h,clearable:!0,searchable:!0})}),Kt("div",{className:"vm-explore-metrics-header__size",children:[Kt(om,{label:"Size graphs",value:l,list:lm,onChange:d}),Kt(qa,{title:"".concat(g?"Hide":"Show"," tip"),children:Kt(Pa,{variant:"text",color:g?"warning":"gray",startIcon:Kt($r,{}),onClick:y,ariaLabel:"visibility tips"})})]}),Kt("div",{className:"vm-explore-metrics-header-metrics",children:Kt(om,{label:"Metrics",value:u,list:a,placeholder:"Search metric name",onChange:f,noOptionsText:m,clearable:!0,searchable:!0})})]}),g&&Kt(Ea,{variant:"warning",children:Kt("div",{className:"vm-explore-metrics-header-description",children:[Kt("p",{children:["Please note: this page is solely designed for exploring Prometheus metrics. Prometheus metrics always contain ",Kt("code",{children:"job"})," and ",Kt("code",{children:"instance"})," labels (see ",Kt("a",{className:"vm-link vm-link_colored",href:"https://prometheus.io/docs/concepts/jobs_instances/",children:"these docs"}),"), and this page relies on them as filters. ",Kt("br",{}),"Please use this page for Prometheus metrics only, in accordance with their naming conventions."]}),Kt(Pa,{variant:"text",size:"small",startIcon:Kt(ur,{}),onClick:_,ariaLabel:"close tips"})]})})]})},cm=Pt("job",""),sm=Pt("instance",""),fm=Pt("metrics",""),dm=Pt("size",""),hm=Ot.find((function(e){return dm?e.id===dm:e.isDefault}))||Ot[0],mm=function(){var e=v((0,r.useState)(cm),2),t=e[0],n=e[1],a=v((0,r.useState)(sm),2),i=a[0],o=a[1],l=v((0,r.useState)(fm?fm.split("&"):[]),2),u=l[0],c=l[1],s=v((0,r.useState)(hm),2),f=s[0],d=s[1];!function(e){var t=e.job,n=e.instance,a=e.metrics,i=e.size,o=Vn(),l=o.duration,u=o.relativeTime,c=o.period.date,s=ba().customStep,f=Vi().setSearchParamsFromKeys,d=function(){var e,r=md((ct(e={},"g0.range_input",l),ct(e,"g0.end_input",c),ct(e,"g0.step_input",s),ct(e,"g0.relative_time",u),ct(e,"size",i),ct(e,"job",t),ct(e,"instance",n),ct(e,"metrics",a),e));f(r)};(0,r.useEffect)(d,[l,u,c,s,t,n,a,i]),(0,r.useEffect)(d,[])}({job:t,instance:i,metrics:u.join("&"),size:f.id});var h=function(){var e=Xt().serverUrl,t=Vn().period,n=v((0,r.useState)([]),2),a=n[0],i=n[1],o=v((0,r.useState)(!1),2),l=o[0],u=o[1],c=v((0,r.useState)(),2),s=c[0],f=c[1],d=(0,r.useMemo)((function(){return function(e,t){return"".concat(e,"/api/v1/label/job/values?start=").concat(t.start,"&end=").concat(t.end)}(e,t)}),[e,t]);return(0,r.useEffect)((function(){var e=function(){var e=si(ui().mark((function e(){var t,n,r;return ui().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return u(!0),e.prev=1,e.next=4,fetch(d);case 4:return t=e.sent,e.next=7,t.json();case 7:n=e.sent,r=n.data||[],i(r.sort((function(e,t){return e.localeCompare(t)}))),t.ok?f(void 0):f("".concat(n.errorType,"\r\n").concat(null===n||void 0===n?void 0:n.error)),e.next=16;break;case 13:e.prev=13,e.t0=e.catch(1),e.t0 instanceof Error&&f("".concat(e.t0.name,": ").concat(e.t0.message));case 16:u(!1);case 17:case"end":return e.stop()}}),e,null,[[1,13]])})));return function(){return e.apply(this,arguments)}}();e().catch(console.error)}),[d]),{jobs:a,isLoading:l,error:s}}(),m=h.jobs,p=h.isLoading,g=h.error,_=em(t),b=_.instances,w=_.isLoading,k=_.error,D=tm(t,i),x=D.names,C=D.isLoading,E=D.error,S=(0,r.useMemo)((function(){return p||w||C}),[p,w,C]),A=(0,r.useMemo)((function(){return g||k||E}),[g,k,E]),N=function(e){c(e?function(t){return t.includes(e)?t.filter((function(t){return t!==e})):[].concat(y(t),[e])}:[])},M=function(e,t,n){var r=n>u.length-1;n<0||r||c((function(e){var r=y(e),a=v(r.splice(t,1),1)[0];return r.splice(n,0,a),r}))};return(0,r.useEffect)((function(){i&&b.length&&!b.includes(i)&&o("")}),[b,i]),Kt("div",{className:"vm-explore-metrics",children:[Kt(um,{jobs:m,instances:b,names:x,job:t,size:f.id,instance:i,selectedMetrics:u,onChangeJob:n,onChangeSize:function(e){var t=Ot.find((function(t){return t.id===e}));t&&d(t)},onChangeInstance:o,onToggleMetric:N}),S&&Kt(hd,{}),A&&Kt(Ea,{variant:"error",children:A}),!t&&Kt(Ea,{variant:"info",children:"Please select job to see list of metric names."}),t&&!u.length&&Kt(Ea,{variant:"info",children:"Please select metric names to see the graphs."}),Kt("div",{className:"vm-explore-metrics-body",children:u.map((function(e,n){return Kt(am,{name:e,job:t,instance:i,index:n,length:u.length,size:f,onRemoveItem:N,onChangeOrder:M},e)}))})]})},pm=function(){var t=td();return Kt("div",{className:"vm-preview-icons",children:Object.entries(e).map((function(e){var n,r=v(e,2),a=r[0],i=r[1];return Kt("div",{className:"vm-preview-icons-item",onClick:(n=a,si(ui().mark((function e(){return ui().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t("<".concat(n,"/>"),"<".concat(n,"/> has been copied"));case 2:case"end":return e.stop()}}),e)})))),children:[Kt("div",{className:"vm-preview-icons-item__svg",children:i()}),Kt("div",{className:"vm-preview-icons-item__name",children:"<".concat(a,"/>")})]},a)}))})},vm=function(e){return e.copy="Copy",e.copied="Copied",e}(vm||{}),gm=function(e){var t=e.code,n=v((0,r.useState)(vm.copy),2),a=n[0],i=n[1];return(0,r.useEffect)((function(){var e=null;return a===vm.copied&&(e=setTimeout((function(){return i(vm.copy)}),1e3)),function(){e&&clearTimeout(e)}}),[a]),Kt("code",{className:"vm-code-example",children:[t,Kt("div",{className:"vm-code-example__copy",children:Kt(qa,{title:a,children:Kt(Pa,{size:"small",variant:"text",onClick:function(){navigator.clipboard.writeText(t),i(vm.copied)},startIcon:Kt(Or,{}),ariaLabel:"close"})})})]})},ym=function(){return Kt("a",{className:"vm-link vm-link_colored",href:"https://docs.victoriametrics.com/MetricsQL.html",target:"_blank",rel:"help noreferrer",children:"MetricsQL"})},_m=function(){return Kt("a",{className:"vm-link vm-link_colored",href:"https://grafana.com/grafana/dashboards/1860-node-exporter-full/",target:"_blank",rel:"help noreferrer",children:"Node Exporter Full"})},bm=function(){return Kt("section",{className:"vm-with-template-tutorial",children:[Kt("h2",{className:"vm-with-template-tutorial__title",children:["Tutorial for WITH expressions in ",Kt(ym,{})]}),Kt("div",{className:"vm-with-template-tutorial-section",children:[Kt("p",{className:"vm-with-template-tutorial-section__text",children:["Let's look at the following real query from ",Kt(_m,{})," dashboard:"]}),Kt(gm,{code:'(\n (\n node_memory_MemTotal_bytes{instance=~"$node:$port", job=~"$job"}\n -\n node_memory_MemFree_bytes{instance=~"$node:$port", job=~"$job"}\n )\n /\n node_memory_MemTotal_bytes{instance=~"$node:$port", job=~"$job"}\n) * 100'}),Kt("p",{className:"vm-with-template-tutorial-section__text",children:"It is clear the query calculates the percentage of used memory for the given $node, $port and $job. Isn't it? :)"})]}),Kt("div",{className:"vm-with-template-tutorial-section",children:[Kt("p",{className:"vm-with-template-tutorial-section__text",children:"What's wrong with this query? Copy-pasted label filters for distinct timeseries which makes it easy to mistype these filters during modification. Let's simplify the query with WITH expressions:"}),Kt(gm,{code:'WITH (\n commonFilters = {instance=~"$node:$port",job=~"$job"}\n)\n(\n node_memory_MemTotal_bytes{commonFilters}\n -\n node_memory_MemFree_bytes{commonFilters}\n)\n /\nnode_memory_MemTotal_bytes{commonFilters} * 100'})]}),Kt("div",{className:"vm-with-template-tutorial-section",children:[Kt("p",{className:"vm-with-template-tutorial-section__text",children:["Now label filters are located in a single place instead of three distinct places. The query mentions node_memory_MemTotal_bytes metric twice and ","{commonFilters}"," three times. WITH expressions may improve this:"]}),Kt(gm,{code:'WITH (\n my_resource_utilization(free, limit, filters) = (limit{filters} - free{filters}) / limit{filters} * 100\n)\nmy_resource_utilization(\n node_memory_MemFree_bytes,\n node_memory_MemTotal_bytes,\n {instance=~"$node:$port",job=~"$job"},\n)'}),Kt("p",{className:"vm-with-template-tutorial-section__text",children:"Now the template function my_resource_utilization() may be used for monitoring arbitrary resources - memory, CPU, network, storage, you name it."})]}),Kt("div",{className:"vm-with-template-tutorial-section",children:[Kt("p",{className:"vm-with-template-tutorial-section__text",children:["Let's take another nice query from ",Kt(_m,{})," dashboard:"]}),Kt(gm,{code:'(\n (\n (\n count(\n count(node_cpu_seconds_total{instance=~"$node:$port",job=~"$job"}) by (cpu)\n )\n )\n -\n avg(\n sum by (mode) (rate(node_cpu_seconds_total{mode=\'idle\',instance=~"$node:$port",job=~"$job"}[5m]))\n )\n )\n *\n 100\n)\n /\ncount(\n count(node_cpu_seconds_total{instance=~"$node:$port",job=~"$job"}) by (cpu)\n)'}),Kt("p",{className:"vm-with-template-tutorial-section__text",children:"Do you understand what does this mess do? Is it manageable? :) WITH expressions are happy to help in a few iterations."})]}),Kt("div",{className:"vm-with-template-tutorial-section",children:[Kt("p",{className:"vm-with-template-tutorial-section__text",children:"1. Extract common filters used in multiple places into a commonFilters variable:"}),Kt(gm,{code:'WITH (\n commonFilters = {instance=~"$node:$port",job=~"$job"}\n)\n(\n (\n (\n count(\n count(node_cpu_seconds_total{commonFilters}) by (cpu)\n )\n )\n -\n avg(\n sum by (mode) (rate(node_cpu_seconds_total{mode=\'idle\',commonFilters}[5m]))\n )\n )\n *\n 100\n)\n /\ncount(\n count(node_cpu_seconds_total{commonFilters}) by (cpu)\n)'})]}),Kt("div",{className:"vm-with-template-tutorial-section",children:[Kt("p",{className:"vm-with-template-tutorial-section__text",children:'2. Extract "count(count(...) by (cpu))" into cpuCount variable:'}),Kt(gm,{code:'WITH (\n commonFilters = {instance=~"$node:$port",job=~"$job"},\n cpuCount = count(count(node_cpu_seconds_total{commonFilters}) by (cpu))\n)\n(\n (\n cpuCount\n -\n avg(\n sum by (mode) (rate(node_cpu_seconds_total{mode=\'idle\',commonFilters}[5m]))\n )\n )\n *\n 100\n) / cpuCount'})]}),Kt("div",{className:"vm-with-template-tutorial-section",children:[Kt("p",{className:"vm-with-template-tutorial-section__text",children:"3. Extract rate(...) part into cpuIdle variable, since it is clear now that this part calculates the number of idle CPUs:"}),Kt(gm,{code:'WITH (\n commonFilters = {instance=~"$node:$port",job=~"$job"},\n cpuCount = count(count(node_cpu_seconds_total{commonFilters}) by (cpu)),\n cpuIdle = sum(rate(node_cpu_seconds_total{mode=\'idle\',commonFilters}[5m]))\n)\n((cpuCount - cpuIdle) * 100) / cpuCount'})]}),Kt("div",{className:"vm-with-template-tutorial-section",children:[Kt("p",{className:"vm-with-template-tutorial-section__text",children:["4. Put node_cpu_seconds_total","{commonFilters}"," into its own varialbe with the name cpuSeconds:"]}),Kt(gm,{code:'WITH (\n cpuSeconds = node_cpu_seconds_total{instance=~"$node:$port",job=~"$job"},\n cpuCount = count(count(cpuSeconds) by (cpu)),\n cpuIdle = sum(rate(cpuSeconds{mode=\'idle\'}[5m]))\n)\n((cpuCount - cpuIdle) * 100) / cpuCount'}),Kt("p",{className:"vm-with-template-tutorial-section__text",children:"Now the query became more clear comparing to the initial query."})]}),Kt("div",{className:"vm-with-template-tutorial-section",children:[Kt("p",{className:"vm-with-template-tutorial-section__text",children:"WITH expressions may be nested and may be put anywhere. Try expanding the following query:"}),Kt(gm,{code:"WITH (\n f(a, b) = WITH (\n f1(x) = b-x,\n f2(x) = x+x\n ) f1(a)*f2(b)\n) f(foo, with(x=bar) x)"})]})]})},wm=function(e,t){return"".concat(e,"/expand-with-exprs?query=").concat(encodeURIComponent(t),"&format=json")},km=function(){var e=v(ut(),1)[0],t=function(){var e=Xt().serverUrl,t=v(ut(),2),n=t[0],a=t[1],i=v((0,r.useState)(""),2),o=i[0],l=i[1],u=v((0,r.useState)(!1),2),c=u[0],s=u[1],f=v((0,r.useState)(),2),d=f[0],h=f[1],m=function(){var t=si(ui().mark((function t(r){var i,o,u;return ui().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n.set("expr",r),a(n),i=wm(e,r),s(!0),t.prev=4,t.next=7,fetch(i);case 7:return o=t.sent,t.next=10,o.json();case 10:u=t.sent,l((null===u||void 0===u?void 0:u.expr)||""),h(String(u.error||"")),t.next=18;break;case 15:t.prev=15,t.t0=t.catch(4),t.t0 instanceof Error&&"AbortError"!==t.t0.name&&h("".concat(t.t0.name,": ").concat(t.t0.message));case 18:s(!1);case 19:case"end":return t.stop()}}),t,null,[[4,15]])})));return function(e){return t.apply(this,arguments)}}();return{data:o,error:d,loading:c,expand:m}}(),n=t.data,a=t.loading,i=t.error,o=t.expand,l=v((0,r.useState)(e.get("expr")||""),2),u=l[0],c=l[1],s=function(){o(u)};return(0,r.useEffect)((function(){u&&o(u)}),[]),Kt("section",{className:"vm-with-template",children:[a&&Kt(hd,{}),Kt("div",{className:"vm-with-template-body vm-block",children:[Kt("div",{className:"vm-with-template-body__expr",children:Kt(wi,{type:"textarea",label:"MetricsQL query with optional WITH expressions",value:u,error:i,autofocus:!0,onEnter:s,onChange:function(e){c(e)}})}),Kt("div",{className:"vm-with-template-body__result",children:Kt(wi,{type:"textarea",label:"MetricsQL query after expanding WITH expressions and applying other optimizations",value:n,disabled:!0})}),Kt("div",{className:"vm-with-template-body-top",children:Kt(Pa,{variant:"contained",onClick:s,startIcon:Kt(wr,{}),children:"Expand"})})]}),Kt("div",{className:"vm-block",children:Kt(bm,{})})]})},Dm=function(e,t,n){var r=["format=json","relabel_configs=".concat(encodeURIComponent(t)),"metric=".concat(encodeURIComponent(n))];return"".concat(e,"/metric-relabel-debug?").concat(r.join("&"))},xm='- if: \'{bar_label=~"b.*"}\'\n source_labels: [foo_label, bar_label]\n separator: "_"\n target_label: foobar\n- action: labeldrop\n regex: "foo_.*"\n- target_label: job\n replacement: "my-application-2"',Cm='{__name__="my_metric", bar_label="bar", foo_label="foo", job="my-application", instance="192.168.0.1"}',Em=function(){var e=v(ut(),2),t=e[0],n=e[1],a=function(){var e=Xt().serverUrl,t=v((0,r.useState)(null),2),n=t[0],a=t[1],i=v((0,r.useState)(!1),2),o=i[0],l=i[1],u=v((0,r.useState)(),2),c=u[0],s=u[1],f=function(){var t=si(ui().mark((function t(n,r){var i,o,u;return ui().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=Dm(e,n,r),l(!0),t.prev=2,t.next=5,fetch(i);case 5:return o=t.sent,t.next=8,o.json();case 8:u=t.sent,a(u.error?null:u),s(String(u.error||"")),t.next=16;break;case 13:t.prev=13,t.t0=t.catch(2),t.t0 instanceof Error&&"AbortError"!==t.t0.name&&s("".concat(t.t0.name,": ").concat(t.t0.message));case 16:l(!1);case 17:case"end":return t.stop()}}),t,null,[[2,13]])})));return function(e,n){return t.apply(this,arguments)}}();return{data:n,error:c,loading:o,fetchData:f}}(),i=a.data,o=a.loading,l=a.error,u=a.fetchData,c=v(kh("","config"),2),s=c[0],f=c[1],d=v(kh("","labels"),2),h=d[0],m=d[1],p=(0,r.useCallback)((function(){u(s,h),t.set("config",s),t.set("labels",h),n(t)}),[s,h]);return(0,r.useEffect)((function(){var e=t.get("config")||"",n=t.get("labels")||"";(n||e)&&(u(e,n),f(e),m(n))}),[]),Kt("section",{className:"vm-relabeling",children:[o&&Kt(hd,{}),Kt("div",{className:"vm-relabeling-header vm-block",children:[Kt("div",{className:"vm-relabeling-header-configs",children:Kt(wi,{type:"textarea",label:"Relabel configs",value:s,autofocus:!0,onChange:function(e){f(e||"")},onEnter:p})}),Kt("div",{className:"vm-relabeling-header__labels",children:Kt(wi,{type:"textarea",label:"Labels",value:h,onChange:function(e){m(e||"")},onEnter:p})}),Kt("div",{className:"vm-relabeling-header-bottom",children:[Kt("a",{className:"vm-link vm-link_with-icon",target:"_blank",href:"https://docs.victoriametrics.com/relabeling.html",rel:"help noreferrer",children:[Kt(sr,{}),"Relabeling cookbook"]}),Kt("a",{className:"vm-link vm-link_with-icon",target:"_blank",href:"https://docs.victoriametrics.com/vmagent.html#relabeling",rel:"help noreferrer",children:[Kt(Ir,{}),"Documentation"]}),Kt(Pa,{variant:"text",onClick:function(){var e=xm,r=Cm;f(e),m(r),u(e,r),t.set("config",e),t.set("labels",r),n(t)},children:"Try example"}),Kt(Pa,{variant:"contained",onClick:p,startIcon:Kt(wr,{}),children:"Submit"})]})]}),l&&Kt(Ea,{variant:"error",children:l}),i&&Kt("div",{className:"vm-relabeling-steps vm-block",children:[i.originalLabels&&Kt("div",{className:"vm-relabeling-steps-item",children:Kt("div",{className:"vm-relabeling-steps-item__row",children:[Kt("span",{children:"Original labels:"}),Kt("code",{dangerouslySetInnerHTML:{__html:i.originalLabels}})]})}),i.steps.map((function(e,t){return Kt("div",{className:"vm-relabeling-steps-item",children:[Kt("div",{className:"vm-relabeling-steps-item__row",children:[Kt("span",{children:"Step:"}),t+1]}),Kt("div",{className:"vm-relabeling-steps-item__row",children:[Kt("span",{children:"Relabeling Rule:"}),Kt("code",{children:Kt("pre",{children:e.rule})})]}),Kt("div",{className:"vm-relabeling-steps-item__row",children:[Kt("span",{children:"Input Labels:"}),Kt("code",{children:Kt("pre",{dangerouslySetInnerHTML:{__html:e.inLabels}})})]}),Kt("div",{className:"vm-relabeling-steps-item__row",children:[Kt("span",{children:"Output labels:"}),Kt("code",{children:Kt("pre",{dangerouslySetInnerHTML:{__html:e.outLabels}})})]})]},t)})),i.resultingLabels&&Kt("div",{className:"vm-relabeling-steps-item",children:Kt("div",{className:"vm-relabeling-steps-item__row",children:[Kt("span",{children:"Resulting labels:"}),Kt("code",{dangerouslySetInnerHTML:{__html:i.resultingLabels}})]})})]})]})},Sm=function(e){var t=e.rows,n=e.columns,a=e.defaultOrderBy,i=e.copyToClipboard,o=e.paginationOffset,l=v((0,r.useState)(a),2),u=l[0],c=l[1],s=v((0,r.useState)("desc"),2),f=s[0],d=s[1],h=v((0,r.useState)(null),2),m=h[0],p=h[1],g=(0,r.useMemo)((function(){var e=o.startIndex,n=o.endIndex;return Nh(t,Ah(f,u)).slice(e,n)}),[t,u,f,o]),y=function(e,t){return si(ui().mark((function n(){return ui().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(m!==t){n.next=2;break}return n.abrupt("return");case 2:return n.prev=2,n.next=5,navigator.clipboard.writeText(String(e));case 5:p(t),n.next=11;break;case 8:n.prev=8,n.t0=n.catch(2),console.error(n.t0);case 11:case"end":return n.stop()}}),n,null,[[2,8]])})))};return(0,r.useEffect)((function(){if(null!==m){var e=setTimeout((function(){return p(null)}),2e3);return function(){return clearTimeout(e)}}}),[m]),Kt("table",{className:"vm-table",children:[Kt("thead",{className:"vm-table-header",children:Kt("tr",{className:"vm-table__row vm-table__row_header",children:[n.map((function(e){return Kt("th",{className:"vm-table-cell vm-table-cell_header vm-table-cell_sort",onClick:(t=e.key,function(){d((function(e){return"asc"===e&&u===t?"desc":"asc"})),c(t)}),children:Kt("div",{className:"vm-table-cell__content",children:[Kt("div",{children:String(e.title||e.key)}),Kt("div",{className:Jr()({"vm-table__sort-icon":!0,"vm-table__sort-icon_active":u===e.key,"vm-table__sort-icon_desc":"desc"===f&&u===e.key}),children:Kt(vr,{})})]})},String(e.key));var t})),i&&Kt("th",{className:"vm-table-cell vm-table-cell_header"})]})}),Kt("tbody",{className:"vm-table-body",children:g.map((function(e,t){return Kt("tr",{className:"vm-table__row",children:[n.map((function(t){return Kt("td",{className:Jr()(ct({"vm-table-cell":!0},"".concat(t.className),t.className)),children:e[t.key]||"-"},String(t.key))})),i&&Kt("td",{className:"vm-table-cell vm-table-cell_right",children:e[i]&&Kt("div",{className:"vm-table-cell__content",children:Kt(qa,{title:m===t?"Copied":"Copy row",children:Kt(Pa,{variant:"text",color:m===t?"success":"gray",size:"small",startIcon:Kt(m===t?Nr:Or,{}),onClick:y(e[i],t),ariaLabel:"copy row"})})})})]},t)}))})]})},Am=function(){var e=xa().isMobile,t=Vn().timezone,n=function(){var e=Xt().serverUrl,t=v((0,r.useState)([]),2),n=t[0],a=t[1],o=v((0,r.useState)(i()().format(an)),2),l=o[0],u=o[1],c=v((0,r.useState)(!1),2),s=c[0],f=c[1],d=v((0,r.useState)(),2),h=d[0],m=d[1],p=(0,r.useMemo)((function(){return"".concat(e,"/api/v1/status/active_queries")}),[e]),g=function(){var e=si(ui().mark((function e(){var t,n;return ui().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return f(!0),e.prev=1,e.next=4,fetch(p);case 4:return t=e.sent,e.next=7,t.json();case 7:n=e.sent,a(n.data),u(i()().format("HH:mm:ss:SSS")),t.ok?m(void 0):m("".concat(n.errorType,"\r\n").concat(null===n||void 0===n?void 0:n.error)),e.next=16;break;case 13:e.prev=13,e.t0=e.catch(1),e.t0 instanceof Error&&m("".concat(e.t0.name,": ").concat(e.t0.message));case 16:f(!1);case 17:case"end":return e.stop()}}),e,null,[[1,13]])})));return function(){return e.apply(this,arguments)}}();return(0,r.useEffect)((function(){g().catch(console.error)}),[p]),{data:n,lastUpdated:l,isLoading:s,error:h,fetchData:g}}(),a=n.data,o=n.lastUpdated,l=n.isLoading,u=n.error,c=n.fetchData,s=(0,r.useMemo)((function(){return a.map((function(e){var t=i()(e.start).tz().format(rn),n=i()(e.end).tz().format(rn);return{duration:e.duration,remote_addr:e.remote_addr,query:e.query,args:"".concat(t," to ").concat(n,", step=").concat(yn(e.step)),data:JSON.stringify(e,null,2)}}))}),[a,t]),f=(0,r.useMemo)((function(){if(null===s||void 0===s||!s.length)return[];var e=Object.keys(s[0]),t={remote_addr:"client address"},n=["data"];return e.filter((function(e){return!n.includes(e)})).map((function(e){return{key:e,title:t[e]||e}}))}),[s]),d=function(){var e=si(ui().mark((function e(){return ui().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:c().catch(console.error);case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();return Kt("div",{className:"vm-active-queries",children:[l&&Kt(hd,{}),Kt("div",{className:"vm-active-queries-header",children:[!s.length&&!u&&Kt(Ea,{variant:"info",children:"There are currently no active queries running"}),u&&Kt(Ea,{variant:"error",children:u}),Kt("div",{className:"vm-active-queries-header-controls",children:[Kt(Pa,{variant:"contained",onClick:d,startIcon:Kt(mr,{}),children:"Update"}),Kt("div",{className:"vm-active-queries-header__update-msg",children:["Last updated: ",o]})]})]}),!!s.length&&Kt("div",{className:Jr()({"vm-block":!0,"vm-block_mobile":e}),children:Kt(Sm,{rows:s,columns:f,defaultOrderBy:"duration",copyToClipboard:"data",paginationOffset:{startIndex:0,endIndex:1/0}})})]})},Nm=function(e){var t=e.onClose,n=e.onUpload,a=xa().isMobile,i=v((0,r.useState)(""),2),o=i[0],l=i[1],u=v((0,r.useState)(""),2),c=u[0],s=u[1],f=(0,r.useMemo)((function(){try{return JSON.parse(o),""}catch(e){return e instanceof Error?e.message:"Unknown error"}}),[o]),d=function(){s(f),f||(n(o),t())};return Kt("div",{className:Jr()({"vm-json-form vm-json-form_one-field":!0,"vm-json-form_mobile vm-json-form_one-field_mobile":a}),children:[Kt(wi,{value:o,label:"JSON",type:"textarea",error:c,autofocus:!0,onChange:function(e){s(""),l(e)},onEnter:d}),Kt("div",{className:"vm-json-form-footer",children:Kt("div",{className:"vm-json-form-footer__controls vm-json-form-footer__controls_right",children:[Kt(Pa,{variant:"outlined",color:"error",onClick:t,children:"Cancel"}),Kt(Pa,{variant:"contained",onClick:d,children:"apply"})]})})]})},Mm=function(e){var t=e.data,n=e.period,a=xa().isMobile,i=pa().tableCompact,o=va(),l=v((0,r.useState)([]),2),u=l[0],c=l[1],s=v((0,r.useState)(),2),f=s[0],d=s[1],h=v((0,r.useState)(),2),m=h[0],p=h[1],g=v((0,r.useState)(!1),2),_=g[0],b=g[1],w=v((0,r.useState)([]),2),k=w[0],D=w[1],x=v((0,r.useState)(),2),C=x[0],E=x[1],S=(0,r.useMemo)((function(){return Gd(m||[]).map((function(e){return e.key}))}),[m]),A=(0,r.useMemo)((function(){var e=t.some((function(e){return"matrix"===e.data.resultType}));return t.some((function(e){return"vector"===e.data.resultType}))&&e?la:e?la.filter((function(e){return"chart"===e.value})):la.filter((function(e){return"chart"!==e.value}))}),[t]),N=v((0,r.useState)(A[0].value),2),M=N[0],T=N[1],F=ba().yaxis,O=wa(),L=function(e){O({type:"SET_YAXIS_LIMITS",payload:e})};return(0,r.useEffect)((function(){var e="chart"===M?"matrix":"vector",n=t.filter((function(t){return t.data.resultType===e&&t.trace})).map((function(e){var t,n;return e.trace?new fd(e.trace,(null===e||void 0===e||null===(t=e.vmui)||void 0===t||null===(n=t.params)||void 0===n?void 0:n.query)||"Query"):null}));c(n.filter(Boolean))}),[t,M]),(0,r.useEffect)((function(){var e=[],n=[],r=[];t.forEach((function(t,a){var i,o,l=t.data.result.map((function(e){var n,r,i;return ft(ft({},e),{},{group:Number(null!==(n=null===(r=t.vmui)||void 0===r||null===(i=r.params)||void 0===i?void 0:i.id)&&void 0!==n?n:a)+1})}));"matrix"===t.data.resultType?(n.push.apply(n,y(l)),e.push((null===(i=t.vmui)||void 0===i||null===(o=i.params)||void 0===o?void 0:o.query)||"Query")):r.push.apply(r,y(l))})),D(e),d(n),p(r)}),[t]),(0,r.useEffect)((function(){b(!!f&&Os(f))}),[f]),Kt("div",{className:Jr()({"vm-query-analyzer-view":!0,"vm-query-analyzer-view_mobile":a}),children:[!!u.length&&Kt(Dd,{traces:u,onDeleteClick:function(e){c((function(t){return t.filter((function(t){return t.idValue!==e.idValue}))}))}}),Kt("div",{className:Jr()({"vm-block":!0,"vm-block_mobile":a}),children:[Kt("div",{className:"vm-custom-panel-body-header",children:[Kt("div",{className:"vm-custom-panel-body-header__tabs",children:Kt(oa,{activeItem:M,items:A,onChange:function(e){T(e)}})}),Kt("div",{className:"vm-custom-panel-body-header__graph-controls",children:["chart"===M&&Kt(Ka,{}),"chart"===M&&Kt(Wd,{yaxis:F,setYaxisLimits:L,toggleEnableLimits:function(){O({type:"TOGGLE_ENABLE_YAXIS_LIMITS"})}}),"table"===M&&Kt(nh,{columns:S,defaultColumns:C,onChangeColumns:E,tableCompact:i,toggleTableCompact:function(){o({type:"TOGGLE_TABLE_COMPACT"})}})]})]}),f&&n&&"chart"===M&&Kt(Ud,{data:f,period:n,customStep:n.step||"1s",query:k,yaxis:F,setYaxisLimits:L,setPeriod:function(){return null},height:a?.5*window.innerHeight:500,isHistogram:_}),m&&"code"===M&&Kt(Zd,{data:m}),m&&"table"===M&&Kt(Xd,{data:m,displayColumns:C})]})]})},Tm=function(e){var t,n,a=e.data,o=e.period,l=(0,r.useMemo)((function(){return a.filter((function(e){return e.stats&&"matrix"===e.data.resultType}))}),[a]),u=(0,r.useMemo)((function(){var e,t;return null===(e=a.find((function(e){var t;return null===e||void 0===e||null===(t=e.vmui)||void 0===t?void 0:t.comment})))||void 0===e||null===(t=e.vmui)||void 0===t?void 0:t.comment}),[a]),c=(0,r.useMemo)((function(){if(!o)return"";var e=i()(1e3*o.start).tz().format(rn),t=i()(1e3*o.end).tz().format(rn);return"".concat(e," - ").concat(t)}),[o]),s=Ia(!1),f=s.value,d=s.setTrue,h=s.setFalse;return Kt(Zt.HY,{children:[Kt("div",{className:"vm-query-analyzer-info-header",children:[Kt(Pa,{startIcon:Kt(sr,{}),variant:"outlined",color:"warning",onClick:d,children:"Show report info"}),o&&Kt(Zt.HY,{children:[Kt("div",{className:"vm-query-analyzer-info-header__period",children:[Kt(Pr,{})," step: ",o.step]}),Kt("div",{className:"vm-query-analyzer-info-header__period",children:[Kt(gr,{})," ",c]})]})]}),f&&Kt(Ya,{title:"Report info",onClose:h,children:Kt("div",{className:"vm-query-analyzer-info",children:[u&&Kt("div",{className:"vm-query-analyzer-info-item vm-query-analyzer-info-item_comment",children:[Kt("div",{className:"vm-query-analyzer-info-item__title",children:"Comment:"}),Kt("div",{className:"vm-query-analyzer-info-item__text",children:u})]}),l.map((function(e,t){var n;return Kt("div",{className:"vm-query-analyzer-info-item",children:[Kt("div",{className:"vm-query-analyzer-info-item__title",children:l.length>1?"Query ".concat(t+1,":"):"Stats:"}),Kt("div",{className:"vm-query-analyzer-info-item__text",children:[Object.entries(e.stats||{}).map((function(e){var t=v(e,2),n=t[0],r=t[1];return Kt("div",{children:[n,": ",null!==r&&void 0!==r?r:"-"]},n)})),"isPartial: ",String(null!==(n=e.isPartial)&&void 0!==n?n:"-")]})]},t)})),Kt("div",{className:"vm-query-analyzer-info-type",children:null!==(t=l[0])&&void 0!==t&&null!==(n=t.vmui)&&void 0!==n&&n.params?"The report was created using vmui":"The report was created manually"})]})})]})},Fm=function(){var e=v((0,r.useState)([]),2),t=e[0],n=e[1],a=v((0,r.useState)(""),2),i=a[0],o=a[1],l=(0,r.useMemo)((function(){return!!t.length}),[t]),u=Ia(!1),c=u.value,s=u.setTrue,f=u.setFalse,d=(0,r.useMemo)((function(){var e,n;if(t){var r=null===(e=t[0])||void 0===e||null===(n=e.vmui)||void 0===n?void 0:n.params,a={start:+((null===r||void 0===r?void 0:r.start)||0),end:+((null===r||void 0===r?void 0:r.end)||0),step:null===r||void 0===r?void 0:r.step,date:""};if(!r){var i=t.filter((function(e){return"matrix"===e.data.resultType})).map((function(e){return e.data.result})).flat().map((function(e){var t;return e.values?null===(t=e.values)||void 0===t?void 0:t.map((function(e){return e[0]})):[0]})).flat(),o=Array.from(new Set(i.filter(Boolean))).sort((function(e,t){return e-t}));a.start=o[0],a.end=o[o.length-1],a.step=gn(function(e){var t=e.slice(1).map((function(t,n){return t-e[n]})),n={};t.forEach((function(e){var t=e.toString();n[t]=(n[t]||0)+1}));var r=0,a=0;for(var i in n)n[i]>a&&(a=n[i],r=Number(i));return r}(o))}return a.date=Dn(En(a.end)),a}}),[t]),h=function(e){try{var t=JSON.parse(e),r=Array.isArray(t)?t:[t];!function(e){return e.every((function(e){if("object"===typeof e&&null!==e){var t=e.data;if("object"===typeof t&&null!==t){var n=t.result,r=t.resultType;return Array.isArray(n)&&"string"===typeof r}}return!1}))}(r)?o("Invalid structure - JSON does not match the expected format"):n(r)}catch(a){a instanceof Error&&o("".concat(a.name,": ").concat(a.message))}},m=function(e){e.map((function(e){var t=new FileReader;t.onload=function(e){var t,n=String(null===(t=e.target)||void 0===t?void 0:t.result);h(n)},t.readAsText(e)}))},p=function(e){o("");var t=Array.from(e.target.files||[]);m(t),e.target.value=""},g=Kh(),y=g.files,_=g.dragging;return(0,r.useEffect)((function(){m(y)}),[y]),Kt("div",{className:"vm-trace-page",children:[l&&Kt("div",{className:"vm-trace-page-header",children:[Kt("div",{className:"vm-trace-page-header-errors",children:Kt(Tm,{data:t,period:d})}),Kt("div",{children:Kt(Jh,{onOpenModal:s,onChange:p})})]}),i&&Kt("div",{className:"vm-trace-page-header-errors-item vm-trace-page-header-errors-item_margin-bottom",children:[Kt(Ea,{variant:"error",children:i}),Kt(Pa,{className:"vm-trace-page-header-errors-item__close",startIcon:Kt(ur,{}),variant:"text",color:"error",onClick:function(){o("")}})]}),l&&Kt(Mm,{data:t,period:d}),!l&&Kt("div",{className:"vm-trace-page-preview",children:[Kt("p",{className:"vm-trace-page-preview__text",children:["Please, upload file with JSON response content.","\n","The file must contain query information in JSON format.","\n","Graph will be displayed after file upload.","\n","Attach files by dragging & dropping, selecting or pasting them."]}),Kt(Jh,{onOpenModal:s,onChange:p})]}),c&&Kt(Ya,{title:"Paste JSON",onClose:f,children:Kt(Nm,{onClose:f,onUpload:h})}),_&&Kt("div",{className:"vm-trace-page__dropzone"})]})},Om=function(){var e=v((0,r.useState)(!1),2),t=e[0],n=e[1];return Kt(Zt.HY,{children:Kt(et,{children:Kt(Fa,{children:Kt(Zt.HY,{children:[Kt(Gh,{onLoaded:n}),t&&Kt(Ve,{children:Kt(je,{path:"/",element:Kt(co,{}),children:[Kt(je,{path:yt.home,element:Kt(uh,{})}),Kt(je,{path:yt.metrics,element:Kt(mm,{})}),Kt(je,{path:yt.cardinality,element:Kt(zh,{})}),Kt(je,{path:yt.topQueries,element:Kt(Yh,{})}),Kt(je,{path:yt.trace,element:Kt(Xh,{})}),Kt(je,{path:yt.queryAnalyzer,element:Kt(Fm,{})}),Kt(je,{path:yt.dashboards,element:Kt(fh,{})}),Kt(je,{path:yt.withTemplate,element:Kt(km,{})}),Kt(je,{path:yt.relabel,element:Kt(Em,{})}),Kt(je,{path:yt.activeQueries,element:Kt(Am,{})}),Kt(je,{path:yt.icons,element:Kt(pm,{})})]})})]})})})})},Lm=function(e){e&&n.e(522).then(n.bind(n,522)).then((function(t){var n=t.getCLS,r=t.getFID,a=t.getFCP,i=t.getLCP,o=t.getTTFB;n(e),r(e),a(e),i(e),o(e)}))},Pm=document.getElementById("root");Pm&&(0,r.render)(Kt(Om,{}),Pm),Lm()}()}();
\ No newline at end of file
diff --git a/app/vmselect/vmui/static/js/main.8dad30cf.js.LICENSE.txt b/app/vmselect/vmui/static/js/main.5c627264.js.LICENSE.txt
similarity index 100%
rename from app/vmselect/vmui/static/js/main.8dad30cf.js.LICENSE.txt
rename to app/vmselect/vmui/static/js/main.5c627264.js.LICENSE.txt