var T=Object.defineProperty;var j=Object.getOwnPropertySymbols;var k=Object.prototype.hasOwnProperty,C=Object.prototype.propertyIsEnumerable;var y=(a,e,s)=>e in a?T(a,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[e]=s,S=(a,e)=>{for(var s in e||(e={}))k.call(e,s)&&y(a,s,e[s]);if(j)for(var s of j(e))C.call(e,s)&&y(a,s,e[s]);return a};import{j as i,_ as l,z as o}from"./main.2.8.10.js";import{u as I,b as r}from"./react-router.DMwpH23k.js";import"./CopyIcn.BnhKHfEP.js";import{S as L}from"./SnackMsg.7BjcJK1j.js";import{S as N}from"./Steps.B84Ui3GU.js";import{I as z,g as E}from"./Integrations.BFhED4ck.js";import M from"./ACPTAuthorization.cQH81By0.js";import{c as F}from"./ACPTCommonFunc.iH3r2Kh_.js";import{m as B,o as D,t as H,a as q,c as G,b as J,A as K}from"./ACPTIntegLayout.CZkO93dg.js";import"./react-vendor.P7K3d6op.js";import"./Note.DalStCGz.js";import"./Table.DSsAy4VI.js";import"./index.DpWdl9V1.js";import"./TutorialLink.D6K_DiHL.js";import"./ProUtilHelpers.CtRYkgop.js";import"./TagifyInput.C4ilRm4k.js";import"./lodash.DCvQBX3r.js";function pt({formFields:a,setFlow:e,flow:s,allIntegURL:d}){const u=I(),[g,c]=r.useState(!1),[b,f]=r.useState({}),[n,x]=r.useState(1),[P,_]=r.useState({show:!1}),[t,m]=r.useState({name:"ACPT",type:"ACPT",base_url:window.location.origin,api_key:"",field_map:[{formField:"",acptFormField:""}],label_field_map:[{formField:"",acptFormField:""}],acptFields:[],acptLabels:[],utilities:{},icon:"wordpress",capability:"manage_options",module:"",cptFields:J,cptLabels:G,taxonomyLabels:q,taxonomyFields:H,optionPageFields:D,modules:B}),w=()=>{c(!0),E(s,e,d,t,u,"","",c).then(p=>{var v;p.success?(o.success((v=p.data)==null?void 0:v.msg),u(d)):o.error(p.data||p)})},A=h=>{if(setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),!F(t)){o.error(l("Please map mandatory fields","bit-integrations"));return}if(["create_cpt","update_cpt","create_option_page","update_option_page"].includes(t.module)&&!(t!=null&&t.icon)){o.error(l("Please select Icon","bit-integrations"));return}if(["create_option_page","update_option_page"].includes(t.module)&&!(t!=null&&t.capability)){o.error(l("Please select Capability","bit-integrations"));return}t.field_map.length>0&&x(h)};return i.jsxs("div",{children:[i.jsx(L,{snack:P,setSnackbar:_}),i.jsx("div",{className:"txt-center mt-2",children:i.jsx(N,{step:3,active:n})}),i.jsx(M,{acptConf:t,setAcptConf:m,step:n,setStep:x,loading:b,setLoading:f}),i.jsxs("div",{className:"btcd-stp-page",style:S({},n===2&&{width:900,minHeight:"400px",height:"auto",overflow:"visible"}),children:[i.jsx(K,{formFields:a,acptConf:t,setAcptConf:m,loading:b,setLoading:f,isLoading:g,setIsLoading:c,setSnackbar:_}),(t==null?void 0:t.module)&&i.jsxs("button",{onClick:()=>A(3),disabled:!F(t),className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[l("Next","bit-integrations"),"  ",i.jsx("div",{className:"btcd-icn icn-arrow_back rev-icn d-in-b"})]})]}),(t==null?void 0:t.module)&&i.jsx(z,{step:n,saveConfig:()=>w(),isLoading:g,dataConf:t,setDataConf:m,formFields:a})]})}export{pt as default};
