import{k as v,g as x,j as t,_ as A,z as s}from"./main.2.8.1.js";import{u as I,h as E,d as r}from"./react-router-dom.9mCuUg3q.js";import"./Note.BeM7sN-p.js";import{B as L}from"./BackIcn._kGL_vVw.js";import{S as b}from"./Steps.1hz7v9Vj.js";import{I as j,g as C}from"./Integrations.D2bgBas2.js";import N from"./HighLevelAuthorization.BtuL5UpF.js";import{O,c as o,T as a}from"./HighLevelCommonFunc.DjRv4nFN.js";import{H as R}from"./HighLevelIntegLayout.DQtbxHSD.js";import"./CopyIcn.3gZpHton.js";import"./SnackMsg.S8DrwLlT.js";import"./Table.DAL7rcPQ.js";import"./index.wO-AxluA.js";import"./tutorialLinks.kMkIDzcD.js";import"./TutorialLink.BAFX--T3.js";import"./ProUtilHelpers.fQlR3mWW.js";import"./TagifyInput.Cu0YIRbG.js";import"./tagify.YxUZd8Ix.js";function Z({formFields:c,setFlow:f,flow:u,allIntegURL:T}){const g=v(x),{isPro:k}=g,P=I(),{formID:n}=E(),[h,S]=r.useState(!1),[i,d]=r.useState(1),[p,m]=r.useState({auth:!1,customFields:!1,options:!1,contacts:!1,users:!1,hlTasks:!1,pipelines:!1,opportunities:!1}),[e,l]=r.useState({name:"GoHighLevel",type:"GoHighLevel",api_key:"",field_map:[{formField:"",highLevelField:""}],actions:{},tags:[],version:k?"v2":"v1",highLevelFields:[],selectedTags:"",selectedTask:"",contacts:[],selectedContact:"",selectedTaskStatus:"",users:[],selectedUser:"",hlTasks:[],updateTaskId:"",pipelines:[],selectedPipeline:"",stages:[],currentStages:[],selectedStage:"",opportunities:[],selectedOpportunity:""}),_=U=>{setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300);{if(!O.includes(e.selectedTask)&&!o(e)){s.error("Please map all required fields to continue!");return}if(!(e!=null&&e.selectedTask)){s.error("Please select task to continue!");return}if(e.selectedTask===a.UPDATE_CONTACT&&!e.selectedContact&&!o(e)){s.error("Please select a contact or map fields!");return}if((e.selectedTask===a.CREATE_TASK||e.selectedTask===a.UPDATE_TASK)&&!e.selectedContact&&!o(e)){s.error("Please select a contact or map fields!");return}if(e.selectedTask===a.UPDATE_TASK&&!e.updateTaskId&&!o(e)){s.error("Please select a task or map fields!");return}if(e.selectedTask===a.CREATE_OPPORTUNITY||e.selectedTask===a.UPDATE_OPPORTUNITY){if(!e.selectedPipeline){s.error("Please select a pipeline!");return}if(!e.selectedStage){s.error("Please select a stage!");return}if(!e.selectedTaskStatus){s.error("Please select a status!");return}}e.name!==""&&e.field_map.length>0&&d(3)}};return t.jsxs("div",{children:[t.jsx("div",{className:"txt-center mt-2",children:t.jsx(b,{step:3,active:i})}),t.jsx(N,{formID:n,highLevelConf:e,setHighLevelConf:l,step:i,setstep:d,loading:p,setLoading:m}),t.jsxs("div",{className:"btcd-stp-page",style:{width:i===2&&900,height:i===2&&"auto"},children:[t.jsx(R,{formID:n,formFields:c,highLevelConf:e,setHighLevelConf:l,loading:p,setLoading:m}),t.jsxs("button",{onClick:()=>_(),disabled:!(e!=null&&e.selectedTask),className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[A("Next","bit-integrations"),"  ",t.jsx(L,{className:"ml-1 rev-icn"})]})]}),t.jsx(j,{step:i,saveConfig:()=>C(u,f,T,e,P,"","",S),isLoading:h,dataConf:e,setDataConf:l,formFields:c})]})}export{Z as default};
