import{n as p,f as k,d as n,k as y,l as N,o as j,g as h,c as F,q as a,j as o,e as g}from"./index-CzUo07dn.js";import{N as v,t as x,a as b}from"./NetworkForwardForm-CYTKEd4X.js";import{c as C}from"./network-forwards-DoiUK_R5.js";import{B as L}from"./BaseLayout-D6pt0Et9.js";import{H as q}from"./HelpLink-INVHAe6u.js";import{F as $}from"./FormFooterLayout-CkQ9739Z.js";import{d as A}from"./networks-AOdNDxHC.js";import"./index.esm-BBoKC3tX.js";import"./NotificationRow-IVGrYQV6.js";import"./formFields-BDRvqvBI.js";import"./ScrollableContainer-CSFAM_C4.js";const z=()=>{const d=p(),c=k(),u=n.useNotify(),f=y(),m=N(),{network:s,project:r}=j(),{data:e}=h({queryKey:[a.projects,r,a.networks,s],queryFn:()=>A(s??"",r??"")}),t=F({initialValues:{listenAddress:(e==null?void 0:e.type)!=="ovn"?"":(e==null?void 0:e.config["ipv4.address"])!=="none"?"0.0.0.0":(e==null?void 0:e.config["ipv6.address"])!=="none"?"::":"",ports:[]},validationSchema:v,onSubmit:l=>{const i=x(l);C(s??"",i,r??"").then(()=>{m.invalidateQueries({queryKey:[a.projects,r,a.networks,e,a.forwards]}),c(`/ui/project/${r}/network/${s}/forwards`),f.success(`Network forward ${i.listen_address} created.`)}).catch(w=>{t.setSubmitting(!1),u.failure("Network forward creation failed",w)})}});return o.jsxs(L,{title:o.jsx(q,{href:`${d}/howto/network_forwards/`,title:"Learn more about network forwards",children:"Create a network forward"}),contentClassName:"create-network",children:[o.jsx(b,{formik:t,network:e}),o.jsxs($,{children:[o.jsx(g,{className:"p-button--base",to:`/ui/project/${r}/network/${s}/forwards`,children:"Cancel"}),o.jsx(n.ActionButton,{loading:t.isSubmitting,disabled:!t.isValid||!t.values.listenAddress,onClick:()=>void t.submitForm(),children:"Create"})]})]})};export{z as default};
