import{j as i,_ as m}from"./main.2.8.10.js";import{u as h,e as j,b as o}from"./react-router.DMwpH23k.js";import"./CopyIcn.BnhKHfEP.js";import{B as I}from"./BackIcn.BFDZx8No.js";import{S}from"./SnackMsg.7BjcJK1j.js";import{I as _,g as T}from"./Integrations.BFhED4ck.js";import k from"./NotificationXAuthorization.-s8aPsJh.js";import{c as v}from"./NotificationXCommonFunc.uPzYzJMB.js";import{N as y,a as A}from"./NotificationXIntegLayout.eIDHvrPD.js";import"./react-vendor.P7K3d6op.js";import"./Note.DalStCGz.js";import"./Table.DSsAy4VI.js";import"./index.DpWdl9V1.js";import"./TutorialLink.D6K_DiHL.js";import"./ProUtilHelpers.CtRYkgop.js";import"./TagifyInput.C4ilRm4k.js";import"./lodash.DCvQBX3r.js";import"./GlobalIntegrationHelper.Belqr4OT.js";function K({formFields:d,setFlow:u,flow:g,allIntegURL:x}){const N=h(),{formID:c}=j(),[a,n]=o.useState(!1),[e,p]=o.useState(1),[b,s]=o.useState({show:!1}),[t,l]=o.useState({name:"NotificationX",type:"NotificationX",field_map:[{formField:"",notificationXField:""}],entry_map:[],actions:{},mainAction:"",selected_notification_id:"",notifications:[]}),f=r=>{if(setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),r===3){if(A.includes(t==null?void 0:t.mainAction)&&!(t!=null&&t.selected_notification_id)){s({show:!0,msg:m("Please select a notification to continue.","bit-integrations")});return}if(!v(t)){s({show:!0,msg:m("Please map all required fields to continue.","bit-integrations")});return}t.name!==""&&p(r)}else p(r)};return i.jsxs("div",{children:[i.jsx(S,{snack:b,setSnackbar:s}),i.jsx("div",{className:"txt-center mt-2"}),i.jsx(k,{formID:c,notificationXConf:t,setNotificationXConf:l,step:e,nextPage:f,isLoading:a,setIsLoading:n,setSnackbar:s}),i.jsxs("div",{className:"btcd-stp-page",style:{width:e===2&&900,height:e===2&&"auto",minHeight:e===2&&"500px"},children:[i.jsx(y,{formID:c,formFields:d,notificationXConf:t,setNotificationXConf:l,setSnackbar:s,setIsLoading:n,isLoading:a}),i.jsx("br",{}),i.jsx("br",{}),i.jsx("br",{}),i.jsxs("button",{onClick:()=>f(3),disabled:!t.mainAction,className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[m("Next","bit-integrations"),i.jsx(I,{className:"ml-1 rev-icn"})]})]}),i.jsx(_,{step:e,saveConfig:()=>T(g,u,x,t,N,"","",n),isLoading:a})]})}export{K as default};
