import{b1 as h,l as n,a0 as C,S,a1 as y,C as _,b2 as M,b3 as j,b4 as A,a as T,b5 as U}from"./lib-1.0.63-DJZPtMem.js";import{R as O}from"./RestApi-1.0.63-BUfzocgq.js";import{T as u}from"./TargetEnum-1.0.63-CIW1jlU5.js";const v=(t,r,i,c,e,s,a,o=!1)=>{n.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)},D=(t,r,i,c,e,s,a,o,g,l=!1)=>{const b={app_id:t,cnt_id:r,target:i,settings:JSON.stringify(c),theme:JSON.stringify(a)};e!==void 0&&(b.chart=JSON.stringify(e)),s!==void 0&&(b.map=JSON.stringify(s)),O(_.appUrlAppSettings,b,o,g,l)},x=(t,r,i,c,e=!1)=>{var g,l,b,I,J,N;const s=h(t);n.debug(s);const{state:a,...o}=j.getSelectors().selectTableById(S.getState().tables,t);if(n.debug(a,o),s.app_id){let d={...C.getSelectors().selectChart(S.getState().charts,t)};if(Object.keys(d).length===0){const f=A.getSelectors().selectMetaDataById(S.getState().metaData,t);try{const m=JSON.parse((b=(l=(g=f==null?void 0:f.app)==null?void 0:g.container)==null?void 0:l[0])==null?void 0:b.cnt_chart);Object.keys(m).length===0?d=void 0:d={...m}}catch{d=void 0}}else delete d.data;n.debug(d);let p={...M.getSelectors().selectMap(S.getState().maps,t)};if(Object.keys(p).length===0){const f=A.getSelectors().selectMetaDataById(S.getState().metaData,t);try{const m=JSON.parse((N=(J=(I=f==null?void 0:f.app)==null?void 0:I.container)==null?void 0:J[0])==null?void 0:N.cnt_map);Object.keys(m).length===0?p=void 0:p={...m}}catch{p=void 0}}else p==null||delete p.state;n.debug(p);const{...B}=y.getSelectors().selectThemeById(S.getState().themes,t);n.debug(B),D(s.app_id,s.cnt_id,u.TABLE,o,d,p,B,i,c,e)}else s.dbs.trim()!==""&&s.tbl.trim()!==""?v(r,u.TABLE,s.dbs,s.tbl,o,i,c,e):(console.error("error","Missing data source"),c(T.contactSupport))},H=(t,r,i,c,e,s=!1)=>{const a=h(t);n.debug(a);const{state:o,...g}=U.getSelectors().selectForm(S.getState().forms,t);if(n.debug(o,g),a.app_id){const{...l}=y.getSelectors().selectThemeById(S.getState().themes,t);n.debug(l),D(a.app_id,a.cnt_id,i,g,void 0,void 0,l,c,e,s)}else a.dbs.trim()!==""&&a.tbl.trim()!==""?v(r,i,a.dbs,a.tbl,g,c,e,s):(console.error("error","Missing data source"),e(T.contactSupport))},P=(t,r,i,c=!1)=>{const e=h(t);n.debug(e,t);const s=e.app_id,a=e.cnt_id,o=C.getSelectors().selectChart(S.getState().charts,t);n.debug(o);const{...g}=y.getSelectors().selectThemeById(S.getState().themes,t);n.debug(g),O(_.appUrlAppSettings,{app_id:s,cnt_id:a,target:u.CHART,settings:JSON.stringify(o),theme:JSON.stringify(g)},r,i,c)},k=(t,r,i,c=!1)=>{const e=h(t);n.debug(e,t);const s=e.app_id,a=e.cnt_id,{state:o,...g}=M.getSelectors().selectMap(S.getState().maps,t);n.debug(g);const{...l}=y.getSelectors().selectThemeById(S.getState().themes,t);n.debug(l),O(_.appUrlAppSettings,{app_id:s,cnt_id:a,target:u.MAP,settings:JSON.stringify(g),theme:JSON.stringify(l)},r,i,c)};export{P as a,k as b,v as c,x as d,H as e,D as s};
