File: /var/www/html/wordpress/wp-content/plugins/bit-integrations/assets/bi.511.976.js
var N=Object.defineProperty;var h=Object.getOwnPropertySymbols;var v=Object.prototype.hasOwnProperty,_=Object.prototype.propertyIsEnumerable;var j=(a,t,i)=>t in a?N(a,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):a[t]=i,o=(a,t)=>{for(var i in t||(t={}))v.call(t,i)&&j(a,i,t[i]);if(h)for(var i of h(t))_.call(t,i)&&j(a,i,t[i]);return a};import{j as l,f as w,L as $}from"./main-685.js";import{x as k}from"./bi.451.455.js";import{_ as c,d as M}from"./bi.878.0.js";import{g as R,a as T}from"./bi.577.975.js";import{M as q,a as V}from"./bi.776.3.js";const F=(a,t,i)=>{const e=o({},t);e.field_map.splice(a,0,{}),i(o({},e))},S=(a,t,i)=>{const e=o({},t);e.field_map.length>1&&e.field_map.splice(a,1),i(o({},e))},g=(a,t,i,e)=>{const n=o({},i);n.field_map[t][a.target.name]=a.target.value,a.target.value==="custom"&&(n.field_map[t].customValue=""),e(o({},n))},A=(a,t,i,e,n)=>{const r=o({},i);r.field_map[t][n]=a.target.value,e(o({},r))};function L({field:a,index:t,conf:i,setConf:e,fieldValue:n,fieldLabel:r,className:b}){return l.jsx(q,{onChange:p=>A(p,t,i,e,n),label:c(r,"bit-integrations"),className:b,type:"text",value:a[n],placeholder:c(r,"bit-integrations")})}function P({i:a,formFields:t,field:i,systemeIOConf:e,setSystemeIOConf:n}){var d;const r=(e==null?void 0:e.systemeIOFields)&&e.systemeIOFields.filter(s=>s.required===!0)||[],b=(e==null?void 0:e.systemeIOFields)&&e.systemeIOFields.filter(s=>s.required===!1)||[],p=w(M),{isPro:m}=p;return l.jsx("div",{className:"flx mt-2 mb-2 btcbi-field-map",children:l.jsxs("div",{className:"pos-rel flx",children:[l.jsxs("div",{className:"flx integ-fld-wrp",children:[l.jsxs("select",{className:"btcd-paper-inp mr-2",name:"formField",value:i.formField||"",onChange:s=>g(s,a,e,n),children:[l.jsx("option",{value:"",children:c("Select Field","bit-integrations")}),l.jsx("optgroup",{label:c("Form Fields","bit-integrations"),children:t==null?void 0:t.map(s=>l.jsx("option",{value:s.name,children:s.label},`ff-rm-${s.name}`))}),l.jsx("option",{value:"custom",children:c("Custom...","bit-integrations")}),l.jsx("optgroup",{label:sprintf(c("General Smart Codes %s","bit-integrations"),m?"":`(${c("Pro","bit-integrations")})`),children:m&&((d=V)==null?void 0:d.map(s=>l.jsx("option",{value:s.name,children:s.label},`ff-rm-${s.name}`)))})]}),i.formField==="custom"&&l.jsx(L,{field:i,index:a,conf:e,setConf:n,fieldValue:"customValue",fieldLabel:"Custom Value",className:"mr-2"}),l.jsxs("select",{className:"btcd-paper-inp",disabled:a<r.length,name:"systemeIOFormField",value:a<r.length?r[a].key||"":i.systemeIOFormField||"",onChange:s=>g(s,a,e,n),children:[l.jsx("option",{value:"",children:c("Select Field","bit-integrations")}),a<r.length?l.jsx("option",{value:r[a].key,children:r[a].label},r[a].key):b.map(({key:s,label:x})=>l.jsx("option",{value:s,children:x},s))]})]}),a>=r.length&&l.jsxs(l.Fragment,{children:[l.jsx("button",{onClick:()=>F(a,e,n),className:"icn-btn sh-sm ml-2 mr-1",type:"button",children:"+"}),l.jsx("button",{onClick:()=>S(a,e,n),className:"icn-btn sh-sm ml-1",type:"button","aria-label":"btn",children:l.jsx("span",{className:"btcd-icn icn-trash-2"})})]})]})})}function H({formFields:a,systemeIOConf:t,setSystemeIOConf:i,loading:e,setLoading:n,isLoading:r,setIsLoading:b,setSnackbar:p}){const m=(d,s)=>{i(x=>{const u=o({},x);return u[s]=d,u})};return l.jsxs(l.Fragment,{children:[(r||e.tag||e.session||e.fields)&&l.jsx($,{style:{display:"flex",justifyContent:"center",alignItems:"center",height:100,transform:"scale(0.7)"}}),t.actionName&&!e.tag&&!e.fields&&l.jsxs(l.Fragment,{children:[l.jsx("br",{}),l.jsx("br",{}),l.jsxs("div",{className:"flx",children:[l.jsx("b",{className:"wdt-200 d-in-b",children:c("Select tag:","bit-integrations")}),l.jsx(k,{options:(t==null?void 0:t.tags)&&t.tags.map(d=>({label:d.name,value:`${d.id}`})),className:"msl-wrp-options dropdown-custom-width",defaultValue:t==null?void 0:t.selectedTag,onChange:d=>m(d,"selectedTag"),singleSelect:!0,closeOnSelect:!0}),l.jsx("button",{onClick:()=>R(t,i,n),className:"icn-btn sh-sm ml-2 mr-2 tooltip",style:{"--tooltip-txt":`'${c("Refresh Tags","bit-integrations")}'`},type:"button",disabled:e.tag,children:"↻"})]})]}),t.actionName&&!r&&l.jsxs("div",{children:[l.jsx("br",{}),l.jsxs("div",{className:"mt-5",children:[l.jsx("b",{className:"wdt-100",children:c("Field Map","bit-integrations")}),l.jsx("button",{onClick:()=>T(t,i,n),className:"icn-btn sh-sm ml-2 mr-2 tooltip",style:{"--tooltip-txt":`'${c("Refresh Contact Fields","bit-integrations")}'`},type:"button",disabled:e.fields,children:"↻"})]}),l.jsx("br",{}),l.jsx("div",{className:"btcd-hr mt-1"}),l.jsxs("div",{className:"flx flx-around mt-2 mb-2 btcbi-field-map-label",children:[l.jsx("div",{className:"txt-dp",children:l.jsx("b",{children:c("Form Fields","bit-integrations")})}),l.jsx("div",{className:"txt-dp",children:l.jsx("b",{children:c("SystemeIO Fields","bit-integrations")})})]}),t==null?void 0:t.field_map.map((d,s)=>l.jsx(P,{i:s,field:d,systemeIOConf:t,formFields:a,setSystemeIOConf:i,setSnackbar:p},`rp-m-${s+9}`)),l.jsx("div",{className:"txt-center btcbi-field-map-button mt-2",children:l.jsx("button",{onClick:()=>F(t.field_map.length,t,i),className:"icn-btn sh-sm",type:"button",children:"+"})}),l.jsx("br",{}),l.jsx("br",{})]})]})}export{H as S};