var K=Object.defineProperty,b=Object.defineProperties;var _=Object.getOwnPropertyDescriptors;var y=Object.getOwnPropertySymbols;var p=Object.prototype.hasOwnProperty,A=Object.prototype.propertyIsEnumerable;var F=(e,s,t)=>s in e?K(e,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[s]=t,r=(e,s)=>{for(var t in s||(s={}))p.call(s,t)&&F(e,t,s[t]);if(y)for(var t of y(s))A.call(s,t)&&F(e,t,s[t]);return e},c=(e,s)=>b(e,_(s));import{_ as u,b as m,c as n,A as k}from"./bi.636.93.js";const v=(e,s,t)=>{const f=k(s,i=>{const{name:a}=e.target;e.target.value!==""?i[a]=e.target.value:delete i[a]});t(f)},z=e=>{const s=e==null?void 0:e.staticFields.filter(t=>t.required===!0);return s.length>0?s.map(t=>({formField:"",mailjetFormField:t.key})):[{formField:"",mailjetFormField:""}]},I=e=>!((e!=null&&e.field_map?e.field_map.filter(t=>!t.formField||!t.mailjetFormField||!t.formField==="custom"&&!t.customValue):[]).length>0),M=(e,s,t,f,i,a,h)=>{if(!e.apiKey){t({apiKey:e.apiKey?"":u("API key can't be empty","bit-integrations")});return}if(!e.secretKey){t({secretKey:e.secretKey?"":u("Secret key can't be empty","bit-integrations")});return}t({}),h==="authentication"&&a(c(r({},i),{auth:!0})),h==="refreshLists"&&a(c(r({},i),{lists:!0}));const o={apiKey:e.apiKey,secretKey:e.secretKey};m(o,"mailjet_authentication").then(l=>{if(l&&l.success){const d=r({},e);f(!0),h==="authentication"?(l.data&&(d.lists=l.data),a(c(r({},i),{auth:!1})),n.success(u("Authorized Successfully","bit-integrations")),q(d,s,a)):h==="refreshLists"&&(l.data&&(d.lists=l.data,s(d)),a(c(r({},i),{lists:!1})),n.success(u("All lists fectched successfully","bit-integrations")));return}a(c(r({},i),{auth:!1})),n.error(u("Authorized failed","bit-integrations"))})},q=(e,s,t)=>{t(c(r({},t),{customFields:!0}));const f={apiKey:e.apiKey,secretKey:e.secretKey};m(f,"mailjet_fetch_all_custom_fields").then(i=>{if(i&&i.success){const a=r({},e);i.data&&(a.customFields=i.data),s(a),t(c(r({},t),{customFields:!1})),n.success(u("Custom fields fetch successfully","bit-integrations"));return}t(c(r({},t),{customFields:!1})),n.error(u("Custom fields fetch failed","bit-integrations"))})};export{q as a,I as c,z as g,v as h,M as m};
