const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ChartSettings-1.0.74-whS3H1C5.js","./RestApiError-1.0.74-Bb1un17k.js","./vendor-1.0.74-CN03Eozo.js","./tanstack-1.0.74-aU0azVkW.js","./redux-1.0.74-D8bIc6ki.js","./lib-1.0.74-B5IEqfHg.js","./utils-1.0.74-7xWhx9mc.js","./Tooltip-1.0.74-Bsfqgjy3.js","./Tooltip-1.0.74--D4jr2go.css","./settings-1.0.74-BnRB9SOY.js","./iconBase-1.0.74-Cs0vntJu.js","./CircularProgress-1.0.74-QfwfRJ7i.js","./ButtonBase-1.0.74-W6tAH7AI.js","./Typography-1.0.74-B4mhsevh.js","./useEnhancedEffect-1.0.74-B56M26dS.js","./index-1.0.74-DxwH6OqZ.js","./ThemeProvider-1.0.74-4uzbYYLM.js","./Portal-1.0.74-BrUPeMX9.js","./Link-1.0.74-Cr-Ob-AP.js","./index-1.0.74-CCIRxPEn.js","./index-1.0.74-DtMr5-xA.js","./ConfirmDialog-1.0.74-CXu4CqK2.js","./AdminTheme-1.0.74-BtTaJUu_.js","./Modal-1.0.74-BfLid1bk.js","./Box-1.0.74-DEbuVvGV.js","./Menu-1.0.74-CdjCBJ4R.js","./isHostComponent-1.0.74-DVu5iVWx.js","./CardHeader-1.0.74-CHbhRPw-.js","./TextField-1.0.74-BW9Byijb.js","./Select-1.0.74-DHOnlEEH.js","./createSvgIcon-1.0.74-Cw_ZFbxi.js","./InputAdornment-1.0.74-DzikPcDx.js","./CardActions-1.0.74-DRn8SDKF.js","./MenuItem-1.0.74-D9LDbFUb.js","./settings-1.0.74-9cL4xzrg.css","./hooks-1.0.74-NYCTWeI9.js","./DynamicModeEnum-1.0.74-BXuL5kgA.js","./ActionsSettings-1.0.74-C1yaah3Y.js","./RestApi-1.0.74-5XKxNzpR.js","./TargetEnum-1.0.74-BJN_W527.js","./Spinner-1.0.74-B63QTBL9.js","./index-1.0.74-C9JunOsO.js","./TabPanel-1.0.74-BfVdq8Gf.js","./useThemeProps-1.0.74-eOKEtzB-.js","./getThemeProps-1.0.74-DOfDN6_V.js"])))=>i.map(i=>d[i]);
import{_ as X}from"./RestApiError-1.0.74-Bb1un17k.js";import{j as n}from"./tanstack-1.0.74-aU0azVkW.js";import{r as s}from"./redux-1.0.74-D8bIc6ki.js";import{u as Z,C as $}from"./Chart-1.0.74-BOylOstd.js";import{a as H}from"./hooks-1.0.74-NYCTWeI9.js";import{l,s as K,T as Q,X as W,C as I,Y as D,x as ee,G as te,Z as re,_ as ie,$ as se}from"./lib-1.0.74-B5IEqfHg.js";import{R as oe}from"./RestApi-1.0.74-5XKxNzpR.js";import{A as ae,u as ne}from"./useTheme-1.0.74-CW3awVDs.js";import{a as pe}from"./AdminTheme-1.0.74-BtTaJUu_.js";import{u as ce}from"./useMetadata-1.0.74--jxfVI7W.js";import{T as Y}from"./ThemeProvider-1.0.74-4uzbYYLM.js";import"./vendor-1.0.74-CN03Eozo.js";import"./useChartSettings-1.0.74-C6-5LBxk.js";import"./Languages-1.0.74-DaJcF5OJ.js";import"./useLocaleMrt-1.0.74-BUIBUKA0.js";import"./useLocaleUd-1.0.74-DiRzsyAi.js";import"./utils-1.0.74-7xWhx9mc.js";import"./Box-1.0.74-DEbuVvGV.js";import"./CircularProgress-1.0.74-QfwfRJ7i.js";import"./Typography-1.0.74-B4mhsevh.js";import"./index-1.0.74-DxwH6OqZ.js";import"./ButtonBase-1.0.74-W6tAH7AI.js";import"./useEnhancedEffect-1.0.74-B56M26dS.js";import"./Portal-1.0.74-BrUPeMX9.js";import"./iconBase-1.0.74-Cs0vntJu.js";import"./useLocaleApp-1.0.74-BAnA1P2j.js";import"./useRemoveAppFromStore-1.0.74-CJatuZ_l.js";import"./useFullScreen-1.0.74-DAWjksdW.js";import"./index-1.0.74-iJ_9eGZx.js";import"./getThemeProps-1.0.74-DOfDN6_V.js";const me=s.lazy(()=>X(()=>import("./ChartSettings-1.0.74-whS3H1C5.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44]),import.meta.url)),Ue=({appId:i,appDbId:_,shortcodeArgs:k})=>{l.debug(i,_);const b=H(),x=s.useRef(!0);x.current&&K(i,500),s.useEffect(()=>{x.current=!1},[]);const[v,d]=s.useState(!1),e=ce(i),B=ne(),F=ae(B,ee.table,D.form),U=s.useMemo(()=>pe(),[]),q=Z(i),f=o=>{switch(o.indexOf("(")>0?o.substring(0,o.indexOf("(")).toLowerCase():o){case"decimal":case"double":case"double precision":case"float":case"real":case"bit":case"tinyint":case"smallint":case"int":case"integer":case"mediumint":case"bigint":return"number";case"time":return"time";case"date":return"date";case"datetime":case"timestamp":return"datetime"}return"text"},z=()=>{var o,g;oe(I.appUrlChartData,{app_id:_,search_custom:W((g=(o=e==null?void 0:e.app)==null?void 0:o.container[0])==null?void 0:g.cnt_query),shortcode_params:k},a=>{var S,C,E,A,j,O,P,R,N,w,J,L;if(l.debug(a),(a==null?void 0:a.data)!==void 0){if(Array.isArray(a.data)){const c=a.data,h=[];a.explain.map(t=>{t.Type?h.push(f(t.Type)):t.type?h.push(f(t.type)):t.TYPE&&h.push(f(t.TYPE))});const p=[],M=[];Object.keys(c[0]).map(t=>M.push(t)),p.push(M);for(let t=0;t<c.length;t++){const T=[];Object.keys(c[t]).map((V,G)=>h[G]==="text"?T.push(c[t][V]):T.push(Number(c[t][V]))),p.push(T)}l.debug(p);let r={};if(((C=(S=e==null?void 0:e.app)==null?void 0:S.container[0])==null?void 0:C.cnt_chart)!==void 0&&((A=(E=e==null?void 0:e.app)==null?void 0:E.container[0])==null?void 0:A.cnt_chart)!==null&&((O=(j=e==null?void 0:e.app)==null?void 0:j.container[0])==null?void 0:O.cnt_chart)!=="")try{r=JSON.parse(e.app.container[0].cnt_chart)}catch(t){console.error("Invalid JSON - chart settings"),console.error(t)}r===!1&&(r={}),l.debug(r);const m=te({},re,r);m.data=p,m.majorAxisColumn=p[0][0],m.minorAxisColumns=p[0].slice(1),Array.isArray(r==null?void 0:r.chartTypes)&&r.chartTypes.length>0&&(m.chartType=r.chartTypes[0]),b(ie({appId:i,chartState:m}));let u={};if(((R=(P=e==null?void 0:e.app)==null?void 0:P.app[0])==null?void 0:R.app_theme)!==void 0&&((w=(N=e==null?void 0:e.app)==null?void 0:N.app[0])==null?void 0:w.app_theme)!==null&&((L=(J=e==null?void 0:e.app)==null?void 0:J.app[0])==null?void 0:L.app_theme)!=="")try{u=JSON.parse(e.app.app[0].app_theme)}catch(t){console.error("Invalid JSON - theme settings"),console.error(t)}u===!1&&(u={}),l.debug(u),b(se({appId:i,themeState:u})),d(!0)}}else console.error("Error loading chart data"),d(!0)},()=>{console.error("Error loading chart data"),d(!0)})};s.useEffect(()=>{z()},[]);const y=s.useMemo(()=>Q(e),[e]);return v?n.jsxs(n.Fragment,{children:[n.jsx(Y,{theme:F,children:n.jsx($,{appId:i,isBuilderEnabled:y,isToolbarEnabled:!0,isExploring:(e==null?void 0:e.isExploring)===!0})}),y&&q&&n.jsx(Y,{theme:U,children:n.jsx(s.Suspense,{children:n.jsx(me,{appId:i})})})]}):null};export{Ue as default};
