import{a as i}from"./machine.-tangy-colts-beg-869.js";import{aR as a}from"./main-tangy-colts-beg.js";globalThis.jotaiAtomCache=globalThis.jotaiAtomCache||{cache:new Map,get(e,s){return this.cache.has(e)?this.cache.get(e):(this.cache.set(e,s),s)}};const n=()=>a("pro_fluent-crm/tags",void 0,void 0,"GET"),l=()=>a("pro_fluent-crm/lists",void 0,void 0,"GET"),c=()=>a("pro_fluent-crm/status",void 0,void 0,"GET"),d=()=>a("pro_fluent-crm/companies",void 0,void 0,"GET"),m=()=>a("pro_fluent-crm/contact-fields",void 0,void 0,"GET"),u=()=>a("pro_fluent-crm/contact-custom-fields",void 0,void 0,"GET"),f=()=>a("pro_fluent-crm/company-fields",void 0,void 0,"GET"),r=()=>a("pro_fluent-crm/company-custom-fields",void 0,void 0,"GET");globalThis.jotaiAtomCache=globalThis.jotaiAtomCache||{cache:new Map,get(e,s){return this.cache.has(e)?this.cache.get(e):(this.cache.set(e,s),s)}};const g=async e=>{e.setComponent("tag-id",t=>{t.loading=!0});const{data:s,status:o}=await n();if(o==="error"){e.setComponent("tag-id",t=>{e.util.isSelectComponent(t)&&(t.status=o,t.loading=!1,t.invalidMessage=s)}),console.error("Failed to fetch tag");return}e.setComponent("tag-id",t=>{e.util.isSelectComponent(t)&&(t.options=s,t.loading=!1,t.status=void 0)})},h=async e=>{e.setComponent("list-id",t=>{t.loading=!0});const{data:s,status:o}=await l();if(o==="error"){e.setComponent("list-id",t=>{e.util.isSelectComponent(t)&&(t.status=o,t.loading=!1,t.invalidMessage=s)}),console.error("Failed to fetch list");return}e.setComponent("list-id",t=>{e.util.isSelectComponent(t)&&(t.options=s,t.loading=!1,t.status=void 0)})},F=async e=>{e.setComponent("status-id",t=>{t.loading=!0});const{data:s,status:o}=await c();if(o==="error"){e.setComponent("status-id",t=>{e.util.isSelectComponent(t)&&(t.status=o,t.loading=!1,t.invalidMessage=s)}),console.error("Failed to fetch status");return}e.setComponent("status-id",t=>{e.util.isSelectComponent(t)&&(t.options=s,t.loading=!1,t.status=void 0)})},y=async e=>{e.setComponent("company-id",t=>{t.loading=!0});const{data:s,status:o}=await d();if(o==="error"){e.setComponent("company-id",t=>{e.util.isSelectComponent(t)&&(t.status=o,t.loading=!1,t.invalidMessage=s)}),console.error("Failed to fetch company");return}e.setComponent("company-id",t=>{e.util.isSelectComponent(t)&&(t.options=s,t.loading=!1,t.status=void 0)})},M=async e=>{e.setComponent("field-map",o=>{o.loading=!0});const{data:s}=await m();e.setComponent("field-map",o=>{if(!e.util.isRepeaterFieldComponent(o))return;const t=o.fieldsMetaData[0];t.options=s,o.loading=!1}),i({$:e,componentId:"field-map",dbKey:"fieldMap",fields:s,mapFieldKey:"fluentCrmField",mapFieldValue:"value"})},T=async e=>{e.setComponent("custom-field-map",o=>{o.loading=!0});const{data:s}=await u();e.setComponent("custom-field-map",o=>{if(!e.util.isRepeaterFieldComponent(o))return;const t=o.fieldsMetaData[0];t.options=s,o.loading=!1})},w=async e=>{e.setComponent("field-map",o=>{o.loading=!0});const{data:s}=await f();e.setComponent("field-map",o=>{if(!e.util.isRepeaterFieldComponent(o))return;const t=o.fieldsMetaData[0];t.options=s,o.loading=!1}),i({$:e,componentId:"field-map",dbKey:"fieldMap",fields:s,mapFieldKey:"fluentCrmField",mapFieldValue:"value"})},S=async e=>{e.setComponent("custom-field-map",o=>{o.loading=!0});const{data:s}=await r();e.setComponent("custom-field-map",o=>{if(!e.util.isRepeaterFieldComponent(o))return;const t=o.fieldsMetaData[0];t.options=s,o.loading=!1})};export{h as a,y as b,w as c,S as d,M as e,g as f,T as g,F as h};
