"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[8410],{48410(y,D,o){o.d(D,{getTimeSeriesTableTransformer:()=>U,q:()=>g});var F=o(81160),p=o(43866),_=o(69839),A=o(19560),v=o(76529),O=o(26384),u=o(17727),b=o(52358);const U=()=>({id:A.F.timeSeriesTable,name:(0,b.t)("transformers.time-series-table.name.time-series-to-table","Time series to table"),description:(0,b.t)("transformers.time-series-table.description.convert-to-table-rows","Convert time series data to table rows so that they can be viewed in tabular or sparkline format."),defaultOptions:{},isApplicable:n=>{for(const r of n)if((0,_.aH)(r))return O.M.Applicable;return O.M.NotApplicable},isApplicableDescription:(0,b.t)("transformers.time-series-table.is-applicable-description.requires-time-series-frame","The Time series to table transformation requires at least one time series frame to function. You currently have none."),operator:n=>r=>r.pipe((0,F.T)(a=>C(n,a)))});function C(n,r){const a={},m={},E=[];let I=g(r);for(const e of Object.keys(I)){const d=r.filter(i=>i.refId===e);a[e]={},m[e]={};const f=[];d.forEach(i=>{i.fields.forEach(s=>{s.type===u.PU.number&&s.labels&&Object.keys(s.labels).forEach(t=>{f.includes(t)||(m[e][t]=h(t,u.PU.string),f.push(t))})})});for(let i=0;i<d.length;i++){const s=d[i];let t=null,c=n[e]?.timeField;if(c&&c.length>0?t=s.fields.find(l=>l.name===c):t=s.fields.find(l=>(0,_.hF)(l)),!(0,_.aH)(s)){E.push(s);continue}for(const l of s.fields){if(l.type!==u.PU.number)continue;const M=n[e]?.stat??v.gy.lastNotNull,R=(0,v.Nw)({field:l,reducers:[M]})[M]??null,T=new p.k;t!==void 0&&(T.addField(t),T.addField(l),a[e][`Trend #${e}`]===void 0&&(a[e][`Trend #${e}`]=h(`Trend #${e}`,u.PU.frame)),a[e][`Trend #${e}`].values.push({...T,value:R,length:l.values.length})),f.forEach(P=>{m[e][P].values.push(l.labels?.[P]??"")})}}}for(const e of Object.keys(I)){const d={},f=new p.k;f.refId=e;const i=m[e];if(i!==void 0)for(const[t,c]of Object.entries(i))d[t]===void 0&&(d[t]=c);for(const t of Object.values(d))f.addField(t);const s=a[e];for(const t of Object.values(s))f.addField(t);f.fields.length>0&&E.push(f)}return E}function h(n,r){return{name:n,type:r,config:{},values:[]}}function g(n){let r={};for(const a of n)a.refId!==void 0&&(r[a.refId]===void 0?r[a.refId]=1:r[a.refId]++);return r}}}]);

//# sourceMappingURL=8410-react19.3ad3692f08dea5e45316.js.map