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-BTX30BGB.js";import{N as v,t as x,a as b}from"./NetworkForwardForm-AmAZJKo8.js";import{c as C}from"./network-forwards-C9rQkTHv.js";import{B as L}from"./BaseLayout-C9qzVjMS.js";import{H as q}from"./HelpLink-kd-C01he.js";import{F as $}from"./FormFooterLayout-C8pm2C5J.js";import{d as A}from"./networks-CpaxpXQg.js";import"./index.esm-BV12eBbn.js";import"./NotificationRow-BrFpgHY8.js";import"./ClusterMemberSelector-DcVN_9Mu.js";import"./formFields-BDRvqvBI.js";import"./ScrollableContainer-BFMZMaL4.js";const G=()=>{const d=p(),c=k(),u=n.useNotify(),m=y(),f=N(),{network:s,project:e}=j(),{data:r}=h({queryKey:[a.projects,e,a.networks,s],queryFn:()=>A(s??"",e??"")}),t=F({initialValues:{listenAddress:(r==null?void 0:r.type)!=="ovn"?"":(r==null?void 0:r.config["ipv4.address"])!=="none"?"0.0.0.0":(r==null?void 0:r.config["ipv6.address"])!=="none"?"::":"",ports:[]},validationSchema:v,onSubmit:l=>{const i=x(l);C(s??"",i,e??"").then(()=>{f.invalidateQueries({queryKey:[a.projects,e,a.networks,r,a.forwards]}),c(`/ui/project/${e}/network/${s}/forwards`),m.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:r}),o.jsxs($,{children:[o.jsx(g,{className:"p-button--base",to:`/ui/project/${e}/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{G as default};
