import{_ as t,j as a,z as y}from"./main.2.8.1.js";import{u as k,h as N,d as r}from"./react-router-dom.9mCuUg3q.js";import"./Note.BeM7sN-p.js";import{B as C}from"./BackIcn._kGL_vVw.js";import{S as A}from"./SnackMsg.S8DrwLlT.js";import{S as _}from"./Steps.1hz7v9Vj.js";import{l as w,I as E,s as M}from"./Integrations.D2bgBas2.js";import{h as T,c as z}from"./SalesforceCommonFunc.NwtI-ly9.js";import{S as L}from"./SalesforceIntegLayout.B2b3rfT6.js";import P from"./SalesforceAuthorization.F4SFRWmb.js";import"./CopyIcn.3gZpHton.js";import"./Table.DAL7rcPQ.js";import"./index.wO-AxluA.js";import"./TagifyInput.Cu0YIRbG.js";import"./tagify.YxUZd8Ix.js";import"./ActionProFeatureLabels.CuihmlQ8.js";import"./tutorialLinks.kMkIDzcD.js";import"./TutorialLink.BAFX--T3.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),[h,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 x=["contact-create","lead-create","account-create","campaign-create","opportunity-create","event-create","case-create"].includes(e==null?void 0:e.actionName),j=i=>{if(x&&!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:h,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};
