var B=Object.defineProperty;var q=Object.getOwnPropertySymbols;var w=Object.prototype.hasOwnProperty,_=Object.prototype.propertyIsEnumerable;var C=(t,a,l)=>a in t?B(t,a,{enumerable:!0,configurable:!0,writable:!0,value:l}):t[a]=l,h=(t,a)=>{for(var l in a||(a={}))w.call(a,l)&&C(t,l,a[l]);if(q)for(var l of q(a))_.call(a,l)&&C(t,l,a[l]);return t};import{u as I,r as s,j as i}from"./main-406.js";import{d as L,_ as T,I as E,G as A,c as n}from"./bi.394.85.js";import{S as H}from"./bi.68.941.js";import G from"./bi.185.324.js";import{c as N}from"./bi.389.905.js";import{C as M}from"./bi.519.906.js";import"./bi.150.760.js";function V({formFields:t,setFlow:a,flow:l,allIntegURL:y}){const b=I(),[c,d]=s.useState(!1),[f,m]=s.useState({}),[r,k]=s.useState(1),[x,u]=s.useState({show:!1}),P=[{label:"First Name",key:"FirstName",required:!1},{label:"Last Name",key:"LastName",required:!0},{label:"Email Address",key:"Email",required:!1},{label:"Company",key:"Company",required:!1},{label:"Phone Number",key:"Phone",required:!1},{label:"Job Title",key:"Designation",required:!1},{label:"Description",key:"Description",required:!1},{label:"Source",key:"Source",required:!1},{label:"Next Follow Up Date",key:"NextFollowUpDate",required:!1},{label:"Twitter",key:"Twitter",required:!1},{label:"LinkedIn",key:"LinkedIn",required:!1},{label:"GooglePlus",key:"GooglePlus",required:!1},{label:"Facebook",key:"Facebook",required:!1},{label:"Skype",key:"Skype",required:!1},{label:"Street",key:"Street",required:!1},{label:"City",key:"City",required:!1},{label:"State",key:"State",required:!1},{label:"Country",key:"Country",required:!1},{label:"Postal Code",key:"PostalCode",required:!1},{label:"Postal Code",key:"PostalCode",required:!1}],v=[{label:"Company Name",key:"Name",required:!0},{label:"Website",key:"Website",required:!1},{label:"Phone Number",key:"Phone",required:!1},{label:"Description",key:"Description",required:!1},{label:"Billing Street",key:"BillingStreet",required:!1},{label:"Billing City",key:"BillingCity",required:!1},{label:"Billing State",key:"BillingState",required:!1},{label:"Billing Country",key:"BillingCountry",required:!1},{label:"Billing Postal Code",key:"BillingPostalCode",required:!1},{label:"Shipping Street",key:"ShippingStreet",required:!1},{label:"Shipping City",key:"ShippingCity",required:!1},{label:"Shipping State",key:"ShippingState",required:!1},{label:"Shipping Country",key:"ShippingCountry",required:!1},{label:"Shipping Postal Code",key:"ShippingPostalCode",required:!1}],j=[{label:"Deal Name",key:"Name",required:!0},{label:"Amount",key:"Amount",required:!1},{label:"Close Date",key:"CloseDate",required:!1}],[e,p]=s.useState({name:"CompanyHub",type:"CompanyHub",sub_domain:"",api_key:"",field_map:[{formField:"",companyHubFormField:""}],actionName:"",contactFields:P,companyFields:v,dealFields:j,actions:{}}),D=()=>{d(!0),A(l,a,y,e,b,"","",d).then(o=>{var S;o.success?(n.success((S=o.data)==null?void 0:S.msg),b(y)):n.error(o.data||o)})},F=g=>{if(setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),!N(e)){n.error("Please map mandatory fields");return}if(e.actionName==="deal"&&!e.selectedStage){n.error("Please select a Deal Stage");return}e.field_map.length>0&&k(g)};return i.jsxs("div",{children:[i.jsx(L,{snack:x,setSnackbar:u}),i.jsx("div",{className:"txt-center mt-2",children:i.jsx(H,{step:3,active:r})}),i.jsx(G,{companyHubConf:e,setCompanyHubConf:p,step:r,setStep:k,loading:f,setLoading:m,setSnackbar:u}),i.jsxs("div",{className:"btcd-stp-page",style:h({},r===2&&{width:900,height:"auto",overflow:"visible"}),children:[i.jsx(M,{formFields:t,companyHubConf:e,setCompanyHubConf:p,loading:f,setLoading:m,isLoading:c,setIsLoading:d,setSnackbar:u}),(e==null?void 0:e.actionName)&&i.jsxs("button",{onClick:()=>F(3),disabled:!N(e),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"})]})]}),(e==null?void 0:e.actionName)&&i.jsx(E,{step:r,saveConfig:()=>D(),isLoading:c,dataConf:e,setDataConf:p,formFields:t})]})}export{V as default};
