import{u as v,j as s,_ as t,Q as y,$ as N,e as b}from"./main-634.js";import{a8 as u,a9 as $,aa as F,ab as R}from"./bf-746-82.js";import{r as _,a as z}from"./bf-850-97.js";import{n as V}from"./bf-25-81.js";import{M as w}from"./bf-438-114.js";function E({i,formFields:j,field:c,marketingHubConf:l,setMarketingHubConf:a}){var m,h,p,d,x;const r=c.zohoFormField===""||((m=l.default.fields[l.list].required)==null?void 0:m.indexOf(c.zohoFormField))===-1,n=v(N),{isPro:o}=n;return s.jsxs("div",{className:"flx mt-2 mr-1",children:[s.jsxs("div",{className:"flx integ-fld-wrp",children:[s.jsxs("select",{className:"btcd-paper-inp mr-2",name:"formField",value:c.formField||"",onChange:e=>u(e,i,l,a),children:[s.jsx("option",{value:"",children:t("Select Field")}),s.jsx("optgroup",{label:"Form Fields",children:j.map(e=>e.type!=="file-up"&&s.jsx("option",{value:e.key,children:e.name},`ff-zhcrm-${e.key}`))}),s.jsx("option",{value:"custom",children:t("Custom...")}),s.jsx("optgroup",{label:`General Smart Codes ${o?"":"(PRO)"}`,children:o&&((h=V)==null?void 0:h.map(e=>s.jsx("option",{value:e.name,children:e.label},`ff-rm-${e.name}`)))})]}),c.formField==="custom"&&s.jsx(w,{onChange:e=>$(e,i,l,a),label:t("Custom Value"),className:"mr-2",type:"text",value:c.customValue,placeholder:t("Custom Value")}),s.jsxs("select",{className:"btcd-paper-inp",name:"zohoFormField",value:c.zohoFormField||"",disabled:!r,onChange:e=>u(e,i,l,a),children:[s.jsx("option",{value:"",children:t("Select Field")}),r?((x=(d=(p=l==null?void 0:l.default)==null?void 0:p.fields)==null?void 0:d[l.list])==null?void 0:x.fields)&&l.default.fields[l.list].fields.map(e=>e!=="Contact Email"&&s.jsx("option",{value:e,children:e},`${e}-1`)):s.jsx("option",{value:"Contact Email",children:t("Contact Email")},"contact_email")]})]}),s.jsx("button",{onClick:()=>F(i,l,a),className:"icn-btn sh-sm ml-2 mr-1",type:"button",children:"+"}),r&&s.jsx("button",{onClick:()=>R(i,l,a),className:"icn-btn sh-sm ml-1",type:"button","aria-label":"btn",children:s.jsx(y,{})})]})}function O({formID:i,formFields:j,handleInput:c,marketingHubConf:l,setMarketingHubConf:a,isLoading:r,setisLoading:n,setSnackbar:o}){var m,h,p;return s.jsxs(s.Fragment,{children:[s.jsx("br",{}),s.jsx("b",{className:"wdt-100 d-in-b",children:t("List:")}),s.jsxs("select",{onChange:d=>c(d),name:"list",value:l.list,className:"btcd-paper-inp w-7",children:[s.jsx("option",{value:"",children:t("Select List")}),((m=l==null?void 0:l.default)==null?void 0:m.lists)&&Object.values(l.default.lists).map(d=>s.jsx("option",{value:d.listkey,children:d.listname},d.listkey))]}),s.jsx("button",{onClick:()=>_(i,l,a,n,o),className:"icn-btn sh-sm ml-2 mr-2 tooltip",style:{"--tooltip-txt":`'${t("Refresh MarketingHub Lists")}'`},type:"button",disabled:r,children:"↻"}),s.jsx("br",{}),s.jsx("br",{}),r&&s.jsx(b,{style:{display:"flex",justifyContent:"center",alignItems:"center",height:100,transform:"scale(0.7)"}}),l.list&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"mt-4",children:[s.jsx("b",{className:"wdt-100",children:t("Map Fields")}),s.jsx("button",{onClick:()=>z(i,l,a,n,o),className:"icn-btn sh-sm ml-2 mr-2 tooltip",style:{"--tooltip-txt":`'${t("Refresh MarketingHub Contact Fields")}'`},type:"button",disabled:r,children:"↻"})]}),s.jsx("div",{className:"btcd-hr mt-1"}),((p=(h=l.default)==null?void 0:h.fields)==null?void 0:p[l.list])&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flx flx-around mt-2 mb-1",children:[s.jsx("div",{className:"txt-dp",children:s.jsx("b",{children:t("Form Fields")})}),s.jsx("div",{className:"txt-dp",children:s.jsx("b",{children:t("Zoho Fields")})})]}),l.field_map.map((d,x)=>s.jsx(E,{i:x,field:d,marketingHubConf:l,formFields:j,setMarketingHubConf:a},`marketingHub-m-${x+9}`)),s.jsx("div",{className:"txt-center  mt-2",style:{marginRight:85},children:s.jsx("button",{onClick:()=>F(l.field_map.length,l,a),className:"icn-btn sh-sm",type:"button",children:"+"})})]})]})]})}export{O as Z};
