var E=Object.defineProperty;var P=Object.getOwnPropertySymbols;var S=Object.prototype.hasOwnProperty,k=Object.prototype.propertyIsEnumerable;var j=(l,t,i)=>t in l?E(l,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):l[t]=i,m=(l,t)=>{for(var i in t||(t={}))S.call(t,i)&&j(l,i,t[i]);if(P)for(var i of P(t))k.call(t,i)&&j(l,i,t[i]);return l};import{j as s,_ as r,L as w}from"./main.2.9.0.js";import{u as o}from"./CopyIcn.CEA_lFLo.js";import{a as O,h as I}from"./Integrations.DL8wqGct.js";import{T as L}from"./TagifyInput.KPPRQJ1B.js";import{a as R,T as d,g as F,b as $,P as _,v as A,d as T,e as D,C as M}from"./VoxelCommonFunctions.4nW0KITs.js";import{a9 as W}from"./Note.NSUdvR3c.js";const y=(l,t,i)=>{const a=m({},t);a.field_map.splice(l,0,{}),i(m({},a))},U=(l,t,i)=>{const a=m({},t);a.field_map.length>1&&a.field_map.splice(l,1),i(m({},a))},N=(l,t,i,a)=>{const n=m({},i);n.field_map[t][l.target.name]=l.target.value,l.target.value==="custom"&&(n.field_map[t].customValue=""),a(m({},n))};function x({i:l,formFields:t,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 s.jsx("div",{className:"flx mt-2 mb-2 btcbi-field-map",children:s.jsxs("div",{className:"pos-rel flx",children:[s.jsxs("div",{className:"flx integ-fld-wrp",children:[s.jsxs("select",{className:"btcd-paper-inp mr-2",name:"formField",value:i.formField||"",onChange:e=>N(e,l,a,n),children:[s.jsx("option",{value:"",children:r("Select Field","bit-integrations")}),s.jsx("optgroup",{label:r("Form Fields","bit-integrations"),children:t==null?void 0:t.map(e=>s.jsx("option",{value:e.name,children:e.label},`ff-rm-${e.name}`))}),s.jsx("option",{value:"custom",children:r("Custom...","bit-integrations")}),s.jsx("optgroup",{label:"General Smart Codes",children:(b=O)==null?void 0:b.map(e=>s.jsx("option",{value:e.name,children:e.label},`ff-rm-${e.name}`))})]}),i.formField==="custom"&&s.jsx(L,{onChange:e=>I(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:t}),s.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:[s.jsx("option",{value:"",children:r("Select Field","bit-integrations")}),l<p.length?s.jsx("option",{value:p[l].key,children:p[l].label},p[l].key):g.map(({key:e,label:c})=>s.jsx("option",{value:e,children:c},e))]})]}),s.jsx("div",{className:"flx integ-fld-wrp",children:l>=p.length&&s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:()=>y(l,a,n),className:"icn-btn sh-sm ml-2 mr-1",type:"button",children:"+"}),s.jsx("button",{onClick:()=>U(l,a,n),className:"icn-btn sh-sm ml-1",type:"button","aria-label":"btn",children:s.jsx("span",{className:"btcd-icn icn-trash-2"})})]})})]})})}function B({formFields:l,voxelConf:t,setVoxelConf:i,loading:a,setLoading:n,setSnackbar:p}){const g=e=>{const c=m({},t);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,M,a,n);break;case d.NEW_PROFILE:case d.UPDATE_PROFILE:T(c,i,D,a,n);break;case d.SET_POST_VERIFIED:case d.SET_COLLECTION_POST_VERIFIED:case d.SET_PROFILE_VERIFIED:const u=A(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({},t);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 s.jsx(s.Fragment,{children:s.jsxs("div",{children:[s.jsxs("div",{className:"flx mt-3 mb-4",children:[s.jsx("b",{className:"wdt-200 d-in-b",children:r("Select Task:","bit-integrations")}),s.jsx(o,{style:{width:"450px"},options:R,className:"msl-wrp-options",defaultValue:t==null?void 0:t.selectedTask,onChange:e=>g(e),singleSelect:!0})]}),(t.selectedTask===d.NEW_POST||t.selectedTask===d.UPDATE_POST)&&s.jsxs("div",{className:"flx mt-3 mb-4",children:[s.jsx("b",{className:"wdt-200 d-in-b",children:r("Select Post Type:","bit-integrations")}),s.jsx(o,{style:{width:"450px"},options:t==null?void 0:t.postTypes,className:"msl-wrp-options",defaultValue:t==null?void 0:t.selectedPostType,onChange:e=>h(e,"selectedPostType"),disabled:a.postTypes,singleSelect:!0}),s.jsx("button",{onClick:()=>F(t,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:"↻"})]}),(t.selectedTask===d.UPDATE_POST||t.selectedTask===d.UPDATE_COLLECTION_POST)&&s.jsxs("div",{className:"flx mt-3 mb-4",children:[s.jsx("b",{className:"wdt-200 d-in-b",children:r("Select Post:","bit-integrations")}),s.jsx(o,{style:{width:"450px"},options:t.posts,className:"msl-wrp-options",defaultValue:t==null?void 0:t.selectedPost,onChange:e=>h(e,"selectedPost"),disabled:a.posts||a.postTypes||a.postFields,singleSelect:!0}),s.jsx("button",{onClick:()=>$(t,i,t.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||!t.selectedPostType,type:"button",children:"↻"})]}),_.includes(t.selectedTask)&&s.jsxs("div",{className:"flx mt-3 mb-4",children:[s.jsx("b",{className:"wdt-200 d-in-b",children:r("Select Post Status:","bit-integrations")}),s.jsx(o,{style:{width:"450px"},options:[{value:"publish",label:"Publish"},{value:"draft",label:"Draft"},{value:"pending",label:"Pending"}],className:"msl-wrp-options",defaultValue:t==null?void 0:t.selectedPostStatus,onChange:e=>h(e,"selectedPostStatus"),singleSelect:!0})]}),(a.postTypes||a.postFields||a.posts)&&s.jsx(w,{style:{display:"flex",justifyContent:"center",alignItems:"center",height:45,transform:"scale(0.5)"}}),s.jsx("div",{className:"mt-5",children:s.jsx("b",{className:"wdt-100",children:r("Field Map","bit-integrations")})}),s.jsx("br",{}),s.jsx("div",{className:"btcd-hr mt-1"}),s.jsxs("div",{className:"flx flx-around mt-2 mb-2 btcbi-field-map-label",children:[s.jsx("div",{className:"txt-dp",children:s.jsx("b",{children:r("Form Fields","bit-integrations")})}),s.jsx("div",{className:"txt-dp",children:s.jsx("b",{children:r("The Events Calendar Fields","bit-integrations")})})]}),t.selectedTask&&(t==null?void 0:t.field_map.map((e,c)=>s.jsx(x,{i:c,field:e,voxelConf:t,formFields:l,setVoxelConf:i,setSnackbar:p},`rp-m-${c+9}`))),(t==null?void 0:t.selectedTask)&&t.field_map.length!==0&&s.jsx("div",{className:"txt-center btcbi-field-map-button mt-2",children:s.jsx("button",{onClick:()=>y(t.field_map.length,t,i),className:"icn-btn sh-sm",type:"button",children:"+"})}),(_.includes(t.selectedTask)||t.selectedTask===d.NEW_PROFILE||t.selectedTask===d.UPDATE_PROFILE)&&s.jsx(W,{note:b,isInstruction:!0,isHeadingNull:!1,maxWidth:"100%"})]})})}export{B as V};
