var P=Object.defineProperty;var D=Object.getOwnPropertySymbols;var V=Object.prototype.hasOwnProperty,I=Object.prototype.propertyIsEnumerable;var S=(a,t,s)=>t in a?P(a,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[t]=s,v=(a,t)=>{for(var s in t||(t={}))V.call(t,s)&&S(a,s,t[s]);if(D)for(var s of D(t))I.call(t,s)&&S(a,s,t[s]);return a};import{j as o,_ as i,z as r}from"./main.2.9.0.js";import{u as L,b as c}from"./react-router.DMwpH23k.js";import"./CopyIcn.CEA_lFLo.js";import{S as R}from"./SnackMsg.DYSD96P4.js";import{S as A}from"./Steps.BYe8zHkm.js";import{I as C,g as w}from"./Integrations.DL8wqGct.js";import{T as n,c as f}from"./dokanCommonFunctions.pnvssYPY.js";import{D as M}from"./DokanIntegLayout.ByacbM_l.js";import O from"./DokanAuthorization.yqcJNoIL.js";import"./react-vendor.P7K3d6op.js";import"./Note.NSUdvR3c.js";import"./Table.BfF8RYFZ.js";import"./index.DpWdl9V1.js";import"./TagifyInput.KPPRQJ1B.js";import"./lodash.DCvQBX3r.js";import"./TutorialLink.CFG7bS5c.js";function se({formFields:a,setFlow:t,flow:s,allIntegURL:u}){const g=L(),[_,E]=c.useState(!1),[T,b]=c.useState({auth:!1,euFields:!1,vendors:!1}),[d,k]=c.useState(1),[j,m]=c.useState({show:!1}),[e,p]=c.useState({name:"Dokan",type:"Dokan",field_map:[],staticFields:[],selectedTask:"",vendors:[],selectedVendor:"",actions:{},deleteVendorFieldMap:!1,selectedPaymentMethod:""}),N=()=>{E(!0),w(s,t,u,e,g,"","",E).then(l=>{var x;l.success?(r.success((x=l.data)==null?void 0:x.msg),g(u)):r.error(l.data||l)})},y=h=>{if(setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),!e.selectedTask){r.error(i("Please select a task!","bit-integrations"));return}if((e.selectedTask===n.UPDATE_VENDOR||e.selectedTask===n.WITHDRAW_REQUEST)&&!e.selectedVendor){r.error(i("Please select a vendor!","bit-integrations"));return}if(e.selectedTask!==n.DELETE_VENDOR&&!f(e)){r.error(i("Please map mandatory fields!","bit-integrations"));return}if(e.selectedTask===n.DELETE_VENDOR&&!e.selectedVendor&&!f(e)){r.error(i("Please select a topic or map fields!","bit-integrations"));return}if(e.selectedTask===n.WITHDRAW_REQUEST&&!e.selectedPaymentMethod){r.error(i("Please select a payment method!","bit-integrations"));return}e.field_map.length>0&&k(h)};return o.jsxs("div",{children:[o.jsx(R,{snack:j,setSnackbar:m}),o.jsx("div",{className:"txt-center mt-2",children:o.jsx(A,{step:3,active:d})}),o.jsx(O,{dokanConf:e,setDokanConf:p,step:d,setStep:k,loading:T,setLoading:b,setSnackbar:m}),o.jsxs("div",{className:"btcd-stp-page",style:v({},d===2&&{width:900,height:"auto",overflow:"visible"}),children:[o.jsx(M,{formFields:a,dokanConf:e,setDokanConf:p,loading:T,setLoading:b,setSnackbar:m}),o.jsxs("button",{onClick:()=>y(3),disabled:(e==null?void 0:e.selectedTask)!==n.DELETE_VENDOR&&!f(e),className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[i("Next","bit-integrations"),"  ",o.jsx("div",{className:"btcd-icn icn-arrow_back rev-icn d-in-b"})]})]}),o.jsx(C,{step:d,saveConfig:()=>N(),isLoading:_,dataConf:e,setDataConf:p,formFields:a})]})}export{se as default};
