import{a0 as w,k as b,d as n,h as N,n as h,r as L,f as j,q as i,j as o,L as C}from"./index-DET0E_3l.js";import{N as x,t as y,a as B}from"./NetworkLoadBalancerForm-wPLGoXA4.js";import{c as g}from"./network-load-balancers-MU7rOPtq.js";import{B as v}from"./BaseLayout-CzqnKJIH.js";import{H as F}from"./HelpLink-ByrgZGrN.js";import{F as S}from"./FormFooterLayout-YMKZRDmQ.js";import{u as $}from"./useNetworks-B0Ui0BRT.js";import"./NotificationRow-BgqB5Xch.js";import"./formFields-D4E6x_f1.js";import"./networks-Iph4Lp3C.js";const _=()=>{const d=w(),m=b(),c=n.useNotify(),u=n.useToastNotification(),k=N(),{network:t,project:a}=h(),{data:l,error:r}=$(t??"",a??"");L.useEffect(()=>{r&&c.failure("Loading networks failed",r)},[r]);const e=j({initialValues:{listenAddress:"",backends:[],ports:[]},validationSchema:x,onSubmit:p=>{const f=y(p);g(t??"",f,a??"").then(s=>{k.invalidateQueries({queryKey:[i.projects,a,i.networks,l,i.loadBalancers]}),m(`/ui/project/${encodeURIComponent(a??"")}/network/${encodeURIComponent(t??"")}/load-balancers`),u.success(`Network load balancer with listen address ${s} created.`)}).catch(s=>{e.setSubmitting(!1),c.failure("Network load balancer creation failed",s)})}});return o.jsxs(v,{title:o.jsx(F,{href:`${d}/howto/network_load_balancers/`,title:"Learn more about network load balancers",children:"Create a network load balancer"}),contentClassName:"create-network",children:[o.jsx(B,{formik:e,network:l}),o.jsxs(S,{children:[o.jsx(C,{className:"p-button--base",to:`/ui/project/${encodeURIComponent(a??"")}/network/${encodeURIComponent(t??"")}/load-balancers`,children:"Cancel"}),o.jsx(n.ActionButton,{loading:e.isSubmitting,disabled:!e.isValid||e.isSubmitting||!e.values.listenAddress,onClick:()=>void e.submitForm(),children:"Create"})]})]})};export{_ as default};
