import{_ as t,j as a,z as y}from"./main.2.9.0.js";import{u as k,e as C,b as s}from"./react-router.DMwpH23k.js";import"./CopyIcn.CEA_lFLo.js";import{B as N}from"./BackIcn._8Wofmn2.js";import{S as A}from"./SnackMsg.DYSD96P4.js";import{S as _}from"./Steps.BYe8zHkm.js";import{l as w,I as E,s as M}from"./Integrations.DL8wqGct.js";import{h as T,c as z}from"./SalesforceCommonFunc.MjYD6_iX.js";import{S as D}from"./SalesforceIntegLayout.C7SiLQvq.js";import L from"./SalesforceAuthorization.D-1c-iQ6.js";import"./react-vendor.P7K3d6op.js";import"./Note.NSUdvR3c.js";import"./Table.BfF8RYFZ.js";import"./index.DpWdl9V1.js";import"./TagifyInput.KPPRQJ1B.js";import"./lodash.DCvQBX3r.js";import"./ActionProFeatureLabels.gUp7_RXn.js";import"./TutorialLink.CFG7bS5c.js";function ee({formFields:m,setFlow:g,flow:f,allIntegURL:v}){const S=k(),{formID:p}=C(),[r,l]=s.useState(!1),[n,u]=s.useState(1),[x,o]=s.useState({show:!1}),d=[{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,c]=s.useState({name:"Salesforce",type:"Salesforce",clientId:"",clientSecret:"",field_map:[],selesforceActionModules:d,action_modules:d,actions:{}});s.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}u(i)},I=()=>{var i,b;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!((b=e.actions)!=null&&b.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:o}),a.jsx("div",{className:"txt-center mt-2",children:a.jsx(_,{step:3,active:n})}),a.jsx(L,{formID:p,salesforceConf:e,setSalesforceConf:c,step:n,setStep:u,isLoading:r,setIsLoading:l,setSnackbar:o}),a.jsxs("div",{className:"btcd-stp-page",style:{width:n===2&&900,height:n===2&&"auto"},children:[a.jsx(D,{formID:p,formFields:m,handleInput:i=>T(i,e,c),salesforceConf:e,setSalesforceConf:c,isLoading:r,setIsLoading:l,setSnackbar:o}),a.jsxs("button",{onClick:()=>j(3),disabled:I()||r,className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[t("Next","bit-integrations"),a.jsx(N,{className:"ml-1 rev-icn"})]})]}),a.jsx(E,{step:n,saveConfig:()=>M({flow:f,setFlow:g,allIntegURL:v,navigate:S,conf:e,setIsLoading:l,setSnackbar:o}),isLoading:r,dataConf:e,setDataConf:c,formFields:m})]})}export{ee as default};
