var L=Object.defineProperty;var N=Object.getOwnPropertySymbols;var M=Object.prototype.hasOwnProperty,P=Object.prototype.propertyIsEnumerable;var q=(s,t,a)=>t in s?L(s,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):s[t]=a,x=(s,t)=>{for(var a in t||(t={}))M.call(t,a)&&q(s,a,t[a]);if(N)for(var a of N(t))P.call(t,a)&&q(s,a,t[a]);return s};import{u as w,r as l,j as r}from"./main-406.js";import{d as R,_ as T,I as A,G as E,c as m}from"./bi.394.85.js";import{S as D}from"./bi.68.941.js";import z from"./bi.158.335.js";import{h as B,c as C}from"./bi.470.926.js";import{N as G}from"./bi.866.927.js";import"./bi.150.760.js";function X({formFields:s,setFlow:t,flow:a,allIntegURL:p}){const f=w(),[b,u]=l.useState(!1),[y,k]=l.useState({}),[i,h]=l.useState(1),[v,c]=l.useState({show:!1}),S=[{key:"first_name",label:"First Name",required:!0},{key:"email",label:"Email Address",required:!0},{key:"last_name",label:"Last Name",required:!1},{key:"phone",label:"Phone Number",required:!1},{key:"address_1",label:"Address 1",required:!1},{key:"city",label:"City",required:!1},{key:"state",label:"State",required:!1},{key:"postalCode",label:"Postal Code",required:!1},{key:"country",label:"Country",required:!1}],_=[{key:"name",label:"Name",required:!0},{key:"url",label:"URL",required:!1},{key:"phone",label:"Phone Number",required:!1},{key:"address_1",label:"Address 1",required:!1},{key:"city",label:"City",required:!1},{key:"state",label:"State",required:!1},{key:"postalCode",label:"Postal Code",required:!1},{key:"country",label:"Country",required:!1}],j=[{key:"description",label:"Lead Description",required:!0},{key:"dueTime",label:"Due Time",required:!1},{key:"confidence",label:"Confidence",required:!1}],[e,o]=l.useState({name:"NutshellCRM",type:"NutshellCRM",user_name:"",api_token:"",field_map:[{formField:"",nutshellCRMFormField:""}],actionName:"",actionId:"",peopleFields:S,companyFields:_,leadFields:j,actions:{}}),I=()=>{u(!0),E(a,t,p,e,f,"","",u).then(d=>{var g;d.success?(m.success((g=d.data)==null?void 0:g.msg),f(p)):m.error(d.data||d)})},F=n=>{if(setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),!C(e)){m.error("Please map mandatory fields");return}e.field_map.length>0&&h(n)};return r.jsxs("div",{children:[r.jsx(R,{snack:v,setSnackbar:c}),r.jsx("div",{className:"txt-center mt-2",children:r.jsx(D,{step:3,active:i})}),r.jsx(z,{nutshellCRMConf:e,setNutshellCRMConf:o,step:i,setStep:h,loading:y,setLoading:k,setSnackbar:c}),r.jsxs("div",{className:"btcd-stp-page",style:x({},i===2&&{width:900,height:"auto",overflow:"visible"}),children:[r.jsx(G,{formFields:s,handleInput:n=>B(n,e,o),nutshellCRMConf:e,setNutshellCRMConf:o,loading:y,setLoading:k,isLoading:b,setIsLoading:u,setSnackbar:c}),(e==null?void 0:e.actionName)&&r.jsxs("button",{onClick:()=>F(3),disabled:!C(e),className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[T("Next","bit-integrations")," "," ",r.jsx("div",{className:"btcd-icn icn-arrow_back rev-icn d-in-b"})]})]}),(e==null?void 0:e.actionName)&&r.jsx(A,{step:i,saveConfig:()=>I(),isLoading:b,dataConf:e,setDataConf:o,formFields:s})]})}export{X as default};
