var I=Object.defineProperty;var v=Object.getOwnPropertySymbols;var C=Object.prototype.hasOwnProperty,E=Object.prototype.propertyIsEnumerable;var j=(a,e,s)=>e in a?I(a,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[e]=s,S=(a,e)=>{for(var s in e||(e={}))C.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{u as F,r as o,j as i}from"./main-406.js";import{d as L,_ as T,I as M,G as P,c as l}from"./bi.394.85.js";import{S as z}from"./bi.68.941.js";import A from"./bi.909.328.js";import{c as _}from"./bi.721.913.js";import{N as B}from"./bi.122.914.js";import"./bi.150.760.js";function R({formFields:a,setFlow:e,flow:s,allIntegURL:p}){const u=F(),[g,c]=o.useState(!1),[f,b]=o.useState({}),[n,x]=o.useState(1),[k,m]=o.useState({show:!1}),[t,d]=o.useState({name:"Nimble",type:"Nimble",api_key:"",field_map:[{formField:"",nimbleFormField:""}],actionName:"",actions:{}}),y=()=>{c(!0),P(s,e,p,t,u,"","",c).then(r=>{var h;r.success?(l.success((h=r.data)==null?void 0:h.msg),u(p)):l.error(r.data||r)})},w=N=>{if(setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),!_(t)){l.error("Please map mandatory fields");return}t.field_map.length>0&&x(N)};return i.jsxs("div",{children:[i.jsx(L,{snack:k,setSnackbar:m}),i.jsx("div",{className:"txt-center mt-2",children:i.jsx(z,{step:3,active:n})}),i.jsx(A,{nimbleConf:t,setNimbleConf:d,step:n,setStep:x,loading:f,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:d,loading:f,setLoading:b,isLoading:g,setIsLoading:c,setSnackbar:m}),(t==null?void 0:t.actionName)&&i.jsxs("button",{onClick:()=>w(3),disabled:!_(t),className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[T("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:()=>y(),isLoading:g,dataConf:t,setDataConf:d,formFields:a})]})}export{R as default};
