var f=Object.defineProperty,h=Object.defineProperties;var k=Object.getOwnPropertyDescriptors;var d=Object.getOwnPropertySymbols;var y=Object.prototype.hasOwnProperty,F=Object.prototype.propertyIsEnumerable;var m=(r,i,e)=>i in r?f(r,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[i]=e,l=(r,i)=>{for(var e in i||(i={}))y.call(i,e)&&m(r,e,i[e]);if(d)for(var e of d(i))F.call(i,e)&&m(r,e,i[e]);return r},n=(r,i)=>h(r,k(i));import{u as _}from"./Note.NSUdvR3c.js";import{_ as t,z as u,b as p}from"./main.2.9.0.js";const P=[{name:"create_or_update_subscriber",label:t("Create or Update Subscriber","bit-integrations"),is_pro:!0},{name:"update_subscriber",label:t("Update Subscriber","bit-integrations"),is_pro:!0},{name:"delete_subscriber",label:t("Delete Subscriber","bit-integrations"),is_pro:!0},{name:"remove_phone_from_subscriber",label:t("Remove Phone From Subscriber","bit-integrations"),is_pro:!0},{name:"add_subscriber_to_group",label:t("Add Subscriber To Group","bit-integrations"),is_pro:!0},{name:"remove_subscriber_from_group",label:t("Remove Subscriber From Group","bit-integrations"),is_pro:!0},{name:"create_group",label:t("Create Group","bit-integrations"),is_pro:!0},{name:"update_group",label:t("Update Group","bit-integrations"),is_pro:!0},{name:"delete_group",label:t("Delete Group","bit-integrations"),is_pro:!0}],S=[{key:"email",label:t("Email","bit-integrations"),required:!0},{key:"firstname",label:t("First Name","bit-integrations"),required:!1},{key:"lastname",label:t("Last Name","bit-integrations"),required:!1},{key:"phone",label:t("Phone","bit-integrations"),required:!1}],q=[{key:"subscriber_id",label:t("Subscriber ID / Email","bit-integrations"),required:!0},{key:"firstname",label:t("First Name","bit-integrations"),required:!1},{key:"lastname",label:t("Last Name","bit-integrations"),required:!1},{key:"phone",label:t("Phone","bit-integrations"),required:!1},{key:"subscriber_status",label:t("Subscriber Status","bit-integrations"),required:!1},{key:"sms_status",label:t("SMS Status","bit-integrations"),required:!1},{key:"transactional_email_status",label:t("Transactional Email Status","bit-integrations"),required:!1}],c=[{key:"emails",label:t("Emails (comma separated)","bit-integrations"),required:!0}],A=[{key:"subscriber_id",label:t("Subscriber ID / Email","bit-integrations"),required:!0}],g=[{key:"title",label:t("Group Title","bit-integrations"),required:!0}],D={create_or_update_subscriber:S,update_subscriber:q,delete_subscriber:c,remove_phone_from_subscriber:A,add_subscriber_to_group:c,remove_subscriber_from_group:c,create_group:g,update_group:g,delete_group:[]},G=["add_subscriber_to_group","remove_subscriber_from_group","update_group","delete_group"],N=["create_or_update_subscriber","update_subscriber"],U=["create_or_update_subscriber","update_subscriber","add_subscriber_to_group"],M=(r,i,e)=>{const{name:s,value:a}=r.target;e(o=>_(o,b=>{b[s]=a}))},I=r=>{const i=(r||[]).filter(e=>e.required===!0);return i.length>0?i.map(e=>({formField:"",senderField:e.key})):[{formField:"",senderField:""}]},R=r=>G.includes(r==null?void 0:r.mainAction)&&!(r!=null&&r.groupId)?!1:(r!=null&&r.field_map?r.field_map.filter(e=>!e.formField||!e.senderField||e.formField==="custom"&&!e.customValue):[]).length<1,x=(r,i,e,s)=>{if(!r.api_token){u.error(t("API token can't be empty","bit-integrations"));return}s(n(l({},e),{auth:!0})),p({api_token:r.api_token},"sender_authorize").then(a=>{if(s(n(l({},e),{auth:!1})),a&&a.success){i(!0),u.success(t("Authorized Successfully","bit-integrations"));return}u.error(t("Authorization failed","bit-integrations"))})},B=(r,i,e)=>{if(!r.api_token){u.error(t("API token can't be empty","bit-integrations"));return}e(!0),p({api_token:r.api_token},"refresh_sender_groups").then(s=>{var a;if(s&&s.success&&((a=s.data)!=null&&a.groups)){i(o=>_(o,b=>{b.allGroups=s.data.groups})),e(!1),u.success(t("Groups fetched successfully","bit-integrations"));return}e(!1),u.error(t("Groups fetch failed","bit-integrations"))}).catch(()=>e(!1))},T=(r,i,e)=>{if(!r.api_token){u.error(t("API token can't be empty","bit-integrations"));return}e(!0),p({api_token:r.api_token},"refresh_sender_fields").then(s=>{var a;if(s&&s.success&&((a=s.data)!=null&&a.fields)){i(o=>_(o,b=>{b.allFields=s.data.fields})),e(!1),u.success(t("Custom fields fetched successfully","bit-integrations"));return}e(!1),u.error(t("Custom fields fetch failed","bit-integrations"))}).catch(()=>e(!1))};export{G as a,T as b,R as c,D as d,x as e,I as g,M as h,P as m,B as r,N as s,U as t};
