var C=Object.defineProperty;var h=Object.getOwnPropertySymbols;var D=Object.prototype.hasOwnProperty,_=Object.prototype.propertyIsEnumerable;var g=(a,t,s)=>t in a?C(a,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[t]=s,b=(a,t)=>{for(var s in t||(t={}))D.call(t,s)&&g(a,s,t[s]);if(h)for(var s of h(t))_.call(t,s)&&g(a,s,t[s]);return a};import{j as o,_ as d}from"./main.2.8.10.js";import{u as k,e as q,b as m}from"./react-router.DMwpH23k.js";import"./CopyIcn.BnhKHfEP.js";import{S as w}from"./SnackMsg.7BjcJK1j.js";import{S as I}from"./Steps.B84Ui3GU.js";import{I as y,s as N}from"./Integrations.BFhED4ck.js";import P from"./FreshSalesAuthorization.h3nBZKrt.js";import{h as A,c as E,a as L}from"./FreshSalesCommonFunc.CZmNZVGv.js";import{F as T}from"./FreshSalesIntegLayout.D8JqaHLL.js";import"./react-vendor.P7K3d6op.js";import"./Note.DalStCGz.js";import"./Table.DSsAy4VI.js";import"./index.DpWdl9V1.js";import"./TutorialLink.D6K_DiHL.js";import"./ActionProFeatureLabels.BzMNdAoD.js";import"./TagifyInput.C4ilRm4k.js";import"./lodash.DCvQBX3r.js";function te({formFields:a,setFlow:t,flow:s,allIntegURL:x}){const S=k(),{formID:c}=q(),[u,i]=m.useState(!1),[n,f]=m.useState(1),[F,r]=m.useState({show:!1}),[e,l]=m.useState({name:"FreshSales",type:"FreshSales",api_key:"",bundle_alias:"",default:{modules:{Account:{required:!0,requiredFields:[]},Deal:{required:!0,requiredFields:[]},Contact:{required:!0,requiredFields:[]},Product:{requiredFields:[]}}},moduleData:{module:""},field_map:[{formField:"",freshSalesFormField:""}],actions:{}}),v=()=>{N({flow:s,setFlow:t,allIntegURL:x,conf:e,navigate:S,setIsLoading:i,setSnackbar:r})},j=p=>{if(setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),!E(e)){r({show:!0,msg:d("Please map mandatory fields","bit-integrations")});return}if(!L(e)){["Deal","Contact"].includes(e.moduleData.module)&&r({show:!0,msg:d("Please select a account or a contact","bit-integrations")}),e.moduleData.module==="Contacts"&&r({show:!0,msg:d("Please select a account","bit-integrations")});return}e.moduleData.module&&e.field_map.length>0&&f(p)};return o.jsxs("div",{children:[o.jsx(w,{snack:F,setSnackbar:r}),o.jsx("div",{className:"txt-center mt-2",children:o.jsx(I,{step:3,active:n})}),o.jsx(P,{formID:c,freshSalesConf:e,setFreshSalesConf:l,step:n,setstep:f,isLoading:u,setIsLoading:i,setSnackbar:r}),o.jsxs("div",{className:"btcd-stp-page",style:b({},n===2&&{width:900,height:"auto",overflow:"visible"}),children:[o.jsx(T,{formID:c,formFields:a,handleInput:p=>A(p,e,l,c,i,r),freshSalesConf:e,setFreshSalesConf:l,isLoading:u,setIsLoading:i,setSnackbar:r}),o.jsxs("button",{onClick:()=>j(3),disabled:e.moduleData.module===""||e.field_map.length<1,className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[d("Next","bit-integrations"),"  ",o.jsx("div",{className:"btcd-icn icn-arrow_back rev-icn d-in-b"})]})]}),o.jsx(y,{step:n,saveConfig:()=>v(),isLoading:u,dataConf:e,setDataConf:l,formFields:a})]})}export{te as default};
