var _=Object.defineProperty;var F=Object.getOwnPropertySymbols;var y=Object.prototype.hasOwnProperty,w=Object.prototype.propertyIsEnumerable;var u=(i,t,n)=>t in i?_(i,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[t]=n,p=(i,t)=>{for(var n in t||(t={}))y.call(t,n)&&u(i,n,t[n]);if(F)for(var n of F(t))w.call(t,n)&&u(i,n,t[n]);return i};import{k,g as S,j as e,_ as m,s as A,L as I}from"./main.2.8.1.js";import"./Note.BeM7sN-p.js";import"./react-router-dom.9mCuUg3q.js";import{a as M,h as V}from"./Integrations.D2bgBas2.js";import{g as $}from"./SureCartCommonFunc.CXfk-Ps-.js";import{T as q}from"./TagifyInput.Cu0YIRbG.js";const N=(i,t,n,l,c)=>{const s=p({},t);s.field_map.splice(i,0,{}),n(p({},s))},L=(i,t,n,l,c)=>{const s=p({},t);s.field_map.length>1&&s.field_map.splice(i,1),n(p({},s))},v=(i,t,n,l,c,s)=>{const b=p({},n);b.field_map[t][i.target.name]=i.target.value,i.target.value==="custom"&&(b.field_map[t].customValue=""),l(p({},b))};function R({i,field:t,formFields:n,sureCartConf:l,setSureCartConf:c}){var x,d,o,h;if(((x=l==null?void 0:l.field_map)==null?void 0:x.length)===1&&t.SureCartFormField===""){const a=p({},l),g=$(a);a.field_map=g,c(a)}const s=((d=l==null?void 0:l.customerFields)==null?void 0:d.filter(a=>a.required===!0))||[],b=((o=l==null?void 0:l.customerFields)==null?void 0:o.filter(a=>a.required===!1))||[],j=k(S),{isPro:r}=j;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",value:t.formField||"",onChange:a=>v(a,i,l,c),children:[e.jsx("option",{value:"",children:m("Select Field","bit-integrations")}),e.jsx("optgroup",{label:m("Form Fields","bit-integrations"),children:n==null?void 0:n.map(a=>e.jsx("option",{value:a.name,children:a.label},`ff-rm-${a.name}`))}),e.jsx("option",{value:"custom",children:m("Custom...","bit-integrations")}),e.jsx("optgroup",{label:A(m("General Smart Codes %s","bit-integrations"),r?"":`(${m("Pro","bit-integrations")})`),children:r&&((h=M)==null?void 0:h.map(a=>e.jsx("option",{value:a.name,children:a.label},`ff-rm-${a.name}`)))})]}),t.formField==="custom"&&e.jsx(q,{onChange:a=>V(a,i,l,c),label:m("Custom Value","bit-integrations"),className:"mr-2",type:"text",value:t.customValue,placeholder:m("Custom Value","bit-integrations"),formFields:n}),e.jsxs("select",{className:"btcd-paper-inp",disabled:i<s.length,name:"SureCartFormField",value:i<s.length?s[i].key||"":t.SureCartFormField||"",onChange:a=>v(a,i,l,c),children:[e.jsx("option",{value:"",children:m("Select Field","bit-integrations")}),i<s.length?e.jsx("option",{value:s[i].key,children:s[i].label},s[i].key):b.map(({key:a,label:g})=>e.jsx("option",{value:a,children:g},a))]})]}),i>=s.length&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>N(i,l,c),className:"icn-btn sh-sm ml-2 mr-1",type:"button",children:"+"}),e.jsx("button",{onClick:()=>L(i,l,c),className:"icn-btn sh-sm ml-1",type:"button","aria-label":"btn",children:e.jsx("span",{className:"btcd-icn icn-trash-2"})})]})]})})}function B({formID:i,formFields:t,handleInput:n,sureCartConf:l,setSureCartConf:c,isLoading:s,setIsLoading:b,setSnackbar:j,a:r}){const x=d=>{const o=p({},l),{name:h}=d.target;d.target.value!==""?o[h]=d.target.value:delete o[h],o[d.target.name]=d.target.value,c(p({},o))};return e.jsxs(e.Fragment,{children:[s&&e.jsx(I,{style:{display:"flex",justifyContent:"center",alignItems:"center",height:100,transform:"scale(0.7)"}}),e.jsxs(e.Fragment,{children:[e.jsx("br",{}),e.jsx("b",{className:"wdt-200 d-in-b",children:m("Actions:","bit-integrations")}),e.jsxs("select",{onChange:x,name:"mainAction",value:l==null?void 0:l.mainAction,className:"btcd-paper-inp w-5",children:[e.jsx("option",{value:"",children:m("Select Actions","bit-integrations")}),(l==null?void 0:l.allActions)&&l.allActions.map(({key:d,label:o})=>e.jsx("option",{value:d,children:o},d))]}),e.jsx("br",{}),e.jsx("div",{className:"mt-4",children:e.jsx("b",{className:"wdt-100",children:m("Map Fields","bit-integrations")})}),e.jsx("div",{className:"btcd-hr mt-1"}),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:m("Form Fields","bit-integrations")})}),e.jsx("div",{className:"txt-dp",children:e.jsx("b",{children:m("SureCart Fields","bit-integrations")})})]}),l.field_map.map((d,o)=>e.jsx(R,{i:o,field:d,formFields:t,sureCartConf:l,setSureCartConf:c},`keap-m-${o+9}`)),e.jsx("br",{}),e.jsx("div",{className:"txt-center btcbi-field-map-button mt-2",children:e.jsx("button",{onClick:()=>N(l.field_map.length,l,c),className:"icn-btn sh-sm",type:"button",children:"+"})})]})]})}export{B as S};
