"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const i=require("react/jsx-runtime"),D=require("react"),x=require("semantic-ui-react"),E=require("../data/DataProvider.js"),O=require("../data/DataConsumer.js"),U=require("@devgateway/wp-react-lib"),A=require("react-redux"),L=p=>{const{editing:r=!1,unique:n,intl:a,childContent:t,"data-csv":c="","data-no-data-message":l="No data matches your selection","data-view-mode":e="info","data-height":s,"data-dimension1":d,"data-app":m,"data-measures":N={},"data-format":M="{}","data-group":C,"data-filters":q=[],"data-value-type":F}=p,R=a.locale,S=D.useRef(null),P=o=>r?o:decodeURIComponent(o),h=o=>{try{return JSON.parse(P(o))}catch{console.error("error parsing value:"+o)}return null},u=h(M),w=u?{style:u.style==="compacted"?"decimal":u.style,notation:u.style==="compacted"?"compact":"standard",currency:u.currency,minimumFractionDigits:parseInt(u.minimumFractionDigits),maximumFractionDigits:parseInt(u.maximumFractionDigits)}:{notation:"standard",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2},[I,k]=D.useState(e),T=r?e:I,g=r?s-80:s-40,j={},y=h(q)||{};y&&y.forEach&&y.forEach(o=>{o.value!=null&&o.value.filter(b=>b!=null&&b.toString().trim()!="").length>0&&(j[o.param]=o.value)});let v=!1;const f=[];return d!="none"&&f.push(d),m!="csv"&&(!f.length||!h(N)[0])&&(v=!0),i.jsx("div",{ref:S,children:i.jsxs(x.Container,{className:"chart container data-label",style:{height:s+"px"},fluid:!0,children:[i.jsx(E.default,{style:{height:`${g}px`},params:j,app:m,group:C,csv:c,editing:r,store:[m,n,...f],source:f.join("/"),children:i.jsx(x.Container,{style:{height:`${g}px`},className:"body data-label-body",fluid:!0,children:!v&&i.jsx(O.default,{children:i.jsx(_,{locale:R,dimensions:[...f],valueType:F,intl:a,app:m,format:w,measure:h(N)[0]||null})})})}),i.jsx("br",{}),t&&T=="info"&&i.jsx(x.Container,{fluid:!0,style:{height:g+"px"},className:"body data-label-body",children:i.jsx(U.PostContent,{post:{content:{rendered:t}}})})]})})},_=p=>{const{valueType:r,measure:n,data:a,format:t,intl:c}=p;let l="N/A";if(r==="first"){const e=a.children[0][n];l=c.formatNumber(t.style==="percent"?e/100:e,{...t})}else if(r==="total"){const e=a[n];l=c.formatNumber(t.style==="percent"?e/100:e,{...t})}else if(r==="min"&&!isNaN(a[n])){const e=Math.min(...a.children.map(s=>s[n]));l=c.formatNumber(t.style==="percent"?e/100:e,{...t})}else if(r==="max"&&!isNaN(a[n])){const e=Math.max(...a.children.map(s=>s[n]));l=c.formatNumber(t.style==="percent"?e/100:e,{...t})}else if(r==="avg"&&!isNaN(a[n])){const e=a.children.map(d=>d[n]),s=e.reduce((d,m)=>d+m,0)/e.length;l=c.formatNumber(t.style==="percent"?s/100:s,{...t})}return i.jsx("div",{children:l})},$=(p,r)=>{const{"data-app":n,"data-group":a}=r,t=p.getIn(["data","measures",n,a]);return t?{injectedMeasures:t}:{}},H={},J=A.connect($,H)(L);exports.default=J;
