var A=Object.defineProperty,P=Object.defineProperties;var q=Object.getOwnPropertyDescriptors;var _=Object.getOwnPropertySymbols;var b=Object.prototype.hasOwnProperty,g=Object.prototype.propertyIsEnumerable;var K=(s,t,e)=>t in s?A(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e,l=(s,t)=>{for(var e in t||(t={}))b.call(t,e)&&K(s,e,t[e]);if(_)for(var e of _(t))g.call(t,e)&&K(s,e,t[e]);return s},d=(s,t)=>P(s,q(t));var o=(s,t,e)=>new Promise((a,c)=>{var r=i=>{try{u(e.next(i))}catch(m){c(m)}},f=i=>{try{u(e.throw(i))}catch(m){c(m)}},u=i=>i.done?a(i.value):Promise.resolve(i.value).then(r,f);u((e=e.apply(s,t)).next())});import{_ as h,b as y,c as n,G as T,s as k}from"./bi.394.85.js";const x=(s,t,e,a,c)=>{const r=l({},t),f=l({},a);f[s.target.name]="",r[s.target.name]=s.target.value,c(f),e(r)},C=(s,t,e,a,c,r)=>{if(!s.authKey){e({authKey:s.authKey?"":h("API key can't be empty")});return}e({}),r(d(l({},c),{auth:!0}));const f={authKey:s.authKey};y(f,"selzy_handle_authorize").then(u=>{var i;if(u.success&&u.data){const m=l({},s);if(u.data){m.default||(m.default={});const w=(i=u.data.result)==null?void 0:i.map(F=>d(l({},F),{id:String(F.id)}));m.default.lists=w}z(m,t,c,r),t(m),a(!0),r(d(l({},c),{auth:!1})),n.success(h("Authorized successfully"));return}r(d(l({},c),{auth:!1})),n.error(h("Authorized failed"))})},M=(s,t,e,a)=>o(void 0,null,function*(){var f;a(d(l({},e),{list:!0}));const c={authKey:s.authKey},r=yield y(c,"selzy_handle_authorize");if(r.success){const u=(f=r.data.result)==null?void 0:f.map(m=>d(l({},m),{id:String(m.id)})),i=l({},s);if(u){i.default||(i.default={}),i.default.lists=u,t(i),a(d(l({},e),{list:!1})),n.success(h("List refresh successfully"));return}}a(d(l({},e),{list:!1})),n.success(h("List refresh failed"))}),S=(s,t,e,a)=>o(void 0,null,function*(){a&&a(d(l({},e),{tag:!0}));const c={authKey:s.authKey},r=yield y(c,"selzy_get_all_tags");if(r.success){const f=r.data.result,u=l({},s);return f&&(u.default||(u.default={}),u.default.tags=f,t(u),a&&(a(d(l({},e),{tag:!1})),n.success(h("Tag refresh successfully")))),!0}return a&&(a(d(l({},e),{tag:!1})),n.success(h("Tag refresh failed"))),!1}),z=(s,t,e,a)=>o(void 0,null,function*(){a&&a(d(l({},e),{customFields:!0}));const c={authKey:s.authKey},r=yield y(c,"selzy_get_all_custom_fields");if(r.success){const f=l({},s);return r.data&&(f.default||(f.default={}),f.default.customFields=r.data,t(f),a&&(a(d(l({},e),{customFields:!1})),n.success(h("Custom fileds fetched successfully")))),!0}return a&&(a(d(l({},e),{customFields:!1})),n.success(h("Custom fileds fetching failed"))),!1}),B=s=>{const t=s==null?void 0:s.selzyFields.filter(e=>e.required===!0);return t.length>0?t.map(e=>({formField:"",selzyFormField:e.key})):[{formField:"",selzyFormField:""}]},p=s=>!((s!=null&&s.field_map?s.field_map.filter(e=>!e.formField||!e.selzyFormField||!e.formField==="custom"&&!e.customValue):[]).length>0),E=(s,t,e)=>{if(setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),!p(s)){n.error("Please map mandatory fields");return}s.field_map.length>0&&t(e)},G=(s,t,e,a,c,r)=>{r(!0),T(s,t,e,a,c,"","",r).then(u=>{var i;u.success?(n.success((i=u.data)==null?void 0:i.msg),c(e)):n.error(u.data||u)})},V=(s,t,e,a,c,r)=>{if(!p(e)){n.error("Please map mandatory fields");return}if(p(e)==="required"){n.error("You must select email or phone in klaviyo fields");return}k({flow:s,allIntegURL:t,conf:e,navigate:a,edit:c,setIsLoading:r})};export{M as a,S as b,z as c,C as d,G as e,B as g,x as h,E as n,V as s};
