var _=Object.defineProperty,D=Object.defineProperties;var y=Object.getOwnPropertyDescriptors;var h=Object.getOwnPropertySymbols;var z=Object.prototype.hasOwnProperty,m=Object.prototype.propertyIsEnumerable;var p=(t,e,s)=>e in t?_(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,c=(t,e)=>{for(var s in e||(e={}))z.call(e,s)&&p(t,s,e[s]);if(h)for(var s of h(e))m.call(e,s)&&p(t,s,e[s]);return t},w=(t,e)=>D(t,y(e));import{b as F,_ as r}from"./main.2.9.0.js";const L=(t,e,s,d,i,l,a,o,n)=>{let f=c({},s);f[t.target.name]=t.target.value,t.target.name==="list"&&(f=q(f,e,d,i,l)),d(c({},f))},q=(t,e,s,d,i)=>{var a,o;const l=c({},t);return l.field_map=[{formField:"",zohoFormField:"Contact Email"}],(o=(a=l==null?void 0:l.default)==null?void 0:a.fields)!=null&&o[l.list]||R(e,l,s,d,i),l},P=(t,e,s,d,i)=>{d(!0);const l={formID:t,id:e.id,dataCenter:e.dataCenter,clientId:e.clientId,clientSecret:e.clientSecret,tokenDetails:e.tokenDetails};F(l,"zmarketingHub_refresh_lists").then(a=>{if(a&&a.success){const o=c({},e);a.data.lists&&(o.default=w(c({},o.default),{lists:a.data.lists})),a.data.tokenDetails&&(o.tokenDetails=a.data.tokenDetails),i({show:!0,msg:r("Lists refreshed","bit-integrations")}),s(c({},o))}else a&&a.data&&a.data.data||!a.success&&typeof a.data=="string"?i({show:!0,msg:`${r("Lists refresh failed Cause:")}${a.data.data||a.data}. ${r("please try again","bit-integrations")}`}):i({show:!0,msg:r("Lists refresh failed. please try again","bit-integrations")});d(!1)}).catch(()=>d(!1))},R=(t,e,s,d,i)=>{const{list:l}=e;if(!l)return;d(!0);const a={formID:t,list:l,dataCenter:e.dataCenter,clientId:e.clientId,clientSecret:e.clientSecret,tokenDetails:e.tokenDetails};F(a,"zmarketingHub_refresh_contact_fields").then(o=>{if(o&&o.success){const n=c({},e);o.data.fields?(n.default.fields||(n.default.fields={}),n.default.fields[l]=o.data,i({show:!0,msg:r("Contact Fields refreshed","bit-integrations")})):i({show:!0,msg:r("Zoho didn't provide fields names for this list","bit-integrations")}),o.data.tokenDetails&&(n.tokenDetails=o.data.tokenDetails),s(c({},n))}else i({show:!0,msg:r("Contact Fields refresh failed. please try again","bit-integrations")});d(!1)}).catch(()=>d(!1))},g=t=>!((t!=null&&t.field_map?t.field_map.filter(s=>{var d,i,l;return!s.formField&&s.zohoFormField&&((l=(i=(d=t==null?void 0:t.default)==null?void 0:d.fields)==null?void 0:i[t.list])==null?void 0:l.required.indexOf(s.zohoFormField))!==-1}):[]).length>0),v=()=>{const t={},s=window.location.href.replace(`${window.opener.location.href}/redirect`,"").split("&");s&&s.forEach(d=>{const i=d.split("=");i[1]&&(t[i[0]]=i[1])}),localStorage.setItem("__zohoMarkatingHub",JSON.stringify(t)),window.close()};export{R as a,g as c,L as h,P as r,v as s};
