var I=Object.defineProperty;var v=Object.getOwnPropertySymbols;var k=Object.prototype.hasOwnProperty,P=Object.prototype.propertyIsEnumerable;var S=(a,t,s)=>t in a?I(a,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[t]=s,j=(a,t)=>{for(var s in t||(t={}))k.call(t,s)&&S(a,s,t[s]);if(v)for(var s of v(t))P.call(t,s)&&S(a,s,t[s]);return a};import{u as T,r as i,j as n}from"./main-333.js";import{d as C,_ as A,I as E,F as L,c as o}from"./bi.636.93.js";import{S as O}from"./bi.563.969.js";import M from"./bi.446.337.js";import{h as z,c as F}from"./bi.406.932.js";import{F as B}from"./bi.251.933.js";import"./bi.318.783.js";function V({formFields:a,setFlow:t,flow:s,allIntegURL:m}){const f=T(),[g,d]=i.useState(!1),[h,x]=i.useState({}),[r,b]=i.useState(1),[N,u]=i.useState({show:!1}),[e,c]=i.useState({name:"Flowlu",type:"Flowlu",api_key:"",company_name:"",field_map:[{formField:"",flowluFormField:""}],actionName:"",actionId:"",flowluFields:[],actions:{}}),w=()=>{d(!0),L(s,t,m,e,f,"","",d).then(p=>{var y;p.success?(o.success((y=p.data)==null?void 0:y.msg),f(m)):o.error(p.data||p)})},_=l=>{if(setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),!F(e)){o.error("Please map mandatory fields");return}if(e.actionName==="account"&&!e.selectedAccountType){o.error("Please select an Account Type");return}if(e.actionName==="opportunity"){if(!e.selectedPipeline){o.error("Please select a Opportunity Pipeline");return}if(!e.selectedOpportunityStage){o.error("Please select a Opportunity Stage");return}}e.field_map.length>0&&b(l)};return n.jsxs("div",{children:[n.jsx(C,{snack:N,setSnackbar:u}),n.jsx("div",{className:"txt-center mt-2",children:n.jsx(O,{step:3,active:r})}),n.jsx(M,{flowluConf:e,setFlowluConf:c,step:r,setStep:b,loading:h,setLoading:x,setSnackbar:u}),n.jsxs("div",{className:"btcd-stp-page",style:j({},r===2&&{width:900,height:"auto",overflow:"visible"}),children:[n.jsx(B,{formFields:a,handleInput:l=>z(l,e,c),flowluConf:e,setFlowluConf:c,loading:h,setLoading:x,isLoading:g,setIsLoading:d,setSnackbar:u}),(e==null?void 0:e.actionName)&&n.jsxs("button",{onClick:()=>_(3),disabled:!F(e),className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[A("Next","bit-integrations")," "," ",n.jsx("div",{className:"btcd-icn icn-arrow_back rev-icn d-in-b"})]})]}),(e==null?void 0:e.actionName)&&n.jsx(E,{step:r,saveConfig:()=>w(),isLoading:g,dataConf:e,setDataConf:c,formFields:a})]})}export{V as default};
