D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
usr
/
share
/
grafana
/
public
/
build
/
Filename :
3565.c72c689910f39dca72d5.js
back
Copy
"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[3565],{53769:(Ce,Oe,l)=>{l.d(Oe,{JX:()=>Le,Wz:()=>T,oZ:()=>ye,uG:()=>S});var j=l(42844),x=l(89949),o=l.n(x),H=l(27702),ue=l(34667),g=l(60644),k=l(40705),w=l(48024),pe=l(1128),fe=l(28580),de=l(73565),te=l(24513);const S=[{value:te.EM.Range,label:"Range",description:"Run query over a range of time."},{value:te.EM.Instant,label:"Instant",description:'Run query against a single point in time. For this query, the "To" time is used.'}];ue.config.featureToggles.lokiExperimentalStreaming&&S.push({value:te.EM.Stream,label:"Stream",description:"Run a query and keep sending results on an interval"});const ye=[{value:1,label:"1/1"}].concat((0,x.map)([2,3,4,5,10],B=>({value:B,label:"1/"+B})));function Le(B){const{lineLimitValue:N,resolution:V,onRunQuery:G,runOnBlur:A,onChange:L}=B,u=B.query??{},D=(0,de.Lw)(u);function R(I){const K={...u,maxLines:T(I)};L(K)}function m(I){const{instant:K,range:re,...ee}=u;L({...ee,queryType:I})}function P(I){u.maxLines!==T(I.currentTarget.value)&&R(I.currentTarget.value)}function M(I){I.key==="Enter"&&G()}function U(I){const K={...u,resolution:I.value};L(K)}return H.createElement("div",{"aria-label":"Loki extra field",className:"gf-form-inline"},H.createElement("div",{"data-testid":"queryTypeField",className:(0,j.cx)("gf-form explore-input-margin",(0,j.css)` flex-wrap: nowrap; `),"aria-label":"Query type field"},H.createElement(g.c,{width:"auto"},"Query type"),H.createElement(k.S,{options:S,value:D,onChange:I=>{m(I),A&&G()}})),H.createElement("div",{"data-testid":"lineLimitField",className:(0,j.cx)("gf-form",(0,j.css)` flex-wrap: nowrap; `),"aria-label":"Line limit field"},H.createElement(w._,{label:"Line limit",tooltip:"Upper limit for number of log lines returned by query."},H.createElement(pe.I,{className:"width-4",placeholder:"auto",type:"number",min:0,onChange:P,onKeyDown:M,value:N,onBlur:()=>{A&&G()}})),H.createElement(w._,{label:"Resolution",tooltip:"Resolution 1/1 sets step parameter of Loki metrics range queries such that each pixel corresponds to one data point. For better performance, lower resolutions can be picked. 1/2 only retrieves a data point for every other pixel, and 1/10 retrieves one data point per 10 pixels."},H.createElement(fe.Ph,{isSearchable:!1,onChange:U,options:ye,value:V,"aria-label":"Select resolution"}))))}var xe=(0,H.memo)(Le);function T(B){const N=parseInt(B,10);if(!(isNaN(N)||N<0))return N}},53310:(Ce,Oe,l)=>{l.d(Oe,{O:()=>o,t:()=>k});var j=l(25224),x=l(55889);function o(w,pe,fe){if(!w)return!1;const de=H(pe);if(!de.length)return!1;let te=de;if(w!==pe){const S=H(w);te=de.flatMap(v=>S.filter(ye=>v.text===ye.text)||v)}return te.map(S=>ue(w,fe,S)).filter(g)}function H(w){const pe=[];return j.E2.parse(w).iterate({enter:de=>{if(de.type.id===x._A){const te=de.node;pe.push({node:te,text:w.substring(te.from,te.to)})}}}),pe}function ue(w,pe,fe){if(pe.length===1){const S=fe.node.from===fe.node.to,v=S&&fe.node.parent?fe.node.parent:fe.node,ye=S?w.substring(v.from,v.to):fe.text;return{startLineNumber:1,startColumn:v.from+1,endLineNumber:1,endColumn:v.to+1,error:ye}}let de=0,te=0;for(let S=0;S<pe.length;S++){if(te=de+pe[S].length,fe.node.from>te){de+=pe[S].length+1;continue}return{startLineNumber:S+1,startColumn:fe.node.from-de+1,endLineNumber:S+1,endColumn:fe.node.to-de+1,error:fe.text}}return null}function g(w){return w!==null}const k={__interval:{text:"1s",value:"1s"},__interval_ms:{text:"1000",value:1e3},__range_ms:{text:"1000",value:1e3},__range_s:{text:"1",value:1},__range:{text:"1s",value:"1s"}}},61875:(Ce,Oe,l)=>{l.d(Oe,{KV:()=>it,Ic:()=>Lt,xf:()=>we,NZ:()=>qe,V8:()=>Ut,$f:()=>Be});var j=l(89949),x=l(91826),o=l(6857),H=l(45383),ue=l(78209),g=l(39343),k=l(56469),w=l(76970),pe=l(90996),fe=l(76305),de=l(53933),te=l(51451),S=l(62247),v=l(1726),ye=l(27938),Le=l(76772),xe=l(31832),T=l(29241),B=l(42751),N=l(34667),V=l(89024),G=l(26858),A=l(99386),L=l(26631),u=l(30209),D=l(22833),R=l(55889),m=l(84084),P=l(6570),M=l.n(P),U=l(99633),I=l(68246),K=l(73308),re=l(84273),ee=l(62434),i=l(24513);const p=["job","namespace"],d="{}",Q=10,C=1e3*60*60*24,J=1e6,ne=[{label:"$__interval",sortValue:"$__interval"},{label:"$__range",sortValue:"$__range"},{label:"1m",sortValue:"00:01:00"},{label:"5m",sortValue:"00:05:00"},{label:"10m",sortValue:"00:10:00"},{label:"30m",sortValue:"00:30:00"},{label:"1h",sortValue:"01:00:00"},{label:"1d",sortValue:"24:00:00"}],oe=null,he=s=>({label:s,filterText:`"${s}"`});function be(s,t){const e=Date.now()-C,r=t.filter(c=>c.ts>e&&c.query.expr===s.label);let a=`Queried ${r.length} times in the last 24h.`;const n=r[0];if(n){const c=(0,U.CQ)(n.ts).fromNow();a=`${a} Last queried ${c}.`}return{...s,documentation:a}}class Pe extends I.iL{constructor(t,e){super(),this.started=!1,this.lookupsDisabled=!1,this.seriesCache=new m.z({max:10}),this.labelsCache=new m.z({max:10}),this.cleanText=r=>r.replace(/[{}[\]="(),!~+\-*/^%\|]/g,"").trim(),this.request=async(r,a)=>{try{return await this.datasource.metadataRequest(r,a)}catch(n){console.error(n)}},this.start=()=>(this.startTask||(this.startTask=this.fetchLabels().then(()=>(this.started=!0,[]))),this.startTask),this.getBeginningCompletionItems=r=>({suggestions:[...this.getEmptyCompletionItems(r).suggestions,...this.getTermCompletionItems().suggestions]}),this.getTermCompletionItems=()=>{const r=[];return r.push({prefixMatch:!0,label:"Functions",items:ee.r8.map(a=>({...a,kind:"function"}))}),{suggestions:r}},this.getPipeCompletionItem=()=>{const r=[];return r.push({label:"Operators",items:ee.Rd.map(a=>({...a,kind:"operators"}))}),r.push({label:"Parsers",items:ee.uR.map(a=>({...a,kind:"parsers"}))}),{suggestions:r}},this.fetchSeriesLabels=async r=>{const a=this.datasource.interpolateString(r),n="series",{start:c,end:f}=this.datasource.getTimeRangeParams(),O=this.generateCacheKey(n,c,f,a);let b=this.seriesCache.get(O);if(!b){const _={"match[]":a,start:c,end:f},Z=await this.request(n,_),{values:Y}=(0,K.DY)(Z);b=Y,this.seriesCache.set(O,b)}return b},this.fetchSeries=async r=>{const a="series",{start:n,end:c}=this.datasource.getTimeRangeParams(),f={"match[]":r,start:n,end:c};return await this.request(a,f)},this.datasource=t,this.labelKeys=[],this.labelFetchTs=0,Object.assign(this,e)}getSyntax(){return ee.ZP}getLabelKeys(){return this.labelKeys}async provideCompletionItems(t,e){const{wrapperClasses:r,value:a,prefix:n,text:c}=t,f={suggestions:[]};if(!a)return f;const O=a?.document.text.length===0,b=a.document.getTextsAtRange(a.selection),_=b.size===1?b.first().getText():null,Z=_?_[a.selection.anchor.offset]:null,Y=r.length>3,W=n&&!Y,ae=!Z||Z===")",q=n&&!c.match(/^['"~=\]})\s]+$/)&&ae,h=/[+\-*/^%]/,y=c.match(h);return r.includes("context-range")?this.getRangeCompletionItems():r.includes("context-labels")?await this.getLabelCompletionItems(t):r.includes("context-pipe")?this.getPipeCompletionItem():O?this.getEmptyCompletionItems(e):W&&ae&&!y?this.getBeginningCompletionItems(e):W&&q?this.getTermCompletionItems():f}getEmptyCompletionItems(t){const e=t?.history,r=[];if(e?.length){const a=(0,j.chain)(e).map(n=>n.query.expr).filter().uniq().take(Q).map(he).map(n=>be(n,e)).value();r.push({prefixMatch:!0,skipSort:!0,label:"History",items:a})}return{suggestions:r}}getRangeCompletionItems(){return{context:"context-range",suggestions:[{label:"Range vector",items:[...ne]}]}}async getLabelCompletionItems({text:t,wrapperClasses:e,labelKey:r,value:a}){let n="context-labels";const c=[];if(!a)return{context:n,suggestions:[]};const f=a.anchorBlock.getText(),O=a.selection.anchor.offset,b=t.match(/^(=|=~|!=|!~)/);let _,Z;try{Z=(0,K.rV)(f,O),_=Z.selector}catch{_=d}if(!r&&_===d){await this.start();const ae=this.getLabelKeys();return{context:n,suggestions:[{label:"Labels",items:ae.map(he)}]}}const Y=Z?Z.labelKeys:[];let W;if(_)if(_===d&&r){const ae=await this.getLabelValues(r);W={[r]:ae}}else W=await this.getSeriesLabels(_);if(!W)return console.warn(`Server did not return any values for selector = ${_}`),{context:n,suggestions:c};if(t&&b||e.includes("attr-value"))r&&W[r]&&(n="context-label-values",c.push({label:`Label values for "${r}"`,items:W[r].map(he).filter(({filterText:ae})=>ae!==t)}));else{const ae=W?Object.keys(W):p;if(ae){const q=(0,j.difference)(ae,Y);if(q.length){const y={label:"Labels",items:q.map(E=>({label:E}))};c.push(y)}}}return{context:n,suggestions:c}}importFromAbstractQuery(t){return{refId:t.refId,expr:(0,K.PL)(t),queryType:i.EM.Range}}exportToAbstractQuery(t){const e=t.expr;if(!e||e.length===0)return{refId:t.refId,labelMatchers:[]};const r=M().tokenize(e,ee.ZP);return{refId:t.refId,labelMatchers:(0,K.UO)(r)}}async getSeriesLabels(t){if(!this.lookupsDisabled)try{return await this.fetchSeriesLabels(t)}catch(e){console.error(e);return}}async fetchLabels(){const t="labels",e=this.datasource.getTimeRangeParams();this.labelFetchTs=Date.now().valueOf();const r=await this.request(t,e);if(Array.isArray(r)){const a=r.slice().sort().filter(n=>n!=="__name__");return this.labelKeys=a,this.labelKeys}return[]}generateCacheKey(t,e,r,a){return[t,this.roundTime(e),this.roundTime(r),a].join()}roundTime(t){return t?Math.floor(t/J/1e3/60/5):0}async getLabelValues(t){return await this.fetchLabelValues(t)}async fetchLabelValues(t){const e=encodeURIComponent(this.datasource.interpolateString(t)),r=`label/${e}/values`,a=this.datasource.getTimeRangeParams(),{start:n,end:c}=a,f=this.generateCacheKey(r,n,c,e),O={start:n,end:c};let b=this.labelsCache.get(f);if(!b){this.labelsCache.set(f,[]);const _=await this.request(r,O);Array.isArray(_)&&(b=_.slice().sort(),this.labelsCache.set(f,b))}return b??[]}async getParserAndLabelKeys(t){const e=await this.datasource.getDataSamples({expr:t,refId:"data-samples"});if(!e.length)return{extractedLabelKeys:[],unwrapLabelKeys:[],hasJSON:!1,hasLogfmt:!1,hasPack:!1};const{hasLogfmt:r,hasJSON:a,hasPack:n}=(0,re.OP)(e[0]);return{extractedLabelKeys:(0,re.e8)(e[0]),unwrapLabelKeys:(0,re.zb)(e[0]),hasJSON:a,hasPack:n,hasLogfmt:r}}}var Me=l(80852),Je=l(19985),et=l(22479),ct=l(90581),Vt=l(48314),Rt=l(69966),pr=l(16993),Tt=l(48592),mr=l(19973),ut=l(37497),Kt={url:"",deserializer:function(s){return JSON.parse(s.data)},serializer:function(s){return JSON.stringify(s)}},gr="WebSocketSubject.error must be called with an object with an error code, and an optional reason: { code: number, reason: string }",Or=function(s){(0,Vt.__extends)(t,s);function t(e,r){var a=s.call(this)||this;if(a._socket=null,e instanceof Tt.y)a.destination=r,a.source=e;else{var n=a._config=(0,Vt.__assign)({},Kt);if(a._output=new Rt.x,typeof e=="string")n.url=e;else for(var c in e)e.hasOwnProperty(c)&&(n[c]=e[c]);if(!n.WebSocketCtor&&WebSocket)n.WebSocketCtor=WebSocket;else if(!n.WebSocketCtor)throw new Error("no WebSocket constructor can be found");a.destination=new ut.t}return a}return t.prototype.lift=function(e){var r=new t(this._config,this.destination);return r.operator=e,r.source=this,r},t.prototype._resetState=function(){this._socket=null,this.source||(this.destination=new ut.t),this._output=new Rt.x},t.prototype.multiplex=function(e,r,a){var n=this;return new Tt.y(function(c){try{n.next(e())}catch(O){c.error(O)}var f=n.subscribe({next:function(O){try{a(O)&&c.next(O)}catch(b){c.error(b)}},error:function(O){return c.error(O)},complete:function(){return c.complete()}});return function(){try{n.next(r())}catch(O){c.error(O)}f.unsubscribe()}})},t.prototype._connectSocket=function(){var e=this,r=this._config,a=r.WebSocketCtor,n=r.protocol,c=r.url,f=r.binaryType,O=this._output,b=null;try{b=n?new a(c,n):new a(c),this._socket=b,f&&(this._socket.binaryType=f)}catch(Z){O.error(Z);return}var _=new mr.w0(function(){e._socket=null,b&&b.readyState===1&&b.close()});b.onopen=function(Z){var Y=e._socket;if(!Y){b.close(),e._resetState();return}var W=e._config.openObserver;W&&W.next(Z);var ae=e.destination;e.destination=pr.Lv.create(function(q){if(b.readyState===1)try{var h=e._config.serializer;b.send(h(q))}catch(y){e.destination.error(y)}},function(q){var h=e._config.closingObserver;h&&h.next(void 0),q&&q.code?b.close(q.code,q.reason):O.error(new TypeError(gr)),e._resetState()},function(){var q=e._config.closingObserver;q&&q.next(void 0),b.close(),e._resetState()}),ae&&ae instanceof ut.t&&_.add(ae.subscribe(e.destination))},b.onerror=function(Z){e._resetState(),O.error(Z)},b.onclose=function(Z){b===e._socket&&e._resetState();var Y=e._config.closeObserver;Y&&Y.next(Z),Z.wasClean?O.complete():O.error(Z)},b.onmessage=function(Z){try{var Y=e._config.deserializer;O.next(Y(Z))}catch(W){O.error(W)}}},t.prototype._subscribe=function(e){var r=this,a=this.source;return a?a.subscribe(e):(this._socket||this._connectSocket(),this._output.subscribe(e),e.add(function(){var n=r._socket;r._output.observers.length===0&&(n&&(n.readyState===1||n.readyState===0)&&n.close(),r._resetState())}),e)},t.prototype.unsubscribe=function(){var e=this._socket;e&&(e.readyState===1||e.readyState===0)&&e.close(),this._resetState(),s.prototype.unsubscribe.call(this)},t}(Rt.u);function hr(s){return new Or(s)}var kt=l(52141),vr=l(99817);const br=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function ft(s){return typeof s=="string"&&br.test(s)}const dt=ft;function zt(s){if(!dt(s))throw TypeError("Invalid UUID");let t;const e=new Uint8Array(16);return e[0]=(t=parseInt(s.slice(0,8),16))>>>24,e[1]=t>>>16&255,e[2]=t>>>8&255,e[3]=t&255,e[4]=(t=parseInt(s.slice(9,13),16))>>>8,e[5]=t&255,e[6]=(t=parseInt(s.slice(14,18),16))>>>8,e[7]=t&255,e[8]=(t=parseInt(s.slice(19,23),16))>>>8,e[9]=t&255,e[10]=(t=parseInt(s.slice(24,36),16))/1099511627776&255,e[11]=t/4294967296&255,e[12]=t>>>24&255,e[13]=t>>>16&255,e[14]=t>>>8&255,e[15]=t&255,e}const jt=zt;function yr(s){s=unescape(encodeURIComponent(s));const t=[];for(let e=0;e<s.length;++e)t.push(s.charCodeAt(e));return t}const Pr="6ba7b810-9dad-11d1-80b4-00c04fd430c8",Er="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function xr(s,t,e){function r(a,n,c,f){var O;if(typeof a=="string"&&(a=yr(a)),typeof n=="string"&&(n=jt(n)),((O=n)===null||O===void 0?void 0:O.length)!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let b=new Uint8Array(16+a.length);if(b.set(n),b.set(a,n.length),b=e(b),b[6]=b[6]&15|t,b[8]=b[8]&63|128,c){f=f||0;for(let _=0;_<16;++_)c[f+_]=b[_];return c}return(0,vr.S)(b)}try{r.name=s}catch{}return r.DNS=Pr,r.URL=Er,r}function Qr(s,t,e,r){switch(s){case 0:return t&e^~t&r;case 1:return t^e^r;case 2:return t&e^t&r^e&r;case 3:return t^e^r}}function _t(s,t){return s<<t|s>>>32-t}function Lr(s){const t=[1518500249,1859775393,2400959708,3395469782],e=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof s=="string"){const c=unescape(encodeURIComponent(s));s=[];for(let f=0;f<c.length;++f)s.push(c.charCodeAt(f))}else Array.isArray(s)||(s=Array.prototype.slice.call(s));s.push(128);const r=s.length/4+2,a=Math.ceil(r/16),n=new Array(a);for(let c=0;c<a;++c){const f=new Uint32Array(16);for(let O=0;O<16;++O)f[O]=s[c*64+O*4]<<24|s[c*64+O*4+1]<<16|s[c*64+O*4+2]<<8|s[c*64+O*4+3];n[c]=f}n[a-1][14]=(s.length-1)*8/Math.pow(2,32),n[a-1][14]=Math.floor(n[a-1][14]),n[a-1][15]=(s.length-1)*8&4294967295;for(let c=0;c<a;++c){const f=new Uint32Array(80);for(let W=0;W<16;++W)f[W]=n[c][W];for(let W=16;W<80;++W)f[W]=_t(f[W-3]^f[W-8]^f[W-14]^f[W-16],1);let O=e[0],b=e[1],_=e[2],Z=e[3],Y=e[4];for(let W=0;W<80;++W){const ae=Math.floor(W/20),q=_t(O,5)+Qr(ae,b,_,Z)+Y+t[ae]+f[W]>>>0;Y=Z,Z=_,_=_t(b,30)>>>0,b=O,O=q}e[0]=e[0]+O>>>0,e[1]=e[1]+b>>>0,e[2]=e[2]+_>>>0,e[3]=e[3]+Z>>>0,e[4]=e[4]+Y>>>0}return[e[0]>>24&255,e[0]>>16&255,e[0]>>8&255,e[0]&255,e[1]>>24&255,e[1]>>16&255,e[1]>>8&255,e[1]&255,e[2]>>24&255,e[2]>>16&255,e[2]>>8&255,e[2]&255,e[3]>>24&255,e[3]>>16&255,e[3]>>8&255,e[3]&255,e[4]>>24&255,e[4]>>16&255,e[4]>>8&255,e[4]&255]}const $r=xr("v5",80,Lr),Gt="6ec946da-0f49-47a8-983a-1d76d17e7c92";function Ht(s,t){const e=s.streams;if(!e||!e.length)return;const r=t.fields[0],a=t.fields[1],n=t.fields[2],c={};for(const f of e){const O=Object.entries(f.stream).map(([b,_])=>`${b}="${_}"`).sort().join("");for(const[b,_]of f.values)r.values.push(new Date(parseInt(b.slice(0,-6),10)).toISOString()),a.values.push(_),n.values.push(pt(b,O,_,c,t.refId))}}function pt(s,t,e,r,a){let n=$r(`${s}_${t}_${e}`,Gt);if(n in r){const c=r[n]+1;r[n]=c,n=`${n}_${c}`}else r[n]=0;return a?`${a}_${n}`:n}class mt{constructor(){this.streams={}}getStream(t,e=5e3){let r=this.streams[t.url];if(r)return r;const a=new kt.a({capacity:t.size});return a.addField({name:"Time",type:T.fS.time,config:{}}),a.addField({name:"Line",type:T.fS.string}),a.addField({name:"id",type:T.fS.string}),a.meta={...a.meta,preferredVisualisationType:"logs"},a.refId=t.refId,r=hr(t.url).pipe((0,g.U)(n=>(Ht(n,a),[a])),(0,Je.a)(n=>n.pipe((0,et.z)((c,f)=>{const O=f+1;return c.code===1006&&O<30?(O>10&&console.warn(`Websocket connection is being disrupted. We keep reconnecting but consider starting new live tailing again. Error: ${c.reason}`),(0,Me.H)(e)):(0,x._)(c)}))),(0,ct.x)(()=>{delete this.streams[t.url]})),this.streams[t.url]=r,r}}var Te=l(25224),Yt=l(33877),gt=l(73807),Qe=l(56812),Rr=l(84749),$e=l(42844),X=l(27702),Tr=l(25111),_r=l(18112),Fe=l(86312),Zt=l(66310),St=l(80011),je=l(66670),Ft=l(41640),qt=l(73453),Jt=l(62108),Ot=l(79978),ht=l(28580),Xe=l(71107),Ae=l(48024),Sr=l(20540),Ct=l(42074),We=l(86383),De=l(64826),ce=l(73565);function Mt(s){return{labels:(0,$e.css)` display: flex; gap: ${s.spacing(.5)}; `,wrapper:(0,$e.css)` display: flex; flex-direction: column; flex: 1; gap: ${s.spacing(.5)}; position: relative; `,textWrapper:(0,$e.css)` display: flex; align-items: center; `,hidden:(0,$e.css)` visibility: hidden; `,label:(0,$e.css)` max-width: 100%; &:first-of-type { margin-bottom: ${s.spacing(2)}; } &:not(:first-of-type) { margin: ${s.spacing(2)} 0; } `,rawQueryContainer:(0,$e.css)` text-align: start; line-break: anywhere; margin-top: -${s.spacing(.25)}; margin-right: ${s.spacing(6)}; min-height: ${s.spacing(4)}; `,ui:(0,$e.css)` background-color: ${s.colors.background.secondary}; padding: ${s.spacing(2)}; `,rawQuery:(0,$e.css)` display: inline; `,queryDescription:(0,$e.css)` margin-left: ${s.spacing(.5)}; `,iconButton:(0,$e.css)` position: absolute; top: ${s.spacing(1)}; right: ${s.spacing(1)}; z-index: ${s.zIndex.navbarFixed}; `,operationsToggle:(0,$e.css)` margin: ${s.spacing(1)} 0 ${s.spacing(-1)} 0; & > div { margin: 0; & > label { padding: 0; } } `}}const er="isLogContextQueryUiOpen";function Dt(s){const{row:t,logContextProvider:e,updateFilter:r,onClose:a,origQuery:n,runContextQuery:c}=s,f=(0,Zt.wW)(Mt),[O,b]=(0,X.useState)([]),[_,Z]=(0,X.useState)(!1),[Y,W]=(0,X.useState)(!1),[ae,q]=(0,X.useState)(Qe.Z.getBool(er,!1)),[h,y]=(0,X.useState)(Qe.Z.getBool(Ge,!1)),E=X.useRef(),$=X.useRef(!1),F=X.useRef([]),z=(0,X.useMemo)(()=>!(_&&O.some(le=>le.fromParser===le.enabled)||h&&e.queryContainsValidPipelineStages(n)),[O,h,_,e,n]);(0,X.useEffect)(()=>{if(_){if(!$.current){$.current=_;return}if(O.filter(({enabled:le,fromParser:_e})=>le&&!_e).length===0){b(F.current);return}return F.current=structuredClone(O),E.current&&clearTimeout(E.current),W(!0),E.current=window.setTimeout(()=>{r(O.filter(({enabled:_e})=>_e));const le={removedLabels:[],selectedExtractedLabels:[]};O.forEach(({enabled:_e,fromParser:Re,label:lt})=>{!_e&&!Re&&le.removedLabels.push(lt),_e&&Re&&le.selectedExtractedLabels.push(lt)}),Qe.Z.set(vt,JSON.stringify(le)),W(!1)},1500),()=>{clearTimeout(E.current)}}},[O,_]),(0,X.useEffect)(()=>()=>{clearTimeout(E.current),a()},[a]),(0,Tr.Z)(async()=>{W(!0);const le=await e.getInitContextFilters(t.labels,n);b(le),Z(!0),W(!1)}),(0,X.useEffect)(()=>((0,Fe.ff)("grafana_explore_logs_loki_log_context_loaded",{logRowUid:t.uid,type:"load"}),()=>{(0,Fe.ff)("grafana_explore_logs_loki_log_context_loaded",{logRowUid:t.uid,type:"unload"})}),[t.uid]);const se=O.filter(({fromParser:le})=>!le),ie=se.filter(({enabled:le})=>le),me=O.filter(({fromParser:le})=>le),ge=me.filter(({enabled:le})=>le),ve=(0,X.useCallback)(le=>({label:`${le.label}="${(0,De.Hk)(le.value)}"`,value:le.label}),[]),Ue=n&&(0,ce.cQ)(n.expr).parserCount===1&&me.length>0;let ke=e.prepareExpression(O.filter(({enabled:le})=>le),n);return X.createElement("div",{className:f.wrapper},X.createElement(St.u,{content:"Revert to initial log context query."},X.createElement("div",{className:f.iconButton},X.createElement(je.zx,{"data-testid":"revert-button",icon:"history-alt",variant:"secondary",disabled:z,onClick:le=>{(0,Fe.ff)("grafana_explore_logs_loki_log_context_reverted",{logRowUid:t.uid}),b(_e=>_e.map(Re=>({...Re,enabled:!Re.fromParser}))),Qe.Z.delete(vt),Qe.Z.delete(Ge),y(!1)}}))),X.createElement(Ft.U,{collapsible:!0,isOpen:ae,onToggle:()=>{Qe.Z.set(er,!ae),q(le=>!le),(0,Fe.ff)("grafana_explore_logs_loki_log_context_toggled",{logRowUid:t.uid,action:ae?"close":"open"})},label:X.createElement("div",{className:f.rawQueryContainer},_?X.createElement(X.Fragment,null,X.createElement(We.U,{lang:{grammar:ee.xY,name:"loki"},query:ke,className:f.rawQuery}),X.createElement(St.u,{content:"The initial log context query is created from all labels defining the stream for the selected log line. Use the editor below to customize the log context query."},X.createElement(qt.J,{name:"info-circle",size:"sm",className:f.queryDescription}))):X.createElement(Jt.$,null))},X.createElement("div",{className:f.ui},X.createElement(Ot._,{className:f.label,description:"The initial log context query is created from all labels defining the stream for the selected log line. You can broaden your search by removing one or more of the label filters."},"Widen the search"),X.createElement(ht.NU,{isLoading:Y,options:se.map(ve),value:ie.map(ve),closeMenuOnSelect:!0,maxMenuHeight:200,noOptionsMessage:"No further labels available",onChange:(le,_e)=>(_e.action==="select-option"&&(0,Fe.ff)("grafana_explore_logs_loki_log_context_filtered",{logRowUid:t.uid,type:"label",action:"select"}),_e.action==="remove-value"&&(0,Fe.ff)("grafana_explore_logs_loki_log_context_filtered",{logRowUid:t.uid,type:"label",action:"remove"}),b(O.map(Re=>(Re.fromParser||(Re.enabled=le.some(lt=>lt.value===Re.label)),Re))))}),Ue&&X.createElement(X.Fragment,null,X.createElement(Ot._,{className:f.label,description:"By using a parser in your original query, you can use filters for extracted labels. Refine your search by applying extracted labels created from the selected log line."},"Refine the search"),X.createElement(ht.NU,{isLoading:Y,options:me.map(ve),value:ge.map(ve),closeMenuOnSelect:!0,maxMenuHeight:200,noOptionsMessage:"No further labels available",isClearable:!0,onChange:(le,_e)=>{_e.action==="select-option"&&(0,Fe.ff)("grafana_explore_logs_loki_log_context_filtered",{logRowUid:t.uid,type:"parsed_label",action:"select"}),_e.action==="remove-value"&&(0,Fe.ff)("grafana_explore_logs_loki_log_context_filtered",{logRowUid:t.uid,type:"parsed_label",action:"remove"}),b(O.map(Re=>(Re.fromParser&&(Re.enabled=le.some(lt=>lt.value===Re.label)),Re)))}})),e.queryContainsValidPipelineStages(n)&&X.createElement(Xe.Z,{className:f.operationsToggle},X.createElement(Ae._,{label:"Include LogQL pipeline operations",tooltip:X.createElement(Sr.D,{content:(0,_r.a)("This will include LogQL operations such as `line_format` or `label_format`. It won't include line or label filter operations.")})},X.createElement(Ct.x,{value:h,showLabel:!0,transparent:!0,onChange:le=>{(0,Fe.ff)("grafana_explore_logs_loki_log_context_pipeline_toggled",{logRowUid:t.uid,action:le.currentTarget.checked?"enable":"disable"}),Qe.Z.set(Ge,le.currentTarget.checked),y(le.currentTarget.checked),c&&c()}}))))))}var Ee=l(87603),Fr=l(93882),tr=(s=>(s[s.Ascending=0]="Ascending",s[s.Descending=1]="Descending",s))(tr||{});function Cr(s,t){const e=s.values,r=Array(e.length);for(let n=0;n<r.length;n++)r[n]=n;const a=t===0;return r.sort((n,c)=>{const f=e[n],O=e[c];return f<O?a?-1:1:f>O?a?1:-1:0}),r}function Nt(s,t){const{fields:e,...r}=s,a=e.find(c=>c.name==="tsNs");if(a===void 0)throw new Error("missing nanosecond-timestamp field. should never happen");const n=Cr(a,t);return{...r,fields:e.map(c=>({...c,values:new Fr.o(c.values,n).toArray()}))}}const vt="lokiLogContextPreservedLabels",Ge="lokiLogContextShouldIncludePipelineOperations";class Ie{constructor(t){this.getLogRowContextQuery=async(e,r,a)=>{const{query:n}=await this.getQueryAndRange(e,r,a);return n},this.getLogRowContext=async(e,r,a)=>{const n=r&&r.direction||te.M4.Backward,{query:c,range:f}=await this.getQueryAndRange(e,r,a),O=_=>{const Y=_.data.map(W=>Nt(W,tr.Descending));return{..._,data:Y}},b=S.zj.Explore;return(0,ue.n)(this.datasource.query(Be(c,f,b,`${qe}${n}`)).pipe((0,k.K)(_=>{throw{message:"Error during context query. Please check JS console logs.",status:_.status,statusText:_.statusText}}),(0,pe.w)(_=>(0,H.of)(O(_)))))},this.processContextFiltersToExpr=(e,r)=>{let n=`{${e.map(c=>!c.fromParser&&c.enabled?`${c.label}="${(0,De.U9)(c.value)}"`:"").filter(c=>!!c).join(",")}}`;if(r&&(0,ce.cQ)(r.expr).parserCount===1){const c=(0,ce.oi)(r.expr);if(c){n=(0,Ee.Pg)(n,c);const f=e.filter(O=>O.fromParser&&O.enabled);for(const O of f)O.enabled&&(n=(0,Ee.F2)(n,O.label,"=",O.value))}}return n},this.processPipelineStagesToExpr=(e,r)=>{let a=e;const n=r?.expr??"";if((0,ce.cQ)(n).parserCount>1)return a;const c=(0,ce.te)(n,[Te.We,Te.Li,Te.wm,Te.pj]),f=c.filter(b=>b.type?.id===Te.We),O=c.filter(b=>b.type?.id!==Te.We);for(const b of f)O.some(_=>b.contains(_))||(a+=` ${b.getExpression(n)}`);return a},this.queryContainsValidPipelineStages=e=>{const r=e?.expr??"",a=(0,ce.te)(r,[Te.We,Te.Li,Te.wm,Te.pj]),n=a.filter(f=>f.type?.id===Te.We),c=a.filter(f=>f.type?.id!==Te.We);return n.some(f=>c.every(O=>f.contains(O)===!1))},this.getInitContextFilters=async(e,r)=>{if(!r||(0,j.isEmpty)(e))return[];let a=[];if(!(0,ce.cQ)(r.expr).queryWithParser)await this.datasource.languageProvider.start(),a=this.datasource.languageProvider.getLabelKeys();else{const f=(0,ce.QI)(r.expr),O=await this.datasource.languageProvider.fetchSeriesLabels(f[0]);a=Object.keys(O)}const n=[];Object.entries(e).forEach(([f,O])=>{const b={label:f,value:O,enabled:a.includes(f),fromParser:!a.includes(f)};n.push(b)});let c;try{c=JSON.parse(Qe.Z.get(vt))}catch{}if(c){let f=!1;const O=n.map(_=>c.removedLabels.includes(_.label)?(f=!0,{..._,enabled:!1}):c.selectedExtractedLabels.includes(_.label)?(f=!0,{..._,enabled:!0}):{..._});return O.some(({enabled:_,fromParser:Z})=>_&&!Z)?(f&&(0,Rr.WI)((0,Yt.$l)((0,gt.AT)("Previously used log context filters have been applied."))),O):n}else return n},this.datasource=t,this.appliedContextFilters=[]}async getQueryAndRange(t,e,r){const a=e&&e.direction||te.M4.Backward,n=e&&e.limit||this.datasource.maxLines;if(this.appliedContextFilters.length===0){const c=(await this.getInitContextFilters(t.labels,r)).filter(f=>f.enabled);this.appliedContextFilters=c}return await this.prepareLogRowContextQueryTarget(t,n,a,r)}async prepareLogRowContextQueryTarget(t,e,r,a){const n=this.prepareExpression(this.appliedContextFilters,a),c=2*60*60*1e3,f=r===te.M4.Forward?i.sb.Forward:i.sb.Backward,O={expr:n,queryType:i.EM.Range,refId:`${qe}_${Math.random().toString()}`,maxLines:e,direction:f,datasource:{uid:this.datasource.uid,type:this.datasource.type}},_=new xe.N(t.dataFrame).getFirstFieldOfType(T.fS.time);if(_===void 0)throw new Error("loki: data frame missing time-field, should never happen");const Z=_.values[t.rowIndex],Y=(0,U.zh)(Z),W=f===i.sb.Forward?{from:Y,to:(0,U.zh)(t.timeEpochMs+c)}:{from:(0,U.zh)(t.timeEpochMs-c),to:Y};return{query:O,range:{from:W.from,to:W.to,raw:W}}}getLogRowContextUi(t,e,r){const a=n=>{this.appliedContextFilters=n,e&&e()};return this.onContextClose=this.onContextClose??(()=>{this.appliedContextFilters=[]}),Dt({row:t,origQuery:r,updateFilter:a,onClose:this.onContextClose,logContextProvider:this,runContextQuery:e})}prepareExpression(t,e){let r=this.processContextFiltersToExpr(t,e);return Qe.Z.getBool(Ge,!1)&&(r=this.processPipelineStagesToExpr(r,e)),r}}var He=l(32053),Ye=l(10864);function Mr(s,t){if(!t.length)return[];const e=(0,j.groupBy)(t,"name"),r=Object.values(e).map(Bt),a=s.fields.find(n=>n.type===T.fS.string);if(a===void 0)throw new Error("invalid logs-dataframe, string-field missing");return a.values.forEach(n=>{for(const c of r){const f=n.match(e[c.name][0].matcherRegex);c.values.push(f&&f[1])}}),r}function Bt(s){const t=(0,Ye.F)(),e=s.reduce((r,a)=>{if(a.datasourceUid){const n=t.getInstanceSettings(a.datasourceUid);r.push({title:a.urlDisplayLabel||"",url:"",internal:{query:{query:a.url,queryType:n?.type==="tempo"?"traceql":void 0},datasourceUid:a.datasourceUid,datasourceName:n?.name??"Data source not found"}})}else a.url&&r.push({title:a.urlDisplayLabel||"",url:a.url});return r},[]);return{name:s[0].name,type:T.fS.string,config:{links:e},values:[]}}function tt(s){const t=s.filter(r=>r.refId!==void 0),e=(0,j.groupBy)(t,r=>r.refId);return Object.entries(e).map(([r,a])=>Dr(a,r))}function Dr(s,t){const e={name:"Time",config:{},values:[],type:T.fS.time},r={name:`Value #${t}`,config:{},values:[],type:T.fS.number},a=new Set(s.map(f=>f.fields.map(O=>Object.keys(O.labels??{})).flat()).flat()),c=Array.from(a).sort().map(f=>({name:f,config:{filterable:!0},values:[],type:T.fS.string}));return s.forEach(f=>{const O=f.fields.find(W=>W.type===T.fS.time),b=f.fields.find(W=>W.type===T.fS.number);if(O==null||b==null)return;const _=O.values,Z=b.values;for(let W of _)e.values.push(W);for(let W of Z)r.values.push(W);const Y=b.labels??{};for(let W of c){const ae=Y[W.name]??"";for(let q=0;q<Z.length;q++)W.values.push(ae)}}),{fields:[e,...c,r],refId:t,meta:{preferredVisualisationType:"table"},length:e.values.length}}function Nr(s){return s.fields.every(t=>t.type===T.fS.time||t.type===T.fS.number)}function rr(s,t){const{meta:e,...r}=s,a={...e,...t};return{...r,meta:a}}function Br(s,t,e){const r={...s.meta?.custom,lokiQueryStatKey:"Summary: total bytes processed"};(0,re.vh)(s)&&(r.error="Error when parsing some of the logs");const a={preferredVisualisationType:"logs",limit:t?.maxLines,searchWords:t!==void 0?(0,ce.n6)((0,ce.x9)(t.expr)):void 0,custom:r},n=rr(s,a),c=Mr(n,e);return{...n,fields:[...n.fields,...c]}}function Ir(s,t,e){return s.map(r=>{const a=r.refId!==void 0?t.get(r.refId):void 0;return Br(r,a,e)})}function wr(s){return s.length>0?tt(s):[]}function Ne(s){const t={preferredVisualisationType:"graph"};return s.map(e=>rr(e,t))}function bt(s,t){const e=[],r=[],a=[];return s.forEach(n=>{Nr(n)?n.refId!=null&&t.get(n.refId)?.queryType===i.EM.Instant?r.push(n):a.push(n):e.push(n)}),{streamsFrames:e,metricInstantFrames:r,metricRangeFrames:a}}function yt(s,t){if(s===void 0)return s;const{refId:e,message:r}=s;if(e===void 0||r===void 0)return s;const a=t.get(e);return a===void 0?s:r.includes("escape")&&a.expr.includes("\\")?{...s,message:`${r}. Make sure that all special characters are escaped with \\. For more information on escaping of special characters visit LogQL documentation at https://grafana.com/docs/loki/latest/logql/.`}:s}function Ar(s,t,e){const{data:r,error:a,...n}=s,c=r.map(Z=>{if(!(0,He.aY)(Z))throw new Error("transformation only supports dataframe responses");return Z}),f=new Map(t.map(Z=>[Z.refId,Z])),{streamsFrames:O,metricInstantFrames:b,metricRangeFrames:_}=bt(c,f);return{...n,error:yt(a,f),data:[...Ne(_),...wr(b),...Ir(O,f,e)]}}var Ur=l(57942),It=l(81924),Pt=l(1128),Xr=l(53769),Wr=l(83392);const Vr=(0,X.memo)(function(t){const{annotation:e,onAnnotationChange:r,history:a}=t;if(e===void 0||r===void 0)return null;const n=f=>{const O=(0,ce.Ib)(f).queryType===i.EM.Instant;r({...e,expr:f.expr,maxLines:f.maxLines,instant:O})},c={refId:"",expr:e.expr,maxLines:e.maxLines,instant:e.instant,queryType:e.queryType};return X.createElement(X.Fragment,null,X.createElement("div",{className:"gf-form-group"},X.createElement(Wr.n,{datasource:t.datasource,query:c,onChange:n,onRunQuery:()=>{},history:a,ExtraFieldElement:X.createElement(Xr.JX,{lineLimitValue:c?.maxLines?.toString()||"",resolution:c.resolution||1,query:c,onRunQuery:()=>{},onChange:n})})),X.createElement(Ur.p,null,X.createElement(It.S,{label:"Title",tooltip:"Use either the name or a pattern. For example, {{instance}} is replaced with label value for the label instance."},X.createElement(Pt.I,{type:"text",placeholder:"alertname",value:e.titleFormat,onChange:f=>{r({...e,titleFormat:f.currentTarget.value})}})),X.createElement(It.S,{label:"Tags"},X.createElement(Pt.I,{type:"text",placeholder:"label1,label2",value:e.tagKeys,onChange:f=>{r({...e,tagKeys:f.currentTarget.value})}})),X.createElement(It.S,{label:"Text",tooltip:"Use either the name or a pattern. For example, {{instance}} is replaced with label value for the label instance."},X.createElement(Pt.I,{type:"text",placeholder:"instance",value:e.textFormat,onChange:f=>{r({...e,textFormat:f.currentTarget.value})}}))))});var ar=l(53310);const nr=/^label_names\(\)\s*$/,sr=/^label_values\((?:(.+),\s*)?([a-zA-Z_$][a-zA-Z0-9_]*)\)\s*$/;function Kr(s){if(typeof s!="string")return s;const t={refId:"LokiVariableQueryEditor-VariableQuery",type:i.Z3.LabelNames};if(s.match(nr))return{...t,type:i.Z3.LabelNames};const r=s.match(sr);return r?{...t,type:i.Z3.LabelValues,label:r[2]?r[2]:r[1],stream:r[2]?r[1]:void 0}:t}function kr(s,t){if(t.length===0)return[];const e=[],{queryWithParser:r,parserCount:a}=(0,ce.cQ)(s);if(!r){const{hasLogfmt:f,hasJSON:O,hasPack:b}=(0,re.OP)(t[0]);O&&(b?e.push({type:"ADD_UNPACK_PARSER",label:"Selected log stream selector has packed logs.",fix:{title:"add unpack parser",label:"Consider using unpack parser.",action:{type:"ADD_UNPACK_PARSER",query:s}}}):e.push({type:"ADD_JSON_PARSER",label:"Selected log stream selector has JSON formatted logs.",fix:{title:"add json parser",label:"Consider using JSON parser.",action:{type:"ADD_JSON_PARSER",query:s}}})),f&&e.push({type:"ADD_LOGFMT_PARSER",label:"Selected log stream selector has logfmt formatted logs.",fix:{title:"add logfmt parser",label:"Consider using logfmt parser to turn key-value pairs in your log lines to labels.",action:{type:"ADD_LOGFMT_PARSER",query:s}}})}if(r){if(a===1){const O=(0,ce.N7)(s);(0,re.ki)(t[0])&&!O&&e.push({type:"ADD_NO_PIPELINE_ERROR",label:"Some logs in your selected log streams have parsing error.",fix:{title:"remove pipeline errors",label:"Consider filtering out logs with parsing errors.",action:{type:"ADD_NO_PIPELINE_ERROR",query:s}}})}(0,ce.Iu)(s)||e.push({type:"ADD_LABEL_FILTER",label:"Consider filtering logs by their label and value.",fix:{title:"add label filter",label:"",action:{type:"ADD_LABEL_FILTER",query:s}}})}if(!(0,ce.hI)(s)){const f=(0,re.EO)(t[0]),O=(0,re.Y)(t[0]);!f&&O&&e.push({type:"ADD_LEVEL_LABEL_FORMAT",label:`Some logs in your selected log stream have "${O}" label.`,fix:{title:"add label level format",label:`If ${O} label has level values, consider using label_format to rename it to "level". Level label can be then visualized in log volumes.`,action:{type:"ADD_LEVEL_LABEL_FORMAT",query:s,options:{renameTo:"level",originalLabel:O}}}})}return(0,ce.Qh)(s)||e.push({type:"ADD_LINE_FILTER",label:"Consider filtering logs for specific string.",fix:{title:"add line filter",label:"",action:{type:"ADD_LINE_FILTER",query:s}}}),e}var zr=l(66117),jr=l(46580),Gr=l(69376),Ve=l(32082),Ke=l(66805);function rt(s,t,e){if(t-s<=e)return[[s,t]];const r=[];for(let a=t;a>s;a-=e){const n=Math.max(a-e,s);r.push([n,a])}return r.reverse(),r}function Ze(s,t,e){const r=s-s%e;let a=t;const n=t%e;return n!==0&&(a+=e-n),[r,a]}function at(s,t,e,r){if(r<e)return[[s,t]];const a=Math.trunc(r/e)*e,[n,c]=Ze(s,t,e),f=[];for(let O=c;O>n;O-=a+e){const b=Math.max(O-a,n);f.push([b,O])}return f.reverse(),f}var ir=l(57864);function or(s,t,e,r){const a=t.from.toDate().getTime(),n=t.to.toDate().getTime();return(s?rt(a,n,r):at(a,n,e,r)).map(([f,O])=>{const b=(0,U.CQ)(f),_=(0,U.CQ)(O);return{from:b,to:_,raw:{from:b,to:_}}})}function Hr(s,t){return t?s.map(e=>{if(!e.maxLines||!(0,ce.rE)(e.expr))return e;const r=t.data.find(n=>n.refId===e.refId);if(!r)return e;const a=e.maxLines-r.length;return{...e,maxLines:a<0?0:a}}).filter(e=>e.maxLines===void 0||e.maxLines>0):s}function ze(s,t){let e={data:[],state:Ke.Gu.Streaming};const r=Math.max(...t.map(({partition:b})=>b.length)),a=t.filter(({partition:b})=>b.length===r)[0].partition;let n=!1,c=null;const f=(b,_,Z)=>{if(n){b.complete();return}const Y=()=>{e.state=Ke.Gu.Done,b.next(e),b.complete()},W=()=>{const{nextRequestN:E,nextRequestGroup:$}=Et(t,Z,_);if(E>0&&$>=0){f(b,E,$);return}Y()},ae=t[Z],q=ae.partition[_-1],h=Hr(ae.request.targets,e);if(!h.length){W();return}const y={...t[Z].request,range:q,targets:h};ae.request.requestId&&(y.requestId=`${ae.request.requestId}_${_}`),c=s.runQuery(y).subscribe({next:E=>{e=(0,re._P)(e,E),e=Yr(e,y,a,_),((e.errors??[]).length>0||e.error!=null)&&(n=!0)},complete:()=>{b.next(e),W()},error:E=>{b.error(E)}})};return new Tt.y(b=>(f(b,r,0),()=>{n=!0,c?.unsubscribe()}))}function Yr(s,t,e,r){if((0,ce.rE)(t.targets[0].expr)||nt(t))return s;const a="loki-splitting-progress";if(s.data=s.data.filter(c=>c.name!==a),r<=1)return s;const n=(0,jr.P)([{time:e[0].from.valueOf(),timeEnd:e[r-2].to.valueOf(),isRegion:!0,color:"rgba(120, 120, 120, 0.1)"}]);return n.name=a,n.meta={dataTopic:Gr.w5.Annotations},s.data.push(n),s}function nt(s){return s.targets.some(t=>t.refId.startsWith("log-volume"))}function Et(s,t,e){for(let r=t+1;r<s.length;r++)if(s[r].partition[e-1])return{nextRequestGroup:r,nextRequestN:e};return{nextRequestGroup:s.findIndex(r=>r?.partition[e-1]!==void 0),nextRequestN:e-1}}function xt(s){return s.queryType!==i.EM.Instant&&!(0,ce.zE)(s.expr)}function Zr(s,t){const e=t.targets.filter(Y=>!Y.hide).filter(Y=>Y.expr),[r,a]=(0,j.partition)(e,Y=>!xt(Y)),[n,c]=(0,j.partition)(a,Y=>(0,ce.rE)(Y.expr));t.queryGroupId=(0,zr.Z)();const f=24*60*60*1e3,O=(0,j.groupBy)(n,Y=>Y.splitDuration?(0,Ve.iX)((0,Ve.RA)(Y.splitDuration)):f),b=(0,j.groupBy)(c,Y=>Y.splitDuration?(0,Ve.iX)((0,Ve.RA)(Y.splitDuration)):f),_=[];for(const[Y,W]of Object.entries(O)){const ae=(0,j.groupBy)(W,q=>q.resolution||1);for(const q in ae)_.push({request:{...t,targets:ae[q]},partition:or(!0,t.range,t.intervalMs,Number(Y))})}for(const[Y,W]of Object.entries(b)){const ae=(0,j.groupBy)(W,q=>qr(t.intervalMs,t.range,q.resolution||1,q.step));for(const q in ae)_.push({request:{...t,targets:ae[q]},partition:or(!1,t.range,Number(q),Number(Y))})}r.length&&_.push({request:{...t,targets:r},partition:[t.range]});const Z=new Date;return ze(s,_).pipe((0,w.b)(Y=>{Y.state===Ke.Gu.Done&&(0,ir.Dl)(Y,_,t,Z,{predefinedOperations:s.predefinedOperations})}))}function qr(s,t,e,r){const a=/(-?\d+(?:\.\d+)?)(ms|[Mwdhmsy])/;if(r?.match(a))return fe.intervalToMs(r)*e;const n=s*e,c=Math.round((t.to.valueOf()-t.from.valueOf())/11e3);return Math.max(n,c)}var lr=l(63384),cr=l(47838),Jr=l(81087),ea=l(43685);async function ur(s){const t=JSON.stringify({expr:s.expr}),e=new TextEncoder().encode(t),r=await crypto.subtle.digest("SHA-1",e);return Array.from(new Uint8Array(r.slice(0,8))).map(n=>n.toString(16).padStart(2,"0")).join("")}function fr(s,t,e){const r=e.range,a=r.to.valueOf()-r.from.valueOf()+1e3;let n=e.maxDataPoints??1e3;n>100&&(n*=2);let c;const f=O=>{if(O?.message){const b=O.message;c?c.push(b):c=cr.Av.fromDataFrameJSON(b,{maxLength:n,maxDelta:a,displayNameFormat:s.legendFormat})}return c};return(0,lr.P)(()=>ur(s)).pipe((0,et.z)(O=>(0,ea.gj)().getStream({scope:Jr.z.DataSource,namespace:t.uid,path:`tail/${O}`,data:{...s,timeRange:{from:r.from.valueOf().toString(),to:r.to.valueOf().toString()}}}).pipe((0,g.U)(b=>{const _=f(b);return{data:_?[_]:[],state:de.Gu.Streaming}}))))}var ta=l(91053),ra=l(79726);const aa=[{label:"Label names",value:i.Z3.LabelNames},{label:"Label values",value:i.Z3.LabelValues}],na="LokiVariableQueryEditor-VariableQuery",Qt=({onChange:s,query:t,datasource:e})=>{const[r,a]=(0,X.useState)(void 0),[n,c]=(0,X.useState)(""),[f,O]=(0,X.useState)([]),[b,_]=(0,X.useState)("");(0,X.useEffect)(()=>{if(!t)return;const q=typeof t=="string"?Kr(t):t;a(q.type),c(q.label||""),_(q.stream||"")},[t]),(0,X.useEffect)(()=>{r===i.Z3.LabelValues&&e.labelNamesQuery().then(q=>{O(q.map(({text:h})=>({label:h,value:h})))})},[e,r]);const Z=q=>{a(q.value),q.value!==void 0&&s({type:q.value,label:n,stream:b,refId:na})},Y=q=>{c(q.value||"")},W=q=>{_(q.currentTarget.value)},ae=()=>{r!==void 0&&s({type:r,label:n,stream:b,refId:"LokiVariableQueryEditor-VariableQuery"})};return X.createElement(X.Fragment,null,X.createElement(Xe.Z,null,X.createElement(Ae._,{label:"Query type",labelWidth:20},X.createElement(ht.Ph,{"aria-label":"Query type",onChange:Z,onBlur:ae,value:r,options:aa,width:16})),r===i.Z3.LabelValues&&X.createElement(X.Fragment,null,X.createElement(Ae._,{label:"Label",labelWidth:20},X.createElement(ht.Ph,{"aria-label":"Label",onChange:Y,onBlur:ae,value:{label:n,value:n},options:f,width:16,allowCustomValue:!0})))),r===i.Z3.LabelValues&&X.createElement(Xe.Z,null,X.createElement(Ae._,{label:"Stream selector",labelWidth:20,grow:!0,tooltip:X.createElement("div",null,'Optional. If defined, a list of values for the specified log stream selector is returned. For example: {label="value"} or {label="$variable"}')},X.createElement(Pt.I,{type:"text","aria-label":"Stream selector",placeholder:"Optional stream selector",value:b,onChange:W,onBlur:ae}))))};class wt extends ra.Mg{constructor(t){super(),this.datasource=t,this.editor=Qt,this.query=this.query.bind(this)}async execute(t){return this.datasource.metricFindQuery(t)}query(t){const e=this.execute(t.targets[0]);return(0,ta.D)(e).pipe((0,g.U)(r=>({data:r})))}}const At=1e3,st="/loki/api/v1",Lt="loki-data-samples",we="annotation-",qe="log-row-context-query-",Ut="log-volume-",Xt="log-sample-",Se=1e6;function Be(s,t,e,r,a){const n=fe.calculateInterval(t,1);return{targets:[s],requestId:r,interval:n.interval,intervalMs:n.intervalMs,range:t,scopedVars:{},timezone:"UTC",app:e,startTime:Date.now(),hideFromInspector:a}}class it extends B.CK{constructor(t,e=(0,A.J)(),r=(0,G.$t)()){super(t),this.instanceSettings=t,this.templateSrv=e,this.timeSrv=r,this.streams=new mt,this.runLiveQuery=(n,c)=>{const f=this.createLiveTarget(n,c);return this.streams.getStream(f).pipe((0,g.U)(O=>({data:O||[],key:`loki-${f.refId}`,state:de.Gu.Streaming})),(0,k.K)(O=>(0,x._)(()=>`Live tailing was stopped due to following error: ${O.reason}`)))},this.getLogRowContext=async(n,c,f)=>await this.logContextProvider.getLogRowContext(n,c,(0,ce.QT)(f)),this.getLogRowContextQuery=async(n,c,f)=>await this.logContextProvider.getLogRowContextQuery(n,c,(0,ce.QT)(f)),this.languageProvider=new Pe(this);const a=t.jsonData||{};this.maxLines=parseInt(a.maxLines??"0",10)||At,this.predefinedOperations=a.predefinedOperations??"",this.annotations={QueryEditor:Vr},this.variables=new wt(this),this.logContextProvider=new Ie(this)}getDataProvider(t,e){if(this.getSupportedSupplementaryQueryTypes().includes(t))switch(t){case te.v8.LogsVolume:return this.getLogsVolumeDataProvider(e);case te.v8.LogsSample:return this.getLogsSampleDataProvider(e);default:return}}getSupportedSupplementaryQueryTypes(){return[te.v8.LogsVolume,te.v8.LogsSample]}getSupplementaryQuery(t,e){if(!this.getSupportedSupplementaryQueryTypes().includes(t.type))return;const r=(0,ce.Ib)(e),a=(0,Ee.C6)(r.expr);let n=!1;switch(t.type){case te.v8.LogsVolume:return n=!!(a&&(0,ce.rE)(a)&&r.queryType===i.EM.Range),n?{...r,refId:`${Ut}${r.refId}`,queryType:i.EM.Range,supportingQueryType:i.$o.LogsVolume,expr:`sum by (level) (count_over_time(${a}[$__interval]))`}:void 0;case te.v8.LogsSample:return n=!!(a&&!(0,ce.rE)(a)),n?{...r,queryType:i.EM.Range,refId:`${Xt}${r.refId}`,expr:(0,ce.SP)(a),maxLines:Number.isNaN(Number(t.limit))?this.maxLines:Number(t.limit)}:void 0;default:return}}getLogsVolumeDataProvider(t){const e=(0,j.cloneDeep)(t),r=e.targets.map(a=>this.getSupplementaryQuery({type:te.v8.LogsVolume},a)).filter(a=>!!a);if(r.length)return(0,u.Bz)(this,{...e,targets:r},{extractLevel:Wt,range:t.range,targets:t.targets})}getLogsSampleDataProvider(t){const e=(0,j.cloneDeep)(t),r=e.targets.map(a=>this.getSupplementaryQuery({type:te.v8.LogsSample,limit:100},a)).filter(a=>!!a);if(r.length)return(0,u.Ce)(this,{...e,targets:r})}query(t){const e=t.targets.map(ce.Ib).map(c=>({...c,maxLines:c.maxLines??this.maxLines})),r={...t,targets:e},a=r.targets.filter(c=>c.queryType===i.EM.Stream);if(N.config.featureToggles.lokiExperimentalStreaming&&a.length>0&&r.rangeRaw?.to==="now"){const c={...r,targets:a};return(0,o.T)(...a.map(f=>fr(this.applyTemplateVariables(f,t.scopedVars),this,c)))}if(r.liveStreaming)return this.runLiveQueryThroughBackend(r);if(N.config.featureToggles.lokiQuerySplitting&&(0,ce.TH)(r.targets))return Zr(this,r);const n=new Date;return this.runQuery(r).pipe((0,w.b)(c=>(0,ir.Ci)(c,r,n,{predefinedOperations:this.predefinedOperations})))}runQuery(t){return super.query(t).pipe((0,g.U)(e=>Ar(e,t.targets,this.instanceSettings.jsonData.derivedFields??[])))}runLiveQueryThroughBackend(t){const e=t.targets.filter(a=>a.expr!==""&&(0,ce.rE)(a.expr));if(e.length===0)return(0,H.of)({data:[],state:de.Gu.Done});const r=e.map(a=>{const n=a.maxLines||this.maxLines;return this.runLiveQuery(a,n)});return(0,o.T)(...r)}createLiveTarget(t,e){const r=t.expr,a=this.instanceSettings.url,n=(0,L.tW)({query:r});return{query:r,url:(0,V.F3)(`${a}/loki/api/v1/tail?${n}`),refId:t.refId,size:e}}getRangeScopedVars(t=this.getTimeRange()){const e=t.to.diff(t.from),r=Math.round(e/1e3);return{__range_ms:{text:e,value:e},__range_s:{text:r,value:r},__range:{text:r+"s",value:r+"s"}}}interpolateVariablesInQueries(t,e){let r=t;return t&&t.length&&(r=t.map(a=>({...a,datasource:this.getRef(),expr:this.addAdHocFilters(this.templateSrv.replace(a.expr,e,this.interpolateQueryExpr))}))),r}getQueryDisplayText(t){return t.expr}getTimeRange(){return this.timeSrv.timeRange()}getTimeRangeParams(){const t=this.getTimeRange();return{start:t.from.valueOf()*Se,end:t.to.valueOf()*Se}}async importFromAbstractQueries(t){await this.languageProvider.start();const e=this.languageProvider.labelKeys;return e&&e.length&&(t=t.map(r=>(r.labelMatchers=r.labelMatchers.filter(a=>e.includes(a.name)),r))),t.map(r=>this.languageProvider.importFromAbstractQuery(r))}async exportToAbstractQueries(t){return t.map(e=>this.languageProvider.exportToAbstractQuery(e))}async metadataRequest(t,e,r){if(t.startsWith("/"))throw new Error(`invalid metadata request url: ${t}`);return(await this.getResource(t,e,r)).data||[]}async statsMetadataRequest(t,e,r){if(t.startsWith("/"))throw new Error(`invalid metadata request url: ${t}`);return await this.getResource(t,e,r)}async getQueryStats(t){if((0,ce.I2)(this.interpolateString(t,ar.t)))return;const{start:e,end:r}=this.getTimeRangeParams(),a=(0,ce.QI)(t);let n={streams:0,chunks:0,bytes:0,entries:0};for(const c of a)try{const f=await this.statsMetadataRequest("index/stats",{query:c,start:e,end:r},{showErrorAlert:!1});n={streams:n.streams+f.streams,chunks:n.chunks+f.chunks,bytes:n.bytes+f.bytes,entries:n.entries+f.entries}}catch{break}return n}async metricFindQuery(t){if(!t)return Promise.resolve([]);if(typeof t=="string"){const r=this.interpolateString(t);return await this.legacyProcessMetricFindQuery(r)}const e={...t,label:this.interpolateString(t.label||""),stream:this.interpolateString(t.stream||"")};return await this.processMetricFindQuery(e)}async processMetricFindQuery(t){return t.type===i.Z3.LabelNames?this.labelNamesQuery():t.label?t.stream?this.labelValuesSeriesQuery(t.stream,t.label):this.labelValuesQuery(t.label):[]}async legacyProcessMetricFindQuery(t){if(t.match(nr))return await this.labelNamesQuery();const r=t.match(sr);return r?r[1]?await this.labelValuesSeriesQuery(r[1],r[2]):await this.labelValuesQuery(r[2]):Promise.resolve([])}async labelNamesQuery(){const t="labels",e=this.getTimeRangeParams();return(await this.metadataRequest(t,e)).map(a=>({text:a}))}async labelValuesQuery(t){const e=this.getTimeRangeParams(),r=`label/${t}/values`;return(await this.metadataRequest(r,e)).map(n=>({text:n}))}async labelValuesSeriesQuery(t,e){const a={...this.getTimeRangeParams(),"match[]":t},n="series",c=new Set;return(await this.metadataRequest(n,a)).forEach(O=>{O[e]&&c.add({text:O[e]})}),Array.from(c)}async getDataSamples(t){if(!(0,ce.rE)(t.expr)||(0,ce.I2)(this.interpolateString(t.expr,ar.t)))return[];const e={expr:t.expr,queryType:i.EM.Range,refId:Lt,maxLines:10},r=this.getTimeRange(),a=Be(e,r,S.zj.Unknown,Lt,!0);return await(0,ue.n)(this.query(a).pipe((0,pe.w)(n=>(0,H.of)(n.data))))}async getTagKeys(){return await this.labelNamesQuery()}async getTagValues(t={}){return await this.labelValuesQuery(t.key)}interpolateQueryExpr(t,e){return!e.multi&&!e.includeAll?ot(t):typeof t=="string"?$t(t):(0,j.map)(t,$t).join("|")}toggleQueryFilter(t,e){let r=t.expr??"";switch(e.type){case"FILTER_FOR":{if(e.options?.key&&e.options?.value){const a=(0,De.Hk)(e.options.value);r=(0,Ee.j2)(r,e.options.key,"=",a)?(0,Ee.zX)(r,e.options.key,"=",a):(0,Ee.F2)(r,e.options.key,"=",a)}break}case"FILTER_OUT":{if(e.options?.key&&e.options?.value){const a=(0,De.Hk)(e.options.value);(0,Ee.j2)(r,e.options.key,"=",a)&&(r=(0,Ee.zX)(r,e.options.key,"=",a)),r=(0,Ee.F2)(r,e.options.key,"!=",a)}break}default:break}return{...t,expr:r}}queryHasFilter(t,e){let r=t.expr??"";return(0,Ee.j2)(r,e.key,"=",e.value)}modifyQuery(t,e){let r=t.expr??"";switch(e.type){case"ADD_FILTER":{if(e.options?.key&&e.options?.value){const a=(0,De.Hk)(e.options.value);r=(0,Ee.F2)(r,e.options.key,"=",a)}break}case"ADD_FILTER_OUT":{if(e.options?.key&&e.options?.value){const a=(0,De.Hk)(e.options.value);r=(0,Ee.F2)(r,e.options.key,"!=",a)}break}case"ADD_LOGFMT_PARSER":{r=(0,Ee.Pg)(r,"logfmt");break}case"ADD_JSON_PARSER":{r=(0,Ee.Pg)(r,"json");break}case"ADD_UNPACK_PARSER":{r=(0,Ee.Pg)(r,"unpack");break}case"ADD_NO_PIPELINE_ERROR":{r=(0,Ee.cT)(r);break}case"ADD_LEVEL_LABEL_FORMAT":{e.options?.originalLabel&&e.options?.renameTo&&(r=(0,Ee.NT)(r,{renameTo:e.options.renameTo,originalLabel:e.options.originalLabel}));break}case"ADD_LABEL_FILTER":{const a=(0,Ee.qC)(t.expr),n=(0,Ee.st)(t.expr),c=(0,Ee.EF)([...a,...n]),f=(0,Ee.y2)("","","=");r=(0,Ee.g8)(r,[c],f);break}case"ADD_LINE_FILTER":{r=(0,Ee.Ld)(r);break}default:break}return{...t,expr:r}}getTime(t,e){return typeof t=="string"&&(t=v.parse(t,e)),Math.ceil(t.valueOf()*1e6)}getLogRowContextUi(t,e,r){return this.logContextProvider.getLogRowContextUi(t,e,(0,ce.QT)(r))}testDatasource(){const t=Date.now(),e={start:(t-10*60*1e3)*Se,end:t*Se};return this.metadataRequest("labels",e).then(r=>r.length>0?{status:"success",message:"Data source successfully connected."}:{status:"error",message:"Data source connected, but no labels were received. Verify that Loki and Promtail are correctly configured."},r=>{const a=r?.data?.message??"";return{status:"error",message:`Unable to connect with Loki${a!==""?` (${a})`:""}. Please check the server logs for more details.`}})}async annotationQuery(t){const{expr:e,maxLines:r,instant:a,tagKeys:n="",titleFormat:c="",textFormat:f=""}=t.annotation;if(!e)return[];const O=`${we}${t.annotation.name}`,b={refId:O,expr:e,maxLines:r,instant:a,queryType:a?i.EM.Instant:i.EM.Range},_=Be(b,t.range,S.zj.Dashboard,O),{data:Z}=await(0,ue.n)(this.query(_)),Y=[],W=n.split(",").filter(ae=>ae!=="");for(const ae of Z)new ye.U(ae).forEach(h=>{const{labels:y}=h,E=Object.entries(y).map(([F,z])=>[F,z.trim()]).filter(([F,z])=>!(z===""||W.length&&!W.includes(F))).map(([F,z])=>z),$=Array.from(new Set(E));Y.push({time:new Date(h.Time).valueOf(),title:(0,Le.W)(c,y),text:(0,Le.W)(f,y)||h.Line,tags:$})});return Y}showContextToggle(t){return!0}processError(t,e){let r=(0,j.cloneDeep)(t);return r.refId=e.refId,r.data&&t.data.message.includes("escape")&&e.expr.includes("\\")&&(r.data.message=`Error: ${t.data.message}. Make sure that all special characters are escaped with \\. For more information on escaping of special characters visit LogQL documentation at https://grafana.com/docs/loki/latest/logql/.`),r}addAdHocFilters(t){const e=this.templateSrv.getAdhocFilters(this.name);let r=(0,R.bU)(t);return r=e.reduce((a,n)=>{const{key:c,operator:f}=n;let{value:O}=n;return(0,De._z)(f)?O=ot(O):O=(0,De.Hk)(O,f),(0,Ee.F2)(a,c,f,O)},r),(0,R.Tt)(r)}filterQuery(t){return!(t.hide||t.expr==="")}applyTemplateVariables(t,e){const{__interval:r,__interval_ms:a,__range:n,__range_s:c,__range_ms:f,...O}=e||{},b=this.addAdHocFilters(t.expr);return{...t,legendFormat:this.templateSrv.replace(t.legendFormat,O),expr:this.templateSrv.replace(b,O,this.interpolateQueryExpr)}}interpolateString(t,e){return this.templateSrv.replace(t,e,this.interpolateQueryExpr)}getVariables(){return this.templateSrv.getVariables().map(t=>`$${t.name}`)}getQueryHints(t,e){return kr(t.expr,e)}getDefaultQuery(t){const e={refId:"A",expr:""};return t===S.zj.UnifiedAlerting?{...e,queryType:i.EM.Instant}:{...e,queryType:i.EM.Range}}}function ot(s){return typeof s=="string"?s.replace(/'/g,"\\\\'"):s}function $t(s){return typeof s=="string"?ot(s.replace(/\\/g,"\\\\\\\\").replace(/[$^*{}\[\]+?.()|]/g,"\\\\$&")):s}function Wt(s){let t;try{t=new xe.N(s).getFirstFieldOfType(T.fS.number)}catch{}return t?.labels?dr(t.labels):te.in.unknown}function dr(s){const t=["level","lvl","loglevel"];let e;for(let r of t)if(r in s){e=r;break}return e?(0,D.jx)(s[e]):te.in.unknown}},87603:(Ce,Oe,l)=>{l.d(Oe,{C6:()=>T,EF:()=>K,F2:()=>v,Ff:()=>w,Ld:()=>M,NT:()=>xe,Pg:()=>ye,Xw:()=>B,cT:()=>Le,g8:()=>R,j2:()=>pe,qC:()=>V,st:()=>G,y2:()=>u,zX:()=>fe});var j=l(89949),x=l.n(j),o=l(25224),H=l(64826),ue=l(73565),g=l(58029),k=l(16516);class w{constructor(p,d,Q){this.from=p,this.to=d,this.type=Q}static fromNode(p){return new w(p.from,p.to,p.type)}contains(p){return this.from<=p.from&&this.to>=p.to}getExpression(p){return p.substring(this.from,this.to)}}function pe(i,p,d,Q){return S(i,p,d,Q).length>0}function fe(i,p,d,Q){const C=S(i,p,d,Q);for(const J of C)i=J.parent?.type.id===o.pj?de(i,J):te(i,J);return i}function de(i,p){const d=p.parent?.parent;return!d||d.type.id!==o.We?i:(i.substring(0,d.from)+i.substring(d.to)).trim()}function te(i,p){let d=p;do d=d.parent;while(d&&d.type.id!==o.Qf);const Q=p.getChild(o.xb);if(!d||!Q)return i;const C=i.substring(Q.from,Q.to),J=i.substring(0,d.from),ne=i.substring(d.to),oe=(0,k._z)(i.substring(d.from,d.to));return oe.query.labels=oe.query.labels.filter(he=>he.label!==C),J+g.y.renderQuery(oe.query)+ne}function S(i,p,d,Q){const C=o.E2.parse(i),J=[];return C.iterate({enter:({type:ne,node:oe})=>{ne.id===o.xO&&J.push(oe)}}),J.filter(ne=>{const oe=ne.getChild(o.xb),he=oe?.nextSibling,be=ne.getChild(o.Ld);if(!oe||!he||!be||i.substring(oe.from,oe.to)!==p)return!1;const Me=i.substring(be.from,be.to);return!((0,k.LE)(Me)!==(0,H.iS)(Q)||i.substring(he.from,he.to)!==d)})}function v(i,p,d,Q){if(!p||!Q)throw new Error("Need label to add to query.");const C=B(i);if(!C.length)return i;const J=N(i),ne=C.every(Pe=>J.some(Me=>Me.from>=Pe.from&&Me.to<=Pe.to)),oe=V(i),he=G(i),be=u(p,Q,d);if(ne&&(he.length||oe.length)){const Pe=ee((0,ue.te)(i,[o.wi])),Me=[...oe,...he],Je=Pe.map(et=>K(Me.filter(ct=>et.contains(ct))));return R(i,Je,be)}else return D(i,C,be)}function ye(i,p){const d=A(i);if(d.length)return m(i,d,p);{const Q=B(i);return Q.length?m(i,Q,p):i}}function Le(i){const p=V(i);if(!p.length)return i;const d=u("__error__","","=");return R(i,p,d)}function xe(i,p){const d=L(i);return P(i,d,p)}function T(i){const p=U(i);if(!p.length)return i;let d="",Q=0;for(let C of p)d=d+i.substring(Q,C.from),Q=C.to;return d=d+i.substring(Q),d}function B(i){const p=o.E2.parse(i),d=[];return p.iterate({enter:({type:Q,node:C})=>{if(Q.id===o.Qf)return d.push(w.fromNode(C)),!1}}),d}function N(i){const p=o.E2.parse(i),d=[];return p.iterate({enter:({node:Q})=>{Q.type.id===o.Qf&&d.push(...re(Q,o.xO))}}),d}function V(i){const p=o.E2.parse(i),d=[];return p.iterate({enter:({type:Q,node:C})=>{if(Q.id===o.Li||Q.id===o.Lu)return d.push(w.fromNode(C)),!1}}),d}function G(i){const p=o.E2.parse(i),d=[];return p.iterate({enter:({type:Q,node:C})=>{if(Q.id===o.pj)return d.push(w.fromNode(C)),!1}}),d}function A(i){const p=o.E2.parse(i),d=[];return p.iterate({enter:({type:Q,node:C})=>{if(Q.id===o.wm)return d.push(w.fromNode(C)),!1}}),d}function L(i){const p=o.E2.parse(i),d=[];return p.iterate({enter:({type:Q,node:C})=>{if(Q.id===o.bL)return d.push(w.fromNode(C)),!1;if(Q.id===o.UN){const J=[],ne=C.getChild(o.Qf);ne&&J.push(w.fromNode(ne));const oe=C.getChild(o.iP);oe&&J.push(w.fromNode(oe));const he=C.getChild(o.Xt);he&&J.push(w.fromNode(he));const be=(0,j.sortBy)(J,Pe=>Pe.to);return d.push(new w(be[0].from,be[be.length-1].to)),!1}}}),d}function u(i,p,d){return{label:i,op:d,value:p}}function D(i,p,d){let Q="",C=0;for(let J=0;J<p.length;J++){const ne=p[J],oe=J===p.length-1,he=i.substring(C,ne.from),be=oe?i.substring(ne.to):"",Pe=(0,k._z)(i.substring(ne.from,ne.to));I(Pe.query.labels,d)||Pe.query.labels.push(d);const Me=g.y.renderQuery(Pe.query);Q+=he+Me+be,C=ne.to}return Q}function R(i,p,d){let Q="",C=0;for(let J=0;J<p.length;J++){const ne=p[J],oe=J===p.length-1,he=i.substring(C,ne.to),be=oe?i.substring(ne.to):"";let Pe="";!Number.isNaN(Number(d.value))&&(d.op==="<"||d.op===">")?Pe=` | ${d.label}${d.op}${Number(d.value)}`:Pe=` | ${d.label}${d.op}\`${(0,H.iS)(d.value)}\``,Q+=he+Pe+be,C=ne.to}return Q}function m(i,p,d){let Q="",C=0;for(let J=0;J<p.length;J++){const ne=p[J],oe=J===p.length-1,he=i.substring(C,ne.to),be=oe?i.substring(ne.to):"";Q+=he+` | ${d}`+be,C=ne.to}return Q}function P(i,p,d){let Q="",C=0;for(let J=0;J<p.length;J++){const ne=p[J],oe=J===p.length-1,he=i.substring(C,ne.to),be=oe?i.substring(ne.to):"",Pe=` | label_format ${d.renameTo}=${d.originalLabel}`;Q+=he+Pe+be,C=ne.to}return Q}function M(i){const p=B(i);if(!p.length)return i;const d=p[0].to;return i.slice(0,d)+" |= ``"+i.slice(d)}function U(i){const p=o.E2.parse(i),d=[];return p.iterate({enter:({type:Q,from:C,to:J})=>{if(Q.id===o.gD)return d.push(new w(C,J,Q)),!1}}),d}function I(i,p){return i.find(d=>d.label===p.label&&d.value===p.value)}function K(i){return i.reduce((p,d)=>p.to>d.to?p:d)}function re(i,p){if(i.type.id===p)return[w.fromNode(i)];const d=[];let Q=0,C=i.childAfter(Q);for(;C;)d.push(...re(C,p)),Q=C.to,C=i.childAfter(Q);return d}function ee(i){return i.filter(p=>i.every(d=>p.contains(d)===!1||p===d))}},73565:(Ce,Oe,l)=>{l.d(Oe,{H6:()=>ye,I2:()=>V,Ib:()=>de,Iu:()=>m,Ix:()=>ee,Lw:()=>te,N7:()=>u,QI:()=>U,QT:()=>re,Qh:()=>P,SP:()=>R,TH:()=>I,cQ:()=>A,dQ:()=>Le,hI:()=>D,n6:()=>fe,oi:()=>L,rE:()=>G,te:()=>B,x9:()=>pe,zE:()=>M});var j=l(89949),x=l.n(j),o=l(25224),H=l(86312),ue=l(55889),g=l(53310),k=l(87603),w=l(24513);function pe(i){return`${i||""}`.trim()}function fe(i){const p=[],d=T(i,[o.yx]);for(let Q of d){const C=Q.getChild(o.wn)?.getChild(o.OC),J=Q.getChild(o.wn)?.getChild(o.Ih),ne=Q.getChild(o.Ld);if(!C&&!J||!ne)continue;const oe=i.substring(ne.from,ne.to).trim(),he=oe[0]==="`",be=oe.substring(1,oe.length-1);if(!be)continue;let Pe="";J?Pe=he?be:be.replace(/\\\\/g,"\\"):Pe=(0,j.escapeRegExp)(be),Pe&&p.push(Pe)}return p}function de(i){const p=te(i),{instant:d,range:Q,...C}=i;return{...C,queryType:p}}function te(i){const{queryType:p}=i;return p===w.EM.Range||p===w.EM.Instant||p===w.EM.Stream?p:i.instant===!0?w.EM.Instant:w.EM.Range}const S=["String","Identifier","LineComment","Number"],v=["__error__","__interval","__interval_ms"];function ye(i){let p=i;return o.E2.parse(i).iterate({enter:({name:Q,from:C,to:J})=>{const ne=i.substring(C,J);S.includes(Q)&&!v.includes(ne)&&(p=p.replace(ne,Q))}}),p}function Le(i){const p=[];return o.E2.parse(i).iterate({enter:({name:Q})=>{p.push(Q)}}),p}function xe(i,p){let d=!1;return o.E2.parse(i).iterate({enter:({type:C})=>{if(C.id===p)return d=!0,!1}}),d}function T(i,p){const d=[];return o.E2.parse(i).iterate({enter:C=>{(p===void 0||p.includes(C.type.id))&&d.push(C.node)}}),d}function B(i,p){const d=[];return o.E2.parse(i).iterate({enter:C=>{(p===void 0||p.includes(C.type.id))&&d.push(k.Ff.fromNode(C.node))}}),d}function N(i,p){const d=T(i,[p]);return d.length>0?d[0]:void 0}function V(i){return xe(i,ue._A)}function G(i){return!xe(i,o.cq)}function A(i){const d=T(i,[o.Li,o.Lu]).length;return{queryWithParser:d>0,parserCount:d}}function L(i){const p=T(i,[o.Li,o.Lu]);return p.length>0?i.substring(p[0].from,p[0].to).trim():void 0}function u(i){const p=T(i,[o.pj]);for(const d of p){const Q=d.getChild(o.xO)?.getChild(o.xb);if(Q&&i.substring(Q.from,Q.to)==="__error__")return!0}return!1}function D(i){return xe(i,o.zV)}function R(i){if(G(i))return i;const p=N(i,o.Qf);if(!p)return i;const d=i.substring(p.from,p.to),Q=N(i,o.iP),C=Q?i.substring(Q.from,Q.to):"";return`${d} ${C}`.trim()}function m(i){return xe(i,o.pj)}function P(i){return xe(i,o.yx)}function M(i){const p=T(i,[o.e6]);for(const d of p)if(i.substring(d.from,d.to).match(/\[\$__range(_s|_ms)?/))return!0;return!1}function U(i){return(0,k.Xw)(i).map(Q=>i.slice(Q.from,Q.to))}function I(i){return i.filter(d=>!d.hide).filter(d=>!d.refId.includes("do-not-chunk")).filter(d=>d.expr).length>0}const K=i=>i?i.expr!==void 0:!1,re=i=>{if(!(!i||!K(i)))return i};function ee(i,p){const d=V(p.interpolateString(i,g.t));if((0,H.ff)("grafana_loki_format_query_clicked",{is_invalid:d,query_type:G(i)?"logs":"metric"}),d)return i;let Q=(0,ue.bU)(i);const C=[],J=o.E2.parse(Q);if(J.topNode.firstChild?.firstChild?.type.id===o.cq){const oe=/\[__V_[0-2]__\w+__V__\]/g;C.push(...Q.matchAll(oe)),Q=Q.replace(oe,"[0s]")}let ne=(0,o.aX)(Q);return J.topNode.firstChild?.firstChild?.type.id===o.cq&&C.forEach(oe=>{ne=ne.replace("[0s]",oe[0])}),(0,ue.Tt)(ne)}},58029:(Ce,Oe,l)=>{l.d(Oe,{y:()=>ue});var j=l(54433),x=l(25577),o=l(4737);class H extends j.x{constructor(){super(x._f),this.setOperationCategories([o.Ly.Aggregations,o.Ly.RangeFunctions,o.Ly.Formats,o.Ly.BinaryOps,o.Ly.LabelFilters,o.Ly.LineFilters])}renderLabels(k){return k.length===0?"{}":super.renderLabels(k)}getQueryPatterns(){return[{name:"Parse log lines with logfmt parser",type:o.Hv.Log,operations:[{id:o.B5.Logfmt,params:[]},{id:o.B5.LabelFilterNoErrors,params:[]}]},{name:"Parse log lines with JSON parser",type:o.Hv.Log,operations:[{id:o.B5.Json,params:[]},{id:o.B5.LabelFilterNoErrors,params:[]}]},{name:"Filter log line and parse with logfmt parser",type:o.Hv.Log,operations:[{id:o.B5.LineContains,params:[""]},{id:o.B5.Logfmt,params:[]},{id:o.B5.LabelFilterNoErrors,params:[]}]},{name:"Filter log lines and parse with json parser",type:o.Hv.Log,operations:[{id:o.B5.LineContains,params:[""]},{id:o.B5.Json,params:[]},{id:o.B5.LabelFilterNoErrors,params:[]}]},{name:"Parse log line with logfmt parser and use label filter",type:o.Hv.Log,operations:[{id:o.B5.LineContains,params:[""]},{id:o.B5.Logfmt,params:[]},{id:o.B5.LabelFilterNoErrors,params:[]},{id:o.B5.LabelFilter,params:["label","=","value"]}]},{name:"Parse log lines with nested json",type:o.Hv.Log,operations:[{id:o.B5.LineContains,params:[""]},{id:o.B5.Json,params:[]},{id:o.B5.LabelFilterNoErrors,params:[]},{id:o.B5.LineFormat,params:["{{.message}}"]},{id:o.B5.Json,params:[]},{id:o.B5.LabelFilterNoErrors,params:[]}]},{name:"Reformat log lines",type:o.Hv.Log,operations:[{id:o.B5.LineContains,params:[""]},{id:o.B5.Logfmt,params:[]},{id:o.B5.LabelFilterNoErrors,params:[]},{id:o.B5.LineFormat,params:["{{.message}}"]}]},{name:"Rename lvl label to level",type:o.Hv.Log,operations:[{id:o.B5.LineContains,params:[""]},{id:o.B5.Logfmt,params:[]},{id:o.B5.LabelFilterNoErrors,params:[]},{id:o.B5.LabelFormat,params:["lvl","level"]}]},{name:"Query on value inside a log line",type:o.Hv.Metric,operations:[{id:o.B5.LineContains,params:[""]},{id:o.B5.Logfmt,params:[]},{id:o.B5.LabelFilterNoErrors,params:[]},{id:o.B5.Unwrap,params:[""]},{id:o.B5.LabelFilterNoErrors,params:[]},{id:o.B5.SumOverTime,params:["$__interval"]},{id:o.B5.Sum,params:[]}]},{name:"Total requests per label of streams",type:o.Hv.Metric,operations:[{id:o.B5.LineContains,params:[""]},{id:o.B5.CountOverTime,params:["$__interval"]},{id:o.B5.Sum,params:[]}]},{name:"Total requests per parsed label or label of streams",type:o.Hv.Metric,operations:[{id:o.B5.LineContains,params:[""]},{id:o.B5.Logfmt,params:[]},{id:o.B5.LabelFilterNoErrors,params:[]},{id:o.B5.CountOverTime,params:["$__interval"]},{id:o.B5.Sum,params:[]}]},{name:"Bytes used by a log stream",type:o.Hv.Metric,operations:[{id:o.B5.LineContains,params:[""]},{id:o.B5.BytesOverTime,params:["$__interval"]}]},{name:"Count of log lines per stream",type:o.Hv.Metric,operations:[{id:o.B5.LineContains,params:[""]},{id:o.B5.CountOverTime,params:["$__interval"]}]},{name:"Top N results by label or parsed label",type:o.Hv.Metric,operations:[{id:o.B5.Logfmt,params:[]},{id:o.B5.LabelFilterNoErrors,params:[]},{id:o.B5.CountOverTime,params:["$__interval"]},{id:o.B5.Sum,params:[]},{id:o.B5.TopK,params:[10]}]},{name:"Extracted quantile",type:o.Hv.Metric,operations:[{id:o.B5.Logfmt,params:[]},{id:o.B5.LabelFilterNoErrors,params:[]},{id:o.B5.Unwrap,params:["latency"]},{id:o.B5.LabelFilterNoErrors,params:[]},{id:o.B5.QuantileOverTime,params:["$__interval",.5]},{id:o.B5.Sum,params:[]}]}]}}const ue=new H},12906:(Ce,Oe,l)=>{l.d(Oe,{E:()=>H,i:()=>o});var j=l(42994),x=l(4737);const o=[{id:x.B5.Addition,name:"Add scalar",sign:"+"},{id:x.B5.Subtraction,name:"Subtract scalar",sign:"-"},{id:x.B5.MultiplyBy,name:"Multiply by scalar",sign:"*"},{id:x.B5.DivideBy,name:"Divide by scalar",sign:"/"},{id:x.B5.Modulo,name:"Modulo by scalar",sign:"%"},{id:x.B5.Exponent,name:"Exponent",sign:"^"},{id:x.B5.EqualTo,name:"Equal to",sign:"==",comparison:!0},{id:x.B5.NotEqualTo,name:"Not equal to",sign:"!=",comparison:!0},{id:x.B5.GreaterThan,name:"Greater than",sign:">",comparison:!0},{id:x.B5.LessThan,name:"Less than",sign:"<",comparison:!0},{id:x.B5.GreaterOrEqual,name:"Greater or equal to",sign:">=",comparison:!0},{id:x.B5.LessOrEqual,name:"Less or equal to",sign:"<=",comparison:!0}],H=o.map(g=>{const k=[{name:"Value",type:"number"}],w=[2];return g.comparison&&(k.unshift({name:"Bool",type:"boolean",description:"If checked comparison will return 0 or 1 for the value rather than filtering."}),w.unshift(!1)),{id:g.id,name:g.name,params:k,defaultParams:w,alternativesKey:"binary scalar operations",category:x.Ly.BinaryOps,renderer:ue(g.sign),addOperationHandler:j.PP}});function ue(g){return function(w,pe,fe){let de=w.params[0],te="";return w.params.length===2&&(de=w.params[1],te=w.params[0]?" bool":""),`${fe} ${g}${te} ${de}`}}},55701:(Ce,Oe,l)=>{l.d(Oe,{O6:()=>g,Ql:()=>de,ZO:()=>fe,f0:()=>v,qV:()=>ye,we:()=>ue,xu:()=>pe,zj:()=>Le});var j=l(4002),x=l(42994),o=l(62434),H=l(4737);function ue(T,B){const N=[xe()],V=["$__interval"];let G;return T===H.B5.QuantileOverTime&&(V.push("0.95"),N.push({name:"Quantile",type:"number"})),B&&(N.push({name:"By label",type:"string",restParam:!0,optional:!0}),G=(0,x.ZI)(`__${T}_by`)),{id:T,name:(0,x.t7)(T),params:N,defaultParams:V,alternativesKey:"range function",category:H.Ly.RangeFunctions,orderRank:H.jK.RangeVectorFunction,renderer:w,addOperationHandler:v,paramChangedHandler:G,explainHandler:(A,L)=>{let u=o.r8.find(D=>D.insertText===A.id)?.documentation??"";return A.params[0]==="$__interval"?`${u} \`$__interval\` is a variable that will be replaced with the [calculated interval](https://grafana.com/docs/grafana/latest/dashboards/variables/add-template-variables/#__interval) based on the time range and width of the graph. In Dashboards, you can affect the interval variable using **Max data points** and **Min interval**. You can find these options under **Query options** right of the data source select dropdown.`:`${u} The [range vector](https://grafana.com/docs/loki/latest/logql/metric_queries/#range-vector-aggregation) is set to \`${A.params[0]}\`.`}}}function g(T){const B=ue(T,!0),N=B.params.slice(0,-1);return[B,{id:`__${T}_by`,name:`${(0,x.t7)(T)} by`,params:[...N,{name:"Label",type:"string",restParam:!0,optional:!0,editor:j.g}],defaultParams:[...B.defaultParams,""],alternativesKey:"range function with grouping",category:H.Ly.RangeFunctions,renderer:k(T,"by"),paramChangedHandler:(0,x.j8)(T),explainHandler:(0,x.Sp)(T,"by"),addOperationHandler:v,hideFromList:!0},{id:`__${T}_without`,name:`${(0,x.t7)(T)} without`,params:[...N,{name:"Label",type:"string",restParam:!0,optional:!0,editor:j.g}],defaultParams:[...B.defaultParams,""],alternativesKey:"range function with grouping",category:H.Ly.RangeFunctions,renderer:k(T,"without"),paramChangedHandler:(0,x.j8)(T),explainHandler:(0,x.Sp)(T,"without"),addOperationHandler:v,hideFromList:!0}]}function k(T,B){return function(V,G,A){const L=G.params.findIndex(R=>R.restParam),u=V.params.slice(0,L),D=V.params.slice(L);return u.length===2&&T===H.B5.QuantileOverTime?`${T}(${u[1]}, ${A} [${u[0]}]) ${B} (${D.join(", ")})`:`${T}(${A} [${u[0]}]) ${B} (${D.join(", ")})`}}function w(T,B,N){const V=T.params??[],G=V[0]??"$__interval";if(V.length===2&&T.id===H.B5.QuantileOverTime){const A=V[1];return`${T.id}(${A}, ${N} [${G}])`}return`${T.id}(${N} [${V[0]??"$__interval"}])`}function pe(T,B,N){return["<","<=",">",">="].includes(String(T.params[1]))?`${N} | ${T.params[0]} ${T.params[1]} ${T.params[2]}`:`${N} | ${T.params[0]} ${T.params[1]} \`${T.params[2]}\``}function fe(T,B){const N=T.params[1].toString().startsWith("!");return B.filter(A=>A.id===H.B5.LabelFilter&&A.params[0]===T.params[0]&&A.params[2]===T.params[2]).some(A=>!!(N&&A.params[1].toString().startsWith("!")===!1||N===!1&&A.params[1].toString().startsWith("!")))}function de(T,B,N){return`${N} | ${T.id}`}function te(T){return T.category===H.Ly.RangeFunctions}function S(T,B,N){const V=T.findIndex(G=>{const A=B.getOperationDef(G.id);return A?N(A):!1});return V===-1?T.length:V}function v(T,B,N){const V={id:T.id,params:T.defaultParams},G=[...B.operations],A=G.find(L=>{const u=N.getOperationDef(L.id);return u?te(u):!1});switch(T.category){case H.Ly.Aggregations:case H.Ly.Functions:if(!A){const u=S(G,N,D=>D.category===H.Ly.Functions);G.splice(u,0,{id:H.B5.Rate,params:["$__interval"]})}G.push(V);break;case H.Ly.RangeFunctions:if(A){const u=G.indexOf(A);G[u]=V;break}default:const L=S(G,N,u=>(T.orderRank??100)<(u.orderRank??100));G.splice(L,0,V);break}return{...B,operations:G}}function ye(T,B){return{...B,binaryQueries:[...B.binaryQueries??[],{operator:"/",query:B}]}}function Le(T,B){return function(V,G,A){return B?`${A} ${T} \`(?i)${V.params[0]}\``:`${A} ${T} \`${V.params[0]}\``}}function xe(){return{name:"Range",type:"string",options:["$__interval","$__range","1m","5m","10m","1h","24h"]}}},25577:(Ce,Oe,l)=>{l.d(Oe,{j$:()=>B,kf:()=>xe,XK:()=>T,_f:()=>ye});var j=l(42994),x=l(12906),o=l(27702),H=l(81078),ue=l(28580),g=l(53310),k=l(61875),w=l(73565),pe=l(84273),fe=l(58029);function de({onChange:N,index:V,operationIndex:G,value:A,query:L,datasource:u}){const[D,R]=(0,o.useState)({});return o.createElement(ue.Ph,{inputId:(0,j.i1)(G,V),onOpenMenu:async()=>{if(u instanceof k.KV){R({isLoading:!0});const m=await te(L,u);R({options:m,isLoading:void 0})}},isLoading:D.isLoading,allowCustomValue:!0,noOptionsMessage:"No labels found",loadingMessage:"Loading labels",options:D.options,value:A?(0,H.E)(A.toString()):null,onChange:m=>{m.value&&N(V,m.value)}})}async function te(N,V){const G=fe.y.renderQuery(N),A=(0,w.SP)(G);if((0,w.I2)(V.interpolateString(A,g.t)))return[];const L=await V.getDataSamples({expr:A,refId:"unwrap_samples"});return(0,pe.zb)(L[0]).map(R=>({label:R,value:R}))}var S=l(55701),v=l(4737);function ye(){const N=[v.B5.Sum,v.B5.Min,v.B5.Max,v.B5.Avg,v.B5.Stddev,v.B5.Stdvar,v.B5.Count].flatMap(u=>(0,j.IT)(u,{addOperationHandler:S.f0,orderRank:v.jK.Last})),V=[v.B5.TopK,v.B5.BottomK].flatMap(u=>(0,j.Z3)(u,{params:[{name:"K-value",type:"number"}],defaultParams:[5]},{addOperationHandler:S.f0,orderRank:v.jK.Last})),G=[(0,S.we)(v.B5.Rate),(0,S.we)(v.B5.RateCounter),(0,S.we)(v.B5.CountOverTime),(0,S.we)(v.B5.SumOverTime),(0,S.we)(v.B5.BytesRate),(0,S.we)(v.B5.BytesOverTime),(0,S.we)(v.B5.AbsentOverTime)],A=[...(0,S.O6)(v.B5.AvgOverTime),...(0,S.O6)(v.B5.MaxOverTime),...(0,S.O6)(v.B5.MinOverTime),...(0,S.O6)(v.B5.FirstOverTime),...(0,S.O6)(v.B5.LastOverTime),...(0,S.O6)(v.B5.StdvarOverTime),...(0,S.O6)(v.B5.StddevOverTime),...(0,S.O6)(v.B5.QuantileOverTime)];return[...N,...V,...G,...A,{id:v.B5.Json,name:"Json",params:[{name:"Expression",type:"string",restParam:!0,optional:!0,minWidth:18,placeholder:'server="servers[0]"',description:"Using expressions with your json parser will extract only the specified json fields to labels. You can specify one or more expressions in this way. All expressions must be quoted."}],defaultParams:[],alternativesKey:"format",category:v.Ly.Formats,orderRank:v.jK.Parsers,renderer:(u,D,R)=>`${R} | json ${u.params.join(", ")}`.trim(),addOperationHandler:S.f0,explainHandler:()=>"This will extract keys and values from a [json](https://grafana.com/docs/loki/latest/logql/log_queries/#json) formatted log line as labels. The extracted labels can be used in label filter expressions and used as values for a range aggregation via the unwrap operation."},{id:v.B5.Logfmt,name:"Logfmt",params:[],defaultParams:[],alternativesKey:"format",category:v.Ly.Formats,orderRank:v.jK.Parsers,renderer:S.Ql,addOperationHandler:S.f0,explainHandler:()=>"This will extract all keys and values from a [logfmt](https://grafana.com/docs/loki/latest/logql/log_queries/#logfmt) formatted log line as labels. The extracted labels can be used in label filter expressions and used as values for a range aggregation via the unwrap operation."},{id:v.B5.Regexp,name:"Regexp",params:[{name:"String",type:"string",hideName:!0,placeholder:"<re>",description:"The regexp expression that matches the structure of a log line.",minWidth:20}],defaultParams:[""],alternativesKey:"format",category:v.Ly.Formats,orderRank:v.jK.Parsers,renderer:(u,D,R)=>`${R} | regexp \`${u.params[0]}\``,addOperationHandler:S.f0,explainHandler:()=>'The [regexp parser](https://grafana.com/docs/loki/latest/logql/log_queries/#regular-expression) takes a single parameter | regexp "<re>" which is the regular expression using the Golang RE2 syntax. The regular expression must contain a least one named sub-match (e.g (?P<name>re)), each sub-match will extract a different label. The expression matches the structure of a log line. The extracted labels can be used in label filter expressions and used as values for a range aggregation via the unwrap operation.'},{id:v.B5.Pattern,name:"Pattern",params:[{name:"String",type:"string",hideName:!0,placeholder:"<pattern-expression>",description:"The expression that matches the structure of a log line.",minWidth:20}],defaultParams:[""],alternativesKey:"format",category:v.Ly.Formats,orderRank:v.jK.Parsers,renderer:(u,D,R)=>`${R} | pattern \`${u.params[0]}\``,addOperationHandler:S.f0,explainHandler:()=>"The [pattern parser](https://grafana.com/docs/loki/latest/logql/log_queries/#pattern) allows the explicit extraction of fields from log lines by defining a pattern expression (| pattern `<pattern-expression>`). The expression matches the structure of a log line. The extracted labels can be used in label filter expressions and used as values for a range aggregation via the unwrap operation."},{id:v.B5.Unpack,name:"Unpack",params:[],defaultParams:[],alternativesKey:"format",category:v.Ly.Formats,orderRank:v.jK.Parsers,renderer:S.Ql,addOperationHandler:S.f0,explainHandler:()=>"This will extract all keys and values from a JSON log line, [unpacking](https://grafana.com/docs/loki/latest/logql/log_queries/#unpack) all embedded labels in the pack stage. The extracted labels can be used in label filter expressions and used as values for a range aggregation via the unwrap operation."},{id:v.B5.LineFormat,name:"Line format",params:[{name:"String",type:"string",hideName:!0,placeholder:"{{.status_code}}",description:"A line template that can refer to stream labels and extracted labels.",minWidth:20}],defaultParams:[""],alternativesKey:"format",category:v.Ly.Formats,orderRank:v.jK.PipeOperations,renderer:(u,D,R)=>`${R} | line_format \`${u.params[0]}\``,addOperationHandler:S.f0,explainHandler:()=>`This will replace log line using a specified template. The template can refer to stream labels and extracted labels. Example: \`{{.status_code}} - {{.message}}\` [Read the docs](https://grafana.com/docs/loki/latest/logql/log_queries/#line-format-expression) for more. `},{id:v.B5.LabelFormat,name:"Label format",params:[{name:"Label",type:"string"},{name:"Rename to",type:"string"}],defaultParams:["",""],alternativesKey:"format",category:v.Ly.Formats,orderRank:v.jK.PipeOperations,renderer:(u,D,R)=>`${R} | label_format ${u.params[1]}=${u.params[0]}`,addOperationHandler:S.f0,explainHandler:()=>'This will change name of label to desired new label. In the example below, label "error_level" will be renamed to "level".\n\nExample: ``error_level=`level` ``\n\n[Read the docs](https://grafana.com/docs/loki/latest/logql/log_queries/#labels-format-expression) for more.\n '},{id:v.B5.LineContains,name:"Line contains",params:[{name:"String",type:"string",hideName:!0,placeholder:"Text to find",description:"Find log lines that contains this text",minWidth:20,runQueryOnEnter:!0}],defaultParams:[""],alternativesKey:"line filter",category:v.Ly.LineFilters,orderRank:v.jK.LineFilters,renderer:(0,S.zj)("|="),addOperationHandler:S.f0,explainHandler:u=>`Return log lines that contain string \`${u.params[0]}\`.`},{id:v.B5.LineContainsNot,name:"Line does not contain",params:[{name:"String",type:"string",hideName:!0,placeholder:"Text to exclude",description:"Find log lines that does not contain this text",minWidth:26,runQueryOnEnter:!0}],defaultParams:[""],alternativesKey:"line filter",category:v.Ly.LineFilters,orderRank:v.jK.LineFilters,renderer:(0,S.zj)("!="),addOperationHandler:S.f0,explainHandler:u=>`Return log lines that does not contain string \`${u.params[0]}\`.`},{id:v.B5.LineContainsCaseInsensitive,name:"Line contains case insensitive",params:[{name:"String",type:"string",hideName:!0,placeholder:"Text to find",description:"Find log lines that contains this text",minWidth:33,runQueryOnEnter:!0}],defaultParams:[""],alternativesKey:"line filter",category:v.Ly.LineFilters,orderRank:v.jK.LineFilters,renderer:(0,S.zj)("|~",!0),addOperationHandler:S.f0,explainHandler:u=>`Return log lines that match regex \`(?i)${u.params[0]}\`.`},{id:v.B5.LineContainsNotCaseInsensitive,name:"Line does not contain case insensitive",params:[{name:"String",type:"string",hideName:!0,placeholder:"Text to exclude",description:"Find log lines that does not contain this text",minWidth:40,runQueryOnEnter:!0}],defaultParams:[""],alternativesKey:"line filter",category:v.Ly.LineFilters,orderRank:v.jK.LineFilters,renderer:(0,S.zj)("!~",!0),addOperationHandler:S.f0,explainHandler:u=>`Return log lines that does not match regex \`(?i)${u.params[0]}\`.`},{id:v.B5.LineMatchesRegex,name:"Line contains regex match",params:[{name:"Regex",type:"string",hideName:!0,placeholder:"Pattern to match",description:"Find log lines that match this regex pattern",minWidth:30,runQueryOnEnter:!0}],defaultParams:[""],alternativesKey:"line filter",category:v.Ly.LineFilters,orderRank:v.jK.LineFilters,renderer:(0,S.zj)("|~"),addOperationHandler:S.f0,explainHandler:u=>`Return log lines that match a \`RE2\` regex pattern. \`${u.params[0]}\`.`},{id:v.B5.LineMatchesRegexNot,name:"Line does not match regex",params:[{name:"Regex",type:"string",hideName:!0,placeholder:"Pattern to exclude",description:"Find log lines that does not match this regex pattern",minWidth:30,runQueryOnEnter:!0}],defaultParams:[""],alternativesKey:"line filter",category:v.Ly.LineFilters,orderRank:v.jK.LineFilters,renderer:(0,S.zj)("!~"),addOperationHandler:S.f0,explainHandler:u=>`Return log lines that doesn't match a \`RE2\` regex pattern. \`${u.params[0]}\`.`},{id:v.B5.LineFilterIpMatches,name:"IP line filter expression",params:[{name:"Operator",type:"string",minWidth:16,options:[v.AI.contains,v.AI.doesNotContain]},{name:"Pattern",type:"string",placeholder:"<pattern>",minWidth:16,runQueryOnEnter:!0}],defaultParams:["|=",""],alternativesKey:"line filter",category:v.Ly.LineFilters,orderRank:v.jK.LineFilters,renderer:(u,D,R)=>`${R} ${u.params[0]} ip(\`${u.params[1]}\`)`,addOperationHandler:S.f0,explainHandler:u=>`Return log lines using IP matching of \`${u.params[1]}\``},{id:v.B5.LabelFilter,name:"Label filter expression",params:[{name:"Label",type:"string",minWidth:14},{name:"Operator",type:"string",minWidth:14,options:[v.AI.equals,v.AI.doesNotEqual,v.AI.matchesRegex,v.AI.doesNotMatchRegex,v.AI.greaterThan,v.AI.lessThan,v.AI.greaterThanOrEqual,v.AI.lessThanOrEqual]},{name:"Value",type:"string",minWidth:14}],defaultParams:["","=",""],alternativesKey:"label filter",category:v.Ly.LabelFilters,orderRank:v.jK.PipeOperations,renderer:S.xu,addOperationHandler:S.f0,explainHandler:()=>"Label expression filter allows filtering using original and extracted labels."},{id:v.B5.LabelFilterIpMatches,name:"IP label filter expression",params:[{name:"Label",type:"string",minWidth:14},{name:"Operator",type:"string",minWidth:14,options:[v.AI.equals,v.AI.doesNotEqual]},{name:"Value",type:"string",minWidth:14}],defaultParams:["","=",""],alternativesKey:"label filter",category:v.Ly.LabelFilters,orderRank:v.jK.PipeOperations,renderer:(u,D,R)=>`${R} | ${u.params[0]} ${u.params[1]} ip(\`${u.params[2]}\`)`,addOperationHandler:S.f0,explainHandler:u=>`Return log lines using IP matching of \`${u.params[2]}\` for \`${u.params[0]}\` label`},{id:v.B5.LabelFilterNoErrors,name:"No pipeline errors",params:[],defaultParams:[],alternativesKey:"label filter",category:v.Ly.LabelFilters,orderRank:v.jK.NoErrors,renderer:(u,D,R)=>`${R} | __error__=\`\``,addOperationHandler:S.f0,explainHandler:()=>"Filter out all formatting and parsing errors."},{id:v.B5.Unwrap,name:"Unwrap",params:[{name:"Identifier",type:"string",hideName:!0,minWidth:16,placeholder:"Label key",editor:de},{name:"Conversion function",hideName:!0,type:"string",options:["duration","duration_seconds","bytes"],optional:!0}],defaultParams:["",""],alternativesKey:"format",category:v.Ly.Formats,orderRank:v.jK.Unwrap,renderer:(u,D,R)=>`${R} | unwrap ${u.params[1]?`${u.params[1]}(${u.params[0]})`:u.params[0]}`,addOperationHandler:S.f0,explainHandler:u=>{let D=String(u.params[0]).length>0?u.params[0]:"<label>";return`Use the extracted label \`${D}\` as sample values instead of log lines for the subsequent range aggregation.${u.params[1]?` Conversion function \`${u.params[1]}\` wrapping \`${D}\` will attempt to convert this label from a specific format (e.g. 3k, 500ms).`:""}`}},{id:v.B5.Decolorize,name:"Decolorize",params:[],defaultParams:[],alternativesKey:"format",category:v.Ly.Formats,orderRank:v.jK.PipeOperations,renderer:(u,D,R)=>`${R} | decolorize`,addOperationHandler:S.f0,explainHandler:()=>"This will remove ANSI color codes from log lines."},...x.E,{id:v.B5.NestedQuery,name:"Binary operation with query",params:[],defaultParams:[],category:v.Ly.BinaryOps,renderer:(u,D,R)=>R,addOperationHandler:S.qV}]}const Le=ye();function xe(N){return(Le.find(A=>A.id===N)?.explainHandler?.({id:"",params:["<value>"]})||"").replace(/\[(.*)\]\(.*\)/g,"$1")}function T(N){return Le.find(V=>V.id===N)}function B(N,V){return!(V.length<N.params.filter(G=>!G.optional).length)}},16516:(Ce,Oe,l)=>{l.d(Oe,{LE:()=>L,_z:()=>k});var j=l(23419),x=l(25224),o=l(55889),H=l(12906),ue=l(25577),g=l(4737);function k(m){const P=(0,o.bU)(m),U=x.E2.parse(P).topNode,K={query:{labels:[],operations:[]},errors:[]};try{w(P,U,K)}catch(re){console.error(re),re instanceof Error&&K.errors.push({text:re.message})}return R(K.query)&&(K.errors=[]),K}function w(m,P,M){const U=M.query;switch(P.type.id){case x.xO:{U.labels.push(pe(m,P));const I=P.getChild(o._A);I&&M.errors.push((0,o.wf)(m,I));break}case x.yx:{const{operation:I,error:K}=fe(m,P);I&&U.operations.push(I),K&&M.errors.push(D(m,P,K));break}case x.Li:{U.operations.push(de(m,P));break}case x.pj:{const{operation:I,error:K}=S(m,P);I&&U.operations.push(I),K&&M.errors.push(D(m,P,K));break}case x.Lu:{U.operations.push(te(m,P));break}case x.PQ:{U.operations.push(v(m,P));break}case x.Md:{U.operations.push(ye(m,P));break}case x.Xt:{const{operation:I,error:K}=xe(m,P,M);I&&U.operations.push(I),K&&M.errors.push(D(m,P,K));break}case x.pM:{U.operations.push(Le());break}case x.Tr:{U.operations.push(T(m,P,M));break}case x.M0:{U.operations.push(B(m,P,M));break}case x.uf:{V(m,P,M);break}case o._A:{if(A(P))break;M.errors.push((0,o.wf)(m,P));break}default:{let I=P.firstChild;for(;I;)w(m,I,M),I=I.nextSibling}}}function pe(m,P){const M=P.getChild(x.xb),U=(0,o.KF)(m,M),I=(0,o.KF)(m,M.nextSibling);let K=(0,o.KF)(m,P.getChild(x.Ld));return K=K.substring(1,K.length-1),{label:U,op:I,value:K}}function fe(m,P){const M=(0,o.KF)(m,P.getChild(x.wn)),U=L((0,o.KF)(m,P.getChild(x.Ld)));return P.getChild(x.JX)?.getChild(x.Ip)?{operation:{id:g.B5.LineFilterIpMatches,params:[M,U]}}:{operation:{id:{"|=":g.B5.LineContains,"!=":g.B5.LineContainsNot,"|~":g.B5.LineMatchesRegex,"!~":g.B5.LineMatchesRegexNot}[M],params:[U]}}}function de(m,P){const M=P.firstChild,U=(0,o.KF)(m,M),I=L((0,o.KF)(m,P.getChild(x.Ld)));let K=I?[I]:[];const re=(0,ue.XK)(U);return re&&!(0,ue.j$)(re,K)&&(K=re?.defaultParams||[]),{id:U,params:K}}function te(m,P){const M=P.getChild(x.bb),U=(0,o.KF)(m,M),I=[...(0,o.ff)(m,P,x.uw)];return{id:U,params:I}}function S(m,P){if(P.getChild(x.Or)||P.getChild(x.W8)||P.getChild("Comma"))return{error:'Label filter with comma, "and", "or" not supported in query builder'};if(P.firstChild.type.id===x.Fo){const i=P.firstChild,p=i?.getChild(x.xb),d=p?.nextSibling,Q=i?.getChild(x.Ld),C=L((0,o.KF)(m,Q));return{operation:{id:g.B5.LabelFilterIpMatches,params:[(0,o.KF)(m,p),(0,o.KF)(m,d),C]}}}const M=g.B5.LabelFilter;if(P.firstChild.type.id===x.ai){const p=P.firstChild.firstChild.firstChild,d=p.nextSibling,Q=d.nextSibling,C=L((0,o.KF)(m,Q));return{operation:{id:M,params:[(0,o.KF)(m,p),(0,o.KF)(m,d),C]}}}const I=P.firstChild.firstChild,K=I.nextSibling,re=K.nextSibling,ee=[(0,o.KF)(m,I),(0,o.KF)(m,K),L((0,o.KF)(m,re))];return ee.join("")==="__error__="?{operation:{id:g.B5.LabelFilterNoErrors,params:[]}}:{operation:{id:M,params:ee}}}function v(m,P){const M=g.B5.LineFormat,U=L((0,o.KF)(m,P.getChild(x.Ld)));return{id:M,params:[U]}}function ye(m,P){const M=g.B5.LabelFormat,U=P.getChild(x.xb),K=U.nextSibling.nextSibling;return{id:M,params:[(0,o.KF)(m,K),L((0,o.KF)(m,U))]}}function Le(){return{id:g.B5.Decolorize,params:[]}}function xe(m,P,M){const U=P.getChild(x.Xt),I=P.getChild(x.pj),K=P.getChild(x.Z7);if(U&&w(m,U,M),I&&w(m,I,M),K){if(K.nextSibling?.type.id===x.h3){const re=K.nextSibling,ee=re.nextSibling;return{operation:{id:g.B5.Unwrap,params:[(0,o.KF)(m,ee),(0,o.KF)(m,re)]}}}return{operation:{id:g.B5.Unwrap,params:[(0,o.KF)(m,K?.nextSibling),""]}}}return{}}function T(m,P,M){const U=P.getChild(x.gQ),I=(0,o.KF)(m,U),K=P.getChild(x.Mr),re=P.getChild(x.UN),ee=K!=null?[(0,o.KF)(m,K)]:[],i=re?.getChild(x.e6),p=i?(0,o.KF)(m,i):null;p&&ee.unshift(p.substring(1,p.length-1));const d={id:I,params:ee};return re&&w(m,re,M),d}function B(m,P,M){const U=P.getChild(x.Up);let I=(0,o.KF)(m,U);const K=P.getChild(x.Kz),re=[],ee=P.getChild(x.Mr);ee&&re.push(Number((0,o.KF)(m,ee))),K&&(K.getChild(x.By)&&I&&(I=`__${I}_by`),K.getChild(x.yN)&&(I=`__${I}_without`),re.push(...(0,o.ff)(m,K,x.xb)));const i=P.getChild(x.cq),p={id:I,params:re};return i&&w(m,i,M),p}const N=H.i.reduce((m,P)=>(m[P.sign]={id:P.id,comparison:P.comparison},m),{});function V(m,P,M){const U=M.query,I=P.firstChild,K=(0,o.KF)(m,I.nextSibling),re=G(m,P.getChild(j.v3)),ee=P.lastChild,i=N[K],p=u(I,"MetricExpr.LiteralExpr.Number"),d=u(ee,"MetricExpr.LiteralExpr.Number"),Q=ee.getChild(x.uf);if(p||w(m,I,M),d)U.operations.push((0,o.Es)(i,m,ee,!!re?.isBool));else if(Q){const C=(0,o.ge)(ee);C?.name==="Number"&&U.operations.push((0,o.Es)(i,m,C,!!re?.isBool)),w(m,ee,M)}else{U.binaryQueries=U.binaryQueries||[];const C={operator:K,query:{labels:[],operations:[]}};re?.isMatcher&&(C.vectorMatchesType=re.matchType,C.vectorMatches=re.matches),U.binaryQueries.push(C),w(m,ee,{query:C.query,errors:M.errors})}}function G(m,P){if(P){if(P.getChild(x.tW))return{isBool:!0,isMatcher:!1};{const M=P.getChild(j.Wc);return M?{isMatcher:!0,isBool:!1,matches:(0,o.KF)(m,M.getChild(x.XT)?.getChild(x.pQ)),matchType:M.getChild(x.On)?"on":"ignoring"}:void 0}}}function A(m){return m?.parent?.type.id===x.e6}function L(m){return m[0]==='"'&&m[m.length-1]==='"'?m.substring(1,m.length-1).replace(/\\"/g,'"').replace(/\\\\/g,"\\"):m.replace(/`/g,"")}function u(m,P){let M=m;const U=P.split(".");for(const I of U)if(M=M.getChild(I),!M)return null;return M}function D(m,P,M){const U=(0,o.wf)(m,P);return U.text=`${M}: ${U.text}`,U}function R(m){return m.labels.length===0&&m.operations.length===0}},4737:(Ce,Oe,l)=>{l.d(Oe,{AI:()=>ue,B5:()=>o,Hv:()=>j,Ly:()=>x,jK:()=>H});var j=(g=>(g.Log="log",g.Metric="metric",g))(j||{}),x=(g=>(g.Aggregations="Aggregations",g.RangeFunctions="Range functions",g.Functions="Functions",g.Formats="Formats",g.LineFilters="Line filters",g.LabelFilters="Label filters",g.BinaryOps="Binary operations",g))(x||{}),o=(g=>(g.Json="json",g.Logfmt="logfmt",g.Regexp="regexp",g.Pattern="pattern",g.Unpack="unpack",g.LineFormat="line_format",g.LabelFormat="label_format",g.Decolorize="decolorize",g.Rate="rate",g.RateCounter="rate_counter",g.CountOverTime="count_over_time",g.SumOverTime="sum_over_time",g.AvgOverTime="avg_over_time",g.MaxOverTime="max_over_time",g.MinOverTime="min_over_time",g.FirstOverTime="first_over_time",g.LastOverTime="last_over_time",g.StdvarOverTime="stdvar_over_time",g.StddevOverTime="stddev_over_time",g.QuantileOverTime="quantile_over_time",g.BytesRate="bytes_rate",g.BytesOverTime="bytes_over_time",g.AbsentOverTime="absent_over_time",g.Sum="sum",g.Avg="avg",g.Min="min",g.Max="max",g.Stddev="stddev",g.Stdvar="stdvar",g.Count="count",g.TopK="topk",g.BottomK="bottomk",g.LineContains="__line_contains",g.LineContainsNot="__line_contains_not",g.LineContainsCaseInsensitive="__line_contains_case_insensitive",g.LineContainsNotCaseInsensitive="__line_contains_not_case_insensitive",g.LineMatchesRegex="__line_matches_regex",g.LineMatchesRegexNot="__line_matches_regex_not",g.LineFilterIpMatches="__line_filter_ip_matches",g.LabelFilter="__label_filter",g.LabelFilterNoErrors="__label_filter_no_errors",g.LabelFilterIpMatches="__label_filter_ip_marches",g.Unwrap="unwrap",g.SumBy="__sum_by",g.SumWithout="__sum_without",g.Addition="__addition",g.Subtraction="__subtraction",g.MultiplyBy="__multiply_by",g.DivideBy="__divide_by",g.Modulo="__modulo",g.Exponent="__exponent",g.NestedQuery="__nested_query",g.EqualTo="__equal_to",g.NotEqualTo="__not_equal_to",g.GreaterThan="__greater_than",g.LessThan="__less_than",g.GreaterOrEqual="__greater_or_equal",g.LessOrEqual="__less_or_equal",g))(o||{}),H=(g=>(g[g.LineFilters=1]="LineFilters",g[g.Parsers=2]="Parsers",g[g.PipeOperations=3]="PipeOperations",g[g.Unwrap=4]="Unwrap",g[g.NoErrors=5]="NoErrors",g[g.RangeVectorFunction=5]="RangeVectorFunction",g[g.Last=6]="Last",g))(H||{});const ue={equals:{label:"=",value:"=",description:"Equals",isMultiValue:!1},doesNotEqual:{label:"!=",value:"!=",description:"Does not equal",isMultiValue:!1},matchesRegex:{label:"=~",value:"=~",description:"Matches regex",isMultiValue:!0},doesNotMatchRegex:{label:"!~",value:"!~",description:"Does not match regex",isMultiValue:!0},greaterThan:{label:">",value:">",description:"Greater than",isMultiValue:!1},greaterThanOrEqual:{label:">=",value:">=",description:"Greater than or equal to",isMultiValue:!1},lessThan:{label:"<",value:"<",description:"Less than",isMultiValue:!1},lessThanOrEqual:{label:"<=",value:"<=",description:"Less than or equal to",isMultiValue:!1},contains:{label:"|=",value:"|=",description:"Contains",isMultiValue:!1},doesNotContain:{label:"!=",value:"!=",description:"Does not contain",isMultiValue:!1}}},84273:(Ce,Oe,l)=>{l.d(Oe,{_P:()=>T,EO:()=>de,vh:()=>fe,ki:()=>ye,e8:()=>S,Y:()=>Le,OP:()=>te,zb:()=>v});var j=l(29241),x=l(32082),o=l(43987),H=l(64987),ue=l(64826);function g(L){let u;try{u=JSON.parse(L)}catch{}return typeof u=="object"}const k=/(?:^|\s)([\w\(\)\[\]\{\}]+)=(""|(?:".*?[^\\]"|[^"\s]\S*))/;function w(L){return k.test(L)}function pe(L){let u;try{return u=JSON.parse(L),u.hasOwnProperty("_entry")}catch{return!1}}function fe(L){return(L.fields.find(D=>D.name==="labels")?.values??[]).some(D=>D.__error__!==void 0)}function de(L){return(L.fields.find(D=>D.name==="labels")?.values??[]).some(D=>D.level!==void 0)}function te(L){const u=L.fields.find(M=>M.type===j.fS.string);if(u==null)return{hasJSON:!1,hasLogfmt:!1,hasPack:!1};const D=u.values;let R=!1,m=!1,P=!1;return D.forEach(M=>{g(M)&&(R=!0,P=pe(M)),w(M)&&(m=!0)}),{hasLogfmt:m,hasJSON:R,hasPack:P}}function S(L){const u=L?.fields?.find(D=>D.name==="labels")?.values??[];return u?.length?Object.keys(u[0]):[]}function v(L){const u=L?.fields?.find(R=>R.name==="labels")?.values??[];return u?.length?Object.keys(u[0]).filter(R=>{const m=u[0][R];return m?!isNaN(Number(m))||(0,x.IA)(m)||(0,ue.aC)(m):!1}).filter(R=>u.every(m=>m[R])):[]}function ye(L){const u=L.fields.find(R=>R.name==="labels"&&R.type===j.fS.other);return u==null?!1:u.values.some(R=>R.__error__)}function Le(L){const u=L.fields.find(m=>m.name==="labels"&&m.type===j.fS.other);if(u==null)return null;const D=u.values.slice(0,2);let R=null;for(let m of D){const P=Object.keys(m).find(M=>M==="lvl"||M.includes("level"));if(P){R=P;break}}return R}function xe(L,u){if(L.refId!==u.refId)return!1;const D=L.meta?.type,R=u.meta?.type;if(D!==R)return!1;if(D===o.P.TimeSeriesMulti){const M=L.fields.find(I=>I.type===j.fS.number),U=u.fields.find(I=>I.type===j.fS.number);return M===void 0||U===void 0?!1:(0,H.Vv)(M.labels??{},U.labels??{})}const m=L.meta?.custom?.frameType,P=u.meta?.custom?.frameType;return m==="LabeledTimeValues"&&P==="LabeledTimeValues"}function T(L,u){if(!L)return G(u);u.data.forEach(P=>{const M=L.data.find(U=>xe(U,P));if(!M){L.data.push(A(P));return}B(M,P)});const D=[...L.errors??[],...u.errors??[]];D.length>0&&(L.errors=D);const R=L.error??u.error;R!=null&&(L.error=R);const m=[...L.traceIds??[],...u.traceIds??[]];return m.length>0&&(L.traceIds=m),L}function B(L,u){const D=L.fields.length;for(let R=0;R<D;R++)if(L.fields[R].values=[].concat.apply(u.fields[R].values,L.fields[R].values),u.fields[R].nanos){const m=L.fields[R].nanos?.slice()||[];L.fields[R].nanos=u.fields[R].nanos?.concat(m)}L.length+=u.length,L.meta={...L.meta,stats:V(L.meta?.stats??[],u.meta?.stats??[])}}const N="Summary: total bytes processed";function V(L,u){const D=L.find(P=>P.displayName===N),R=u.find(P=>P.displayName===N);if(R!=null&&D!=null)return[{value:R.value+D.value,displayName:N,unit:D.unit}];const m=R??D;return m!=null?[m]:[]}function G(L){return{...L,data:L.data.map(A)}}function A(L){return{...L,fields:L.fields.map(u=>({...u,values:u.values}))}}},57864:(Ce,Oe,l)=>{l.d(Oe,{Ci:()=>xe,Dl:()=>T,uJ:()=>fe});var j=l(62247),x=l(86312),o=l(34667),H=l(81587),ue=l(39568),g=l(61875),k=l(93716),w=l(73565),pe=l(24513);const fe=({payload:{dashboardId:B,orgId:N,grafanaVersion:V,queries:G}})=>{try{const A=G[k.id].filter(ee=>!ee.hide).map(ee=>(0,w.Ib)(ee));if(!A?.length)return;const L=A.filter(ee=>(0,w.rE)(ee.expr)),u=A.filter(ee=>!(0,w.rE)(ee.expr)),D=A.filter(ee=>ee.queryType===pe.EM.Instant),R=A.filter(ee=>ee.queryType===pe.EM.Range),m=A.filter(ee=>ee.editorMode===ue.c.Builder),P=A.filter(ee=>ee.editorMode===ue.c.Code),M=A.filter(de),U=A.filter(te),I=A.filter(S),K=A.filter(v),re={grafana_version:V,dashboard_id:B,org_id:N,queries_count:A.length,logs_queries_count:L.length,metric_queries_count:u.length,instant_queries_count:D.length,range_queries_count:R.length,builder_mode_queries_count:m.length,code_mode_queries_count:P.length,queries_with_template_variables_count:M.length,queries_with_changed_resolution_count:U.length,queries_with_changed_line_limit_count:I.length,queries_with_changed_legend_count:K.length};(0,x.ff)("grafana_loki_dashboard_loaded",re)}catch(A){console.error("error in loki tracking handler",A)}},de=B=>H.J7.test(B.expr),te=B=>B.resolution?B.resolution!==1:!1,S=B=>B.maxLines!==null&&B.maxLines!==void 0,v=B=>B.legendFormat?B.legendFormat!=="":!1,ye=B=>{const N=[g.xf,g.NZ,g.V8];return!!(B===g.Ic||N.some(V=>B.startsWith(V)))},Le=B=>{let N=0;for(const V of B.data){const G=V.meta?.custom?.lokiQueryStatKey;G&&(N+=V.meta?.stats?.find(A=>A.displayName===G)?.value??0)}return N};function xe(B,N,V,G={},A={}){const{app:L,targets:u}=N;if(L===j.zj.Dashboard||L===j.zj.PanelViewer)return;let D=Le(B);for(const R of u){if(ye(R.refId))return;(0,x.ff)("grafana_loki_query_executed",{app:L,grafana_version:o.config.buildInfo.version,editor_mode:R.editorMode,has_data:B.data.some(m=>m.length>0),has_error:B.error!==void 0,legend:R.legendFormat,line_limit:R.maxLines,parsed_query:(0,w.dQ)(R.expr).join(","),obfuscated_query:(0,w.H6)(R.expr),query_type:(0,w.rE)(R.expr)?"logs":"metric",query_vector_type:R.queryType,resolution:R.resolution,simultaneously_executed_query_count:u.filter(m=>!m.hide).length,simultaneously_hidden_query_count:u.filter(m=>m.hide).length,time_range_from:N?.range?.from?.toISOString(),time_range_to:N?.range?.to?.toISOString(),time_taken:Date.now()-V.getTime(),bytes_processed:D,is_split:!1,predefined_operations_applied:G.predefinedOperations?R.expr.includes(G.predefinedOperations):"n/a",...A})}}function T(B,N,V,G,A={}){const L={split_query_group_count:N.length,split_query_largest_partition_size:Math.max(...N.map(({partition:u})=>u.length)),split_query_total_request_count:N.reduce((u,{partition:D})=>u+D.length,0),is_split:!0,simultaneously_executed_query_count:V.targets.filter(u=>!u.hide).length,simultaneously_hidden_query_count:V.targets.filter(u=>u.hide).length};for(const u of N){const D=u.partition.length;xe(B,u.request,G,A,{...L,split_query_partition_size:D})}}},24513:(Ce,Oe,l)=>{l.d(Oe,{sb:()=>H,EM:()=>x,Z3:()=>g,$o:()=>o});var j=(k=>(k.Builder="builder",k.Code="code",k))(j||{}),x=(k=>(k.Instant="instant",k.Range="range",k.Stream="stream",k))(x||{}),o=(k=>(k.DataSample="dataSample",k.LogsSample="logsSample",k.LogsVolume="logsVolume",k))(o||{}),H=(k=>(k.Backward="backward",k.Forward="forward",k))(H||{}),ue=(k=>(k.Stream="streams",k.Vector="vector",k.Matrix="matrix",k))(ue||{}),g=(k=>(k[k.LabelNames=0]="LabelNames",k[k.LabelValues=1]="LabelValues",k))(g||{})},25224:(Ce,Oe,l)=>{l.d(Oe,{By:()=>ft,E2:()=>oe,Fo:()=>De,Ih:()=>Jt,Ip:()=>ct,JX:()=>Ot,Kz:()=>ze,Ld:()=>$e,Li:()=>Xe,Lu:()=>Ae,M0:()=>nt,Md:()=>Bt,Mr:()=>Ie,OC:()=>qt,On:()=>Kt,Or:()=>jt,PQ:()=>He,Qf:()=>Te,Tr:()=>bt,UN:()=>Ve,Up:()=>Et,W8:()=>zt,WZ:()=>Ht,We:()=>Zt,XT:()=>lr,Xt:()=>Ze,Z7:()=>et,aX:()=>q,ai:()=>ce,bL:()=>mt,bb:()=>he,cq:()=>Ne,dh:()=>Qt,e6:()=>Ke,gD:()=>Gt,gP:()=>Yt,gQ:()=>yt,h3:()=>at,iP:()=>Fe,pM:()=>kt,pQ:()=>cr,pj:()=>We,tW:()=>ut,uf:()=>xt,uw:()=>Ct,wi:()=>pt,wm:()=>St,wn:()=>Ft,xO:()=>gt,xb:()=>Qe,yN:()=>dt,yx:()=>je,zV:()=>Ye});var j=l(55859);const x=1,o=2,H=3,ue=4,g=5,k=6,w=7,pe=8,fe=9,de=10,te=11,S=12,v=13,ye=14,Le=15,xe=16,T=17,B=18,N=19,V=20,G=21,A=22,L=23,u=24,D=25,R=26,m=27,P=28,M=29,U=30,I=31,K=32,re=33,ee=34,i=38,p=86,d={json:x,logfmt:o,unpack:H,pattern:ue,regexp:g,ip:w,label_format:pe,line_format:fe,label_replace:de,vector:te,offset:S,bool:v,on:ye,ignoring:Le,group_left:xe,group_right:T,unwrap:k,decolorize:B,drop:N,keep:V},Q=h=>d[h.toLowerCase()]||-1,C={by:G,without:A,and:L,or:u,unless:D,sum:R,avg:m,count:P,max:M,min:U,stddev:I,stdvar:K,bottomk:re,topk:ee},J=h=>C[h.toLowerCase()]||-1,ne={__proto__:null,count_over_time:281,rate:283,rate_counter:285,bytes_over_time:287,bytes_rate:289,avg_over_time:291,sum_over_time:293,min_over_time:295,max_over_time:297,stddev_over_time:299,stdvar_over_time:301,quantile_over_time:303,first_over_time:305,last_over_time:307,absent_over_time:309,bytes:315,duration:317,duration_seconds:319},oe=j.WQ.deserialize({version:14,states:"CdOYQPOOO#]QPO'#DTO$lQPO'#DSOYQPO'#DSOOQO'#EW'#EWO$yQPO'#EVOOQO'#Es'#EsO%OQPO'#ErQ%ZQPOOOOQO'#FR'#FRO&[QPO'#FRO&aQPO'#FSO&fQPO'#FTOOQO'#EU'#EUOOQO'#DR'#DROOQO'#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'#EgO&kQPO'#DVOOQO'#DU'#DUO&yQPO,59oOOQO'#Db'#DbO'RQPO'#DaOOQO'#D`'#D`O'ZQPO'#D_O(tQPO'#D_OOQO'#D^'#D^O*vQPO,59nO,UQPO,59nO,]QPO,5:pO,dQPO,5:qO,oQPO'#EpO.tQPO,5;^O.{QPO,5;^O/QQPO,5;`O/QQPO,5;`O/QQPO,5;`O/QQPO,5;`O/QQPO,5;`O/QQPO,5;`OOQO,5;m,5;mOYQPO,5;nO1^QPO,5;oO1cQPO,59qO#]QPO,59pOOQO1G/Z1G/ZOOQO'#De'#DeOOQO,59{,59{O1hQPO,59{OOQO,59z,59zO1mQPO'#DVO2[QPO'#DgOOQO'#Dg'#DgO3xQPO'#DgO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i&[R%Z$fR#i!kQ#h!kR%[$gR#m!lQ#l!lR%]$hj^O!|!}#O#P#Q#R&`&a&b&c&d&eQyRQ!v|Q#S!VQ#|!xQ${#{R%o$|w]OR|!V!x!|!}#O#P#Q#R#{$|&`&a&b&c&d&ewTOR|!V!x!|!}#O#P#Q#R#{$|&`&a&b&c&d&ewSOR|!V!x!|!}#O#P#Q#R#{$|&`&a&b&c&d&eQ!szQ#t!rR$w#vS#r!q#sW$k#o#q$r$sQ%d$jQ%k$tR%w%jQ$q#rQ%d$kQ%y%kR&R%wQ#q!qS$j#o$rQ$p#rQ$s#sS%g$n$qS%v%i%kR&S%yR%`$iR%^$iQ}VQ$v#uQ$z#zQ%z%lR%{%nR#x!uwVOR|!V!x!|!}#O#P#Q#R#{$|&`&a&b&c&d&eQ!|!OQ!}!PQ#O!QQ#P!RQ#Q!SQ#R!TQ&`&fQ&a&gQ&b&hQ&c&iQ&d&jR&e&kh!z!O!P!Q!R!S!T&f&g&h&i&j&kR$R!{Q$P!yQ%R$QR%r%SR%O$OQ%P$OR%|%p",nodeNames:"\u26A0 Json Logfmt Unpack Pattern Regexp Unwrap Ip LabelFormat LineFormat LabelReplace Vector Offset Bool On Ignoring GroupLeft GroupRight Decolorize Drop Keep By Without And Or Unless Sum Avg Count Max Min Stddev Stdvar Bottomk Topk LineComment LogQL Expr LogExpr Selector Matchers Matcher Identifier Eq String Neq Re Nre PipelineExpr PipelineStage LineFilters LineFilter Filter PipeExact PipeMatch FilterOp Pipe LabelParser JsonExpressionParser JsonExpressionList JsonExpression LabelFilter IpLabelFilter UnitFilter DurationFilter Gtr Duration Gte Lss Lte Eql BytesFilter Bytes NumberFilter Number LineFormatExpr LabelFormatExpr LabelsFormat LabelFormatMatcher DecolorizeExpr DropLabelsExpr DropLabels DropLabel KeepLabelsExpr KeepLabels KeepLabel MetricExpr RangeAggregationExpr RangeOp CountOverTime Rate RateCounter BytesOverTime BytesRate AvgOverTime SumOverTime MinOverTime MaxOverTime StddevOverTime StdvarOverTime QuantileOverTime FirstOverTime LastOverTime AbsentOverTime LogRangeExpr Range OffsetExpr UnwrapExpr ConvOp BytesConv DurationConv DurationSecondsConv Grouping Labels VectorAggregationExpr VectorOp BinOpExpr BinOpModifier OnOrIgnoringModifier GroupingLabels GroupingLabelList GroupingLabel LabelName Add Sub Mul Div Mod Pow LiteralExpr LabelReplaceExpr VectorExpr",maxTerm:159,skippedNodes:[0,35],repeatNodeCount:0,tokenData:"3X~RvX^#ipq#iqr$^rs$qst%cuv%nxy%syz%xz{%}{|&S|}&X}!O&^!O!P&c!P!Q'c!Q!R'h!R![)O![!]0O!^!_0d!_!`0q!`!a1W!c!}1e!}#O1{#P#Q2Q#Q#R2V#R#S1e#S#T2[#T#o1e#o#p2h#p#q2m#q#r3S#y#z#i$f$g#i#BY#BZ#i$IS$I_#i$I|$JO#i$JT$JU#i$KV$KW#i&FU&FV#i~#nY#z~X^#ipq#i#y#z#i$f$g#i#BY#BZ#i$IS$I_#i$I|$JO#i$JT$JU#i$KV$KW#i&FU&FV#i~$aQ!_!`$g#r#s$l~$lO}~~$qO!P~~$tUOY$qZr$qrs%Ws#O$q#O#P%]#P~$q~%]O|~~%`PO~$q~%hQs~OY%cZ~%c~%sO#s~~%xO$O~~%}O$P~~&SO#q~~&XO#o~~&^O#|~~&cO#p~~&fP!Q![&i~&nR!l~!Q![&i!g!h&w#X#Y&w~&zR{|'T}!O'T!Q!['Z~'WP!Q!['Z~'`P!l~!Q!['Z~'hO#r~~'me!l~!O!P&i!Q![)O!g!h*c!i!j+Q!m!n+Q!o!p+Q!r!s+Q!v!w+Q#U#V*u#W#X+Z#X#Y-]#Z#[-o#[#]+r#_#`-o#a#b-x#d#e-o#g#h,z#h#i-o#k#l.Z#l#m/d#m#n.u~)Td!l~!O!P&i!Q![)O!g!h*c!i!j+Q!m!n+Q!o!p+Q!r!s+Q!v!w+Q#U#V*u#W#X+Z#X#Y-]#Z#[-o#[#]+r#_#`-o#a#b-x#d#e-o#g#h,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38,Te=39,Yt=40,gt=41,Qe=42,Rr=43,$e=44,X=45,Tr=46,_r=47,Fe=48,Zt=49,St=50,je=51,Ft=52,qt=53,Jt=54,Ot=55,ht=56,Xe=57,Ae=58,Sr=59,Ct=60,We=61,De=62,ce=63,Mt=64,er=65,Dt=66,Ee=67,Fr=68,tr=69,Cr=70,Nt=71,vt=72,Ge=73,Ie=74,He=75,Ye=76,Mr=77,Bt=78,tt=79,Dr=80,Nr=81,rr=82,Br=83,Ir=84,wr=85,Ne=86,bt=87,yt=88,Ar=89,Ur=90,It=91,Pt=92,Xr=93,Wr=94,Vr=95,ar=96,nr=97,sr=98,Kr=99,kr=100,zr=101,jr=102,Gr=103,Ve=104,Ke=105,rt=106,Ze=107,at=108,ir=109,or=110,Hr=111,ze=112,Yr=113,nt=114,Et=115,xt=116,Zr=117,qr=118,lr=119,cr=120,Jr=121,ea=122,ur=123,fr=124,ta=125,ra=126,aa=127,na=128,Qt=129,wt=130,At=131;function st(h,y){const E=[];return oe.parse(h).iterate({enter:F=>{(y===void 0||y===F.type.id)&&E.push(F.node)}}),E[0]}function Lt(h){return!st(h,p)}function we(h){return" ".repeat(h)}function qe(h,y){return h.split(` `).map($=>we(y)+$).join(` `)}function Ut(h){return h.split(` `).map(E=>E.trimEnd()).join(` `)}function Xt(h,y){const E=h.firstChild?.type.id===y;let $=!1;return h.firstChild&&E&&($=!0,h=h.firstChild),{addBrackets:$,newNode:h}}function Se(h,y){const E=[];let $=h.firstChild;for(;$;)y.includes($.type.id)&&E.push($),E.push(...Se($,y)),$=$.nextSibling;return E}function Be(h,y,E){return y===h?` ${E}`:` ${we(1)}${E}`}function it(h,y){let E=h.length-1;for(;E>=0&&y.includes(h[E]);)E--;return h.substring(0,E+1)}const ot=(h,y)=>{const{addBrackets:E,newNode:$}=Xt(h,mt);h=$;const F=oe.parse(y.substring(h.from,h.to));let z="";return F.iterate({enter:se=>{const ie=se.node;switch(ie.type.id){case Te:z+=$t(ie,y);break;case Fe:ie.parent?.type.id!==Fe&&(z+=Wt(ie,y));break}}}),E?"("+z+")":z};function $t(h,y){const E=y.substring(h.from,h.to),$=oe.parse(E),F=[];let z="";return $.iterate({enter:se=>{const ie=se.node;ie.type.id===gt&&F.push(ie)}}),F.sort((se,ie)=>{const me=se.getChild(Qe),ge=ie.getChild(Qe),ve=me&&y.substring(me.from,me.to),Ue=ge&&y.substring(ge.from,ge.to);return!ve||!Ue?0:ve<Ue?-1:ve>Ue?1:0}),F.forEach(se=>{const ie=se.getChild(Qe),me=ie?ie.nextSibling:null,ge=se.getChild($e),ve=ie?y.substring(ie.from,ie.to):null,Ue=me?y.substring(me.from,me.to):null,ke=ge?y.substring(ge.from,ge.to):null;z+=`${ve}${Ue}${ke}, `}),"{"+it(z,", ")+"}"}function Wt(h,y){const E=[je,Xe,We,Ae,He,Ye,tt];let $,F="";return Se(h,E).forEach(z=>{switch(z.type.id){case je:F+=Be(je,$,dr(z,y)),$=je;break;case Xe:F+=Be(Xe,$,s(z,y)),$=Xe;break;case Ae:F+=Be(Ae,$,t(z,y)),$=Ae;break;case We:F+=Be(We,$,e(z,y)),$=We;break;case He:F+=Be(He,$,r(z,y)),$=He;break;case Ye:F+=Be(Ye,$,a(z,y)),$=Ye;break;case tt:F+=Be(tt,$,n()),$=tt;break}}),F}function dr(h,y){const E=h.getChild(Ft),$=h.getChild(Ot),F=h.getChild($e),z=E&&y.substring(E.from,E.to),se=F&&y.substring(F.from,F.to);return $?`${z} ip(${se})`:`${z} ${se}`}function s(h,y){if(h.getChild($e)){const F=h.getChild(Je)||h.getChild(Me),z=h.getChild($e),se=F&&y.substring(F.from,F.to),ie=z&&y.substring(z.from,z.to);return`| ${se}${ie}`}return`| ${y.substring(h.from,h.to)}`}function t(h,y){const E=Se(h,[Ct]);let $="";return E.forEach(F=>{const z=F.getChild(Qe),se=F.getChild($e),ie=z&&y.substring(z.from,z.to),me=se&&y.substring(se.from,se.to);$+=`${ie}=${me}, `}),`| json ${it($,", ")}`}function e(h,y){const E=h.getChild(gt)||h.getChild(De)||h.getChild(Ge)||h.getChild(ce)?.getChild(Mt)||h.getChild(ce)?.getChild(Nt);if(!E)return"";const $=E.type.id,F=E.getChild(Qe),z=F&&F.nextSibling;let se;$===Mt?se=E.getChild(Dt):$===Nt?se=E.getChild(vt):$===Ge?se=E.getChild(Ie):se=E.getChild($e);const ie=F&&y.substring(F.from,F.to),me=z&&y.substring(z.from,z.to),ge=se&&y.substring(se.from,se.to);return $===De?`| ${ie}${me}ip(${ge})`:`| ${ie}${me}${ge}`}function r(h,y){const E=h.getChild($e);return`| line_format ${E&&y.substring(E.from,E.to)}`}function a(h,y){const E=Se(h,[Bt]);let $="| label_format ";return E.forEach(F=>{let z,se;F.getChildren(Qe).length===2?[z,se]=F.getChildren(Qe):(z=F.getChild(Qe),se=F.getChild($e));const ie=z&&y.substring(z.from,z.to),me=se&&y.substring(se.from,se.to);$+=`${ie}=${me}, `}),it($,", ")}function n(){return"| decolorize"}const c=(h,y)=>{const{addBrackets:E,newNode:$}=Xt(h,Ne);h=$;let F="";const z=h.firstChild;switch(z&&z.type.id){case bt:F=f(h,y);break;case nt:F=_(h,y);break;case xt:F=Z(h,y);break;case Qt:F=Y(h,y);break;case wt:F=W(h,y);break;case At:F=ae(h,y);break}return E?"("+F+")":F};function f(h,y){let E="";return Se(h,[yt,Ie,Ve,ze]).forEach($=>{if($.parent?.type.id===bt)switch($.type.id){case yt:E+=`${y.substring($.from,$.to)}( `;break;case Ie:E+=`${we(1)+y.substring($.from,$.to)}, `;break;case Ve:E+=O($,y);break;case ze:E+=b($,y);break}}),E}function O(h,y){const E=[];let $="",F="",z="",se="",ie="";Se(h,[Te,Ke,rt,Ze,Fe]).forEach(ge=>{if(ge.parent?.type.id===Ve)switch(E.push(ge),ge.type.id){case Te:{let ve=y.substring(ge.from,ge.to);$+=$t({...ge,from:0,to:ve.length},ve);break}case Fe:F+=Wt(ge,y);break;case Ke:z+=y.substring(ge.from,ge.to);break;case rt:{const ve=ge.getChild(Dt);se+=` offset ${ve?y.substring(ve.from,ve.to):""}`;break}case Ze:Se(ge,[Qe,at,We]).forEach((ve,Ue,ke)=>{switch(ve.type.id){case Qe:{if(ve.parent?.type.id!==Ze||ke.find(_e=>_e.type.id===at))return;ie+=`| unwrap ${y.substring(ve.from,ve.to)} `;return}case at:{const le=ke.find(Re=>Re.type.id===Qe),_e=le?y.substring(le.from,le.to):"";ie+=`| unwrap ${y.substring(ve.from,ve.to)}(${_e}) `;return}case We:ie+=e(ve,y);return}});break}});let me="";return E.forEach((ge,ve,Ue)=>{const ke=Ue[ve-1];ge.type.id===Te&&(me+=we(1)+$),ge.type.id===Fe&&(me+=qe(F,1)),ge.type.id===Ke&&(me+=` `+we(1)+z),ge.type.id===rt&&(me+=se),ge.type.id===Ze&&(ke?.type.id!==rt&&ke?.type.id!==Ke?me+=` `+we(1)+ie:me+=" "+ie)}),me+=` )`}function b(h,y){let E="";const $=Se(h,[Qe]).map(F=>y.substring(F.from,F.to));return Se(h,[ft,dt]).forEach(F=>{if(F.parent?.type.id===ze)switch(F.type.id){case ft:E=` by (${$.join(", ")}) `;break;case dt:E=` without (${$.join(", ")}) `;break}}),E}function _(h,y){let E="";return Se(h,[Et,Ie,Ne,ze]).forEach(($,F,z)=>{if($.parent?.type.id===nt)switch($.type.id){case Et:E+=`${y.substring($.from,$.to)}`;break;case Ie:E+=`( `,E+=`${we(1)+y.substring($.from,$.to)}, `;break;case Ne:{const se=z.find(ge=>ge.type.id===Ie&&ge.parent?.type.id===nt);E+=se?"":`( `;const ie=y.substring($.from,$.to),me=st(ie,Ne);E+=qe(c(me,ie),1),E+=` )`;break}case ze:E+=b($,y);break}}),E}function Z(h,y){let E;const[$,F]=Se(h,[pt]).map((z,se)=>{se===0&&(E=y.substring(z.nextSibling?.from??0,z.nextSibling?.to));const ie=y.substring(z.from,z.to);let me;return Lt(ie)?(me=st(ie,i),ot(me,ie)):(me=st(ie,Ne),c(me,ie))});return $+` `+E+` `+F}function Y(h,y){h=h.getChild(Qt)??h;const E=h.getChild(ur),$=h.getChild(fr),F=h.getChild(Ie);return F?E?`+${y.substring(F.from,F.to)}`:$?`-${y.substring(F.from,F.to)}`:y.substring(F.from,F.to):""}function W(h,y){let E=`label_replace( `;return Se(h,[Ne,$e]).forEach($=>{if($.parent?.type.id===wt)if($.type.id===Ne){const F=y.substring($.from,$.to),z=st(F,Ne);E+=qe(c(z,F),1)+`, `}else E+=we(1)+y.substring($.from,$.to)+`, `}),it(E,`, `)+` )`}function ae(h,y){h=h.getChild(At)??h;const E=h.getChild(Ie);return E?`vector(${y.substring(E.from,E.to)})`:""}const q=h=>{const y=oe.parse(h);let E="";return y.iterate({enter:$=>{const F=$.node;if(!(F.parent?.type.id!==pt||F.parent?.parent?.type.id===xt))switch(F.type.id){case Ne:return E=c(F,h),!1;case mt:return E=ot(F,h),!1}}}),Ut(E)}}}]); //# sourceMappingURL=3565.c72c689910f39dca72d5.js.map