var E=Object.defineProperty;var P=Object.getOwnPropertySymbols;var S=Object.prototype.hasOwnProperty,k=Object.prototype.propertyIsEnumerable;var j=(l,s,i)=>s in l?E(l,s,{enumerable:!0,configurable:!0,writable:!0,value:i}):l[s]=i,m=(l,s)=>{for(var i in s||(s={}))S.call(s,i)&&j(l,i,s[i]);if(P)for(var i of P(s))k.call(s,i)&&j(l,i,s[i]);return l};import{j as t,_ as r,L as w}from"./main.2.8.1.js";import{x as o,a9 as O}from"./Note.BeM7sN-p.js";import{a as I,h as L}from"./Integrations.D2bgBas2.js";import{T as R}from"./TagifyInput.Cu0YIRbG.js";import{a as $,T as d,g as F,b as A,P as _,v as D,d as T,e as M,C as W}from"./VoxelCommonFunctions.PIi6EewD.js";const y=(l,s,i)=>{const a=m({},s);a.field_map.splice(l,0,{}),i(m({},a))},U=(l,s,i)=>{const a=m({},s);a.field_map.length>1&&a.field_map.splice(l,1),i(m({},a))},N=(l,s,i,a)=>{const n=m({},i);n.field_map[s][l.target.name]=l.target.value,l.target.value==="custom"&&(n.field_map[s].customValue=""),a(m({},n))};function x({i:l,formFields:s,field:i,voxelConf:a,setVoxelConf:n}){var h,b;const p=(a==null?void 0:a.voxelFields.filter(e=>e.required===!0))||[],g=((h=a==null?void 0:a.voxelFields)==null?void 0:h.filter(e=>e.required===!1))||[];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:i.formField||"",onChange:e=>N(e,l,a,n),children:[t.jsx("option",{value:"",children:r("Select Field","bit-integrations")}),t.jsx("optgroup",{label:r("Form Fields","bit-integrations"),children:s==null?void 0:s.map(e=>t.jsx("option",{value:e.name,children:e.label},`ff-rm-${e.name}`))}),t.jsx("option",{value:"custom",children:r("Custom...","bit-integrations")}),t.jsx("optgroup",{label:"General Smart Codes",children:(b=I)==null?void 0:b.map(e=>t.jsx("option",{value:e.name,children:e.label},`ff-rm-${e.name}`))})]}),i.formField==="custom"&&t.jsx(R,{onChange:e=>L(e,l,a,n),label:r("Custom Value","bit-integrations"),className:"mr-2",type:"text",value:i.customValue,placeholder:r("Custom Value","bit-integrations"),formFields:s}),t.jsxs("select",{className:"btcd-paper-inp",disabled:l<p.length,name:"voxelField",value:l<p?p[l].label||"":i.voxelField||"",onChange:e=>N(e,l,a,n),children:[t.jsx("option",{value:"",children:r("Select Field","bit-integrations")}),l<p.length?t.jsx("option",{value:p[l].key,children:p[l].label},p[l].key):g.map(({key:e,label:c})=>t.jsx("option",{value:e,children:c},e))]})]}),t.jsx("div",{className:"flx integ-fld-wrp",children:l>=p.length&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>y(l,a,n),className:"icn-btn sh-sm ml-2 mr-1",type:"button",children:"+"}),t.jsx("button",{onClick:()=>U(l,a,n),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,voxelConf:s,setVoxelConf:i,loading:a,setLoading:n,setSnackbar:p}){const g=e=>{const c=m({},s);if(c.selectedTask=e,c.selectedEvent="",e)switch(e){case d.NEW_POST:case d.UPDATE_POST:F(c,i,a,n);break;case d.NEW_COLLECTION_POST:case d.UPDATE_COLLECTION_POST:T(c,i,W,a,n);break;case d.NEW_PROFILE:case d.UPDATE_PROFILE:T(c,i,M,a,n);break;case d.SET_POST_VERIFIED:case d.SET_COLLECTION_POST_VERIFIED:case d.SET_PROFILE_VERIFIED:const u=D(e);c.voxelFields=u.staticFields,c.field_map=u.fieldMap;break}else c.selectedPostType="",c.field_map=[];i(m({},c))},h=(e,c)=>{const u=m({},s);u[c]=e,!e&&c==="selectedPostType"&&(u.voxelFields=[],u.field_map=[],u.posts=[],u.selectedPost=""),e&&c==="selectedPostType"&&T(u,i,e,a,n),i(m({},u))},b=`<h4>${r('If you have "recurring-date, event-date, work-hours" or any kind of image or attachment fields see the instructions below:',"bit-integrations")}</h4>
  <ul>
    <li>${r("For any kind of <strong>image, file, or other attachment,</strong> provide an <strong>attachment ID; for multiple, provide comma-separated ids.</strong>","bit-integrations")}</li>
    <li>${r("For <strong>Event Unit</strong> field, accepted values: <strong>day, week, month, year.</strong>","bit-integrations")}</li>
    <li>${r("For <strong>Work Days</strong> field, accepted values: <strong>sat, sun, mon, tue, wed, thu, fri.</strong>","bit-integrations")}</li>
    <li>${r("For <strong>Work Hours</strong> field, enter time ranges as start and end times, with a dash between them. For more than one range, separate them with commas. <strong>Example: 09:00-12:00 or 09:00-11:00, 12:00-14:00.</strong>","bit-integrations")}</li>
    <li>${r("For <strong>Work Status</strong> field, accepted values: <strong> hours, open, close, appointments_only.</strong>","bit-integrations")}</li>
    <li>${r("For <strong>Taxonomy</strong> field, provide taxonomy slug(s), separate with comma if multiple allowed.","bit-integrations")}</li>
    <li>${r("For <strong>Product & Post Relation</strong> field, provide product id and post id respectively.","bit-integrations")}</li>
    <li>${r("For <strong>Multi Select</strong> field, accepted values: <strong>array</strong> or <strong>comma-separated string</strong>.","bit-integrations")}</li>
  </ul>`;return t.jsx(t.Fragment,{children:t.jsxs("div",{children:[t.jsxs("div",{className:"flx mt-3 mb-4",children:[t.jsx("b",{className:"wdt-200 d-in-b",children:r("Select Task:","bit-integrations")}),t.jsx(o,{style:{width:"450px"},options:$,className:"msl-wrp-options",defaultValue:s==null?void 0:s.selectedTask,onChange:e=>g(e),singleSelect:!0})]}),(s.selectedTask===d.NEW_POST||s.selectedTask===d.UPDATE_POST)&&t.jsxs("div",{className:"flx mt-3 mb-4",children:[t.jsx("b",{className:"wdt-200 d-in-b",children:r("Select Post Type:","bit-integrations")}),t.jsx(o,{style:{width:"450px"},options:s==null?void 0:s.postTypes,className:"msl-wrp-options",defaultValue:s==null?void 0:s.selectedPostType,onChange:e=>h(e,"selectedPostType"),disabled:a.postTypes,singleSelect:!0}),t.jsx("button",{onClick:()=>F(s,i,a,n),className:"icn-btn sh-sm ml-2 mr-2 tooltip",style:{"--tooltip-txt":`'${r("Refresh Post Types","bit-integrations")}'`},disabled:a.postTypes,type:"button",children:"↻"})]}),(s.selectedTask===d.UPDATE_POST||s.selectedTask===d.UPDATE_COLLECTION_POST)&&t.jsxs("div",{className:"flx mt-3 mb-4",children:[t.jsx("b",{className:"wdt-200 d-in-b",children:r("Select Post:","bit-integrations")}),t.jsx(o,{style:{width:"450px"},options:s.posts,className:"msl-wrp-options",defaultValue:s==null?void 0:s.selectedPost,onChange:e=>h(e,"selectedPost"),disabled:a.posts||a.postTypes||a.postFields,singleSelect:!0}),t.jsx("button",{onClick:()=>A(s,i,s.selectedPostType,a,n),className:"icn-btn sh-sm ml-2 mr-2 tooltip",style:{"--tooltip-txt":`'${r("Refresh Posts","bit-integrations")}'`},disabled:a.posts||a.postTypes||a.postFields||!s.selectedPostType,type:"button",children:"↻"})]}),_.includes(s.selectedTask)&&t.jsxs("div",{className:"flx mt-3 mb-4",children:[t.jsx("b",{className:"wdt-200 d-in-b",children:r("Select Post Status:","bit-integrations")}),t.jsx(o,{style:{width:"450px"},options:[{value:"publish",label:"Publish"},{value:"draft",label:"Draft"},{value:"pending",label:"Pending"}],className:"msl-wrp-options",defaultValue:s==null?void 0:s.selectedPostStatus,onChange:e=>h(e,"selectedPostStatus"),singleSelect:!0})]}),(a.postTypes||a.postFields||a.posts)&&t.jsx(w,{style:{display:"flex",justifyContent:"center",alignItems:"center",height:45,transform:"scale(0.5)"}}),t.jsx("div",{className:"mt-5",children:t.jsx("b",{className:"wdt-100",children:r("Field Map","bit-integrations")})}),t.jsx("br",{}),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:r("Form Fields","bit-integrations")})}),t.jsx("div",{className:"txt-dp",children:t.jsx("b",{children:r("The Events Calendar Fields","bit-integrations")})})]}),s.selectedTask&&(s==null?void 0:s.field_map.map((e,c)=>t.jsx(x,{i:c,field:e,voxelConf:s,formFields:l,setVoxelConf:i,setSnackbar:p},`rp-m-${c+9}`))),(s==null?void 0:s.selectedTask)&&s.field_map.length!==0&&t.jsx("div",{className:"txt-center btcbi-field-map-button mt-2",children:t.jsx("button",{onClick:()=>y(s.field_map.length,s,i),className:"icn-btn sh-sm",type:"button",children:"+"})}),(_.includes(s.selectedTask)||s.selectedTask===d.NEW_PROFILE||s.selectedTask===d.UPDATE_PROFILE)&&t.jsx(O,{note:b,isInstruction:!0,isHeadingNull:!1,maxWidth:"100%"})]})})}export{z as V};
