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

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