var _=Object.defineProperty;var n=Object.getOwnPropertySymbols;var m=Object.prototype.hasOwnProperty,k=Object.prototype.propertyIsEnumerable;var d=(e,r,s)=>r in e?_(e,r,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[r]=s,o=(e,r)=>{for(var s in r||(r={}))m.call(r,s)&&d(e,s,r[s]);if(n)for(var s of n(r))k.call(r,s)&&d(e,s,r[s]);return e};import{_ as l,c as h,z as u}from"./main-343.js";const y=(e,r,s)=>{const a=o({},r),{name:t}=e.target;e.target.value!==""?a[t]=e.target.value:delete a[t],s(o({},a))},z=e=>{const r=e==null?void 0:e.mailerLiteFields.filter(s=>s.required===!0);return r.length>0?r.map(s=>({formField:"",mailerLiteFormField:s.key})):[{formField:"",mailerLiteFormField:""}]},b=e=>!((e!=null&&e.field_map?e.field_map.filter(s=>!s.formField||!s.mailerLiteFormField||!s.formField==="custom"&&!s.customValue):[]).length>0),g=(e,r,s,a,t,i)=>{if(!e.auth_token){s({auth_token:e.auth_token?"":l("Api Key can't be empty")});return}s({}),t(!0);const F={auth_token:e.auth_token,version:e.version};h(F,"bitforms_mailerlite_refresh_fields").then(c=>{if(c&&c.success){const f=o({},e);c.data&&(f.mailerLiteFields=c.data),r(f),i==="authorization"?(t(!1),a(!0),u.success(l("Authorized successfully"))):(t(!1),u.success(l("Fields refresh successfully")));return}i==="authorization"?(t(!1),a(!1),u.error(l(c.data)),u.error(l("Authorized Failed"))):(t(!1),u.error(l("Fields refresh failed")))})},q=(e,r,s)=>{s(!0);const a={auth_token:e.auth_token,version:e.version};h(a,"bitforms_mailerlite_fetch_all_groups").then(t=>{if(t&&t.success){const i=o({},e);t.data&&(i.groups=t.data),r(i),s(!1),u.success(l("Group fetch successfully"));return}s(!1),u.error(l("Group fetch failed"))})};export{z as a,b as c,q as g,y as h,g as m};
