var N=Object.defineProperty;var x=Object.getOwnPropertySymbols;var _=Object.prototype.hasOwnProperty,g=Object.prototype.propertyIsEnumerable;var j=(l,a,e)=>a in l?N(l,a,{enumerable:!0,configurable:!0,writable:!0,value:e}):l[a]=e,d=(l,a)=>{for(var e in a||(a={}))_.call(a,e)&&j(l,e,a[e]);if(x)for(var e of x(a))g.call(a,e)&&j(l,e,a[e]);return l};import{r as y,h as k,j as t,L as w}from"./main-406.js";import{k as I,_ as m,l as M,m as A,p as S}from"./bi.394.85.js";import{T as q}from"./bi.704.707.js";const O=(l,a,e,s,r,i)=>{const o=d({},a),{name:u}=l.target;l.target.value!==""?o[u]=l.target.value:delete o[u],o[l.target.name]=l.target.value,e(d({},o))},L=l=>{const a=l==null?void 0:l.giveWpFields.filter(e=>e.required===!0);return a.length>0?a.map(e=>({formField:"",giveWpFormField:e.key})):[{formField:"",giveWpFormField:""}]},U=l=>!((l.field_map?l.field_map.filter(e=>!e.formField||!e.giveWpFormField):[]).length>0),$=(l,a,e)=>{const s=d({},a);s.field_map.splice(l,0,{}),e(d({},s))},R=(l,a,e)=>{const s=d({},a);s.field_map.length>1&&s.field_map.splice(l,1),e(d({},s))},F=(l,a,e,s)=>{const r=d({},e);r.field_map[a][l.target.name]=l.target.value,l.target.value==="custom"&&(r.field_map[a].customValue=""),s(d({},r))};function V({i:l,formFields:a,field:e,giveWpConf:s,setGiveWpConf:r}){var b;y.useEffect(()=>{var n;if(((n=s==null?void 0:s.field_map)==null?void 0:n.length)===1&&e.giveWpFormField===""){const c=d({},s),p=L(c);c.field_map=p,r(c)}},[]);const i=(s==null?void 0:s.giveWpFields.filter(n=>n.required===!0))||[],o=(s==null?void 0:s.giveWpFields.filter(n=>n.required===!1))||[],u=k(I),{isPro:h}=u;return t.jsx("div",{className:"flx mt-2 mb-2 btcbi-field-map",children:t.jsxs("div",{className:"pos-rel flx",children:[t.jsxs("div",{className:"flx integ-fld-wrp",children:[t.jsxs("select",{className:"btcd-paper-inp mr-2",name:"formField",value:e.formField||"",onChange:n=>F(n,l,s,r),children:[t.jsx("option",{value:"",children:m("Select Field","bit-integrations")}),t.jsx("optgroup",{label:"Form Fields",children:a==null?void 0:a.map(n=>t.jsx("option",{value:n.name,children:n.label},`ff-rm-${n.name}`))}),t.jsx("option",{value:"custom",children:m("Custom...","bit-integrations")}),t.jsx("optgroup",{label:`General Smart Codes ${h?"":"(PRO)"}`,children:h&&((b=M)==null?void 0:b.map(n=>t.jsx("option",{value:n.name,children:n.label},`ff-rm-${n.name}`)))})]}),e.formField==="custom"&&t.jsx(q,{onChange:n=>A(n,l,s,r),label:m("Custom Value","bit-integrations"),className:"mr-2",type:"text",value:e.customValue,placeholder:m("Custom Value","bit-integrations"),formFields:a}),t.jsxs("select",{className:"btcd-paper-inp",disabled:l<i.length,name:"giveWpFormField",value:l<i.length?i[l].key||"":e.giveWpFormField||"",onChange:n=>F(n,l,s,r),children:[t.jsx("option",{value:"",children:m("Select Field","bit-integrations")}),l<i.length?t.jsx("option",{value:i[l].key,children:i[l].label},i[l].key):o.map(({key:n,label:c})=>t.jsx("option",{value:n,children:c},n))]})]}),l>=i.length&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>$(l,s,r),className:"icn-btn sh-sm ml-2 mr-1",type:"button",children:"+"}),t.jsx("button",{onClick:()=>R(l,s,r),className:"icn-btn sh-sm ml-1",type:"button","aria-label":"btn",children:t.jsx("span",{className:"btcd-icn icn-trash-2"})})]})]})})}function z({formFields:l,handleInput:a,giveWpConf:e,setGiveWpConf:s,isLoading:r,setIsLoading:i,setSnackbar:o,allIntegURL:u,isInfo:h,edit:b}){return t.jsxs(t.Fragment,{children:[t.jsx("br",{}),t.jsx("b",{className:"wdt-200 d-in-b",children:m("Actions:","bit-integrations")}),t.jsxs("select",{onChange:a,name:"mainAction",value:e==null?void 0:e.mainAction,className:"btcd-paper-inp w-5",children:[t.jsx("option",{value:"",children:m("Select Actions","bit-integrations")}),(e==null?void 0:e.allActions)&&e.allActions.map(({key:n,label:c})=>t.jsx("option",{value:n,children:c},n))]}),t.jsx("br",{}),t.jsx("br",{}),r&&t.jsx(w,{style:{display:"flex",justifyContent:"center",alignItems:"center",height:100,transform:"scale(0.7)"}}),t.jsx(t.Fragment,{children:["1"].includes(e==null?void 0:e.mainAction)&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"mt-4",children:t.jsx("b",{className:"wdt-100",children:m("Map Fields","bit-integrations")})}),t.jsx("div",{className:"btcd-hr mt-1"}),t.jsxs("div",{className:"flx flx-around mt-2 mb-2 btcbi-field-map-label",children:[t.jsx("div",{className:"txt-dp",children:t.jsx("b",{children:m("Form Fields","bit-integrations")})}),t.jsx("div",{className:"txt-dp",children:t.jsx("b",{children:m("GiveWp Fields","bit-integrations")})})]}),e.field_map.map((n,c)=>t.jsx(V,{i:c,field:n,giveWpConf:e,formFields:l,setGiveWpConf:s},`dash-m-${c+9}`)),t.jsx("div",{className:"txt-center btcbi-field-map-button mt-2",children:t.jsx("button",{onClick:()=>S(e.field_map.length,e,s),className:"icn-btn sh-sm",type:"button",children:"+"})})]})}),t.jsx("br",{})]})}export{z as G,U as c,O as h};
