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