"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[5841],{55841(T,P,n){n.d(P,{extractFieldsTransformer:()=>M});var d=n(2543),_=n.n(d),E=n(81160),v=n(81239),K=n(72830),x=n(19560),A=n(17727),O=n(47468),p=n(9868),m=n(64032);const M={id:x.F.extractFields,name:"Extract fields",description:"Parse fields from the contends of another",defaultOptions:{delimiter:","},operator:(e,t)=>s=>s.pipe((0,E.T)(a=>M.transformer(e,t)(a))),transformer:e=>t=>t.map(s=>r(s,e))};function r(e,t){if(!t.source)return e;const s=(0,O.UI)(e,t.source);if(!s)return e;const a=p.S.getIfExists(t.format??m.K.Auto);if(!a)throw new Error("unkonwn extractor");const c=e.length,o=[],g=new Map,D=a.getParser(t);for(let f=0;f<c;f++){let i=s.values[f];if((0,d.isString)(i))try{i=D(i)}catch{i={}}if(i!=null){if(t.format===m.K.JSON&&t.jsonPaths&&t.jsonPaths?.length>0){const u={},h=t.jsonPaths.filter(l=>l.path);h.length>0&&(h.forEach(l=>{const U=l.alias&&l.alias.length>0?l.alias:l.path;u[U]=(0,d.get)(i,l.path)??"Not Found"}),i=u)}for(const[u,h]of Object.entries(i)){let l=g.get(u);l==null&&(l=new Array(c).fill(void 0),g.set(u,l),o.push(u)),l[f]=h}}}const R=o.map(f=>{const i=g.get(f);if(!i)throw new Error(`Could not find field with name: ${f}`);const u={name:f,values:i,type:i?(0,v.oE)(i.find(h=>h!=null)):A.PU.other,config:{}};return u.name=(0,K.fk)(u,e),u});if(t.keepTime){const f=(0,O.UI)(e,"Time")||(0,O.UI)(e,"time");f&&R.unshift(f)}return t.replace||R.unshift(...e.fields),{...e,fields:R}}},9868(T,P,n){n.d(P,{S:()=>M});var d=n(85453),_=n(11011),E=n(64032);const v={id:E.K.JSON,name:"JSON",description:"Parse JSON string",getParser:r=>e=>JSON.parse(e)},K={id:E.K.RegExp,name:"RegExp",description:"Parse with RegExp",getParser:r=>{let e=/(?<NewField>.*)/;if((0,d.AP)(r.regExp))try{e=(0,d.dO)(r.regExp)}catch(t){t instanceof Error&&console.warn(t.message)}return t=>t.match(e)?.groups}};function x(r){const e=[];let t="",s="";const a={};for(let c=0;c<r.length;c++){let o=r[c];o===t&&(t="",o=r[++c]);const g=o==="\\";if(g&&(o=r[++c]),g||t.length){e.push(o);continue}switch((o==='"'||o==="'")&&(t=o),o){case":":case"=":e.length&&(s&&(a[s]=""),s=e.join(""),e.length=0);break;case'"':case"'":case" ":case"	":case"\r":case`
`:e.length&&s===""&&(a[e.join("")]="",e.length=0);case",":case";":case"&":case"{":case"}":if(e.length){const D=e.join("");s.length?(a[s]=D,s=""):s=D,e.length=0}break;default:e.push(o),c===r.length-1&&s===""&&e.length&&(a[e.join("")]="",e.length=0)}}return s.length&&(a[s]=e.join("")),a}const A={id:E.K.KeyValues,name:"Key+value pairs",description:"Look for a=b, c: d values in the line",getParser:r=>x},O={id:E.K.Delimiter,name:"Split by delimiter",description:"Splits at delimited values, such as commas",getParser:({delimiter:r=","})=>{const e=new RegExp(`\\s*${(0,d.jD)(r)}\\s*`,"g");return t=>{const s=t.trim().split(e),a={};for(const c of s)a[c]=1;return a}}},p=[v,A,O,K],m={id:E.K.Auto,name:"Auto",description:"parse new fields automatically",getParser:r=>{const e=p.map(t=>t.getParser(r));return t=>{for(const s of e)try{const a=s(t);if(a!=null)return a}catch{}}}},M=new _.O(()=>[...p,m])},64032(T,P,n){n.d(P,{K:()=>d});var d=(_=>(_.JSON="json",_.KeyValues="kvp",_.Auto="auto",_.RegExp="regexp",_.Delimiter="delimiter",_))(d||{})}}]);

//# sourceMappingURL=5841.e755ca1c0a0f0a4beb9e.js.map