import{j as t}from"./tanstack-1.0.74-aU0azVkW.js";import{r as p}from"./redux-1.0.74-D8bIc6ki.js";import{S as j}from"./SanitizeComponent-1.0.74-DsOvasd7.js";import{M as v,aa as C}from"./index-1.0.74-DxwH6OqZ.js";import{l as S}from"./lib-1.0.74-B5IEqfHg.js";import{u as w}from"./useChartType-1.0.74-DpywGUvE.js";import{M as T}from"./Modal-1.0.74-BfLid1bk.js";import{B as l}from"./Box-1.0.74-DEbuVvGV.js";import{I as x}from"./iconBase-1.0.74-Cs0vntJu.js";import{S as M}from"./Slider-1.0.74-BxpDcEEP.js";import"./vendor-1.0.74-CN03Eozo.js";import"./utils-1.0.74-7xWhx9mc.js";import"./CircularProgress-1.0.74-QfwfRJ7i.js";import"./ButtonBase-1.0.74-W6tAH7AI.js";import"./Typography-1.0.74-B4mhsevh.js";import"./useEnhancedEffect-1.0.74-B56M26dS.js";import"./ThemeProvider-1.0.74-4uzbYYLM.js";import"./Portal-1.0.74-BrUPeMX9.js";import"./hooks-1.0.74-NYCTWeI9.js";import"./visuallyHidden-1.0.74-Dan1xhjv.js";import"./isHostComponent-1.0.74-DVu5iVWx.js";const Y=({appId:o,getChartImageURI:g,printChart:f,setPrintChart:s})=>{var m,u,d,h;const a=w(o),c=p.useRef(null),i=()=>window.document.querySelector(`#pp-chart-${o} .pp-chart-google-container svg`),[n,q]=p.useState(((m=i())==null?void 0:m.clientWidth)??0),b=()=>{var r;const e=window.open("","print");e==null||e.document.write("<html><head><title>"+document.title+"</title>"),e==null||e.document.write("</head><body >"),e==null||e.document.write("<h1>"+document.title+"</h1>"),e==null||e.document.write(((r=c.current)==null?void 0:r.innerHTML)??""),e==null||e.document.write("</body></html>"),e==null||e.document.close(),e==null||e.focus(),setTimeout(()=>{e==null||e.print(),e==null||e.close()},400)},y=()=>{const e=window.document.querySelector(`#pp-chart-${o} div div`);if(e===null)return null;const r=e==null?void 0:e.cloneNode(!0);return r&&r.removeAttribute("id"),t.jsx(l,{className:"pp-chart-print-container",children:t.jsx(j,{html:r.innerHTML})})};return a==="Gauge"||a==="Table"?null:t.jsx(T,{open:f,onClose:()=>s(!1),"aria-labelledby":"modal-modal-title","aria-describedby":"modal-modal-description",children:t.jsx(l,{sx:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",bgcolor:"background.paper",border:"1px solid #eee",boxShadow:24,p:4,borderRadius:"4px",width:window.document.querySelectorAll(`#pp-chart-${o} svg`)!==null?(u=i())==null?void 0:u.clientWidth:"auto",height:window.document.querySelectorAll(`#pp-chart-${o} svg`)!==null?(((d=i())==null?void 0:d.clientHeight)??0)+70:"auto"},children:t.jsxs(l,{sx:{position:"relative",display:"grid",gridTemplateRows:"1fr",height:"-webkit-fill-available"},children:[t.jsx(x,{color:"primary",onClick:()=>{s(!1)},sx:{position:"absolute",right:0},children:t.jsx(v,{})}),t.jsxs(l,{sx:{display:"grid",gridTemplateRows:window.document.querySelectorAll(`#pp-chart-${o} svg`).length===1?"1fr 60px":"1fr 40px",height:"-webkit-fill-available"},children:[t.jsx(l,{ref:c,sx:{alignSelf:"center",textAlign:"center"},children:window.document.querySelectorAll(`#pp-chart-${o} svg`)!==null?t.jsx("img",{src:g(),style:{width:n}}):y()}),t.jsxs(l,{sx:{display:"grid",gridTemplateColumns:"1fr auto",justifyContent:"space-between",alignItems:"center"},children:[t.jsx(l,{children:i()!==null&&t.jsx(M,{value:n,min:1,max:(h=i())==null?void 0:h.clientWidth,step:1,valueLabelDisplay:"on",disabled:!0,onChange:(e,r)=>{S.debug(e,r)},sx:{width:"calc(100% - 40px)",margin:"20px"}})}),t.jsx(x,{color:"primary",onClick:()=>{b()},children:t.jsx(C,{})})]})]})]})})})};export{Y as default};
