import{j as e,_ as c}from"./main.2.9.0.js";import{u as j,e as C,b as i}from"./react-router.DMwpH23k.js";import"./CopyIcn.CEA_lFLo.js";import{B as F}from"./BackIcn._8Wofmn2.js";import{S}from"./SnackMsg.DYSD96P4.js";import{I,g as y}from"./Integrations.DL8wqGct.js";import _ from"./FluentCartAuthorization.DSa-PvnW.js";import{F as k,c as v}from"./FluentCartIntegLayout._M6_oNsn.js";import"./react-vendor.P7K3d6op.js";import"./Note.NSUdvR3c.js";import"./Table.BfF8RYFZ.js";import"./index.DpWdl9V1.js";import"./TutorialLink.CFG7bS5c.js";import"./ProUtilHelpers.CHf_DzPf.js";import"./TagifyInput.KPPRQJ1B.js";import"./lodash.DCvQBX3r.js";import"./GlobalIntegrationHelper.B6YI8w_n.js";function O({formFields:p,setFlow:f,flow:g,allIntegURL:x}){const h=j(),{formID:l}=C(),[n,o]=i.useState(!1),[s,u]=i.useState(1),[b,a]=i.useState({show:!1}),[t,r]=i.useState({name:"FluentCart",type:"FluentCart",field_map:[{formField:"",fluentCartField:""}],actions:{},mainAction:""}),d=m=>{if(setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),m===3){if(t.mainAction==="create_coupon"&&!(t!=null&&t.discountType)){a({show:!0,msg:c("Please select discount Type to continue.","bit-integrations")});return}if(!v(t)){a({show:!0,msg:c("Please map all required fields to continue.","bit-integrations")});return}t.name!==""&&t.field_map.length>0&&u(m)}else u(m)};return e.jsxs("div",{children:[e.jsx(S,{snack:b,setSnackbar:a}),e.jsx("div",{className:"txt-center mt-2"}),e.jsx(_,{formID:l,fluentCartConf:t,setFluentCartConf:r,step:s,nextPage:d,isLoading:n,setIsLoading:o,setSnackbar:a}),e.jsxs("div",{className:"btcd-stp-page",style:{width:s===2&&900,height:s===2&&"auto",minHeight:s===2&&"500px"},children:[e.jsx(k,{formID:l,formFields:p,fluentCartConf:t,setFluentCartConf:r,setSnackbar:a,setIsLoading:o,isLoading:n}),e.jsx("br",{}),e.jsx("br",{}),e.jsx("br",{}),e.jsxs("button",{onClick:()=>d(3),disabled:t.field_map.length<1,className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[c("Next","bit-integrations"),e.jsx(F,{className:"ml-1 rev-icn"})]})]}),e.jsx(I,{step:s,saveConfig:()=>y(g,f,x,t,h,"","",o),isLoading:n,dataConf:t,setDataConf:r,formFields:p})]})}export{O as default};
