var T=Object.defineProperty;var b=Object.getOwnPropertySymbols;var V=Object.prototype.hasOwnProperty,A=Object.prototype.propertyIsEnumerable;var y=(e,t,a)=>t in e?T(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,p=(e,t)=>{for(var a in t||(t={}))V.call(t,a)&&y(e,a,t[a]);if(b)for(var a of b(t))A.call(t,a)&&y(e,a,t[a]);return e};import{c as _,V as N,_ as r,u as P,j as o,bu as $,Q as S,$ as w}from"./main-634.js";import{n as C}from"./bf-25-81.js";import{M as O}from"./bf-438-114.js";import{B as q}from"./bf-913-201.js";const E=(e,t,a,l)=>{const s=p({},a);s[e].splice(t,0,{}),l(p({},s))},I=(e,t,a,l)=>{const s=p({},a);s[e].length>1&&s[e].splice(t,1),l(p({},s))},j=(e,t,a,l,s)=>{const i=p({},l);i[e][a][t.target.name]=t.target.value,s(p({},i))},G=e=>!((e!=null&&e.post_map?e.post_map.filter(a=>!a.formField&&a.postField&&a.required):[]).length>0),Q=e=>!((e!=null&&e.acf_map?e.acf_map.filter(a=>!a.formField&&a.acfField&&a.required):[]).length>0),H=(e,t,a)=>{const l=_({post_type:e==null?void 0:e.post_type},"bitforms_get_custom_field").then(s=>{var i,c,m,f;return s!==void 0&&s.success&&((i=s==null?void 0:s.data)!=null&&i.acfFields&&t(s.data.acfFields),(c=s==null?void 0:s.data)!=null&&c.acfFile&&a(s.data.acfFile)),((m=s==null?void 0:s.data)==null?void 0:m.acfFields.length)!==0||((f=s==null?void 0:s.data)==null?void 0:f.acfFile.length)!==0?"Successfully refresh ACF Fields.":"ACF Fields not found"});N.promise(l,{success:s=>s,error:r("Error Occured"),loading:r("Loading ACF Fields...")})},J=(e,t)=>{const a=_({},"bitforms_get_post_type").then(l=>{var s,i,c;if(l&&l.success){let m=p({},e);return(s=l==null?void 0:l.data)!=null&&s.post_types&&(m=Object.values((i=l==null?void 0:l.data)==null?void 0:i.post_types),t(m)),((c=l==null?void 0:l.data)==null?void 0:c.post_types.length)!==0?"Successfully refresh Post Types.":" Post Types not found"}});N.promise(a,{success:l=>l,error:r("Error Occured"),loading:r("Loading Post Types...")})};function K({i:e,type:t,formFields:a,field:l,dataConf:s,setDataConf:i,customFields:c,fieldType:m}){var g;const f={acf:{propName:"acf_map",fldName:"acfField"},post:{propName:"post_map",fldName:"postField"},acfFile:{propName:"acf_file_map",fldName:"acfFileUpload"}},v=P(w),{isPro:h}=v,{propName:d,fldName:u}=f[t],M=(n,k)=>{const x=p({},s);x[d][k].customValue=n.target.value,i(x)},F=!!c.find(n=>n.key===l[u]&&n.required);return o.jsxs("div",{className:"flx mt-2 mr-1",children:[o.jsxs("div",{className:"flx integ-fld-wrp",children:[o.jsxs("select",{className:"btcd-paper-inp mr-2",name:"formField",value:l.formField||"",onChange:n=>j(d,n,e,s,i),children:[o.jsx("option",{value:"",children:r("Select Field")}),t!=="acfFile"?o.jsxs(o.Fragment,{children:[o.jsx(q,{formFields:a}),o.jsx("option",{value:"custom",children:r("Custom...")})]}):o.jsx("optgroup",{label:"Form Fields",children:a.map(n=>$.includes(n.type)&&o.jsx("option",{value:n.key,children:n.name},`ff-zhcrm-${n.key}`))}),m!=="file"&&o.jsx("optgroup",{label:`General Smart Codes ${h?"":"(PRO)"}`,children:h&&((g=C)==null?void 0:g.map(n=>o.jsx("option",{value:n.name,children:n.label},`ff-rm-${n.name}`)))})]}),l.formField==="custom"&&o.jsx(O,{onChange:n=>M(n,e),label:r("Custom Value"),className:"mr-2",type:"text",value:l.customValue,placeholder:r("Custom Value")}),o.jsxs("select",{className:"btcd-paper-inp",name:u,value:l[u]||"",onChange:n=>j(d,n,e,s,i),disabled:F,defaultValue:"0",children:[o.jsx("option",{value:"0",children:r("Select Field")}),c==null?void 0:c.map(n=>o.jsx("option",{value:n.key,children:`${n.name}`},`${n.key}-1`))]})]}),!F&&o.jsxs(o.Fragment,{children:[o.jsx("button",{onClick:()=>E(d,e,s,i),className:"icn-btn sh-sm ml-2 mr-1",type:"button",children:"+"}),o.jsx("button",{onClick:()=>I(d,e,s,i),className:"icn-btn sh-sm ml-1",type:"button","aria-label":"btn",children:o.jsx(S,{})})]})]})}export{K as F,E as a,Q as b,G as c,J as d,H as r};
