=12)){var r=d.map((function(e,t){return e-(t===m.target?n:0)}));h(r)}}}),[m,u]),_=(0,r.useCallback)((function(){g(ft(ft({},m),{},{enable:!1}))}),[m]),b=function(e){return function(t){!function(e,t){g({start:e.clientX,target:t,enable:!0})}(t,e)}};return Cr("mousemove",y),Cr("mouseup",_),zt("div",{className:"vm-predefined-dashboard",children:zt(ta,{defaultExpanded:c,onChange:function(e){return s(e)},title:zt((function(){return zt("div",{className:_r()({"vm-predefined-dashboard-header":!0,"vm-predefined-dashboard-header_open":c}),children:[(n||a)&&zt("span",{className:"vm-predefined-dashboard-header__title",children:n||"".concat(t+1,". ").concat(a)}),i&&zt("span",{className:"vm-predefined-dashboard-header__count",children:["(",i.length," panels)"]})]})}),{}),children:zt("div",{className:"vm-predefined-dashboard-panels",children:Array.isArray(i)&&i.length?i.map((function(e,t){return zt("div",{className:"vm-predefined-dashboard-panels-panel vm-block vm-block_empty-padding",style:{gridColumn:"span ".concat(d[t])},children:[zt(_f,{title:e.title,description:e.description,unit:e.unit,expr:e.expr,alias:e.alias,filename:a,showLegend:e.showLegend}),zt("button",{className:"vm-predefined-dashboard-panels-panel__resizer",onMouseDown:b(t)})]},t)})):zt("div",{className:"vm-predefined-dashboard-panels-panel__alert",children:zt(Zr,{variant:"error",children:[zt("code",{children:'"panels"'})," not found. Check the configuration file ",zt("b",{children:a}),"."]})})})})})},Df=function(){!function(){var e=Sn(),t=e.duration,n=e.relativeTime,i=e.period.date,a=$r().customStep,o=v(ut(),2)[1],u=function(){var e,r=Es((ct(e={},"g0.range_input",t),ct(e,"g0.end_input",i),ct(e,"g0.step_input",a),ct(e,"g0.relative_time",n),e));o(r)};(0,r.useEffect)(u,[t,n,i,a]),(0,r.useEffect)(u,[])}();var e=Gr().isMobile,t=ri(),n=t.dashboardsSettings,i=t.dashboardsLoading,a=t.dashboardsError,o=v((0,r.useState)(0),2),u=o[0],l=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[u]||{}}),[n,u]),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]),p=function(e){return function(){!function(e){l(e)}(e)}};return zt("div",{className:"vm-predefined-panels",children:[i&&zt(gs,{}),!n.length&&a&&zt(Zr,{variant:"error",children:a}),!n.length&&zt(Zr,{variant:"info",children:"Dashboards not found"}),c.length>1&&zt("div",{className:_r()({"vm-predefined-panels-tabs":!0,"vm-predefined-panels-tabs_mobile":e}),children:c.map((function(e){return zt("div",{className:_r()({"vm-predefined-panels-tabs__tab":!0,"vm-predefined-panels-tabs__tab_active":e.value==u}),onClick:p(e.value),children:e.label},e.value)}))}),zt("div",{className:"vm-predefined-panels__dashboards",children:[h&&f.map((function(e,t){return zt(bf,{index:t,filename:d,title:e.title,panels:e.panels},"".concat(u,"_").concat(t))})),!!n.length&&!h&&zt(Zr,{variant:"error",children:[zt("code",{children:'"rows"'})," not found. Check the configuration file ",zt("b",{children:d}),"."]})]})]})},wf=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)},kf=function(){function e(){b(this,e),this.tsdbStatus=void 0,this.tabsNames=void 0,this.tsdbStatus=this.defaultTSDBStatus,this.tabsNames=["table","graph"],this.getDefaultState=this.getDefaultState.bind(this)}return x(e,[{key:"tsdbStatusData",get:function(){return this.tsdbStatus},set:function(e){this.tsdbStatus=e}},{key:"defaultTSDBStatus",get:function(){return{totalSeries:0,totalSeriesPrev:0,totalSeriesByAll:0,totalLabelValuePairs:0,seriesCountByMetricName:[],seriesCountByLabelName:[],seriesCountByFocusLabelValue:[],seriesCountByLabelValuePair:[],labelValueCountByLabelName:[]}}},{key:"keys",value:function(e,t){var n=e&&/__name__=".+"/.test(e),r=e&&/{.+=".+"}/g.test(e),i=e&&/__name__=".+", .+!=""/g.test(e),a=[];return a=t||i?a.concat("seriesCountByFocusLabelValue"):n?a.concat("labelValueCountByLabelName"):r?a.concat("seriesCountByMetricName","seriesCountByLabelName"):a.concat("seriesCountByMetricName","seriesCountByLabelName","seriesCountByLabelValuePair","labelValueCountByLabelName"),a}},{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:xf,seriesCountByLabelName:Cf,seriesCountByFocusLabelValue:Ef,seriesCountByLabelValuePair:Sf,labelValueCountByLabelName:Af}}},{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}(),xf=[{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:""}],Cf=[{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:""}],Ef=[{id:"name",label:"Label value"},{id:"value",label:"Number of series"},{id:"percentage",label:"Share in total"},{disablePadding:!1,id:"action",label:"",numeric:!1}],Sf=[{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:""}],Af=[{id:"name",label:"Label name"},{id:"value",label:"Number of unique values"},{id:"action",label:""}],Nf={seriesCountByMetricName:function(e){var t=e.query;return Mf("__name__",t)},seriesCountByLabelName:function(e){var t=e.query;return"{".concat(t,'!=""}')},seriesCountByFocusLabelValue:function(e){var t=e.query,n=e.focusLabel;return Mf(n,t)},seriesCountByLabelValuePair:function(e){var t=e.query.split("="),n=t[0],r=t.slice(1).join("=");return Mf(n,r)},labelValueCountByLabelName:function(e){var t=e.query,n=e.match;return""===n?"{".concat(t,'!=""}'):"".concat(n.replace("}",""),", ").concat(t,'!=""}')}},Mf=function(e,t){return e?"{"+e+"="+JSON.stringify(t)+"}":""},Ff=function(e){var t,n=e.totalSeries,r=e.totalSeriesPrev,i=e.totalSeriesAll,a=e.seriesCountByMetricName,o=Gr().isMobile,u=v(ut(),1)[0],l=u.get("match"),c=u.get("focusLabel"),s=/__name__/.test(l||""),f=(null===(t=a[0])||void 0===t?void 0:t.value)/i*100,d=n-r,h=Math.abs(d)/r*100,p=[{title:"Total series",value:n.toLocaleString("en-US"),dynamic:n&&r?"".concat(h.toFixed(2),"%"):"",display:!c,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(f)?"-":"".concat(f.toFixed(2),"%"),display:s,info:"The share of these series in the total number of time series."}].filter((function(e){return e.display}));return p.length?zt("div",{className:_r()({"vm-cardinality-totals":!0,"vm-cardinality-totals_mobile":o}),children:p.map((function(e){var t=e.title,n=e.value,i=e.info,a=e.dynamic;return zt("div",{className:"vm-cardinality-totals-card",children:[zt("h4",{className:"vm-cardinality-totals-card__title",children:[t,i&&zt(hi,{title:zt("p",{className:"vm-cardinality-totals-card__tooltip",children:i}),children:zt("div",{className:"vm-cardinality-totals-card__info-icon",children:zt(jn,{})})})]}),zt("span",{className:"vm-cardinality-totals-card__value",children:n}),!!a&&zt(hi,{title:"in relation to the previous day: ".concat(r.toLocaleString("en-US")),children:zt("span",{className:_r()({"vm-dynamic-number":!0,"vm-dynamic-number_positive vm-dynamic-number_down":d<0,"vm-dynamic-number_negative vm-dynamic-number_up":d>0}),children:a})})]},t)}))}):null},Tf=function(e){var t=Gr().isMobile,n=v(ut(),2),i=n[0],a=n[1],o=i.get("tips")||"",u=v((0,r.useState)(i.get("match")||""),2),l=u[0],c=u[1],s=v((0,r.useState)(i.get("focusLabel")||""),2),f=s[0],d=s[1],h=v((0,r.useState)(+(i.get("topN")||10)),2),p=h[0],m=h[1],g=(0,r.useMemo)((function(){return p<0?"Number must be bigger than zero":""}),[p]),y=function(){i.set("match",l),i.set("topN",p.toString()),i.set("focusLabel",f),a(i)};return(0,r.useEffect)((function(){var e=i.get("match"),t=+(i.get("topN")||10),n=i.get("focusLabel");e!==l&&c(e||""),t!==p&&m(t),n!==f&&d(n||"")}),[i]),zt("div",{className:_r()({"vm-cardinality-configurator":!0,"vm-cardinality-configurator_mobile":t,"vm-block":!0,"vm-block_mobile":t}),children:[zt("div",{className:"vm-cardinality-configurator-controls",children:[zt("div",{className:"vm-cardinality-configurator-controls__query",children:zt(Si,{label:"Time series selector",type:"string",value:l,onChange:c,onEnter:y})}),zt("div",{className:"vm-cardinality-configurator-controls__item",children:zt(Si,{label:"Focus label",type:"text",value:f||"",onChange:d,onEnter:y,endIcon:zt(hi,{title:zt("div",{children:zt("p",{children:"To identify values with the highest number of series for the selected label."})}),children:zt(hr,{})})})}),zt("div",{className:"vm-cardinality-configurator-controls__item vm-cardinality-configurator-controls__item_limit",children:zt(Si,{label:"Limit entries",type:"number",value:p,error:g,onChange:function(e){var t=+e;m(isNaN(t)?0:t)},onEnter:y})})]}),zt("div",{className:"vm-cardinality-configurator-bottom",children:[zt(Ff,ft({},e)),zt("div",{className:"vm-cardinality-configurator-bottom-helpful",children:zt("a",{className:"vm-link vm-link_with-icon",target:"_blank",href:"https://docs.victoriametrics.com/#cardinality-explorer",rel:"help noreferrer",children:[zt(fr,{}),"Documentation"]})}),zt("div",{className:"vm-cardinality-configurator-bottom__execute",children:[zt(hi,{title:o?"Hide tips":"Show tips",children:zt(ui,{variant:"text",color:o?"warning":"gray",startIcon:zt(gr,{}),onClick:function(){i.get("tips")||""?i.delete("tips"):i.set("tips","true"),a(i)}})}),zt(ui,{variant:"text",startIcon:zt(zn,{}),onClick:function(){i.set("match",""),i.set("focusLabel",""),a(i)},children:"Reset"}),zt(ui,{startIcon:zt(Zn,{}),onClick:y,children:"Execute Query"})]})]})]})};function Of(e){var t=e.order,n=e.orderBy,r=e.onRequestSort,i=e.headerCells;return zt("thead",{className:"vm-table-header vm-cardinality-panel-table__header",children:zt("tr",{className:"vm-table__row vm-table__row_header",children:i.map((function(e){return zt("th",{className:_r()({"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:(i=e.id,function(e){r(e,i)}),children:zt("div",{className:"vm-table-cell__content",children:[e.info?zt(hi,{title:e.info,children:[zt("div",{className:"vm-metrics-content-header__tip-icon",children:zt(jn,{})}),e.label]}):zt(Rt.HY,{children:e.label}),"action"!==e.id&&"percentage"!==e.id&&zt("div",{className:_r()({"vm-table__sort-icon":!0,"vm-table__sort-icon_active":n===e.id,"vm-table__sort-icon_desc":"desc"===t&&n===e.id}),children:zt(qn,{})})]})},e.id);var i}))})})}function If(e,t,n){return t[n]e[n]?1:0}function Bf(e,t){return"desc"===e?function(e,n){return If(e,n,t)}:function(e,n){return-If(e,n,t)}}function Pf(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 Rf=function(e){var t=e.rows,n=e.headerCells,i=e.defaultSortColumn,a=e.tableCells,o=v((0,r.useState)("desc"),2),u=o[0],l=o[1],c=v((0,r.useState)(i),2),s=c[0],f=c[1],d=Pf(t,Bf(u,s));return zt("table",{className:"vm-table vm-cardinality-panel-table",children:[zt(Of,{order:u,orderBy:s,onRequestSort:function(e,t){l(s===t&&"asc"===u?"desc":"asc"),f(t)},rowCount:t.length,headerCells:n}),zt("tbody",{className:"vm-table-header",children:d.map((function(e){return zt("tr",{className:"vm-table__row",children:a(e)},e.name)}))})]})},Lf=function(e){var t=e.row,n=e.totalSeries,r=e.totalSeriesPrev,i=e.onActionClick,a=n>0?t.value/n*100:-1,o=r>0?t.valuePrev/r*100:-1,u=[a,o].some((function(e){return-1===e})),l=a-o,c=u?"":"".concat(l.toFixed(2),"%"),s=function(){i(t.name)};return zt(Rt.HY,{children:[zt("td",{className:"vm-table-cell",children:zt("span",{className:"vm-link vm-link_colored",onClick:s,children:t.name})},t.name),zt("td",{className:"vm-table-cell",children:[t.value,!!t.diff&&zt(hi,{title:"in relation to the previous day: ".concat(t.valuePrev),children:zt("span",{className:_r()({"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),a>0&&zt("td",{className:"vm-table-cell",children:zt("div",{className:"vm-cardinality-panel-table__progress",children:[zt(ys,{value:a}),c&&zt(hi,{title:"in relation to the previous day",children:zt("span",{className:_r()({"vm-dynamic-number":!0,"vm-dynamic-number_positive vm-dynamic-number_down":l<0,"vm-dynamic-number_negative vm-dynamic-number_up":l>0}),children:c})})]})},t.progressValue),zt("td",{className:"vm-table-cell vm-table-cell_right",children:zt("div",{className:"vm-table-cell__content",children:zt(hi,{title:"Filter by ".concat(t.name),children:zt(ui,{variant:"text",size:"small",onClick:s,children:zt(Kn,{})})})})},"action")]})},zf=function(e){var t=e.data,n=v((0,r.useState)([]),2),i=n[0],a=n[1],o=v((0,r.useState)([0,0]),2),u=o[0],l=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);l(n),a(e.map((function(e){return ft(ft({},e),{},{percentage:e.value/n[0]*100})})))}),[t]),zt("div",{className:"vm-simple-bar-chart",children:[zt("div",{className:"vm-simple-bar-chart-y-axis",children:u.map((function(e){return zt("div",{className:"vm-simple-bar-chart-y-axis__tick",children:e},e)}))}),zt("div",{className:"vm-simple-bar-chart-data",children:i.map((function(e){var t=e.name,n=e.value,r=e.percentage;return zt(hi,{title:"".concat(t,": ").concat(n),placement:"top-center",children:zt("div",{className:"vm-simple-bar-chart-data-item",style:{maxHeight:"".concat(r||0,"%")}})},"".concat(t,"_").concat(n))}))})]})},jf=function(e){var t=e.rows,n=e.tabs,i=void 0===n?[]:n,a=e.chartContainer,o=e.totalSeries,u=e.totalSeriesPrev,l=e.onActionClick,c=e.sectionTitle,s=e.tip,f=e.tableHeaderCells,d=Gr().isMobile,h=v((0,r.useState)("table"),2),p=h[0],m=h[1],g=(0,r.useMemo)((function(){return i.map((function(e,t){return{value:e,label:e,icon:zt(0===t?er:Xn,{})}}))}),[i]);return zt("div",{className:_r()({"vm-metrics-content":!0,"vm-metrics-content_mobile":d,"vm-block":!0,"vm-block_mobile":d}),children:[zt("div",{className:"vm-metrics-content-header vm-section-header",children:[zt("h5",{className:_r()({"vm-metrics-content-header__title":!0,"vm-section-header__title":!0,"vm-section-header__title_mobile":d}),children:[!d&&s&&zt(hi,{title:zt("p",{dangerouslySetInnerHTML:{__html:s},className:"vm-metrics-content-header__tip"}),children:zt("div",{className:"vm-metrics-content-header__tip-icon",children:zt(jn,{})})}),c]}),zt("div",{className:"vm-section-header__tabs",children:zt(Sr,{activeItem:p,items:g,onChange:m})})]}),"table"===p&&zt("div",{ref:a,className:_r()({"vm-metrics-content__table":!0,"vm-metrics-content__table_mobile":d}),children:zt(Rf,{rows:t,headerCells:f,defaultSortColumn:"value",tableCells:function(e){return zt(Lf,{row:e,totalSeries:o,totalSeriesPrev:u,onActionClick:l})}})}),"graph"===p&&zt("div",{className:"vm-metrics-content__chart",children:zt(zf,{data:t.map((function(e){return{name:e.name,value:e.value}}))})})]})},$f=function(e){var t=e.title,n=e.children;return zt("div",{className:"vm-cardinality-tip",children:[zt("div",{className:"vm-cardinality-tip-header",children:[zt("div",{className:"vm-cardinality-tip-header__tip-icon",children:zt(gr,{})}),zt("h4",{className:"vm-cardinality-tip-header__title",children:t||"Tips"})]}),zt("p",{className:"vm-cardinality-tip__description",children:n})]})},Hf=function(){return zt($f,{title:"Metrics with a high number of series",children:zt("ul",{children:[zt("li",{children:["Identify and eliminate labels with frequently changed values to reduce their\xa0",zt(Ns,{href:"https://docs.victoriametrics.com/FAQ.html#what-is-high-cardinality",children:"cardinality"}),"\xa0and\xa0",zt(Ns,{href:"https://docs.victoriametrics.com/FAQ.html#what-is-high-churn-rate",children:"high churn rate"})]}),zt("li",{children:["Find unused time series and\xa0",zt(Ns,{href:"https://docs.victoriametrics.com/relabeling.html",children:"drop entire metrics"})]}),zt("li",{children:["Aggregate time series before they got ingested into the database via\xa0",zt(Ns,{href:"https://docs.victoriametrics.com/stream-aggregation.html",children:"streaming aggregation"})]})]})})},Yf=function(){return zt($f,{title:"Labels with a high number of unique values",children:zt("ul",{children:[zt("li",{children:"Decrease the number of unique label values to reduce cardinality"}),zt("li",{children:["Drop the label entirely via\xa0",zt(Ns,{href:"https://docs.victoriametrics.com/relabeling.html",children:"relabeling"})]}),zt("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"})]})})},Uf=function(){return zt($f,{title:"Dashboard of a single metric",children:[zt("p",{children:"This dashboard helps to understand the cardinality of a single metric."}),zt("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."}),zt("p",{children:"Use the series selector at the top of the page to apply additional filters."})]})},Vf=function(){return zt($f,{title:"Dashboard of a label",children:[zt("p",{children:"This dashboard helps you understand the count of time series per label."}),zt("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."}),zt("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."})]})},qf=function(){var e=Gr().isMobile,t=v(ut(),2),n=t[0],i=t[1],o=n.get("tips")||"",u=n.get("match")||"",l=n.get("focusLabel")||"",c=function(){var e=new kf,t=v(ut(),1)[0],n=t.get("match"),i=t.get("focusLabel"),o=+(t.get("topN")||10),u=t.get("date")||a()().tz().format(Ut),l=$t().serverUrl,c=v((0,r.useState)(!1),2),s=c[0],f=c[1],d=v((0,r.useState)(),2),h=d[0],p=d[1],m=v((0,r.useState)(e.defaultTSDBStatus),2),g=m[0],y=m[1],_=function(){var t=sa(la().mark((function t(r){var i,o,u,c,s,d,h,m,g,_,b,D,w,k,x,C;return la().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(l){t.next=2;break}return t.abrupt("return");case 2:return p(""),f(!0),y(e.defaultTSDBStatus),i={date:r.date,topN:0,match:"",focusLabel:""},o=ft(ft({},r),{},{date:a()(r.date).subtract(1,"day").tz().format(Ut)}),u=wf(l,r),c=wf(l,o),s=wf(l,i),d=[u,c,s],t.prev=11,t.next=14,Promise.all(d.map((function(e){return fetch(e)})));case 14:return h=t.sent,t.next=17,Promise.all(h.map((function(e){return e.json()})));case 17:m=t.sent,g=v(m,3),_=g[0],b=g[1],D=g[2],h[0].ok?(w=D.data,k=ft({},b.data),(x=ft({},_.data)).totalSeriesByAll=null===w||void 0===w?void 0:w.totalSeries,x.totalSeriesPrev=null===k||void 0===k?void 0:k.totalSeries,C=null===n||void 0===n?void 0:n.replace(/[{}"]/g,""),x.seriesCountByLabelValuePair=x.seriesCountByLabelValuePair.filter((function(e){return e.name!==C})),Object.keys(x).forEach((function(e){var t=e,n=x[t],r=k[t];Array.isArray(n)&&Array.isArray(r)&&n.forEach((function(e){var t,n=null===(t=r.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}))})),y(x),f(!1)):(p(_.error),y(e.defaultTSDBStatus),f(!1)),t.next=29;break;case 25:t.prev=25,t.t0=t.catch(11),f(!1),t.t0 instanceof Error&&p("".concat(t.t0.name,": ").concat(t.t0.message));case 29:case"end":return t.stop()}}),t,null,[[11,25]])})));return function(e){return t.apply(this,arguments)}}();return(0,r.useEffect)((function(){_({topN:o,match:n,date:u,focusLabel:i})}),[l,n,i,o,u]),(0,r.useEffect)((function(){h&&(y(e.defaultTSDBStatus),f(!1))}),[h]),e.tsdbStatusData=g,{isLoading:s,appConfigurator:e,error:h}}(),s=c.isLoading,f=c.appConfigurator,d=c.error,h=f.tsdbStatusData,p=f.getDefaultState,m=f.tablesHeaders,g=f.sectionsTips,y=p(u,l);return zt("div",{className:_r()({"vm-cardinality-panel":!0,"vm-cardinality-panel_mobile":e}),children:[s&&zt(gs,{message:"Please wait while cardinality stats is calculated. \n This may take some time if the db contains big number of time series."}),zt(Tf,{totalSeries:h.totalSeries,totalSeriesPrev:h.totalSeriesPrev,totalSeriesAll:h.totalSeriesByAll,totalLabelValuePairs:h.totalLabelValuePairs,seriesCountByMetricName:h.seriesCountByMetricName}),o&&zt("div",{className:"vm-cardinality-panel-tips",children:[!u&&!l&&zt(Hf,{}),u&&!l&&zt(Uf,{}),!u&&!l&&zt(Yf,{}),l&&zt(Vf,{})]}),d&&zt(Zr,{variant:"error",children:d}),f.keys(u,l).map((function(e){return zt(jf,{sectionTitle:f.sectionsTitles(l)[e],tip:g[e],rows:h[e],onActionClick:(t=e,function(e){var r=Nf[t]({query:e,focusLabel:l,match:u});n.set("match",r),"labelValueCountByLabelName"!==t&&"seriesCountByLabelName"!=t||n.set("focusLabel",e),"seriesCountByFocusLabelValue"==t&&n.set("focusLabel",""),i(n)}),tabs:y.tabs[e],chartContainer:y.containerRefs[e],totalSeriesPrev:f.totalSeries(e,!0),totalSeries:f.totalSeries(e),tableHeaderCells:m[e]},e);var t}))]})},Wf=function(e){var t=e.rows,n=e.columns,i=e.defaultOrderBy,a=Xr().showInfoMessage,o=v((0,r.useState)(i||"count"),2),u=o[0],l=o[1],c=v((0,r.useState)("desc"),2),s=c[0],f=c[1],d=(0,r.useMemo)((function(){return Pf(t,Bf(s,u))}),[t,u,s]),h=function(e){return function(){var t;t=e,f((function(e){return"asc"===e&&u===t?"desc":"asc"})),l(t)}},p=function(e){var t=e.query;return function(){navigator.clipboard.writeText(t),a({text:"Query has been copied",type:"success"})}};return zt("table",{className:"vm-table",children:[zt("thead",{className:"vm-table-header",children:zt("tr",{className:"vm-table__row vm-table__row_header",children:[n.map((function(e){return zt("th",{className:"vm-table-cell vm-table-cell_header vm-table-cell_sort",onClick:h(e.sortBy||e.key),children:zt("div",{className:"vm-table-cell__content",children:[e.title||e.key,zt("div",{className:_r()({"vm-table__sort-icon":!0,"vm-table__sort-icon_active":u===e.key,"vm-table__sort-icon_desc":"desc"===s&&u===e.key}),children:zt(qn,{})})]})},e.key)})),zt("th",{className:"vm-table-cell vm-table-cell_header"})," "]})}),zt("tbody",{className:"vm-table-body",children:d.map((function(e,t){return zt("tr",{className:"vm-table__row",children:[n.map((function(t){return zt("td",{className:"vm-table-cell",children:e[t.key]||"-"},t.key)})),zt("td",{className:"vm-table-cell vm-table-cell_no-padding",children:zt("div",{className:"vm-top-queries-panels__table-actions",children:[zt(hi,{title:"Execute query",children:zt(rt,{to:"".concat(mt.home,"?g0.expr=").concat(encodeURIComponent(e.query)),target:"_blank",rel:"noreferrer",children:zt(ui,{variant:"text",size:"small",startIcon:zt(Kn,{})})})}),zt(hi,{title:"Copy query",children:zt(ui,{variant:"text",size:"small",startIcon:zt(lr,{}),onClick:p(e)})})]})})]},t)}))})]})},Qf=["table","JSON"].map((function(e,t){return{value:String(t),label:e,icon:zt(0===t?er:tr,{})}})),Gf=function(e){var t=e.rows,n=e.title,i=e.columns,a=e.defaultOrderBy,o=Gr().isMobile,u=v((0,r.useState)(0),2),l=u[0],c=u[1];return zt("div",{className:_r()({"vm-top-queries-panel":!0,"vm-block":!0,"vm-block_mobile":o}),children:[zt("div",{className:_r()({"vm-top-queries-panel-header":!0,"vm-section-header":!0,"vm-top-queries-panel-header_mobile":o}),children:[zt("h5",{className:_r()({"vm-section-header__title":!0,"vm-section-header__title_mobile":o}),children:n}),zt("div",{className:"vm-section-header__tabs",children:zt(Sr,{activeItem:String(l),items:Qf,onChange:function(e){c(+e)}})})]}),zt("div",{className:_r()({"vm-top-queries-panel__table":!0,"vm-top-queries-panel__table_mobile":o}),children:[0===l&&zt(Wf,{rows:t,columns:i,defaultOrderBy:a}),1===l&&zt(hs,{data:t})]})]})},Jf=function(){var e=Gr().isMobile,t=function(){var e=$t().serverUrl,t=qr(),n=t.topN,i=t.maxLifetime,a=t.runQuery,o=v((0,r.useState)(null),2),u=o[0],l=o[1],c=v((0,r.useState)(!1),2),s=c[0],f=c[1],d=v((0,r.useState)(),2),h=d[0],p=d[1],m=(0,r.useMemo)((function(){return function(e,t,n){return"".concat(e,"/api/v1/status/top_queries?topN=").concat(t||"","&maxLifetime=").concat(n||"")}(e,n,i)}),[e,n,i]),g=function(){var e=sa(la().mark((function e(){var t,n;return la().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return f(!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,t.ok&&["topByAvgDuration","topByCount","topBySumDuration"].forEach((function(e){var t=n[e];Array.isArray(t)&&t.forEach((function(e){return e.timeRange=sn(1e3*e.timeRangeSeconds)}))})),l(t.ok?n:null),p(String(n.error||"")),e.next=16;break;case 13:e.prev=13,e.t0=e.catch(1),e.t0 instanceof Error&&"AbortError"!==e.t0.name&&p("".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()}),[a]),{data:u,error:h,loading:s}}(),n=t.data,i=t.error,o=t.loading,u=qr(),l=u.topN,c=u.maxLifetime,s=(0,r.useContext)(Vr).dispatch;!function(){var e=qr(),t=e.topN,n=e.maxLifetime,i=v(ut(),2)[1],a=function(){var e=Es({topN:String(t),maxLifetime:n});i(e)};(0,r.useEffect)(a,[t,n]),(0,r.useEffect)(a,[])}();var f=(0,r.useMemo)((function(){var e=c.trim().split(" ").reduce((function(e,t){var n=rn(t);return n?ft(ft({},e),n):ft({},e)}),{});return!!a().duration(e).asMilliseconds()}),[c]),d=(0,r.useMemo)((function(){return!!l&&l<1}),[l]),h=(0,r.useMemo)((function(){return d?"Number must be bigger than zero":""}),[d]),p=(0,r.useMemo)((function(){return f?"":"Invalid duration value"}),[f]),m=function(e){if(!n)return e;var t=n[e];return"number"===typeof t?gc(t,t,t):t||e},g=function(){s({type:"SET_RUN_QUERY"})},y=function(e){"Enter"===e.key&&g()};return(0,r.useEffect)((function(){n&&(l||s({type:"SET_TOP_N",payload:+n.topN}),c||s({type:"SET_MAX_LIFE_TIME",payload:n.maxLifetime}))}),[n]),zt("div",{className:_r()({"vm-top-queries":!0,"vm-top-queries_mobile":e}),children:[o&&zt(gs,{containerStyles:{height:"500px"}}),zt("div",{className:_r()({"vm-top-queries-controls":!0,"vm-block":!0,"vm-block_mobile":e}),children:[zt("div",{className:"vm-top-queries-controls-fields",children:[zt("div",{className:"vm-top-queries-controls-fields__item",children:zt(Si,{label:"Max lifetime",value:c,error:p,helperText:"For example ".concat("30ms, 15s, 3d4h, 1y2w"),onChange:function(e){s({type:"SET_MAX_LIFE_TIME",payload:e})},onKeyDown:y})}),zt("div",{className:"vm-top-queries-controls-fields__item",children:zt(Si,{label:"Number of returned queries",type:"number",value:l||"",error:h,onChange:function(e){s({type:"SET_TOP_N",payload:+e})},onKeyDown:y})})]}),zt("div",{className:_r()({"vm-top-queries-controls-bottom":!0,"vm-top-queries-controls-bottom_mobile":e}),children:[zt("div",{className:"vm-top-queries-controls-bottom__info",children:["VictoriaMetrics tracks the last\xa0",zt(hi,{title:"search.queryStats.lastQueriesCount",children:zt("b",{children:m("search.queryStats.lastQueriesCount")})}),"\xa0queries with durations at least\xa0",zt(hi,{title:"search.queryStats.minQueryDuration",children:zt("b",{children:m("search.queryStats.minQueryDuration")})})]}),zt("div",{className:"vm-top-queries-controls-bottom__button",children:zt(ui,{startIcon:zt(Zn,{}),onClick:g,children:"Execute"})})]})]}),i&&zt(Zr,{variant:"error",children:i}),n&&zt(Rt.HY,{children:zt("div",{className:"vm-top-queries-panels",children:[zt(Gf,{rows:n.topByCount,title:"Most frequently executed queries",columns:[{key:"query"},{key:"timeRange",sortBy:"timeRangeSeconds",title:"Query Time Interval"},{key:"count"}]}),zt(Gf,{rows:n.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"}),zt(Gf,{rows:n.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"})]})})]})},Zf={"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)"},Kf={"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(97,97,97, 0.92)","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)"},Xf=function(){var e=v((0,r.useState)(Ot()),2),t=e[0],n=e[1],i=function(e){n(e.matches)};return(0,r.useEffect)((function(){var e=window.matchMedia("(prefers-color-scheme: dark)");return e.addEventListener("change",i),function(){return e.removeEventListener("change",i)}}),[]),t},ed=["primary","secondary","error","warning","info","success"],td=function(e){var t,n=e.onLoaded,i=gt(),a=vt().palette,o=void 0===a?{}:a,u=$t().theme,l=Xf(),c=Ht(),s=Er(),f=v((0,r.useState)((ct(t={},Mt.dark,Zf),ct(t,Mt.light,Kf),ct(t,Mt.system,Ot()?Zf:Kf),t)),2),d=f[0],h=f[1],p=function(){var e=window,t=e.innerWidth,n=e.innerHeight,r=document.documentElement,i=r.clientWidth,a=r.clientHeight;Tt("scrollbar-width","".concat(t-i,"px")),Tt("scrollbar-height","".concat(n-a,"px")),Tt("vh","".concat(.01*n,"px"))},m=function(){ed.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"}(Ft("color-".concat(e)));Tt("".concat(e,"-text"),r),t===ed.length-1&&(c({type:"SET_DARK_THEME"}),n(!0))}))},g=function(){var e=St("THEME")||Mt.system,t=d[e];Object.entries(t).forEach((function(e){var t=v(e,2),n=t[0],r=t[1];Tt(n,r)})),m(),i&&(ed.forEach((function(e){var t=o[e];t&&Tt("color-".concat(e),t)})),m())};return(0,r.useEffect)((function(){p(),g()}),[d]),(0,r.useEffect)(p,[s]),(0,r.useEffect)((function(){var e=Ot()?Zf:Kf;d[Mt.system]!==e?h((function(t){return ft(ft({},t),{},ct({},Mt.system,e))})):g()}),[u,l]),(0,r.useEffect)((function(){i&&c({type:"SET_THEME",payload:Mt.light})}),[]),null},nd=function(){var e=v((0,r.useState)([]),2),t=e[0],n=e[1],i=v((0,r.useState)(!1),2),a=i[0],o=i[1],u=(0,r.useRef)(document.body),l=function(e){e.preventDefault(),e.stopPropagation(),"dragenter"===e.type||"dragover"===e.type?o(!0):"dragleave"===e.type&&o(!1)};return Cr("dragenter",l,u),Cr("dragleave",l,u),Cr("dragover",l,u),Cr("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)}),u),Cr("paste",(function(e){var t,r=null===(t=e.clipboardData)||void 0===t?void 0:t.items;if(r){var i=Array.from(r).filter((function(e){return"application/json"===e.type})).map((function(e){return e.getAsFile()})).filter((function(e){return null!==e}));n(i)}}),u),{files:t,dragging:a}},rd=function(e){var t=e.onOpenModal,n=e.onChange;return zt("div",{className:"vm-trace-page-controls",children:[zt(ui,{variant:"outlined",onClick:t,children:"Paste JSON"}),zt(hi,{title:"The file must contain tracing information in JSON format",children:zt(ui,{children:["Upload Files",zt("input",{id:"json",type:"file",accept:"application/json",multiple:!0,title:" ",onChange:n})]})})]})},id=function(){var e=v((0,r.useState)([]),2),t=e[0],n=e[1],i=v((0,r.useState)([]),2),a=i[0],o=i[1],u=(0,r.useMemo)((function(){return!!t.length}),[t]),l=v(ut(),2)[1],c=li(!1),s=c.value,f=c.setTrue,d=c.setFalse,h=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";o((function(n){return[{filename:t,text:": ".concat(e.message)}].concat(_(n))}))},p=function(e,t){try{var r=JSON.parse(e),i=r.trace||r;if(!i.duration_msec)return void h(new Error(Nt.traceNotFound),t);var a=new fs(i,t);n((function(e){return[a].concat(_(e))}))}catch(o){o instanceof Error&&h(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);p(r,n)},t.readAsText(e)}))},g=function(e){o([]);var t=Array.from(e.target.files||[]);m(t),e.target.value=""},y=function(e){return function(){!function(e){o((function(t){return t.filter((function(t,n){return n!==e}))}))}(e)}};(0,r.useEffect)((function(){l({})}),[]);var b=nd(),D=b.files,w=b.dragging;return(0,r.useEffect)((function(){m(D)}),[D]),zt("div",{className:"vm-trace-page",children:[zt("div",{className:"vm-trace-page-header",children:[zt("div",{className:"vm-trace-page-header-errors",children:a.map((function(e,t){return zt("div",{className:"vm-trace-page-header-errors-item",children:[zt(Zr,{variant:"error",children:[zt("b",{className:"vm-trace-page-header-errors-item__filename",children:e.filename}),zt("span",{children:e.text})]}),zt(ui,{className:"vm-trace-page-header-errors-item__close",startIcon:zt(Ln,{}),variant:"text",color:"error",onClick:y(t)})]},"".concat(e,"_").concat(t))}))}),zt("div",{children:u&&zt(rd,{onOpenModal:f,onChange:g})})]}),u&&zt("div",{children:zt(Ds,{jsonEditor:!0,traces:t,onDeleteClick:function(e){var r=t.filter((function(t){return t.idValue!==e.idValue}));n(_(r))}})}),!u&&zt("div",{className:"vm-trace-page-preview",children:[zt("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",zt("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."]}),zt(rd,{onOpenModal:f,onChange:g})]}),s&&zt(di,{title:"Paste JSON",onClose:d,children:zt(bs,{editable:!0,displayTitle:!0,defaultTile:"JSON ".concat(t.length+1),onClose:d,onUpload:p})}),w&&zt("div",{className:"vm-trace-page__dropzone"})]})},ad=function(e){var t=$t().serverUrl,n=Sn().period,i=v((0,r.useState)([]),2),a=i[0],o=i[1],u=v((0,r.useState)(!1),2),l=u[0],c=u[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=sa(la().mark((function e(){var t,n,r;return la().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:a,isLoading:l,error:f}},od=function(e,t){var n=$t().serverUrl,i=Sn().period,a=v((0,r.useState)([]),2),o=a[0],u=a[1],l=v((0,r.useState)(!1),2),c=l[0],s=l[1],f=v((0,r.useState)(),2),d=f[0],h=f[1],p=(0,r.useMemo)((function(){return function(e,t,n,r){var i=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(","),a="{".concat(i,"}");return"".concat(e,"/api/v1/label/__name__/values?match[]=").concat(encodeURIComponent(a),"&start=").concat(t.start,"&end=").concat(t.end)}(n,i,e,t)}),[n,i,e,t]);return(0,r.useEffect)((function(){if(e){var t=function(){var e=sa(la().mark((function e(){var t,n,r;return la().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s(!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,r=n.data||[],u(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)}}),[p]),{names:o,isLoading:c,error:d}},ud=function(e){var t=e.name,n=e.job,i=e.instance,a=e.rateEnabled,o=e.isBucket,u=e.height,l=Gr().isMobile,c=$r(),s=c.customStep,f=c.yaxis,d=Sn().period,h=Hr(),p=An(),m=on(d.end-d.start),g=an(s),y=sn(10*g*1e3),_=v((0,r.useState)(!1),2),b=_[0],D=_[1],w=b&&s===m?y:s,k=li(!1),x=k.value,C=k.setTrue,E=(0,r.useMemo)((function(){var e=Object.entries({job:n,instance:i}).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 u=a?"rollup_rate(".concat(r,")"):"rollup(".concat(r,")");return"\nwith (q = ".concat(u,') (\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,i,a,o]),S=ds({predefinedQuery:[E],visible:!0,customStep:w,showAllSeries:x}),A=S.isLoading,N=S.graphData,M=S.error,F=S.warning,T=S.isHistogram;return(0,r.useEffect)((function(){D(T)}),[T]),zt("div",{className:_r()({"vm-explore-metrics-graph":!0,"vm-explore-metrics-graph_mobile":l}),children:[A&&zt(gs,{}),M&&zt(Zr,{variant:"error",children:M}),F&&zt(Zr,{variant:"warning",children:zt("div",{className:"vm-explore-metrics-graph__warning",children:[zt("p",{children:F}),zt(ui,{color:"warning",variant:"outlined",onClick:C,children:"Show all"})]})}),N&&d&&zt(Kc,{data:N,period:d,customStep:w,query:[E],yaxis:f,setYaxisLimits:function(e){h({type:"SET_YAXIS_LIMITS",payload:e})},setPeriod:function(e){var t=e.from,n=e.to;p({type:"SET_PERIOD",payload:{from:t,to:n}})},showLegend:!1,height:u,isHistogram:T})]})},ld=function(e){var t=e.name,n=e.index,r=e.length,i=e.isBucket,a=e.rateEnabled,o=e.onChangeRate,u=e.onRemoveItem,l=e.onChangeOrder,c=Gr().isMobile,s=li(!1),f=s.value,d=s.setTrue,h=s.setFalse,p=function(){u(t)},m=function(){l(t,n,n+1)},v=function(){l(t,n,n-1)};return zt("div",c?{className:"vm-explore-metrics-item-header vm-explore-metrics-item-header_mobile",children:[zt("div",{className:"vm-explore-metrics-item-header__name",children:t}),zt(ui,{variant:"text",size:"small",startIcon:zt(mr,{}),onClick:d}),f&&zt(di,{title:t,onClose:h,children:zt("div",{className:"vm-explore-metrics-item-header-modal",children:[zt("div",{className:"vm-explore-metrics-item-header-modal-order",children:[zt(ui,{startIcon:zt(ir,{}),variant:"outlined",onClick:v,disabled:0===n}),zt("p",{children:["position:",zt("span",{className:"vm-explore-metrics-item-header-modal-order__index",children:["#",n+1]})]}),zt(ui,{endIcon:zt(rr,{}),variant:"outlined",onClick:m,disabled:n===r-1})]}),!i&&zt("div",{className:"vm-explore-metrics-item-header-modal__rate",children:[zt(ts,{label:zt("span",{children:["enable ",zt("code",{children:"rate()"})]}),value:a,onChange:o,fullWidth:!0}),zt("p",{children:"calculates the average per-second speed of metrics change"})]}),zt(ui,{startIcon:zt(Ln,{}),color:"error",variant:"outlined",onClick:p,fullWidth:!0,children:"Remove graph"})]})})]}:{className:"vm-explore-metrics-item-header",children:[zt("div",{className:"vm-explore-metrics-item-header-order",children:[zt(hi,{title:"move graph up",children:zt(ui,{className:"vm-explore-metrics-item-header-order__up",startIcon:zt(Vn,{}),variant:"text",color:"gray",size:"small",onClick:v})}),zt("div",{className:"vm-explore-metrics-item-header__index",children:["#",n+1]}),zt(hi,{title:"move graph down",children:zt(ui,{className:"vm-explore-metrics-item-header-order__down",startIcon:zt(Vn,{}),variant:"text",color:"gray",size:"small",onClick:m})})]}),zt("div",{className:"vm-explore-metrics-item-header__name",children:t}),!i&&zt("div",{className:"vm-explore-metrics-item-header__rate",children:zt(hi,{title:"calculates the average per-second speed of metric's change",children:zt(ts,{label:zt("span",{children:["enable ",zt("code",{children:"rate()"})]}),value:a,onChange:o})})}),zt("div",{className:"vm-explore-metrics-item-header__close",children:zt(hi,{title:"close graph",children:zt(ui,{startIcon:zt(Ln,{}),variant:"text",color:"gray",size:"small",onClick:p})})})]})},cd=function(e){var t=e.name,n=e.job,i=e.instance,a=e.index,o=e.length,u=e.size,l=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],p=d[1],m=Er(),g=(0,r.useMemo)(u.height,[u,m]);return(0,r.useEffect)((function(){p(s)}),[n]),zt("div",{className:"vm-explore-metrics-item vm-block vm-block_empty-padding",children:[zt(ld,{name:t,index:a,length:o,isBucket:f,rateEnabled:h,size:u.id,onChangeRate:p,onRemoveItem:l,onChangeOrder:c}),zt(ud,{name:t,job:n,instance:i,rateEnabled:h,isBucket:f,height:g},"".concat(t,"_").concat(n,"_").concat(i,"_").concat(h))]})},sd=function(e){var t=e.values,n=e.onRemoveItem,r=Gr().isMobile;return r?zt("span",{className:"vm-select-input-content__counter",children:["selected ",t.length]}):zt(Rt.HY,{children:t.map((function(e){return zt("div",{className:"vm-select-input-content__selected",children:[zt("span",{children:e}),zt("div",{onClick:(t=e,function(e){n(t),e.stopPropagation()}),children:zt(Ln,{})})]},e);var t}))})},fd=function(e){var t=e.value,n=e.list,i=e.label,a=e.placeholder,o=e.noOptionsText,u=e.clearable,l=void 0!==u&&u,c=e.searchable,s=void 0!==c&&c,f=e.autofocus,d=e.onChange,h=$t().isDarkTheme,p=Gr().isMobile,m=v((0,r.useState)(""),2),g=m[0],y=m[1],_=(0,r.useRef)(null),b=v((0,r.useState)(!1),2),D=b[0],w=b[1],k=(0,r.useRef)(null),x=Array.isArray(t),C=Array.isArray(t)?t:void 0,E=p&&x&&!(null===C||void 0===C||!C.length),S=(0,r.useMemo)((function(){return D?g:Array.isArray(t)?"":t}),[t,g,D,x]),A=(0,r.useMemo)((function(){return D?g||"(.+)":""}),[g,D]),N=function(){k.current&&k.current.blur()},M=function(e){d(e),x||(w(!1),N()),x&&k.current&&k.current.focus()};return(0,r.useEffect)((function(){y(""),D&&k.current&&k.current.focus(),D||N()}),[D,k]),(0,r.useEffect)((function(){f&&k.current&&!p&&k.current.focus()}),[f,k]),Cr("keyup",(function(e){k.current!==e.target&&w(!1)})),zt("div",{className:_r()({"vm-select":!0,"vm-select_dark":h}),children:[zt("div",{className:"vm-select-input",onClick:function(e){e.target instanceof HTMLInputElement||w((function(e){return!e}))},ref:_,children:[zt("div",{className:"vm-select-input-content",children:[!(null===C||void 0===C||!C.length)&&zt(sd,{values:C,onRemoveItem:M}),!E&&zt("input",{value:S,type:"text",placeholder:a,onInput:function(e){y(e.target.value)},onFocus:function(){w(!0)},ref:k,readOnly:p||!s})]}),i&&zt("span",{className:"vm-text-field__label",children:i}),l&&t&&zt("div",{className:"vm-select-input__icon",onClick:function(e){return function(t){M(e),t.stopPropagation()}}(""),children:zt(Ln,{})}),zt("div",{className:_r()({"vm-select-input__icon":!0,"vm-select-input__icon_open":D}),children:zt(qn,{})})]}),zt(Xc,{label:i,value:A,options:n,anchor:_,selected:C,maxWords:10,minLength:0,fullWidth:!0,noOptionsText:o,onSelect:M,onOpenAutocomplete:w})]})},dd=xt.map((function(e){return e.id})),hd=function(e){var t=e.jobs,n=e.instances,i=e.names,a=e.job,o=e.instance,u=e.size,l=e.selectedMetrics,c=e.onChangeJob,s=e.onChangeInstance,f=e.onToggleMetric,d=e.onChangeSize,h=(0,r.useMemo)((function(){return a?"":"No instances. Please select job"}),[a]),p=(0,r.useMemo)((function(){return a?"":"No metric names. Please select job"}),[a]),m=Gr().isMobile;return zt("div",{className:_r()({"vm-explore-metrics-header":!0,"vm-explore-metrics-header_mobile":m,"vm-block":!0,"vm-block_mobile":m}),children:[zt("div",{className:"vm-explore-metrics-header__job",children:zt(fd,{value:a,list:t,label:"Job",placeholder:"Please select job",onChange:c,autofocus:!a,searchable:!0})}),zt("div",{className:"vm-explore-metrics-header__instance",children:zt(fd,{value:o,list:n,label:"Instance",placeholder:"Please select instance",onChange:s,noOptionsText:h,clearable:!0,searchable:!0})}),zt("div",{className:"vm-explore-metrics-header__size",children:zt(fd,{label:"Size graphs",value:u,list:dd,onChange:d})}),zt("div",{className:"vm-explore-metrics-header-metrics",children:zt(fd,{label:"Metrics",value:l,list:i,placeholder:"Search metric name",onChange:f,noOptionsText:p,clearable:!0,searchable:!0})})]})},pd=Ct("job",""),md=Ct("instance",""),vd=Ct("metrics",""),gd=Ct("size",""),yd=xt.find((function(e){return gd?e.id===gd:e.isDefault}))||xt[0],_d=function(){var e=v((0,r.useState)(pd),2),t=e[0],n=e[1],i=v((0,r.useState)(md),2),a=i[0],o=i[1],u=v((0,r.useState)(vd?vd.split("&"):[]),2),l=u[0],c=u[1],s=v((0,r.useState)(yd),2),f=s[0],d=s[1];!function(e){var t=e.job,n=e.instance,i=e.metrics,a=e.size,o=Sn(),u=o.duration,l=o.relativeTime,c=o.period.date,s=$r().customStep,f=v(ut(),2)[1],d=function(){var e,r=Es((ct(e={},"g0.range_input",u),ct(e,"g0.end_input",c),ct(e,"g0.step_input",s),ct(e,"g0.relative_time",l),ct(e,"size",a),ct(e,"job",t),ct(e,"instance",n),ct(e,"metrics",i),e));f(r)};(0,r.useEffect)(d,[u,l,c,s,t,n,i,a]),(0,r.useEffect)(d,[])}({job:t,instance:a,metrics:l.join("&"),size:f.id});var h=function(){var e=$t().serverUrl,t=Sn().period,n=v((0,r.useState)([]),2),i=n[0],a=n[1],o=v((0,r.useState)(!1),2),u=o[0],l=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=sa(la().mark((function e(){var t,n,r;return la().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return l(!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||[],a(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:l(!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:i,isLoading:u,error:s}}(),p=h.jobs,m=h.isLoading,g=h.error,y=ad(t),b=y.instances,D=y.isLoading,w=y.error,k=od(t,a),x=k.names,C=k.isLoading,E=k.error,S=(0,r.useMemo)((function(){return m||D||C}),[m,D,C]),A=(0,r.useMemo)((function(){return g||w||E}),[g,w,E]),N=function(e){c(e?function(t){return t.includes(e)?t.filter((function(t){return t!==e})):[].concat(_(t),[e])}:[])},M=function(e,t,n){var r=n>l.length-1;n<0||r||c((function(e){var r=_(e),i=v(r.splice(t,1),1)[0];return r.splice(n,0,i),r}))};return(0,r.useEffect)((function(){a&&b.length&&!b.includes(a)&&o("")}),[b,a]),zt("div",{className:"vm-explore-metrics",children:[zt(hd,{jobs:p,instances:b,names:x,job:t,size:f.id,instance:a,selectedMetrics:l,onChangeJob:n,onChangeSize:function(e){var t=xt.find((function(t){return t.id===e}));t&&d(t)},onChangeInstance:o,onToggleMetric:N}),S&&zt(gs,{}),A&&zt(Zr,{variant:"error",children:A}),!t&&zt(Zr,{variant:"info",children:"Please select job to see list of metric names."}),t&&!l.length&&zt(Zr,{variant:"info",children:"Please select metric names to see the graphs."}),zt("div",{className:"vm-explore-metrics-body",children:l.map((function(e,n){return zt(cd,{name:e,job:t,instance:a,index:n,length:l.length,size:f,onRemoveItem:N,onChangeOrder:M},e)}))})]})},bd=function(){var t=Mc();return zt("div",{className:"vm-preview-icons",children:Object.entries(e).map((function(e){var n,r=v(e,2),i=r[0],a=r[1];return zt("div",{className:"vm-preview-icons-item",onClick:(n=i,sa(la().mark((function e(){return la().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:[zt("div",{className:"vm-preview-icons-item__svg",children:a()}),zt("div",{className:"vm-preview-icons-item__name",children:"<".concat(i,"/>")})]},i)}))})},Dd=function(e){return e.copy="Copy",e.copied="Copied",e}(Dd||{}),wd=function(e){var t=e.code,n=v((0,r.useState)(Dd.copy),2),i=n[0],a=n[1];return(0,r.useEffect)((function(){var e=null;return i===Dd.copied&&(e=setTimeout((function(){return a(Dd.copy)}),1e3)),function(){e&&clearTimeout(e)}}),[i]),zt("code",{className:"vm-code-example",children:[t,zt("div",{className:"vm-code-example__copy",children:zt(hi,{title:i,children:zt(ui,{size:"small",variant:"text",onClick:function(){navigator.clipboard.writeText(t),a(Dd.copied)},startIcon:zt(lr,{})})})})]})},kd=function(){return zt("a",{className:"vm-link vm-link_colored",href:"https://docs.victoriametrics.com/MetricsQL.html",target:"_blank",rel:"help noreferrer",children:"MetricsQL"})},xd=function(){return zt("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"})},Cd=function(){return zt("section",{className:"vm-with-template-tutorial",children:[zt("h2",{className:"vm-with-template-tutorial__title",children:["Tutorial for WITH expressions in ",zt(kd,{})]}),zt("div",{className:"vm-with-template-tutorial-section",children:[zt("p",{className:"vm-with-template-tutorial-section__text",children:["Let's look at the following real query from ",zt(xd,{})," dashboard:"]}),zt(wd,{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'}),zt("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? :)"})]}),zt("div",{className:"vm-with-template-tutorial-section",children:[zt("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:"}),zt(wd,{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'})]}),zt("div",{className:"vm-with-template-tutorial-section",children:[zt("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:"]}),zt(wd,{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)'}),zt("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."})]}),zt("div",{className:"vm-with-template-tutorial-section",children:[zt("p",{className:"vm-with-template-tutorial-section__text",children:["Let's take another nice query from ",zt(xd,{})," dashboard:"]}),zt(wd,{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)'}),zt("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."})]}),zt("div",{className:"vm-with-template-tutorial-section",children:[zt("p",{className:"vm-with-template-tutorial-section__text",children:"1. Extract common filters used in multiple places into a commonFilters variable:"}),zt(wd,{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)'})]}),zt("div",{className:"vm-with-template-tutorial-section",children:[zt("p",{className:"vm-with-template-tutorial-section__text",children:'2. Extract "count(count(...) by (cpu))" into cpuCount variable:'}),zt(wd,{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'})]}),zt("div",{className:"vm-with-template-tutorial-section",children:[zt("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:"}),zt(wd,{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'})]}),zt("div",{className:"vm-with-template-tutorial-section",children:[zt("p",{className:"vm-with-template-tutorial-section__text",children:["4. Put node_cpu_seconds_total","{commonFilters}"," into its own varialbe with the name cpuSeconds:"]}),zt(wd,{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'}),zt("p",{className:"vm-with-template-tutorial-section__text",children:"Now the query became more clear comparing to the initial query."})]}),zt("div",{className:"vm-with-template-tutorial-section",children:[zt("p",{className:"vm-with-template-tutorial-section__text",children:"WITH expressions may be nested and may be put anywhere. Try expanding the following query:"}),zt(wd,{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)"})]})]})},Ed=function(e,t){return"".concat(e,"/expand-with-exprs?query=").concat(t,"&format=json")},Sd=function(){var e=function(){var e=$t().serverUrl,t=v((0,r.useState)(""),2),n=t[0],i=t[1],a=v((0,r.useState)(!1),2),o=a[0],u=a[1],l=v((0,r.useState)(),2),c=l[0],s=l[1],f=function(){var t=sa(la().mark((function t(n){var r,a,o;return la().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Ed(e,n),u(!0),t.prev=2,t.next=5,fetch(r);case 5:return a=t.sent,t.next=8,a.json();case 8:o=t.sent,i((null===o||void 0===o?void 0:o.expr)||""),s(String(o.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:u(!1);case 17:case"end":return t.stop()}}),t,null,[[2,13]])})));return function(e){return t.apply(this,arguments)}}();return{data:n,error:c,loading:o,expand:f}}(),t=e.data,n=e.loading,i=e.error,a=e.expand,o=v((0,r.useState)(""),2),u=o[0],l=o[1];return zt("section",{className:"vm-with-template",children:[n&&zt(gs,{}),zt("div",{className:"vm-with-template-body vm-block",children:[zt("div",{className:"vm-with-template-body__expr",children:zt(Si,{type:"textarea",label:"MetricsQL query with optional WITH expressions",value:u,error:i,autofocus:!0,onChange:function(e){l(e)}})}),zt("div",{className:"vm-with-template-body__result",children:zt(Si,{type:"textarea",label:"MetricsQL query after expanding WITH expressions and applying other optimizations",value:t,disabled:!0})}),zt("div",{className:"vm-with-template-body-top",children:zt(ui,{variant:"contained",onClick:function(){a(u)},startIcon:zt(Zn,{}),children:"Expand"})})]}),zt("div",{className:"vm-block",children:zt(Cd,{})})]})},Ad=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("&"))},Nd='- 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"',Md='{__name__="my_metric", bar_label="bar", foo_label="foo", job="my-application", instance="192.168.0.1"}',Fd=function(){var e=v(ut(),2),t=e[0],n=e[1],i=function(){var e=$t().serverUrl,t=v((0,r.useState)(null),2),n=t[0],i=t[1],a=v((0,r.useState)(!1),2),o=a[0],u=a[1],l=v((0,r.useState)(),2),c=l[0],s=l[1],f=function(){var t=sa(la().mark((function t(n,r){var a,o,l;return la().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Ad(e,n,r),u(!0),t.prev=2,t.next=5,fetch(a);case 5:return o=t.sent,t.next=8,o.json();case 8:l=t.sent,i(l.error?null:l),s(String(l.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:u(!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}}(),a=i.data,o=i.loading,u=i.error,l=i.fetchData,c=v((0,r.useState)(""),2),s=c[0],f=c[1],d=v((0,r.useState)(""),2),h=d[0],p=d[1];return(0,r.useEffect)((function(){var e=t.get("config")||"",n=t.get("labels")||"";(n||e)&&(l(e,n),f(e),p(n))}),[]),zt("section",{className:"vm-relabeling",children:[o&&zt(gs,{}),zt("div",{className:"vm-relabeling-header vm-block",children:[zt("div",{className:"vm-relabeling-header__configs",children:zt(Si,{type:"textarea",label:"Relabel configs",value:s,autofocus:!0,onChange:function(e){f(e)}})}),zt("div",{className:"vm-relabeling-header__labels",children:zt(Si,{type:"textarea",label:"Labels",value:h,onChange:function(e){p(e)}})}),zt("div",{className:"vm-relabeling-header-bottom",children:[zt("a",{className:"vm-link vm-link_with-icon",target:"_blank",href:"https://docs.victoriametrics.com/relabeling.html",rel:"help noreferrer",children:[zt(jn,{}),"Relabeling cookbook"]}),zt("a",{className:"vm-link vm-link_with-icon",target:"_blank",href:"https://docs.victoriametrics.com/vmagent.html#relabeling",rel:"help noreferrer",children:[zt(fr,{}),"Documentation"]}),zt(ui,{variant:"text",onClick:function(){var e=Nd,r=Md;f(e),p(r),l(e,r),t.set("config",e),t.set("labels",r),n(t)},children:"Try example"}),zt(ui,{variant:"contained",onClick:function(){l(s,h),t.set("config",s),t.set("labels",h),n(t)},startIcon:zt(Zn,{}),children:"Submit"})]})]}),u&&zt(Zr,{variant:"error",children:u}),a&&zt("div",{className:"vm-relabeling-steps vm-block",children:[a.originalLabels&&zt("div",{className:"vm-relabeling-steps-item",children:zt("div",{className:"vm-relabeling-steps-item__row",children:[zt("span",{children:"Original labels:"}),zt("code",{dangerouslySetInnerHTML:{__html:a.originalLabels}})]})}),a.steps.map((function(e,t){return zt("div",{className:"vm-relabeling-steps-item",children:[zt("div",{className:"vm-relabeling-steps-item__row",children:[zt("span",{children:"Step:"}),t+1]}),zt("div",{className:"vm-relabeling-steps-item__row",children:[zt("span",{children:"Relabeling Rule:"}),zt("code",{children:zt("pre",{children:e.rule})})]}),zt("div",{className:"vm-relabeling-steps-item__row",children:[zt("span",{children:"Input Labels:"}),zt("code",{children:zt("pre",{dangerouslySetInnerHTML:{__html:e.inLabels}})})]}),zt("div",{className:"vm-relabeling-steps-item__row",children:[zt("span",{children:"Output labels:"}),zt("code",{children:zt("pre",{dangerouslySetInnerHTML:{__html:e.outLabels}})})]})]},t)})),a.resultingLabels&&zt("div",{className:"vm-relabeling-steps-item",children:zt("div",{className:"vm-relabeling-steps-item__row",children:[zt("span",{children:"Resulting labels:"}),zt("code",{dangerouslySetInnerHTML:{__html:a.resultingLabels}})]})})]})]})},Td=function(){var e=v((0,r.useState)(!1),2),t=e[0],n=e[1];return zt(Rt.HY,{children:zt(et,{children:zt(ii,{children:zt(Rt.HY,{children:[zt(td,{onLoaded:n}),t&&zt(qe,{children:zt(Ue,{path:"/",element:zt(_a,{}),children:[zt(Ue,{path:mt.home,element:zt(Os,{})}),zt(Ue,{path:mt.metrics,element:zt(_d,{})}),zt(Ue,{path:mt.cardinality,element:zt(qf,{})}),zt(Ue,{path:mt.topQueries,element:zt(Jf,{})}),zt(Ue,{path:mt.trace,element:zt(id,{})}),zt(Ue,{path:mt.dashboards,element:zt(Df,{})}),zt(Ue,{path:mt.withTemplate,element:zt(Sd,{})}),zt(Ue,{path:mt.relabel,element:zt(Fd,{})}),zt(Ue,{path:mt.icons,element:zt(bd,{})})]})})]})})})})},Od=function(e){e&&n.e(27).then(n.bind(n,27)).then((function(t){var n=t.getCLS,r=t.getFID,i=t.getFCP,a=t.getLCP,o=t.getTTFB;n(e),r(e),i(e),a(e),o(e)}))},Id=document.getElementById("root");Id&&(0,r.render)(zt(Td,{}),Id),Od()}()}();
\ No newline at end of file
diff --git a/app/vmselect/vmui/static/js/main.ba695a31.js.LICENSE.txt b/app/vmselect/vmui/static/js/main.ff1e4560.js.LICENSE.txt
similarity index 91%
rename from app/vmselect/vmui/static/js/main.ba695a31.js.LICENSE.txt
rename to app/vmselect/vmui/static/js/main.ff1e4560.js.LICENSE.txt
index b04f7e278..766948666 100644
--- a/app/vmselect/vmui/static/js/main.ba695a31.js.LICENSE.txt
+++ b/app/vmselect/vmui/static/js/main.ff1e4560.js.LICENSE.txt
@@ -7,7 +7,7 @@
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
/**
- * @remix-run/router v1.3.0
+ * @remix-run/router v1.5.0
*
* Copyright (c) Remix Software Inc.
*
@@ -18,7 +18,7 @@
*/
/**
- * React Router DOM v6.7.0
+ * React Router DOM v6.10.0
*
* Copyright (c) Remix Software Inc.
*
@@ -29,7 +29,7 @@
*/
/**
- * React Router v6.7.0
+ * React Router v6.10.0
*
* Copyright (c) Remix Software Inc.
*