import{_ as t,j as a,z as y}from"./main.2.8.10.js";import{u as k,e as N,b as r}from"./react-router.DMwpH23k.js";import"./CopyIcn.BnhKHfEP.js";import{B as C}from"./BackIcn.BFDZx8No.js";import{S as A}from"./SnackMsg.7BjcJK1j.js";import{S as _}from"./Steps.B84Ui3GU.js";import{l as w,I as E,s as M}from"./Integrations.BFhED4ck.js";import{h as T,c as z}from"./SalesforceCommonFunc.D4mXgs8x.js";import{S as L}from"./SalesforceIntegLayout.Dqm9a_SQ.js";import P from"./SalesforceAuthorization.C373QtLX.js";import"./react-vendor.P7K3d6op.js";import"./Note.DalStCGz.js";import"./Table.DSsAy4VI.js";import"./index.DpWdl9V1.js";import"./TagifyInput.C4ilRm4k.js";import"./lodash.DCvQBX3r.js";import"./ActionProFeatureLabels.BzMNdAoD.js";import"./TutorialLink.D6K_DiHL.js";function ee({formFields:b,setFlow:g,flow:v,allIntegURL:f}){const S=k(),{formID:m}=N(),[o,c]=r.useState(!1),[n,p]=r.useState(1),[x,s]=r.useState({show:!1}),u=[{label:t("Create Contact","bit-integrations"),value:"contact-create"},{label:t("Create lead","bit-integrations"),value:"lead-create"},{label:t("Create Account","bit-integrations"),value:"account-create"},{label:t("Create Campaign","bit-integrations"),value:"campaign-create"},{label:t("Add campaign member","bit-integrations"),value:"add-campaign-member"},{label:t("Create Task","bit-integrations"),value:"task-create"},{label:t("Oportunity Create","bit-integrations"),value:"opportunity-create"},{label:t("Event Create","bit-integrations"),value:"event-create"},{label:t("Create Case","bit-integrations"),value:"case-create"}],[e,l]=r.useState({name:"Salesforce",type:"Salesforce",clientId:"",clientSecret:"",field_map:[],selesforceActionModules:u,action_modules:u,actions:{}});r.useEffect(()=>{window.opener&&w("salesforce")},[]);const h=["contact-create","lead-create","account-create","campaign-create","opportunity-create","event-create","case-create"].includes(e==null?void 0:e.actionName),j=i=>{if(h&&!z(e)){y.error("Please map mandatory fields !");return}p(i)},I=()=>{var i,d;if((e==null?void 0:e.actionName)==="opportunity-create")return!((i=e.actions)!=null&&i.opportunityStageId);if((e==null?void 0:e.actionName)==="event-create")return!((d=e.actions)!=null&&d.eventSubjectId);if((e==null?void 0:e.actionName)==="add-campaign-member")return!e.campaignId};return a.jsxs("div",{children:[a.jsx(A,{snack:x,setSnackbar:s}),a.jsx("div",{className:"txt-center mt-2",children:a.jsx(_,{step:3,active:n})}),a.jsx(P,{formID:m,salesforceConf:e,setSalesforceConf:l,step:n,setStep:p,isLoading:o,setIsLoading:c,setSnackbar:s}),a.jsxs("div",{className:"btcd-stp-page",style:{width:n===2&&900,height:n===2&&"auto"},children:[a.jsx(L,{formID:m,formFields:b,handleInput:i=>T(i,e,l),salesforceConf:e,setSalesforceConf:l,isLoading:o,setIsLoading:c,setSnackbar:s}),a.jsxs("button",{onClick:()=>j(3),disabled:I()||o,className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[t("Next","bit-integrations"),a.jsx(C,{className:"ml-1 rev-icn"})]})]}),a.jsx(E,{step:n,saveConfig:()=>M({flow:v,setFlow:g,allIntegURL:f,navigate:S,conf:e,setIsLoading:c,setSnackbar:s})})]})}export{ee as default};
