var F=Object.defineProperty,y=Object.defineProperties;var p=Object.getOwnPropertyDescriptors;var _=Object.getOwnPropertySymbols;var q=Object.prototype.hasOwnProperty,A=Object.prototype.propertyIsEnumerable;var k=(s,t,e)=>t in s?F(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e,a=(s,t)=>{for(var e in t||(t={}))q.call(t,e)&&k(s,e,t[e]);if(_)for(var e of _(t))A.call(t,e)&&k(s,e,t[e]);return s},c=(s,t)=>y(s,p(t));import{_ as o,b as h,c as u}from"./bi.636.93.js";const w=(s,t,e)=>{const r=a({},t);r.name=s.target.value,e(a({},r))},P=(s,t,e,r,i,l,d="authentication")=>{const n=a({},s);if(!n.name||!n.api_token){e({name:n.name?"":o("Integration name can't be empty","bit-integrations"),api_token:n.api_token?"":o("Access Api Token Key can't be empty","bit-integrations")});return}let m;d==="authentication"?(l(c(a({},i),{auth:!0})),m="Authorization Failed"):d==="accounts"&&(l(c(a({},i),{accounts:!0})),m="Accounts fetching failed");const b={api_token:n.api_token};h(b,"drip_authorize").then(f=>{f!=null&&f.success?(n.accounts=f.data,d==="authentication"?(r(!0),u.success("Authorized Successfully")):d==="accounts"&&u.success("Accounts fetched Successfully")):u.error(m),t(a({},n)),l(c(a({},i),{auth:!1,accounts:!1}))})},M=s=>!((s!=null&&s.field_map?s.field_map.filter(e=>!e.formField||!e.dripField||!e.formField==="custom"&&!e.customValue):[]).length>0),S=s=>{const t=s==null?void 0:s.dripFormFields.filter(e=>e.required===!0);return t.length>0?t.map(e=>({formField:"",dripField:e.key})):[{formField:"",dripField:""}]},T=(s,t,e)=>{e(c(a({},e),{customFields:!0}));const r={apiToken:s.api_token,selectedAccountId:s.selectedAccountId};h(r,"drip_fetch_all_custom_fields").then(i=>{if(i&&i.success){const l=a({},s);i.data&&(l.dripFormFields=[...g,...i.data]),t(l),e(c(a({},e),{customFields:!1})),u.success(o("Custom fields fetch successfully","bit-integrations"));return}e(c(a({},e),{customFields:!1})),u.error(o("Custom fields fetch failed","bit-integrations"))})},E=(s,t,e)=>{e(c(a({},e),{tags:!0}));const r={apiToken:s.api_token,selectedAccountId:s.selectedAccountId};h(r,"drip_fetch_all_tags").then(i=>{if(i&&i.success){const l=a({},s);i.data&&(l.tags=i.data),t(l),e(c(a({},e),{tags:!1})),u.success(o("Tags fetched successfully","bit-integrations"));return}e(c(a({},e),{customFields:!1})),u.error(o("Tags fetching failed","bit-integrations"))})},g=[{key:"email",label:"Email",required:!0},{key:"first_name",label:"First Name",required:!1},{key:"last_name",label:"Last Name",required:!1},{key:"address1",label:"Address 1",required:!1},{key:"address2",label:"Address 2",required:!1},{key:"city",label:"City",required:!1},{key:"state",label:"State",required:!1},{key:"zip",label:"Zip",required:!1},{key:"country",label:"Country",required:!1},{key:"phone",label:"Phone",required:!1},{key:"time_zone",label:"Time Zone",required:!1},{key:"ip_address",label:"IP Address",required:!1}];export{E as a,T as b,M as c,P as d,S as g,w as h,g as s};
