import{a}from"./machine.-tangy-colts-beg-869.js";import{aR as i}from"./main-tangy-colts-beg.js";globalThis.jotaiAtomCache=globalThis.jotaiAtomCache||{cache:new Map,get(e,o){return this.cache.has(e)?this.cache.get(e):(this.cache.set(e,o),o)}};const n=()=>i("pro_mailpoet/get",void 0,void 0,"GET"),l=()=>i("pro_mailpoet/get_lists"),c=()=>i("pro_mailpoet/get_subscriber_fields",void 0,void 0,"GET");globalThis.jotaiAtomCache=globalThis.jotaiAtomCache||{cache:new Map,get(e,o){return this.cache.has(e)?this.cache.get(e):(this.cache.set(e,o),o)}};const f=async e=>{e.setComponent("form-id",t=>{t.loading=!0});const{data:o,status:s}=await n();if(s==="error"){e.setComponent("form-id",t=>{e.util.isSelectComponent(t)&&(t.status=s,t.loading=!1,t.invalidMessage=o)}),console.error("Failed to fetch form");return}e.setComponent("form-id",t=>{e.util.isSelectComponent(t)&&(t.options=o,t.loading=!1,t.status=void 0)})},m=async e=>{e.setComponent("lists",t=>{t.loading=!0});const{data:o,status:s}=await l();if(s==="error"){e.setComponent("lists",t=>{e.util.isSelectComponent(t)&&(t.status=s,t.loading=!1,t.invalidMessage=JSON.stringify(o))}),console.error("Failed to fetch post types");return}e.setComponent("lists",t=>{e.util.isSelectComponent(t)&&(t.options=o,t.loading=!1,t.status=void 0)})},u=async e=>{e.setComponent("field-map",s=>{s.loading=!0});const{data:o}=await c();e.setComponent("field-map",s=>{if(!e.util.isRepeaterFieldComponent(s))return;const t=s.fieldsMetaData[0];t.options=o,s.loading=!1}),a({$:e,componentId:"field-map",dbKey:"fieldMap",fields:o,mapFieldKey:"mailPoetField",mapFieldValue:"value"})};export{u as a,f as b,m as f};
