var C=Object.defineProperty;var v=Object.getOwnPropertySymbols;var z=Object.prototype.hasOwnProperty,E=Object.prototype.propertyIsEnumerable;var j=(a,e,s)=>e in a?C(a,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[e]=s,S=(a,e)=>{for(var s in e||(e={}))z.call(e,s)&&j(a,s,e[s]);if(v)for(var s of v(e))E.call(e,s)&&j(a,s,e[s]);return a};import{j as i,_ as k,z as d}from"./main.2.8.10.js";import{u as F,b as o}from"./react-router.DMwpH23k.js";import"./CopyIcn.BnhKHfEP.js";import{S as L}from"./SnackMsg.7BjcJK1j.js";import{S as T}from"./Steps.B84Ui3GU.js";import{I as M,g as P}from"./Integrations.BFhED4ck.js";import A from"./NimbleAuthorization.tJpYc2gv.js";import{c as y}from"./NimbleCommonFunc.Buc4BMZu.js";import{N as B}from"./NimbleIntegLayout.CKnFJspa.js";import"./react-vendor.P7K3d6op.js";import"./Note.DalStCGz.js";import"./Table.DSsAy4VI.js";import"./index.DpWdl9V1.js";import"./TutorialLink.D6K_DiHL.js";function U({formFields:a,setFlow:e,flow:s,allIntegURL:l}){const g=F(),[f,c]=o.useState(!1),[u,b]=o.useState({}),[n,x]=o.useState(1),[_,m]=o.useState({show:!1}),[t,p]=o.useState({name:"Nimble",type:"Nimble",api_key:"",field_map:[{formField:"",nimbleFormField:""}],actionName:"",actions:{}}),w=()=>{c(!0),P(s,e,l,t,g,"","",c).then(r=>{var h;r.success?(d.success((h=r.data)==null?void 0:h.msg),g(l)):d.error(r.data||r)})},I=N=>{if(setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),!y(t)){d.error(k("Please map mandatory fields","bit-integrations"));return}t.field_map.length>0&&x(N)};return i.jsxs("div",{children:[i.jsx(L,{snack:_,setSnackbar:m}),i.jsx("div",{className:"txt-center mt-2",children:i.jsx(T,{step:3,active:n})}),i.jsx(A,{nimbleConf:t,setNimbleConf:p,step:n,setStep:x,loading:u,setLoading:b,setSnackbar:m}),i.jsxs("div",{className:"btcd-stp-page",style:S({},n===2&&{width:900,height:"auto",overflow:"visible"}),children:[i.jsx(B,{formFields:a,nimbleConf:t,setNimbleConf:p,loading:u,setLoading:b,isLoading:f,setIsLoading:c,setSnackbar:m}),(t==null?void 0:t.actionName)&&i.jsxs("button",{onClick:()=>I(3),disabled:!y(t),className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[k("Next","bit-integrations"),"  ",i.jsx("div",{className:"btcd-icn icn-arrow_back rev-icn d-in-b"})]})]}),(t==null?void 0:t.actionName)&&i.jsx(M,{step:n,saveConfig:()=>w(),isLoading:f,dataConf:t,setDataConf:p,formFields:a})]})}export{U as default};
