File: /var/www/html/wordpress/wp-content/plugins/bit-integrations/assets/bi.268.863.js
var L=Object.defineProperty;var _=Object.getOwnPropertySymbols;var M=Object.prototype.hasOwnProperty,S=Object.prototype.propertyIsEnumerable;var w=(t,a,d)=>a in t?L(t,a,{enumerable:!0,configurable:!0,writable:!0,value:d}):t[a]=d,x=(t,a)=>{for(var d in a||(a={}))M.call(a,d)&&w(t,d,a[d]);if(_)for(var d of _(a))S.call(a,d)&&w(t,d,a[d]);return t};import{f as g,j as e,L as T}from"./main-685.js";import{d as o,_ as l}from"./bi.878.0.js";import{a as j,d as $,g as A,b as V}from"./bi.214.862.js";import{a as q,h as R}from"./bi.776.3.js";import{T as U}from"./bi.768.751.js";import"./bi.451.455.js";import{b as B}from"./bi.601.11.js";import{P as I,a as E}from"./bi.463.750.js";import{A as G}from"./bi.684.749.js";function P({i:t,field:a,formFields:d,klaviyoConf:n,setKlaviyoConf:p,type:b}){var N;const u=g(o),{isPro:m}=u,s=(n==null?void 0:n.klaviyoFields.filter(i=>i.required===!0))||[],r=(n==null?void 0:n.klaviyoFields.filter(i=>i.required===!1))||[],c=(i,h)=>{const F=x({},n);F[b][h][i.target.name]=i.target.value,p(F)};return e.jsx("div",{className:"flx mt-2 mb-2 btcbi-field-map",children:e.jsxs("div",{className:"pos-rel flx",children:[e.jsxs("div",{className:"flx integ-fld-wrp",children:[e.jsxs("select",{className:"btcd-paper-inp mr-2",name:"formField",onChange:i=>{c(i,t)},value:a.formField||"",children:[e.jsx("option",{value:"",children:l("Select Field","bit-integrations")}),e.jsx("optgroup",{label:l("Form Fields","bit-integrations"),children:d==null?void 0:d.map(i=>e.jsx("option",{value:i.name,children:i.label},`ff-rm-${i.name}`))}),e.jsx("option",{value:"custom",children:l("Custom...","bit-integrations")}),e.jsx("optgroup",{label:sprintf(l("General Smart Codes %s","bit-integrations"),m?"":`(${l("Pro","bit-integrations")})`),children:m&&((N=q)==null?void 0:N.map(i=>e.jsx("option",{value:i.name,children:i.label},`ff-rm-${i.name}`)))})]}),a.formField==="custom"&&e.jsx(U,{onChange:i=>R(i,t),label:l("Custom Value","bit-integrations"),className:"mr-2",type:"text",value:a.customValue,placeholder:l("Custom Value","bit-integrations"),formFields:d}),b==="field_map"?e.jsxs("select",{className:"btcd-paper-inp",disabled:t<s.length,name:"klaviyoFormField",onChange:i=>{c(i,t)},value:t<s.length?s[t].key||"":a.klaviyoFormField||"",children:[e.jsx("option",{value:"",children:l("Select Field","bit-integrations")}),t<s.length?e.jsx("option",{value:s[t].key,children:s[t].label},s[t].key):r.map(({key:i,label:h})=>e.jsx("option",{value:i,children:h},i))]}):e.jsx("input",{className:"btcd-paper-inp",name:"klaviyoFormField",value:a.klaviyoFormField||"",onChange:i=>{c(i,t)},type:"text"})]}),e.jsx("button",{onClick:()=>j(t,n,p,b),className:"icn-btn sh-sm ml-2 mr-1",type:"button",children:"+"}),e.jsx("button",{onClick:()=>$(t,n,p,b),className:"icn-btn sh-sm ml-1",type:"button","aria-label":"btn",children:e.jsx("span",{className:"btcd-icn icn-trash-2"})})]})})}function H({klaviyoConf:t,setKlaviyoConf:a,loading:d,setLoading:n}){const p=g(o),{isPro:b}=p,u=(m,s)=>{var c;const r=x({},t);(c=m.target)!=null&&c.checked?r.update=!0:delete r.update,a(x({},r))};return e.jsx("div",{className:"pos-rel d-flx w-8",children:e.jsx(B,{checked:(t==null?void 0:t.update)||!1,onChange:m=>u(m),className:"wdt-200 mt-4 mr-2",value:"update",isInfo:!b,title:e.jsx(I,{title:l("Update Profile","bit-integrations")}),subTitle:e.jsx(E,{title:l("Update Profile","bit-integrations"),subtitle:l("A record gets updated based on the email, else a new profile will be created","bit-integrations"),proVersion:"2.4.9"})})})}function f({klaviyoConf:t,setKlaviyoConf:a,formFields:d,loading:n,setLoading:p}){var u,m;g(o);const b=s=>{const r=x({},t),{name:c}=s.target;switch(s.target.value!==""?r[c]=s.target.value:delete r[c],r[s.target.name]=s.target.value,s.target.name){case"listId":r.field_map=V(r),r.custom_field_map=[{formField:"",klaviyoFormField:""}];break}a(x({},r))};return e.jsxs("div",{children:[e.jsx("b",{className:"wdt-200 d-in-b mt-2",children:l("List:","bit-integrations")}),e.jsxs("select",{name:"listId",value:t.listId,onChange:b,className:"btcd-paper-inp w-5",children:[e.jsx("option",{value:"",children:l("Select List","bit-integrations")}),((u=t==null?void 0:t.default)==null?void 0:u.lists)&&t.default.lists.map((s,r)=>{var c;return e.jsx("option",{value:s==null?void 0:s.id,children:(c=s==null?void 0:s.attributes)==null?void 0:c.name},r)})]}),e.jsx("button",{onClick:()=>A(t,a,n,p),className:"icn-btn sh-sm ml-2 mr-2 tooltip",style:{"--tooltip-txt":'"Refresh list"'},type:"button",disabled:n.list,children:"↻"}),n.list&&e.jsx(T,{style:{display:"flex",justifyContent:"center",alignItems:"center",height:100,transform:"scale(0.7)"}}),(t==null?void 0:t.listId)&&e.jsxs("div",{className:"mt-5",children:[e.jsx("b",{className:"wdt-100",children:l("Field Map","bit-integrations")}),e.jsx("div",{className:"btcd-hr mt-2 mb-4"}),e.jsxs("div",{className:"flx flx-around mt-2 mb-2 btcbi-field-map-label",children:[e.jsx("div",{className:"txt-dp",children:e.jsx("b",{children:l("Form Fields","bit-integrations")})}),e.jsx("div",{className:"txt-dp",children:e.jsx("b",{children:l("Klaviyo Fields","bit-integrations")})})]}),t==null?void 0:t.field_map.map((s,r)=>e.jsx(P,{i:r,field:s,formFields:d,klaviyoConf:t,setKlaviyoConf:a,type:"field_map"},`ko-m-${r+8}`)),e.jsx("div",{className:"txt-center btcbi-field-map-button mt-2",children:e.jsx("button",{onClick:()=>j(t.field_map.length,t,a,"field_map"),className:"icn-btn sh-sm",type:"button",children:"+"})})]}),e.jsx("br",{}),(t==null?void 0:t.listId)&&e.jsxs("div",{className:"mt-5",children:[e.jsxs(G,{title:l("Custom Properties","bit-integrations"),children:[e.jsx("b",{className:"wdt-100",children:e.jsx(I,{title:l("Custom Properties","bit-integrations")})}),e.jsx("div",{className:"btcd-hr mt-2 mb-4"}),e.jsxs("div",{className:"flx flx-around mt-2 mb-2 btcbi-field-map-label",children:[e.jsx("div",{className:"txt-dp",children:e.jsx("b",{children:l("Form Fields","bit-integrations")})}),e.jsx("div",{className:"txt-dp",children:e.jsx("b",{children:l("Klaviyo Property name","bit-integrations")})})]}),(m=t==null?void 0:t.custom_field_map)==null?void 0:m.map((s,r)=>e.jsx(P,{i:r,field:s,formFields:d,klaviyoConf:t,setKlaviyoConf:a,type:"custom_field_map"},`ko-m-${r+8}`)),e.jsx("div",{className:"txt-center btcbi-field-map-button mt-2",children:e.jsx("button",{onClick:()=>{var s;return j((s=t==null?void 0:t.custom_field_map)==null?void 0:s.length,t,a,"custom_field_map")},className:"icn-btn sh-sm",type:"button",children:"+"})})]}),e.jsx("br",{}),e.jsx("div",{className:"mt-4",children:e.jsx("b",{className:"wdt-100",children:l("Utilities","bit-integrations")})}),e.jsx("div",{className:"btcd-hr mt-1"}),e.jsx(H,{klaviyoConf:t,setKlaviyoConf:a,formFields:d,loading:n,setLoading:p})]})]})}export{f as K};