import{h as f,$ as O,g as A,k,i as b,j as a,_ as r,z as t}from"./main.2.8.10.js";import{u as C,b as d}from"./react-router.DMwpH23k.js";import{S as L}from"./SnackMsg.7BjcJK1j.js";import{S as y,I as N,s as j}from"./Integrations.BFhED4ck.js";import{J as h}from"./JetEngineIntegLayout.ow97Y8ab.js";import{h as p,D as I,c as i,T as s}from"./jetEngineCommonFunctions.17QZZiM-.js";import"./react-vendor.P7K3d6op.js";import"./Note.DalStCGz.js";import"./CopyIcn.BnhKHfEP.js";import"./Table.DSsAy4VI.js";import"./index.DpWdl9V1.js";import"./TagifyInput.C4ilRm4k.js";import"./lodash.DCvQBX3r.js";function q({allIntegURL:m}){const E=C(),[l,S]=f(O),[e,o]=f(A),[u,D]=d.useState(!1),[g,P]=d.useState({auth:!1,menuPosition:!1,relationTypes:!1,cptList:!1,cctList:!1,relationList:!1}),[_,n]=d.useState({show:!1}),T=k(b),x=()=>{if(!e.selectedTask){t.error(r("Please select a task!","bit-integrations"));return}if(!I.includes(e.selectedTask)&&!i(e)){t.error(r("Please map mandatory fields!","bit-integrations"));return}if((e.selectedTask===s.CREATE_TAXONOMY||e.selectedTask===s.UPDATE_TAXONOMY)&&!e.selectedTaxPostTypes){t.error(r("Please select post type(s)!","bit-integrations"));return}if(e.selectedTask===s.CREATE_RELATION||e.selectedTask===s.UPDATE_RELATION){if(!e.relOptions.parentObject){t.error(r("Please select a parent object!","bit-integrations"));return}if(!e.relOptions.childObject){t.error(r("Please select a child object!","bit-integrations"));return}if(!e.relOptions.selectedRelationType){t.error(r("Please select a relation type!","bit-integrations"));return}}if(e.selectedTask===s.UPDATE_POST_TYPE&&!e.selectedCPT){t.error("Please select a custom post type!");return}if(e.selectedTask===s.UPDATE_CONTENT_TYPE&&!e.selectedCCT){t.error("Please select a custom content type!");return}if(e.selectedTask===s.UPDATE_TAXONOMY&&!e.selectedTaxForEdit){t.error("Please select a taxonomy!");return}if(e.selectedTask===s.UPDATE_RELATION&&!e.relOptions.selectedRelationForEdit){t.error("Please select a relation!");return}if(e.selectedTask===s.DELETE_POST_TYPE&&!e.selectedCPT&&!i(e)){t.error("Please select a custom post type or map fields!");return}if(e.selectedTask===s.DELETE_CONTENT_TYPE&&!e.selectedCCT&&!i(e)){t.error("Please select a custom content type or map fields!");return}if(e.selectedTask===s.DELETE_TAXONOMY&&!e.selectedTaxForEdit&&!i(e)){t.error("Please select a taxonomy or map fields!");return}if(e.selectedTask===s.DELETE_RELATION&&!e.relOptions.selectedRelationForEdit&&!i(e)){t.error("Please select a relation or map fields!");return}j({flow:l,allIntegURL:m,conf:e,navigate:E,edit:1,setSnackbar:n})};return a.jsxs("div",{style:{width:900},children:[a.jsx(L,{snack:_,setSnackbar:n}),a.jsxs("div",{className:"flx mt-3",children:[a.jsx("b",{className:"wdt-200 d-in-b",children:r("Integration Name:","bit-integrations")}),a.jsx("input",{className:"btcd-paper-inp w-5",onChange:c=>p(c,e,o),name:"name",defaultValue:e.name||"",type:"text",placeholder:r("Integration Name...","bit-integrations")})]}),a.jsx("br",{}),a.jsx(y,{entity:l.triggered_entity,setSnackbar:n}),a.jsx(h,{formID:l.triggered_entity_id,formFields:T,handleInput:c=>p(c,e,o),jetEngineConf:e,setJetEngineConf:o,loading:g,setLoading:P,setSnackbar:n}),a.jsx(N,{edit:!0,saveConfig:x,isLoading:u,dataConf:e,setDataConf:o,formFields:T}),a.jsx("br",{})]})}export{q as default};
