import{h as p,$ as S,g as v,k as N,i as y,j as e,_ as o}from"./main.2.9.0.js";import{u as F,e as E,b as n}from"./react-router.DMwpH23k.js";import{S as M}from"./SnackMsg.DYSD96P4.js";import{u as g}from"./Note.NSUdvR3c.js";import"./CopyIcn.CEA_lFLo.js";import{S as k,I as $,s as P}from"./Integrations.DL8wqGct.js";import{h as R,c as D}from"./MailerLiteCommonFunc.4jonRfr9.js";import{M as A}from"./MailerLiteIntegLayout.CLM9hmXD.js";import"./react-vendor.P7K3d6op.js";import"./Table.BfF8RYFZ.js";import"./index.DpWdl9V1.js";import"./ProUtilHelpers.CHf_DzPf.js";import"./TagifyInput.KPPRQJ1B.js";import"./lodash.DCvQBX3r.js";function Z({allIntegURL:u}){const f=F(),{id:C}=E(),[r,T]=p(S),[t,i]=p(v),[h,q]=n.useState(!1),[x,_]=n.useState((t==null?void 0:t.name)||""),[c,m]=n.useState({list:!1,field:!1,auth:!1,group:!1}),[b,s]=n.useState({show:!1}),l=N(y),j=()=>{if(!D(t)){s({show:!0,msg:o("Please map mandatory fields","bit-integrations")});return}if((t==null?void 0:t.action)==="unassign_subscriber_from_group"&&!(t!=null&&t.selected_group_id)){s({show:!0,msg:o("Please select a group","bit-integrations")});return}P({flow:r,allIntegURL:u,conf:t,navigate:f,edit:1,setSnackbar:s})};n.useEffect(()=>{t!=null&&t.action||i(a=>g(a,d=>{d.action="add_subscriber"}))},[]);const I=a=>{_(a.target.value),i(d=>g(d,w=>{w.name=a.target.value}))};return e.jsxs("div",{style:{width:900},children:[e.jsx(M,{snack:b,setSnackbar:s}),e.jsxs("div",{className:"flx mt-3",children:[e.jsx("b",{className:"wdt-200 d-in-b",children:o("Integration Name:","bit-integrations")}),e.jsx("input",{className:"btcd-paper-inp w-5",onChange:I,name:"name",value:x,type:"text",placeholder:o("Integration Name...","bit-integrations")})]}),e.jsx("br",{}),e.jsx(k,{entity:r.triggered_entity,setSnackbar:s}),e.jsx(A,{formID:r.triggered_entity_id,formFields:l,handleInput:a=>R(a,t,i,c,m),mailerLiteConf:t,setMailerLiteConf:i,loading:c,setLoading:m,setSnackbar:s}),e.jsx($,{edit:!0,saveConfig:j,disabled:t.field_map.length<1,isLoading:h,dataConf:t,setDataConf:i,formFields:l}),e.jsx("br",{})]})}export{Z as default};
