var y=Object.defineProperty;var D=Object.getOwnPropertySymbols;var P=Object.prototype.hasOwnProperty,V=Object.prototype.propertyIsEnumerable;var v=(a,t,s)=>t in a?y(a,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[t]=s,S=(a,t)=>{for(var s in t||(t={}))P.call(t,s)&&v(a,s,t[s]);if(D)for(var s of D(t))V.call(t,s)&&v(a,s,t[s]);return a};import{u as I,r as i,j as o}from"./main-333.js";import{d as L,_ as R,I as A,F as C,c as r}from"./bi.636.93.js";import{S as w}from"./bi.563.969.js";import{T as n,c as m}from"./bi.202.966.js";import{D as M}from"./bi.687.965.js";import F from"./bi.664.355.js";import"./bi.535.730.js";import"./bi.286.731.js";import"./bi.318.783.js";function J({formFields:a,setFlow:t,flow:s,allIntegURL:f}){const u=I(),[_,g]=i.useState(!1),[E,T]=i.useState({auth:!1,euFields:!1,vendors:!1}),[c,k]=i.useState(1),[b,l]=i.useState({show:!1}),[e,p]=i.useState({name:"Dokan",type:"Dokan",field_map:[],staticFields:[],selectedTask:"",vendors:[],selectedVendor:"",actions:{},deleteVendorFieldMap:!1,selectedPaymentMethod:""}),j=()=>{g(!0),C(s,t,f,e,u,"","",g).then(d=>{var x;d.success?(r.success((x=d.data)==null?void 0:x.msg),u(f)):r.error(d.data||d)})},N=h=>{if(setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),!e.selectedTask){r.error("Please select a task!");return}if((e.selectedTask===n.UPDATE_VENDOR||e.selectedTask===n.WITHDRAW_REQUEST)&&!e.selectedVendor){r.error("Please select a vendor!");return}if(e.selectedTask!==n.DELETE_VENDOR&&!m(e)){r.error("Please map mandatory fields!");return}if(e.selectedTask===n.DELETE_VENDOR&&!e.selectedVendor&&!m(e)){r.error("Please select a topic or map fields!");return}if(e.selectedTask===n.WITHDRAW_REQUEST&&!e.selectedPaymentMethod){r.error("Please select a payment method!");return}e.field_map.length>0&&k(h)};return o.jsxs("div",{children:[o.jsx(L,{snack:b,setSnackbar:l}),o.jsx("div",{className:"txt-center mt-2",children:o.jsx(w,{step:3,active:c})}),o.jsx(F,{dokanConf:e,setDokanConf:p,step:c,setStep:k,loading:E,setLoading:T,setSnackbar:l}),o.jsxs("div",{className:"btcd-stp-page",style:S({},c===2&&{width:900,height:"auto",overflow:"visible"}),children:[o.jsx(M,{formFields:a,dokanConf:e,setDokanConf:p,loading:E,setLoading:T,setSnackbar:l}),o.jsxs("button",{onClick:()=>N(3),disabled:(e==null?void 0:e.selectedTask)!==n.DELETE_VENDOR&&!m(e),className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[R("Next","bit-integrations"),"  ",o.jsx("div",{className:"btcd-icn icn-arrow_back rev-icn d-in-b"})]})]}),o.jsx(A,{step:c,saveConfig:()=>j(),isLoading:_,dataConf:e,setDataConf:p,formFields:a})]})}export{J as default};
