12 |
- (self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[8960],{17966:(e,t,i)=>{"use strict";i.d(t,{F:()=>a});var s=i(98604),r=i(11277),n=i(53373);function a(e,t,i){let s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"=";if(!t||!i)throw new Error("Need label to add to query.");const r=o(e);if(!r.length)return e;const n=l(t,i,s);return h(e,r,n)}function o(e){const t=s.E2.parse(e),i=[];return t.iterate({enter:(t,s,r,a)=>{if("VectorSelector"===t.name){const t=(0,n._)(e.substring(s,r));return i.push({query:t.query,from:s,to:r}),!1}}}),i}function l(e,t,i){return{label:e,op:i,value:t===1/0?"+Inf":t.toString()}}function h(e,t,i){const s=new r.K;let n="",a=0;for(let r=0;r<t.length;r++){const o=t[r],l=r===t.length-1,h=e.substring(a,o.from),c=l?e.substring(o.to):"";u(o.query.labels,i)||o.query.labels.push(i);n+=h+s.renderQuery(o.query)+c,a=o.to}return n}function u(e,t){return e.find((e=>e.label===t.label&&e.value===t.value))}},65161:(e,t,i)=>{"use strict";i.d(t,{UQ:()=>y,ZK:()=>f,ZP:()=>b});var s=i(82897),r=i(64303),n=i.n(r),a=i(50539),o=i.n(a),l=i(43215),h=i(69783),u=i(82777),c=i(53454);function d(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}const p=["job","instance"],f=1e4,g=e=>({label:e}),m=e=>(e.kind="function",e);function y(e,t){if(!t[e])return;const{type:i,help:s}=t[e];return`${i.toUpperCase()}: ${s}`}const O=/(="|!="|=~"|!~"|\{|\[|\(|\+|-|\/|\*|%|\^|\band\b|\bor\b|\bunless\b|==|>=|!=|<=|>|<|=|~|,)/;class b extends l.LanguageProvider{constructor(e,t){var i;super(),i=this,d(this,"histogramMetrics",void 0),d(this,"timeRange",void 0),d(this,"metrics",void 0),d(this,"metricsMetadata",void 0),d(this,"datasource",void 0),d(this,"labelKeys",[]),d(this,"labelsCache",new(n())({max:10})),d(this,"request",(async function(e,t){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};try{return(await i.datasource.metadataRequest(e,s)).data.data}catch(e){console.error(e)}return t})),d(this,"start",(async()=>(this.datasource.lookupsDisabled||(await this.fetchLabels(),this.metrics=await this.fetchLabelValues("__name__")||[],await this.loadMetricsMetadata(),this.histogramMetrics=(0,u.NO)(this.metrics).sort()),[]))),d(this,"provideCompletionItems",(async function(e){let{prefix:t,text:s,value:r,labelKey:n,wrapperClasses:a}=e,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const l={suggestions:[]};if(!r)return l;const h=0===r.document.text.length,u=r.document.getTextsAtRange(r.selection),c=1===u.size?u.first().getText():null,d=c?c[r.selection.anchor.offset]:null,p=a.length>3,f=t&&!p,g=!d||")"===d,m=t&&!s.match(/^[\]})\s]+$/)&&g,y=/[+\-*/^%]/,O=s.match(y);return a.includes("context-range")?i.getRangeCompletionItems():a.includes("context-labels")?i.getLabelCompletionItems({prefix:t,text:s,value:r,labelKey:n,wrapperClasses:a}):a.includes("context-aggregation")?i.getAggregationCompletionItems(r):h?i.getEmptyCompletionItems(o):f&&g&&!O?i.getBeginningCompletionItems(o):f&&m?i.getTermCompletionItems():l})),d(this,"getBeginningCompletionItems",(e=>({suggestions:[...this.getEmptyCompletionItems(e).suggestions,...this.getTermCompletionItems().suggestions]}))),d(this,"getEmptyCompletionItems",(e=>{const{history:t}=e,i=[];if(t&&t.length){const e=(0,s.chain)(t).map((e=>e.query.expr)).filter().uniq().take(5).map(g).map((e=>function(e,t){const i=Date.now()-864e5,s=t.filter((t=>t.ts>i&&t.query===e.label)),r=s.length,n=s[0];let a=`Queried ${r} times in the last 24h.`;n&&(a=`${a} Last queried ${(0,l.dateTime)(n.ts).fromNow()}.`);return Object.assign({},e,{documentation:a})}(e,t))).value();i.push({searchFunctionType:h.SearchFunctionType.Prefix,skipSort:!0,label:"History",items:e})}return{suggestions:i}})),d(this,"getTermCompletionItems",(()=>{const{metrics:e,metricsMetadata:t}=this,i=[];return i.push({searchFunctionType:h.SearchFunctionType.Prefix,label:"Functions",items:c.r8.map(m)}),e&&e.length&&i.push({label:"Metrics",items:e.map((e=>function(e,t){const i={label:e};return t&&t[e]&&(i.documentation=y(e,t)),i}(e,t))),searchFunctionType:h.SearchFunctionType.Fuzzy}),{suggestions:i}})),d(this,"getAggregationCompletionItems",(async e=>{const t=[];let i;const s=e.document.getBlocks().reduce(((t,s)=>{if(void 0===t)return"";if(!s)return t;const r=null==s?void 0:s.getText();return e.anchorBlock.key===s.key&&(i=e.selection.anchor.offset+t.length),t+r}),""),r=s.lastIndexOf("(",i);let n=s.lastIndexOf("(",r-1),a=s.indexOf(")",n);if(-1===n){const e=s.indexOf(")",i);a=s.indexOf(")",e+1),n=s.lastIndexOf("(",a)}const o={suggestions:t,context:"context-aggregation"};if(-1===n)return o;const l=s.slice(n+1,a).replace(/\[[^\]]+\]$/,""),c=(0,u.rV)(l,l.length-2).selector,d=await this.getSeries(c),p=Object.keys(d);if(p.length>0){const e=(0,u.ZO)(p);t.push({label:`Labels${e}`,items:p.map(g),searchFunctionType:h.SearchFunctionType.Fuzzy})}return o})),d(this,"getLabelCompletionItems",(async e=>{let{text:t,wrapperClasses:i,labelKey:r,value:n}=e;if(!n)return{suggestions:[]};const a=[],o=n.anchorBlock.getText(),l=n.selection.anchor.offset,c=o.substr(l),d=o.substr(0,l),f=t.match(/^(=|=~|!=|!~)/),m=c.match(/^"?[,}]|$/),y=d.match(/(=|=~|!=|!~)$/)&&c.match(/^"/);if(!(f&&m)&&!(m&&!f)||y)return{suggestions:a};let O,b;try{b=(0,u.rV)(o,l),O=b.selector}catch{O="{}"}const x=O.includes("__name__="),v=b?b.labelKeys:[];let $,k={};if(O&&(k=await this.getSeries(O,!x)),0===Object.keys(k).length)return console.warn(`Server did not return any values for selector = ${O}`),{suggestions:a};if(t&&f||i.includes("attr-value")){if(r&&k[r]){$="context-label-values";const e=(0,u.ZO)(k[r]);a.push({label:`Label values for "${r}"${e}`,items:k[r].map(g),searchFunctionType:h.SearchFunctionType.Fuzzy})}}else{const e=k?Object.keys(k):x?null:p;if(e){const t=(0,s.difference)(e,v);if(t.length){$="context-labels";const e=t.map((e=>({label:e}))),i={label:`Labels${(0,u.ZO)(e)}`,items:e,searchFunctionType:h.SearchFunctionType.Fuzzy};a.push(i)}}}return{context:$,suggestions:a}})),d(this,"fetchLabelValues",(async e=>{const t=this.datasource.getTimeRangeParams(),i=`/api/v1/label/${this.datasource.interpolateString(e)}/values`;return await this.request(i,[],t)})),d(this,"fetchSeriesLabels",(async(e,t)=>{const i=this.datasource.interpolateString(e),s=this.datasource.getTimeRangeParams(),r=Object.assign({},s,{"match[]":i}),n=`/api/v1/series?${new URLSearchParams({"match[]":i,start:(0,u.s4)(parseInt(s.start,10)).toString(),end:(0,u.s4)(parseInt(s.end,10)).toString(),withName:t?"true":"false"}).toString()}`;let a=this.labelsCache.get(n);if(!a){const e=await this.request("/api/v1/series",[],r),{values:i}=(0,u.DY)(e,t);a=i,this.labelsCache.set(n,a)}return a})),d(this,"fetchSeries",(async e=>{const t=this.datasource.getTimeRangeParams(),i=Object.assign({},t,{"match[]":e});return await this.request("/api/v1/series",{},i)})),d(this,"fetchDefaultSeries",(0,s.once)((async()=>{const e=await Promise.all(p.map((e=>this.fetchLabelValues(e))));return p.reduce(((t,i,s)=>Object.assign({},t,{[i]:e[s]})),{})}))),this.datasource=e,this.histogramMetrics=[],this.timeRange={start:0,end:0},this.metrics=[],Object.assign(this,t)}cleanText(e){return e.split(O).pop().trimLeft().replace(/"$/,"").replace(/^"/,"")}get syntax(){return c.ZP}async loadMetricsMetadata(){this.metricsMetadata=(0,u.I4)(await this.request("/api/v1/metadata",{}))}getLabelKeys(){return this.labelKeys}getRangeCompletionItems(){return{context:"context-range",suggestions:[{label:"Range vector",items:[...c.Ty]}]}}importFromAbstractQuery(e){return(0,u.e5)(e)}exportToAbstractQuery(e){const t=e.expr;if(!t||0===t.length)return{refId:e.refId,labelMatchers:[]};const i=o().tokenize(t,c.ZP),s=(0,u.UO)(i),r=function(e,t){let i="";for(let e in t)if("string"==typeof t[e]){i=t[e];break}return i}(0,i);return r&&r.length>0&&s.push({name:"__name__",operator:l.AbstractLabelOperator.Equal,value:r}),{refId:e.refId,labelMatchers:s}}async getSeries(e,t){if(this.datasource.lookupsDisabled)return{};try{return"{}"===e?await this.fetchDefaultSeries():await this.fetchSeriesLabels(e,t)}catch(e){return console.error(e),{}}}async getLabelValues(e){return await this.fetchLabelValues(e)}async fetchLabels(){const e=this.datasource.getTimeRangeParams();this.labelFetchTs=Date.now().valueOf();const t=await this.request("/api/v1/labels",[],e);return Array.isArray(t)&&(this.labelKeys=t.slice().sort()),[]}}},82777:(e,t,i)=>{"use strict";i.d(t,{DY:()=>c,I4:()=>m,NO:()=>u,PL:()=>P,U9:()=>$,UO:()=>Q,ZO:()=>x,e5:()=>S,ll:()=>g,o8:()=>y,rV:()=>f,s4:()=>O,tU:()=>k});var s=i(82897),r=i(50539),n=i(43215),a=i(17966),o=i(65161);const l=["__name__"];function h(e,t){if(null==e)return{};var i,s,r={},n=Object.keys(e);for(s=0;s<n.length;s++)i=n[s],t.indexOf(i)>=0||(r[i]=e[i]);return r}const u=e=>{const t=new Set,i=new RegExp("_bucket($|:)");for(let s=0;s<e.length;s++){const r=e[s];i.test(r)&&t.add(r)}return[...t]};function c(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const i={};e.forEach((e=>{const{__name__:s}=e,r=h(e,l);t&&(i.__name__=i.__name__||new Set,i.__name__.has(s)||i.__name__.add(s)),Object.keys(r).forEach((e=>{i[e]||(i[e]=new Set),i[e].has(r[e])||i[e].add(r[e])}))}));const s={};return b(Object.keys(i)).forEach((e=>{s[e]=b(Array.from(i[e]))})),{values:s,keys:Object.keys(s)}}const d=/\{[^}]*?(\}|$)/,p=/\b(\w+)(!?=~?)("[^"\n]*?")/g;function f(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;if(!e.match(d)){if(e.match(/^[A-Za-z:][\w:]*$/))return{selector:`{__name__="${e}"}`,labelKeys:["__name__"]};throw new Error("Query must contain a selector: "+e)}const i=e.slice(0,t),s=i.lastIndexOf("{"),r=i.lastIndexOf("}");if(-1===s)throw new Error("Not inside selector, missing open brace: "+i);if(r>-1&&r>s)throw new Error("Not inside selector, previous selector already closed: "+i);const n=e.slice(t),a=n.indexOf("}"),o=a+t,l=n.indexOf("{"),h=l+t;if(-1===o)throw new Error("Not inside selector, missing closing brace in suffix: "+n);if(l>-1&&h<o)throw new Error("Not inside selector, next selector opens before this one closed: "+n);const u=e.slice(s,o),c={};u.replace(p,((i,s,r,n)=>{const a=e.indexOf(i),o=a+s.length+r.length+1,l=a+s.length+r.length+n.length-1;return(t<o||t>l)&&(c[s]={value:n,operator:r}),""}));const f=e.slice(0,s),g=f.match(/[A-Za-z:][\w:]*$/);g&&(c.__name__={value:`"${g[0]}"`,operator:"="});const m=Object.keys(c).sort(),y=m.map((e=>`${e}${c[e].operator}${c[e].value}`)).join(","),O=["{",y,"}"].join("");return{labelKeys:m,selector:O}}function g(e,t){const i=Object.keys(t),s=new RegExp(`(\\s|^)(${i.join("|")})(\\s|$|\\(|\\[|\\{)`,"ig"),r=e.replace(s,((e,i,s,r)=>`${i}${t[s]}${r}`)).split(/(\+|\-|\*|\/|\%|\^)/),n=/(\)\{|\}\{|\]\{)/,o=r.map((e=>function(e,t){var i;const s=e.match(t);if(!s)return e;const r=null!==(i=s.index)&&void 0!==i?i:0,n=e.slice(0,r+1),o=e.slice(r+1),l=[];o.replace(p,((e,t,i,s)=>(l.push({key:t,operator:i,value:s}),"")));let h=n;return l.filter(Boolean).forEach((e=>{const t=e.value.slice(1,-1);h=(0,a.F)(h,e.key,t,e.operator)})),h}(e,n)));return o.join("")}function m(e){if(!e)return e;const t={},i={};for(const s in e){const r=e[s][0];t[s]=r,"histogram"===r.type&&(i[`${s}_bucket`]={type:"counter",help:`Cumulative counters for the observation buckets (${r.help})`},i[`${s}_count`]={type:"counter",help:`Count of events that have been observed for the histogram metric (${r.help})`},i[`${s}_sum`]={type:"counter",help:`Total sum of all observed values for the histogram metric (${r.help})`}),"summary"===r.type&&(i[`${s}_count`]={type:"counter",help:`Count of events that have been observed for the base metric (${r.help})`},i[`${s}_sum`]={type:"counter",help:`Total sum of all observed values for the base metric (${r.help})`})}const s={ALERTS:{type:"counter",help:"Time series showing pending and firing alerts. The sample value is set to 1 as long as the alert is in the indicated active (pending or firing) state."}};return Object.assign({},t,i,s)}function y(e){return O(e/1e3)}function O(e){return Math.floor(e/60)}function b(e){return e.slice(0,o.ZK)}function x(e){return e&&e.length>=o.ZK?`, limited to the first ${o.ZK} received items`:""}const v=/[*+?()|\\.\[\]{}^$]/g;function $(e){return e.replace(/\\/g,"\\\\").replace(/\n/g,"\\n").replace(/"/g,'\\"')}function k(e){return $(e.replace(v,"\\$&"))}const w={"=":n.AbstractLabelOperator.Equal,"!=":n.AbstractLabelOperator.NotEqual,"=~":n.AbstractLabelOperator.EqualRegEx,"!~":n.AbstractLabelOperator.NotEqualRegEx},_=(0,s.invert)(w);function P(e){const t=e.labelMatchers.map((e=>{const t=_[e.operator];return t?`${e.name}${t}"${e.value}"`:""})).filter((e=>""!==e)).join(", ");return t?`{${t}}`:""}function S(e){return{refId:e.refId,expr:P(e),range:!0}}function Q(e){const t=[];for(let i in e)if(e[i]instanceof r.Token){let s=e[i];if("context-labels"===s.type){let e="",i="",n="",a=s.content;for(let s in a)if("string"==typeof a[s]){let e;e=a[s],"="!==e&&"!="!==e&&"=~"!==e&&"!~"!==e||(n=e)}else if(a[s]instanceof r.Token)switch(a[s].type){case"label-key":e=a[s].content;break;case"label-value":i=a[s].content,i=i.substring(1,i.length-1);const r=w[n];r&&t.push({name:e,operator:r,value:i})}}}return t}},11277:(e,t,i)=>{"use strict";i.d(t,{K:()=>b,Z:()=>x});var s=i(53454),r=i(8254),n=i(47908),a=i(19093),o=i(12524);function l(e){var t,i,s,r,n,l;return Object.assign({},e,{id:e.id,name:null!==(t=e.name)&&void 0!==t?t:(0,a.t7)(e.id),params:null!==(i=e.params)&&void 0!==i?i:[],defaultParams:null!==(s=e.defaultParams)&&void 0!==s?s:[],category:null!==(r=e.category)&&void 0!==r?r:o.C.Functions,renderer:null!==(n=e.renderer)&&void 0!==n?n:e.params?a.zJ:a.pS,addOperationHandler:null!==(l=e.addOperationHandler)&&void 0!==l?l:a.PP})}function h(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return{id:e,name:(0,a.t7)(e),params:[(0,a.kq)(t)],defaultParams:[t?"$__rate_interval":"$__interval"],alternativesKey:"range function",category:o.C.RangeFunctions,renderer:c,addOperationHandler:d,changeTypeHandler:u}}function u(e,t){return("$__rate_interval"===e.params[0]&&"$__rate_interval"!==t.defaultParams[0]||"$__interval"===e.params[0]&&"$__interval"!==t.defaultParams[0])&&(e.params=t.defaultParams),e}function c(e,t,i){var s,r;let n=null!==(s=(null!==(r=e.params)&&void 0!==r?r:[])[0])&&void 0!==s?s:"5m";return`${t.id}(${i}[${n}])`}function d(e,t,i){const s={id:e.id,params:e.defaultParams};if(t.operations.length>0){if(i.getOperationDef(t.operations[0].id).addOperationHandler===d)return Object.assign({},t,{operations:[s,...t.operations.slice(1)]})}return Object.assign({},t,{operations:[s,...t.operations]})}function p(e,t){var i;return Object.assign({},t,{binaryQueries:[...null!==(i=t.binaryQueries)&&void 0!==i?i:[],{operator:"/",query:t}]})}function f(e,t,i){if("string"!=typeof e.params[1])throw"The separator must be a string";const s=`"${e.params[1]}"`;return`${e.id}(${i}, "${e.params[0]}", ${s}, "${e.params.slice(2).join(s)}")`}function g(e,t){const i={id:e.id,params:e.defaultParams};return Object.assign({},t,{operations:[...t.operations,i]})}function m(e){return{id:e,name:(0,a.t7)(e),params:[(0,a.kq)()],defaultParams:["$__interval"],alternativesKey:"overtime function",category:o.C.RangeFunctions,renderer:y,addOperationHandler:d}}function y(e,t,i){var s,r;let n=null!==(s=(null!==(r=e.params)&&void 0!==r?r:[])[0])&&void 0!==s?s:"$__interval";return`${t.id}(${i}[${n}])`}var O=i(37393);class b extends O.x{constructor(){super((()=>{const e=[{id:o.G.HistogramQuantile,name:"Histogram quantile",params:[{name:"Quantile",type:"number",options:[.99,.95,.9,.75,.5,.25]}],defaultParams:[.9],category:o.C.Functions,renderer:a.pS,addOperationHandler:a.PP},{id:o.G.LabelReplace,name:"Label replace",params:[{name:"Destination label",type:"string"},{name:"Replacement",type:"string"},{name:"Source label",type:"string"},{name:"Regex",type:"string"}],category:o.C.Functions,defaultParams:["","$1","","(.*)"],renderer:a.zJ,addOperationHandler:a.PP},{id:o.G.Ln,name:"Ln",params:[],defaultParams:[],category:o.C.Functions,renderer:a.pS,addOperationHandler:a.PP},h(o.G.Changes),h(o.G.Rate,!0),h(o.G.Irate),h(o.G.Increase,!0),h(o.G.Idelta),h(o.G.Delta),l({id:o.G.HoltWinters,params:[(0,a.kq)(),{name:"Smoothing Factor",type:"number"},{name:"Trend Factor",type:"number"}],defaultParams:["$__interval",.5,.5],alternativesKey:"range function",category:o.C.RangeFunctions,renderer:a.e8,addOperationHandler:d,changeTypeHandler:u}),l({id:o.G.PredictLinear,params:[(0,a.kq)(),{name:"Seconds from now",type:"number"}],defaultParams:["$__interval",60],alternativesKey:"range function",category:o.C.RangeFunctions,renderer:a.e8,addOperationHandler:d,changeTypeHandler:u}),l({id:o.G.QuantileOverTime,params:[(0,a.kq)(),{name:"Quantile",type:"number"}],defaultParams:["$__interval",.5],alternativesKey:"overtime function",category:o.C.RangeFunctions,renderer:a.NZ,addOperationHandler:d,changeTypeHandler:u}),...r.EX,{id:o.G.NestedQuery,name:"Binary operation with query",params:[],defaultParams:[],category:o.C.BinaryOps,renderer:(e,t,i)=>i,addOperationHandler:p},l({id:o.G.Absent}),l({id:o.G.Acos,category:o.C.Trigonometric}),l({id:o.G.Acosh,category:o.C.Trigonometric}),l({id:o.G.Asin,category:o.C.Trigonometric}),l({id:o.G.Asinh,category:o.C.Trigonometric}),l({id:o.G.Atan,category:o.C.Trigonometric}),l({id:o.G.Atanh,category:o.C.Trigonometric}),l({id:o.G.Ceil}),l({id:o.G.Clamp,name:"Clamp",params:[{name:"Minimum Scalar",type:"number"},{name:"Maximum Scalar",type:"number"}],defaultParams:[1,1]}),l({id:o.G.ClampMax,params:[{name:"Maximum Scalar",type:"number"}],defaultParams:[1]}),l({id:o.G.ClampMin,params:[{name:"Minimum Scalar",type:"number"}],defaultParams:[1]}),l({id:o.G.Cos,category:o.C.Trigonometric}),l({id:o.G.Cosh,category:o.C.Trigonometric}),l({id:o.G.DayOfMonth,category:o.C.Time}),l({id:o.G.DayOfWeek,category:o.C.Time}),l({id:o.G.DaysInMonth,category:o.C.Time}),l({id:o.G.Deg}),h(o.G.Deriv),l({id:o.G.Exp}),l({id:o.G.Floor}),l({id:o.G.Group}),l({id:o.G.Hour}),l({id:o.G.LabelJoin,params:[{name:"Destination Label",type:"string",editor:n.g},{name:"Separator",type:"string"},{name:"Source Label",type:"string",restParam:!0,optional:!0,editor:n.g}],defaultParams:["",",",""],renderer:f,addOperationHandler:g}),l({id:o.G.Log10}),l({id:o.G.Log2}),l({id:o.G.Minute}),l({id:o.G.Month}),l({id:o.G.Pi,renderer:e=>`${e.id}()`}),l({id:o.G.Quantile,params:[{name:"Value",type:"number"}],defaultParams:[1],renderer:a.pS}),l({id:o.G.Rad}),h(o.G.Resets),l({id:o.G.Round,category:o.C.Functions,params:[{name:"To Nearest",type:"number"}],defaultParams:[1]}),l({id:o.G.Scalar}),l({id:o.G.Sgn}),l({id:o.G.Sin,category:o.C.Trigonometric}),l({id:o.G.Sinh,category:o.C.Trigonometric}),l({id:o.G.Sort}),l({id:o.G.SortDesc}),l({id:o.G.Sqrt}),l({id:o.G.Stddev}),l({id:o.G.Tan,category:o.C.Trigonometric}),l({id:o.G.Tanh,category:o.C.Trigonometric}),l({id:o.G.Time,renderer:e=>`${e.id}()`}),l({id:o.G.Timestamp}),l({id:o.G.Vector,params:[{name:"Value",type:"number"}],defaultParams:[1],renderer:e=>`${e.id}(${e.params[0]})`}),l({id:o.G.Year}),...(0,a.IT)(o.G.Sum),...(0,a.IT)(o.G.Avg),...(0,a.IT)(o.G.Min),...(0,a.IT)(o.G.Max),...(0,a.IT)(o.G.Count),...(0,a.Z3)(o.G.TopK,{params:[{name:"K-value",type:"number"}],defaultParams:[5]}),...(0,a.Z3)(o.G.BottomK,{params:[{name:"K-value",type:"number"}],defaultParams:[5]}),...(0,a.Z3)(o.G.CountValues,{params:[{name:"Identifier",type:"string"}],defaultParams:["count"]}),m(o.G.SumOverTime),m(o.G.AvgOverTime),m(o.G.MinOverTime),m(o.G.MaxOverTime),m(o.G.CountOverTime),m(o.G.LastOverTime),m(o.G.PresentOverTime),m(o.G.AbsentOverTime),m(o.G.StddevOverTime)];for(const t of e){const e=s.r8.find((e=>e.insertText===t.id));e&&(t.documentation=e.documentation)}return e})),this.setOperationCategories([o.C.Aggregations,o.C.RangeFunctions,o.C.Functions,o.C.BinaryOps,o.C.Trigonometric,o.C.Time])}getQueryPatterns(){return[{name:"Rate then sum",operations:[{id:"rate",params:["$__rate_interval"]},{id:"sum",params:[]}]},{name:"Rate then sum by(label) then avg",operations:[{id:"rate",params:["$__rate_interval"]},{id:"__sum_by",params:[""]},{id:"avg",params:[]}]},{name:"Histogram quantile on rate",operations:[{id:"rate",params:["$__rate_interval"]},{id:"__sum_by",params:["le"]},{id:"histogram_quantile",params:[.95]}]},{name:"Histogram quantile on increase ",operations:[{id:"increase",params:["$__rate_interval"]},{id:"__max_by",params:["le"]},{id:"histogram_quantile",params:[.95]}]}]}}const x=new b},8254:(e,t,i)=>{"use strict";i.d(t,{EX:()=>o,PX:()=>a,iQ:()=>n});var s=i(19093),r=i(12524);const n=[{id:r.G.Addition,name:"Add scalar",sign:"+"},{id:r.G.Subtraction,name:"Subtract scalar",sign:"-"},{id:r.G.MultiplyBy,name:"Multiply by scalar",sign:"*"},{id:r.G.DivideBy,name:"Divide by scalar",sign:"/"},{id:r.G.Modulo,name:"Modulo by scalar",sign:"%"},{id:r.G.Exponent,name:"Exponent",sign:"^"},{id:r.G.EqualTo,name:"Equal to",sign:"==",comparison:!0},{id:r.G.NotEqualTo,name:"Not equal to",sign:"!=",comparison:!0},{id:r.G.GreaterThan,name:"Greater than",sign:">",comparison:!0},{id:r.G.LessThan,name:"Less than",sign:"<",comparison:!0},{id:r.G.GreaterOrEqual,name:"Greater or equal to",sign:">=",comparison:!0},{id:r.G.LessOrEqual,name:"Less or equal to",sign:"<=",comparison:!0}],a=n.reduce(((e,t)=>(e[t.sign]={id:t.id,comparison:t.comparison},e)),{}),o=n.map((e=>{const t=[{name:"Value",type:"number"}],i=[2];return e.comparison&&(t.push({name:"Bool",type:"boolean",description:"If checked comparison will return 0 or 1 for the value rather than filtering."}),i.push(!1)),{id:e.id,name:e.name,params:t,defaultParams:i,alternativesKey:"binary scalar operations",category:r.C.BinaryOps,renderer:(n=e.sign,function(e,t,i){let s=e.params[0],r="";return 2===e.params.length&&(r=e.params[1]?" bool":""),`${i} ${n}${r} ${s}`}),addOperationHandler:s.PP};var n}))},47908:(e,t,i)=>{"use strict";i.d(t,{g:()=>h});var s=i(68404),r=i(43215),n=i(69783),a=i(11277),o=i(19093),l=i(45916);function h(e){let{onChange:t,index:i,operationIndex:h,value:u,query:c,datasource:d}=e;const[p,f]=(0,s.useState)({});return(0,l.jsx)(n.Select,{inputId:(0,o.i1)(h,i),autoFocus:""===u||void 0,openMenuOnFocus:!0,onOpenMenu:async()=>{f({isLoading:!0});const e=await async function(e,t){let i=e.labels;"prometheus"===t.type&&(i=[{label:"__name__",op:"=",value:e.metric},...e.labels]);const s=a.Z.renderLabels(i),r=await t.languageProvider.fetchSeriesLabels(s);return Object.keys(r).map((e=>({label:e,value:e})))}(c,d);f({options:e,isLoading:void 0})},isLoading:p.isLoading,allowCustomValue:!0,noOptionsMessage:"No labels found",loadingMessage:"Loading labels",options:p.options,value:(0,r.toOption)(u),onChange:e=>t(i,e.value)})}},53373:(e,t,i)=>{"use strict";i.d(t,{_:()=>a});var s=i(98604),r=i(8254),n=i(25890);function a(e){const t=(0,n.bU)(e),i=s.E2.parse(t).topNode,r={query:{metric:"",labels:[],operations:[]},errors:[]};try{o(t,i,r)}catch(e){console.error(e),r.errors.push({text:e.message})}return function(e){if(0===e.labels.length&&0===e.operations.length&&!e.metric)return!0;return!1}(r.query)&&(r.errors=[]),r}function o(e,t,i){const s=i.query;switch(t.name){case"MetricIdentifier":s.metric=(0,n.KF)(e,t);break;case"LabelMatcher":{s.labels.push(function(e,t){const i=(0,n.KF)(e,t.getChild("LabelName")),s=(0,n.KF)(e,t.getChild("MatchOp")),r=(0,n.KF)(e,t.getChild("StringLiteral")).replace(/"/g,"");return{label:i,op:s,value:r}}(e,t));const r=t.getChild(n.GQ);r&&i.errors.push((0,n.wf)(e,r));break}case"FunctionCall":!function(e,t,i){const s=i.query,r=t.getChild("FunctionIdentifier"),a=(0,n.KF)(e,r),o=t.getChild("FunctionCallBody").getChild("FunctionCallArgs"),u=[];let c="";if(l.includes(a)||a.endsWith("_over_time")){let i=(0,n.KF)(e,t).match(/\[(.+)\]/);null!=i&&i[1]&&(c=i[1],u.push(i[1]))}const d={id:a,params:u};if(s.operations.unshift(d),o){if((0,n.KF)(e,o)===c+"]")return;h(e,o,i,d)}}(e,t,i);break;case"AggregateExpr":!function(e,t,i){const s=i.query,r=t.getChild("AggregateOp");let a=(0,n.KF)(e,r);const o=t.getChild("AggregateModifier"),l=[];if(o){o.getChild("By")&&a&&(a=`__${a}_by`);o.getChild("Without")&&(a=`__${a}_without`),l.push(...(0,n.ff)(e,o,"GroupingLabel"))}const u=t.getChild("FunctionCallBody").getChild("FunctionCallArgs"),c={id:a,params:[]};s.operations.unshift(c),h(e,u,i,c),c.params.push(...l)}(e,t,i);break;case"BinaryExpr":!function(e,t,i){const s=i.query,a=t.firstChild,l=(0,n.KF)(e,a.nextSibling),h=function(e,t){if(!t)return;if(t.getChild("Bool"))return{isBool:!0,isMatcher:!1};{var i;const s=t.getChild("OnOrIgnoring");if(!s)return;return{isMatcher:!0,isBool:!1,matches:(0,n.KF)(e,null===(i=s.getChild("GroupingLabels"))||void 0===i?void 0:i.getChild("GroupingLabelList")),matchType:s.getChild("On")?"on":"ignoring"}}}(e,t.getChild("BinModifiers")),u=t.lastChild,c=r.PX[l],d=a.getChild("NumberLiteral"),p=u.getChild("NumberLiteral"),f=u.getChild("BinaryExpr");d||o(e,a,i);if(p)s.operations.push((0,n.Es)(c,e,u,!(null==h||!h.isBool)));else if(f){const t=(0,n.ge)(u);"NumberLiteral"===(null==t?void 0:t.name)&&s.operations.push((0,n.Es)(c,e,t,!(null==h||!h.isBool))),o(e,u,i)}else{s.binaryQueries=s.binaryQueries||[];const t={operator:l,query:{metric:"",labels:[],operations:[]}};null!=h&&h.isMatcher&&(t.vectorMatchesType=h.matchType,t.vectorMatches=h.matches),s.binaryQueries.push(t),o(e,u,{query:t.query,errors:i.errors})}}(e,t,i);break;case n.GQ:if(function(e){var t,i,s;return"Expr"===(null===(t=e.prevSibling)||void 0===t?void 0:t.name)&&"VectorSelector"===(null===(i=e.prevSibling)||void 0===i||null===(s=i.firstChild)||void 0===s?void 0:s.name)}(t))break;i.errors.push((0,n.wf)(e,t));break;default:{"ParenExpr"===t.name&&i.errors.push((0,n.wf)(e,t));let s=t.firstChild;for(;s;)o(e,s,i),s=s.nextSibling}}}const l=["changes","rate","irate","increase","delta"];function h(e,t,i,s){if(t)switch(t.name){case"Expr":case"FunctionCallArgs":{let r=t.firstChild;for(;r;)h(e,r,i,s),r=r.nextSibling;break}case"NumberLiteral":s.params.push(parseFloat((0,n.KF)(e,t)));break;case"StringLiteral":s.params.push((0,n.KF)(e,t).replace(/"/g,""));break;default:o(e,t,i)}}},64722:(e,t,i)=>{"use strict";i.d(t,{H:()=>o});var s=i(68404),r=i(69783),n=i(45916);const a=["defaultValue","minWidth","maxWidth","onCommitChange","onKeyDown","onBlur"];const o=s.forwardRef(((e,t)=>{const{defaultValue:i="",minWidth:o=10,maxWidth:l,onCommitChange:h,onKeyDown:u,onBlur:c}=e,d=function(e,t){if(null==e)return{};var i,s,r={},n=Object.keys(e);for(s=0;s<n.length;s++)i=n[s],t.indexOf(i)>=0||(r[i]=e[i]);return r}(e,a),[p,f]=s.useState(i),[g,m]=s.useState(o);return(0,s.useEffect)((()=>{m(function(e,t,i){if(!e)return t;const s=3,n=(0,r.measureText)(e.toString(),14).width/8+s;if(t&&n<t)return t;if(i&&n>i)return n;return n}(p.toString(),o,l))}),[p,l,o]),(0,n.jsx)(r.Input,Object.assign({},d,{ref:t,value:p.toString(),onChange:e=>{f(e.currentTarget.value)},width:g,onBlur:e=>{c?c(e):h&&h(e)},onKeyDown:e=>{u?u(e):"Enter"===e.key&&h&&h(e)},"data-testid":"autosize-input"}))}));o.displayName="AutoSizeInput"},55268:(e,t,i)=>{"use strict";i.d(t,{R:()=>h});var s,r=i(36636),n=(i(68404),i(90747)),a=i(90923),o=i(69783),l=i(45916);function h(e){let{feedbackUrl:t}=e;const i=(0,o.useStyles2)(u);return a.config.feedbackLinksEnabled?(0,l.jsx)(n.Stack,{gap:1,children:(0,l.jsxs)("a",{href:t,className:i.link,title:"This query builder is new, please let us know how we can improve it",target:"_blank",rel:"noreferrer noopener",onClick:()=>(0,a.reportInteraction)("grafana_feedback_link_clicked",{link:t}),children:[s||(s=(0,l.jsx)(o.Icon,{name:"comment-alt-message"}))," Give feedback"]})}):null}function u(e){return{link:(0,r.css)({color:e.colors.text.secondary,fontSize:e.typography.bodySmall.fontSize,":hover":{color:e.colors.text.link}})}}},50818:(e,t,i)=>{"use strict";i.d(t,{P:()=>c});var s=i(82897),r=i(68404),n=i(90747),a=i(43215),o=i(69783),l=i(45916);function h(e){var t;let{item:i,defaultOp:h,onChange:c,onDelete:d,onGetLabelNames:p,onGetLabelValues:f}=e;const[g,m]=(0,r.useState)({}),y=()=>i.op===u[0].label,O=e=>e?e.indexOf("|")>0?e.split("|"):[e]:[];return(0,l.jsx)("div",{"data-testid":"prometheus-dimensions-filter-item",children:(0,l.jsxs)(n.InputGroup,{children:[(0,l.jsx)(o.Select,{inputId:"prometheus-dimensions-filter-item-key",width:"auto",value:i.label?(0,a.toOption)(i.label):null,allowCustomValue:!0,onOpenMenu:async()=>{m({isLoadingLabelNames:!0});const e=await p(i);m({labelNames:e,isLoadingLabelNames:void 0})},isLoading:g.isLoadingLabelNames,options:g.labelNames,onChange:e=>{var t;e.label&&c(Object.assign({},i,{op:null!==(t=i.op)&&void 0!==t?t:h,label:e.label}))}}),(0,l.jsx)(o.Select,{value:(0,a.toOption)(null!==(t=i.op)&&void 0!==t?t:h),options:u,width:"auto",onChange:e=>{null!=e.value&&c(Object.assign({},i,{op:e.value}))}}),(0,l.jsx)(o.Select,{inputId:"prometheus-dimensions-filter-item-value",width:"auto",value:y()?O(null==i?void 0:i.value).map(a.toOption):O(null==i?void 0:i.value).map(a.toOption)[0],allowCustomValue:!0,onOpenMenu:async()=>{m({isLoadingLabelValues:!0});const e=await f(i);m(Object.assign({},g,{labelValues:e,isLoadingLabelValues:void 0}))},isMulti:y(),isLoading:g.isLoadingLabelValues,options:(()=>{const e=g.labelValues?[...g.labelValues]:[],t=O(null==i?void 0:i.value).map(a.toOption);return(0,s.uniqBy)([...t,...e],"value")})(),onChange:e=>{if(e.value){var t;c(Object.assign({},i,{value:e.value,op:null!==(t=i.op)&&void 0!==t?t:h}))}else{var s;const t=e.map((e=>e.label)).join("|");c(Object.assign({},i,{value:t,op:null!==(s=i.op)&&void 0!==s?s:h}))}}}),(0,l.jsx)(n.AccessoryButton,{"aria-label":"remove",icon:"times",variant:"secondary",onClick:d})]})})}const u=[{label:"=~",value:"=~"},{label:"=",value:"="},{label:"!=",value:"!="},{label:"!~",value:"!~"}];function c(e){let{labelsFilters:t,onChange:i,onGetLabelNames:a,onGetLabelValues:o,error:u}=e;const[c,d]=(0,r.useState)([{op:"="}]);(0,r.useEffect)((()=>{t.length>0?d(t):d([{op:"="}])}),[t]);return(0,l.jsx)(n.EditorFieldGroup,{children:(0,l.jsx)(n.EditorField,{label:"Labels",error:u,invalid:!!u,children:(0,l.jsx)(n.EditorList,{items:c,onChange:e=>{d(e);const r=e.filter((e=>null!=e.label&&null!=e.value));(0,s.isEqual)(r,t)||i(r)},renderItem:(e,t,i)=>(0,l.jsx)(h,{item:e,defaultOp:"=",onChange:t,onDelete:i,onGetLabelNames:a,onGetLabelValues:o})})})})}},37393:(e,t,i)=>{"use strict";i.d(t,{x:()=>a});var s=i(43215),r=i(12524);function n(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}class a{constructor(e){n(this,"operationsRegistry",void 0),n(this,"categories",[]),this.operationsRegistry=new s.Registry(e)}setOperationCategories(e){this.categories=e}getOperationsForCategory(e){return this.operationsRegistry.list().filter((t=>t.category===e&&!t.hideFromList))}getAlternativeOperations(e){return this.operationsRegistry.list().filter((t=>t.alternativesKey&&t.alternativesKey===e))}getCategories(){return this.categories}getOperationDef(e){return this.operationsRegistry.getIfExists(e)}renderOperations(e,t){for(const i of t){const t=this.operationsRegistry.getIfExists(i.id);if(!t)throw new Error(`Could not find operation ${i.id} in the registry`);e=t.renderer(i,t,e)}return e}renderBinaryQueries(e,t){if(t)for(const i of t)e=`${this.renderBinaryQuery(e,i)}`;return e}renderBinaryQuery(e,t){let i=e+` ${t.operator} `;return t.vectorMatches&&(i+=`${t.vectorMatchesType}(${t.vectorMatches}) `),i+this.renderQuery(t.query,!0)}renderLabels(e){if(0===e.length)return"";let t="{";for(const i of e)"{"!==t&&(t+=", "),t+=`${i.label}${i.op}"${i.value}"`;return t+"}"}renderQuery(e,t){var i,s,r;let n=`${null!==(i=e.metric)&&void 0!==i?i:""}${this.renderLabels(e.labels)}`;return n=this.renderOperations(n,e.operations),!t&&this.hasBinaryOp(e)&&Boolean(null===(s=e.binaryQueries)||void 0===s?void 0:s.length)&&(n=`(${n})`),n=this.renderBinaryQueries(n,e.binaryQueries),t&&(this.hasBinaryOp(e)||Boolean(null===(r=e.binaryQueries)||void 0===r?void 0:r.length))&&(n=`(${n})`),n}hasBinaryOp(e){return void 0!==e.operations.find((e=>{const t=this.getOperationDef(e.id);return(null==t?void 0:t.category)===r.C.BinaryOps}))}}},2926:(e,t,i)=>{"use strict";i.d(t,{B:()=>o});var s=i(36636),r=(i(68404),i(43215)),n=i(69783),a=i(45916);function o(e){let{title:t,stepNumber:i,markdown:s,children:o}=e;const h=(0,n.useStyles2)(l);return(0,a.jsxs)("div",{className:h.box,children:[void 0!==i&&(0,a.jsx)("div",{className:h.stepNumber,children:i}),(0,a.jsxs)("div",{className:h.boxInner,children:[t&&(0,a.jsx)("div",{className:h.header,children:(0,a.jsx)("span",{children:t})}),(0,a.jsxs)("div",{className:h.body,children:[s&&(0,a.jsx)("div",{dangerouslySetInnerHTML:{__html:(0,r.renderMarkdown)(s)}}),o]})]})]})}const l=e=>({box:(0,s.css)({background:e.colors.background.secondary,padding:e.spacing(1),borderRadius:e.shape.borderRadius(),position:"relative"}),boxInner:(0,s.css)({marginLeft:e.spacing(4)}),stepNumber:(0,s.css)({fontWeight:e.typography.fontWeightMedium,background:e.colors.secondary.main,width:"20px",height:"20px",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",position:"absolute",top:"10px",left:"11px",fontSize:e.typography.bodySmall.fontSize}),header:(0,s.css)({paddingBottom:e.spacing(.5),display:"flex",alignItems:"center",fontFamily:e.typography.fontFamilyMonospace}),body:(0,s.css)({color:e.colors.text.secondary,"p:last-child":{margin:0},a:{color:e.colors.text.link,textDecoration:"underline"}})})},13177:(e,t,i)=>{"use strict";i.d(t,{P:()=>C});var s,r=i(36636),n=i(68404),a=i(48435),o=i(29990),l=i(20002),h=i(90747),u=i(69783),c=i(59418),d=i(43215),p=i(45916);const f=n.memo((e=>{let{def:t,operation:i}=e;const r=(0,u.useStyles2)(g),[a,o]=(0,n.useState)(!1),{getTooltipProps:l,setTooltipRef:d,setTriggerRef:f,visible:y}=(0,c.O)({placement:"top",visible:a,offset:[0,16],onVisibleChange:o,interactive:!0,trigger:["click"]});return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(u.Button,{title:"Click to show description",ref:f,icon:"info-circle",size:"sm",variant:"secondary",fill:"text"}),y&&(0,p.jsx)(u.Portal,{children:(0,p.jsxs)("div",Object.assign({ref:d},l(),{className:r.docBox,children:[(0,p.jsxs)("div",{className:r.docBoxHeader,children:[(0,p.jsx)("span",{children:t.renderer(i,t,"<expr>")}),s||(s=(0,p.jsx)(h.FlexItem,{grow:1})),(0,p.jsx)(u.Button,{icon:"times",onClick:()=>o(!1),fill:"text",variant:"secondary",title:"Remove operation"})]}),(0,p.jsx)("div",{className:r.docBoxBody,dangerouslySetInnerHTML:{__html:m(t,i)}})]}))})]})}));f.displayName="OperationDocs";const g=e=>({docBox:(0,r.css)({overflow:"hidden",background:e.colors.background.primary,border:`1px solid ${e.colors.border.strong}`,boxShadow:e.shadows.z3,maxWidth:"600px",padding:e.spacing(1),borderRadius:e.shape.borderRadius(),zIndex:e.zIndex.tooltip}),docBoxHeader:(0,r.css)({fontSize:e.typography.h5.fontSize,fontFamily:e.typography.fontFamilyMonospace,paddingBottom:e.spacing(1),display:"flex",alignItems:"center"}),docBoxBody:(0,r.css)({marginBottom:e.spacing(-1),color:e.colors.text.secondary}),signature:(0,r.css)({fontSize:e.typography.bodySmall.fontSize,fontFamily:e.typography.fontFamilyMonospace}),dropdown:(0,r.css)({opacity:0,color:e.colors.text.secondary})});function m(e,t){var i;return(0,d.renderMarkdown)(e.explainHandler?e.explainHandler(t,e):null!==(i=e.documentation)&&void 0!==i?i:"no docs")}var y;const O=n.memo((e=>{var t;let{operation:i,def:s,index:r,onChange:a,onRemove:o,queryModeller:l,dragHandleProps:c}=e;const d=(0,u.useStyles2)(b),[g,m]=(0,n.useState)({}),O=()=>{if(g.isOpen)m(Object.assign({},g,{isOpen:!1}));else{const e=l.getAlternativeOperations(s.alternativesKey).map((e=>({label:e.name,value:e})));m({isOpen:!0,alternatives:e})}};return(0,p.jsxs)("div",{className:d.header,children:[!g.isOpen&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("div",Object.assign({},c,{children:null!==(t=s.name)&&void 0!==t?t:s.id})),y||(y=(0,p.jsx)(h.FlexItem,{grow:1})),(0,p.jsxs)("div",{className:`${d.operationHeaderButtons} operation-header-show-on-hover`,children:[(0,p.jsx)(u.Button,{icon:"angle-down",size:"sm",onClick:O,fill:"text",variant:"secondary",title:"Click to view alternative operations"}),(0,p.jsx)(f,{def:s,operation:i}),(0,p.jsx)(u.Button,{icon:"times",size:"sm",onClick:()=>o(r),fill:"text",variant:"secondary",title:"Remove operation"})]})]}),g.isOpen&&(0,p.jsx)("div",{className:d.selectWrapper,children:(0,p.jsx)(u.Select,{autoFocus:!0,openMenuOnFocus:!0,placeholder:"Replace with",options:g.alternatives,isOpen:!0,onCloseMenu:O,onChange:e=>{if(e.value){const t=l.getOperationDef(e.value.id),n=[...t.defaultParams];for(let e=0;e<Math.min(i.params.length,n.length);e++)t.params[e].type===s.params[e].type&&(n[e]=i.params[e]);const o=Object.assign({},i,{params:n,id:e.value.id});a(r,s.changeTypeHandler?s.changeTypeHandler(o,t):o)}}})})]})}));O.displayName="OperationHeader";const b=e=>({header:(0,r.css)({borderBottom:`1px solid ${e.colors.border.medium}`,padding:e.spacing(.5,.5,.5,1),display:"flex",alignItems:"center","&:hover .operation-header-show-on-hover":(0,r.css)({opacity:1})}),operationHeaderButtons:(0,r.css)({opacity:0,transition:e.transitions.create(["opacity"],{duration:e.transitions.duration.short})}),selectWrapper:(0,r.css)({paddingRight:e.spacing(2)})});var x=i(64722),v=i(19093);function $(e){return e.editor?e.editor:e.options?_:"boolean"===e.type?w:k}function k(e){var t;return(0,p.jsx)(x.H,{id:(0,v.i1)(e.operationIndex,e.index),defaultValue:null===(t=e.value)||void 0===t?void 0:t.toString(),minWidth:e.paramDef.minWidth,placeholder:e.paramDef.placeholder,title:e.paramDef.description,onCommitChange:t=>{e.onChange(e.index,t.currentTarget.value),e.paramDef.runQueryOnEnter&&"keydown"===t.type&&e.onRunQuery()}})}function w(e){return(0,p.jsx)(u.Checkbox,{id:(0,v.i1)(e.operationIndex,e.index),value:e.value,onChange:t=>e.onChange(e.index,t.currentTarget.checked)})}function _(e){var t,i;let{paramDef:s,value:r,index:n,operationIndex:a,onChange:o}=e,l=s.options;null!==(t=l[0])&&void 0!==t&&t.label||(l=s.options.map((e=>({label:e.toString(),value:e}))));let h=null!==(i=l.find((e=>e.value===r)))&&void 0!==i?i:(0,d.toOption)(r);return(0,p.jsx)(u.Select,{id:(0,v.i1)(a,n),value:h,options:l,placeholder:s.placeholder,allowCustomValue:!0,onChange:e=>o(n,e.value)})}function P(e){let{operation:t,index:i,onRemove:s,onChange:o,onRunQuery:l,queryModeller:c,query:d,datasource:f,highlight:g}=e;const m=(0,u.useStyles2)(Q),y=c.getOperationDef(t.id),b=function(e){const[t,i]=(0,n.useState)(!0);return(0,n.useEffect)((()=>{let t;return e?t=setTimeout((()=>{i(!1)}),1):i(!0),()=>clearTimeout(t)}),[e]),t&&e}(g);if(!y)return(0,p.jsxs)("span",{children:["Operation ",t.id," not found"]});const x=(e,s)=>{const r=Object.assign({},t,{params:[...t.params]});r.params[e]=s,S(y,r,i,e,o)},k=()=>{const e=Object.assign({},t,{params:[...t.params,""]});S(y,e,i,t.params.length,o)},w=e=>{const s=Object.assign({},t,{params:[...t.params.slice(0,e),...t.params.slice(e+1)]});S(y,s,i,e,o)},_=[];for(let e=0;e<t.params.length;e++){const s=y.params[Math.min(y.params.length-1,e)],r=$(s);_.push((0,p.jsxs)("div",{className:m.paramRow,children:[!s.hideName&&(0,p.jsxs)("div",{className:m.paramName,children:[(0,p.jsx)("label",{htmlFor:(0,v.i1)(i,e),children:s.name}),s.description&&(0,p.jsx)(u.Tooltip,{placement:"top",content:s.description,theme:"info",children:(0,p.jsx)(u.Icon,{name:"info-circle",size:"sm",className:m.infoIcon})})]}),(0,p.jsx)("div",{className:m.paramValue,children:(0,p.jsxs)(h.Stack,{gap:.5,direction:"row",alignItems:"center",wrap:!1,children:[(0,p.jsx)(r,{index:e,paramDef:s,value:t.params[e],operation:t,operationIndex:i,onChange:x,onRunQuery:l,query:d,datasource:f}),s.restParam&&(t.params.length>y.params.length||s.optional)&&(0,p.jsx)(u.Button,{"data-testid":`operations.${i}.remove-rest-param`,size:"sm",fill:"text",icon:"times",variant:"secondary",title:`Remove ${s.name}`,onClick:()=>w(e)})]})})]},`${e}-1`))}let P;if(y.params.length>0){const e=y.params[y.params.length-1];e.restParam&&(P=function(e,t,i,s,r){return(0,p.jsx)("div",{className:r.restParam,children:(0,p.jsx)(u.Button,{size:"sm",icon:"plus",title:`Add ${e.name}`,variant:"secondary",onClick:t,"data-testid":`operations.${i}.add-rest-param`,children:e.name})},`${s}-2`)}(e,k,i,t.params.length,m))}return(0,p.jsx)(a._l,{draggableId:`operation-${i}`,index:i,children:e=>(0,p.jsxs)("div",Object.assign({className:(0,r.cx)(m.card,b&&m.cardHighlight),ref:e.innerRef},e.draggableProps,{"data-testid":`operations.${i}.wrapper`,children:[(0,p.jsx)(O,{operation:t,dragHandleProps:e.dragHandleProps,def:y,index:i,onChange:o,onRemove:s,queryModeller:c}),(0,p.jsx)("div",{className:m.body,children:_}),P,i<d.operations.length-1&&(0,p.jsxs)("div",{className:m.arrow,children:[(0,p.jsx)("div",{className:m.arrowLine}),(0,p.jsx)("div",{className:m.arrowArrow})]})]}))})}function S(e,t,i,s,r){e.paramChangedHandler?r(i,e.paramChangedHandler(s,t,e)):r(i,t)}const Q=e=>({card:(0,r.css)({background:e.colors.background.primary,border:`1px solid ${e.colors.border.medium}`,display:"flex",flexDirection:"column",cursor:"grab",borderRadius:e.shape.borderRadius(1),marginBottom:e.spacing(1),position:"relative",transition:"all 1s ease-in 0s"}),cardHighlight:(0,r.css)({boxShadow:`0px 0px 4px 0px ${e.colors.primary.border}`,border:`1px solid ${e.colors.primary.border}`}),infoIcon:(0,r.css)({marginLeft:e.spacing(.5),color:e.colors.text.secondary,":hover":{color:e.colors.text.primary}}),body:(0,r.css)({margin:e.spacing(1,1,.5,1),display:"table"}),paramRow:(0,r.css)({label:"paramRow",display:"table-row",verticalAlign:"middle"}),paramName:(0,r.css)({display:"table-cell",padding:e.spacing(0,1,0,0),fontSize:e.typography.bodySmall.fontSize,fontWeight:e.typography.fontWeightMedium,verticalAlign:"middle",height:"32px"}),paramValue:(0,r.css)({label:"paramValue",display:"table-cell",verticalAlign:"middle"}),restParam:(0,r.css)({padding:e.spacing(0,1,1,1)}),arrow:(0,r.css)({position:"absolute",top:"0",right:"-18px",display:"flex"}),arrowLine:(0,r.css)({height:"2px",width:"8px",backgroundColor:e.colors.border.strong,position:"relative",top:"14px"}),arrowArrow:(0,r.css)({width:0,height:0,borderTop:"5px solid transparent",borderBottom:"5px solid transparent",borderLeft:`7px solid ${e.colors.border.strong}`,position:"relative",top:"10px"})});function C(e){let{query:t,datasource:i,queryModeller:s,onChange:r,onRunQuery:c}=e;const d=(0,u.useStyles2)(T),{operations:f}=t,g=function(e){const t=(0,o.Z)(),i=(0,l.Z)(e);if(!t())return e.map((()=>!1));if(!i)return e.map((()=>!0));let s=[];if(i.length-1===e.length&&e.every((e=>i.includes(e))))return e.map((()=>!1));if(i.length+1===e.length&&i.every((t=>e.includes(t)))){const t=e.find((e=>!i.includes(e)));s=e.map((e=>e===t))}else s=e.map(((e,t)=>{var s,r,n;return r=e.id,n=null===(s=i[t])||void 0===s?void 0:s.id,!(r===n||`__${r}_by`===n||r===`__${n}_by`)}));return s}(f),[m,y]=(0,n.useState)(!1),O=(e,i)=>{const s=[...f];s.splice(e,1,i),r(Object.assign({},t,{operations:s}))},b=e=>{const i=[...f.slice(0,e),...f.slice(e+1)];r(Object.assign({},t,{operations:i}))},x=s.getCategories().map((e=>({value:e,label:e,items:s.getOperationsForCategory(e).map((e=>({value:e.id,label:e.name,isLeaf:!0})))})));return(0,p.jsx)(h.Stack,{gap:1,direction:"column",children:(0,p.jsxs)(h.Stack,{gap:1,children:[f.length>0&&(0,p.jsx)(a.Z5,{onDragEnd:e=>{if(!e.destination)return;const i=[...f],s=i[e.source.index];i.splice(e.source.index,1),i.splice(e.destination.index,0,s),r(Object.assign({},t,{operations:i}))},children:(0,p.jsx)(a.bK,{droppableId:"sortable-field-mappings",direction:"horizontal",children:e=>(0,p.jsxs)("div",Object.assign({className:d.operationList,ref:e.innerRef},e.droppableProps,{children:[f.map(((e,r)=>(0,p.jsx)(P,{queryModeller:s,index:r,operation:e,query:t,datasource:i,onChange:O,onRemove:b,onRunQuery:c,highlight:g[r]},e.id+r))),e.placeholder]}))})}),(0,p.jsx)("div",{className:d.addButton,children:m?(0,p.jsx)(u.Cascader,{options:x,onSelect:e=>{const i=s.getOperationDef(e);i&&(r(i.addOperationHandler(i,t,s)),y(!1))},onBlur:()=>{y(!1)},autoFocus:!0,alwaysOpen:!0,hideActiveLevelLabel:!0,placeholder:"Search"}):(0,p.jsx)(u.Button,{icon:"plus",variant:"secondary",onClick:()=>y(!0),title:"Add operation",children:"Operations"})})]})})}const T=e=>({heading:(0,r.css)({label:"heading",fontSize:12,fontWeight:e.typography.fontWeightMedium,marginBottom:0}),operationList:(0,r.css)({label:"operationList",display:"flex",flexWrap:"wrap",gap:e.spacing(2)}),addButton:(0,r.css)({label:"addButton",width:126,paddingBottom:e.spacing(1)})})},74929:(e,t,i)=>{"use strict";i.d(t,{V:()=>a});i(68404);var s=i(2926),r=i(3690),n=i(45916);function a(e){let{query:t,queryModeller:i,stepNumber:a,lang:o}=e;return(0,n.jsx)(n.Fragment,{children:t.operations.map(((e,t)=>{var l;const h=i.getOperationDef(e.id);if(!h)return`Operation ${e.id} not found`;const u=h.renderer(e,h,"<expr>"),c=h.explainHandler?h.explainHandler(e,h):null!==(l=h.documentation)&&void 0!==l?l:"no docs";return(0,n.jsx)(s.B,{stepNumber:t+a,title:(0,n.jsx)(r.U,{query:u,lang:o}),markdown:c},t)}))})}},77441:(e,t,i)=>{"use strict";i.d(t,{B:()=>o});var s=i(36636),r=(i(68404),i(90747)),n=i(69783),a=i(45916);function o(e){let{children:t}=e;const i=(0,n.useStyles2)(l);return(0,a.jsx)("div",{className:i.root,children:(0,a.jsx)(r.Stack,{gap:1,children:t})})}const l=e=>({root:(0,s.css)({padding:e.spacing(1,1,0,1),backgroundColor:e.colors.background.secondary,borderRadius:e.shape.borderRadius(1)})})},50966:(e,t,i)=>{"use strict";i.d(t,{k:()=>l});var s=i(36636),r=(i(68404),i(69783)),n=i(7524),a=i(45916);const o=[{label:"Explain",value:n.c.Explain},{label:"Builder",value:n.c.Builder,component:()=>(0,a.jsx)(r.Tag,{className:(0,s.css)({fontSize:10,padding:"1px 5px",verticalAlign:"text-bottom"}),name:"Beta",colorIndex:1})},{label:"Code",value:n.c.Code}];function l(e){let{mode:t,onChange:i}=e;return(0,a.jsx)("div",{"data-testid":"QueryEditorModeToggle",children:(0,a.jsx)(r.RadioButtonGroup,{options:o,size:"sm",value:t,onChange:i})})}},82631:(e,t,i)=>{"use strict";i.d(t,{n:()=>u});var s=i(36636),r=i(82897),n=i(68404),a=i(90747),o=i(69783),l=i(45916);const h=["label"];function u(e){let{label:t}=e,i=function(e,t){if(null==e)return{};var i,s,r={},n=Object.keys(e);for(s=0;s<n.length;s++)i=n[s],t.indexOf(i)>=0||(r[i]=e[i]);return r}(e,h);const s=t.replace(" ","-"),u=(0,n.useRef)((0,r.uniqueId)(`switch-${s}`)),d=(0,o.useStyles2)(c);return(0,l.jsxs)(a.Stack,{gap:1,children:[(0,l.jsx)("label",{htmlFor:u.current,className:d.switchLabel,children:t}),(0,l.jsx)(o.Switch,Object.assign({},i,{id:u.current}))]})}const c=e=>({switchLabel:(0,s.css)({color:e.colors.text.secondary,cursor:"pointer",fontSize:e.typography.bodySmall.fontSize,"&:hover":{color:e.colors.text.primary}})})},68374:(e,t,i)=>{"use strict";i.d(t,{d:()=>l});var s=i(36636),r=(i(68404),i(17433)),n=i(90747),a=i(69783),o=i(45916);function l(e){let{title:t,children:i,collapsedInfo:s}=e;const[l,u]=(0,r.Z)(!1),c=(0,a.useStyles2)(h);return(0,o.jsxs)(n.Stack,{gap:0,direction:"column",children:[(0,o.jsxs)("div",{className:c.header,onClick:u,title:"Click to edit options",children:[(0,o.jsx)("div",{className:c.toggle,children:(0,o.jsx)(a.Icon,{name:l?"angle-down":"angle-right"})}),(0,o.jsx)("h6",{className:c.title,children:t}),!l&&(0,o.jsx)("div",{className:c.description,children:s.map(((e,t)=>(0,o.jsx)("span",{children:e},t)))})]}),l&&(0,o.jsx)("div",{className:c.body,children:i})]})}const h=e=>({switchLabel:(0,s.css)({color:e.colors.text.secondary,cursor:"pointer",fontSize:e.typography.bodySmall.fontSize,"&:hover":{color:e.colors.text.primary}}),header:(0,s.css)({display:"flex",cursor:"pointer",alignItems:"baseline",color:e.colors.text.primary,"&:hover":{background:e.colors.emphasize(e.colors.background.primary,.03)}}),title:(0,s.css)({flexGrow:1,overflow:"hidden",fontSize:e.typography.bodySmall.fontSize,fontWeight:e.typography.fontWeightMedium,margin:0}),description:(0,s.css)({color:e.colors.text.secondary,fontSize:e.typography.bodySmall.fontSize,paddingLeft:e.spacing(2),gap:e.spacing(2),display:"flex"}),body:(0,s.css)({display:"flex",paddingTop:e.spacing(2),gap:e.spacing(2),flexWrap:"wrap"}),toggle:(0,s.css)({color:e.colors.text.secondary,marginRight:`${e.spacing(1)}`})})},3690:(e,t,i)=>{"use strict";i.d(t,{U:()=>l});var s=i(36636),r=i(50539),n=i.n(r),a=(i(68404),i(69783)),o=i(45916);function l(e){let{query:t,lang:i}=e;const r=(0,a.useTheme2)(),l=h(r),u=n().highlight(t,i.grammar,i.name);return(0,o.jsx)("div",{className:(0,s.cx)(l.editorField,"prism-syntax-highlight"),"aria-label":"selector",dangerouslySetInnerHTML:{__html:u}})}const h=e=>({editorField:(0,s.css)({fontFamily:e.typography.fontFamilyMonospace,fontSize:e.typography.bodySmall.fontSize})})},19093:(e,t,i)=>{"use strict";i.d(t,{IT:()=>O,NZ:()=>d,PP:()=>f,Z3:()=>b,e8:()=>c,i1:()=>m,kq:()=>y,pS:()=>l,t7:()=>g,zJ:()=>h});var s=i(82897),r=i(71788),n=i.n(r),a=i(47908),o=i(12524);function l(e,t,i){const s=p(e,t,i),r=e.id+"(";return i&&s.push(i),r+s.join(", ")+")"}function h(e,t,i){const s=p(e,t,i),r=e.id+"(";return i&&s.unshift(i),r+s.join(", ")+")"}function u(e,t,i,s){var r,n;if(t.params.length<2)throw`Cannot render a function with params of length [${t.params.length}]`;let a=null!==(r=(null!==(n=e.params)&&void 0!==n?n:[])[0])&&void 0!==r?r:"5m";const o=p(Object.assign({},e,{params:e.params.slice(1)}),Object.assign({},t,{params:t.params.slice(1),defaultParams:t.defaultParams.slice(1)}),i),l=e.id+"(";return i&&(s?o.push(`${i}[${a}]`):o.unshift(`${i}[${a}]`)),l+o.join(", ")+")"}function c(e,t,i){return u(e,t,i,!1)}function d(e,t,i){return u(e,t,i,!0)}function p(e,t,i){var s;return(null!==(s=e.params)&&void 0!==s?s:[]).map(((e,i)=>"string"===t.params[i].type?'"'+e+'"':e))}function f(e,t){const i={id:e.id,params:e.defaultParams};return Object.assign({},t,{operations:[...t.operations,i]})}function g(e){return(0,s.capitalize)(e.replace(/_/g," "))}function m(e,t){return`operations.${e}.param.${t}`}function y(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const t={name:"Range",type:"string",options:[{label:"$__interval",value:"$__interval"},{label:"1m",value:"1m"},{label:"5m",value:"5m"},{label:"10m",value:"10m"},{label:"1h",value:"1h"},{label:"24h",value:"24h"}]};return e&&t.options.unshift({label:"$__rate_interval",value:"$__rate_interval"}),t}function O(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i=[Object.assign({id:e,name:g(e),params:[{name:"By label",type:"string",restParam:!0,optional:!0}],defaultParams:[],alternativesKey:"plain aggregations",category:o.C.Aggregations,renderer:l,paramChangedHandler:_(`__${e}_by`),explainHandler:$(e,""),addOperationHandler:f},t),Object.assign({id:`__${e}_by`,name:`${g(e)} by`,params:[{name:"Label",type:"string",restParam:!0,optional:!0,editor:a.g}],defaultParams:[""],alternativesKey:"aggregations by",category:o.C.Aggregations,renderer:x(e),paramChangedHandler:w(e),explainHandler:$(e,"by"),addOperationHandler:f,hideFromList:!0},t),Object.assign({id:`__${e}_without`,name:`${g(e)} without`,params:[{name:"Label",type:"string",restParam:!0,optional:!0,editor:a.g}],defaultParams:[""],alternativesKey:"aggregations by",category:o.C.Aggregations,renderer:v(e),paramChangedHandler:w(e),explainHandler:$(e,"without"),addOperationHandler:f,hideFromList:!0},t)];return i}function b(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const s=O(e,i);return s[0].params.unshift(...t.params),s[1].params.unshift(...t.params),s[2].params.unshift(...t.params),s[0].defaultParams=t.defaultParams,s[1].defaultParams=[...t.defaultParams,""],s[2].defaultParams=[...t.defaultParams,""],s[1].renderer=k(e),s[2].renderer=k(e),s}function x(e){return function(t,i,s){return`${e} by(${t.params.join(", ")}) (${s})`}}function v(e){return function(t,i,s){return`${e} without(${t.params.join(", ")}) (${s})`}}function $(e,t){return function(i){const s=i.params.map((e=>`\`${e}\``)).join(" and "),r=n()("label",i.params.length);switch(t){case"by":return`Calculates ${e} over dimensions while preserving ${r} ${s}.`;case"without":return`Calculates ${e} over the dimensions ${s}. All other labels are preserved.`;default:return`Calculates ${e} over the dimensions.`}}}function k(e){return function(t,i,s){const r=i.params.findIndex((e=>e.restParam)),n=t.params.slice(0,r),a=t.params.slice(r);return`${e} by(${a.join(", ")}) (${n.map(((e,t)=>"string"===i.params[t].type?`"${e}"`:e)).join(", ")}, ${s})`}}function w(e){return function(t,i,s){return i.params.length<s.params.length?Object.assign({},i,{id:e}):i}}function _(e){return function(t,i,s){return i.params.length===s.params.length?Object.assign({},i,{id:e}):i}}},25890:(e,t,i)=>{"use strict";i.d(t,{Es:()=>u,GQ:()=>s,KF:()=>h,bU:()=>o,ff:()=>c,ge:()=>r,wf:()=>n});const s="⚠";function r(e){return e.firstChild?r(e.firstChild):e}function n(e,t){var i;return{text:h(e,t),from:t.from,to:t.to,parentType:null===(i=t.parent)||void 0===i?void 0:i.name}}const a=/\$(\w+)|\[\[([\s\S]+?)(?::(\w+))?\]\]|\${(\w+)(?:\.([^:^\}]+))?(?::([^\}]+))?}/g;function o(e){return e.replace(a,((e,t,i,s,r,n,a)=>{const o=s||a;let l=t,h="0";return i&&(l=i,h="1"),r&&(l=r,h="2"),`__V_${h}__`+l+"__V__"+(o?"__F__"+o+"__F__":"")}))}const l=[(e,t)=>`$${e}`,(e,t)=>`[[${e}${t?`:${t}`:""}]]`,(e,t)=>`\${${e}${t?`:${t}`:""}}`];function h(e,t){return t?function(e){return e.replace(/__V_(\d)__(.+?)__V__(?:__F__(\w+)__F__)?/g,((e,t,i,s)=>l[parseInt(t,10)](i,s)))}(e.substring(t.from,t.to)):""}function u(e,t,i,s){const r=[parseFloat(h(t,i))];return e.comparison&&r.push(s),{id:e.id,params:r}}function c(e,t,i){if(t.name===i)return[h(e,t)];const s=[];let r=0,n=t.childAfter(r);for(;n;)s.push(...c(e,n,i)),r=n.to,n=t.childAfter(r);return s}},7524:(e,t,i)=>{"use strict";let s;i.d(t,{c:()=>s}),function(e){e.Code="code",e.Builder="builder",e.Explain="explain"}(s||(s={}))},12524:(e,t,i)=>{"use strict";let s,r;i.d(t,{C:()=>s,G:()=>r}),function(e){e.Aggregations="Aggregations",e.RangeFunctions="Range functions",e.Functions="Functions",e.BinaryOps="Binary operations",e.Trigonometric="Trigonometric",e.Time="Time Functions"}(s||(s={})),function(e){e.Abs="abs",e.Absent="absent",e.AbsentOverTime="absent_over_time",e.Acos="acos",e.Acosh="acosh",e.Asin="asin",e.Asinh="asinh",e.Atan="atan",e.Atanh="atanh",e.Avg="avg",e.AvgOverTime="avg_over_time",e.BottomK="bottomk",e.Ceil="ceil",e.Changes="changes",e.Clamp="clamp",e.ClampMax="clamp_max",e.ClampMin="clamp_min",e.Cos="cos",e.Cosh="cosh",e.Count="count",e.CountOverTime="count_over_time",e.CountScalar="count_scalar",e.CountValues="count_values",e.DayOfMonth="day_of_month",e.DayOfWeek="day_of_week",e.DaysInMonth="days_in_month",e.Deg="deg",e.Delta="delta",e.Deriv="deriv",e.DropCommonLabels="drop_common_labels",e.Exp="exp",e.Floor="floor",e.Group="group",e.HistogramQuantile="histogram_quantile",e.HoltWinters="holt_winters",e.Hour="hour",e.Idelta="idelta",e.Increase="increase",e.Irate="irate",e.LabelJoin="label_join",e.LabelReplace="label_replace",e.Last="last",e.LastOverTime="last_over_time",e.Ln="ln",e.Log10="log10",e.Log2="log2",e.Max="max",e.MaxOverTime="max_over_time",e.Min="min",e.MinOverTime="min_over_time",e.Minute="minute",e.Month="month",e.Pi="pi",e.PredictLinear="predict_linear",e.Present="present",e.PresentOverTime="present_over_time",e.Quantile="quantile",e.QuantileOverTime="quantile_over_time",e.Rad="rad",e.Rate="rate",e.Resets="resets",e.Round="round",e.Scalar="scalar",e.Sgn="sgn",e.Sin="sin",e.Sinh="sinh",e.Sort="sort",e.SortDesc="sort_desc",e.Sqrt="sqrt",e.Stddev="stddev",e.StddevOverTime="stddev_over_time",e.Sum="sum",e.SumOverTime="sum_over_time",e.Tan="tan",e.Tanh="tanh",e.Time="time",e.Timestamp="timestamp",e.TopK="topk",e.Vector="vector",e.Year="year",e.Addition="__addition",e.Subtraction="__subtraction",e.MultiplyBy="__multiply_by",e.DivideBy="__divide_by",e.Modulo="__modulo",e.Exponent="__exponent",e.NestedQuery="__nested_query",e.EqualTo="__equal_to",e.NotEqualTo="__not_equal_to",e.GreaterThan="__greater_than",e.LessThan="__less_than",e.GreaterOrEqual="__greater_or_equal",e.LessOrEqual="__less_or_equal"}(r||(r={}))},20002:(e,t,i)=>{"use strict";i.d(t,{Z:()=>r});var s=i(68404);function r(e){var t=(0,s.useRef)();return(0,s.useEffect)((function(){t.current=e})),t.current}},64303:e=>{const t="object"==typeof performance&&performance&&"function"==typeof performance.now?performance:Date,i="function"==typeof AbortController,s=i?AbortController:class{constructor(){this.signal=new r}abort(){this.signal.dispatchEvent("abort")}},r=i?AbortSignal:class{constructor(){this.aborted=!1,this._listeners=[]}dispatchEvent(e){if("abort"===e){this.aborted=!0;const t={type:e,target:this};this.onabort(t),this._listeners.forEach((e=>e(t)),this)}}onabort(){}addEventListener(e,t){"abort"===e&&this._listeners.push(t)}removeEventListener(e,t){"abort"===e&&(this._listeners=this._listeners.filter((e=>e!==t)))}},n=new Set,a=(e,t)=>{const i=`LRU_CACHE_OPTION_${e}`;h(i)&&u(i,`${e} option`,`options.${t}`,g)},o=(e,t)=>{const i=`LRU_CACHE_METHOD_${e}`;if(h(i)){const{prototype:s}=g,{get:r}=Object.getOwnPropertyDescriptor(s,e);u(i,`${e} method`,`cache.${t}()`,r)}},l=(...e)=>{"object"==typeof process&&process&&"function"==typeof process.emitWarning?process.emitWarning(...e):console.error(...e)},h=e=>!n.has(e),u=(e,t,i,s)=>{n.add(e);l(`The ${t} is deprecated. Please use ${i} instead.`,"DeprecationWarning",e,s)},c=e=>e&&e===Math.floor(e)&&e>0&&isFinite(e),d=e=>c(e)?e<=Math.pow(2,8)?Uint8Array:e<=Math.pow(2,16)?Uint16Array:e<=Math.pow(2,32)?Uint32Array:e<=Number.MAX_SAFE_INTEGER?p:null:null;class p extends Array{constructor(e){super(e),this.fill(0)}}class f{constructor(e){if(0===e)return[];const t=d(e);this.heap=new t(e),this.length=0}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}}class g{constructor(e={}){const{max:t=0,ttl:i,ttlResolution:s=1,ttlAutopurge:r,updateAgeOnGet:o,updateAgeOnHas:u,allowStale:p,dispose:m,disposeAfter:y,noDisposeOnSet:O,noUpdateTTL:b,maxSize:x=0,sizeCalculation:v,fetchMethod:$,noDeleteOnFetchRejection:k}=e,{length:w,maxAge:_,stale:P}=e instanceof g?{}:e;if(0!==t&&!c(t))throw new TypeError("max option must be a nonnegative integer");const S=t?d(t):Array;if(!S)throw new Error("invalid max value: "+t);if(this.max=t,this.maxSize=x,this.sizeCalculation=v||w,this.sizeCalculation){if(!this.maxSize)throw new TypeError("cannot set sizeCalculation without setting maxSize");if("function"!=typeof this.sizeCalculation)throw new TypeError("sizeCalculation set to non-function")}if(this.fetchMethod=$||null,this.fetchMethod&&"function"!=typeof this.fetchMethod)throw new TypeError("fetchMethod must be a function if specified");if(this.keyMap=new Map,this.keyList=new Array(t).fill(null),this.valList=new Array(t).fill(null),this.next=new S(t),this.prev=new S(t),this.head=0,this.tail=0,this.free=new f(t),this.initialFill=1,this.size=0,"function"==typeof m&&(this.dispose=m),"function"==typeof y?(this.disposeAfter=y,this.disposed=[]):(this.disposeAfter=null,this.disposed=null),this.noDisposeOnSet=!!O,this.noUpdateTTL=!!b,this.noDeleteOnFetchRejection=!!k,0!==this.maxSize){if(!c(this.maxSize))throw new TypeError("maxSize must be a positive integer if specified");this.initializeSizeTracking()}if(this.allowStale=!!p||!!P,this.updateAgeOnGet=!!o,this.updateAgeOnHas=!!u,this.ttlResolution=c(s)||0===s?s:1,this.ttlAutopurge=!!r,this.ttl=i||_||0,this.ttl){if(!c(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.initializeTTLTracking()}if(0===this.max&&0===this.ttl&&0===this.maxSize)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.max&&!this.maxSize){const e="LRU_CACHE_UNBOUNDED";if(h(e)){n.add(e);l("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",e,g)}}P&&a("stale","allowStale"),_&&a("maxAge","ttl"),w&&a("length","sizeCalculation")}getRemainingTTL(e){return this.has(e,{updateAgeOnHas:!1})?1/0:0}initializeTTLTracking(){this.ttls=new p(this.max),this.starts=new p(this.max),this.setItemTTL=(e,i)=>{if(this.starts[e]=0!==i?t.now():0,this.ttls[e]=i,0!==i&&this.ttlAutopurge){const t=setTimeout((()=>{this.isStale(e)&&this.delete(this.keyList[e])}),i+1);t.unref&&t.unref()}},this.updateItemAge=e=>{this.starts[e]=0!==this.ttls[e]?t.now():0};let e=0;const i=()=>{const i=t.now();if(this.ttlResolution>0){e=i;const t=setTimeout((()=>e=0),this.ttlResolution);t.unref&&t.unref()}return i};this.getRemainingTTL=t=>{const s=this.keyMap.get(t);return void 0===s?0:0===this.ttls[s]||0===this.starts[s]?1/0:this.starts[s]+this.ttls[s]-(e||i())},this.isStale=t=>0!==this.ttls[t]&&0!==this.starts[t]&&(e||i())-this.starts[t]>this.ttls[t]}updateItemAge(e){}setItemTTL(e,t){}isStale(e){return!1}initializeSizeTracking(){this.calculatedSize=0,this.sizes=new p(this.max),this.removeItemSize=e=>this.calculatedSize-=this.sizes[e],this.requireSize=(e,t,i,s)=>{if(!c(i)){if(!s)throw new TypeError("invalid size value (must be positive integer)");if("function"!=typeof s)throw new TypeError("sizeCalculation must be a function");if(i=s(t,e),!c(i))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}return i},this.addItemSize=(e,t,i,s)=>{this.sizes[e]=s;const r=this.maxSize-this.sizes[e];for(;this.calculatedSize>r;)this.evict(!0);this.calculatedSize+=this.sizes[e]}}removeItemSize(e){}addItemSize(e,t,i,s){}requireSize(e,t,i,s){if(i||s)throw new TypeError("cannot set size without setting maxSize on cache")}*indexes({allowStale:e=this.allowStale}={}){if(this.size)for(let t=this.tail;this.isValidIndex(t)&&(!e&&this.isStale(t)||(yield t),t!==this.head);)t=this.prev[t]}*rindexes({allowStale:e=this.allowStale}={}){if(this.size)for(let t=this.head;this.isValidIndex(t)&&(!e&&this.isStale(t)||(yield t),t!==this.tail);)t=this.next[t]}isValidIndex(e){return this.keyMap.get(this.keyList[e])===e}*entries(){for(const e of this.indexes())yield[this.keyList[e],this.valList[e]]}*rentries(){for(const e of this.rindexes())yield[this.keyList[e],this.valList[e]]}*keys(){for(const e of this.indexes())yield this.keyList[e]}*rkeys(){for(const e of this.rindexes())yield this.keyList[e]}*values(){for(const e of this.indexes())yield this.valList[e]}*rvalues(){for(const e of this.rindexes())yield this.valList[e]}[Symbol.iterator](){return this.entries()}find(e,t={}){for(const i of this.indexes())if(e(this.valList[i],this.keyList[i],this))return this.get(this.keyList[i],t)}forEach(e,t=this){for(const i of this.indexes())e.call(t,this.valList[i],this.keyList[i],this)}rforEach(e,t=this){for(const i of this.rindexes())e.call(t,this.valList[i],this.keyList[i],this)}get prune(){return o("prune","purgeStale"),this.purgeStale}purgeStale(){let e=!1;for(const t of this.rindexes({allowStale:!0}))this.isStale(t)&&(this.delete(this.keyList[t]),e=!0);return e}dump(){const e=[];for(const t of this.indexes()){const i=this.keyList[t],s={value:this.valList[t]};this.ttls&&(s.ttl=this.ttls[t]),this.sizes&&(s.size=this.sizes[t]),e.unshift([i,s])}return e}load(e){this.clear();for(const[t,i]of e)this.set(t,i.value,i)}dispose(e,t,i){}set(e,t,{ttl:i=this.ttl,noDisposeOnSet:s=this.noDisposeOnSet,size:r=0,sizeCalculation:n=this.sizeCalculation,noUpdateTTL:a=this.noUpdateTTL}={}){r=this.requireSize(e,t,r,n);let o=0===this.size?void 0:this.keyMap.get(e);if(void 0===o)o=this.newIndex(),this.keyList[o]=e,this.valList[o]=t,this.keyMap.set(e,o),this.next[this.tail]=o,this.prev[o]=this.tail,this.tail=o,this.size++,this.addItemSize(o,t,e,r),a=!1;else{const i=this.valList[o];t!==i&&(this.isBackgroundFetch(i)?i.__abortController.abort():s||(this.dispose(i,e,"set"),this.disposeAfter&&this.disposed.push([i,e,"set"])),this.removeItemSize(o),this.valList[o]=t,this.addItemSize(o,t,e,r)),this.moveToTail(o)}if(0===i||0!==this.ttl||this.ttls||this.initializeTTLTracking(),a||this.setItemTTL(o,i),this.disposeAfter)for(;this.disposed.length;)this.disposeAfter(...this.disposed.shift());return this}newIndex(){return 0===this.size?this.tail:this.size===this.max&&0!==this.max?this.evict(!1):0!==this.free.length?this.free.pop():this.initialFill++}pop(){if(this.size){const e=this.valList[this.head];return this.evict(!0),e}}evict(e){const t=this.head,i=this.keyList[t],s=this.valList[t];return this.isBackgroundFetch(s)?s.__abortController.abort():(this.dispose(s,i,"evict"),this.disposeAfter&&this.disposed.push([s,i,"evict"])),this.removeItemSize(t),e&&(this.keyList[t]=null,this.valList[t]=null,this.free.push(t)),this.head=this.next[t],this.keyMap.delete(i),this.size--,t}has(e,{updateAgeOnHas:t=this.updateAgeOnHas}={}){const i=this.keyMap.get(e);return void 0!==i&&!this.isStale(i)&&(t&&this.updateItemAge(i),!0)}peek(e,{allowStale:t=this.allowStale}={}){const i=this.keyMap.get(e);if(void 0!==i&&(t||!this.isStale(i)))return this.valList[i]}backgroundFetch(e,t,i){const r=void 0===t?void 0:this.valList[t];if(this.isBackgroundFetch(r))return r;const n=new s,a={signal:n.signal,options:i},o=new Promise((t=>t(this.fetchMethod(e,r,a)))).then((t=>(n.signal.aborted||this.set(e,t,a.options),t)),(s=>{if(this.valList[t]===o){!i.noDeleteOnFetchRejection||void 0===o.__staleWhileFetching?this.delete(e):this.valList[t]=o.__staleWhileFetching}if(o.__returned===o)throw s}));return o.__abortController=n,o.__staleWhileFetching=r,o.__returned=null,void 0===t?(this.set(e,o,a.options),t=this.keyMap.get(e)):this.valList[t]=o,o}isBackgroundFetch(e){return e&&"object"==typeof e&&"function"==typeof e.then&&Object.prototype.hasOwnProperty.call(e,"__staleWhileFetching")&&Object.prototype.hasOwnProperty.call(e,"__returned")&&(e.__returned===e||null===e.__returned)}async fetch(e,{allowStale:t=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,ttl:s=this.ttl,noDisposeOnSet:r=this.noDisposeOnSet,size:n=0,sizeCalculation:a=this.sizeCalculation,noUpdateTTL:o=this.noUpdateTTL,noDeleteOnFetchRejection:l=this.noDeleteOnFetchRejection}={}){if(!this.fetchMethod)return this.get(e,{allowStale:t,updateAgeOnGet:i});const h={allowStale:t,updateAgeOnGet:i,ttl:s,noDisposeOnSet:r,size:n,sizeCalculation:a,noUpdateTTL:o,noDeleteOnFetchRejection:l};let u=this.keyMap.get(e);if(void 0===u){const t=this.backgroundFetch(e,u,h);return t.__returned=t}{const s=this.valList[u];if(this.isBackgroundFetch(s))return t&&void 0!==s.__staleWhileFetching?s.__staleWhileFetching:s.__returned=s;if(!this.isStale(u))return this.moveToTail(u),i&&this.updateItemAge(u),s;const r=this.backgroundFetch(e,u,h);return t&&void 0!==r.__staleWhileFetching?r.__staleWhileFetching:r.__returned=r}}get(e,{allowStale:t=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet}={}){const s=this.keyMap.get(e);if(void 0!==s){const r=this.valList[s],n=this.isBackgroundFetch(r);if(this.isStale(s))return n?t?r.__staleWhileFetching:void 0:(this.delete(e),t?r:void 0);if(n)return;return this.moveToTail(s),i&&this.updateItemAge(s),r}}connect(e,t){this.prev[t]=e,this.next[e]=t}moveToTail(e){e!==this.tail&&(e===this.head?this.head=this.next[e]:this.connect(this.prev[e],this.next[e]),this.connect(this.tail,e),this.tail=e)}get del(){return o("del","delete"),this.delete}delete(e){let t=!1;if(0!==this.size){const i=this.keyMap.get(e);if(void 0!==i)if(t=!0,1===this.size)this.clear();else{this.removeItemSize(i);const t=this.valList[i];this.isBackgroundFetch(t)?t.__abortController.abort():(this.dispose(t,e,"delete"),this.disposeAfter&&this.disposed.push([t,e,"delete"])),this.keyMap.delete(e),this.keyList[i]=null,this.valList[i]=null,i===this.tail?this.tail=this.prev[i]:i===this.head?this.head=this.next[i]:(this.next[this.prev[i]]=this.next[i],this.prev[this.next[i]]=this.prev[i]),this.size--,this.free.push(i)}}if(this.disposed)for(;this.disposed.length;)this.disposeAfter(...this.disposed.shift());return t}clear(){for(const e of this.rindexes({allowStale:!0})){const t=this.valList[e];if(this.isBackgroundFetch(t))t.__abortController.abort();else{const i=this.keyList[e];this.dispose(t,i,"delete"),this.disposeAfter&&this.disposed.push([t,i,"delete"])}}if(this.keyMap.clear(),this.valList.fill(null),this.keyList.fill(null),this.ttls&&(this.ttls.fill(0),this.starts.fill(0)),this.sizes&&this.sizes.fill(0),this.head=0,this.tail=0,this.initialFill=1,this.free.length=0,this.calculatedSize=0,this.size=0,this.disposed)for(;this.disposed.length;)this.disposeAfter(...this.disposed.shift())}get reset(){return o("reset","clear"),this.clear}get length(){return((e,t)=>{const i=`LRU_CACHE_PROPERTY_${e}`;if(h(i)){const{prototype:s}=g,{get:r}=Object.getOwnPropertyDescriptor(s,e);u(i,`${e} property`,`cache.${t}`,r)}})("length","size"),this.size}static get AbortController(){return s}static get AbortSignal(){return r}}e.exports=g},98604:(e,t,i)=>{"use strict";i.d(t,{E2:()=>o});var s=i(85409);const r={inf:146,nan:147,bool:1,ignoring:2,on:3,group_left:4,group_right:5,offset:6},n={avg:8,atan2:7,bottomk:9,count:10,count_values:11,group:12,max:13,min:14,quantile:15,stddev:16,stdvar:17,sum:18,topk:19,by:20,without:21,and:22,or:23,unless:24,start:25,end:26},a={__proto__:null,absent_over_time:307,absent:309,abs:311,acos:313,acosh:315,asin:317,asinh:319,atan:321,atanh:323,avg_over_time:325,ceil:327,changes:329,clamp:331,clamp_max:333,clamp_min:335,cos:337,cosh:339,count_over_time:341,days_in_month:343,day_of_month:345,day_of_week:347,deg:349,delta:351,deriv:353,exp:355,floor:357,histogram_quantile:359,holt_winters:361,hour:363,idelta:365,increase:367,irate:369,label_replace:371,label_join:373,last_over_time:375,ln:377,log10:379,log2:381,max_over_time:383,min_over_time:385,minute:387,month:389,pi:391,predict_linear:393,present_over_time:395,quantile_over_time:397,rad:399,rate:401,resets:403,round:405,scalar:407,sgn:409,sin:411,sinh:413,sort:415,sort_desc:417,sqrt:419,stddev_over_time:421,stdvar_over_time:423,sum_over_time:425,tan:427,tanh:429,timestamp:431,time:433,vector:435,year:437},o=s.WQ.deserialize({version:13,states:"6[OYQPOOO&{QPOOOOQO'#C{'#C{O'QQPO'#CzQ']QQOOOOQO'#De'#DeO'WQPO'#DdOOQO'#E}'#E}O(jQPO'#FTOYQPO'#FPOYQPO'#FSOOQO'#FV'#FVO.fQSO'#FWO.nQQO'#FUOOQO'#FU'#FUOOQO'#Cy'#CyOOQO'#Df'#DfOOQO'#Dh'#DhOOQO'#Di'#DiOOQO'#Dj'#DjOOQO'#Dk'#DkOOQO'#Dl'#DlOOQO'#Dm'#DmOOQO'#Dn'#DnOOQO'#Do'#DoOOQO'#Dp'#DpOOQO'#Dq'#DqOOQO'#Dr'#DrOOQO'#Ds'#DsOOQO'#Dt'#DtOOQO'#Du'#DuOOQO'#Dv'#DvOOQO'#Dw'#DwOOQO'#Dx'#DxOOQO'#Dy'#DyOOQO'#Dz'#DzOOQO'#D{'#D{OOQO'#D|'#D|OOQO'#D}'#D}OOQO'#EO'#EOOOQO'#EP'#EPOOQO'#EQ'#EQOOQO'#ER'#EROOQO'#ES'#ESOOQO'#ET'#ETOOQO'#EU'#EUOOQO'#EV'#EVOOQO'#EW'#EWOOQO'#EX'#EXOOQO'#EY'#EYOOQO'#EZ'#EZOOQO'#E['#E[OOQO'#E]'#E]OOQO'#E^'#E^OOQO'#E_'#E_OOQO'#E`'#E`OOQO'#Ea'#EaOOQO'#Eb'#EbOOQO'#Ec'#EcOOQO'#Ed'#EdOOQO'#Ee'#EeOOQO'#Ef'#EfOOQO'#Eg'#EgOOQO'#Eh'#EhOOQO'#Ei'#EiOOQO'#Ej'#EjOOQO'#Ek'#EkOOQO'#El'#ElOOQO'#Em'#EmOOQO'#En'#EnOOQO'#Eo'#EoOOQO'#Ep'#EpOOQO'#Eq'#EqOOQO'#Er'#ErOOQO'#Es'#EsOOQO'#Et'#EtOOQO'#Eu'#EuOOQO'#Ev'#EvOOQO'#Ew'#EwOOQO'#Ex'#ExOOQO'#Ey'#EyOOQO'#Ez'#EzQOQPOOO0XQPO'#C|O0^QPO'#DRO'WQPO,59fO0eQQO,59fO2RQPO,59oO2RQPO,59oO2RQPO,59oO2RQPO,59oO2RQPO,59oO7}QQO,5;gO8SQQO,5;jO8[QPO,5;yOOQO,5:O,5:OOOQO,5;i,5;iO8sQQO,5;kO8zQQO,5;nO:bQPO'#FYO:pQPO,5;rOOQO'#FX'#FXOOQO,5;r,5;rOOQO,5;p,5;pO:xQSO'#C}OOQO,59h,59hO;QQPO,59mO;YQQO'#DSOOQO,59m,59mOOQO1G/Q1G/QO0XQPO'#DWOAVQPO'#DVOAaQPO'#DVOYQPO1G/ZOYQPO1G/ZOYQPO1G/ZOYQPO1G/ZOYQPO1G/ZOAkQSO1G1ROOQO1G1U1G1UOAsQQO1G1UOAxQPO'#E}OOQO'#Fa'#FaOOQO1G1e1G1eOBTQPO1G1eOOQO1G1V1G1VOOQO'#FZ'#FZOBYQPO,5;tOB_QSO1G1^OOQO1G1^1G1^OOQO'#DP'#DPOBgQPO,59iOOQO'#DO'#DOOOQO,59i,59iOYQPO,59nOOQO1G/X1G/XOOQO,59r,59rOH_QPO,59qOHfQPO,59qOI}QQO7+$uOJ_QQO7+$uOKsQQO7+$uOLZQQO7+$uOMrQQO7+$uOOQO7+&m7+&mON]QQO7+&sOOQO7+&p7+&pONeQPO7+'POOQO1G1`1G1`OOQO1G1_1G1_OOQO7+&x7+&xONjQSO1G/TOOQO1G/T1G/TONrQQO1G/YOOQO1G/]1G/]ON|QPO1G/]OOQO<<J_<<J_O!&oQPO<<J_OOQO<<Jk<<JkOOQO1G/U1G/UOOQO7+$o7+$oOOQO7+$w7+$wOOQOAN?yAN?y",stateData:"!&t~O$ZOSkOS~OWQOXQOYQOZQO[QO]QO^QO_QO`QOaQObQOcQO!ZZO#t_O$WVO$XVO$[XO$_`O$`aO$abO$bcO$cdO$deO$efO$fgO$ghO$hiO$ijO$jkO$klO$lmO$mnO$noO$opO$pqO$qrO$rsO$stO$tuO$uvO$vwO$wxO$xyO$yzO$z{O${|O$|}O$}!OO%O!PO%P!QO%Q!RO%R!SO%S!TO%T!UO%U!VO%V!WO%W!XO%X!YO%Y!ZO%Z![O%[!]O%]!^O%^!_O%_!`O%`!aO%a!bO%b!cO%c!dO%d!eO%e!fO%f!gO%g!hO%h!iO%i!jO%j!kO%k!lO%l!mO%m!nO%n!oO%o!pO%p!qO%q!rO%r!sO%uWO%vWO%wVO%y[O~O!ZZO~Od!uOe!uO$[!vO~OU#POV!yOf!|Og!}Oh!|Ox!yO{!yO|!yO}!yO!O!zO!P!zO!Q!{O!R!{O!S!{O!T!{O!U!{O!V!{O$S#QO%s#OO~O$W#SO$X#SO%w#SOW#wXX#wXY#wXZ#wX[#wX]#wX^#wX_#wX`#wXa#wXb#wXc#wX!Z#wX#t#wX$W#wX$X#wX$[#wX$_#wX$`#wX$a#wX$b#wX$c#wX$d#wX$e#wX$f#wX$g#wX$h#wX$i#wX$j#wX$k#wX$l#wX$m#wX$n#wX$o#wX$p#wX$q#wX$r#wX$s#wX$t#wX$u#wX$v#wX$w#wX$x#wX$y#wX$z#wX${#wX$|#wX$}#wX%O#wX%P#wX%Q#wX%R#wX%S#wX%T#wX%U#wX%V#wX%W#wX%X#wX%Y#wX%Z#wX%[#wX%]#wX%^#wX%_#wX%`#wX%a#wX%b#wX%c#wX%d#wX%e#wX%f#wX%g#wX%h#wX%i#wX%j#wX%k#wX%l#wX%m#wX%n#wX%o#wX%p#wX%q#wX%r#wX%u#wX%v#wX%w#wX%y#wX~Ot#VO%z#YO~O%y[OU#xXV#xXf#xXg#xXh#xXx#xX{#xX|#xX}#xX!O#xX!P#xX!Q#xX!R#xX!S#xX!T#xX!U#xX!V#xX$S#xX$V#xX%s#xX$^#xX$]#xX~O$[#[O~O$^#`O~PYOd!uOe!uOUnaVnafnagnahnaxna{na|na}na!Ona!Pna!Qna!Rna!Sna!Tna!Una!Vna$Sna$Vna%sna$^na$]na~OP#dOQ#bOR#bOWyPXyPYyPZyP[yP]yP^yP_yP`yPayPbyPcyP!ZyP#tyP$WyP$XyP$[yP$_yP$`yP$ayP$byP$cyP$dyP$eyP$fyP$gyP$hyP$iyP$jyP$kyP$lyP$myP$nyP$oyP$pyP$qyP$ryP$syP$tyP$uyP$vyP$wyP$xyP$yyP$zyP${yP$|yP$}yP%OyP%PyP%QyP%RyP%SyP%TyP%UyP%VyP%WyP%XyP%YyP%ZyP%[yP%]yP%^yP%_yP%`yP%ayP%byP%cyP%dyP%eyP%fyP%gyP%hyP%iyP%jyP%kyP%lyP%myP%nyP%oyP%pyP%qyP%ryP%uyP%vyP%wyP%yyP~O#p#jO~O!P#lO#p#kO~Oi#nOj#nO$WVO$XVO%u#mO%v#mO%wVO~O$^#qO~P']Ox!yOU#vaV#vaf#vag#vah#va{#va|#va}#va!O#va!P#va!Q#va!R#va!S#va!T#va!U#va!V#va$S#va$V#va%s#va$^#va$]#va~O!V#rO$O#rO$P#rO$Q#rO~O$]#tO%z#uO~Ot#vO$^#yO~O$]#zO$^#{O~O$]vX$^vX~P']OWyXXyXYyXZyX[yX]yX^yX_yX`yXayXbyXcyX!ZyX#tyX$WyX$XyX$[yX$_yX$`yX$ayX$byX$cyX$dyX$eyX$fyX$gyX$hyX$iyX$jyX$kyX$lyX$myX$nyX$oyX$pyX$qyX$ryX$syX$tyX$uyX$vyX$wyX$xyX$yyX$zyX${yX$|yX$}yX%OyX%PyX%QyX%RyX%SyX%TyX%UyX%VyX%WyX%XyX%YyX%ZyX%[yX%]yX%^yX%_yX%`yX%ayX%byX%cyX%dyX%eyX%fyX%gyX%hyX%iyX%jyX%kyX%lyX%myX%nyX%oyX%pyX%qyX%ryX%uyX%vyX%wyX%yyX~OS#}OT#}O~P;dOQ#bOR#bO~P;dO%t$UO%x$VO~O#p$WO~O$W#SO$X#SO%w#SO~O$[$XO~O#t$YO~Ot#VO%z$[O~O$]$]O$^$^O~OWyaXyaYyaZya[ya]ya^ya_ya`yaayabyacya!Zya#tya$Wya$Xya$_ya$`ya$aya$bya$cya$dya$eya$fya$gya$hya$iya$jya$kya$lya$mya$nya$oya$pya$qya$rya$sya$tya$uya$vya$wya$xya$yya$zya${ya$|ya$}ya%Oya%Pya%Qya%Rya%Sya%Tya%Uya%Vya%Wya%Xya%Yya%Zya%[ya%]ya%^ya%_ya%`ya%aya%bya%cya%dya%eya%fya%gya%hya%iya%jya%kya%lya%mya%nya%oya%pya%qya%rya%uya%vya%wya%yya~O$[#[O~PBoOS$aOT$aO$[ya~PBoOx!yOUwqfwqgwqhwq!Owq!Pwq!Qwq!Rwq!Swq!Twq!Uwq!Vwq$Swq$Vwq%swq$^wq$]wq~OVwq{wq|wq}wq~PHsOV!yO{!yO|!yO}!yO~PHsOV!yOx!yO{!yO|!yO}!yO!O!zO!P!zOUwqfwqgwqhwq$Swq$Vwq%swq$^wq$]wq~O!Qwq!Rwq!Swq!Twq!Uwq!Vwq~PJoO!Q!{O!R!{O!S!{O!T!{O!U!{O!V!{O~PJoOV!yOf!|Oh!|Ox!yO{!yO|!yO}!yO!O!zO!P!zO!Q!{O!R!{O!S!{O!T!{O!U!{O!V!{O~OUwqgwq$Swq$Vwq%swq$^wq$]wq~PLqO#p$cO%t$bO~O$^$dO~Ot#vO$^$fO~O$]vi$^vi~P']O$[#[OWyiXyiYyiZyi[yi]yi^yi_yi`yiayibyicyi!Zyi#tyi$Wyi$Xyi$_yi$`yi$ayi$byi$cyi$dyi$eyi$fyi$gyi$hyi$iyi$jyi$kyi$lyi$myi$nyi$oyi$pyi$qyi$ryi$syi$tyi$uyi$vyi$wyi$xyi$yyi$zyi${yi$|yi$}yi%Oyi%Pyi%Qyi%Ryi%Syi%Tyi%Uyi%Vyi%Wyi%Xyi%Yyi%Zyi%[yi%]yi%^yi%_yi%`yi%ayi%byi%cyi%dyi%eyi%fyi%gyi%hyi%iyi%jyi%kyi%lyi%myi%nyi%oyi%pyi%qyi%ryi%uyi%vyi%wyi%yyi~O%t$hO~O",goto:"(u$UPPPPPPPPPPPPPPPPPPPPPPPPPPPPP$V$u%R%_%e%q%tP%z&T$uP&W&gPPPPPPPPPPP$u&q&}P&}&}&}&}&}&}&}&}&}&}&}&}&}&}&}&}&}&}&}&}&}&}&}&}&}&}&}&}&}&}&}&}&}&}&}&}&}&}&}&}&}&}&}&}&}&}&}&}&}&}&}&}&}&}&}&}&}&}&}&}&}&}&}&}&}$uP'Z$u$uP$u$u'j$u'v(V(f(i(oPPP$uP(rQSOQ#TXQ#UYQ#_!vQ$P#eQ$Q#fQ$R#gQ$S#hQ$T#iR$_#ze_OXY!v#e#f#g#h#i#zeROXY!v#e#f#g#h#i#zQ!wRR#a!xQ#]!uQ#|#bQ$`#}R$g$aR#w#[Q#x#[R$e$]Q!xRQ#RUR#a!wR#^!vQ#e!yQ#f!zQ#g!{Q#h!|R#i!}Y#c!y!z!{!|!}R$O#deUOXY!v#e#f#g#h#i#zeTOXY!v#e#f#g#h#i#zd_OXY!v#e#f#g#h#i#zR#o#QeYOXY!v#e#f#g#h#i#zd]OXY!v#e#f#g#h#i#zR!tPd^OXY!v#e#f#g#h#i#zR#Z]R#W[Q#X[R$Z#tR#s#VR#p#Q",nodeNames:"⚠ Bool Ignoring On GroupLeft GroupRight Offset Atan2 Avg Bottomk Count CountValues Group Max Min Quantile Stddev Stdvar Sum Topk By Without And Or Unless Start End LineComment PromQL Expr AggregateExpr AggregateOp AggregateModifier GroupingLabels GroupingLabelList GroupingLabel LabelName FunctionCallBody FunctionCallArgs BinaryExpr Pow BinModifiers OnOrIgnoring Mul Div Mod Add Sub Eql Gte Gtr Lte Lss Neq FunctionCall FunctionIdentifier AbsentOverTime Identifier Absent Abs Acos Acosh Asin Asinh Atan Atanh AvgOverTime Ceil Changes Clamp ClampMax ClampMin Cos Cosh CountOverTime DaysInMonth DayOfMonth DayOfWeek Deg Delta Deriv Exp Floor HistogramQuantile HoltWinters Hour Idelta Increase Irate LabelReplace LabelJoin LastOverTime Ln Log10 Log2 MaxOverTime MinOverTime Minute Month Pi PredictLinear PresentOverTime QuantileOverTime Rad Rate Resets Round Scalar Sgn Sin Sinh Sort SortDesc Sqrt StddevOverTime StdvarOverTime SumOverTime Tan Tanh Timestamp Time Vector Year MatrixSelector Duration NumberLiteral OffsetExpr ParenExpr StringLiteral SubqueryExpr UnaryExpr UnaryOp VectorSelector MetricIdentifier LabelMatchers LabelMatchList LabelMatcher MatchOp EqlSingle EqlRegex NeqRegex StepInvariantExpr At AtModifierPreprocessors MetricName",maxTerm:226,skippedNodes:[0,27],repeatNodeCount:0,tokenData:"1R~RwX^#lpq#lqr$ars$tst%huv%swx%xxy&gyz&lz{&q{|&v|}&}}!O'S!O!P'Z!P!Q(Z!Q!R(`!R![)W![!]-r!^!_.n!_!`.{!`!a/b!b!c/o!c!}/t!}#O0[#P#Q0a#Q#R0f#R#S/t#S#T0k#T#o/t#o#p0w#q#r0|#y#z#l$f$g#l#BY#BZ#l$IS$I_#l$I|$JO#l$JT$JU#l$KV$KW#l&FU&FV#l~#qY$Z~X^#lpq#l#y#z#l$f$g#l#BY#BZ#l$IS$I_#l$I|$JO#l$JT$JU#l$KV$KW#l&FU&FV#l~$dQ!_!`$j#r#s$o~$oO!V~~$tO$Q~~$yU#t~OY$tZr$trs%]s#O$t#O#P%b#P~$t~%bO#t~~%ePO~$t~%mQk~OY%hZ~%h~%xO}~~%}U#t~OY%xZw%xwx%]x#O%x#O#P&a#P~%x~&dPO~%x~&lO$[~~&qO$^~~&vO{~R&}O%vP!OQ~'SO$]~R'ZO%uP!PQP'^P!Q!['aP'fR%wP!Q!['a!g!h'o#X#Y'oP'rR{|'{}!O'{!Q![(RP(OP!Q![(RP(WP%wP!Q![(R~(`O|~R(eZ%wP!O!P'a!Q![)W!g!h'o#W#X){#X#Y'o#[#]*d#a#b*x#g#h+l#k#l+}#l#m-W#m#n,iR)]Y%wP!O!P'a!Q![)W!g!h'o#W#X){#X#Y'o#[#]*d#a#b*x#g#h+l#k#l+}#m#n,iQ*QP#pQ!Q![*TQ*WS!Q![*T#[#]*d#a#b*x#g#h+lQ*iP#pQ!Q![*lQ*oR!Q![*l#a#b*x#g#h+lQ*}Q#pQ!Q![+T#g#h+gQ+WR!Q![+T#a#b+a#g#h+lQ+dP#g#h+gQ+lO#pQQ+qP#pQ!Q![+tQ+wQ!Q![+t#a#b+aQ,SP#pQ!Q![,VQ,YT!Q![,V#W#X){#[#]*d#a#b*x#g#h+lQ,nP#pQ!Q![,qQ,tU!Q![,q#W#X){#[#]*d#a#b*x#g#h+l#k#l+}P-ZR!Q![-d!c!i-d#T#Z-dP-iR%wP!Q![-d!c!i-d#T#Z-dV-yT%xS!ZR!Q![.Y![!].Y!c!}.Y#R#S.Y#T#o.YR._T!ZR!Q![.Y![!].Y!c!}.Y#R#S.Y#T#o.Y~.sP!U~!_!`.v~.{O!T~~/QQ$OP!_!`/W#r#s/]Q/]O!QQ~/bO$P~~/gP!S~!_!`/j~/oO!R~~/tO$S~V/{T!ZRtS!Q![/t![!].Y!c!}/t#R#S/t#T#o/t~0aO%s~~0fO%t~~0kOx~~0nRO#S0k#S#T%]#T~0k~0|O%y~~1RO%z~",tokenizers:[0,1,2],topRules:{PromQL:[0,28],MetricName:[1,144]},specialized:[{term:57,get:(e,t)=>((e,t)=>r[e.toLowerCase()]||-1)(e)<<1},{term:57,get:(e,t)=>((e,t)=>n[e.toLowerCase()]||-1)(e)<<1|1},{term:57,get:e=>a[e]||-1}],tokenPrec:0})},85409:(e,t,i)=>{"use strict";i.d(t,{WQ:()=>U});const s=1024;let r=0;class n{constructor(e,t){this.from=e,this.to=t}}class a{constructor(e={}){this.id=r++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return"function"!=typeof e&&(e=l.match(e)),t=>{let i=e(t);return void 0===i?null:[this,i]}}}a.closedBy=new a({deserialize:e=>e.split(" ")}),a.openedBy=new a({deserialize:e=>e.split(" ")}),a.group=new a({deserialize:e=>e.split(" ")}),a.contextHash=new a({perNode:!0}),a.lookAhead=new a({perNode:!0}),a.mounted=new a({perNode:!0});const o=Object.create(null);class l{constructor(e,t,i,s=0){this.name=e,this.props=t,this.id=i,this.flags=s}static define(e){let t=e.props&&e.props.length?Object.create(null):o,i=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(null==e.name?8:0),s=new l(e.name||"",t,e.id,i);if(e.props)for(let i of e.props)if(Array.isArray(i)||(i=i(s)),i){if(i[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[i[0].id]=i[1]}return s}prop(e){return this.props[e.id]}get isTop(){return(1&this.flags)>0}get isSkipped(){return(2&this.flags)>0}get isError(){return(4&this.flags)>0}get isAnonymous(){return(8&this.flags)>0}is(e){if("string"==typeof e){if(this.name==e)return!0;let t=this.prop(a.group);return!!t&&t.indexOf(e)>-1}return this.id==e}static match(e){let t=Object.create(null);for(let i in e)for(let s of i.split(" "))t[s]=e[i];return e=>{for(let i=e.prop(a.group),s=-1;s<(i?i.length:0);s++){let r=t[s<0?e.name:i[s]];if(r)return r}}}}l.none=new l("",Object.create(null),0,8);class h{constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let t=[];for(let i of this.types){let s=null;for(let t of e){let e=t(i);e&&(s||(s=Object.assign({},i.props)),s[e[0].id]=e[1])}t.push(s?new l(i.name,s,i.id,i.flags):i)}return new h(t)}}const u=new WeakMap,c=new WeakMap;class d{constructor(e,t,i,s,r){if(this.type=e,this.children=t,this.positions=i,this.length=s,this.props=null,r&&r.length){this.props=Object.create(null);for(let[e,t]of r)this.props["number"==typeof e?e:e.id]=t}}toString(){let e=this.prop(a.mounted);if(e&&!e.overlay)return e.tree.toString();let t="";for(let e of this.children){let i=e.toString();i&&(t&&(t+=","),t+=i)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(e,t=0){let i=null!=e&&u.get(this)||this.topNode,s=new $(i);return null!=e&&(s.moveTo(e,t),u.set(this,s._tree)),s}fullCursor(){return new $(this.topNode,1)}get topNode(){return new O(this,0,0,null)}resolve(e,t=0){let i=y(u.get(this)||this.topNode,e,t,!1);return u.set(this,i),i}resolveInner(e,t=0){let i=y(c.get(this)||this.topNode,e,t,!0);return c.set(this,i),i}iterate(e){let{enter:t,leave:i,from:s=0,to:r=this.length}=e;for(let e=this.cursor(),n=()=>e.node;;){let a=!1;if(e.from<=r&&e.to>=s&&(e.type.isAnonymous||!1!==t(e.type,e.from,e.to,n))){if(e.firstChild())continue;e.type.isAnonymous||(a=!0)}for(;a&&i&&i(e.type,e.from,e.to,n),a=e.type.isAnonymous,!e.nextSibling();){if(!e.parent())return;a=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:P(l.none,this.children,this.positions,0,this.children.length,0,this.length,((e,t,i)=>new d(this.type,e,t,i,this.propValues)),e.makeTree||((e,t,i)=>new d(l.none,e,t,i)))}static build(e){return function(e){var t;let{buffer:i,nodeSet:r,maxBufferLength:n=s,reused:o=[],minRepeatType:l=r.types.length}=e,h=Array.isArray(i)?new p(i,i.length):i,u=r.types,c=0,g=0;function m(e,t,i,s,a){let{id:d,start:p,end:$,size:k}=h,w=g;for(;k<0;){if(h.next(),-1==k){let t=o[d];return i.push(t),void s.push(p-e)}if(-3==k)return void(c=d);if(-4==k)return void(g=d);throw new RangeError(`Unrecognized record size: ${k}`)}let _,S,Q=u[d],C=p-e;if($-p<=n&&(S=x(h.pos-t,a))){let t=new Uint16Array(S.size-S.skip),i=h.pos-S.size,s=t.length;for(;h.pos>i;)s=v(S.start,t,s);_=new f(t,$-S.start,r),C=S.start-e}else{let e=h.pos-k;h.next();let t=[],i=[],s=d>=l?d:-1,r=0,a=$;for(;h.pos>e;)s>=0&&h.id==s&&h.size>=0?(h.end<=a-n&&(O(t,i,p,r,h.end,a,s,w),r=t.length,a=h.end),h.next()):m(p,e,t,i,s);if(s>=0&&r>0&&r<t.length&&O(t,i,p,r,p,a,s,w),t.reverse(),i.reverse(),s>-1&&r>0){let e=y(Q);_=P(Q,t,i,0,t.length,0,$-p,e,e)}else _=b(Q,t,i,$-p,w-$)}i.push(_),s.push(C)}function y(e){return(t,i,s)=>{let r,n,o=0,l=t.length-1;if(l>=0&&(r=t[l])instanceof d){if(!l&&r.type==e&&r.length==s)return r;(n=r.prop(a.lookAhead))&&(o=i[l]+r.length+n)}return b(e,t,i,s,o)}}function O(e,t,i,s,n,a,o,l){let h=[],u=[];for(;e.length>s;)h.push(e.pop()),u.push(t.pop()+i-n);e.push(b(r.types[o],h,u,a-n,l-a)),t.push(n-i)}function b(e,t,i,s,r=0,n){if(c){let e=[a.contextHash,c];n=n?[e].concat(n):[e]}if(r>25){let e=[a.lookAhead,r];n=n?[e].concat(n):[e]}return new d(e,t,i,s,n)}function x(e,t){let i=h.fork(),s=0,r=0,a=0,o=i.end-n,u={size:0,start:0,skip:0};e:for(let n=i.pos-e;i.pos>n;){let e=i.size;if(i.id==t&&e>=0){u.size=s,u.start=r,u.skip=a,a+=4,s+=4,i.next();continue}let h=i.pos-e;if(e<0||h<n||i.start<o)break;let c=i.id>=l?4:0,d=i.start;for(i.next();i.pos>h;){if(i.size<0){if(-3!=i.size)break e;c+=4}else i.id>=l&&(c+=4);i.next()}r=d,s+=e,a+=c}return(t<0||s==e)&&(u.size=s,u.start=r,u.skip=a),u.size>4?u:void 0}function v(e,t,i){let{id:s,start:r,end:n,size:a}=h;if(h.next(),a>=0&&s<l){let o=i;if(a>4){let s=h.pos-(a-4);for(;h.pos>s;)i=v(e,t,i)}t[--i]=o,t[--i]=n-e,t[--i]=r-e,t[--i]=s}else-3==a?c=s:-4==a&&(g=s);return i}let $=[],k=[];for(;h.pos>0;)m(e.start||0,e.bufferStart||0,$,k,-1);let w=null!==(t=e.length)&&void 0!==t?t:$.length?k[0]+$[0].length:0;return new d(u[e.topID],$.reverse(),k.reverse(),w)}(e)}}d.empty=new d(l.none,[],[],0);class p{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new p(this.buffer,this.index)}}class f{constructor(e,t,i){this.buffer=e,this.length=t,this.set=i}get type(){return l.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(",")}childString(e){let t=this.buffer[e],i=this.buffer[e+3],s=this.set.types[t],r=s.name;if(/\W/.test(r)&&!s.isError&&(r=JSON.stringify(r)),i==(e+=4))return r;let n=[];for(;e<i;)n.push(this.childString(e)),e=this.buffer[e+3];return r+"("+n.join(",")+")"}findChild(e,t,i,s,r){let{buffer:n}=this,a=-1;for(let o=e;o!=t&&!(g(r,s,n[o+1],n[o+2])&&(a=o,i>0));o=n[o+3]);return a}slice(e,t,i,s){let r=this.buffer,n=new Uint16Array(t-e);for(let s=e,a=0;s<t;)n[a++]=r[s++],n[a++]=r[s++]-i,n[a++]=r[s++]-i,n[a++]=r[s++]-e;return new f(n,s-i,this.set)}}function g(e,t,i,s){switch(e){case-2:return i<t;case-1:return s>=t&&i<t;case 0:return i<t&&s>t;case 1:return i<=t&&s>t;case 2:return s>t;case 4:return!0}}function m(e,t){let i=e.childBefore(t);for(;i;){let t=i.lastChild;if(!t||t.to!=i.to)break;t.type.isError&&t.from==t.to?(e=i,i=t.prevSibling):i=t}return e}function y(e,t,i,s){for(var r;e.from==e.to||(i<1?e.from>=t:e.from>t)||(i>-1?e.to<=t:e.to<t);){let t=!s&&e instanceof O&&e.index<0?null:e.parent;if(!t)return e;e=t}if(s)for(let s=e,n=s.parent;n;s=n,n=s.parent)s instanceof O&&s.index<0&&(null===(r=n.enter(t,i,!0))||void 0===r?void 0:r.from)!=s.from&&(e=n);for(;;){let r=e.enter(t,i,s);if(!r)return e;e=r}}class O{constructor(e,t,i,s){this.node=e,this._from=t,this.index=i,this._parent=s}get type(){return this.node.type}get name(){return this.node.type.name}get from(){return this._from}get to(){return this._from+this.node.length}nextChild(e,t,i,s,r=0){for(let n=this;;){for(let{children:o,positions:l}=n.node,h=t>0?o.length:-1;e!=h;e+=t){let h=o[e],u=l[e]+n._from;if(g(s,i,u,u+h.length))if(h instanceof f){if(2&r)continue;let a=h.findChild(0,h.buffer.length,t,i-u,s);if(a>-1)return new v(new x(n,h,e,u),null,a)}else if(1&r||!h.type.isAnonymous||k(h)){let o;if(!(1&r)&&h.props&&(o=h.prop(a.mounted))&&!o.overlay)return new O(o.tree,u,e,n);let l=new O(h,u,e,n);return 1&r||!l.type.isAnonymous?l:l.nextChild(t<0?h.children.length-1:0,t,i,s)}}if(1&r||!n.type.isAnonymous)return null;if(e=n.index>=0?n.index+t:t<0?-1:n._parent.node.children.length,n=n._parent,!n)return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this.node.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this.node.children.length-1,-1,e,-2)}enter(e,t,i=!0,s=!0){let r;if(i&&(r=this.node.prop(a.mounted))&&r.overlay){let i=e-this.from;for(let{from:e,to:s}of r.overlay)if((t>0?e<=i:e<i)&&(t<0?s>=i:s>i))return new O(r.tree,r.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,s?0:2)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get cursor(){return new $(this)}get tree(){return this.node}toTree(){return this.node}resolve(e,t=0){return y(this,e,t,!1)}resolveInner(e,t=0){return y(this,e,t,!0)}enterUnfinishedNodesBefore(e){return m(this,e)}getChild(e,t=null,i=null){let s=b(this,e,t,i);return s.length?s[0]:null}getChildren(e,t=null,i=null){return b(this,e,t,i)}toString(){return this.node.toString()}}function b(e,t,i,s){let r=e.cursor,n=[];if(!r.firstChild())return n;if(null!=i)for(;!r.type.is(i);)if(!r.nextSibling())return n;for(;;){if(null!=s&&r.type.is(s))return n;if(r.type.is(t)&&n.push(r.node),!r.nextSibling())return null==s?n:[]}}class x{constructor(e,t,i,s){this.parent=e,this.buffer=t,this.index=i,this.start=s}}class v{constructor(e,t,i){this.context=e,this._parent=t,this.index=i,this.type=e.buffer.set.types[e.buffer.buffer[i]]}get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}child(e,t,i){let{buffer:s}=this.context,r=s.findChild(this.index+4,s.buffer[this.index+3],e,t-this.context.start,i);return r<0?null:new v(this.context,this,r)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}enter(e,t,i,s=!0){if(!s)return null;let{buffer:r}=this.context,n=r.findChild(this.index+4,r.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return n<0?null:new v(this.context,this,n)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new v(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new v(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get cursor(){return new $(this)}get tree(){return null}toTree(){let e=[],t=[],{buffer:i}=this.context,s=this.index+4,r=i.buffer[this.index+3];if(r>s){let n=i.buffer[this.index+1],a=i.buffer[this.index+2];e.push(i.slice(s,r,n,a)),t.push(0)}return new d(this.type,e,t,this.to-this.from)}resolve(e,t=0){return y(this,e,t,!1)}resolveInner(e,t=0){return y(this,e,t,!0)}enterUnfinishedNodesBefore(e){return m(this,e)}toString(){return this.context.buffer.childString(this.index)}getChild(e,t=null,i=null){let s=b(this,e,t,i);return s.length?s[0]:null}getChildren(e,t=null,i=null){return b(this,e,t,i)}}class ${constructor(e,t=0){if(this.mode=t,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,e instanceof O)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let t=e._parent;t;t=t._parent)this.stack.unshift(t.index);this.bufferNode=e,this.yieldBuf(e.index)}}get name(){return this.type.name}yieldNode(e){return!!e&&(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0)}yieldBuf(e,t){this.index=e;let{start:i,buffer:s}=this.buffer;return this.type=t||s.set.types[s.buffer[e]],this.from=i+s.buffer[e+1],this.to=i+s.buffer[e+2],!0}yield(e){return!!e&&(e instanceof O?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)))}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,i){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree.node.children.length-1:0,e,t,i,this.mode));let{buffer:s}=this.buffer,r=s.findChild(this.index+4,s.buffer[this.index+3],e,t-this.buffer.start,i);return!(r<0)&&(this.stack.push(this.index),this.yieldBuf(r))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,i=!0,s=!0){return this.buffer?!!s&&this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,i&&!(1&this.mode),s))}parent(){if(!this.buffer)return this.yieldNode(1&this.mode?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=1&this.mode?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return!!this._tree._parent&&this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode));let{buffer:t}=this.buffer,i=this.stack.length-1;if(e<0){let e=i<0?0:this.stack[i]+4;if(this.index!=e)return this.yieldBuf(t.findChild(e,this.index,-1,0,4))}else{let e=t.buffer[this.index+3];if(e<(i<0?t.buffer.length:t.buffer[this.stack[i]+3]))return this.yieldBuf(e)}return i<0&&this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode))}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,i,{buffer:s}=this;if(s){if(e>0){if(this.index<s.buffer.buffer.length)return!1}else for(let e=0;e<this.index;e++)if(s.buffer.buffer[e+3]<this.index)return!1;({index:t,parent:i}=s)}else({index:t,_parent:i}=this._tree);for(;i;({index:t,_parent:i}=i))if(t>-1)for(let s=t+e,r=e<0?-1:i.node.children.length;s!=r;s+=e){let e=i.node.children[s];if(1&this.mode||e instanceof f||!e.type.isAnonymous||k(e))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,i=0;if(e&&e.context==this.buffer)e:for(let s=this.index,r=this.stack.length;r>=0;){for(let n=e;n;n=n._parent)if(n.index==s){if(s==this.index)return n;t=n,i=r+1;break e}s=this.stack[--r]}for(let e=i;e<this.stack.length;e++)t=new v(this.buffer,t,this.stack[e]);return this.bufferNode=new v(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree.node}}function k(e){return e.children.some((e=>e instanceof f||!e.type.isAnonymous||k(e)))}const w=new WeakMap;function _(e,t){if(!e.isAnonymous||t instanceof f||t.type!=e)return 1;let i=w.get(t);if(null==i){i=1;for(let s of t.children){if(s.type!=e||!(s instanceof d)){i=1;break}i+=_(e,s)}w.set(t,i)}return i}function P(e,t,i,s,r,n,a,o,l){let h=0;for(let i=s;i<r;i++)h+=_(e,t[i]);let u=Math.ceil(1.5*h/8),c=[],d=[];return function t(i,s,r,a,o){for(let h=r;h<a;){let r=h,p=s[h],f=_(e,i[h]);for(h++;h<a;h++){let t=_(e,i[h]);if(f+t>=u)break;f+=t}if(h==r+1){if(f>u){let e=i[r];t(e.children,e.positions,0,e.children.length,s[r]+o);continue}c.push(i[r])}else{let t=s[h-1]+i[h-1].length-p;c.push(P(e,i,s,r,h,p,t,null,l))}d.push(p+o-n)}}(t,i,s,r,0),(o||l)(c,d,a)}class S{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}}new a({perNode:!0});class Q{constructor(e,t,i,s,r,n,a,o,l,h=0,u){this.p=e,this.stack=t,this.state=i,this.reducePos=s,this.pos=r,this.score=n,this.buffer=a,this.bufferBase=o,this.curContext=l,this.lookAhead=h,this.parent=u}toString(){return`[${this.stack.filter(((e,t)=>t%3==0)).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,t,i=0){let s=e.parser.context;return new Q(e,[],t,i,i,0,[],0,s?new C(s,s.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,t){this.stack.push(this.state,t,this.bufferBase+this.buffer.length),this.state=e}reduce(e){let t=e>>19,i=65535&e,{parser:s}=this.p,r=s.dynamicPrecedence(i);if(r&&(this.score+=r),0==t)return this.pushState(s.getGoto(this.state,i,!0),this.reducePos),i<s.minRepeatTerm&&this.storeNode(i,this.reducePos,this.reducePos,4,!0),void this.reduceContext(i,this.reducePos);let n=this.stack.length-3*(t-1)-(262144&e?6:0),a=this.stack[n-2],o=this.stack[n-1],l=this.bufferBase+this.buffer.length-o;if(i<s.minRepeatTerm||131072&e){let e=s.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(i,a,e,l+4,!0)}if(262144&e)this.state=this.stack[n];else{let e=this.stack[n-3];this.state=s.getGoto(e,i,!0)}for(;this.stack.length>n;)this.stack.pop();this.reduceContext(i,a)}storeNode(e,t,i,s=4,r=!1){if(0==e){let e=this,s=this.buffer.length;if(0==s&&e.parent&&(s=e.bufferBase-e.parent.bufferBase,e=e.parent),s>0&&0==e.buffer[s-4]&&e.buffer[s-1]>-1){if(t==i)return;if(e.buffer[s-2]>=t)return void(e.buffer[s-2]=i)}}if(r&&this.pos!=i){let r=this.buffer.length;if(r>0&&0!=this.buffer[r-4])for(;r>0&&this.buffer[r-2]>i;)this.buffer[r]=this.buffer[r-4],this.buffer[r+1]=this.buffer[r-3],this.buffer[r+2]=this.buffer[r-2],this.buffer[r+3]=this.buffer[r-1],r-=4,s>4&&(s-=4);this.buffer[r]=e,this.buffer[r+1]=t,this.buffer[r+2]=i,this.buffer[r+3]=s}else this.buffer.push(e,t,i,s)}shift(e,t,i){let s=this.pos;if(131072&e)this.pushState(65535&e,this.pos);else if(0==(262144&e)){let r=e,{parser:n}=this.p;(i>this.pos||t<=n.maxNode)&&(this.pos=i,n.stateFlag(r,1)||(this.reducePos=i)),this.pushState(r,s),this.shiftContext(t,s),t<=n.maxNode&&this.buffer.push(t,s,i,4)}else this.pos=i,this.shiftContext(t,s),t<=this.p.parser.maxNode&&this.buffer.push(t,s,i,4)}apply(e,t,i){65536&e?this.reduce(e):this.shift(e,t,i)}useNode(e,t){let i=this.p.reused.length-1;(i<0||this.p.reused[i]!=e)&&(this.p.reused.push(e),i++);let s=this.pos;this.reducePos=this.pos=s+e.length,this.pushState(t,s),this.buffer.push(i,s,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,t=e.buffer.length;for(;t>0&&e.buffer[t-2]>e.reducePos;)t-=4;let i=e.buffer.slice(t),s=e.bufferBase+t;for(;e&&s==e.bufferBase;)e=e.parent;return new Q(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,i,s,this.curContext,this.lookAhead,e)}recoverByDelete(e,t){let i=e<=this.p.parser.maxNode;i&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,i?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new X(this);;){let i=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(0==(65536&i))return!0;if(0==i)return!1;t.reduce(i)}}recoverByInsert(e){if(this.stack.length>=300)return[];let t=this.p.parser.nextStates(this.state);if(t.length>8||this.stack.length>=120){let i=[];for(let s,r=0;r<t.length;r+=2)(s=t[r+1])!=this.state&&this.p.parser.hasAction(s,e)&&i.push(t[r],s);if(this.stack.length<120)for(let e=0;i.length<8&&e<t.length;e+=2){let s=t[e+1];i.some(((e,t)=>1&t&&e==s))||i.push(t[e],s)}t=i}let i=[];for(let e=0;e<t.length&&i.length<4;e+=2){let s=t[e+1];if(s==this.state)continue;let r=this.split();r.storeNode(0,r.pos,r.pos,4,!0),r.pushState(s,this.pos),r.shiftContext(t[e],this.pos),r.score-=200,i.push(r)}return i}forceReduce(){let e=this.p.parser.stateSlot(this.state,5);if(0==(65536&e))return!1;let{parser:t}=this.p;if(!t.validAction(this.state,e)){let i=e>>19,s=65535&e,r=this.stack.length-3*i;if(r<0||t.getGoto(this.stack[r],s,!1)<0)return!1;this.storeNode(0,this.reducePos,this.reducePos,4,!0),this.score-=100}return this.reduce(e),!0}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(3!=this.stack.length)return!1;let{parser:e}=this.p;return 65535==e.data[e.stateSlot(this.state,1)]&&!e.stateSlot(this.state,4)}restart(){this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let t=0;t<this.stack.length;t+=3)if(this.stack[t]!=e.stack[t])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(e){return this.p.parser.dialect.flags[e]}shiftContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,e,this,this.p.stream.reset(t)))}reduceContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,e,this,this.p.stream.reset(t)))}emitContext(){let e=this.buffer.length-1;(e<0||-3!=this.buffer[e])&&this.buffer.push(this.curContext.hash,this.reducePos,this.reducePos,-3)}emitLookAhead(){let e=this.buffer.length-1;(e<0||-4!=this.buffer[e])&&this.buffer.push(this.lookAhead,this.reducePos,this.reducePos,-4)}updateContext(e){if(e!=this.curContext.context){let t=new C(this.curContext.tracker,e);t.hash!=this.curContext.hash&&this.emitContext(),this.curContext=t}}setLookAhead(e){e>this.lookAhead&&(this.emitLookAhead(),this.lookAhead=e)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}class C{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}}var T;!function(e){e[e.Insert=200]="Insert",e[e.Delete=190]="Delete",e[e.Reduce=100]="Reduce",e[e.MaxNext=4]="MaxNext",e[e.MaxInsertStackDepth=300]="MaxInsertStackDepth",e[e.DampenInsertStackDepth=120]="DampenInsertStackDepth"}(T||(T={}));class X{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=65535&e,i=e>>19;0==i?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=3*(i-1);let s=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=s}}class L{constructor(e,t,i){this.stack=e,this.pos=t,this.index=i,this.buffer=e.buffer,0==this.index&&this.maybeNext()}static create(e,t=e.bufferBase+e.buffer.length){return new L(e,t,t-e.bufferBase)}maybeNext(){let e=this.stack.parent;null!=e&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,0==this.index&&this.maybeNext()}fork(){return new L(this.stack,this.pos,this.index)}}class A{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const R=new A;class z{constructor(e,t){this.input=e,this.ranges=t,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=R,this.rangeIndex=0,this.pos=this.chunkPos=t[0].from,this.range=t[0],this.end=t[t.length-1].to,this.readNext()}resolveOffset(e,t){let i=this.range,s=this.rangeIndex,r=this.pos+e;for(;r<i.from;){if(!s)return null;let e=this.ranges[--s];r-=i.from-e.to,i=e}for(;t<0?r>i.to:r>=i.to;){if(s==this.ranges.length-1)return null;let e=this.ranges[++s];r+=e.from-i.to,i=e}return r}peek(e){let t,i,s=this.chunkOff+e;if(s>=0&&s<this.chunk.length)t=this.pos+e,i=this.chunk.charCodeAt(s);else{let s=this.resolveOffset(e,1);if(null==s)return-1;if(t=s,t>=this.chunk2Pos&&t<this.chunk2Pos+this.chunk2.length)i=this.chunk2.charCodeAt(t-this.chunk2Pos);else{let e=this.rangeIndex,s=this.range;for(;s.to<=t;)s=this.ranges[++e];this.chunk2=this.input.chunk(this.chunk2Pos=t),t+this.chunk2.length>s.to&&(this.chunk2=this.chunk2.slice(0,s.to-t)),i=this.chunk2.charCodeAt(0)}}return t>=this.token.lookAhead&&(this.token.lookAhead=t+1),i}acceptToken(e,t=0){let i=t?this.resolveOffset(t,-1):this.pos;if(null==i||i<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=e,this.token.end=i}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:e,chunkPos:t}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=e,this.chunk2Pos=t,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let e=this.input.chunk(this.pos),t=this.pos+e.length;this.chunk=t>this.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,t){if(t?(this.token=t,t.start=e,t.lookAhead=e+1,t.value=t.extended=-1):this.token=R,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;e>=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e<this.chunkPos+this.chunk.length?this.chunkOff=e-this.chunkPos:(this.chunk="",this.chunkOff=0),this.readNext()}return this}read(e,t){if(e>=this.chunkPos&&t<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,t-this.chunkPos);if(e>=this.chunk2Pos&&t<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,t-this.chunk2Pos);if(e>=this.range.from&&t<=this.range.to)return this.input.read(e,t);let i="";for(let s of this.ranges){if(s.from>=t)break;s.to>e&&(i+=this.input.read(Math.max(s.from,e),Math.min(s.to,t)))}return i}}class E{constructor(e,t){this.data=e,this.id=t}token(e,t){!function(e,t,i,s){let r=0,n=1<<s,{parser:a}=i.p,{dialect:o}=a;e:for(;0!=(n&e[r]);){let i=e[r+1];for(let s=r+3;s<i;s+=2)if((e[s+1]&n)>0){let i=e[s];if(o.allows(i)&&(-1==t.token.value||t.token.value==i||a.overrides(i,t.token.value))){t.acceptToken(i);break}}for(let s=t.next,n=0,a=e[r+2];n<a;){let o=n+a>>1,l=i+o+(o<<1),h=e[l],u=e[l+1];if(s<h)a=o;else{if(!(s>=u)){r=e[l+2],t.advance();continue e}n=o+1}}break}}(this.data,e,t,this.id)}}E.prototype.contextual=E.prototype.fallback=E.prototype.extend=!1;function j(e,t=Uint16Array){if("string"!=typeof e)return e;let i=null;for(let s=0,r=0;s<e.length;){let n=0;for(;;){let t=e.charCodeAt(s++),i=!1;if(126==t){n=65535;break}t>=92&&t--,t>=34&&t--;let r=t-32;if(r>=46&&(r-=46,i=!0),n+=r,i)break;n*=46}i?i[r++]=n:i=new t(n)}return i}const q="undefined"!=typeof process&&/\bparse\b/.test(process.env.LOG);let D=null;var F,G;function N(e,t,i){let s=e.fullCursor();for(s.moveTo(t);;)if(!(i<0?s.childBefore(t):s.childAfter(t)))for(;;){if((i<0?s.to<t:s.from>t)&&!s.type.isError)return i<0?Math.max(0,Math.min(s.to-1,t-25)):Math.min(e.length,Math.max(s.from+1,t+25));if(i<0?s.prevSibling():s.nextSibling())break;if(!s.parent())return i<0?0:e.length}}!function(e){e[e.Margin=25]="Margin"}(F||(F={}));class I{constructor(e,t){this.fragments=e,this.nodeSet=t,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?N(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?N(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(e<this.nextStart)return null;for(;this.fragment&&this.safeTo<=e;)this.nextFragment();if(!this.fragment)return null;for(;;){let t=this.trees.length-1;if(t<0)return this.nextFragment(),null;let i=this.trees[t],s=this.index[t];if(s==i.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let r=i.children[s],n=this.start[t]+i.positions[s];if(n>e)return this.nextStart=n,null;if(r instanceof d){if(n==e){if(n<this.safeFrom)return null;let e=n+r.length;if(e<=this.safeTo){let t=r.prop(a.lookAhead);if(!t||e+t<this.fragment.to)return r}}this.index[t]++,n+r.length>=Math.max(this.safeFrom,e)&&(this.trees.push(r),this.start.push(n),this.index.push(0))}else this.index[t]++,this.nextStart=n+r.length}}}class M{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map((e=>new A))}getActions(e){let t=0,i=null,{parser:s}=e.p,{tokenizers:r}=s,n=s.stateSlot(e.state,3),a=e.curContext?e.curContext.hash:0,o=0;for(let s=0;s<r.length;s++){if(0==(1<<s&n))continue;let l=r[s],h=this.tokens[s];if((!i||l.fallback)&&((l.contextual||h.start!=e.pos||h.mask!=n||h.context!=a)&&(this.updateCachedToken(h,l,e),h.mask=n,h.context=a),h.lookAhead>h.end+25&&(o=Math.max(h.lookAhead,o)),0!=h.value)){let s=t;if(h.extended>-1&&(t=this.addActions(e,h.extended,h.end,t)),t=this.addActions(e,h.value,h.end,t),!l.extend&&(i=h,t>s))break}}for(;this.actions.length>t;)this.actions.pop();return o&&e.setLookAhead(o),i||e.pos!=this.stream.end||(i=new A,i.value=e.p.parser.eofTerm,i.start=i.end=e.pos,t=this.addActions(e,i.value,i.end,t)),this.mainToken=i,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new A,{pos:i,p:s}=e;return t.start=i,t.end=Math.min(i+1,s.stream.end),t.value=i==s.stream.end?s.parser.eofTerm:0,t}updateCachedToken(e,t,i){if(t.token(this.stream.reset(i.pos,e),i),e.value>-1){let{parser:t}=i.p;for(let s=0;s<t.specialized.length;s++)if(t.specialized[s]==e.value){let r=t.specializers[s](this.stream.read(e.start,e.end),i);if(r>=0&&i.p.parser.dialect.allows(r>>1)){0==(1&r)?e.value=r>>1:e.extended=r>>1;break}}}else e.value=0,e.end=Math.min(i.p.stream.end,i.pos+1)}putAction(e,t,i,s){for(let t=0;t<s;t+=3)if(this.actions[t]==e)return s;return this.actions[s++]=e,this.actions[s++]=t,this.actions[s++]=i,s}addActions(e,t,i,s){let{state:r}=e,{parser:n}=e.p,{data:a}=n;for(let e=0;e<2;e++)for(let o=n.stateSlot(r,e?2:1);;o+=3){if(65535==a[o]){if(1!=a[o+1]){0==s&&2==a[o+1]&&(s=this.putAction(H(a,o+2),t,i,s));break}o=H(a,o+2)}a[o]==t&&(s=this.putAction(H(a,o+1),t,i,s))}return s}}!function(e){e[e.Distance=5]="Distance",e[e.MaxRemainingPerStep=3]="MaxRemainingPerStep",e[e.MinBufferLengthPrune=500]="MinBufferLengthPrune",e[e.ForceReduceLimit=10]="ForceReduceLimit",e[e.CutDepth=15e3]="CutDepth",e[e.CutTo=9e3]="CutTo"}(G||(G={}));class B{constructor(e,t,i,s){this.parser=e,this.input=t,this.ranges=s,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.stream=new z(t,s),this.tokens=new M(e,this.stream),this.topTerm=e.top[1];let{from:r}=s[0];this.stacks=[Q.start(this,e.top[0],r)],this.fragments=i.length&&this.stream.end-r>4*e.bufferLength?new I(i,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e,t,i=this.stacks,s=this.minStackPos,r=this.stacks=[];for(let n=0;n<i.length;n++){let a=i[n];for(;;){if(this.tokens.mainToken=null,a.pos>s)r.push(a);else{if(this.advanceStack(a,r,i))continue;{e||(e=[],t=[]),e.push(a);let i=this.tokens.getMainToken(a);t.push(i.value,i.end)}}break}}if(!r.length){let t=e&&function(e){let t=null;for(let i of e){let e=i.p.stoppedAt;(i.pos==i.p.stream.end||null!=e&&i.pos>e)&&i.p.parser.stateFlag(i.state,2)&&(!t||t.score<i.score)&&(t=i)}return t}(e);if(t)return this.stackToTree(t);if(this.parser.strict)throw q&&e&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+s);this.recovering||(this.recovering=5)}if(this.recovering&&e){let i=null!=this.stoppedAt&&e[0].pos>this.stoppedAt?e[0]:this.runRecovery(e,t,r);if(i)return this.stackToTree(i.forceAll())}if(this.recovering){let e=1==this.recovering?1:3*this.recovering;if(r.length>e)for(r.sort(((e,t)=>t.score-e.score));r.length>e;)r.pop();r.some((e=>e.reducePos>s))&&this.recovering--}else if(r.length>1)e:for(let e=0;e<r.length-1;e++){let t=r[e];for(let i=e+1;i<r.length;i++){let s=r[i];if(t.sameState(s)||t.buffer.length>500&&s.buffer.length>500){if(!((t.score-s.score||t.buffer.length-s.buffer.length)>0)){r.splice(e--,1);continue e}r.splice(i--,1)}}}this.minStackPos=r[0].pos;for(let e=1;e<r.length;e++)r[e].pos<this.minStackPos&&(this.minStackPos=r[e].pos);return null}stopAt(e){if(null!=this.stoppedAt&&this.stoppedAt<e)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=e}advanceStack(e,t,i){let s=e.pos,{parser:r}=this,n=q?this.stackID(e)+" -> ":"";if(null!=this.stoppedAt&&s>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let t=e.curContext&&e.curContext.tracker.strict,i=t?e.curContext.hash:0;for(let o=this.fragments.nodeAt(s);o;){let s=this.parser.nodeSet.types[o.type.id]==o.type?r.getGoto(e.state,o.type.id):-1;if(s>-1&&o.length&&(!t||(o.prop(a.contextHash)||0)==i))return e.useNode(o,s),q&&console.log(n+this.stackID(e)+` (via reuse of ${r.getName(o.type.id)})`),!0;if(!(o instanceof d)||0==o.children.length||o.positions[0]>0)break;let l=o.children[0];if(!(l instanceof d&&0==o.positions[0]))break;o=l}}let o=r.stateSlot(e.state,4);if(o>0)return e.reduce(o),q&&console.log(n+this.stackID(e)+` (via always-reduce ${r.getName(65535&o)})`),!0;if(e.stack.length>=15e3)for(;e.stack.length>9e3&&e.forceReduce(););let l=this.tokens.getActions(e);for(let a=0;a<l.length;){let o=l[a++],h=l[a++],u=l[a++],c=a==l.length||!i,d=c?e:e.split();if(d.apply(o,h,u),q&&console.log(n+this.stackID(d)+` (via ${0==(65536&o)?"shift":`reduce of ${r.getName(65535&o)}`} for ${r.getName(h)} @ ${s}${d==e?"":", split"})`),c)return!0;d.pos>s?t.push(d):i.push(d)}return!1}advanceFully(e,t){let i=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>i)return V(e,t),!0}}runRecovery(e,t,i){let s=null,r=!1;for(let n=0;n<e.length;n++){let a=e[n],o=t[n<<1],l=t[1+(n<<1)],h=q?this.stackID(a)+" -> ":"";if(a.deadEnd){if(r)continue;if(r=!0,a.restart(),q&&console.log(h+this.stackID(a)+" (restarted)"),this.advanceFully(a,i))continue}let u=a.split(),c=h;for(let e=0;u.forceReduce()&&e<10;e++){if(q&&console.log(c+this.stackID(u)+" (via force-reduce)"),this.advanceFully(u,i))break;q&&(c=this.stackID(u)+" -> ")}for(let e of a.recoverByInsert(o))q&&console.log(h+this.stackID(e)+" (via recover-insert)"),this.advanceFully(e,i);this.stream.end>a.pos?(l==a.pos&&(l++,o=0),a.recoverByDelete(o,l),q&&console.log(h+this.stackID(a)+` (via recover-delete ${this.parser.getName(o)})`),V(a,i)):(!s||s.score<a.score)&&(s=a)}return s}stackToTree(e){return e.close(),d.build({buffer:L.create(e),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:e.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(e){let t=(D||(D=new WeakMap)).get(e);return t||D.set(e,t=String.fromCodePoint(this.nextStackID++)),t+e}}function V(e,t){for(let i=0;i<t.length;i++){let s=t[i];if(s.pos==e.pos&&s.sameState(e))return void(t[i].score<e.score&&(t[i]=e))}t.push(e)}class W{constructor(e,t,i){this.source=e,this.flags=t,this.disabled=i}allows(e){return!this.disabled||0==this.disabled[e]}}class U extends class{startParse(e,t,i){return"string"==typeof e&&(e=new S(e)),i=i?i.length?i.map((e=>new n(e.from,e.to))):[new n(0,0)]:[new n(0,e.length)],this.createParse(e,t||[],i)}parse(e,t,i){let s=this.startParse(e,t,i);for(;;){let e=s.advance();if(e)return e}}}{constructor(e){if(super(),this.wrappers=[],13!=e.version)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (13)`);let t=e.nodeNames.split(" ");this.minRepeatTerm=t.length;for(let i=0;i<e.repeatNodeCount;i++)t.push("");let i=Object.keys(e.topRules).map((t=>e.topRules[t][1])),r=[];for(let e=0;e<t.length;e++)r.push([]);function n(e,t,i){r[e].push([t,t.deserialize(String(i))])}if(e.nodeProps)for(let t of e.nodeProps){let e=t[0];for(let i=1;i<t.length;){let s=t[i++];if(s>=0)n(s,e,t[i++]);else{let r=t[i+-s];for(let a=-s;a>0;a--)n(t[i++],e,r);i++}}}this.nodeSet=new h(t.map(((t,s)=>l.define({name:s>=this.minRepeatTerm?void 0:t,id:s,props:r[s],top:i.indexOf(s)>-1,error:0==s,skipped:e.skippedNodes&&e.skippedNodes.indexOf(s)>-1})))),this.strict=!1,this.bufferLength=s;let a=j(e.tokenData);if(this.context=e.context,this.specialized=new Uint16Array(e.specialized?e.specialized.length:0),this.specializers=[],e.specialized)for(let t=0;t<e.specialized.length;t++)this.specialized[t]=e.specialized[t].term,this.specializers[t]=e.specialized[t].get;this.states=j(e.states,Uint32Array),this.data=j(e.stateData),this.goto=j(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map((e=>"number"==typeof e?new E(a,e):e)),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,t,i){let s=new B(this,e,t,i);for(let r of this.wrappers)s=r(s,e,t,i);return s}getGoto(e,t,i=!1){let s=this.goto;if(t>=s[0])return-1;for(let r=s[t+1];;){let t=s[r++],n=1&t,a=s[r++];if(n&&i)return a;for(let i=r+(t>>1);r<i;r++)if(s[r]==e)return a;if(n)return-1}}hasAction(e,t){let i=this.data;for(let s=0;s<2;s++)for(let r,n=this.stateSlot(e,s?2:1);;n+=3){if(65535==(r=i[n])){if(1!=i[n+1]){if(2==i[n+1])return H(i,n+2);break}r=i[n=H(i,n+2)]}if(r==t||0==r)return H(i,n+1)}return 0}stateSlot(e,t){return this.states[6*e+t]}stateFlag(e,t){return(this.stateSlot(e,0)&t)>0}validAction(e,t){if(t==this.stateSlot(e,4))return!0;for(let i=this.stateSlot(e,1);;i+=3){if(65535==this.data[i]){if(1!=this.data[i+1])return!1;i=H(this.data,i+2)}if(t==H(this.data,i+1))return!0}}nextStates(e){let t=[];for(let i=this.stateSlot(e,1);;i+=3){if(65535==this.data[i]){if(1!=this.data[i+1])break;i=H(this.data,i+2)}if(0==(1&this.data[i+2])){let e=this.data[i+1];t.some(((t,i)=>1&i&&t==e))||t.push(this.data[i],e)}}return t}overrides(e,t){let i=Z(this.data,this.tokenPrecTable,t);return i<0||Z(this.data,this.tokenPrecTable,e)<i}configure(e){let t=Object.assign(Object.create(U.prototype),this);if(e.props&&(t.nodeSet=this.nodeSet.extend(...e.props)),e.top){let i=this.topRules[e.top];if(!i)throw new RangeError(`Invalid top rule name ${e.top}`);t.top=i}return e.tokenizers&&(t.tokenizers=this.tokenizers.map((t=>{let i=e.tokenizers.find((e=>e.from==t));return i?i.to:t}))),e.contextTracker&&(t.context=e.contextTracker),e.dialect&&(t.dialect=this.parseDialect(e.dialect)),null!=e.strict&&(t.strict=e.strict),e.wrap&&(t.wrappers=t.wrappers.concat(e.wrap)),null!=e.bufferLength&&(t.bufferLength=e.bufferLength),t}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let t=this.dynamicPrecedences;return null==t?0:t[e]||0}parseDialect(e){let t=Object.keys(this.dialects),i=t.map((()=>!1));if(e)for(let s of e.split(" ")){let e=t.indexOf(s);e>=0&&(i[e]=!0)}let s=null;for(let e=0;e<t.length;e++)if(!i[e])for(let i,r=this.dialects[t[e]];65535!=(i=this.data[r++]);)(s||(s=new Uint8Array(this.maxTerm+1)))[i]=1;return new W(e,i,s)}static deserialize(e){return new U(e)}}function H(e,t){return e[t]|e[t+1]<<16}function Z(e,t,i){for(let s,r=t;65535!=(s=e[r]);r++)if(s==i)return r-t;return-1}}}]);
- //# sourceMappingURL=8960.635b556710589072e459.js.map
|