"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[5076,8410],{65076(F,g,t){t.d(g,{TimeSeriesTableTransformEditor:()=>h});var d=t(14553),T=t(55501),O=t(69839),E=t(76529),m=t(52358),b=t(89702),c=t(72480),M=t(59714),C=t(6634),A=t(87748),D=t(48410);function h({input:f,options:a,onChange:n}){const u=(0,D.q)(f),v=(0,T.useCallback)((r,o)=>{const l=o?.value!==void 0?o.value:"";n({...a,[r]:{...a[r],timeField:l}})},[n,a]),I=(0,T.useCallback)((r,o)=>{const l=o[0];l&&(0,E.Em)(l)&&n({...a,[r]:{...a[r],stat:l}})},[n,a]);let s=[];for(const r of Object.keys(u)){const o={},l=[];for(const i of f)if(i.refId===r)for(const e of i.fields)(0,O.hF)(e)&&(o[e.name]=e);for(const i of Object.values(o)){const{name:e}=i;l.push({label:e,value:e})}s.push((0,d.jsxs)(C.C,{children:[(0,d.jsx)(c.I,{children:(0,d.jsx)(M.c,{children:`Trend #${r}`})}),(0,d.jsx)(c.I,{label:(0,m.t)("transformers.time-series-table-transform-editor.label-time-field","Time field"),tooltip:(0,m.t)("transformers.time-series-table-transform-editor.tooltip-time-field","The time field that will be used for the time series. If not selected the first found will be used."),children:(0,d.jsx)(A.l6,{onChange:v.bind(null,r),options:l,value:a[r]?.timeField,isClearable:!0})}),(0,d.jsx)(c.I,{label:(0,m.t)("transformers.time-series-table-transform-editor.label-stat","Stat"),tooltip:(0,m.t)("transformers.time-series-table-transform-editor.tooltip-statistic-should-calculated-series","The statistic that should be calculated for this time series."),children:(0,d.jsx)(b.S,{stats:[a[r]?.stat??E.gy.lastNotNull],onChange:I.bind(null,r),filterOptions:i=>i.id!==E.gy.allValues&&i.id!==E.gy.uniqueValues})})]},r))}return(0,d.jsx)(d.Fragment,{children:s})}},48410(F,g,t){t.d(g,{getTimeSeriesTableTransformer:()=>C,q:()=>h});var d=t(81160),T=t(43866),O=t(69839),E=t(19560),m=t(76529),b=t(26384),c=t(17727),M=t(52358);const C=()=>({id:E.F.timeSeriesTable,name:(0,M.t)("transformers.time-series-table.name.time-series-to-table","Time series to table"),description:(0,M.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:f=>{for(const a of f)if((0,O.aH)(a))return b.M.Applicable;return b.M.NotApplicable},isApplicableDescription:(0,M.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:f=>a=>a.pipe((0,d.T)(n=>A(f,n)))});function A(f,a){const n={},u={},v=[];let I=h(a);for(const s of Object.keys(I)){const r=a.filter(l=>l.refId===s);n[s]={},u[s]={};const o=[];r.forEach(l=>{l.fields.forEach(i=>{i.type===c.PU.number&&i.labels&&Object.keys(i.labels).forEach(e=>{o.includes(e)||(u[s][e]=D(e,c.PU.string),o.push(e))})})});for(let l=0;l<r.length;l++){const i=r[l];let e=null,P=f[s]?.timeField;if(P&&P.length>0?e=i.fields.find(_=>_.name===P):e=i.fields.find(_=>(0,O.hF)(_)),!(0,O.aH)(i)){v.push(i);continue}for(const _ of i.fields){if(_.type!==c.PU.number)continue;const R=f[s]?.stat??m.gy.lastNotNull,K=(0,m.Nw)({field:_,reducers:[R]})[R]??null,U=new T.k;e!==void 0&&(U.addField(e),U.addField(_),n[s][`Trend #${s}`]===void 0&&(n[s][`Trend #${s}`]=D(`Trend #${s}`,c.PU.frame)),n[s][`Trend #${s}`].values.push({...U,value:K,length:_.values.length})),o.forEach(B=>{u[s][B].values.push(_.labels?.[B]??"")})}}}for(const s of Object.keys(I)){const r={},o=new T.k;o.refId=s;const l=u[s];if(l!==void 0)for(const[e,P]of Object.entries(l))r[e]===void 0&&(r[e]=P);for(const e of Object.values(r))o.addField(e);const i=n[s];for(const e of Object.values(i))o.addField(e);o.fields.length>0&&v.push(o)}return v}function D(f,a){return{name:f,type:a,config:{},values:[]}}function h(f){let a={};for(const n of f)n.refId!==void 0&&(a[n.refId]===void 0?a[n.refId]=1:a[n.refId]++);return a}}}]);

//# sourceMappingURL=5076-react19.3b392f0e62b5b9d6612c.js.map