import{d as s,n as h,z as j,r as k,j as e,br as f,R as x,b3 as N,q as i}from"./index-lOezWVmi.js";import{N as b}from"./NotificationRow-DdxAfFhk.js";import{H as I}from"./HelpLink-8_zL-2ID.js";import{P as c}from"./PageHeader-DVTHSBni.js";import{g}from"./networks-C9MSk_NH.js";import{U}from"./UsedByItem-DaMb0MQB.js";const K=()=>{const l=s.useNotify(),{project:n}=h(),{data:o=[],error:a,isLoading:p}=j({queryKey:[i.projects,n,i.networkAllocations],queryFn:async()=>g(n??"default")});if(k.useEffect(()=>{a&&l.failure("Loading network allocations failed",a)},[a]),!n)return e.jsx(e.Fragment,{children:"Missing project"});const y=[{content:"Type",sortKey:"type",className:"type"},{content:"Used by",sortKey:"usedBy",className:"usedBy"},{content:"Address",sortKey:"address",className:"address"},{content:"Network",sortKey:"network",className:"network"},{content:"NAT",sortKey:"nat",className:"nat"},{content:"MAC address",sortKey:"hwaddress",className:"hwaddr"}],u=o.map(t=>{var m;const d=f(t.type,[t.used_by]),w=r=>t.type==="instance"?`/ui/project/${encodeURIComponent(r.project)}/instance/${encodeURIComponent(r.name)}`:t.type==="network"?`/ui/project/${encodeURIComponent(r.project)}/network/${encodeURIComponent(r.name)}`:t.type==="network-forward"?`/ui/project/${encodeURIComponent(r.project)}/network/${encodeURIComponent(r.name)}/forward`:"";return{columns:[{content:t.type,role:"cell",className:"type"},{content:e.jsx(e.Fragment,{children:d.length===1?e.jsx(U,{item:d[0],activeProject:n,type:t.type,to:w(d[0])}):t.used_by}),role:"rowheader",className:"usedBy"},{content:t.addresses,role:"cell",className:"address"},{content:e.jsx(x,{type:"network",value:t.network,to:`/ui/project/${encodeURIComponent(n)}/network/${encodeURIComponent(t.network)}`}),role:"cell",className:"network"},{content:t.nat?"Yes":"No",role:"cell",className:"nat"},{content:t.hwaddr,role:"cell",className:"hwaddr"}],sortData:{usedBy:t.used_by.toLowerCase(),address:t.addresses,type:t.type,nat:t.nat,hwaddress:t.hwaddr,network:(m=t.network)==null?void 0:m.toLowerCase()}}});return p?e.jsx(s.Spinner,{className:"u-loader",text:"Loading...",isMainComponent:!0}):e.jsxs(s.CustomLayout,{header:e.jsx(c,{children:e.jsx(c.Left,{children:e.jsx(c.Title,{children:e.jsx(I,{docPath:"/howto/network_ipam/",title:"Learn more about IPAM",children:"IP Address Management"})})})}),children:[e.jsx(b,{}),e.jsxs(s.Row,{children:[o.length>0&&e.jsx(s.ScrollableTable,{dependencies:o,tableId:"network-ipam-table",belowIds:["status-bar"],children:e.jsx(s.MainTable,{className:"network-ipam-table",id:"network-ipam-table",headers:y,rows:u,responsive:!0,sortable:!0,emptyStateMsg:"No data to display"})}),!p&&o.length===0&&e.jsxs(s.EmptyState,{className:"empty-state",image:e.jsx(s.Icon,{className:"empty-state-icon",name:"exposed"}),title:"No network allocations found",children:[e.jsx("p",{children:"There are no network allocations in this project."}),e.jsx("p",{children:e.jsx(N,{docPath:"/howto/network_ipam/",hasExternalIcon:!0,children:"Learn more about network allocations"})})]})]})]})};export{K as default};
