import{bA as u,l as g,bB as D,S,ag as y,C as _,a8 as j,bC as C,aj as U,az as N,b as T,aq as R}from"./lib-1.0.74-B5IEqfHg.js";import{R as O}from"./RestApi-1.0.74-5XKxNzpR.js";import{T as h}from"./TargetEnum-1.0.74-BJN_W527.js";const M=(t,r,i,c,e,s,a,o=!1)=>{g.debug(t,r,i,c,e),O(_.appUrlSettings,{action:"admin_settings",dbs:i,tbl:c,settings:JSON.stringify({scope:t,target:r,data:e})},s,a,o)},v=(t,r,i,c,e,s,a,o,n,p=!1)=>{const m={app_id:t,cnt_id:r,target:i,settings:JSON.stringify(c),theme:JSON.stringify(a)};e!==void 0&&(m.chart=JSON.stringify(e)),s!==void 0&&(m.map=JSON.stringify(s)),O(_.appUrlAppSettings,m,o,n,p)},q=(t,r,i,c,e=!1)=>{var n,p,m,I,B,A;const s=u(t);g.debug(s);const{state:a,...o}=U.getSelectors().selectTableById(S.getState().tables,t);if(g.debug(a,o),s.app_id){let l={...D.getSelectors().selectChart(S.getState().charts,t)};if(Object.keys(l).length===0){const b=N.getSelectors().selectMetaDataById(S.getState().metaData,t);try{const f=JSON.parse((m=(p=(n=b==null?void 0:b.app)==null?void 0:n.container)==null?void 0:p[0])==null?void 0:m.cnt_chart);Object.keys(f).length===0?l=void 0:l={...f}}catch{l=void 0}}else delete l.data;g.debug(l);let d={...C.getSelectors().selectMap(S.getState().maps,t)};if(Object.keys(d).length===0){const b=N.getSelectors().selectMetaDataById(S.getState().metaData,t);try{const f=JSON.parse((A=(B=(I=b==null?void 0:b.app)==null?void 0:I.container)==null?void 0:B[0])==null?void 0:A.cnt_map);Object.keys(f).length===0?d=void 0:d={...f}}catch{d=void 0}}else d==null||delete d.state;g.debug(d);const{...J}=y.getSelectors().selectThemeById(S.getState().themes,t);g.debug(J),v(s.app_id,s.cnt_id,h.TABLE,o,l,d,J,i,c,e)}else s.dbs.trim()!==""&&s.tbl.trim()!==""?M(r,h.TABLE,s.dbs,s.tbl,o,i,c,e):(console.error("error","Missing data source"),c(T.contactSupport))},x=(t,r,i,c,e,s=!1)=>{const a=u(t);g.debug(a);const{state:o,...n}=R.getSelectors().selectForm(S.getState().forms,t);if(g.debug(o,n),a.app_id){const{...p}=y.getSelectors().selectThemeById(S.getState().themes,t);g.debug(p),v(a.app_id,a.cnt_id,i,n,void 0,void 0,p,c,e,s)}else a.dbs.trim()!==""&&a.tbl.trim()!==""?M(r,i,a.dbs,a.tbl,n,c,e,s):(console.error("error","Missing data source"),e(T.contactSupport))},z=(t,r,i,c=!1)=>{const e=u(t);g.debug(e,t);const s=e.app_id,a=e.cnt_id,o=D.getSelectors().selectChart(S.getState().charts,t);g.debug(o);const{...n}=y.getSelectors().selectThemeById(S.getState().themes,t);g.debug(n),O(_.appUrlAppSettings,{app_id:s,cnt_id:a,target:h.CHART,settings:JSON.stringify(o),theme:JSON.stringify(n)},r,i,c)},P=(t,r,i,c=!1)=>{const e=u(t);g.debug(e,t);const s=e.app_id,a=e.cnt_id,{state:o,...n}=C.getSelectors().selectMap(S.getState().maps,t);g.debug(n);const{...p}=y.getSelectors().selectThemeById(S.getState().themes,t);g.debug(p),O(_.appUrlAppSettings,{app_id:s,cnt_id:a,target:h.MAP,settings:JSON.stringify(n),theme:JSON.stringify(p)},r,i,c)},k=(t,r,i,c=!1)=>{const e=u(t);g.debug(e,t);const s=e.app_id,a=e.cnt_id,o=j.getSelectors().selectDashboardById(S.getState().dashboards,t),{...n}=y.getSelectors().selectThemeById(S.getState().themes,t);g.debug(n),O(_.appUrlAppSettings,{app_id:s,cnt_id:a,target:h.DASHBOARD,settings:JSON.stringify(o),theme:JSON.stringify(n)},r,i,c)};export{v as a,z as b,P as c,M as d,q as e,x as f,k as s};
