@mp70/react-networks 0.2.0-beta.1 → 0.2.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +67 -7
- package/dist/index.css +75 -1
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +700 -209
- package/dist/index.d.ts +700 -209
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -1
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import ft,{useState,useMemo,useRef,useEffect,useSyncExternalStore,Component,useCallback}from'react';import {useReactFlow,Handle,Position,getBezierPath,BaseEdge,EdgeLabelRenderer,useEdges,addEdge,ReactFlowProvider,useNodesState,useEdgesState,useOnSelectionChange,ReactFlow,Background,Controls,MiniMap,Panel,applyEdgeChanges,ConnectionMode,getSmoothStepPath,SmoothStepEdge}from'reactflow';import {toPng}from'html-to-image';import {jsx,jsxs,Fragment}from'react/jsx-runtime';var Se=20,je=60,qt=300,Rt=5;function Ar(e){return e==="system"?typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: light)").matches?"light":"dark":e}function Or(e,o){let n=Ar(e)==="light"?"react-flow-light":"react-flow-dark";return o?`${n} ${o}`:n}function Br(e){return Ar(e)==="light"?"#e5e5e5":"#2a2a2a"}function Ur(e,o){return {width:"100%",height:"100%",...o}}var wi=()=>"bottom-up",ot=e=>e.data.uNumberingDirection||wi(),Jt=(e,o,t)=>t==="bottom-up"?o-e+1:e,Qt=(e,o,t)=>t==="bottom-up"?o-e+1:e;var Mo=(e,o,t,n)=>{if(!e.parentId||e.parentId!==o.id)return t;let s=e.data.uHeight||1,a=o.data.uHeight||42,l=ot(o),i=60,d=t.y-i,u=Math.round(d/20)+1,h;l==="bottom-up"?h=Jt(u,a,l)-s+1:h=Jt(u,a,l);let g=a-s+1,c=Math.max(1,Math.min(g,h));if(l==="top-down"&&h<=1&&(c=1),!Lo(o,e,c,n)){let x=eo(o,e,n,c);x!==c&&(c=x);}let f;if(l==="bottom-up"){let x=c+s-1,C=Qt(x,a,l);f=i+(C-1)*20-1;}else {let x=Qt(c,a,l);f=i+(x-1)*20-1;}return {x:t.x,y:f,uPosition:c}},Lo=(e,o,t,n)=>{let s=o.data.uHeight||1,a=e.data.uHeight||42;if(t<1||t+s-1>a)return false;let l=n.filter(i=>i.type==="device"&&i.parentId===e.id&&i.id!==o.id);for(let i of l){let d=i.data.uPosition||1,u=i.data.uHeight||1,h=t,g=t+s-1,c=d,f=d+u-1;if(h<=f&&g>=c)return false}return true},eo=(e,o,t,n=1)=>{let s=o.data.uHeight||1,a=e.data.uHeight||42;for(let l=n;l<=a-s+1;l++)if(Lo(e,o,l,t))return l;return 1},bt=(e,o,t=1)=>{let n=60,s=ot(e),a=e.data.uHeight||42,l=Qt(o,a,s),i;if(s==="bottom-up"){let d=o+t-1,u=Qt(d,a,s);i=n+(u-1)*20-1;}else i=n+(l-1)*20-1;return {x:0,y:i}},Vr=(e,o,t)=>{let n=e.data.uHeight||1,s=bt(o,t,n);return {...e,position:s,data:{...e.data,uPosition:t}}},xi=(e,o)=>{let t=e.data.uPosition||1,n=e.data.uHeight||1,s=o.data.uHeight||42,a=Math.max(1,Math.min(s-n+1,t));return a!==t?Vr(e,o,a):e};function Te(e){switch(e){case "active":return "#10b981";case "inactive":return "#6b7280";case "maintenance":return "#f59e0b";default:return "#6b7280"}}var zo=({data:e,selected:o,id:t,onViewChange:n,onRackFaceChange:s,isDragOver:a=false})=>{let{label:l,ports:i=0,status:d="active",uHeight:u=42,face:h="front",customHeaderText:g,rackWidthPx:c}=e,f=c||300,{getNodes:x,setNodes:C}=useReactFlow(),k=x(),[S,I]=useState(e.showUMarkers!==void 0?e.showUMarkers:true),E=()=>{let R=ot({data:e})==="bottom-up"?"top-down":"bottom-up";C(F=>F.map(W=>W.id===t?{...W,data:{...W.data,uNumberingDirection:R}}:W));},D=()=>{let w=h==="front"?"rear":"front";s?(s(t,w),n&&k.filter(F=>F.parentId===t).forEach(F=>{n(F.id,w);})):n?k.filter(F=>F.parentId===t).forEach(F=>{n(F.id,w);}):C(R=>R.map(F=>F.id===t?{...F,data:{...F.data,face:w}}:F.parentId===t?{...F,data:{...F.data,view:w}}:F));},m=()=>{let w=[],R=60,F=ot({data:e});for(let W=1;W<=u;W++){let L=R+(W-1)*20-4,j=Jt(W,u,F);w.push(jsx("div",{style:{position:"absolute",left:"-35px",top:`${L}px`,background:"#374151",color:"#9ca3af",padding:"2px 4px",borderRadius:"2px",fontSize:"8px",fontWeight:"bold",width:"28px",textAlign:"center",border:"1px solid #4b5563",zIndex:10,height:`${20}px`,display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1},children:j},W));}return w};return jsxs("div",{className:`rack-node ${o?"selected":""} ${a?"drag-over":""}`,style:{background:"transparent",border:`2px solid ${Te(d)}`,borderRadius:"8px",padding:0,width:`${f}px`,height:`${60+u*20}px`,color:"white",fontFamily:"monospace",fontSize:"12px",boxShadow:a?"0 0 20px #3b82f6, 0 0 40px #3b82f6, 0 0 60px #3b82f6":o?"0 0 0 2px #3b82f6":"0 2px 4px rgba(0,0,0,0.1)",position:"relative",display:"flex",flexDirection:"column",transition:"box-shadow 0.2s ease-in-out"},children:[jsxs("div",{style:{textAlign:"center",marginBottom:0,zIndex:2,background:"#1f2937",padding:"8px",position:"relative",height:`${60}px`,display:"flex",flexDirection:"column",justifyContent:"center"},children:[jsx("div",{style:{fontWeight:"bold",marginBottom:"4px"},children:l}),jsxs("div",{style:{fontSize:"10px",color:"#9ca3af"},children:[g?jsx("span",{style:{color:"#fbbf24",fontWeight:"bold"},children:g}):jsxs("span",{children:[typeof i=="number"?i:0," ports"]})," \u2022 ",u,"U \u2022 ",h]}),jsxs("div",{style:{display:"flex",gap:"4px",position:"absolute",top:"4px",right:"4px"},children:[jsx("button",{onPointerDown:w=>{w.stopPropagation();},onMouseDown:w=>{w.stopPropagation();},onClick:w=>{w.stopPropagation(),w.preventDefault(),I(!S);},style:{background:S?"#10b981":"#374151",color:S?"#ffffff":"#9ca3af",border:"1px solid #4b5563",borderRadius:"2px",padding:"2px 6px",fontSize:"8px",cursor:"pointer",fontFamily:"monospace"},title:`${S?"Hide":"Show"} U markers`,children:"U"}),jsx("button",{onPointerDown:w=>{w.stopPropagation();},onMouseDown:w=>{w.stopPropagation();},onClick:w=>{w.stopPropagation(),w.preventDefault(),E();},style:{background:"#374151",color:"#9ca3af",border:"1px solid #4b5563",borderRadius:"2px",padding:"2px 6px",fontSize:"8px",cursor:"pointer",fontFamily:"monospace"},title:`Switch U numbering to ${ot({data:e})==="bottom-up"?"top-down":"bottom-up"}`,children:ot({data:e})==="bottom-up"?"\u2191\u2193":"\u2193\u2191"}),jsx("button",{onPointerDown:w=>{w.stopPropagation();},onMouseDown:w=>{w.stopPropagation();},onClick:w=>{w.stopPropagation(),w.preventDefault(),D();},style:{background:"#374151",color:"#9ca3af",border:"1px solid #4b5563",borderRadius:"2px",padding:"2px 6px",fontSize:"8px",cursor:"pointer",fontFamily:"monospace"},title:`Switch to ${h==="front"?"rear":"front"} view`,children:h==="front"?"\u21C4 Rear":"\u21C4 Front"})]})]}),jsx("div",{style:{flex:1,background:"transparent",position:"relative",minHeight:`${u*20}px`,overflow:"hidden"}}),S&&jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none"},children:m()})]})};var Ao=({data:e,selected:o})=>{let{label:t,status:n="active"}=e;return jsxs("div",{className:`fiber-node ${o?"selected":""}`,style:{background:"#1f2937",border:`2px solid ${Te(n)}`,borderRadius:"50%",width:"60px",height:"60px",display:"flex",alignItems:"center",justifyContent:"center",color:"white",fontFamily:"monospace",fontSize:"10px",fontWeight:"bold",boxShadow:o?"0 0 0 2px #3b82f6":"0 2px 4px rgba(0,0,0,0.1)",position:"relative"},children:[jsx(Handle,{type:"target",position:Position.Top}),jsx(Handle,{type:"source",position:Position.Bottom}),jsx(Handle,{type:"target",position:Position.Left}),jsx(Handle,{type:"source",position:Position.Right}),jsx("div",{style:{textAlign:"center"},children:jsx("div",{style:{fontSize:"8px",lineHeight:"1.2"},children:t})}),jsx("div",{style:{position:"absolute",bottom:"4px",left:"50%",transform:"translateX(-50%)",width:"8px",height:"8px",background:Te(n),borderRadius:"50%"}})]})};var jr=["#1f77b4","#ff7f0e","#2ca02c","#8c564b","#708090","#ffffff","#d62728","#000000","#ffdf00","#8a2be2","#ff69b4","#00ffff"];function xe(e){let o=(e-1)%12;return jr[o]}function nt(e){return e>12}function ze(e){let o=xe(e);return nt(e)?{background:o,backgroundImage:`repeating-linear-gradient(45deg, ${o} 0 6px, #000 6px 9px)`}:{background:o}}function it(e){return xe(e)}function Ae(e){return e.map(o=>({base:xe(o),striped:nt(o)}))}function Si(e,o,t,n,s,a,l,i){let d=Ae(t),u=d.length,h=n?1.2:1,g=!!i?.highlight,c=n?2:1.5,f=i?.highlightWidth??c*3,x=i?.highlightColor??d[0]?.base??"#22d3ee";return jsxs(Fragment,{children:[g&&jsx(BaseEdge,{id:`${e}-highlight`,path:o,style:{...s,stroke:x,strokeWidth:f,opacity:.7,strokeDasharray:"14 10","--rn-edge-highlight-from":`${c}px`,"--rn-edge-highlight-to":`${f}px`}}),d.map((C,k)=>{let I=(u-k)*h;return jsx("path",{d:o,stroke:C.base,strokeWidth:I,fill:"none",strokeLinecap:"butt",opacity:C.striped?.9:1,style:s},`${e}-ribbon-${k}`)}),d.some(C=>C.striped)&&jsx(BaseEdge,{id:`${e}-ribbon-stripe`,path:o,style:{...s,stroke:"#000",strokeWidth:1,strokeDasharray:"3 3",opacity:.4}}),jsx(EdgeLabelRenderer,{children:n&&i&&(i.bandwidth||i.length)&&jsxs("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${a}px,${l}px)`,background:"#1f2937",padding:"4px 8px",borderRadius:"4px",fontSize:"10px",color:"white",fontFamily:"monospace",border:`1px solid ${d[0]?.base||"#00FFFF"}`,pointerEvents:"none",zIndex:9999},children:[i.bandwidth&&jsx("div",{children:i.bandwidth}),i.length&&jsxs("div",{children:[i.length,"m"]}),jsxs("div",{style:{fontSize:"8px",opacity:.8},children:[t.length,"F"]})]})})]})}var ro=({id:e,sourceX:o,sourceY:t,targetX:n,targetY:s,sourcePosition:a,targetPosition:l,data:i,selected:d,style:u={},className:h})=>{let[g,c,f]=getBezierPath({sourceX:o,sourceY:t,sourcePosition:a,targetX:n,targetY:s,targetPosition:l}),{bandwidth:x,length:C,color:k="#00FFFF",striped:S=false,ribbonFiberIds:I,isRibbon:E,highlight:D,highlightColor:m,highlightWidth:w}=i||{},R=!!D;if((E||I&&I.length>=6&&I.length<=12)&&I)return Si(e,g,I,d??false,u??{},c,f,i);let W=d?3:2,L=w??W*3,j={...u,stroke:k,strokeWidth:W,strokeDasharray:"none"};return jsxs(Fragment,{children:[R&&jsx(BaseEdge,{id:`${e}-highlight`,path:g,style:{...u,stroke:m??k,strokeWidth:L,opacity:.7,strokeDasharray:"14 10","--rn-edge-highlight-from":`${W}px`,"--rn-edge-highlight-to":`${L}px`}}),jsx(BaseEdge,{id:e,path:g,style:j}),S&&jsx(BaseEdge,{id:`${e}-stripe`,path:g,style:{...u,stroke:"#000",strokeWidth:1.5,strokeDasharray:"6 6",opacity:.9}}),jsx(EdgeLabelRenderer,{children:d&&i&&(x||C)&&jsxs("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${c}px,${f}px)`,background:"#1f2937",padding:"4px 8px",borderRadius:"4px",fontSize:"10px",color:"white",fontFamily:"monospace",border:`1px solid ${k}`,pointerEvents:"none",zIndex:9999},children:[x&&jsx("div",{children:x}),C&&jsxs("div",{children:[C,"m"]})]})})]})};var Oo=({id:e,sourceX:o,sourceY:t,targetX:n,targetY:s,sourcePosition:a,targetPosition:l,style:i={},data:d,markerEnd:u})=>{let[h]=getBezierPath({sourceX:o,sourceY:t,sourcePosition:a,targetX:n,targetY:s,targetPosition:l}),g=d?.connectorType||"C13";return jsx(BaseEdge,{id:e,path:h,markerEnd:u,style:(()=>{let f={stroke:d?.color||"#f59e0b",strokeWidth:g==="C19"?5:3,strokeLinecap:"round",strokeLinejoin:"round",...i};return g==="C19"?{...f,strokeDasharray:"none"}:{...f,strokeDasharray:"6,3"}})()})};function Fi(e,o,t,n,s,a,l,i,d,u,h){let g=Ae(i),c=g.length,f=d?1.8:1.5,x=!!h?.highlight,C=d?3:2.5,k=h?.highlightWidth??C*3,S=h?.highlightColor??g[0]?.base??"#22d3ee",[I,E,D]=getSmoothStepPath({sourceX:o,sourceY:t,targetX:n,targetY:s,sourcePosition:a,targetPosition:l});return jsxs(Fragment,{children:[x&&jsx(BaseEdge,{id:`${e}-highlight`,path:I,style:{...u,stroke:S,strokeWidth:k,opacity:.7,strokeDasharray:"14 10","--rn-edge-highlight-from":`${C}px`,"--rn-edge-highlight-to":`${k}px`}}),g.map((m,w)=>{let F=(c-w)*f;return jsx("path",{d:I,stroke:m.base,strokeWidth:F,fill:"none",strokeLinecap:"butt",opacity:m.striped?.9:1,style:u},`${e}-ribbon-${w}`)}),g.some(m=>m.striped)&&jsx(BaseEdge,{id:`${e}-ribbon-stripe`,path:I,style:{...u,stroke:"#000",strokeWidth:1,strokeDasharray:"3 3",opacity:.4}}),jsx(EdgeLabelRenderer,{children:d&&h&&(h.bandwidth||h.length)&&jsxs("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${E}px,${D}px)`,background:"#1f2937",padding:"4px 8px",borderRadius:"4px",fontSize:"10px",color:"white",fontFamily:"monospace",border:`1px solid ${g[0]?.base||"#00FFFF"}`,pointerEvents:"none",zIndex:9999},children:[h.bandwidth&&jsx("div",{children:h.bandwidth}),h.length&&jsxs("div",{children:[h.length,"m"]}),jsxs("div",{style:{fontSize:"8px",opacity:.8},children:[i.length,"F"]})]})})]})}var Kr=({id:e,sourceX:o,sourceY:t,targetX:n,targetY:s,sourcePosition:a,targetPosition:l,data:i,selected:d,style:u={},...h})=>{let{color:g="#00FFFF",ribbonFiberIds:c,isRibbon:f,highlight:x,highlightColor:C,highlightWidth:k}=i||{},S=!!x;if((f||c&&c.length>=6&&c.length<=12)&&c)return Fi(e,o,t,n,s,a,l,c,d??false,u??{},i);let E=d?4:3,D=k??E*3,m={...u,stroke:g,strokeWidth:E};return jsxs(Fragment,{children:[S&&jsx(BaseEdge,{id:`${e}-highlight`,path:getSmoothStepPath({sourceX:o,sourceY:t,targetX:n,targetY:s,sourcePosition:a,targetPosition:l})[0],style:{...u,stroke:C??g,strokeWidth:D,opacity:.7,strokeDasharray:"14 10","--rn-edge-highlight-from":`${E}px`,"--rn-edge-highlight-to":`${D}px`}}),jsx(SmoothStepEdge,{...h,id:e,sourceX:o,sourceY:t,targetX:n,targetY:s,sourcePosition:a,targetPosition:l,data:i,selected:d,style:m})]})};function Di({sourceX:e,sourceY:o,targetX:t,targetY:n,sourcePosition:s,targetPosition:a}){let l=s===Position.Left||s===Position.Right,i;if(l){let d=(e+t)/2;i=`M ${e},${o} L ${d},${o} L ${d},${n} L ${t},${n}`;}else {let d=(o+n)/2;i=`M ${e},${o} L ${e},${d} L ${t},${d} L ${t},${n}`;}return i}function $i(e,o,t,n,s,a){let l=Ae(t),i=l.length,d=n?1.2:1,u=!!a?.highlight,h=n?2:1.5,g=a?.highlightWidth??h*3,c=a?.highlightColor??l[0]?.base??"#22d3ee",f=o.match(/M\s+([\d.]+),([\d.]+).*L\s+([\d.]+),([\d.]+)/),x=f?(parseFloat(f[1])+parseFloat(f[3]))/2:0,C=f?(parseFloat(f[2])+parseFloat(f[4]))/2:0;return jsxs(Fragment,{children:[u&&jsx(BaseEdge,{id:`${e}-highlight`,path:o,style:{...s,stroke:c,strokeWidth:g,opacity:.7,strokeDasharray:"14 10","--rn-edge-highlight-from":`${h}px`,"--rn-edge-highlight-to":`${g}px`}}),l.map((k,S)=>{let E=(i-S)*d;return jsx("path",{d:o,stroke:k.base,strokeWidth:E,fill:"none",strokeLinecap:"butt",opacity:k.striped?.9:1,style:s},`${e}-ribbon-${S}`)}),l.some(k=>k.striped)&&jsx(BaseEdge,{id:`${e}-ribbon-stripe`,path:o,style:{...s,stroke:"#000",strokeWidth:1,strokeDasharray:"3 3",opacity:.4}}),jsx(EdgeLabelRenderer,{children:n&&a&&(a.bandwidth||a.length)&&jsxs("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${x}px,${C}px)`,background:"#1f2937",padding:"4px 8px",borderRadius:"4px",fontSize:"10px",color:"white",fontFamily:"monospace",border:`1px solid ${l[0]?.base||"#00FFFF"}`,pointerEvents:"none",zIndex:9999},children:[a.bandwidth&&jsx("div",{children:a.bandwidth}),a.length&&jsxs("div",{children:[a.length,"m"]}),jsxs("div",{style:{fontSize:"8px",opacity:.8},children:[t.length,"F"]})]})})]})}var Jr=({id:e,sourceX:o,sourceY:t,targetX:n,targetY:s,sourcePosition:a,targetPosition:l,data:i,selected:d,style:u={},...h})=>{let{color:g="#00FFFF",striped:c=false,ribbonFiberIds:f,isRibbon:x,highlight:C,highlightColor:k,highlightWidth:S}=i||{},I=!!C,E=Di({sourceX:o,sourceY:t,sourcePosition:a,targetX:n,targetY:s,targetPosition:l});if((x||f&&f.length>=6&&f.length<=12)&&f)return $i(e,E,f,d??false,u??{},i);let m=d?3:2,w=S??m*3,R={...u,stroke:g,strokeWidth:m,strokeDasharray:"none"};return jsxs(Fragment,{children:[I&&jsx(BaseEdge,{id:`${e}-highlight`,path:E,style:{...u,stroke:k??g,strokeWidth:w,opacity:.7,strokeDasharray:"14 10","--rn-edge-highlight-from":`${m}px`,"--rn-edge-highlight-to":`${w}px`}}),jsx(BaseEdge,{id:e,path:E,style:R}),c&&jsx(BaseEdge,{id:`${e}-stripe`,path:E,style:{...u,stroke:"#000",strokeWidth:1.5,strokeDasharray:"6 6",opacity:.9}})]})};var tn=({id:e,sourceX:o,sourceY:t,targetX:n,targetY:s,sourcePosition:a,targetPosition:l,style:i={},data:d,markerEnd:u,selected:h})=>{let{color:g="#6366f1",label:c,highlight:f,highlightColor:x,highlightWidth:C}=d||{},k=!!f,S=8,I=C??S*1.8,[E,D,m]=getBezierPath({sourceX:o,sourceY:t,sourcePosition:a,targetX:n,targetY:s,targetPosition:l}),w={...i,stroke:g,strokeWidth:S,strokeLinecap:"round",strokeLinejoin:"round",strokeDasharray:"none"};return jsxs(Fragment,{children:[k&&jsx(BaseEdge,{id:`${e}-highlight`,path:E,style:{...i,stroke:x??g,strokeWidth:I,opacity:.85,strokeDasharray:"18 12",filter:`drop-shadow(0 0 8px ${x??g}) drop-shadow(0 0 16px ${x??g})`,"--rn-edge-highlight-from":`${S}px`,"--rn-edge-highlight-to":`${I}px`}}),jsx(BaseEdge,{id:e,path:E,markerEnd:u,style:w}),c&&jsx(EdgeLabelRenderer,{children:jsx("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${D}px,${m}px)`,background:"#1f2937",padding:"4px 8px",borderRadius:"4px",fontSize:"10px",color:"white",fontFamily:"monospace",border:`1px solid ${g}`,pointerEvents:"none",zIndex:9999},children:c})})]})};var on=(t=>(t.FULL="full",t.HALF="half",t))(on||{});var Uo={C13:{type:"C13",color:"#f59e0b",borderColor:"#d97706",amperage:10,voltage:230,phases:1},C14:{type:"C14",color:"#f59e0b",borderColor:"#d97706",amperage:10,voltage:230,phases:1},C19:{type:"C19",color:"#fbbf24",borderColor:"#d97706",amperage:16,voltage:230,phases:1},C20:{type:"C20",color:"#fbbf24",borderColor:"#d97706",amperage:16,voltage:230,phases:1}};function _t(e){let o=Uo[e];if(!o)throw new Error(`Unknown connector type: ${e}`);let t=o.amperage===16,n=t?12:8,s=t?10:5,a=t?{borderRadius:"3px"}:{clipPath:"polygon(2px 0, calc(100% - 2px) 0, 100% 2px, 100% 100%, 0 100%, 0 2px)",borderRadius:"0px"};return {width:n,height:s,color:o.color,borderColor:o.borderColor,fontSize:t?"3px":"4px",...a}}function rn(e){let o=Uo[e];if(!o)throw new Error(`Unknown connector type: ${e}`);return o}function zi(e){return rn(e).amperage===16}function Vo(e){return e%10<8?"C13":"C19"}function jo(e){let o=e.toLowerCase();return o.includes("mx304")||o.includes("mx480")||o.includes("mx960")?"C20":"C14"}var mt=({data:e,selected:o})=>{let {label:t,status:n="active",deviceType:s="server",manufacturer:a,role:l,uHeight:i=1,width:d="full",ports:u=[],rearPorts:h=[],view:g,rackWidthPx:c,frontImageUrl:f,rearImageUrl:x,imageFit:C,imagePosition:k,imageRepeat:S,stretchToFit:I}=e,E=c||300,D=g||(h.length>0&&u.length===0?"rear":"front"),m=D==="rear"?x:f,w=m?{backgroundImage:`url(${m})`,backgroundSize:I?"100% 100%":C??"cover",backgroundPosition:k??"center",backgroundRepeat:S??"no-repeat"}:{};u.length>0&&u.forEach(Z=>{Z.ports.forEach(M=>{M.type?.includes("power")?M.label:`${Z.name}-${M.label}`;});}),h.length>0&&h.forEach(Z=>{Z.ports.forEach(M=>{M.type?.includes("power")?M.label:`${Z.name}-${M.label}`;});});let F=i*20,W=E+4,L=Math.floor(E/2),j=d==="half"?`${L}px`:`${W}px`,re=d==="half"?`${L}px`:void 0,ae=(Z,M)=>{let H=[];if(Z.length===0)return H;let A=Math.max(4,Math.floor(F*.4)),z=Math.max(2,Math.floor(F*.2));return Z.forEach((X,oe)=>{X.ports.forEach((_,T)=>{let Q=!!_.type&&_.type.includes("power");if(M==="front"&&Q)return;let J=Q?`${_.label}`:`${X.name}-${_.label}`,V=_.connected,O="#6b7280",we="#374151";if(V)if(_.type?.includes("power"))O=_.type==="power_c19"?"#fbbf24":"#f59e0b";else if(_.type==="console"||_.type==="mgmt")O="#8b5cf6";else if(_.type==="usb")O="#10b981";else switch(_.cableType){case "smf":O="#fbbf24";break;case "cat6":O="#8b5cf6";break;case "om3":O="#06b6d4";break;case "om4":O="#8b5cf6";break;case "om5":O="#84cc16";break;case "cat5e":O="#3b82f6";break;case "cat6a":O="#ef4444";break;case "cat7":O="#f97316";break;case "fiber":O="#3b82f6";break;case "ethernet":O="#10b981";break;default:O="#10b981";}let Fe=V?O:we,G=Position.Top,he={width:`${A}px`,height:`${z}px`,background:O,border:`0.5px solid ${Fe}`,borderRadius:"1px",cursor:"pointer"};if(M==="front")T%2===0?(G=Position.Top,he.transform="translateY(50%)",he.left=`${T/2*(A+2)}px`):(G=Position.Bottom,he.transform="translateY(-50%)",he.left=`${(T-1)/2*(A+2)}px`);else if((s?.toLowerCase().replace(/_/g,"-")||"")==="patch-panel"||s==="switch")T%2===0?(G=Position.Top,he.transform="translateY(50%)",he.left=`${T/2*(A+2)}px`):(G=Position.Bottom,he.transform="translateY(-50%)",he.left=`${(T-1)/2*(A+2)}px`);else if(_.type?.includes("power")){G=Position.Left,he.transform="translateX(50%)";let Vt=F<=20?10:25,jt=F<=20?40:50;he.top=`${Vt+T*jt}%`;let $e=jo(t),_e=_t($e);he={...he,width:`${_e.width}px`,height:`${_e.height}px`,background:_e.color,border:`1px solid ${_e.borderColor}`,zIndex:10,display:"flex",alignItems:"center",justifyContent:"center",fontSize:_e.fontSize,color:"#1a1a1a",fontFamily:"monospace",fontWeight:"bold",borderRadius:_e.borderRadius,clipPath:_e.clipPath};}else G=Position.Right,he.transform="translateX(-50%)",he.top=`${25+T*50}%`;let qe=(s?.toLowerCase().replace(/_/g,"-")||"")==="patch-panel",ke;if(Q)ke="target";else if(s==="switch"||s==="router")ke="source",H.push(jsx(Handle,{id:`${J}-target`,type:"target",position:G,style:he,title:`${X.name} - ${_.label} (input) ${V?"(connected)":"(disconnected)"}`},`${J}-target`));else if(qe){ke=M==="rear"?"source":"target";let Je=M==="rear"?"target":"source";H.push(jsx(Handle,{id:`${J}-${Je}`,type:Je,position:G,style:he,title:`${X.name} - ${_.label} (${Je}) ${V?"(connected)":"(disconnected)"}`},`${J}-${Je}`));}else ke=V?"source":"target";H.push(jsx(Handle,{id:J,type:ke,position:G,style:he,title:`${X.name} - ${_.label} ${V?"(connected)":"(disconnected)"}`,children:Q?T+1:void 0},J));});}),H},se=()=>D==="front"?u.length>0?ae(u,"front"):[]:D==="rear"?h.length>0?ae(h,"rear"):[]:[];return jsxs("div",{className:`device-node ${o?"selected":""}`,style:{backgroundColor:"#1f2937",...w,border:`1px solid ${Te(n)}`,borderRadius:"2px",padding:"0px",width:j,...re&&{left:re},height:`${F}px`,color:"white",fontFamily:"monospace",fontSize:"8px",boxShadow:o?"0 0 0 1px #3b82f6":"0 1px 2px rgba(0,0,0,0.1)",position:"relative",display:"flex",flexDirection:"column",justifyContent:"center",cursor:"grab",marginBottom:"0px",boxSizing:"border-box",marginTop:"0px",marginLeft:"0px",marginRight:"0px"},children:[jsxs("div",{style:{textAlign:"center",flex:1,display:"flex",flexDirection:"column",justifyContent:"center",overflow:"hidden",padding:"2px"},children:[jsx("div",{style:{fontWeight:"bold",fontSize:"7px",lineHeight:"1.1",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:t}),i>1&&jsx("div",{style:{fontSize:"6px",color:"#9ca3af",lineHeight:"1"},children:a})]}),i>1&&jsxs("div",{style:{position:"absolute",bottom:"1px",right:"1px",background:"#374151",color:"#9ca3af",padding:"1px 2px",borderRadius:"1px",fontSize:"6px",lineHeight:"1"},children:[i,"U"]}),jsx("div",{style:{position:"absolute",bottom:"1px",left:"1px",width:"4px",height:"4px",background:Te(n),borderRadius:"50%"}}),se()]})};var Go=({data:e,selected:o})=>{let{label:t,status:n="active",heightCm:s=100,powerPorts:a=36,widthPx:l=15,mgmt_unit:i}=e,d=s*4.2,u=()=>{let c=Math.ceil(a/10),f=Array(10).fill(0).map((w,R)=>R<8?"10A":"16A");for(let w=0,R=0;w<c;++w)for(let F=0;F<10&&R<a;++F,++R){f[F];}let S=[],I=15,m=(d-I-3)/(a-9)*.5;for(let w=0;w<a;w++){let R=I-2+m*w,F=`${w+1}`;if(i&&(i==="top"&&w===0||i==="middle"&&w===Math.floor(a/2)||i==="bottom"&&w===a-1)){S.push(h(R));continue}let L=Vo(w),j=_t(L),re=Math.round((l-j.width)/2-1);S.push(jsx(Handle,{type:"source",position:Position.Right,id:F,style:{position:"absolute",left:`${re}px`,top:`${R-j.height/2}px`,width:`${j.width}px`,height:`${j.height}px`,background:j.color,border:`1px solid ${j.borderColor}`,cursor:"pointer",zIndex:10,display:"flex",alignItems:"center",justifyContent:"center",fontSize:j.fontSize,color:"#1a1a1a",fontFamily:"monospace",fontWeight:"bold",borderRadius:j.borderRadius,clipPath:j.clipPath},title:`Power Port ${w+1} (${L})`,children:w+1},`handle-${F}`));}return S},h=g=>jsxs("div",{style:{position:"absolute",left:`${(l-16)/2}px`,top:`${g-12/2}px`,width:"16px",height:"12px",background:"#1a1a1a",border:"1px solid #374151",borderRadius:"1px",display:"flex",flexDirection:"column",padding:"1px",zIndex:10},children:[jsx("div",{style:{position:"absolute",left:"-10px",top:"1px",background:"#ffffff",border:"0.5px solid #6b7280",borderRadius:"0.5px",width:"8px",height:"10px",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"3px",color:"#10b981",fontFamily:"monospace",fontWeight:"bold",transform:"rotate(90deg)",transformOrigin:"center"},children:"APC"}),jsx(Handle,{type:"source",position:Position.Right,id:"mgmt-net-1",style:{width:"70%",height:"6px",background:"#10b981",border:"1px solid #059669",borderRadius:"1px",cursor:"pointer",zIndex:11,margin:"0 auto"},title:"Management Network Port"},"mgmt-net-1")]},"mgmt-unit");return jsxs("div",{className:`vertical-pdu-node ${o?"selected":""}`,style:{background:"linear-gradient(90deg, #2d3748 0%, #1a202c 50%, #2d3748 100%)",border:`1px solid ${Te(n)}`,borderRadius:"2px",padding:0,width:`${l}px`,height:`${d}px`,color:"white",fontFamily:"monospace",fontSize:"12px",boxShadow:o?"0 0 0 2px #3b82f6":"0 1px 3px rgba(0,0,0,0.3)",position:"relative",display:"flex",flexDirection:"column"},children:[jsx("div",{style:{textAlign:"center",marginBottom:0,zIndex:2,background:"linear-gradient(90deg, #4a5568 0%, #2d3748 50%, #4a5568 100%)",padding:"2px",position:"relative",height:"20px",display:"flex",flexDirection:"column",justifyContent:"center",borderBottom:"1px solid #4a5568"},children:jsx("div",{style:{fontWeight:"bold",fontSize:"6px",color:"#e2e8f0"},children:t})}),jsx("div",{style:{flex:1,background:"linear-gradient(180deg, #2d3748 0%, #1a202c 50%, #2d3748 100%)",position:"relative",minHeight:`${d-20}px`,overflow:"hidden"},children:u()})]})};var qo=({data:e,selected:o,id:t})=>{let{lossDb:n,mode:s="single",ribbonFiberIds:a}=e||{},l=useEdges(),i=l.find(m=>m.target===t&&m.targetHandle==="left"),d=l.find(m=>m.source===t&&m.sourceHandle==="right"),u=l.find(m=>m.target===t&&m.targetHandle==="right"),h=d||u,g=i?.data?.color||"#555",c=h?.data?.color||"#555",f=s==="ribbon",x=i?.data?.ribbonFiberIds||a,C=h?.data?.ribbonFiberIds||a,k=f&&x?Ae(x):null,S=f&&C?Ae(C):null,I=!!i&&!!h;return jsxs("div",{className:`splice-node ${o?"selected":""}`,style:{width:f?85:69,height:f?20:16,borderRadius:8,border:"none",outline:"none",position:"relative",background:"transparent",boxShadow:o?"0 0 0 2px #3b82f6":"none"},children:[f&&k&&S?jsxs("div",{style:{position:"absolute",inset:0,borderRadius:8,overflow:"hidden",opacity:.75,pointerEvents:"none",display:"grid",gridTemplateColumns:"1fr 1fr"},children:[jsx("div",{style:{display:"flex",flexDirection:"column",width:"100%",height:"100%"},children:k.map((m,w)=>jsx("div",{style:{flex:1,background:m.base,opacity:m.striped?.9:1}},`left-${w}`))}),jsx("div",{style:{display:"flex",flexDirection:"column",width:"100%",height:"100%"},children:S.map((m,w)=>jsx("div",{style:{flex:1,background:m.base,opacity:m.striped?.9:1}},`right-${w}`))})]}):jsxs("div",{style:{position:"absolute",inset:0,display:"grid",gridTemplateColumns:"1fr 1fr",borderRadius:8,overflow:"hidden",opacity:.75,pointerEvents:"none"},children:[jsx("div",{style:{background:g}}),jsx("div",{style:{background:c}})]}),jsx("div",{className:"splice-text-overlay",style:{position:"absolute",inset:0,borderRadius:8,pointerEvents:"none",zIndex:1,background:"transparent"}}),I&&jsx("div",{className:"splice-glow",style:{position:"absolute",left:"50%",top:0,bottom:0,width:"1px",background:"rgba(255, 255, 255, 0.6)",boxShadow:"0 0 2px rgba(255, 255, 255, 0.8), 0 0 4px rgba(255, 255, 255, 0.4)",pointerEvents:"none",zIndex:2}}),I&&typeof n=="number"&&jsxs("div",{className:"splice-text-label animate-in",style:{position:"absolute",inset:0,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",fontSize:f?8:9,fontFamily:"monospace",pointerEvents:"none",zIndex:3,fontWeight:"bold",gap:"2px"},children:[jsx("div",{children:`${n.toFixed(2)} dB`}),f&&a&&jsxs("div",{style:{fontSize:"7px",opacity:.8},children:[a.length,"F"]})]}),jsx(Handle,{type:"target",position:Position.Left,id:"left",isConnectable:true,style:{width:12,height:f&&k?20:12,borderRadius:f&&k?"6px":"50%",border:"none",background:f&&k?`linear-gradient(to bottom, ${k.map(m=>m.base).join(", ")})`:g,zIndex:100,cursor:"crosshair",left:-6,top:"50%",transform:"translateY(-50%)"}}),jsx(Handle,{type:"source",position:Position.Right,id:"right",isConnectable:true,style:{width:12,height:f&&S?20:12,borderRadius:f&&S?"6px":"50%",border:"none",background:f&&S?`linear-gradient(to bottom, ${S.map(m=>m.base).join(", ")})`:c,zIndex:100,cursor:"crosshair",right:-6,top:"50%",transform:"translateY(-50%)"}}),jsx(Handle,{type:"target",position:Position.Right,id:"right",isConnectable:true,style:{width:12,height:f&&S?20:12,borderRadius:f&&S?"6px":"50%",border:"none",background:f&&S?`linear-gradient(to bottom, ${S.map(m=>m.base).join(", ")})`:c,zIndex:100,cursor:"crosshair",right:-6,top:"50%",transform:"translateY(-50%)"}})]})};var Lt=20,io=36;var lt=32,dn=4,Ge=12,Oi=69,ct=80,Jo=(ct-Oi)/2;var Qo=(e,o,t,n)=>{if(!e.parentId||e.parentId!==o.id)return t;let s=e.data?.mode==="ribbon",a=s?io:Lt,l=s?32:16,i=lt,d=t.y-i,u=Math.round(d/a)+1,g=Math.max(1,Math.min(Ge,u));if(!Mt(o,e,g,n)){let x=zt(o,e,n,g);if(x!==g){let C=(a-l)/2;return {x:Jo,y:i+(x-1)*a+C,holderPosition:x}}}let c=(a-l)/2,f=i+(g-1)*a+c;return {x:Jo,y:f,holderPosition:g}},Mt=(e,o,t,n)=>!n.filter(a=>a.parentId===e.id&&a.type==="splice"&&a.id!==o.id).some(a=>a.data.holderPosition===t),zt=(e,o,t,n=1)=>{for(let s=n;s<=Ge;s++)if(Mt(e,o,s,t))return s;for(let s=n-1;s>=1;s--)if(Mt(e,o,s,t))return s;return 1},Bi=(e,o)=>At(e,o,false),At=(e,o,t=false)=>{let n=lt,s=t?io:Lt,l=(s-(t?32:16))/2,i=n+(o-1)*s+l;return {x:Jo,y:i}};var or=({data:e,selected:o})=>{let{label:t="Splice Tray"}=e||{},[n,s]=useState(false),a=()=>{if(!n)return null;let l=[],i=lt;for(let d=1;d<=Ge;d++){let u=i+(d-1)*Lt;l.push(jsxs("div",{style:{position:"absolute",left:"-35px",top:`${u}px`,background:"#374151",color:"#9ca3af",padding:"2px 4px",borderRadius:"2px",fontSize:"8px",fontWeight:"bold",width:"28px",textAlign:"center",border:"1px solid #4b5563",zIndex:10,height:`${Lt}px`,display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1},children:["H",d]},d));}return l};return jsxs("div",{className:`splice-tray-node ${o?"selected":""}`,style:{background:"transparent",border:"none",borderRadius:"8px",padding:0,width:`${ct}px`,height:`${lt+Ge*io+dn}px`,color:"white",fontFamily:"monospace",fontSize:"12px",boxShadow:o?"0 0 0 2px #3b82f6":"0 2px 4px rgba(0,0,0,0.1)",position:"relative",display:"flex",flexDirection:"column"},children:[jsxs("div",{style:{textAlign:"center",marginBottom:0,zIndex:2,background:"#1f2937",padding:"2px",position:"relative",height:`${lt}px`,display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"center",gap:"6px",borderRadius:"8px"},children:[jsx("div",{style:{fontWeight:"bold",fontSize:"10px"},children:t}),jsx("button",{onPointerDown:l=>{l.stopPropagation();},onMouseDown:l=>{l.stopPropagation();},onClick:l=>{l.stopPropagation(),l.preventDefault(),s(!n);},style:{background:n?"#10b981":"#374151",color:n?"#ffffff":"#9ca3af",border:"1px solid #4b5563",borderRadius:"2px",padding:"2px 6px",fontSize:"8px",cursor:"pointer",fontFamily:"monospace"},title:`${n?"Hide":"Show"} holder markers`,children:"H"})]}),a(),jsx("div",{style:{position:"absolute",top:lt,left:0,right:0,bottom:0,pointerEvents:"none"}})]})};var rr=({data:e,selected:o,id:t})=>{let{fibersPerTube:n=12,tubeIndex:s=1,startOn:a="left-center"}=e||{},l=e?.mode==="ribbon"||e?.ribbon===true,i=useEdges(),d=`tube-${s}`,u=i.find(ae=>ae.source===t&&ae.sourceHandle===d||ae.target===t&&ae.targetHandle===d),h=u?.data?.color,g=xe((s-1)%12+1),c=h||g,f=Math.max(1,Math.min(24,Number(n)||12)),x=14,C=4,k=1,S=2,I=20,E=f*x+(f-1)*C,D=Math.max(60,E+k*2+S*2),m=a==="left"?Position.Left:a==="right"?Position.Right:Position.Bottom,w=m!==Position.Bottom,R=w?14:20,F=w?8:20,W=w?`inset ${m===Position.Left?"-4px":"4px"} 0 0 rgba(0, 0, 0, 0.35)`:"none",L=u?c:w?`linear-gradient(${m===Position.Left?"to right":"to left"}, rgba(0, 0, 0, 0.45), rgba(0, 0, 0, 0)), ${c}`:`radial-gradient(circle, ${c} 40%, transparent 70%)`,j={width:R,height:F,borderRadius:w?6:"50%",opacity:u?.3:.9,pointerEvents:"auto",background:L,backgroundColor:c,border:u?`2px solid ${c}`:`3px dashed ${c}`,cursor:"crosshair","--fiber-bg":c,boxShadow:u?W:`${W}${W!=="none"?", ":""}0 0 8px ${c}`,transition:"opacity 0.2s, box-shadow 0.2s",...m===Position.Left?{left:-(R-4)}:m===Position.Right?{right:-(R-4)}:{}},re=useMemo(()=>{let ae=[],se=D-S*2-k*2,Z,M,H=false;a==="left"?(Z=k,M=Position.Top):a==="right"?(Z=k+se-E,M=Position.Top,H=true):(Z=k+(se-E)/2,M=Position.Top);for(let A=0;A<f;A++){let z=H?f-A:A+1,X=ze(z),oe=xe(z),_=`fiber-${z}`,T=i.find(we=>we.source===t&&we.sourceHandle===_||we.target===t&&we.targetHandle===_),Q=null;T&&(T.data?.isRibbon||T.data?.ribbonFiberIds&&Array.isArray(T.data.ribbonFiberIds)?Q="#808080":Q=T.data?.color||null);let J=Z+A*(x+C),V=k,O={position:"absolute",left:`${J}px`,top:`${V}px`,width:x,height:x,borderRadius:"50%",border:"none",zIndex:10,cursor:"pointer","--fiber-bg":Q||(l?"#808080":oe)};Q?O.backgroundColor=Q:l?O.backgroundColor="#808080":X.backgroundImage?O["--fiber-bg-image"]=X.backgroundImage:O.backgroundColor=oe,ae.push(jsxs(ft.Fragment,{children:[jsx(Handle,{id:_,type:"target",position:M,className:"tube-fiber-handle",isConnectable:true,style:O,"data-fiber-idx":z,"data-fiber-color":Q||(l?"#808080":oe)}),jsx(Handle,{id:_,type:"source",position:M,className:"tube-fiber-handle",isConnectable:true,style:O,"data-fiber-idx":z,"data-fiber-color":Q||(l?"#808080":oe)})]},`fiber-${z}`));}return ae},[f,a,D,i,t,x,C,k,S,E,l]);return jsxs("div",{style:{width:D,height:I,borderRadius:4,background:"#111827",border:`${S}px solid ${o?"#3b82f6":c}`,position:"relative",boxShadow:o?`0 0 0 ${S}px #3b82f6`:"0 2px 4px rgba(0,0,0,0.2)",padding:k,boxSizing:"border-box",overflow:"visible"},children:[re,jsx(Handle,{id:d,type:"target",position:m,isConnectable:true,className:"tube-connection-handle",style:j,"data-tube-idx":s,"data-tube-color":c,title:u?"Connected - drag to reconnect":"Drag to connect cable tube"}),jsx(Handle,{id:d,type:"source",position:m,isConnectable:true,className:"tube-connection-handle",style:j,"data-tube-idx":s,"data-tube-color":c,title:u?"Connected - drag to reconnect":"Drag to connect cable tube"})]})};var ar=({data:e,selected:o})=>{let{fiberCount:t,cableId:n="CBL-002",label:s,color:a,rotation:l}=e||{},i=ft.useRef(null);ft.useEffect(()=>{if(i.current){let M=typeof l=="number"?l:0;i.current.style.transform=`rotate(${M}deg)`,i.current.style.transformOrigin="center center";}},[l]);let d=Math.max(1,Math.min(24,Number(t)||12)),u=10,h=2,g=6,c=g+u+4,f=60,x=Math.max(120,d*(u+h)+g*2),k=s??`${d}f Cable`,S=n?`Cable ID ${n}`:void 0,I=xe(1),E=a||I,D=o?"#3b82f6":E,m=typeof l=="number"?l:0,w=M=>{let H=(M%360+360)%360;return H>=315||H<45?Position.Top:H>=45&&H<135?Position.Right:H>=135&&H<225?Position.Bottom:Position.Left},R=()=>{let M=[],H=w(m);for(let A=0;A<d;A++){let z=A+1,X=ze(z),oe=xe(z),_=g+A*(u+h),T=-5,Q=X.backgroundImage?X.backgroundImage:oe,J={position:"absolute",left:`${_}px`,top:`${T}px`,width:u,height:u,borderRadius:"50%",border:"none",background:Q,backgroundColor:oe,zIndex:10,cursor:"pointer","--fiber-bg":oe};X.backgroundImage&&(J["--fiber-bg-image"]=X.backgroundImage);let V=`fiber-${z}`;M.push(jsxs(ft.Fragment,{children:[jsx(Handle,{id:V,type:"target",position:H,className:"tube-fiber-handle",isConnectable:true,style:J,"data-fiber-idx":z,"data-fiber-color":oe}),jsx(Handle,{id:V,type:"source",position:H,className:"tube-fiber-handle",isConnectable:true,style:J,"data-fiber-idx":z,"data-fiber-color":oe})]},`fiber-${z}`));}return M},F="cable-button",W=8,L={width:W,height:W,borderRadius:"50%",background:E,backgroundColor:E,border:`1px solid ${E}`,cursor:"pointer",zIndex:10},j=2,ae=(M=>{let H=(M%360+360)%360;return H>=315||H<45?Position.Bottom:H>=45&&H<135?Position.Left:H>=135&&H<225?Position.Top:Position.Right})(m),se={width:x,height:f,position:"relative",transform:`rotate(${m}deg)`,transformOrigin:"center center","--rotation":`${m}deg`},Z={width:"100%",height:"100%",borderRadius:4,background:"#111827",border:`${j}px solid ${D}`,boxShadow:o?"0 0 0 2px #3b82f6":"0 2px 4px rgba(0,0,0,0.2)",padding:g,paddingTop:c,boxSizing:"border-box",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",color:"#e5e7eb",fontFamily:"monospace",textAlign:"center",gap:2};return jsx("div",{ref:i,style:se,children:jsxs("div",{style:Z,children:[R(),jsx(Handle,{id:F,type:"source",position:ae,className:"cable-button-handle",isConnectable:true,style:L,"data-handle-type":"cable-button","data-cable-color":E}),jsx(Handle,{id:F,type:"target",position:ae,className:"cable-button-handle",isConnectable:true,style:L,"data-handle-type":"cable-button","data-cable-color":E}),jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:2,transform:"translateX(2px)"},children:[jsx("div",{style:{fontSize:11,fontWeight:600,textTransform:"uppercase",letterSpacing:.5},children:k}),S&&jsx("div",{style:{fontSize:10,opacity:.8},children:S})]})]})})};var dr=({data:e,selected:o})=>{let{tubeCount:t=12,fibersPerTube:n=12,fiberCount:s,cableId:a="CBL-002",label:l,tubeStartIndex:i=1,color:d}=e||{},u=Math.max(1,Math.min(24,Number(t)||12)),h=Math.max(1,Number(i)||1),g=14,c=10,f=3,x=6,C=x+c+4,k=60,S=Math.max(120,u*(g+f)+x*2),I=s??u*(Number(n)||12),E=l??`${I}f Cable`,D=a?`Cable ID ${a}`:void 0,m=xe(h),w=d||m,R=o?"#3b82f6":w,F=()=>{let ae=[];for(let se=0;se<u;se++){let Z=h+se,M=ze(Z),H=xe(Z),A=x+se*(g+f),z=-5,X=M.backgroundImage?M.backgroundImage:H,oe={position:"absolute",left:`${A}px`,top:`${z}px`,width:g,height:c,borderRadius:6,border:"none",background:X,backgroundColor:H,zIndex:10,cursor:"pointer","--fiber-bg":H};M.backgroundImage&&(oe["--fiber-bg-image"]=M.backgroundImage);let _=`tube-${Z}`;ae.push(jsxs(ft.Fragment,{children:[jsx(Handle,{id:_,type:"target",position:Position.Top,className:"tube-fiber-handle",isConnectable:true,style:oe,"data-fiber-idx":Z,"data-tube-idx":Z,"data-tube-color":H}),jsx(Handle,{id:_,type:"source",position:Position.Top,className:"tube-fiber-handle",isConnectable:true,style:oe,"data-fiber-idx":Z,"data-tube-idx":Z,"data-tube-color":H})]},`tube-${Z}`));}return ae},W="cable-button",L=8,j={width:L,height:L,borderRadius:"50%",background:w,backgroundColor:w,border:`1px solid ${w}`,cursor:"pointer",zIndex:10};return jsxs("div",{style:{width:S,height:k,borderRadius:4,background:"#111827",border:`2px solid ${R}`,position:"relative",boxShadow:o?"0 0 0 2px #3b82f6":"0 2px 4px rgba(0,0,0,0.2)",padding:x,paddingTop:C,boxSizing:"border-box",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",color:"#e5e7eb",fontFamily:"monospace",textAlign:"center",gap:2},children:[F(),jsx(Handle,{id:W,type:"source",position:Position.Bottom,className:"cable-button-handle",isConnectable:true,style:j,"data-handle-type":"cable-button","data-cable-color":w}),jsx(Handle,{id:W,type:"target",position:Position.Bottom,className:"cable-button-handle",isConnectable:true,style:j,"data-handle-type":"cable-button","data-cable-color":w}),jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:2},children:[jsx("div",{style:{fontSize:11,fontWeight:600,textTransform:"uppercase",letterSpacing:.5},children:E}),D&&jsx("div",{style:{fontSize:10,opacity:.8},children:D})]})]})};var lr=({data:e,selected:o,id:t})=>{let{connector:n="LC",couplerFiberCount:s,label:a,portLabelsLeft:l,portLabelsRight:i}=e||{},d=useEdges(),u=typeof s=="number"&&[1,2,4].includes(s)?s:2,h=Math.max(1,Math.min(4,u)),g=9,c=3,f=3,x=60,C=30,k=h*g+(h-1)*c,S=Math.max(C,k+f*2),I=Math.max(x,80),E=(w,R)=>{let F=`${w}-${R+1}`;return d.find(L=>L.source===t&&L.sourceHandle===F||L.target===t&&L.targetHandle===F)?.data?.color||"#555"},D=w=>{let R=[],F=w==="left"?Position.Left:Position.Right,W=w==="left"?l:i;for(let L=0;L<h;L++){let j=L+1,re=`${w}-${j}`,ae=E(w,L),M=f+(S-k)/2+L*(g+c),H={position:"absolute",left:w==="left"?-5:void 0,right:w==="right"?-5:void 0,top:`${M}px`,width:g,height:g,borderRadius:"50%",border:"none",background:ae,zIndex:100,cursor:"crosshair",transform:"translateY(-50%)"};R.push(jsxs(ft.Fragment,{children:[jsx(Handle,{id:re,type:"target",position:F,isConnectable:true,style:H}),jsx(Handle,{id:re,type:"source",position:F,isConnectable:true,style:H})]},re)),W&&W[L]&&R.push(jsx("div",{style:{position:"absolute",left:w==="left"?-30:void 0,right:w==="right"?-30:void 0,top:`${M}px`,transform:"translateY(-50%)",fontSize:"8px",color:"#9ca3af",fontFamily:"monospace",pointerEvents:"none",textAlign:w==="left"?"right":"left",width:"25px"},children:W[L]},`${re}-label`));}return R},m=a||`${n}-${h}f`;return jsxs("div",{className:`coupler-node ${o?"selected":""}`,style:{width:I,height:S,borderRadius:4,border:`2px solid ${o?"#3b82f6":"#4b5563"}`,background:"#1f2937",position:"relative",boxShadow:o?"0 0 0 2px #3b82f6":"0 2px 4px rgba(0,0,0,0.2)",display:"flex",alignItems:"center",justifyContent:"center",color:"#e5e7eb",fontFamily:"monospace",fontSize:"10px",padding:`${f}px`,boxSizing:"border-box"},children:[D("left"),jsx("div",{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",textAlign:"center",pointerEvents:"none",zIndex:1},children:jsx("div",{style:{fontWeight:"bold",fontSize:"9px"},children:m})}),D("right")]})};var gt=32,fo=30,Zi=24,qi=80,po=400,go=300,hn=2,pt=8,mn=120;function ur(e){let{couplerFiberCount:o}=e.data||{},t=typeof o=="number"&&[1,2,4].includes(o)?o:2,n=Math.max(1,Math.min(4,t)),s=7,a=3,l=3,i=60,d=30,u=n*s+(n-1)*a,h=Math.max(d,u+l*2);return {width:Math.max(i,80),height:h}}function bo(e){let{fibersPerTube:o=12}=e.data||{},t=Math.max(1,Math.min(24,Number(o)||12)),n=14,s=4,a=1,l=2,i=20,d=t*n+(t-1)*s;return {width:Math.max(60,d+a*2+l*2),height:i}}function yn(e){return {width:ct,height:0}}function wn(e){return e.type==="coupler"?ur(e):e.type==="tube"?bo(e):e.type==="splice-tray"?yn():{width:80,height:30}}function cr(e){let o=0;for(let t of e){let n=wn(t),s=(t.position?.x||0)+n.width;s>o&&(o=s);}return o}function xn(e,o=0){let t=o;for(let n of e){let s=wn(n),a=(n.position?.y||0)+s.height;a>t&&(t=a);}return t}function Nn(e){return e.data?.panelWidth||po}function Ji(e){return e.data?.panelHeight||go}function kn(e){return Nn(e)-hn*2-pt*2}function Qi(e,o){return kn(e)-o}function Cn(e,o=fo){return Math.floor(e/o)+1}function vn(e,o=fo){return (e-1)*o}function ea(e,o,t){let n=fo,s=Cn(t.y,n),a=vn(s,n);return {x:t.x,y:a,slotPosition:s}}function pr(e,o){if(o.length===0)return {width:e.data?.panelWidth||po,height:e.data?.panelHeight||go};let t=o.some(d=>d.type==="tube"),n=o.some(d=>d.type==="splice-tray"),s=o.some(d=>d.type==="coupler"),a;if(t&&n&&s){let d=0,u=0;for(let c of o)if(c.type==="tube"){let f=bo(c);f.width>d&&(d=f.width);}else if(c.type==="coupler"){let f=ur(c);f.width>u&&(u=f.width);}let h=d+mn+ct+u+5,g=0;a=g+h+g;}else a=cr(o)+4;a=Math.max(e.data?.panelWidth||po,a);let l=xn(o,gt),i=Math.max(e.data?.panelHeight||go,l+pt);return {width:a,height:i}}function Sn(e,o,t){if(e===0)return 0;if(e===1)return o;let n=e*o,s=t-n,a=Math.max(5,s/(e-1));return o+a}function ta(e,o,t){return Sn(e,o,t)}var gn=20,fn=400,bn=300;function Hn(e,o){if(o.length===0)return {width:e.data?.closureWidth||e.data?.panelWidth||fn,height:e.data?.closureHeight||e.data?.panelHeight||bn};let t=o.some(i=>i.type==="tube"),n=o.some(i=>i.type==="splice-tray"),s;if(t&&n){let i=0,d=0,u=0,h=o.filter(c=>c.type==="tube"),g=o.filter(c=>c.type==="splice-tray");if(h.length>0&&g.length>0){let c=g.map(x=>x.position?.x||0),f=c.reduce((x,C)=>x+C,0)/c.length;for(let x of h){let C=bo(x);(x.position?.x||0)<f?C.width>i&&(i=C.width):C.width>d&&(d=C.width);}g.length>0&&(u=ct),s=pt+i+gn+u+gn+d+5;}else s=cr(o)+pt+5;}else s=cr(o)+pt+5;s=Math.max(e.data?.closureWidth||e.data?.panelWidth||fn,s);let a=xn(o,gt),l=Math.max(e.data?.closureHeight||e.data?.panelHeight||bn,a+pt);return {width:s,height:l}}var br=({data:e,selected:o,id:t})=>{let{label:n="Patch Panel",header:s,panelWidth:a,panelHeight:l}=e||{},{getNodes:i,setNodes:d}=useReactFlow(),u=useRef(false),h=useRef([]),g=useMemo(()=>{let E=i().filter(D=>D.parentId===t);return (E.length!==h.current.length||E.some((D,m)=>D.id!==h.current[m]?.id))&&(h.current=E),h.current},[i,t]),c=useMemo(()=>({id:t,type:"patch-panel",position:{x:0,y:0},data:{...e,panelWidth:a,panelHeight:l}}),[t,e,a,l]),f=useMemo(()=>a&&l?{width:a,height:l}:g.length===0?{width:a||400,height:l||300}:pr(c,g),[g,c,a,l]);useEffect(()=>{if(a&&l||u.current)return;let I=a,E=l,D=Math.abs((I||0)-f.width),m=Math.abs((E||0)-f.height);(D>1||m>1)&&(u.current=true,d(w=>w.map(R=>R.id===t?{...R,data:{...R.data,panelWidth:f.width,panelHeight:f.height}}:R)),setTimeout(()=>{u.current=false;},0));},[t,f.width,f.height,a,l,d]);let x=f.width,C=f.height,k=gt,S=s||n;return jsxs("div",{className:`patch-panel-node ${o?"selected":""}`,style:{background:"transparent",border:"none",borderRadius:"8px",padding:0,width:`${x}px`,height:`${C}px`,color:"white",fontFamily:"monospace",fontSize:"12px",boxShadow:o?"0 0 0 2px #3b82f6":"0 2px 4px rgba(0,0,0,0.1)",position:"relative",display:"flex",flexDirection:"column",backgroundColor:"#1f2937",boxSizing:"border-box"},children:[jsx("div",{style:{textAlign:"center",marginBottom:0,zIndex:2,background:"#374151",padding:"6px 12px",position:"relative",height:`${k}px`,display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"center",gap:"6px",borderRadius:"6px 6px 0 0",borderBottom:"1px solid #4b5563"},children:jsx("div",{style:{fontWeight:"bold",fontSize:"11px"},children:S})}),jsx("div",{style:{position:"absolute",top:k,left:0,right:0,bottom:0,pointerEvents:"none",overflow:"visible"}})]})};var yr=({data:e,selected:o,id:t})=>{let{label:n="Closure",header:s,closureWidth:a,closureHeight:l,panelWidth:i,panelHeight:d}=e||{},{getNodes:u,setNodes:h}=useReactFlow(),g=useRef(false),c=useRef([]),f=useMemo(()=>{let w=u().filter(R=>R.parentId===t);return (w.length!==c.current.length||w.some((R,F)=>R.id!==c.current[F]?.id))&&(c.current=w),c.current},[u,t]),x=useMemo(()=>({id:t,type:"closure",position:{x:0,y:0},data:{...e,closureWidth:a||i,closureHeight:l||d}}),[t,e,a,l,i,d]),C=useMemo(()=>a&&l?{width:a,height:l}:i&&d?{width:i,height:d}:f.length===0?{width:a||i||400,height:l||d||300}:Hn(x,f),[f,x,a,l,i,d]);useEffect(()=>{if(a&&l||i&&d||g.current)return;let m=a||i,w=l||d,R=Math.abs((m||0)-C.width),F=Math.abs((w||0)-C.height);(R>1||F>1)&&(g.current=true,h(W=>W.map(L=>L.id===t?{...L,data:{...L.data,closureWidth:C.width,closureHeight:C.height}}:L)),setTimeout(()=>{g.current=false;},0));},[t,C.width,C.height,a,l,i,d,h]);let k=C.width,S=C.height,I=gt,E=s||n,D=k/2;return jsxs("div",{className:`closure-node ${o?"selected":""}`,style:{background:"transparent",border:"none",borderRadius:`${D}px ${D}px 12px 12px`,padding:0,width:`${k}px`,height:`${S}px`,color:"white",fontFamily:"monospace",fontSize:"12px",boxShadow:o?"0 0 0 2px #3b82f6":"0 2px 4px rgba(0,0,0,0.1)",position:"relative",display:"flex",flexDirection:"column",backgroundColor:"#1f2937",boxSizing:"border-box",overflow:"hidden"},children:[jsx("div",{style:{textAlign:"center",marginBottom:0,zIndex:2,background:"#374151",padding:"6px 12px",position:"relative",height:`${I}px`,display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"center",gap:"6px",borderRadius:`${D}px ${D}px 0 0`,borderBottom:"1px solid #4b5563"},children:jsx("div",{style:{fontWeight:"bold",fontSize:"11px"},children:E})}),jsx("div",{style:{position:"absolute",top:I,left:0,right:0,bottom:0,pointerEvents:"none",overflow:"visible"}})]})};var xr=({data:e,selected:o,id:t})=>{let{label:n,splitterType:s="splitter",inputCount:a=1,outputCount:l=8}=e||{},i=useEdges(),d=n||(s==="WDM"?"WDM":"Splitter"),u=9,h=3,g=3,c=50,f=30,x=Math.min(Math.max(a||1,1),2),C=x*u+(x-1)*h,k=Math.min(l||8,48),S=k*u+(k-1)*h,I=Math.max(C,S),E=Math.max(f,I+g*2),D=Math.max(c,50),m=se=>i.find(M=>M.source===t&&M.sourceHandle===se||M.target===t&&M.targetHandle===se)?.data?.color||"#555",w=()=>{let se=[],Z=g+(E-C)/2;for(let M=0;M<x;M++){let H=`input-${M+1}`,A=Z+M*(u+h),z=m(H),X={position:"absolute",left:-5,top:`${A}px`,width:u,height:u,borderRadius:"50%",border:"none",background:z,zIndex:100,cursor:"crosshair",transform:"translateY(-50%)"};se.push(jsxs(ft.Fragment,{children:[jsx(Handle,{id:`${H}-target`,type:"target",position:Position.Left,isConnectable:true,style:X}),jsx(Handle,{id:`${H}-source`,type:"source",position:Position.Left,isConnectable:true,style:X})]},H));}return se},R=()=>{let se=[],Z=g+(E-S)/2;for(let M=0;M<k;M++){let H=`output-${M+1}`,A=Z+M*(u+h),z=m(H),X={position:"absolute",right:-5,top:`${A}px`,width:u,height:u,borderRadius:"50%",border:"none",background:z,zIndex:100,cursor:"crosshair",transform:"translateY(-50%)"};se.push(jsxs(ft.Fragment,{children:[jsx(Handle,{id:`${H}-target`,type:"target",position:Position.Right,isConnectable:true,style:X}),jsx(Handle,{id:`${H}-source`,type:"source",position:Position.Right,isConnectable:true,style:X})]},H));}return se},F=Math.max(C+g*4,f*.6),W=(E-F)/2,L=W+F,j=0,re=E,ae=o?"#3b82f6":"#4b5563";return jsxs("div",{className:`trapezoid-node ${o?"selected":""}`,style:{width:D,height:E,position:"relative",background:"transparent",boxShadow:o?"0 0 0 2px #3b82f6":"0 2px 4px rgba(0,0,0,0.2)",display:"flex",alignItems:"center",justifyContent:"center",color:"#e5e7eb",fontFamily:"monospace",fontSize:"10px",padding:`${g}px`,boxSizing:"border-box"},children:[jsx("svg",{width:D,height:E,viewBox:`0 0 ${D} ${E}`,style:{position:"absolute",top:0,left:0,width:`${D}px`,height:`${E}px`,pointerEvents:"none",zIndex:0},children:jsx("polygon",{points:`0,${W} 0,${L} ${D},${re} ${D},${j}`,fill:"#1f2937",stroke:ae,strokeWidth:"2"})}),w(),jsx("div",{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",textAlign:"center",pointerEvents:"none",zIndex:1},children:jsx("div",{style:{fontWeight:"bold",fontSize:"9px"},children:d})}),R()]})};var In=e=>e?.type==="tube"||e?.type==="splice"||e?.type==="coupler"||e?.type==="fibre-split"||e?.type==="cable"||e?.type==="multi-tube-cable",xt=(e,o)=>In(e)||In(o),ie=(e,o)=>o?e?.type==="fibre-split"?o.replace(/-(source|target)$/i,""):o:o||"";function la(e,o){if(!e.source||!e.target||!e.sourceHandle||!e.targetHandle)return {valid:true};let t=o.nodes.find(_=>_.id===e.source),n=o.nodes.find(_=>_.id===e.target),s=ie(t,e.sourceHandle),a=ie(n,e.targetHandle),l=o.edges.some(_=>_.source===e.source?ie(t,_.sourceHandle)===s:_.target===e.source?ie(t,_.targetHandle)===s:false),i=o.edges.some(_=>_.target===e.target?ie(n,_.targetHandle)===a:_.source===e.target?ie(n,_.sourceHandle)===a:false),d=xt(t,n);if((l||i)&&!d)return l?{valid:false,reason:`Source handle ${e.sourceHandle} on node ${e.source} is already connected`}:{valid:false,reason:`Target handle ${e.targetHandle} on node ${e.target} is already connected`};let u=(_,T)=>(_?.type==="tube"||_?.type==="cable")&&!!T&&T.startsWith("fiber-"),h=(_,T)=>(_?.type==="tube"||_?.type==="multi-tube-cable")&&!!T&&T.startsWith("tube-"),g=(_,T)=>_?.type==="multi-tube-cable"&&!!T&&T.startsWith("tube-"),c=(_,T)=>_?.type==="tube"&&!!T&&T.startsWith("tube-"),f=(_,T)=>(_?.type==="cable"||_?.type==="multi-tube-cable")&&T==="cable-button",x=(_,T)=>_?.type==="splice"&&(T==="left"||T==="right"),C=(_,T)=>_?.type==="coupler"&&!!T&&(T.startsWith("left-")||T.startsWith("right-")),k=(_,T)=>{if(_?.type!=="fibre-split"||!T)return false;let Q=ie(_,T);return Q.startsWith("input-")||Q.startsWith("output-")};if(!d)return {valid:true};if(t?.type==="splice"&&n?.type==="splice"){let _=t.data?.mode==="ribbon",T=n.data?.mode==="ribbon";if(_!==T)return {valid:false,reason:"Ribbon splices can only connect to other ribbon splices"}}let S=u(t,e.sourceHandle),I=u(n,e.targetHandle),E=x(t,e.sourceHandle),D=x(n,e.targetHandle),m=C(t,e.sourceHandle),w=C(n,e.targetHandle),R=k(t,e.sourceHandle),F=k(n,e.targetHandle),W=f(t,e.sourceHandle),L=f(n,e.targetHandle),j=g(t,e.sourceHandle),re=g(n,e.targetHandle),ae=c(t,e.sourceHandle),se=c(n,e.targetHandle),Z=h(t,e.sourceHandle),M=h(n,e.targetHandle);return S&&D||I&&E||(E&&(w||F)||D&&(m||R))||(m&&(w||F||D)||w&&(m||R||E))||W&&L||(j&&se||re&&ae)?{valid:true}:Z&&M?{valid:false,reason:"Tube handles can only connect between cable and tube nodes"}:{valid:false,reason:"Connection not allowed by fiber rules"}}function yo(e,o){if(!o)return;let t=typeof e=="string"?e.replace(/-(target|source)$/i,""):e,n=o.data??{},s=n.handleSideMap;if(s&&s[t])return s[t];if(t==="net-top"||t==="net-bottom")return "front";if(t==="pwr-left-1"||t==="pwr-left-2"||t==="net-right-1"||t==="net-right-2")return "rear";let a=Array.isArray(n.ports)?n.ports:[],l=Array.isArray(n.rearPorts)?n.rearPorts:[];if(t.startsWith("pwr")||t.includes("power"))return "rear";for(let d of a)for(let u of d.ports||[])if((!!u.type&&String(u.type).includes("power")?u.label:`${d.name}-${u.label}`)===t)return "front";for(let d of l)for(let u of d.ports||[])if((!!u.type&&String(u.type).includes("power")?u.label:`${d.name}-${u.label}`)===t)return "rear"}function Nr(e={},o={}){let t={nodes:e.nodes??[],edges:e.edges??[],debug:e.debug??false},n=new Set;return {getState:()=>t,setState:g=>{t={...t,...g},n.forEach(c=>c(t));},subscribe:g=>(n.add(g),()=>n.delete(g)),selectEdgeZIndex:g=>{let c=t.nodes.find(m=>m.id===g.target);if(!c||c.type!=="device")return 1e3;let f=c.data?.view||"front",x=yo(g.targetHandle||"",c);if(x)return f===x?1e3:500;let C=(g.targetHandle||"").toString(),k=C.toLowerCase(),S=k.startsWith("pwr")||k.startsWith("power"),I=k.startsWith("net-")||k.startsWith("port-")||k.startsWith("uplink-")||k.includes("fiber")||k.includes("ports"),E=/^[A-Z0-9]+-\d+$/i.test(C)&&!k.startsWith("pwr")&&!k.startsWith("power"),D=I||E;return S?f==="rear"?1e3:500:D?f==="front"?1e3:500:1e3},validateConnection:g=>(o.validateConnection||la)(g,t),selectNodeById:g=>t.nodes.find(c=>c.id===g),selectConnectedEdges:g=>t.edges.filter(c=>c.source===g||c.target===g)}}function ca(e){let o=s=>e.subscribe(s),t=()=>e.getState();return useSyncExternalStore(o,t,t)}function Cr(e){let o=n=>e.subscribe(n),t=()=>e.getState().nodes;return useSyncExternalStore(o,t,t)}function vr(e){let o=n=>e.subscribe(n),t=()=>e.getState().edges;return useSyncExternalStore(o,t,t)}function Fn(e){return e.selectEdgeZIndex}function Tn(e){let o=e.data.rackWidthPx||300,t=(e.data.uHeight||42)*20,n=e.position.x,s=e.position.x+o,a=e.position.y,l=e.position.y+t;return {left:n,right:s,top:a,bottom:l}}function wo(e,o){let t=Tn(o);return e.x>=t.left&&e.x<=t.right&&e.y>=t.top&&e.y<=t.bottom}function xo(e,o){let t=null,n=1/0;for(let s of o){if(!wo(e,s))continue;let a=Math.sqrt(Math.pow(e.x-s.position.x,2)+Math.pow(e.y-s.position.y,2));a<n&&(n=a,t=s);}return t}function He(e){let{edges:o,connection:t,edgeType:n,selectEdgeZIndex:s,findBy:a,data:l}=e,i=a==="source"?t.sourceHandle:t.targetHandle,d=a==="source"?t.source:t.target;if(!i||!d)return null;let u=o.find(C=>a==="source"?C.source===d&&C.sourceHandle===i:C.target===d&&C.targetHandle===i);if(!u)return null;let h=o.filter(C=>C.id!==u.id),g=addEdge(t,h),c=g[g.length-1],f=s({...t,id:c.id,type:n}),x={...c,type:n,zIndex:f,style:{...c.style,zIndex:f},data:l!==void 0?l:c.data};return [...g.slice(0,-1),x]}function Wn(e){return !e||e.type!=="splice"?false:e.data?.mode==="ribbon"}var Ce=({type:e,children:o})=>{let t=ft.useRef(null),n=ft.useCallback(s=>{if(t.current=s,s){let a=s.parentElement,l=0;for(;a&&!a.classList.contains("react-flow__node")&&l<10;)a=a.parentElement,l++;a&&a.classList.contains("react-flow__node")&&a.setAttribute("data-type",e);}},[e]);return ft.useEffect(()=>{if(t.current){let s=t.current.parentElement,a=0;for(;s&&!s.classList.contains("react-flow__node")&&a<10;)s=s.parentElement,a++;s&&s.classList.contains("react-flow__node")&&s.setAttribute("data-type",e);}},[e]),jsx("div",{ref:n,style:{width:"100%",height:"100%"},children:o})},Mn=(e,o,t)=>({rack:n=>jsx(Ce,{type:"rack",children:jsx(zo,{...n,onViewChange:e,onRackFaceChange:o,isDragOver:t?t()===n.id:false})}),fiber:n=>jsx(Ce,{type:"fiber",children:jsx(Ao,{...n})}),device:n=>jsx(Ce,{type:"device",children:jsx(mt,{...n})}),server:n=>jsx(Ce,{type:"server",children:jsx(mt,{...n})}),switch:n=>jsx(Ce,{type:"switch",children:jsx(mt,{...n})}),router:n=>jsx(Ce,{type:"router",children:jsx(mt,{...n})}),"vertical-pdu":n=>jsx(Ce,{type:"vertical-pdu",children:jsx(Go,{...n})}),splice:n=>jsx(Ce,{type:"splice",children:jsx(qo,{...n})}),"splice-tray":n=>jsx(Ce,{type:"splice-tray",children:jsx(or,{...n})}),tube:n=>jsx(Ce,{type:"tube",children:jsx(rr,{...n})}),cable:n=>jsx(Ce,{type:"cable",children:jsx(ar,{...n})}),"multi-tube-cable":n=>jsx(Ce,{type:"multi-tube-cable",children:jsx(dr,{...n})}),coupler:n=>jsx(Ce,{type:"coupler",children:jsx(lr,{...n})}),"patch-panel":n=>jsx(Ce,{type:"patch-panel",children:jsx(br,{...n})}),closure:n=>jsx(Ce,{type:"closure",children:jsx(yr,{...n})}),"fibre-split":n=>jsx(Ce,{type:"fibre-split",children:jsx(xr,{...n})})}),Ca={fiber:ro,ethernet:ro,power:Oo,smoothstep:Kr,step:Jr,"thick-cable":tn},va=({nodes:e,edges:o,initialNodes:t,initialEdges:n,onNodesChange:s,onEdgesChange:a,store:l,debug:i,onNodeClick:d,onEdgeClick:u,nodeTypes:h,edgeTypes:g,onConnect:c,onEdgeUpdate:f,isValidConnection:x,connectionMode:C,onViewChange:k,onRackFaceChange:S,className:I,style:E,alignRacksToBottom:D,colorMode:m="dark",onInit:w,onFlowMethods:R,showDownloadButton:F=false,downloadButtonPosition:W="top-right",downloadButtonText:L="Download Image",downloadButtonStyle:j,useSmoothstepEdgesForTubes:re=false,connectOnClick:ae=true,panOnDrag:se=true,panOnScroll:Z=true,zoomOnScroll:M=true,fitViewOptions:H})=>{let A=useCallback((r,p)=>{let b=new Map,y=[],v=[],P=($,q)=>!$||!q?false:!!($.startsWith("tube-")||q.type==="splice"&&($==="left"||$==="right")||$==="cable-button");for(let $ of r){if(!$.source||!$.target||!$.sourceHandle||!$.targetHandle){i&&console.warn("Invalid edge skipped (missing source/target/handles):",$);continue}let q=p.find(Pe=>Pe.id===$.source),K=p.find(Pe=>Pe.id===$.target),be=`${$.source}:${$.sourceHandle}`,ce=b.get(be),ve=P($.sourceHandle,q),me=`${$.target}:${$.targetHandle}`,pe=b.get(me),te=P($.targetHandle,K);if(ce&&!ve){i&&console.warn("Duplicate connection detected on source handle, removing:",{handle:be,existingEdge:ce.id,duplicateEdge:$.id}),v.push($);continue}if(pe&&!te){i&&console.warn("Duplicate connection detected on target handle, removing:",{handle:me,existingEdge:pe.id,duplicateEdge:$.id}),v.push($);continue}y.push($),ce||b.set(be,$),pe||b.set(me,$);}return i&&v.length>0&&console.log(`Filtered ${v.length} duplicate edge(s) from initial edges`),y},[i]),z=Array.isArray(e)&&Array.isArray(o),X=ft.useMemo(()=>z?e||[]:t||e||[],[z,e,t]),oe=ft.useMemo(()=>z?o||[]:n||o||[],[z,o,n]),_=ft.useMemo(()=>A(oe,X),[oe,X,A]),T=ft.useMemo(()=>l||Nr({nodes:X,edges:_,debug:i}),[l,z,i,_]),Q=Cr(T),J=vr(T),[V,O,we]=useNodesState(Q),[Fe,G,he]=useEdgesState(J),ue=Fn(T),qe=useRef(null),[ke,Je]=useState(false);useEffect(()=>{let r=()=>{Je(window.innerWidth<=768||/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));};return r(),window.addEventListener("resize",r),()=>window.removeEventListener("resize",r)},[]);let{toObject:vo,setViewport:So,setNodes:Vt,setEdges:jt,getNodes:$e,getEdges:_e,fitView:Ho}=useReactFlow();useEffect(()=>{R&&R({toObject:vo,setViewport:So,setNodes:r=>{Vt(r),T.setState({nodes:r});},setEdges:r=>{jt(r),T.setState({edges:r});},toImage:r=>qe.current?toPng(qe.current,r):Promise.reject(new Error("ReactFlow wrapper not available")),getNodes:()=>$e(),getEdges:()=>_e(),fitView:r=>{if(r?.nodes&&Array.isArray(r.nodes)&&r.nodes.length>0){let p=r.nodes.map(v=>$e().find(P=>P.id===v)).filter(v=>v!==void 0),{nodes:b,...y}=r;Ho({...y,nodes:p});}else {let{nodes:p,...b}=r||{};Ho(b);}}});},[R,vo,So,Vt,jt,T,Ho,$e,_e]);let ti=useCallback(()=>{if(!qe.current){i&&console.error("ReactFlow wrapper ref is not available");return}toPng(qe.current,{filter:r=>!(r?.classList?.contains("react-flow__minimap")||r?.classList?.contains("react-flow__controls")||r?.classList?.contains("react-flow__attribution")||r?.classList?.contains("download-button")||r?.tagName==="BUTTON"),backgroundColor:m==="light"?"#ffffff":"#1a1a1a",pixelRatio:2}).then(r=>{let p=document.createElement("a");p.download=`network-diagram-${new Date().toISOString().split("T")[0]}.png`,p.href=r,p.click();}).catch(r=>{i&&console.error("Error downloading image:",r);});},[m,i]),[Ir,Yt]=useState(null),Fr=useRef(null),Tr=useRef(k),Dr=useRef(S);useEffect(()=>{Tr.current=k;},[k]),useEffect(()=>{Dr.current=S;},[S]),useEffect(()=>{Fr.current=Ir;},[Ir]);let Po=useCallback((r,p)=>{Tr.current?.(r,p);},[]),Eo=useCallback((r,p)=>{Dr.current?.(r,p);},[]),Ro=useCallback(()=>Fr.current,[]),$r=useRef({...Mn(Po,Eo,Ro),...h??{}});useEffect(()=>{$r.current={...Mn(Po,Eo,Ro),...h??{}};},[Po,Eo,Ro,h]);let oi=useMemo(()=>({...Ca,...g??{}}),[g]),Be=useRef(V);useEffect(()=>{Be.current=V;},[V]);let ee=useRef(Fe);useEffect(()=>{ee.current=Fe;},[Fe]),useEffect(()=>{O(Q);},[Q,O]),useEffect(()=>{G(J);},[J,G]),useEffect(()=>{if(z&&o){let r=A(o,e||[]);r.length!==o.length&&(i&&console.warn(`Controlled edges had ${o.length-r.length} duplicate(s) removed`),a?.(r));}},[z,o,e,A,a,i]),useEffect(()=>{z&&T.setState({nodes:e||[]});},[z,e,T]),useEffect(()=>{z&&T.setState({edges:o||[]});},[z,o,T]),useEffect(()=>{if(!D||!V||V.length===0)return;let r=V.filter(K=>K.type==="rack");if(r.length===0)return;let p=r.map(K=>{let ce=K.data?.uHeight||42,ve=60+ce*20;return (K.position?.y||0)+ve}),b=Math.min(...p),y=Math.max(...p);if(y-b<20)return;let P=y,$=V.map(K=>{if(K.type!=="rack")return K;let ce=K.data?.uHeight||42,ve=60+ce*20,me=(K.position?.y||0)+ve,pe=P-me;return Math.abs(pe)<5?K:{...K,position:{x:K.position?.x||0,y:(K.position?.y||0)+pe}}});$.some((K,be)=>K.position!==V[be].position)&&O($);},[D,V,O]);let Io=useRef(new Map);useEffect(()=>{let r=new Map;V.forEach(p=>{r.set(p.id,p);}),Io.current=r;},[V]);let fe=useCallback(r=>Io.current.get(r),[]),Pt=useCallback((r,p)=>{if(!r||!p)return;let b=fe(r);if(!b)return;let y=p.replace(/-(source|target)$/i,"");if(b.type==="fibre-split"&&y.startsWith("output-")){let P=ee.current.filter($=>$.target===r&&($.targetHandle||"").replace(/-(source|target)$/i,"").startsWith("input-"));if(P.length>0){let $=P[0]?.data?.color;if($)return {color:$}}}if((b.type==="tube"||b.type==="cable")&&p.startsWith("fiber-")){let P=p.replace("fiber-",""),$=parseInt(P,10);if($>=1&&$<=24){let q=it($),K=$>12;return {color:q,striped:K}}}if((b.type==="multi-tube-cable"||b.type==="tube")&&p.startsWith("tube-")){let P=p.replace("tube-",""),$=parseInt(P,10);if($>=1&&$<=24){let q=xe($),K=$>12;return {color:q,striped:K}}}let v=b.data;if(v.color)return {color:v.color}},[fe]),_r=useRef(new Map);useEffect(()=>{G(r=>{let p=false,b=r.map(y=>{let v=ue(y);return _r.current.get(y.id)!==v?(p=true,_r.current.set(y.id,v),{...y,zIndex:v,style:{...y.style,zIndex:v}}):y});return p?b:r});},[V,G,ue]),useEffect(()=>{let r=V.map(b=>{if(b.type==="coupler"&&b.parentId){let y=fe(b.parentId);if(y&&(y.type==="patch-panel"||y.type==="closure")&&(!b.extent||b.extent!=="parent"))return {...b,extent:"parent"}}if(b.type==="splice"&&b.parentId&&b.data.holderPosition&&(!b.position||b.position.x===0&&b.position.y===0)){let y=fe(b.parentId);if(y&&y.type==="splice-tray"){let v=b.data.mode==="ribbon",P=At(y,b.data.holderPosition,v);return {...b,position:P}}}if(b.type==="device"&&b.parentId&&b.data.uPosition&&(!b.position||b.position.x===0&&b.position.y===0)){let y=fe(b.parentId);if(y){let v=bt(y,b.data.uPosition);return {...b,position:v}}}return b});r.some((b,y)=>{let v=V[y];return b.extent!==v.extent||b.position?.x!==v.position?.x||b.position?.y!==v.position?.y})&&O(r);},[V,O,fe]);let ri=useCallback(r=>{let p=r.map(b=>{if(b.type==="position"&&b.position){let y=fe(b.id);if(y&&y.type==="coupler"&&y.parentId){let v=fe(y.parentId);if(v&&(v.type==="patch-panel"||v.type==="closure")){if(!y.extent||y.extent!=="parent"){let P={...y,extent:"parent"};O($=>$.map(q=>q.id===y.id?P:q));}return {...b,position:y.position||{x:0,y:0}}}}if(y&&(y.type==="tube"||y.type==="splice-tray")&&y.parentId){let v=fe(y.parentId);if(v&&v.type==="closure"){if(!y.extent||y.extent!=="parent"){let P={...y,extent:"parent"};O($=>$.map(q=>q.id===y.id?P:q));}return {...b,position:y.position||{x:0,y:0}}}}if(y&&y.type==="splice"&&y.parentId){let v=fe(y.parentId);if(v&&v.type==="splice-tray"){let P=Qo(y,v,b.position,Be.current);if(P.holderPosition!==void 0){let $={...y,data:{...y.data,holderPosition:P.holderPosition}};O(q=>q.map(K=>K.id===y.id?$:K));}return {...b,position:{x:P.x,y:P.y}}}}if(y&&y.type==="device"&&y.parentId){let v=fe(y.parentId);if(v){let P=Mo(y,v,b.position,Be.current);if(P.uPosition!==void 0){let $={...y,data:{...y.data,uPosition:P.uPosition}};O(q=>q.map(K=>K.id===y.id?$:K));}return {...b,position:{x:P.x,y:P.y}}}}if(y&&y.type==="device"&&y.parentId){let v=fe(y.parentId);if(v){let P=v;if(!wo(b.position,P)){let $=b.position.x+P.position.x,q=b.position.y+P.position.y,K={...y,parentId:void 0,extent:void 0,data:{...y.data,uPosition:void 0}};return O(be=>be.map(ce=>ce.id===y.id?K:ce)),{...b,position:{x:$,y:q}}}}}}return b});we(p);},[we,O,fe]),ni=useCallback((r,p)=>{Yt(null);},[]),ii=useCallback((r,p,b)=>{if(p.type==="device"&&!p.parentId){let y=Be.current.filter(P=>P.type==="rack").map(P=>P),v=xo(p.position,y);Yt(v?.id??null);}else Yt(null);},[]),ai=useCallback((r,p,b)=>{if(p.type==="device"&&!p.parentId){let y=Be.current.filter(P=>P.type==="rack").map(P=>P),v=xo(p.position,y);if(v){let P=p.position.x-v.position.x,$=p.position.y-v.position.y,q={...p,parentId:v.id,extent:"parent",position:{x:P,y:$},data:{...p.data,uPosition:1}},K=Be.current.map(be=>be.id===p.id?q:be);O(K),z||T.setState({nodes:K});}}Yt(null);},[O,z,T]),si=useCallback(r=>{if(!r.source||!r.target||!r.sourceHandle||!r.targetHandle)return true;let p=fe(r.source),b=fe(r.target),y=ie(p,r.sourceHandle),v=ie(b,r.targetHandle),P=ee.current.some(U=>U.source===r.source?ie(p,U.sourceHandle)===y:U.target===r.source?ie(p,U.targetHandle)===y:false),$=ee.current.some(U=>U.target===r.target?ie(b,U.targetHandle)===v:U.source===r.target?ie(b,U.sourceHandle)===v:false);P&&i&&console.log("Connection will replace: Source handle already connected",{source:r.source,sourceHandle:r.sourceHandle,existingEdges:ee.current.filter(U=>U.source===r.source&&U.sourceHandle===r.sourceHandle||U.target===r.source&&U.targetHandle===r.sourceHandle)}),$&&i&&console.log("Connection will replace: Target handle already connected",{target:r.target,targetHandle:r.targetHandle,existingEdges:ee.current.filter(U=>U.target===r.target&&U.targetHandle===r.targetHandle||U.source===r.target&&U.sourceHandle===r.targetHandle)});let q=xt(p,b);if((P||$)&&!q)return i&&console.log("Connection rejected: Non-fiber handle already connected",r),false;if(!q)return true;if(p?.type==="splice"&&b?.type==="splice"){let U=p.data?.mode==="ribbon",ge=b.data?.mode==="ribbon";if(U!==ge)return i&&console.log("Connection rejected: Ribbon splices can only connect to other ribbon splices",r),false}let K=(U,ge)=>(U?.type==="tube"||U?.type==="cable")&&!!ge&&ge.startsWith("fiber-"),be=(U,ge)=>(U?.type==="tube"||U?.type==="multi-tube-cable")&&!!ge&&ge.startsWith("tube-"),ce=(U,ge)=>U?.type==="multi-tube-cable"&&!!ge&&ge.startsWith("tube-"),ve=(U,ge)=>U?.type==="tube"&&!!ge&&ge.startsWith("tube-"),me=(U,ge)=>(U?.type==="cable"||U?.type==="multi-tube-cable")&&ge==="cable-button",pe=(U,ge)=>U?.type==="splice"&&(ge==="left"||ge==="right"),te=(U,ge)=>U?.type==="coupler"&&!!ge&&(ge.startsWith("left-")||ge.startsWith("right-")),Pe=(U,ge)=>{if(U?.type!=="fibre-split"||!ge)return false;let zr=ge.replace(/-(source|target)$/i,"");return zr.startsWith("input-")||zr.startsWith("output-")},Me=K(p,r.sourceHandle),Qe=K(b,r.targetHandle),le=pe(p,r.sourceHandle),et=pe(b,r.targetHandle),tt=te(p,r.sourceHandle),Xt=te(b,r.targetHandle),Et=Pe(p,r.sourceHandle),Gt=Pe(b,r.targetHandle),Do=me(p,r.sourceHandle),Kt=me(b,r.targetHandle),$o=ce(p,r.sourceHandle),_o=ce(b,r.targetHandle),Wo=ve(p,r.sourceHandle),N=ve(b,r.targetHandle),B=be(p,r.sourceHandle),ne=be(b,r.targetHandle);return Me&&et||Qe&&le||(le&&(Xt||Gt)||et&&(tt||Et))||(tt&&(Xt||Gt||et)||Xt&&(tt||Et||le))||Do&&Kt||($o&&N||_o&&Wo)?true:B&&ne?(i&&console.log("Connection rejected: Tube handles can only connect between cable and tube nodes",r),false):(i&&console.log("Connection rejected: Connection not allowed by fiber rules",r),false)},[fe,i]),di=useCallback(r=>{i&&console.log("onConnect called:",r);let p=fe(r.source),b=fe(r.target);i&&(console.log("onConnect: sourceNode type:",p?.type,"targetNode type:",b?.type),console.log("onConnect: sourceHandle:",r.sourceHandle,"targetHandle:",r.targetHandle));let y=T.validateConnection({source:r.source??null,target:r.target??null,sourceHandle:r.sourceHandle??null,targetHandle:r.targetHandle??null});if(!y.valid){i&&console.warn(`Connection rejected: ${y.reason}`);return}let v=p?.type==="vertical-pdu",P=p?.data,$=p?.type==="device"&&P?.deviceType==="switch",q=!!r.targetHandle&&(r.targetHandle.startsWith("pwr")||r.targetHandle.startsWith("power")),K=!!r.targetHandle&&(r.targetHandle.startsWith("net-")||r.targetHandle.startsWith("port-")||/^[A-Z0-9]+-\d+$/i.test(r.targetHandle)),be=p?.type==="tube"&&b?.type==="multi-tube-cable",ce=p?.type==="multi-tube-cable"&&b?.type==="tube",ve=be||ce,me=r.sourceHandle==="cable-button"&&r.targetHandle==="cable-button",pe="fiber";v&&q?pe="power":me?pe="thick-cable":ve&&(pe=re?"smoothstep":"fiber");let te,Pe=Wn(b),Me=Wn(p);if(Pe||Me){let N=b?.data,B=p?.data,ne=Pe?N.ribbonFiberIds:B.ribbonFiberIds;ne&&Array.isArray(ne)&&ne.length>=6&&ne.length<=12&&(te={ribbonFiberIds:ne,isRibbon:true});}if(!te&&(pe==="fiber"||pe==="smoothstep")&&!v){let N;be?N=Pt(r.target,r.targetHandle):N=Pt(r.source,r.sourceHandle),N&&(te={color:N.color,striped:N.striped,isRibbon:false});}else if(pe==="thick-cable"&&me){let N=p?.data;te={color:N?.color||(N?.tubeStartIndex?xe(N.tubeStartIndex):"#6366f1")};}let Qe=ie(p,r.sourceHandle),le=ie(b,r.targetHandle),et=ee.current.some(N=>N.source===r.source?ie(p,N.sourceHandle)===Qe:N.target===r.source?ie(p,N.targetHandle)===Qe:false),tt=ee.current.some(N=>N.target===r.target?ie(b,N.targetHandle)===le:N.source===r.target?ie(b,N.sourceHandle)===le:false);if(xt(p,b)&&(et||tt)){let N=new Set;for(let B of ee.current){if(B.source===r.source&&ie(p,B.sourceHandle)===Qe){N.add(B.id);continue}if(B.target===r.source&&ie(p,B.targetHandle)===Qe){N.add(B.id);continue}if(B.source===r.target&&ie(b,B.sourceHandle)===le){N.add(B.id);continue}B.target===r.target&&ie(b,B.targetHandle)===le&&N.add(B.id);}if(N.size>0){let B=ee.current.filter(Ve=>!N.has(Ve.id)),ne=addEdge(r,B),Ee=ne[ne.length-1],Re=ue({...r,id:Ee.id,type:pe}),Ue={...Ee,type:pe,zIndex:Re,style:{...Ee.style,zIndex:Re},data:te!==void 0?te:Ee.data};G([...ne.slice(0,-1),Ue]),i&&console.log("Fiber handle replacement: Replaced",N.size,"edge(s)");return}}if(b?.type==="splice"&&(r.targetHandle==="left"||r.targetHandle==="right")&&r.target&&r.targetHandle){let N=ee.current.find(B=>B.target===r.target&&B.targetHandle===r.targetHandle||B.source===r.target&&B.sourceHandle===r.targetHandle);if(N){i&&(console.log("Splice target handle replacement: Found existing edge",N.id,"on splice handle",r.targetHandle),console.log("Existing edge details:",{id:N.id,source:N.source,target:N.target,sourceHandle:N.sourceHandle,targetHandle:N.targetHandle,data:N.data}));let B=r.source&&r.sourceHandle?ee.current.find(U=>U.source===r.source&&U.sourceHandle===r.sourceHandle):null;i&&B&&console.log("Splice target handle replacement: Also found existing source edge",B.id);let ne=new Set;N&&ne.add(N.id),B&&B.id!==N.id&&ne.add(B.id);let Ee=ee.current.filter(U=>!ne.has(U.id));i&&console.log("Splice target handle replacement: Removing",ne.size,"edge(s), creating new connection");let Re=`edge-${r.source}-${r.sourceHandle}-${r.target}-${r.targetHandle}-${Date.now()}`,Ue=ue({...r,id:Re,type:"fiber"}),Ve={id:Re,source:r.source,target:r.target,sourceHandle:r.sourceHandle,targetHandle:r.targetHandle,type:"fiber",zIndex:Ue,style:{zIndex:Ue},data:te!==void 0?te:{}},Zt=[...Ee,Ve];G(Zt),i&&console.log("Splice target handle replacement: Successfully replaced edge with new edge",Ve.id);return}}if(p?.type==="splice"&&r.sourceHandle==="right"&&r.source&&r.sourceHandle){let N=ee.current.find(B=>B.source===r.source&&B.sourceHandle===r.sourceHandle||B.target===r.source&&B.targetHandle===r.sourceHandle);if(N){i&&console.log("Splice source handle replacement: Found existing edge",N.id,"on splice handle",r.sourceHandle);let B=r.target&&r.targetHandle?ee.current.find(U=>U.target===r.target&&U.targetHandle===r.targetHandle):null;i&&B&&console.log("Splice source handle replacement: Also found existing target edge",B.id);let ne=new Set;N&&ne.add(N.id),B&&B.id!==N.id&&ne.add(B.id);let Ee=ee.current.filter(U=>!ne.has(U.id));i&&console.log("Splice source handle replacement: Removing",ne.size,"edge(s), creating new connection");let Re=`edge-${r.source}-${r.sourceHandle}-${r.target}-${r.targetHandle}-${Date.now()}`,Ue=ue({...r,id:Re,type:"fiber"}),Ve={id:Re,source:r.source,target:r.target,sourceHandle:r.sourceHandle,targetHandle:r.targetHandle,type:"fiber",zIndex:Ue,style:{zIndex:Ue},data:te!==void 0?te:{}},Zt=[...Ee,Ve];G(Zt),i&&console.log("Splice source handle replacement: Successfully replaced edge with new edge",Ve.id);return}}if((p?.type==="tube"||p?.type==="cable")&&r.sourceHandle?.startsWith("fiber-")&&r.source&&r.sourceHandle){let N=He({edges:ee.current,connection:r,edgeType:"fiber",selectEdgeZIndex:ue,findBy:"source",data:te});if(N){G(N);return}}if((b?.type==="tube"||b?.type==="cable")&&r.targetHandle?.startsWith("fiber-")&&r.target&&r.targetHandle){let N=He({edges:ee.current,connection:r,edgeType:"fiber",selectEdgeZIndex:ue,findBy:"target",data:te});if(N){G(N);return}}if((p?.type==="multi-tube-cable"||p?.type==="tube")&&r.sourceHandle?.startsWith("tube-")&&r.source&&r.sourceHandle){let N=He({edges:ee.current,connection:r,edgeType:pe,selectEdgeZIndex:ue,findBy:"source",data:te});if(N){G(N);return}}if((b?.type==="multi-tube-cable"||b?.type==="tube")&&r.targetHandle?.startsWith("tube-")&&r.target&&r.targetHandle){let N=He({edges:ee.current,connection:r,edgeType:pe,selectEdgeZIndex:ue,findBy:"target",data:te});if(N){G(N);return}}if(p?.type==="coupler"&&(r.sourceHandle?.startsWith("left-")||r.sourceHandle?.startsWith("right-"))){let N=He({edges:ee.current,connection:r,edgeType:"fiber",selectEdgeZIndex:ue,findBy:"source",data:te});if(N){G(N);return}}if(b?.type==="coupler"&&(r.targetHandle?.startsWith("left-")||r.targetHandle?.startsWith("right-"))){let N=He({edges:ee.current,connection:r,edgeType:"fiber",selectEdgeZIndex:ue,findBy:"target",data:te});if(N){G(N);return}}if(me&&r.source&&r.sourceHandle&&r.target&&r.targetHandle){let N=p?.data,B=N?.color||(N?.tubeStartIndex?xe(N.tubeStartIndex):"#6366f1"),ne=He({edges:ee.current,connection:r,edgeType:"thick-cable",selectEdgeZIndex:ue,findBy:"source",data:{color:B}});if(ne){G(ne);return}if(ne=He({edges:ee.current,connection:r,edgeType:"thick-cable",selectEdgeZIndex:ue,findBy:"target",data:{color:B}}),ne){G(ne);return}}if(v&&q&&r.target&&r.targetHandle){let N=He({edges:ee.current,connection:r,edgeType:"power",selectEdgeZIndex:ue,findBy:"target",data:te});if(N){G(N);return}}if($&&K&&r.target&&r.targetHandle){let N=He({edges:ee.current,connection:r,edgeType:"fiber",selectEdgeZIndex:ue,findBy:"target",data:te});if(N){G(N);return}}let Et=T.validateConnection({source:r.source??null,target:r.target??null,sourceHandle:r.sourceHandle??null,targetHandle:r.targetHandle??null});if(!Et.valid){if(v&&r.source&&r.sourceHandle){let N=He({edges:ee.current,connection:r,edgeType:q?"power":"fiber",selectEdgeZIndex:ue,findBy:"source",data:te});if(N){G(N);return}}if($&&r.source&&r.sourceHandle){let N=He({edges:ee.current,connection:r,edgeType:"fiber",selectEdgeZIndex:ue,findBy:"source",data:te});if(N){G(N);return}}i&&console.warn(`Connection rejected: ${Et.reason}`);return}let Gt=ee.current.some(N=>N.source===r.source&&N.sourceHandle===r.sourceHandle||N.target===r.source&&N.targetHandle===r.sourceHandle),Do=ee.current.some(N=>N.target===r.target&&N.targetHandle===r.targetHandle||N.source===r.target&&N.sourceHandle===r.targetHandle),Kt=(N,B)=>!N||!B?false:!!(N.startsWith("tube-")||B.type==="splice"&&(N==="left"||N==="right")||N==="cable-button"),$o=Kt(r.sourceHandle||"",p),_o=Kt(r.targetHandle||"",b);if(Gt&&!$o){i&&console.warn("FINAL SAFETY CHECK: Source handle already connected, rejecting duplicate connection",{source:r.source,sourceHandle:r.sourceHandle,existingEdges:ee.current.filter(N=>N.source===r.source&&N.sourceHandle===r.sourceHandle||N.target===r.source&&N.targetHandle===r.sourceHandle)});return}if(Do&&!_o){i&&console.warn("FINAL SAFETY CHECK: Target handle already connected, rejecting duplicate connection",{target:r.target,targetHandle:r.targetHandle,existingEdges:ee.current.filter(N=>N.target===r.target&&N.targetHandle===r.targetHandle||N.source===r.target&&N.sourceHandle===r.targetHandle)});return}let Wo={...r,type:pe,zIndex:ue({...r,id:"temp-id"}),data:te};G(N=>{let B=addEdge(Wo,N),ne=B[B.length-1];return ne&&(Mr(Ee=>new Set(Ee).add(ne.id)),setTimeout(()=>{Mr(Ee=>{let Re=new Set(Ee);return Re.delete(ne.id),Re});},1e3)),B});},[G,T,ue,fe,i,Pt,re]),li=useCallback((r,p)=>{if(!p.source||!p.target||!p.sourceHandle||!p.targetHandle)return;let b=T.validateConnection({source:p.source??null,target:p.target??null,sourceHandle:p.sourceHandle??null,targetHandle:p.targetHandle??null});if(!b.valid){i&&console.warn(`Edge update rejected: ${b.reason}`);return}let y=fe(p.source),v=fe(p.target),P=y?.type==="vertical-pdu",$=!!p.targetHandle&&(p.targetHandle.startsWith("pwr")||p.targetHandle.startsWith("power")),q=y?.type==="tube"&&v?.type==="multi-tube-cable",K=y?.type==="multi-tube-cable"&&v?.type==="tube",be=q||K,ce;P&&$?ce="power":be?ce=re?"smoothstep":"fiber":ce="fiber";let ve;if((ce==="fiber"||ce==="smoothstep")&&!P){let me=Pt(p.source,p.sourceHandle);me&&(ve={color:me.color,striped:me.striped});}G(me=>{let pe=xt(y,v),te=ie(y,p.sourceHandle),Pe=ie(v,p.targetHandle);return (pe?me.filter(le=>{if(le.id===r.id)return true;let et=le.source===p.source&&ie(y,le.sourceHandle)===te||le.target===p.source&&ie(y,le.targetHandle)===te,tt=le.target===p.target&&ie(v,le.targetHandle)===Pe||le.source===p.target&&ie(v,le.sourceHandle)===Pe;return !(et||tt)}):me).map(le=>le.id===r.id?{...le,source:p.source,target:p.target,sourceHandle:p.sourceHandle,targetHandle:p.targetHandle,type:ce,data:ve!==void 0?{...le.data,...ve}:le.data,zIndex:ue({...p,id:le.id,type:ce}),style:{...le.style,zIndex:ue({...p,id:le.id,type:ce})}}:le)});},[G,fe,Pt,ue,re,i,T]),ci=useCallback((r,p)=>{if(ke){d&&d(p);return}let b=r.metaKey||r.ctrlKey;if(p.type==="tube"&&p.parentId&&!b){let v=$e().find(P=>P.id===p.parentId&&(P.type==="cable"||P.type==="multi-tube-cable"));if(v){O(P=>P.map($=>({...$,selected:$.id===v.id}))),d&&d(v);return}}if(b&&p.type==="device"){let y=p.data||{},v=y.view||(Array.isArray(y.rearPorts)&&y.rearPorts.length>0?"rear":"front"),P=v==="front"?"rear":"front";i&&console.log(`Command+click: Toggling device ${p.id} from ${v} to ${P}`),k&&k(p.id,P),d&&d(p);}else d&&d(p);},[k,d,i,$e,O,ke]),ui=useCallback(()=>{},[]),pi=useCallback((r,p)=>{u&&u(p);},[u]),[We,Fo]=useState(null),[Wr,Mr]=useState(new Set);useOnSelectionChange({onChange:({nodes:r,edges:p})=>{if(Lr(p||[]),!ke)if(r&&r.length===1){let b=r[0];if(b.type==="tube"&&b.parentId){let v=$e().find(P=>P.id===b.parentId&&(P.type==="cable"||P.type==="multi-tube-cable"));if(v){Fo(v),O(P=>P.map($=>({...$,selected:$.id===v.id}))),d&&d(v);return}}Fo(b),d&&d(b);}else Fo(null),d&&d(null);}});let[To,Lr]=useState([]);useEffect(()=>{let r=p=>{if((p.key==="Backspace"||p.key==="Delete")&&To.length>0){if(document.activeElement?.tagName==="INPUT"||document.activeElement?.tagName==="TEXTAREA")return;let b=To.filter(y=>{let v=y.sourceHandle||"",P=y.targetHandle||"";return v.startsWith("tube-")||P.startsWith("tube-")?(i&&console.log("Cannot delete edge connected to tube handle",y),false):true});if(b.length>0){let y=new Set(b.map(v=>v.id));G(v=>v.filter(P=>!y.has(P.id))),Lr([]),i&&console.log("Deleted edges:",b.map(v=>v.id));}}};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[To,G,i]);let gi=useCallback((r,{nodeId:p,handleType:b})=>{i&&console.log("Connection started from",{nodeId:p,handleType:b});},[i]),fi=useCallback(r=>{i&&console.log("Connection ended",r);},[i]),bi=useCallback(()=>{if(!We)return;let r=fe(We.id);if(r){if(r.type==="rack"){let y=((r.data||{}).face||"front")==="front"?"rear":"front";S?(S(r.id,y),k&&$e().filter(P=>P.parentId===r.id).forEach(P=>{k(P.id,y);})):O(v=>v.map(P=>P.id===r.id?{...P,data:{...P.data,face:y}}:P.parentId===r.id?{...P,data:{...P.data,view:y}}:P));return}if(r.type==="device"){let p=r.data||{},b=Array.isArray(p.rearPorts)&&p.rearPorts.length>0,y=Array.isArray(p.ports)&&p.ports.length>0,P=(p.view||(b&&!y?"rear":"front"))==="front"?"rear":"front";k?k(r.id,P):O($=>$.map(q=>q.id===r.id?{...q,data:{...q.data,view:P}}:q));}}},[We,fe,S,k,O,$e]),hi=useMemo(()=>{let r=Io.current;return Fe.map(p=>{let b=p,y=r.get(String(b.source)),v=r.get(String(b.target)),P=yo(b.sourceHandle||"",y),$=yo(b.targetHandle||"",v),q=y&&y.data?.view,K=v&&v.data?.view,be=y?.type==="device"&&q==="rear",ce=v?.type==="device"&&K==="rear",pe=be&&P!=="rear"||ce&&$!=="rear",te=p.style;if(pe)te={...p.style,opacity:0,pointerEvents:"none",zIndex:0};else if(p.style&&p.style.opacity===0&&p.style.pointerEvents==="none"&&p.style.zIndex===0){let Me={...p.style};delete Me.opacity,delete Me.pointerEvents,delete Me.zIndex,te=Object.keys(Me).length>0?Me:void 0;}return {...p,style:te,className:Wr.has(p.id)?"edge-connecting":p.className}})},[Fe,Wr]),mi=Or(m,I),yi=Ur(m,{touchAction:"none",...E});return jsxs("div",{ref:qe,className:mi,style:yi,children:[jsxs(ReactFlow,{nodes:V,edges:hi,onNodesChange:r=>{ri(r),z?s&&s(Be.current):T.setState({nodes:Be.current});},onEdgesChange:r=>{let p=r.filter(b=>{if(b.type==="remove"){let y=ee.current.find(v=>v.id===b.id);if(y){let v=y.sourceHandle||"",P=y.targetHandle||"";if(v.startsWith("tube-")||P.startsWith("tube-"))return i&&console.log("Edge deletion blocked: Edge connected to tube handle is not detachable",y),false}}return true});if(p.length>0){let b=applyEdgeChanges(p,ee.current);he(p),z?a&&a(b):T.setState({edges:b});}},onConnect:c??di,onConnectStart:gi,onConnectEnd:fi,onEdgeUpdate:f??li,isValidConnection:x??si,connectionMode:C,onNodeClick:ci,onNodeDoubleClick:ui,onNodeDragStart:ni,onNodeDrag:ii,onNodeDragStop:ai,onEdgeClick:pi,onInit:w,nodeTypes:$r.current,edgeTypes:oi,defaultEdgeOptions:{zIndex:1e3,reconnectable:true},nodesDraggable:!ke,nodesConnectable:true,elementsSelectable:!ke,edgesFocusable:!ke,selectNodesOnDrag:false,connectOnClick:ae,panOnDrag:se,panOnScroll:Z&&!ke,zoomOnScroll:M&&!ke,preventScrolling:ke,onlyRenderVisibleElements:true,fitView:true,fitViewOptions:H,proOptions:{hideAttribution:true},children:[jsx(Background,{color:Br(m)}),jsx(Controls,{}),!ke&&jsx(MiniMap,{}),jsx(Panel,{position:"bottom-right",className:"react-networks-attribution",children:jsx("a",{href:"https://github.com/MP70/react-networks",target:"_blank",rel:"noopener noreferrer",className:"react-networks-attribution-link",children:"react-networks"})})]}),F&&jsx("button",{className:"download-button",onClick:ti,style:{position:"absolute",top:W.includes("top")?"10px":"auto",bottom:W.includes("bottom")?"10px":"auto",right:W.includes("right")?"10px":"auto",left:W.includes("left")?"10px":"auto",zIndex:1e3,background:"#374151",color:"#e5e7eb",border:"1px solid #4b5563",borderRadius:"4px",padding:"0.5rem 0.75rem",fontSize:"0.875rem",cursor:"pointer",transition:"all 0.2s ease",...j},children:L}),We&&(We.type==="rack"||We.type==="device")&&jsx("div",{style:{position:"absolute",top:12,right:12,display:"flex",gap:8,zIndex:2e3},children:jsx("button",{onClick:r=>{r.preventDefault(),bi();},style:{background:"#374151",color:"#e5e7eb",border:"1px solid #4b5563",borderRadius:4,padding:"6px 10px",fontSize:11,fontFamily:"monospace",cursor:"pointer"},title:(()=>{let r=We.data;if(We.type==="rack")return (r?.face||"front")==="front"?"Switch to rear":"Switch to front";{let p=Array.isArray(r?.rearPorts)&&r.rearPorts.length>0,b=Array.isArray(r?.ports)&&r.ports.length>0;return (r?.view||(p&&!b?"rear":"front"))==="front"?"Switch to rear":"Switch to front"}})(),children:(()=>{let r=We.data;if(We.type==="rack")return (r?.face||"front")==="front"?"\u21C4 Rear":"\u21C4 Front";{let p=Array.isArray(r?.rearPorts)&&r.rearPorts.length>0,b=Array.isArray(r?.ports)&&r.ports.length>0;return (r?.view||(p&&!b?"rear":"front"))==="front"?"\u21C4 Rear":"\u21C4 Front"}})()})})]})},Sr=e=>jsx(ReactFlowProvider,{children:jsx(va,{...e})});var Hr=class extends Component{constructor(){super(...arguments);this.state={error:null};this.reset=()=>{this.setState({error:null});};}static getDerivedStateFromError(t){return {error:t}}componentDidCatch(t,n){this.props.onError?.(t,n);}render(){let{error:t}=this.state,{children:n,fallback:s}=this.props;return t?typeof s=="function"?s(t,this.reset):s??jsxs("div",{role:"alert",style:{padding:16,margin:8,border:"1px solid #e53e3e",borderRadius:4,backgroundColor:"#fff5f5",color:"#c53030"},children:[jsx("strong",{children:"Diagram error"}),": ",t.message,jsx("button",{type:"button",onClick:this.reset,style:{marginLeft:12,padding:"4px 8px",cursor:"pointer"},children:"Try again"})]}):n}};function Ut(e,{rowHeight:o,tubeGap:t}){let n=[],s=[],a=e.kind??(e.tubeCount?"tube":"simple"),l=a==="tube"?Math.max(1,Math.min(24,e.tubeCount??1)):1,i=a==="tube"?Math.max(1,Math.min(24,e.fibersPerTube??12)):Math.max(1,Math.min(24,e.fiberCount??12)),d=Math.max(1,e.tubeStartIndex??1),u=Math.max(1,e.fiberStartIndex??1),h=0;for(let g=0;g<l;g+=1){let c=d+g,f=e.tubeColorMap?.[c];s.push({tubeIndex:c,y:h,label:`T${c}`,color:f??xe(c)});for(let x=0;x<i;x+=1){let C=u+x,k=ze(C);n.push({key:`${c}-${C}`,tubeIndex:a==="tube"?c:void 0,fiberIndex:C,y:h,color:it(C),striped:nt(C),backgroundImage:typeof k.backgroundImage=="string"?k.backgroundImage:void 0}),h+=o;}g<l-1&&(h+=t);}return {rows:n,tubeLabels:s,height:h}}var Un=e=>`fiber-${e.tube??1}-${e.fiber}`,Vn=e=>it(e.fiber),jn=e=>nt(e.fiber),Ra=(e,o)=>{if(o)return o;if(!(typeof e!="number"||Number.isNaN(e)))return e>=1e3?`${(e/1e3).toFixed(1)} km`:`${Math.round(e)} m`},Ia=({id:e,sourceX:o,sourceY:t,targetX:n,targetY:s,sourcePosition:a,targetPosition:l,data:i})=>{let[d,u,h]=getBezierPath({sourceX:o,sourceY:t,targetX:n,targetY:s,sourcePosition:a,targetPosition:l,curvature:.35}),g=typeof i?.lossDb=="number"?`${i.lossDb.toFixed(2)} dB`:"",c=i?.label??g,f=i?.sourceColor,x=i?.targetColor,C=i?.color??f??x??"#94a3b8",k=i?.sourceStriped??false,S=i?.targetStriped??false,I=i?.highlighted??true,E=i?.dimmed??false,D=i?.circuitId,m=i?.circuitLabel??D,w=i?.showCircuitId??false,R=f&&x&&f!==x,F=n-o,W=s-t,L=Math.sqrt(F*F+W*W),j=u-o,re=h-t,ae=Math.sqrt(j*j+re*re),se=L>0?ae/L*100:50,Z=`fibre-flow-gradient-${e}`,M=k&&!S,H=S&&!k,A=k&&S,z=L*1.25,X=z/2,oe=12,_=Math.ceil(X*1.2/oe),T=Array(_).fill("6 6").join(" "),Q=Math.ceil(X*1.2/oe),J=Array(Q).fill("6 6").join(" "),V=w&&m,O=Math.max(c?c.length*6.2+16:0,V?(m?.length||0)*5.5+16:0),we=V?32:16;return jsxs(Fragment,{children:[jsx("defs",{children:R&&jsxs("linearGradient",{id:Z,x1:o,y1:t,x2:n,y2:s,gradientUnits:"userSpaceOnUse",children:[jsx("stop",{offset:"0%",stopColor:f}),jsx("stop",{offset:`${se}%`,stopColor:f}),jsx("stop",{offset:`${se}%`,stopColor:x}),jsx("stop",{offset:"100%",stopColor:x})]})}),R?jsx("path",{id:e,d,fill:"none",stroke:`url(#${Z})`,strokeWidth:I?4:3,strokeLinecap:"round",strokeLinejoin:"round",opacity:E?.25:1,strokeOpacity:E?.25:1,style:{mixBlendMode:"normal"}}):jsx(BaseEdge,{id:e,path:d,style:{stroke:C,strokeWidth:I?4:3,strokeLinecap:"round",strokeLinejoin:"round",opacity:E?.25:1,strokeOpacity:E?.25:1,mixBlendMode:"normal"}}),(A||M||H)&&jsx("path",{id:`${e}-stripe`,d,fill:"none",stroke:"#000",strokeWidth:I?1.6:1.3,strokeLinecap:"round",strokeLinejoin:"round",strokeDasharray:M?`${T} ${z}`:H?`${X} ${J} ${z}`:"6 6",strokeDashoffset:0,opacity:E?.2:.9,style:{mixBlendMode:"normal"}}),(c||V)&&I&&jsx(EdgeLabelRenderer,{children:jsxs("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${u}px, ${h}px)`,width:O,height:we,background:"rgba(248, 250, 252, 0.92)",border:"1px solid rgba(15, 23, 42, 0.4)",borderRadius:4,fontSize:10,fontFamily:"monospace",color:"rgba(15, 23, 42, 0.9)",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",pointerEvents:"none",padding:"2px 4px",zIndex:9999},children:[c&&jsx("div",{style:{lineHeight:1.2},children:c}),V&&jsx("div",{style:{fontSize:8,opacity:.8,lineHeight:1.2,marginTop:c?2:0},children:m})]})})]})},Fa=({id:e,sourceX:o,sourceY:t,targetX:n,targetY:s,sourcePosition:a,targetPosition:l,data:i})=>{let[d,u,h]=getBezierPath({sourceX:o,sourceY:t,targetX:n,targetY:s,sourcePosition:a,targetPosition:l,curvature:.2}),g=i?.label,c=i?.color??"#64748b";return jsxs(Fragment,{children:[jsx(BaseEdge,{id:e,path:d,style:{stroke:c,strokeWidth:3,opacity:.85,strokeDasharray:"8 10"}}),g&&jsx(EdgeLabelRenderer,{children:jsx("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${u}px, ${h}px)`,padding:"2px 8px",background:"rgba(30, 41, 59, 0.9)",border:`1px solid ${c}`,borderRadius:10,fontSize:10,fontFamily:"monospace",color:"#e2e8f0",letterSpacing:.2,whiteSpace:"nowrap",pointerEvents:"none",zIndex:9999},children:g})})]})},Ta=({data:e})=>{let{cable:o,side:t,rowHeight:n,columnWidth:s,showTubeLabels:a,showFiberNumbers:l,layout:i,colorMode:d="dark"}=e,u=d==="light",h=8,g=12,c=-1,f=0,x=o.jacketColor??"#facc15",C=(o.kind??(o.tubeCount?"tube":"simple"))==="tube",k=a&&C,S=t==="left"?h+f:f,I=t==="right"?h+f:f,E=t==="left"?Position.Right:Position.Left,D={width:4,height:4,borderRadius:"50%",background:x,border:`1px solid ${x}`,boxShadow:"0 0 1px rgba(0,0,0,0.4)",top:"50%",position:"absolute",...t==="left"?{left:0,transform:"translate(-50%, -50%)"}:{right:0,transform:"translate(50%, -50%)"}};return jsxs("div",{style:{position:"relative",width:s,height:i.height,fontFamily:"monospace",color:"inherit",overflow:"visible"},children:[jsx("div",{style:{position:"absolute",top:-18,left:t==="left"?0:void 0,right:t==="right"?0:void 0,fontSize:10,fontWeight:700,letterSpacing:.4,textTransform:"uppercase",background:u?"rgba(248, 250, 252, 0.95)":"rgba(15, 23, 42, 0.9)",color:u?"#1a1a1a":"#f8fafc",padding:"2px 6px",borderRadius:4,whiteSpace:"nowrap",maxWidth:s,overflow:"hidden",textOverflow:"ellipsis",zIndex:10,...t==="right"?{textAlign:"right"}:{}},children:o.label}),jsx("div",{style:{position:"absolute",top:0,bottom:0,width:h,left:t==="left"?0:void 0,right:t==="right"?0:void 0,borderRadius:4,background:C?"transparent":x,border:`1px solid ${x}`,boxShadow:C?"none":"inset 0 0 3px rgba(0,0,0,0.3)",overflow:"hidden"},children:C&&i.tubeLabels.map((m,w)=>{let R=i.rows.filter(ae=>ae.tubeIndex===m.tubeIndex);if(R.length===0)return null;let F=R[0].y,W=R[R.length-1].y+n,L=W-F,j=i.tubeLabels[w+1],re=j&&j.y-W>0;return jsx("div",{style:{position:"absolute",top:F,left:0,right:0,height:L,background:m.color,borderLeft:`2px solid ${m.color}`,borderRight:`2px solid ${m.color}`,borderTop:w===0?`2px solid ${m.color}`:"1px solid rgba(0,0,0,0.15)",borderBottom:re?"1px solid rgba(0,0,0,0.15)":`2px solid ${m.color}`,boxShadow:"inset 0 0 3px rgba(0,0,0,0.1)",borderRadius:w===0&&!re||w===0?"4px 4px 0 0":re?"0":"0 0 4px 4px",zIndex:2}},`tube-segment-${m.tubeIndex}`)})}),!k&&jsx("div",{style:{position:"absolute",top:0,bottom:0,left:S,right:I,...t==="left"?{borderRight:`1px solid ${x}`}:{borderLeft:`1px solid ${x}`},pointerEvents:"none",zIndex:0}}),C&&i.tubeLabels.map((m,w)=>{let R=i.rows.filter(j=>j.tubeIndex===m.tubeIndex);if(R.length===0)return null;let F=R[0].y,L=R[R.length-1].y+n-F;return jsx("div",{style:{position:"absolute",top:F,left:S,right:I,height:L,...t==="left"?{borderRight:`2px solid ${m.color}`}:{borderLeft:`2px solid ${m.color}`},opacity:.5,pointerEvents:"none"}},`tube-border-${m.tubeIndex}`)}),i.rows.map(m=>{let w=`fiber-${m.tubeIndex??1}-${m.fiberIndex}`,R=m.y+n/2,F={position:"absolute",width:g,height:g,borderRadius:"50%",top:R,background:m.backgroundImage?m.backgroundImage:m.color,backgroundColor:m.color,border:`2px solid ${m.color}`,boxShadow:"0 0 6px rgba(0,0,0,0.3)",...t==="left"?{right:-g/2}:{left:-g/2},transform:"translateY(-50%)",zIndex:1e3,cursor:"crosshair","--fiber-bg":m.color,minWidth:g,minHeight:g};m.backgroundImage&&(F["--fiber-bg-image"]=m.backgroundImage);let W=t==="left"?{right:g+c,textAlign:"right"}:{left:g+c,textAlign:"left"};return jsxs(ft.Fragment,{children:[jsx(Handle,{id:w,type:"source",position:E,className:"fibre-flow-handle",style:F,isConnectable:true,"data-fiber-idx":m.fiberIndex,"data-tube-idx":m.tubeIndex,"data-fiber-color":m.color}),jsx(Handle,{id:w,type:"target",position:E,className:"fibre-flow-handle",style:F,isConnectable:true,"data-fiber-idx":m.fiberIndex,"data-tube-idx":m.tubeIndex,"data-fiber-color":m.color}),l&&jsx("div",{style:{position:"absolute",top:m.y+n/2-6,...W,fontSize:8,fontWeight:600,color:u?"rgba(15, 23, 42, 0.7)":"rgba(148, 163, 184, 0.95)",whiteSpace:"nowrap",lineHeight:1},children:m.fiberIndex})]},m.key)}),jsx(Handle,{id:"cable-run",type:"source",position:t==="left"?Position.Left:Position.Right,className:"cable-run-handle",style:D,isConnectable:true,"data-handle-type":"cable-run"}),jsx(Handle,{id:"cable-run",type:"target",position:t==="left"?Position.Left:Position.Right,className:"cable-run-handle",style:D,isConnectable:true,"data-handle-type":"cable-run"})]})},Da=({data:e})=>{let o=e.colorMode==="light";return jsx("div",{style:{width:e.width,height:e.height,background:"transparent",border:o?"1px solid rgba(148, 163, 184, 0.3)":"1px solid rgba(148, 163, 184, 0.5)",borderRadius:12,boxShadow:o?"0 12px 24px rgba(0, 0, 0, 0.1)":"0 12px 24px rgba(15, 23, 42, 0.2)",position:"relative",pointerEvents:"none"},children:jsx("div",{style:{height:e.headerHeight,display:"flex",alignItems:"center",justifyContent:"center",fontFamily:"monospace",fontWeight:700,fontSize:12,letterSpacing:.6,textTransform:"uppercase",color:o?"rgba(15, 23, 42, 0.9)":"rgba(226, 232, 240, 0.9)",background:o?"rgba(241, 245, 249, 0.7)":"rgba(15, 23, 42, 0.6)",borderBottom:o?"1px solid rgba(148, 163, 184, 0.2)":"1px solid rgba(148, 163, 184, 0.35)",borderTopLeftRadius:12,borderTopRightRadius:12},children:e.label})})},$a=(e,o,t,n,s,a,l,i,d,u="dark")=>{let h=[],g=0;return e.forEach(c=>{let f=Ut(c.leftCable,{rowHeight:t,tubeGap:n}),x=Ut(c.rightCable,{rowHeight:t,tubeGap:n}),C=Math.max(f.height,x.height),k=a*2+l,S=32,I=16,E=k+I*2,D=C+S+I*2,m=`flow-closure-${c.id}`,w=`flow-cable-${c.id}-left`,R=`flow-cable-${c.id}-right`,F=o==="horizontal"?{x:g,y:0}:{x:0,y:g};g+=(o==="horizontal"?E:D)+s;let W=c.chamberId?`${c.id} - ${c.chamberId}`:c.id;h.push({id:m,type:"fibre-flow-closure",position:F,data:{label:W,width:E,height:D,headerHeight:S,colorMode:u},selectable:false,draggable:false,style:{width:E,height:D}});let L=S+I+(C-f.height)/2,j=S+I+(C-x.height)/2;h.push({id:w,type:"fibre-flow-cable",position:{x:I,y:L},parentId:m,extent:"parent",data:{label:c.leftCable.label,cable:c.leftCable,side:"left",rowHeight:t,columnWidth:a,showTubeLabels:i,showFiberNumbers:d,layout:f,colorMode:u},style:{width:a,height:f.height}}),h.push({id:R,type:"fibre-flow-cable",position:{x:I+k-a,y:j},parentId:m,extent:"parent",data:{label:c.rightCable.label,cable:c.rightCable,side:"right",rowHeight:t,columnWidth:a,showTubeLabels:i,showFiberNumbers:d,layout:x,colorMode:u},style:{width:a,height:x.height}});}),h},_a=(e,o,t,n=false)=>{let s=[],a=new Map,l=new Map,i=new Map;return (o??[]).forEach(d=>{d.color&&a.set(d.id,d.color),d.label&&l.set(d.id,d.label);}),e.forEach(d=>{let u=`flow-cable-${d.id}-left`,h=`flow-cable-${d.id}-right`;[{nodeId:u,cable:d.leftCable},{nodeId:h,cable:d.rightCable}].forEach(({nodeId:c,cable:f})=>{let x=i.get(f.id);if(x&&x.closureId!==d.id){let C=Ra(f.distanceMeters??x.distanceMeters,f.distanceLabel??x.distanceLabel),k=f.jacketColor??x.jacketColor??"#64748b";s.push({id:`flow-link-${x.nodeId}-${c}`,type:"fibre-flow-link",source:x.nodeId,target:c,sourceHandle:"cable-run",targetHandle:"cable-run",data:{label:C,color:k}});}i.set(f.id,{nodeId:c,closureId:d.id,jacketColor:f.jacketColor,distanceLabel:f.distanceLabel,distanceMeters:f.distanceMeters});}),d.splices.forEach(c=>{let f=t?c.circuitId===t:true,x=!!t&&!f,C=c.circuitId?a.get(c.circuitId):void 0,k=c.circuitId?l.get(c.circuitId):void 0,S=c.color??C,I=Vn(c.from),E=Vn(c.to),D=jn(c.from),m=jn(c.to);s.push({id:`flow-edge-${d.id}-${c.id}`,type:"fibre-flow",source:u,target:h,sourceHandle:Un(c.from),targetHandle:Un(c.to),data:{lossDb:c.lossDb,label:c.label,color:S,sourceColor:I,targetColor:E,sourceStriped:D,targetStriped:m,highlighted:f,dimmed:x,circuitId:c.circuitId,circuitLabel:k,showCircuitId:n}});});}),s},Wa=({closures:e,circuits:o,highlightedCircuitId:t,layout:n="horizontal",rowHeight:s=20,tubeGap:a=10,closureGap:l=140,cableColumnWidth:i=32,spliceAreaWidth:d=260,showTubeLabels:u=true,showFiberNumbers:h=true,colorMode:g="dark",showCircuitId:c=false,className:f,style:x,panOnDrag:C=true,panOnScroll:k=true,zoomOnScroll:S=true})=>{let I=useMemo(()=>$a(e,n,s,a,l,i,d,u,h,g),[e,n,s,a,l,i,d,u,h,g]),E=useMemo(()=>_a(e,o,t,c),[e,o,t,c]),[D,m]=useState(I),[w,R]=useState(E);useEffect(()=>{m(I);},[I,m]),useEffect(()=>{R(E);},[E,R]);let F=useCallback((H,A)=>{if(!H||!A||!A.startsWith("fiber-"))return;let z=D.find(J=>J.id===H);if(!z||z.type!=="fibre-flow-cable")return;let X=/^fiber-(\d+)-(\d+)$/.exec(A);if(!X)return;let oe=Number(X[1]),_=Number(X[2]),Q=z.data.layout.rows.find(J=>(J.tubeIndex??1)===oe&&J.fiberIndex===_);if(Q)return {color:Q.color,striped:Q.striped??false}},[D]),W=useCallback(H=>{if(!H.source||!H.target||!H.sourceHandle||!H.targetHandle)return false;let A=D.find(T=>T.id===H.source),z=D.find(T=>T.id===H.target);if(!A||!z)return false;let X=typeof H.sourceHandle=="string"&&H.sourceHandle.startsWith("fiber-"),oe=typeof H.targetHandle=="string"&&H.targetHandle.startsWith("fiber-");return H.sourceHandle==="cable-run"||H.targetHandle==="cable-run"?true:X&&oe?A.type==="fibre-flow-cable"&&z.type==="fibre-flow-cable":false},[D]),L=useCallback(H=>{let A=H.sourceHandle==="cable-run"||H.targetHandle==="cable-run",z=V=>typeof V=="string"&&V.startsWith("fiber-"),X=z(H.sourceHandle),oe=z(H.targetHandle),_=(V,O,we)=>V.source===O&&V.sourceHandle===we||V.target===O&&V.targetHandle===we,T=A?void 0:F(H.source,H.sourceHandle),Q=A?void 0:F(H.target,H.targetHandle),J=A?void 0:{sourceColor:T?.color,targetColor:Q?.color,color:T?.color??Q?.color,sourceStriped:T?.striped,targetStriped:Q?.striped};R(V=>{let O=V.filter(we=>{let Fe=X&&_(we,H.source,H.sourceHandle),G=oe&&_(we,H.target,H.targetHandle);return !(Fe||G)});return addEdge({...H,type:A?"fibre-flow-link":"fibre-flow",data:J},O)});},[F,R]),j=useCallback((H,A)=>{let z=A.sourceHandle==="cable-run"||A.targetHandle==="cable-run",X=z?void 0:F(A.source,A.sourceHandle),oe=z?void 0:F(A.target,A.targetHandle),_=z?void 0:{sourceColor:X?.color,targetColor:oe?.color,color:X?.color??oe?.color,sourceStriped:X?.striped,targetStriped:oe?.striped},T=J=>typeof J=="string"&&J.startsWith("fiber-"),Q=(J,V,O)=>J.source===V&&J.sourceHandle===O||J.target===V&&J.targetHandle===O;R(J=>{let V=J.filter(G=>G.id!==H.id),O=T(A.sourceHandle),we=T(A.targetHandle),Fe=V.filter(G=>{let he=O&&Q(G,A.source,A.sourceHandle),ue=we&&Q(G,A.target,A.targetHandle);return !(he||ue)});return addEdge({...A,type:z?"fibre-flow-link":"fibre-flow",data:_},Fe)});},[F,R]),re=useCallback(H=>{m(H);},[m]),ae=useCallback(H=>{R(H);},[R]),se=useMemo(()=>({"fibre-flow-cable":Ta,"fibre-flow-closure":Da}),[]),Z=useMemo(()=>({"fibre-flow":Ia,"fibre-flow-link":Fa}),[]),M={borderRadius:8,overflow:"hidden",...x};return jsx(Sr,{nodes:D,edges:w,onNodesChange:re,onEdgesChange:ae,onConnect:L,onEdgeUpdate:j,isValidConnection:W,connectionMode:ConnectionMode.Loose,nodeTypes:se,edgeTypes:Z,className:f,style:M,colorMode:g,panOnDrag:C,panOnScroll:k,zoomOnScroll:S,fitViewOptions:{padding:.2}})},Ma=e=>jsx(Wa,{...e});var Aa=({cable:e,side:o,rowHeight:t=22,tubeGap:n=10,columnWidth:s=150,layout:a,showTubeLabels:l,showFiberNumbers:i=true,showCableLabel:d=true})=>{let u=useMemo(()=>a??Ut(e,{rowHeight:t,tubeGap:n}),[a,e,t,n]),h=26,g=10,c=18,f=o==="left"?s-c:c,x=8,C=o==="left"?6:s-h-18,k=e.jacketColor??"#facc15",S=l??(e.kind??(e.tubeCount?"tube":"simple"))==="tube";return jsxs("div",{style:{position:"relative",width:s,height:u.height,fontFamily:"monospace",color:"inherit"},children:[d&&jsx("div",{style:{position:"absolute",top:-18,left:o==="left"?0:void 0,right:o==="right"?0:void 0,fontSize:10,fontWeight:700,letterSpacing:.4,textTransform:"uppercase",background:"rgba(15, 23, 42, 0.85)",color:"#f8fafc",padding:"2px 6px",borderRadius:4},children:e.label}),jsx("div",{style:{position:"absolute",top:0,bottom:0,width:h,left:o==="left"?0:void 0,right:o==="right"?0:void 0,borderRadius:14,background:`linear-gradient(90deg, ${k} 0%, ${k} 60%, rgba(0,0,0,0.25) 100%)`,border:`2px solid ${k}`,boxShadow:"inset 0 0 6px rgba(0,0,0,0.4)"}}),S&&u.tubeLabels.map(I=>jsxs("div",{style:{position:"absolute",top:I.y+t/2-6,left:C,fontSize:9,fontWeight:700,textTransform:"uppercase",color:"rgba(15, 23, 42, 0.75)",background:"rgba(255, 255, 255, 0.6)",padding:"1px 6px 1px 4px",borderRadius:10,display:"flex",alignItems:"center",gap:4},children:[jsx("span",{style:{width:8,height:8,borderRadius:"50%",backgroundColor:I.color,border:"1px solid rgba(0, 0, 0, 0.4)",boxShadow:"0 0 3px rgba(0,0,0,0.25)"}}),jsx("span",{children:I.label})]},`tube-${I.tubeIndex}`)),u.rows.map(I=>{let E=I.y+t/2-g/2,D=o==="left"?f-g/2-x:f+g/2+x;return jsxs(ft.Fragment,{children:[jsx("div",{style:{position:"absolute",top:E,left:f-g/2,width:g,height:g,borderRadius:"50%",backgroundColor:I.color,backgroundImage:I.backgroundImage,border:"1px solid rgba(0, 0, 0, 0.4)",boxShadow:"0 0 4px rgba(0,0,0,0.25)"}}),i&&jsx("div",{style:{position:"absolute",top:I.y+t/2-6,left:D,transform:o==="left"?"translateX(-100%)":"none",fontSize:10,fontWeight:600,color:"rgba(15, 23, 42, 0.75)"},children:I.fiberIndex})]},I.key)})]})};var Zn=e=>({id:`rack-${e.id}`,type:"rack",position:{x:0,y:0},data:{label:e.name,status:typeof e.status=="object"&&e.status?e.status.value:e.status,uHeight:e.u_height??e.units??42,inventoryId:e.id,inventoryType:"rack",facilityId:e.facility_id,serial:e.serial,assetTag:e.asset_tag,site:typeof e.site=="object"&&e.site?e.site.name:e.site,role:typeof e.role=="object"&&e.role?e.role.name:e.role,tenant:typeof e.tenant=="object"&&e.tenant?e.tenant.name:e.tenant}}),qn=e=>({id:`device-${e.id}`,type:"device",position:{x:0,y:0},parentId:e.rack?`rack-${typeof e.rack=="object"&&e.rack?e.rack.id:e.rack}`:void 0,extent:e.rack?"parent":void 0,data:{label:e.name,status:typeof e.status=="object"&&e.status?e.status.value:e.status,deviceType:e.device_type?.model??e.model,manufacturer:e.device_type?.manufacturer?.name??e.manufacturer,role:typeof e.device_role=="object"&&e.device_role?e.device_role.name:e.role,uHeight:e.device_type?.u_height??e.u_height??1,uPosition:e.position||1,view:e.face||"front",inventoryId:e.id,inventoryType:"device",primaryIp4:typeof e.primary_ip4=="object"&&e.primary_ip4?e.primary_ip4.address:e.primary_ip4,primaryIp6:typeof e.primary_ip6=="object"&&e.primary_ip6?e.primary_ip6.address:e.primary_ip6,site:typeof e.site=="object"&&e.site?e.site.name:e.site,rack:typeof e.rack=="object"&&e.rack?e.rack.name:e.rack}}),Jn=e=>{let o=s=>{if(!s)return;if(typeof s=="string")return s;let a=s.device;return typeof a=="object"&&a?a.id:a},t=o(e.termination_a),n=o(e.termination_b);return {id:`cable-${e.id}`,source:`device-${t}`,target:`device-${n}`,type:"fiber",data:{bandwidth:e.type?.label??e.bandwidth,length:e.length||0,color:e.color,inventoryId:e.id,inventoryType:"cable",status:typeof e.status=="object"&&e.status?e.status.value:e.status,terminationA:typeof e.termination_a=="object"&&e.termination_a?e.termination_a.name:e.termination_a,terminationB:typeof e.termination_b=="object"&&e.termination_b?e.termination_b.name:e.termination_b}}},Oa=e=>{let o=[],t=[];return e.racks.forEach(n=>o.push(Zn(n))),e.devices.forEach(n=>o.push(qn(n))),e.cables.forEach(n=>t.push(Jn(n))),{nodes:o,edges:t}},Ba=e=>{let o=e.filter(s=>s.type==="rack"),t=e.filter(s=>s.type==="device"),n=e.filter(s=>!["rack","device"].includes(s.type));return o.forEach((s,a)=>{s.position={x:a*300,y:100};}),t.forEach(s=>{if(s.parentId){let a=o.find(l=>l.id===s.parentId);if(a){let l=s.data.uPosition||1,i=s.data.uHeight||1;s.position={x:a.position.x+50,y:a.position.y+l*20-i*10};}}else s.position={x:Math.random()*400+100,y:Math.random()*200+50};}),n.forEach((s,a)=>{s.position={x:a*150+100,y:300};}),e};function Co(e){let{items:o,checkOutOfBounds:t,checkConflicts:n}=e,s=[],a=[];for(let l of o){let i=t(l);i&&!i.isValid&&i.error&&a.push(i.error);}for(let l=0;l<o.length;l++){let i=o[l];for(let d=l+1;d<o.length;d++){let u=o[d],h=n(i,u);h&&h.hasConflict&&h.conflict&&s.push(h.conflict);}}return {isValid:s.length===0&&a.length===0,conflicts:s,outOfBounds:a}}var St=class extends Error{constructor(t,n,s,a,l){super(`Device placement conflict: ${n} at U${s}-${s+a-1} in rack ${t}${l?` conflicts with ${l}`:""}`);this.rackId=t;this.deviceId=n;this.uPosition=s;this.uHeight=a;this.conflictWith=l;this.name="DevicePlacementError";}};function Er(e,o={}){return Co({items:e.devices,checkOutOfBounds:t=>t.unit+t.height-1>e.units?{isValid:false,error:{deviceId:t.id,uPosition:t.unit,uHeight:t.height,rackUHeight:e.units}}:null,checkConflicts:(t,n)=>{let s=t.unit,a=t.unit+t.height-1,l=n.unit,i=n.unit+n.height-1;return s<=i&&a>=l?{hasConflict:true,conflict:{deviceId:t.id,uPosition:t.unit,uHeight:t.height,conflictWith:n.id}}:null}})}function Qn(e,o,t={}){let{deviceTypeMapping:n={}}=t,s=n[e.type]||"device",a=bt(o,e.unit,e.height);return {id:e.id,type:s,position:a,parentId:o.id,extent:"parent",data:{label:e.name,status:"active",deviceType:e.type,uHeight:e.height,uPosition:e.unit,width:e.width||"full",role:e.role,ports:e.ports,rearPorts:e.rearPorts,connections:e.connections,frontImageUrl:e.frontImageUrl,rearImageUrl:e.rearImageUrl,frontImageAttribution:e.frontImageAttribution,rearImageAttribution:e.rearImageAttribution,imageFit:e.imageFit,imagePosition:e.imagePosition,imageRepeat:e.imageRepeat,stretchToFit:e.stretchToFit,rackWidthPx:o.data.rackWidthPx}}}function Ua(e){return {id:e.id,type:"rack",position:e.position,data:{label:e.name,status:"active",uHeight:e.units,uNumberingDirection:e.uNumberingDirection||"bottom-up",customHeaderText:e.customHeaderText,ports:[],rackWidthPx:e.rackWidthPx}}}function Va(e,o={}){let{conflictPolicy:t="strict",validatePlacements:n=true}=o,s=[],a=[];if(n)for(let l of e){let i=Er(l,o);if(!i.isValid&&t==="strict"){let d=[];throw i.conflicts.forEach(u=>{d.push(`Device ${u.deviceId} at U${u.uPosition}-${u.uPosition+u.uHeight-1} conflicts with ${u.conflictWith}`);}),i.outOfBounds.forEach(u=>{d.push(`Device ${u.deviceId} at U${u.uPosition}-${u.uPosition+u.uHeight-1} exceeds rack height (${u.rackUHeight}U)`);}),new St(l.id,i.conflicts[0]?.deviceId||i.outOfBounds[0]?.deviceId||"unknown",i.conflicts[0]?.uPosition||i.outOfBounds[0]?.uPosition||1,i.conflicts[0]?.uHeight||i.outOfBounds[0]?.uHeight||1)}}for(let l of e){let i=Ua(l);s.push(i);for(let d of l.devices)try{let u=Qn(d,i,o);a.push(u);}catch(u){if(t==="strict")throw u;if(t==="nearest"){let h=eo(i,{id:d.id,data:{label:d.name,uHeight:d.height}},a,d.unit);if(h!==d.unit){console.warn(`Device ${d.id} moved from U${d.unit} to U${h} due to conflict`);let g={...d,unit:h},c=Qn(g,i,o);a.push(c);}else throw new St(l.id,d.id,d.unit,d.height)}}}return s.push(...a),s}function ja(e){let o=[],t=e.filter(n=>n.type==="rack");for(let n of t){let a=e.filter(l=>l.type==="device"&&l.parentId===n.id).map(l=>({id:l.id,name:l.data.label,unit:l.data.uPosition||1,height:l.data.uHeight||1,type:l.data.deviceType||"server",width:l.data.width,ports:l.data.ports,connections:l.data.connections,frontImageUrl:l.data.frontImageUrl,rearImageUrl:l.data.rearImageUrl,frontImageAttribution:l.data.frontImageAttribution,rearImageAttribution:l.data.rearImageAttribution,imageFit:l.data.imageFit,imagePosition:l.data.imagePosition,imageRepeat:l.data.imageRepeat,stretchToFit:l.data.stretchToFit}));o.push({id:n.id,name:n.data.label,position:n.position,units:n.data.uHeight||42,uNumberingDirection:n.data.uNumberingDirection||"bottom-up",customHeaderText:n.data.customHeaderText,devices:a,rackWidthPx:n.data.rackWidthPx});}return o}function Ya(e,o,t,n){return e.map(s=>s.id!==o?s:{...s,devices:s.devices.map(a=>a.id!==t?a:{...a,unit:n})})}function Xa(e,o,t,n={}){let{conflictPolicy:s="strict"}=n;return e.map(a=>{if(a.id!==o)return a;if(s==="strict"&&!Er({...a,devices:[...a.devices,t]},n).isValid)throw new St(o,t.id,t.unit,t.height);return {...a,devices:[...a.devices,t]}})}function Ga(e,o,t){return e.map(n=>n.id!==o?n:{...n,devices:n.devices.filter(s=>s.id!==t)})}var Ht=class extends Error{constructor(t,n,s,a){super(`Splice placement conflict: ${n} at holder ${s} in tray ${t}${a?` conflicts with ${a}`:""}`);this.trayId=t;this.spliceId=n;this.holder=s;this.conflictWith=a;this.name="SplicePlacementError";}};function Rr(e,o={}){return Co({items:e.splices,checkOutOfBounds:t=>t.holder<1||t.holder>Ge?{isValid:false,error:{spliceId:t.id,holder:t.holder,max:Ge}}:null,checkConflicts:(t,n)=>t.holder===n.holder?{hasConflict:true,conflict:{spliceId:t.id,holder:t.holder,conflictWith:n.id}}:null})}function ei(e,o){let t=e.mode==="ribbon",n=At(o,e.holder,t);return {id:e.id,type:"splice",position:n,parentId:o.id,extent:"parent",data:{label:e.name,holderPosition:e.holder,lossDb:e.lossDb,mode:e.mode||"single",ribbonFiberIds:e.ribbonFiberIds}}}function Ka(e){return {id:e.id,type:"splice-tray",position:e.position,data:{label:e.name,status:"active"}}}function Za(e,o={}){let{conflictPolicy:t="strict",validatePlacements:n=true}=o,s=[],a=[];if(n)for(let l of e){let i=Rr(l,o);if(!i.isValid&&t==="strict"){let d=[];throw i.conflicts.forEach(u=>{d.push(`Splice ${u.spliceId} at holder ${u.holder} conflicts with ${u.conflictWith}`);}),i.outOfBounds.forEach(u=>{d.push(`Splice ${u.spliceId} at holder ${u.holder} is out of bounds (max: ${u.max})`);}),new Ht(l.id,i.conflicts[0]?.spliceId||i.outOfBounds[0]?.spliceId||"unknown",i.conflicts[0]?.holder||i.outOfBounds[0]?.holder||1)}}for(let l of e){let i=Ka(l);s.push(i);for(let d of l.splices)try{let u=d.holder;if(t==="nearest"){let c={id:d.id,type:"splice",position:{x:0,y:0},data:{label:d.name,holderPosition:d.holder}},f=[...s,...a];Mt(i,c,d.holder,f)||(u=zt(i,c,f,d.holder));}let h=u!==d.holder?{...d,holder:u}:d,g=ei(h,i);a.push(g);}catch(u){if(t==="strict")throw u;if(t==="nearest"){let h=[...s,...a],g=zt(i,{id:d.id,data:{label:d.name,holderPosition:d.holder}},h,d.holder);if(g!==d.holder){console.warn(`Splice ${d.id} moved from holder ${d.holder} to holder ${g} due to conflict`);let c={...d,holder:g},f=ei(c,i);a.push(f);}else throw new Ht(l.id,d.id,d.holder)}}}return s.push(...a),s}function qa(e){let o=[],t=e.filter(n=>n.type==="splice-tray");for(let n of t){let a=e.filter(l=>l.type==="splice"&&l.parentId===n.id).map(l=>({id:l.id,name:l.data.label,holder:l.data.holderPosition||1,lossDb:l.data.lossDb,mode:l.data.mode||"single",ribbonFiberIds:l.data.ribbonFiberIds}));o.push({id:n.id,name:n.data.label,position:n.position,splices:a});}return o}function Ja(e,o,t,n){return e.map(s=>s.id!==o?s:{...s,splices:s.splices.map(a=>a.id!==t?a:{...a,holder:n})})}function Qa(e,o,t,n={}){let{conflictPolicy:s="strict"}=n;return e.map(a=>{if(a.id!==o)return a;if(s==="strict"&&!Rr({...a,splices:[...a.splices,t]},n).isValid)throw new Ht(o,t.id,t.holder);return {...a,splices:[...a.splices,t]}})}function es(e,o,t){return e.map(n=>n.id!==o?n:{...n,splices:n.splices.filter(s=>s.id!==t)})}
|
|
2
|
-
export{
|
|
1
|
+
import lt,{useState,useMemo,useRef,useEffect,useSyncExternalStore,Component,useCallback}from'react';import {useReactFlow,Handle,Position,getBezierPath,BaseEdge,EdgeLabelRenderer,useUpdateNodeInternals,useEdges,addEdge,ReactFlowProvider,useNodesState,useEdgesState,applyNodeChanges,useOnSelectionChange,ReactFlow,Background,Controls,MiniMap,Panel,applyEdgeChanges,ConnectionMode,getSmoothStepPath,SmoothStepEdge}from'reactflow';import {toPng}from'html-to-image';import {jsx,jsxs,Fragment}from'react/jsx-runtime';var Me=20,et=60,xo=300,Zt=5;function Sn(e){return e==="system"?typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: light)").matches?"light":"dark":e}function En(e,t){let r=Sn(e)==="light"?"react-flow-light":"react-flow-dark";return t?`${r} ${t}`:r}function Rn(e){return Sn(e)==="light"?"#e5e5e5":"#2a2a2a"}function Tn(e,t){return {width:"100%",height:"100%",...t}}var ba=["device","server","switch","router"],ha=new Set(ba);function qt(e){return typeof e=="string"&&ha.has(e)}function We(e){return !!e&&qt(e.type)}var ma=()=>"bottom-up",ht=e=>e.data.uNumberingDirection||ma(),ko=(e,t,o)=>o==="bottom-up"?t-e+1:e,vo=(e,t,o)=>o==="bottom-up"?t-e+1:e;var Co=(e,t,o,r)=>{if(!e.parentId||e.parentId!==t.id)return o;let i=e.data.uHeight||1,a=t.data.uHeight||42,d=ht(t),s=60,l=o.y-s,p=Math.round(l/20)+1,m;d==="bottom-up"?m=ko(p,a,d)-i+1:m=ko(p,a,d);let f=a-i+1,c=Math.max(1,Math.min(f,m));if(d==="top-down"&&m<=1&&(c=1),!ur(t,e,c,r)){let x=Ho(t,e,r,c);x!==c&&(c=x);}let b;if(d==="bottom-up"){let x=c+i-1,k=vo(x,a,d);b=s+(k-1)*20-1;}else {let x=vo(c,a,d);b=s+(x-1)*20-1;}return {x:o.x,y:b,uPosition:c}},ur=(e,t,o,r)=>{let i=t.data.uHeight||1,a=e.data.uHeight||42;if(o<1||o+i-1>a)return false;let d=r.filter(s=>qt(s.type)&&s.parentId===e.id&&s.id!==t.id);for(let s of d){let l=s.data.uPosition||1,p=s.data.uHeight||1,m=o,f=o+i-1,c=l,b=l+p-1;if(m<=b&&f>=c)return false}return true},Ho=(e,t,o,r=1)=>{let i=t.data.uHeight||1,a=e.data.uHeight||42;for(let d=r;d<=a-i+1;d++)if(ur(e,t,d,o))return d;return 1},_t=(e,t,o=1)=>{let r=60,i=ht(e),a=e.data.uHeight||42,d=vo(t,a,i),s;if(i==="bottom-up"){let l=t+o-1,p=vo(l,a,i);s=r+(p-1)*20-1;}else s=r+(d-1)*20-1;return {x:0,y:s}},In=(e,t,o)=>{let r=e.data.uHeight||1,i=_t(t,o,r),a=Array.isArray(e.data.ports)?e.data.ports:void 0;return {...e,position:i,data:{...e.data,ports:a,uPosition:o}}},ya=(e,t)=>{let o=e.data.uPosition||1,r=e.data.uHeight||1,i=t.data.uHeight||42,a=Math.max(1,Math.min(i-r+1,o));return a!==o?In(e,t,a):e};function Ke(e){switch(e){case "active":return "#10b981";case "inactive":return "#ef4444";case "maintenance":return "#f59e0b";default:return "#6b7280"}}var pr=({data:e,selected:t,id:o,onViewChange:r,onRackFaceChange:i,isDragOver:a=false})=>{let{label:d,ports:s=0,status:l="active",uHeight:p=42,face:m="front",customHeaderText:f,rackWidthPx:c}=e,b=c||300,{getNodes:x,setNodes:k}=useReactFlow(),C=x(),[v,T]=useState(e.showUMarkers!==void 0?e.showUMarkers:true),E=()=>{let _=ht({data:e})==="bottom-up"?"top-down":"bottom-up";k(S=>S.map(D=>D.id===o?{...D,data:{...D.data,uNumberingDirection:_}}:D));},F=()=>{let w=m==="front"?"rear":"front";i?i(o,w):r?C.filter(S=>S.parentId===o).forEach(S=>{r(S.id,w);}):k(_=>_.map(S=>S.id===o?{...S,data:{...S.data,face:w}}:S.parentId===o?{...S,data:{...S.data,view:w}}:S));},y=()=>{let w=[],_=60,S=ht({data:e});for(let D=1;D<=p;D++){let A=_+(D-1)*20-4,U=ko(D,p,S);w.push(jsx("div",{style:{position:"absolute",left:"-35px",top:`${A}px`,background:"#374151",color:"#9ca3af",padding:"2px 4px",borderRadius:"2px",fontSize:"8px",fontWeight:"bold",width:"28px",textAlign:"center",border:"1px solid #4b5563",zIndex:10,height:`${20}px`,display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1},children:U},D));}return w};return jsxs("div",{className:`rack-node ${t?"selected":""} ${a?"drag-over":""}`,style:{background:"transparent",border:`2px solid ${Ke(l)}`,borderRadius:"8px",padding:0,width:`${b}px`,height:`${60+p*20}px`,color:"white",fontFamily:"monospace",fontSize:"12px",boxShadow:a?"0 0 20px #3b82f6, 0 0 40px #3b82f6, 0 0 60px #3b82f6":t?"0 0 0 2px #3b82f6":"0 2px 4px rgba(0,0,0,0.1)",position:"relative",display:"flex",flexDirection:"column",transition:"box-shadow 0.2s ease-in-out"},children:[jsxs("div",{style:{textAlign:"center",marginBottom:0,zIndex:2,background:"#1f2937",padding:"8px",position:"relative",height:`${60}px`,display:"flex",flexDirection:"column",justifyContent:"center"},children:[jsx("div",{style:{fontWeight:"bold",marginBottom:"4px"},children:d}),jsxs("div",{style:{fontSize:"10px",color:"#9ca3af"},children:[f?jsx("span",{style:{color:"#fbbf24",fontWeight:"bold"},children:f}):jsxs("span",{children:[typeof s=="number"?s:0," ports"]})," \u2022 ",p,"U \u2022 ",m]}),jsxs("div",{style:{display:"flex",gap:"4px",position:"absolute",top:"4px",right:"4px"},children:[jsx("button",{onPointerDown:w=>{w.stopPropagation();},onMouseDown:w=>{w.stopPropagation();},onClick:w=>{w.stopPropagation(),w.preventDefault(),T(!v);},style:{background:v?"#10b981":"#374151",color:v?"#ffffff":"#9ca3af",border:"1px solid #4b5563",borderRadius:"2px",padding:"2px 6px",fontSize:"8px",cursor:"pointer",fontFamily:"monospace"},title:`${v?"Hide":"Show"} U markers`,children:"U"}),jsx("button",{onPointerDown:w=>{w.stopPropagation();},onMouseDown:w=>{w.stopPropagation();},onClick:w=>{w.stopPropagation(),w.preventDefault(),E();},style:{background:"#374151",color:"#9ca3af",border:"1px solid #4b5563",borderRadius:"2px",padding:"2px 6px",fontSize:"8px",cursor:"pointer",fontFamily:"monospace"},title:`Switch U numbering to ${ht({data:e})==="bottom-up"?"top-down":"bottom-up"}`,children:ht({data:e})==="bottom-up"?"\u2191\u2193":"\u2193\u2191"}),jsx("button",{onPointerDown:w=>{w.stopPropagation();},onMouseDown:w=>{w.stopPropagation();},onClick:w=>{w.stopPropagation(),w.preventDefault(),F();},style:{background:"#374151",color:"#9ca3af",border:"1px solid #4b5563",borderRadius:"2px",padding:"2px 6px",fontSize:"8px",cursor:"pointer",fontFamily:"monospace"},title:`Switch to ${m==="front"?"rear":"front"} view`,children:m==="front"?"\u21C4 Rear":"\u21C4 Front"})]})]}),jsx("div",{style:{flex:1,background:"transparent",position:"relative",minHeight:`${p*20}px`,overflow:"hidden"}}),v&&jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none"},children:y()})]})};var gr=({data:e,selected:t})=>{let{label:o,status:r="active"}=e;return jsxs("div",{className:`fiber-node ${t?"selected":""}`,style:{background:"#1f2937",border:`2px solid ${Ke(r)}`,borderRadius:"50%",width:"60px",height:"60px",display:"flex",alignItems:"center",justifyContent:"center",color:"white",fontFamily:"monospace",fontSize:"10px",fontWeight:"bold",boxShadow:t?"0 0 0 2px #3b82f6":"0 2px 4px rgba(0,0,0,0.1)",position:"relative"},children:[jsx(Handle,{type:"target",position:Position.Top}),jsx(Handle,{type:"source",position:Position.Bottom}),jsx(Handle,{type:"target",position:Position.Left}),jsx(Handle,{type:"source",position:Position.Right}),jsx("div",{style:{textAlign:"center"},children:jsx("div",{style:{fontSize:"8px",lineHeight:"1.2"},children:o})}),jsx("div",{style:{position:"absolute",bottom:"4px",left:"50%",transform:"translateX(-50%)",width:"8px",height:"8px",background:Ke(r),borderRadius:"50%"}})]})};var Dn=["#1f77b4","#ff7f0e","#2ca02c","#8c564b","#708090","#ffffff","#d62728","#000000","#ffdf00","#8a2be2","#ff69b4","#00ffff"];function De(e){let t=(e-1)%12;return Dn[t]}function yt(e){return e>12}function tt(e,t){let o=t?.base??De(e),r=t?.striped??yt(e),i=r?`repeating-linear-gradient(45deg, ${o} 0 6px, #000 6px 9px)`:void 0;return {base:o,striped:r,backgroundImage:i}}function fr(e){let t=tt(e);return t.backgroundImage?{background:t.base,backgroundImage:t.backgroundImage}:{background:t.base}}function wt(e){return De(e)}function ot(e){return e.map(t=>({base:De(t),striped:yt(t)}))}function va(e,t,o,r,i,a,d,s){let l=ot(o),p=l.length,m=r?1.2:1,f=!!s?.highlight,c=r?2:1.5,b=s?.highlightWidth??c*3,x=s?.highlightColor??l[0]?.base??"#22d3ee";return jsxs(Fragment,{children:[f&&jsx(BaseEdge,{id:`${e}-highlight`,path:t,style:{...i,stroke:x,strokeWidth:b,opacity:.7,strokeDasharray:"14 10","--rn-edge-highlight-from":`${c}px`,"--rn-edge-highlight-to":`${b}px`}}),l.map((k,C)=>{let T=(p-C)*m;return jsx("path",{d:t,stroke:k.base,strokeWidth:T,fill:"none",strokeLinecap:"butt",opacity:k.striped?.9:1,style:i},`${e}-ribbon-${C}`)}),l.some(k=>k.striped)&&jsx(BaseEdge,{id:`${e}-ribbon-stripe`,path:t,style:{...i,stroke:"#000",strokeWidth:1,strokeDasharray:"3 3",opacity:.4}}),jsx(EdgeLabelRenderer,{children:r&&s&&(s.bandwidth||s.length)&&jsxs("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${a}px,${d}px)`,background:"#1f2937",padding:"4px 8px",borderRadius:"4px",fontSize:"10px",color:"white",fontFamily:"monospace",border:`1px solid ${l[0]?.base||"#00FFFF"}`,pointerEvents:"none",zIndex:9999},children:[s.bandwidth&&jsx("div",{children:s.bandwidth}),s.length&&jsxs("div",{children:[s.length,"m"]}),jsxs("div",{style:{fontSize:"8px",opacity:.8},children:[o.length,"F"]})]})})]})}var Eo=({id:e,sourceX:t,sourceY:o,targetX:r,targetY:i,sourcePosition:a,targetPosition:d,data:s,selected:l,style:p={},className:m})=>{let[f,c,b]=getBezierPath({sourceX:t,sourceY:o,sourcePosition:a,targetX:r,targetY:i,targetPosition:d}),{bandwidth:x,length:k,color:C="#00FFFF",striped:v=false,ribbonFiberIds:T,isRibbon:E,highlight:F,highlightColor:y,highlightWidth:w}=s||{},_=!!F;if((E||T&&T.length>=6&&T.length<=12)&&T)return va(e,f,T,l??false,p??{},c,b,s);let D=l?3:2,A=w??D*3,U={...p,stroke:C,strokeWidth:D,strokeDasharray:"none"};return jsxs(Fragment,{children:[_&&jsx(BaseEdge,{id:`${e}-highlight`,path:f,style:{...p,stroke:y??C,strokeWidth:A,opacity:.7,strokeDasharray:"14 10","--rn-edge-highlight-from":`${D}px`,"--rn-edge-highlight-to":`${A}px`}}),jsx(BaseEdge,{id:e,path:f,style:U}),v&&jsx(BaseEdge,{id:`${e}-stripe`,path:f,style:{...p,stroke:"#000",strokeWidth:1.5,strokeDasharray:"6 6",opacity:.9}}),jsx(EdgeLabelRenderer,{children:l&&s&&(x||k)&&jsxs("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${c}px,${b}px)`,background:"#1f2937",padding:"4px 8px",borderRadius:"4px",fontSize:"10px",color:"white",fontFamily:"monospace",border:`1px solid ${C}`,pointerEvents:"none",zIndex:9999},children:[x&&jsx("div",{children:x}),k&&jsxs("div",{children:[k,"m"]})]})})]})};var br=({id:e,sourceX:t,sourceY:o,targetX:r,targetY:i,sourcePosition:a,targetPosition:d,style:s={},data:l,markerEnd:p})=>{let[m]=getBezierPath({sourceX:t,sourceY:o,sourcePosition:a,targetX:r,targetY:i,targetPosition:d}),f=l?.connectorType||"C13";return jsx(BaseEdge,{id:e,path:m,markerEnd:p,style:(()=>{let b={stroke:l?.color||"#f59e0b",strokeWidth:f==="C19"?5:3,strokeLinecap:"round",strokeLinejoin:"round",...s};return f==="C19"?{...b,strokeDasharray:"none"}:{...b,strokeDasharray:"6,3"}})()})};function Ra(e,t,o,r,i,a,d,s,l,p,m){let f=ot(s),c=f.length,b=l?1.8:1.5,x=!!m?.highlight,k=l?3:2.5,C=m?.highlightWidth??k*3,v=m?.highlightColor??f[0]?.base??"#22d3ee",[T,E,F]=getSmoothStepPath({sourceX:t,sourceY:o,targetX:r,targetY:i,sourcePosition:a,targetPosition:d});return jsxs(Fragment,{children:[x&&jsx(BaseEdge,{id:`${e}-highlight`,path:T,style:{...p,stroke:v,strokeWidth:C,opacity:.7,strokeDasharray:"14 10","--rn-edge-highlight-from":`${k}px`,"--rn-edge-highlight-to":`${C}px`}}),f.map((y,w)=>{let S=(c-w)*b;return jsx("path",{d:T,stroke:y.base,strokeWidth:S,fill:"none",strokeLinecap:"butt",opacity:y.striped?.9:1,style:p},`${e}-ribbon-${w}`)}),f.some(y=>y.striped)&&jsx(BaseEdge,{id:`${e}-ribbon-stripe`,path:T,style:{...p,stroke:"#000",strokeWidth:1,strokeDasharray:"3 3",opacity:.4}}),jsx(EdgeLabelRenderer,{children:l&&m&&(m.bandwidth||m.length)&&jsxs("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${E}px,${F}px)`,background:"#1f2937",padding:"4px 8px",borderRadius:"4px",fontSize:"10px",color:"white",fontFamily:"monospace",border:`1px solid ${f[0]?.base||"#00FFFF"}`,pointerEvents:"none",zIndex:9999},children:[m.bandwidth&&jsx("div",{children:m.bandwidth}),m.length&&jsxs("div",{children:[m.length,"m"]}),jsxs("div",{style:{fontSize:"8px",opacity:.8},children:[s.length,"F"]})]})})]})}var Mn=({id:e,sourceX:t,sourceY:o,targetX:r,targetY:i,sourcePosition:a,targetPosition:d,data:s,selected:l,style:p={},...m})=>{let{color:f="#00FFFF",ribbonFiberIds:c,isRibbon:b,highlight:x,highlightColor:k,highlightWidth:C}=s||{},v=!!x;if((b||c&&c.length>=6&&c.length<=12)&&c)return Ra(e,t,o,r,i,a,d,c,l??false,p??{},s);let E=l?4:3,F=C??E*3,y={...p,stroke:f,strokeWidth:E};return jsxs(Fragment,{children:[v&&jsx(BaseEdge,{id:`${e}-highlight`,path:getSmoothStepPath({sourceX:t,sourceY:o,targetX:r,targetY:i,sourcePosition:a,targetPosition:d})[0],style:{...p,stroke:k??f,strokeWidth:F,opacity:.7,strokeDasharray:"14 10","--rn-edge-highlight-from":`${E}px`,"--rn-edge-highlight-to":`${F}px`}}),jsx(SmoothStepEdge,{...m,id:e,sourceX:t,sourceY:o,targetX:r,targetY:i,sourcePosition:a,targetPosition:d,data:s,selected:l,style:y})]})};function Ia({sourceX:e,sourceY:t,targetX:o,targetY:r,sourcePosition:i,targetPosition:a}){let d=i===Position.Left||i===Position.Right,s;if(d){let l=(e+o)/2;s=`M ${e},${t} L ${l},${t} L ${l},${r} L ${o},${r}`;}else {let l=(t+r)/2;s=`M ${e},${t} L ${e},${l} L ${o},${l} L ${o},${r}`;}return s}function Da(e,t,o,r,i,a){let d=ot(o),s=d.length,l=r?1.2:1,p=!!a?.highlight,m=r?2:1.5,f=a?.highlightWidth??m*3,c=a?.highlightColor??d[0]?.base??"#22d3ee",b=t.match(/M\s+([\d.]+),([\d.]+).*L\s+([\d.]+),([\d.]+)/),x=b?(parseFloat(b[1])+parseFloat(b[3]))/2:0,k=b?(parseFloat(b[2])+parseFloat(b[4]))/2:0;return jsxs(Fragment,{children:[p&&jsx(BaseEdge,{id:`${e}-highlight`,path:t,style:{...i,stroke:c,strokeWidth:f,opacity:.7,strokeDasharray:"14 10","--rn-edge-highlight-from":`${m}px`,"--rn-edge-highlight-to":`${f}px`}}),d.map((C,v)=>{let E=(s-v)*l;return jsx("path",{d:t,stroke:C.base,strokeWidth:E,fill:"none",strokeLinecap:"butt",opacity:C.striped?.9:1,style:i},`${e}-ribbon-${v}`)}),d.some(C=>C.striped)&&jsx(BaseEdge,{id:`${e}-ribbon-stripe`,path:t,style:{...i,stroke:"#000",strokeWidth:1,strokeDasharray:"3 3",opacity:.4}}),jsx(EdgeLabelRenderer,{children:r&&a&&(a.bandwidth||a.length)&&jsxs("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${x}px,${k}px)`,background:"#1f2937",padding:"4px 8px",borderRadius:"4px",fontSize:"10px",color:"white",fontFamily:"monospace",border:`1px solid ${d[0]?.base||"#00FFFF"}`,pointerEvents:"none",zIndex:9999},children:[a.bandwidth&&jsx("div",{children:a.bandwidth}),a.length&&jsxs("div",{children:[a.length,"m"]}),jsxs("div",{style:{fontSize:"8px",opacity:.8},children:[o.length,"F"]})]})})]})}var On=({id:e,sourceX:t,sourceY:o,targetX:r,targetY:i,sourcePosition:a,targetPosition:d,data:s,selected:l,style:p={},...m})=>{let{color:f="#00FFFF",striped:c=false,ribbonFiberIds:b,isRibbon:x,highlight:k,highlightColor:C,highlightWidth:v}=s||{},T=!!k,E=Ia({sourceX:t,sourceY:o,sourcePosition:a,targetX:r,targetY:i,targetPosition:d});if((x||b&&b.length>=6&&b.length<=12)&&b)return Da(e,E,b,l??false,p??{},s);let y=l?3:2,w=v??y*3,_={...p,stroke:f,strokeWidth:y,strokeDasharray:"none"};return jsxs(Fragment,{children:[T&&jsx(BaseEdge,{id:`${e}-highlight`,path:E,style:{...p,stroke:C??f,strokeWidth:w,opacity:.7,strokeDasharray:"14 10","--rn-edge-highlight-from":`${y}px`,"--rn-edge-highlight-to":`${w}px`}}),jsx(BaseEdge,{id:e,path:E,style:_}),c&&jsx(BaseEdge,{id:`${e}-stripe`,path:E,style:{...p,stroke:"#000",strokeWidth:1.5,strokeDasharray:"6 6",opacity:.9}})]})};var Bn=({id:e,sourceX:t,sourceY:o,targetX:r,targetY:i,sourcePosition:a,targetPosition:d,style:s={},data:l,markerEnd:p,selected:m})=>{let{color:f="#6366f1",label:c,highlight:b,highlightColor:x,highlightWidth:k}=l||{},C=!!b,v=8,T=k??v*1.8,[E,F,y]=getBezierPath({sourceX:t,sourceY:o,sourcePosition:a,targetX:r,targetY:i,targetPosition:d}),w={...s,stroke:f,strokeWidth:v,strokeLinecap:"round",strokeLinejoin:"round",strokeDasharray:"none"};return jsxs(Fragment,{children:[C&&jsx(BaseEdge,{id:`${e}-highlight`,path:E,style:{...s,stroke:x??f,strokeWidth:T,opacity:.85,strokeDasharray:"18 12",filter:`drop-shadow(0 0 8px ${x??f}) drop-shadow(0 0 16px ${x??f})`,"--rn-edge-highlight-from":`${v}px`,"--rn-edge-highlight-to":`${T}px`}}),jsx(BaseEdge,{id:e,path:E,markerEnd:p,style:w}),c&&jsx(EdgeLabelRenderer,{children:jsx("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${F}px,${y}px)`,background:"#1f2937",padding:"4px 8px",borderRadius:"4px",fontSize:"10px",color:"white",fontFamily:"monospace",border:`1px solid ${f}`,pointerEvents:"none",zIndex:9999},children:c})})]})};var Un=(o=>(o.FULL="full",o.HALF="half",o))(Un||{});var mr={C13:{type:"C13",color:"#f59e0b",borderColor:"#d97706",amperage:10,voltage:230,phases:1},C14:{type:"C14",color:"#f59e0b",borderColor:"#d97706",amperage:10,voltage:230,phases:1},C19:{type:"C19",color:"#fbbf24",borderColor:"#d97706",amperage:16,voltage:230,phases:1},C20:{type:"C20",color:"#fbbf24",borderColor:"#d97706",amperage:16,voltage:230,phases:1}};function ro(e){let t=mr[e];if(!t)throw new Error(`Unknown connector type: ${e}`);let o=t.amperage===16,r=o?12:8*1.3,i=o?10:5*1.3,a=o?{borderRadius:"3px"}:{clipPath:"polygon(2px 0, calc(100% - 2px) 0, 100% 2px, 100% 100%, 0 100%, 0 2px)",borderRadius:"0px"};return {width:r,height:i,color:t.color,borderColor:t.borderColor,fontSize:o?"3px":"4px",...a}}function Vn(e){let t=mr[e];if(!t)throw new Error(`Unknown connector type: ${e}`);return t}function Wa(e){return Vn(e).amperage===16}function yr(e){return e%10<8?"C13":"C19"}function wr(e){let t=e.toLowerCase();return t.includes("mx304")||t.includes("mx480")||t.includes("mx960")?"C20":"C14"}var Aa=/-(source|target)$/i;function Te(e){return e?e.replace(Aa,""):""}function rt(e){return typeof e=="string"&&e.includes("power")}function kt(e,t){return rt(t.type)?t.label:`${e}-${t.label}`}function To(e){let t=Te(e).toLowerCase();return t.startsWith("pwr")||t.includes("power")}var La="#6b7280",za="#374151",Nr="#10b981",Ba="100% 100%",Ua={smf:"#fbbf24",cat6:"#8b5cf6",om3:"#06b6d4",om4:"#8b5cf6",om5:"#84cc16",cat5e:"#3b82f6",cat6a:"#ef4444",cat7:"#f97316",fiber:"#3b82f6",ethernet:"#10b981"},Va=/^[a-zA-Z][a-zA-Z\d+\-.]*:/,ja=/^data:image\//i,Ga=typeof window<"u"?lt.useLayoutEffect:lt.useEffect;function Xa(e){return (e??"").toLowerCase().replace(/_/g,"-")}function Ya(e){return !Va.test(e)&&!e.startsWith("//")}function Ka(e){if(!e)return;let t=e.trim();if(t){if(Ya(t))return t;try{let o=new URL(t),r=o.protocol.toLowerCase();return r==="https:"||r==="blob:"?o.href:r==="data:"&&ja.test(t)?t:void 0}catch{return}}}function Za(e){return `url(${JSON.stringify(e)})`}function kr(e){return rt(e.type)}function qa(e,t){return kt(e,t)}function Ja(e,t,o,r,i){let a=t.length>0||!!r,d=o.length>0||!!i;return e||(a?"front":d?"rear":"front")}function Qa(e,t){return t===true||e==="fill"?Ba:e==="none"?"auto":e==="scale-down"?"contain":e??"cover"}function es(e){return kr(e)?e.type==="power_c19"?"#fbbf24":"#f59e0b":e.type==="console"||e.type==="mgmt"?"#8b5cf6":e.type==="usb"?Nr:e.cableType?Ua[e.cableType]??Nr:Nr}function ts(e){return e.connected?es(e):La}function Gn(e){return e.map(t=>{let o=t.ports.map(r=>`${r.label}:${r.type??""}:${r.connected?"1":"0"}:${r.cableType??""}`).join(",");return `${t.name}[${o}]`}).join("|")}function os(e,t,o,r){return {width:`${e}px`,height:`${t}px`,background:o,border:`0.5px solid ${r}`,borderRadius:"1px",cursor:"pointer"}}function Xn(e,t){return e%2===0?{position:Position.Top,style:{transform:"translateY(50%)",left:`${e/2*(t+2)}px`}}:{position:Position.Bottom,style:{transform:"translateY(-50%)",left:`${(e-1)/2*(t+2)}px`}}}function rs(e,t,o){return t===1?{position:Position.Top,style:{transform:"translateY(50%)",right:"4%",left:void 0}}:Xn(e,o)}function ns(e,t,o,r,i,a,d){if(a==="patch-panel"||a==="switch")return Xn(t,r);if(kr(e)){let p=wr(d),m=ro(p),f;if(i<=20){let x=Math.max(2,i-m.height-2);f=`${o<=1?(2+x)/2:2+t*(x-2)/(o-1)}px`;}else f=`${25+t*50}%`;return {position:Position.Left,style:{transform:"translateX(50%)",top:f,width:`${m.width}px`,height:`${m.height}px`,background:m.color,border:`1px solid ${m.borderColor}`,zIndex:10,display:"flex",alignItems:"center",justifyContent:"center",fontSize:m.fontSize,color:"#1a1a1a",fontFamily:"monospace",fontWeight:"bold",borderRadius:m.borderRadius,clipPath:m.clipPath}}}return {position:Position.Right,style:{transform:"translateX(-50%)",top:`${25+t*50}%`}}}function is(e,t,o,r){if(e)return {primary:"target"};let i=t==="patch-panel";return t==="switch"||t==="router"?{primary:"source",secondary:"target"}:i?o==="rear"?{primary:"source",secondary:"target"}:{primary:"target",secondary:"source"}:{primary:r?"source":"target"}}var $t=({id:e,data:t,selected:o})=>{let r=useUpdateNodeInternals(),{label:i,status:a="active",deviceType:d="server",manufacturer:s,uHeight:l=1,width:p="full",ports:m,rearPorts:f,view:c,rackWidthPx:b,frontImageUrl:x,rearImageUrl:k,imageFit:C,imagePosition:v,imageRepeat:T,stretchToFit:E}=t,F=lt.useMemo(()=>Array.isArray(m)?m:[],[m]),y=lt.useMemo(()=>Array.isArray(f)?f:[],[f]),w=Xa(d),_=b??300,S=Ja(c,F,y,x,k),D=l*20,A=lt.useMemo(()=>[S,w,i,D.toString(),Gn(F),Gn(y)].join("|"),[S,w,i,D,F,y]);Ga(()=>{r(e);},[A,e,r]);let U=lt.useMemo(()=>{let $=Ka(S==="rear"?k:x);return $?{backgroundImage:Za($),backgroundSize:Qa(C,E),backgroundPosition:v??"center",backgroundRepeat:T??"no-repeat"}:{}},[S,k,x,C,E,v,T]),le=_+4,ee=Math.floor(_/2),re=p==="half"?`${ee}px`:`${le}px`,ne=p==="half"?`${ee}px`:void 0,z=w==="server"&&l===1,B=Ke(a),O={"--rn-device-bg-image":String(U.backgroundImage??"none"),"--rn-device-bg-position":String(U.backgroundPosition??"center"),"--rn-device-bg-repeat":String(U.backgroundRepeat??"no-repeat"),"--rn-device-bg-size":String(U.backgroundSize??"cover"),"--rn-device-border-color":B,"--rn-device-box-shadow":o?"0 0 0 1px #3b82f6":"0 1px 2px rgba(0,0,0,0.1)","--rn-device-height":`${D}px`,"--rn-device-left":ne??"auto","--rn-device-status-color":B,"--rn-device-translate-y":z?"-1px":"0px","--rn-device-width":re},L=lt.useCallback((J,$)=>{let M=[];if(J.length===0)return M;let oe=Math.max(4,Math.floor(D*.4)),ie=Math.max(2,Math.floor(D*.2));for(let Q of J)for(let j=0;j<Q.ports.length;j+=1){let ae=Q.ports[j],Ne=kr(ae);if($==="front"&&Ne)continue;let ye=qa(Q.name,ae),ce=ts(ae),qe=ae.connected?ce:za,Ge=os(oe,ie,ce,qe),jt=$==="front"?rs(j,Q.ports.length,oe):ns(ae,j,Q.ports.length,oe,D,w,i),ue={...Ge,...jt.style},$e=is(Ne,w,$,ae.connected);if($e.secondary){let Ae=w==="switch"||w==="router"?`${Q.name} - ${ae.label} (input) ${ae.connected?"(connected)":"(disconnected)"}`:`${Q.name} - ${ae.label} (${$e.secondary}) ${ae.connected?"(connected)":"(disconnected)"}`;M.push(jsx(Handle,{id:`${ye}-${$e.secondary}`,type:$e.secondary,position:jt.position,style:ue,title:Ae},`${ye}-${$e.secondary}`));}M.push(jsx(Handle,{id:ye,type:$e.primary,position:jt.position,style:ue,title:`${Q.name} - ${ae.label} ${ae.connected?"(connected)":"(disconnected)"}`,children:Ne?j+1:void 0},ye));}return M},[D,i,w]),X=lt.useMemo(()=>S==="front"?F.length>0?L(F,"front"):[]:S==="rear"?y.length>0?L(y,"rear"):[]:[],[S,F,y,L]);return jsxs("div",{className:`device-node ${o?"selected":""}`,style:O,children:[jsxs("div",{className:"device-node__content",children:[jsx("div",{className:"device-node__label",children:i}),l>1&&jsx("div",{className:"device-node__manufacturer",children:s})]}),l>1&&jsxs("div",{className:"device-node__u-indicator",children:[l,"U"]}),jsx("div",{className:"device-node__status-indicator"}),X]})};var vr=({data:e,selected:t})=>{let{label:o,status:r="active",heightCm:i=100,powerPorts:a=36,widthPx:d=15,mgmt_unit:s}=e,l=i*4.2,p=()=>{let c=Math.ceil(a/10),b=Array(10).fill(0).map((w,_)=>_<8?"10A":"16A");for(let w=0,_=0;w<c;++w)for(let S=0;S<10&&_<a;++S,++_){b[S];}let v=[],T=15,y=(l-T-3)/(a-9)*.5;for(let w=0;w<a;w++){let _=T-2+y*w,S=`${w+1}`;if(s&&(s==="top"&&w===0||s==="middle"&&w===Math.floor(a/2)||s==="bottom"&&w===a-1)){v.push(m(_));continue}let A=yr(w),U=ro(A),le=Math.round((d-U.width)/2-1);v.push(jsx(Handle,{type:"source",position:Position.Right,id:S,style:{position:"absolute",left:`${le}px`,top:`${_-U.height/2}px`,width:`${U.width}px`,height:`${U.height}px`,background:U.color,border:`1px solid ${U.borderColor}`,cursor:"pointer",zIndex:10,display:"flex",alignItems:"center",justifyContent:"center",fontSize:U.fontSize,color:"#1a1a1a",fontFamily:"monospace",fontWeight:"bold",borderRadius:U.borderRadius,clipPath:U.clipPath},title:`Power Port ${w+1} (${A})`,children:w+1},`handle-${S}`));}return v},m=f=>jsxs("div",{style:{position:"absolute",left:`${(d-16)/2}px`,top:`${f-12/2}px`,width:"16px",height:"12px",background:"#1a1a1a",border:"1px solid #374151",borderRadius:"1px",display:"flex",flexDirection:"column",padding:"1px",zIndex:10},children:[jsx("div",{style:{position:"absolute",left:"-10px",top:"1px",background:"#ffffff",border:"0.5px solid #6b7280",borderRadius:"0.5px",width:"8px",height:"10px",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"3px",color:"#10b981",fontFamily:"monospace",fontWeight:"bold",transform:"rotate(90deg)",transformOrigin:"center"},children:"APC"}),jsx(Handle,{type:"source",position:Position.Right,id:"mgmt-net-1",style:{width:"70%",height:"6px",background:"#10b981",border:"1px solid #059669",borderRadius:"1px",cursor:"pointer",zIndex:11,margin:"0 auto"},title:"Management Network Port"},"mgmt-net-1")]},"mgmt-unit");return jsxs("div",{className:`vertical-pdu-node ${t?"selected":""}`,style:{background:"linear-gradient(90deg, #2d3748 0%, #1a202c 50%, #2d3748 100%)",border:`1px solid ${Ke(r)}`,borderRadius:"2px",padding:0,width:`${d}px`,height:`${l}px`,color:"white",fontFamily:"monospace",fontSize:"12px",boxShadow:t?"0 0 0 2px #3b82f6":"0 1px 3px rgba(0,0,0,0.3)",position:"relative",display:"flex",flexDirection:"column"},children:[jsx("div",{style:{textAlign:"center",marginBottom:0,zIndex:2,background:"linear-gradient(90deg, #4a5568 0%, #2d3748 50%, #4a5568 100%)",padding:"2px",position:"relative",height:"20px",display:"flex",flexDirection:"column",justifyContent:"center",borderBottom:"1px solid #4a5568"},children:jsx("div",{style:{fontWeight:"bold",fontSize:"6px",color:"#e2e8f0"},children:o})}),jsx("div",{style:{flex:1,background:"linear-gradient(180deg, #2d3748 0%, #1a202c 50%, #2d3748 100%)",position:"relative",minHeight:`${l-20}px`,overflow:"hidden"},children:p()})]})};var Pr=({data:e,selected:t,id:o})=>{let{lossDb:r,mode:i="single",ribbonFiberIds:a}=e||{},d=useEdges(),s=d.find(y=>y.target===o&&y.targetHandle==="left"),l=d.find(y=>y.source===o&&y.sourceHandle==="right"),p=d.find(y=>y.target===o&&y.targetHandle==="right"),m=l||p,f=s?.data?.color||"#555",c=m?.data?.color||"#555",b=i==="ribbon",x=s?.data?.ribbonFiberIds||a,k=m?.data?.ribbonFiberIds||a,C=b&&x?ot(x):null,v=b&&k?ot(k):null,T=!!s&&!!m;return jsxs("div",{className:`splice-node ${t?"selected":""}`,style:{width:b?85:69,height:b?20:16,borderRadius:8,border:"none",outline:"none",position:"relative",background:"transparent",boxShadow:t?"0 0 0 2px #3b82f6":"none"},children:[b&&C&&v?jsxs("div",{style:{position:"absolute",inset:0,borderRadius:8,overflow:"hidden",opacity:.75,pointerEvents:"none",display:"grid",gridTemplateColumns:"1fr 1fr"},children:[jsx("div",{style:{display:"flex",flexDirection:"column",width:"100%",height:"100%"},children:C.map((y,w)=>jsx("div",{style:{flex:1,background:y.base,opacity:y.striped?.9:1}},`left-${w}`))}),jsx("div",{style:{display:"flex",flexDirection:"column",width:"100%",height:"100%"},children:v.map((y,w)=>jsx("div",{style:{flex:1,background:y.base,opacity:y.striped?.9:1}},`right-${w}`))})]}):jsxs("div",{style:{position:"absolute",inset:0,display:"grid",gridTemplateColumns:"1fr 1fr",borderRadius:8,overflow:"hidden",opacity:.75,pointerEvents:"none"},children:[jsx("div",{style:{background:f}}),jsx("div",{style:{background:c}})]}),jsx("div",{className:"splice-text-overlay",style:{position:"absolute",inset:0,borderRadius:8,pointerEvents:"none",zIndex:1,background:"transparent"}}),T&&jsx("div",{className:"splice-glow",style:{position:"absolute",left:"50%",top:0,bottom:0,width:"1px",background:"rgba(255, 255, 255, 0.6)",boxShadow:"0 0 2px rgba(255, 255, 255, 0.8), 0 0 4px rgba(255, 255, 255, 0.4)",pointerEvents:"none",zIndex:2}}),T&&typeof r=="number"&&jsxs("div",{className:"splice-text-label animate-in",style:{position:"absolute",inset:0,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",fontSize:b?8:9,fontFamily:"monospace",pointerEvents:"none",zIndex:3,fontWeight:"bold",gap:"2px"},children:[jsx("div",{children:`${r.toFixed(2)} dB`}),b&&a&&jsxs("div",{style:{fontSize:"7px",opacity:.8},children:[a.length,"F"]})]}),jsx(Handle,{type:"target",position:Position.Left,id:"left",isConnectable:true,style:{width:12,height:b&&C?20:12,borderRadius:b&&C?"6px":"50%",border:"none",background:b&&C?`linear-gradient(to bottom, ${C.map(y=>y.base).join(", ")})`:f,zIndex:100,cursor:"crosshair",left:-6,top:"50%",transform:"translateY(-50%)"}}),jsx(Handle,{type:"source",position:Position.Right,id:"right",isConnectable:true,style:{width:12,height:b&&v?20:12,borderRadius:b&&v?"6px":"50%",border:"none",background:b&&v?`linear-gradient(to bottom, ${v.map(y=>y.base).join(", ")})`:c,zIndex:100,cursor:"crosshair",right:-6,top:"50%",transform:"translateY(-50%)"}}),jsx(Handle,{type:"target",position:Position.Right,id:"right",isConnectable:true,style:{width:12,height:b&&v?20:12,borderRadius:b&&v?"6px":"50%",border:"none",background:b&&v?`linear-gradient(to bottom, ${v.map(y=>y.base).join(", ")})`:c,zIndex:100,cursor:"crosshair",right:-6,top:"50%",transform:"translateY(-50%)"}})]})};var lo=20,Io=36;var vt=32,qn=4,ct=12,ss=69,Ct=80,Sr=(Ct-ss)/2;var Er=(e,t,o,r)=>{if(!e.parentId||e.parentId!==t.id)return o;let i=e.data?.mode==="ribbon",a=i?Io:lo,d=i?32:16,s=vt,l=o.y-s,p=Math.round(l/a)+1,f=Math.max(1,Math.min(ct,p));if(!so(t,e,f,r)){let x=co(t,e,r,f);if(x!==f){let k=(a-d)/2;return {x:Sr,y:s+(x-1)*a+k,holderPosition:x}}}let c=(a-d)/2,b=s+(f-1)*a+c;return {x:Sr,y:b,holderPosition:f}},so=(e,t,o,r)=>!r.filter(a=>a.parentId===e.id&&a.type==="splice"&&a.id!==t.id).some(a=>a.data.holderPosition===o),co=(e,t,o,r=1)=>{for(let i=r;i<=ct;i++)if(so(e,t,i,o))return i;for(let i=r-1;i>=1;i--)if(so(e,t,i,o))return i;return 1},ds=(e,t)=>uo(e,t,false),uo=(e,t,o=false)=>{let r=vt,i=o?Io:lo,d=(i-(o?32:16))/2,s=r+(t-1)*i+d;return {x:Sr,y:s}};var Ir=({data:e,selected:t})=>{let{label:o="Splice Tray"}=e||{},[r,i]=useState(false),a=()=>{if(!r)return null;let d=[],s=vt;for(let l=1;l<=ct;l++){let p=s+(l-1)*lo;d.push(jsxs("div",{style:{position:"absolute",left:"-35px",top:`${p}px`,background:"#374151",color:"#9ca3af",padding:"2px 4px",borderRadius:"2px",fontSize:"8px",fontWeight:"bold",width:"28px",textAlign:"center",border:"1px solid #4b5563",zIndex:10,height:`${lo}px`,display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1},children:["H",l]},l));}return d};return jsxs("div",{className:`splice-tray-node ${t?"selected":""}`,style:{background:"transparent",border:"none",borderRadius:"8px",padding:0,width:`${Ct}px`,height:`${vt+ct*Io+qn}px`,color:"white",fontFamily:"monospace",fontSize:"12px",boxShadow:t?"0 0 0 2px #3b82f6":"0 2px 4px rgba(0,0,0,0.1)",position:"relative",display:"flex",flexDirection:"column"},children:[jsxs("div",{style:{textAlign:"center",marginBottom:0,zIndex:2,background:"#1f2937",padding:"2px",position:"relative",height:`${vt}px`,display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"center",gap:"6px",borderRadius:"8px"},children:[jsx("div",{style:{fontWeight:"bold",fontSize:"10px"},children:o}),jsx("button",{onPointerDown:d=>{d.stopPropagation();},onMouseDown:d=>{d.stopPropagation();},onClick:d=>{d.stopPropagation(),d.preventDefault(),i(!r);},style:{background:r?"#10b981":"#374151",color:r?"#ffffff":"#9ca3af",border:"1px solid #4b5563",borderRadius:"2px",padding:"2px 6px",fontSize:"8px",cursor:"pointer",fontFamily:"monospace"},title:`${r?"Hide":"Show"} holder markers`,children:"H"})]}),a(),jsx("div",{style:{position:"absolute",top:vt,left:0,right:0,bottom:0,pointerEvents:"none"}})]})};var Dr=({data:e,selected:t,id:o})=>{let{fibersPerTube:r=12,tubeIndex:i=1,startOn:a="left-center"}=e||{},d=e?.mode==="ribbon"||e?.ribbon===true,s=useEdges(),l=`tube-${i}`,p=s.find(ee=>ee.source===o&&ee.sourceHandle===l||ee.target===o&&ee.targetHandle===l),m=p?.data?.color,f=De((i-1)%12+1),c=m||f,b=Math.max(1,Math.min(24,Number(r)||12)),x=14,k=4,C=1,v=2,T=20,E=b*x+(b-1)*k,F=Math.max(60,E+C*2+v*2),y=a==="left"?Position.Left:a==="right"?Position.Right:Position.Bottom,w=y!==Position.Bottom,_=w?14:20,S=w?8:20,D=w?`inset ${y===Position.Left?"-4px":"4px"} 0 0 rgba(0, 0, 0, 0.35)`:"none",A=p?c:w?`linear-gradient(${y===Position.Left?"to right":"to left"}, rgba(0, 0, 0, 0.45), rgba(0, 0, 0, 0)), ${c}`:`radial-gradient(circle, ${c} 40%, transparent 70%)`,U={width:_,height:S,borderRadius:w?6:"50%",opacity:p?.3:.9,pointerEvents:"auto",background:A,backgroundColor:c,border:p?`2px solid ${c}`:`3px dashed ${c}`,cursor:"crosshair","--fiber-bg":c,boxShadow:p?D:`${D}${D!=="none"?", ":""}0 0 8px ${c}`,transition:"opacity 0.2s, box-shadow 0.2s",...y===Position.Left?{left:-(_-4)}:y===Position.Right?{right:-(_-4)}:{}},le=useMemo(()=>{let ee=[],re=F-v*2-C*2,ne,z,B=false;a==="left"?(ne=C,z=Position.Top):a==="right"?(ne=C+re-E,z=Position.Top,B=true):(ne=C+(re-E)/2,z=Position.Top);for(let O=0;O<b;O++){let L=B?b-O:O+1,X=`fiber-${L}`,J=s.find(Ne=>Ne.source===o&&Ne.sourceHandle===X||Ne.target===o&&Ne.targetHandle===X),$=!!J&&(J.data?.isRibbon||J.data?.ribbonFiberIds&&Array.isArray(J.data.ribbonFiberIds)),M=J?.data?.color,oe=typeof J?.data?.striped=="boolean"?J.data.striped:void 0,ie=tt(L);d||$?ie=tt(L,{base:"#808080",striped:false}):(M||oe!==void 0)&&(ie=tt(L,{...M?{base:M}:{},...oe!==void 0?{striped:oe}:{}}));let Q=ne+O*(x+k),j=C,ae={position:"absolute",left:`${Q}px`,top:`${j}px`,width:x,height:x,borderRadius:"50%",border:"none",zIndex:10,cursor:"pointer","--fiber-bg":ie.base,backgroundColor:ie.base};ie.backgroundImage&&(ae["--fiber-bg-image"]=ie.backgroundImage),ee.push(jsxs(lt.Fragment,{children:[jsx(Handle,{id:X,type:"target",position:z,className:"tube-fiber-handle",isConnectable:true,style:ae,"data-fiber-idx":L,"data-fiber-color":ie.base}),jsx(Handle,{id:X,type:"source",position:z,className:"tube-fiber-handle",isConnectable:true,style:ae,"data-fiber-idx":L,"data-fiber-color":ie.base})]},`fiber-${L}`));}return ee},[b,a,F,s,o,x,k,C,v,E,d]);return jsxs("div",{style:{width:F,height:T,borderRadius:4,background:"#111827",border:`${v}px solid ${t?"#3b82f6":c}`,position:"relative",boxShadow:t?`0 0 0 ${v}px #3b82f6`:"0 2px 4px rgba(0,0,0,0.2)",padding:C,boxSizing:"border-box",overflow:"visible"},children:[le,jsx(Handle,{id:l,type:"target",position:y,isConnectable:true,className:"tube-connection-handle",style:U,"data-tube-idx":i,"data-tube-color":c,title:p?"Connected - drag to reconnect":"Drag to connect cable tube"}),jsx(Handle,{id:l,type:"source",position:y,isConnectable:true,className:"tube-connection-handle",style:U,"data-tube-idx":i,"data-tube-color":c,title:p?"Connected - drag to reconnect":"Drag to connect cable tube"})]})};var $r=({data:e,selected:t})=>{let{fiberCount:o,cableId:r="CBL-002",label:i,color:a,rotation:d}=e||{},s=lt.useRef(null);lt.useEffect(()=>{if(s.current){let z=typeof d=="number"?d:0;s.current.style.transform=`rotate(${z}deg)`,s.current.style.transformOrigin="center center";}},[d]);let l=Math.max(1,Math.min(24,Number(o)||12)),p=10,m=2,f=6,c=f+p+4,b=60,x=Math.max(120,l*(p+m)+f*2),C=i??`${l}f Cable`,v=r?`Cable ID ${r}`:void 0,T=De(1),E=a||T,F=t?"#3b82f6":E,y=typeof d=="number"?d:0,w=z=>{let B=(z%360+360)%360;return B>=315||B<45?Position.Top:B>=45&&B<135?Position.Right:B>=135&&B<225?Position.Bottom:Position.Left},_=()=>{let z=[],B=w(y);for(let O=0;O<l;O++){let L=O+1,X=tt(L),J=X.base,$=f+O*(p+m),M=-5,oe=X.backgroundImage?X.backgroundImage:J,ie={position:"absolute",left:`${$}px`,top:`${M}px`,width:p,height:p,borderRadius:"50%",border:"none",background:oe,backgroundColor:J,zIndex:10,cursor:"pointer","--fiber-bg":J};X.backgroundImage&&(ie["--fiber-bg-image"]=X.backgroundImage);let Q=`fiber-${L}`;z.push(jsxs(lt.Fragment,{children:[jsx(Handle,{id:Q,type:"target",position:B,className:"tube-fiber-handle",isConnectable:true,style:ie,"data-fiber-idx":L,"data-fiber-color":J}),jsx(Handle,{id:Q,type:"source",position:B,className:"tube-fiber-handle",isConnectable:true,style:ie,"data-fiber-idx":L,"data-fiber-color":J})]},`fiber-${L}`));}return z},S="cable-button",D=8,A={width:D,height:D,borderRadius:"50%",background:E,backgroundColor:E,border:`1px solid ${E}`,cursor:"pointer",zIndex:10},U=2,ee=(z=>{let B=(z%360+360)%360;return B>=315||B<45?Position.Bottom:B>=45&&B<135?Position.Left:B>=135&&B<225?Position.Top:Position.Right})(y),re={width:x,height:b,position:"relative",transform:`rotate(${y}deg)`,transformOrigin:"center center","--rotation":`${y}deg`},ne={width:"100%",height:"100%",borderRadius:4,background:"#111827",border:`${U}px solid ${F}`,boxShadow:t?"0 0 0 2px #3b82f6":"0 2px 4px rgba(0,0,0,0.2)",padding:f,paddingTop:c,boxSizing:"border-box",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",color:"#e5e7eb",fontFamily:"monospace",textAlign:"center",gap:2};return jsx("div",{ref:s,style:re,children:jsxs("div",{style:ne,children:[_(),jsx(Handle,{id:S,type:"source",position:ee,className:"cable-button-handle",isConnectable:true,style:A,"data-handle-type":"cable-button","data-cable-color":E}),jsx(Handle,{id:S,type:"target",position:ee,className:"cable-button-handle",isConnectable:true,style:A,"data-handle-type":"cable-button","data-cable-color":E}),jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:2,transform:"translateX(2px)"},children:[jsx("div",{style:{fontSize:11,fontWeight:600,textTransform:"uppercase",letterSpacing:.5},children:C}),v&&jsx("div",{style:{fontSize:10,opacity:.8},children:v})]})]})})};var Wr=({data:e,selected:t})=>{let{tubeCount:o=12,fibersPerTube:r=12,fiberCount:i,cableId:a="CBL-002",label:d,tubeStartIndex:s=1,color:l}=e||{},p=Math.max(1,Math.min(24,Number(o)||12)),m=Math.max(1,Number(s)||1),f=14,c=10,b=3,x=6,k=x+c+4,C=60,v=Math.max(120,p*(f+b)+x*2),T=i??p*(Number(r)||12),E=d??`${T}f Cable`,F=a?`Cable ID ${a}`:void 0,y=De(m),w=l||y,_=t?"#3b82f6":w,S=()=>{let ee=[];for(let re=0;re<p;re++){let ne=m+re,z=tt(ne),B=z.base,O=x+re*(f+b),L=-5,X=z.backgroundImage?z.backgroundImage:B,J={position:"absolute",left:`${O}px`,top:`${L}px`,width:f,height:c,borderRadius:6,border:"none",background:X,backgroundColor:B,zIndex:10,cursor:"pointer","--fiber-bg":B};z.backgroundImage&&(J["--fiber-bg-image"]=z.backgroundImage);let $=`tube-${ne}`;ee.push(jsxs(lt.Fragment,{children:[jsx(Handle,{id:$,type:"target",position:Position.Top,className:"tube-fiber-handle",isConnectable:true,style:J,"data-fiber-idx":ne,"data-tube-idx":ne,"data-tube-color":B}),jsx(Handle,{id:$,type:"source",position:Position.Top,className:"tube-fiber-handle",isConnectable:true,style:J,"data-fiber-idx":ne,"data-tube-idx":ne,"data-tube-color":B})]},`tube-${ne}`));}return ee},D="cable-button",A=8,U={width:A,height:A,borderRadius:"50%",background:w,backgroundColor:w,border:`1px solid ${w}`,cursor:"pointer",zIndex:10};return jsxs("div",{style:{width:v,height:C,borderRadius:4,background:"#111827",border:`2px solid ${_}`,position:"relative",boxShadow:t?"0 0 0 2px #3b82f6":"0 2px 4px rgba(0,0,0,0.2)",padding:x,paddingTop:k,boxSizing:"border-box",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",color:"#e5e7eb",fontFamily:"monospace",textAlign:"center",gap:2},children:[S(),jsx(Handle,{id:D,type:"source",position:Position.Bottom,className:"cable-button-handle",isConnectable:true,style:U,"data-handle-type":"cable-button","data-cable-color":w}),jsx(Handle,{id:D,type:"target",position:Position.Bottom,className:"cable-button-handle",isConnectable:true,style:U,"data-handle-type":"cable-button","data-cable-color":w}),jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:2},children:[jsx("div",{style:{fontSize:11,fontWeight:600,textTransform:"uppercase",letterSpacing:.5},children:E}),F&&jsx("div",{style:{fontSize:10,opacity:.8},children:F})]})]})};var Ar=({data:e,selected:t,id:o})=>{let{connector:r="LC",couplerFiberCount:i,label:a,portLabelsLeft:d,portLabelsRight:s}=e||{},l=useEdges(),p=typeof i=="number"&&[1,2,4].includes(i)?i:2,m=Math.max(1,Math.min(4,p)),f=9,c=3,b=3,x=60,k=30,C=m*f+(m-1)*c,v=Math.max(k,C+b*2),T=Math.max(x,80),E=(w,_)=>{let S=`${w}-${_+1}`;return l.find(A=>A.source===o&&A.sourceHandle===S||A.target===o&&A.targetHandle===S)?.data?.color||"#555"},F=w=>{let _=[],S=w==="left"?Position.Left:Position.Right,D=w==="left"?d:s;for(let A=0;A<m;A++){let U=A+1,le=`${w}-${U}`,ee=E(w,A),z=b+(v-C)/2+A*(f+c),B={position:"absolute",left:w==="left"?-5:void 0,right:w==="right"?-5:void 0,top:`${z}px`,width:f,height:f,borderRadius:"50%",border:"none",background:ee,zIndex:100,cursor:"crosshair",transform:"translateY(-50%)"};_.push(jsxs(lt.Fragment,{children:[jsx(Handle,{id:le,type:"target",position:S,isConnectable:true,style:B}),jsx(Handle,{id:le,type:"source",position:S,isConnectable:true,style:B})]},le)),D&&D[A]&&_.push(jsx("div",{style:{position:"absolute",left:w==="left"?-30:void 0,right:w==="right"?-30:void 0,top:`${z}px`,transform:"translateY(-50%)",fontSize:"8px",color:"#9ca3af",fontFamily:"monospace",pointerEvents:"none",textAlign:w==="left"?"right":"left",width:"25px"},children:D[A]},`${le}-label`));}return _},y=a||`${r}-${m}f`;return jsxs("div",{className:`coupler-node ${t?"selected":""}`,style:{width:T,height:v,borderRadius:4,border:`2px solid ${t?"#3b82f6":"#4b5563"}`,background:"#1f2937",position:"relative",boxShadow:t?"0 0 0 2px #3b82f6":"0 2px 4px rgba(0,0,0,0.2)",display:"flex",alignItems:"center",justifyContent:"center",color:"#e5e7eb",fontFamily:"monospace",fontSize:"10px",padding:`${b}px`,boxSizing:"border-box"},children:[F("left"),jsx("div",{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",textAlign:"center",pointerEvents:"none",zIndex:1},children:jsx("div",{style:{fontWeight:"bold",fontSize:"9px"},children:y})}),F("right")]})};var St=32,Oo=30,hs=24,ms=80,Wo=400,Ao=300,ii=2,Pt=8,ai=120;function Lr(e){let{couplerFiberCount:t}=e.data||{},o=typeof t=="number"&&[1,2,4].includes(t)?t:2,r=Math.max(1,Math.min(4,o)),i=7,a=3,d=3,s=60,l=30,p=r*i+(r-1)*a,m=Math.max(l,p+d*2);return {width:Math.max(s,80),height:m}}function Lo(e){let{fibersPerTube:t=12}=e.data||{},o=Math.max(1,Math.min(24,Number(t)||12)),r=14,i=4,a=1,d=2,s=20,l=o*r+(o-1)*i;return {width:Math.max(60,l+a*2+d*2),height:s}}function si(e){return {width:Ct,height:0}}function di(e){return e.type==="coupler"?Lr(e):e.type==="tube"?Lo(e):e.type==="splice-tray"?si():{width:80,height:30}}function Or(e){let t=0;for(let o of e){let r=di(o),i=(o.position?.x||0)+r.width;i>t&&(t=i);}return t}function li(e,t=0){let o=t;for(let r of e){let i=di(r),a=(r.position?.y||0)+i.height;a>o&&(o=a);}return o}function ci(e){return e.data?.panelWidth||Wo}function ys(e){return e.data?.panelHeight||Ao}function ui(e){return ci(e)-ii*2-Pt*2}function ws(e,t){return ui(e)-t}function pi(e,t=Oo){return Math.floor(e/t)+1}function gi(e,t=Oo){return (e-1)*t}function Ns(e,t,o){let r=Oo,i=pi(o.y,r),a=gi(i,r);return {x:o.x,y:a,slotPosition:i}}function zr(e,t){if(t.length===0)return {width:e.data?.panelWidth||Wo,height:e.data?.panelHeight||Ao};let o=t.some(l=>l.type==="tube"),r=t.some(l=>l.type==="splice-tray"),i=t.some(l=>l.type==="coupler"),a;if(o&&r&&i){let l=0,p=0;for(let c of t)if(c.type==="tube"){let b=Lo(c);b.width>l&&(l=b.width);}else if(c.type==="coupler"){let b=Lr(c);b.width>p&&(p=b.width);}let m=l+ai+Ct+p+5,f=0;a=f+m+f;}else a=Or(t)+4;a=Math.max(e.data?.panelWidth||Wo,a);let d=li(t,St),s=Math.max(e.data?.panelHeight||Ao,d+Pt);return {width:a,height:s}}function fi(e,t,o){if(e===0)return 0;if(e===1)return t;let r=e*t,i=o-r,a=Math.max(5,i/(e-1));return t+a}function xs(e,t,o){return fi(e,t,o)}var oi=20,ri=400,ni=300;function Br(e,t){if(t.length===0)return {width:e.data?.closureWidth||e.data?.panelWidth||ri,height:e.data?.closureHeight||e.data?.panelHeight||ni};let o=t.some(s=>s.type==="tube"),r=t.some(s=>s.type==="splice-tray"),i;if(o&&r){let s=0,l=0,p=0,m=t.filter(c=>c.type==="tube"),f=t.filter(c=>c.type==="splice-tray");if(m.length>0&&f.length>0){let c=f.map(x=>x.position?.x||0),b=c.reduce((x,k)=>x+k,0)/c.length;for(let x of m){let k=Lo(x);(x.position?.x||0)<b?k.width>s&&(s=k.width):k.width>l&&(l=k.width);}f.length>0&&(p=Ct),i=Pt+s+oi+p+oi+l+5;}else i=Or(t)+Pt+5;}else i=Or(t)+Pt+5;i=Math.max(e.data?.closureWidth||e.data?.panelWidth||ri,i);let a=li(t,St),d=Math.max(e.data?.closureHeight||e.data?.panelHeight||ni,a+Pt);return {width:i,height:d}}var jr=({data:e,selected:t,id:o})=>{let{label:r="Patch Panel",header:i,panelWidth:a,panelHeight:d}=e||{},{getNodes:s,setNodes:l}=useReactFlow(),p=useRef(false),m=useRef([]),f=useMemo(()=>{let E=s().filter(F=>F.parentId===o);return (E.length!==m.current.length||E.some((F,y)=>F.id!==m.current[y]?.id))&&(m.current=E),m.current},[s,o]),c=useMemo(()=>({id:o,type:"patch-panel",position:{x:0,y:0},data:{...e,panelWidth:a,panelHeight:d}}),[o,e,a,d]),b=useMemo(()=>a&&d?{width:a,height:d}:f.length===0?{width:a||400,height:d||300}:zr(c,f),[f,c,a,d]);useEffect(()=>{if(a&&d||p.current)return;let T=a,E=d,F=Math.abs((T||0)-b.width),y=Math.abs((E||0)-b.height);(F>1||y>1)&&(p.current=true,l(w=>w.map(_=>_.id===o?{..._,data:{..._.data,panelWidth:b.width,panelHeight:b.height}}:_)),setTimeout(()=>{p.current=false;},0));},[o,b.width,b.height,a,d,l]);let x=b.width,k=b.height,C=St,v=i||r;return jsxs("div",{className:`patch-panel-node ${t?"selected":""}`,style:{background:"transparent",border:"none",borderRadius:"8px",padding:0,width:`${x}px`,height:`${k}px`,color:"white",fontFamily:"monospace",fontSize:"12px",boxShadow:t?"0 0 0 2px #3b82f6":"0 2px 4px rgba(0,0,0,0.1)",position:"relative",display:"flex",flexDirection:"column",backgroundColor:"#1f2937",boxSizing:"border-box"},children:[jsx("div",{style:{textAlign:"center",marginBottom:0,zIndex:2,background:"#374151",padding:"6px 12px",position:"relative",height:`${C}px`,display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"center",gap:"6px",borderRadius:"6px 6px 0 0",borderBottom:"1px solid #4b5563"},children:jsx("div",{style:{fontWeight:"bold",fontSize:"11px"},children:v})}),jsx("div",{style:{position:"absolute",top:C,left:0,right:0,bottom:0,pointerEvents:"none",overflow:"visible"}})]})};var Yr=({data:e,selected:t,id:o})=>{let{label:r="Closure",header:i,closureWidth:a,closureHeight:d,panelWidth:s,panelHeight:l}=e||{},{getNodes:p,setNodes:m}=useReactFlow(),f=useRef(false),c=useRef([]),b=useMemo(()=>{let w=p().filter(_=>_.parentId===o);return (w.length!==c.current.length||w.some((_,S)=>_.id!==c.current[S]?.id))&&(c.current=w),c.current},[p,o]),x=useMemo(()=>({id:o,type:"closure",position:{x:0,y:0},data:{...e,closureWidth:a||s,closureHeight:d||l}}),[o,e,a,d,s,l]),k=useMemo(()=>a&&d?{width:a,height:d}:s&&l?{width:s,height:l}:b.length===0?{width:a||s||400,height:d||l||300}:Br(x,b),[b,x,a,d,s,l]);useEffect(()=>{if(a&&d||s&&l||f.current)return;let y=a||s,w=d||l,_=Math.abs((y||0)-k.width),S=Math.abs((w||0)-k.height);(_>1||S>1)&&(f.current=true,m(D=>D.map(A=>A.id===o?{...A,data:{...A.data,closureWidth:k.width,closureHeight:k.height}}:A)),setTimeout(()=>{f.current=false;},0));},[o,k.width,k.height,a,d,s,l,m]);let C=k.width,v=k.height,T=St,E=i||r,F=C/2;return jsxs("div",{className:`closure-node ${t?"selected":""}`,style:{background:"transparent",border:"none",borderRadius:`${F}px ${F}px 12px 12px`,padding:0,width:`${C}px`,height:`${v}px`,color:"white",fontFamily:"monospace",fontSize:"12px",boxShadow:t?"0 0 0 2px #3b82f6":"0 2px 4px rgba(0,0,0,0.1)",position:"relative",display:"flex",flexDirection:"column",backgroundColor:"#1f2937",boxSizing:"border-box",overflow:"hidden"},children:[jsx("div",{style:{textAlign:"center",marginBottom:0,zIndex:2,background:"#374151",padding:"6px 12px",position:"relative",height:`${T}px`,display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"center",gap:"6px",borderRadius:`${F}px ${F}px 0 0`,borderBottom:"1px solid #4b5563"},children:jsx("div",{style:{fontWeight:"bold",fontSize:"11px"},children:E})}),jsx("div",{style:{position:"absolute",top:T,left:0,right:0,bottom:0,pointerEvents:"none",overflow:"visible"}})]})};var Zr=({data:e,selected:t,id:o})=>{let{label:r,splitterType:i="splitter",inputCount:a=1,outputCount:d=8}=e||{},s=useEdges(),l=r||(i==="WDM"?"WDM":"Splitter"),p=9,m=3,f=3,c=50,b=30,x=Math.min(Math.max(a||1,1),2),k=x*p+(x-1)*m,C=Math.min(d||8,48),v=C*p+(C-1)*m,T=Math.max(k,v),E=Math.max(b,T+f*2),F=Math.max(c,50),y=re=>s.find(z=>z.source===o&&z.sourceHandle===re||z.target===o&&z.targetHandle===re)?.data?.color||"#555",w=()=>{let re=[],ne=f+(E-k)/2;for(let z=0;z<x;z++){let B=`input-${z+1}`,O=ne+z*(p+m),L=y(B),X={position:"absolute",left:-5,top:`${O}px`,width:p,height:p,borderRadius:"50%",border:"none",background:L,zIndex:100,cursor:"crosshair",transform:"translateY(-50%)"};re.push(jsxs(lt.Fragment,{children:[jsx(Handle,{id:`${B}-target`,type:"target",position:Position.Left,isConnectable:true,style:X}),jsx(Handle,{id:`${B}-source`,type:"source",position:Position.Left,isConnectable:true,style:X})]},B));}return re},_=()=>{let re=[],ne=f+(E-v)/2;for(let z=0;z<C;z++){let B=`output-${z+1}`,O=ne+z*(p+m),L=y(B),X={position:"absolute",right:-5,top:`${O}px`,width:p,height:p,borderRadius:"50%",border:"none",background:L,zIndex:100,cursor:"crosshair",transform:"translateY(-50%)"};re.push(jsxs(lt.Fragment,{children:[jsx(Handle,{id:`${B}-target`,type:"target",position:Position.Right,isConnectable:true,style:X}),jsx(Handle,{id:`${B}-source`,type:"source",position:Position.Right,isConnectable:true,style:X})]},B));}return re},S=Math.max(k+f*4,b*.6),D=(E-S)/2,A=D+S,U=0,le=E,ee=t?"#3b82f6":"#4b5563";return jsxs("div",{className:`trapezoid-node ${t?"selected":""}`,style:{width:F,height:E,position:"relative",background:"transparent",boxShadow:t?"0 0 0 2px #3b82f6":"0 2px 4px rgba(0,0,0,0.2)",display:"flex",alignItems:"center",justifyContent:"center",color:"#e5e7eb",fontFamily:"monospace",fontSize:"10px",padding:`${f}px`,boxSizing:"border-box"},children:[jsx("svg",{width:F,height:E,viewBox:`0 0 ${F} ${E}`,style:{position:"absolute",top:0,left:0,width:`${F}px`,height:`${E}px`,pointerEvents:"none",zIndex:0},children:jsx("polygon",{points:`0,${D} 0,${A} ${F},${le} ${F},${U}`,fill:"#1f2937",stroke:ee,strokeWidth:"2"})}),w(),jsx("div",{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",textAlign:"center",pointerEvents:"none",zIndex:1},children:jsx("div",{style:{fontWeight:"bold",fontSize:"9px"},children:l})}),_()]})};var yi=e=>e?.type==="tube"||e?.type==="splice"||e?.type==="coupler"||e?.type==="fibre-split"||e?.type==="cable"||e?.type==="multi-tube-cable",Uo=(e,t)=>yi(e)||yi(t),te=(e,t)=>t?e?.type==="fibre-split"?Te(t):Te(t):t||"";function Vo(e,t){if(!e||!t)return "unknown";let o=Te(t);if(!o)return "unknown";if(e.type==="vertical-pdu")return "power";let r=e.data??{},i=Array.isArray(r.ports)?r.ports:[],a=Array.isArray(r.rearPorts)?r.rearPorts:[];for(let p of [...i,...a])for(let m of p.ports||[])if(kt(p.name,{label:m.label,type:rt(m.type)?m.type:void 0})===o)return rt(m.type)?"power":"network";if(To(o)||/^\d+$/.test(o))return "power";let d=o.toLowerCase(),s=d.startsWith("net-")||d.startsWith("port-")||d.startsWith("uplink-")||d.includes("fiber")||d.includes("ports"),l=/^[A-Z0-9]+-\d+$/i.test(o)&&!d.startsWith("pwr")&&!d.startsWith("power");return s||l?"network":"unknown"}function Et(e,t){return Vo(e,t)==="power"}function Rs(e,t){if(!e.source||!e.target||!e.sourceHandle||!e.targetHandle)return {valid:true};let o=t.nodes.find($=>$.id===e.source),r=t.nodes.find($=>$.id===e.target),i=Uo(o,r);if(!i){let $=Vo(o,e.sourceHandle),M=Vo(r,e.targetHandle);if($!=="unknown"&&M!=="unknown"&&$!==M)return {valid:false,reason:`Cannot connect ${$} handle to ${M} handle`};let oe=$==="power"&&M==="power",ie=o?.type==="vertical-pdu"||r?.type==="vertical-pdu";if(oe&&!ie)return {valid:false,reason:"Power connections must include a PDU endpoint"}}let a=te(o,e.sourceHandle),d=te(r,e.targetHandle),s=t.edges.some($=>e.ignoreEdgeId&&$.id===e.ignoreEdgeId?false:$.source===e.source?te(o,$.sourceHandle)===a:$.target===e.source?te(o,$.targetHandle)===a:false),l=t.edges.some($=>e.ignoreEdgeId&&$.id===e.ignoreEdgeId?false:$.target===e.target?te(r,$.targetHandle)===d:$.source===e.target?te(r,$.sourceHandle)===d:false);if((s||l)&&!i)return s?{valid:false,reason:`Source handle ${e.sourceHandle} on node ${e.source} is already connected`}:{valid:false,reason:`Target handle ${e.targetHandle} on node ${e.target} is already connected`};let p=($,M)=>($?.type==="tube"||$?.type==="cable")&&!!M&&M.startsWith("fiber-"),m=($,M)=>($?.type==="tube"||$?.type==="multi-tube-cable")&&!!M&&M.startsWith("tube-"),f=($,M)=>$?.type==="multi-tube-cable"&&!!M&&M.startsWith("tube-"),c=($,M)=>$?.type==="tube"&&!!M&&M.startsWith("tube-"),b=($,M)=>($?.type==="cable"||$?.type==="multi-tube-cable")&&M==="cable-button",x=($,M)=>$?.type==="splice"&&(M==="left"||M==="right"),k=($,M)=>$?.type==="coupler"&&!!M&&(M.startsWith("left-")||M.startsWith("right-")),C=($,M)=>{if($?.type!=="fibre-split"||!M)return false;let oe=te($,M);return oe.startsWith("input-")||oe.startsWith("output-")};if(!i)return {valid:true};if(o?.type==="splice"&&r?.type==="splice"){let $=o.data?.mode==="ribbon",M=r.data?.mode==="ribbon";if($!==M)return {valid:false,reason:"Ribbon splices can only connect to other ribbon splices"}}let v=p(o,e.sourceHandle),T=p(r,e.targetHandle),E=x(o,e.sourceHandle),F=x(r,e.targetHandle),y=k(o,e.sourceHandle),w=k(r,e.targetHandle),_=C(o,e.sourceHandle),S=C(r,e.targetHandle),D=b(o,e.sourceHandle),A=b(r,e.targetHandle),U=f(o,e.sourceHandle),le=f(r,e.targetHandle),ee=c(o,e.sourceHandle),re=c(r,e.targetHandle),ne=m(o,e.sourceHandle),z=m(r,e.targetHandle);return v&&F||T&&E||(E&&(w||S)||F&&(y||_))||(y&&(w||S||F)||w&&(y||_||E))||D&&A||(U&&re||le&&ee)?{valid:true}:ne&&z?{valid:false,reason:"Tube handles can only connect between cable and tube nodes"}:{valid:false,reason:"Connection not allowed by fiber rules"}}function jo(e,t){if(!t)return;let o=Te(e),r=t.data??{},i=r.handleSideMap;if(i&&i[o])return i[o];if(o==="net-top"||o==="net-bottom")return "front";if(o==="pwr-left-1"||o==="pwr-left-2"||o==="net-right-1"||o==="net-right-2")return "rear";let a=Array.isArray(r.ports)?r.ports:[],d=Array.isArray(r.rearPorts)?r.rearPorts:[];if(To(o))return "rear";for(let s of a)for(let l of s.ports||[])if(kt(s.name,{label:l.label,type:rt(l.type)?l.type:void 0})===o)return "front";for(let s of d)for(let l of s.ports||[])if(kt(s.name,{label:l.label,type:rt(l.type)?l.type:void 0})===o)return "rear"}function qr(e={},t={}){let o={nodes:e.nodes??[],edges:e.edges??[],debug:e.debug??false},r=new Set;return {getState:()=>o,setState:f=>{o={...o,...f},r.forEach(c=>c(o));},subscribe:f=>(r.add(f),()=>r.delete(f)),selectEdgeZIndex:f=>{let c=(k,C)=>{let v=o.nodes.find(re=>re.id===k);if(!(!!v&&(v.type==="device"||v.type==="server"||v.type==="switch"||v.type==="router"))||!v||v.data?.deviceType?.toLowerCase().replace(/_/g,"-")==="patch-panel")return;let F=Array.isArray(v.data?.rearPorts)&&v.data.rearPorts.length>0,y=Array.isArray(v.data?.ports)&&v.data.ports.length>0,w=v.data?.view||(F&&!y?"rear":"front"),_=jo(C||"",v);if(_)return w===_?1e3:500;let S=(C||"").toString().replace(/-(source|target)$/i,""),D=S.toLowerCase(),A=D.startsWith("pwr")||D.startsWith("power"),U=D.startsWith("net-")||D.startsWith("port-")||D.startsWith("uplink-")||D.includes("fiber")||D.includes("ports"),le=/^[A-Z0-9]+-\d+$/i.test(S)&&!D.startsWith("pwr")&&!D.startsWith("power"),ee=U||le;if(A)return w==="rear"?1e3:500;if(ee)return w==="front"?1e3:500},b=c(f.target,f.targetHandle);if(b!==void 0)return b;let x=c(f.source,f.sourceHandle);return x!==void 0?x:1e3},validateConnection:f=>(t.validateConnection||Rs)(f,o),selectNodeById:f=>o.nodes.find(c=>c.id===f),selectConnectedEdges:f=>o.edges.filter(c=>c.source===f||c.target===f)}}function Ts(e){let t=i=>e.subscribe(a=>i()),o=()=>e.getState();return useSyncExternalStore(t,o,o)}function Qr(e){let t=r=>e.subscribe(i=>r()),o=()=>e.getState().nodes;return useSyncExternalStore(t,o,o)}function en(e){let t=r=>e.subscribe(i=>r()),o=()=>e.getState().edges;return useSyncExternalStore(t,o,o)}function wi(e){return e.selectEdgeZIndex}function Ni(e){let t=e.data.rackWidthPx||300,o=60+(e.data.uHeight||42)*20,r=e.position.x,i=e.position.x+t,a=e.position.y,d=e.position.y+o;return {left:r,right:i,top:a,bottom:d}}function xi(e,t){let o=Ni(t);return e.x>=o.left&&e.x<=o.right&&e.y>=o.top&&e.y<=o.bottom}function Go(e,t){let o=null,r=1/0;for(let i of t){if(!xi(e,i))continue;let a=Math.sqrt(Math.pow(e.x-i.position.x,2)+Math.pow(e.y-i.position.y,2));a<r&&(r=a,o=i);}return o}function Pe(e){let{edges:t,connection:o,edgeType:r,selectEdgeZIndex:i,findBy:a,matchOn:d=a,data:s}=e,l=a==="source"?o.sourceHandle:o.targetHandle,p=a==="source"?o.source:o.target;if(!l||!p)return null;let m=Te(l),f=t.find(v=>d==="source"?v.source===p&&Te(v.sourceHandle)===m:v.target===p&&Te(v.targetHandle)===m);if(!f)return null;let c=t.filter(v=>v.id!==f.id),b=addEdge(o,c),x=b[b.length-1],k=i({...o,id:x.id,type:r}),C={...x,type:r,zIndex:k,style:{...x.style,zIndex:k},data:s!==void 0?s:x.data};return [...b.slice(0,-1),C]}function Ci(e){return !e||e.type!=="splice"?false:e.data?.mode==="ribbon"}var Fe=({type:e,children:t})=>{let o=lt.useRef(null),r=lt.useCallback(i=>{if(o.current=i,i){let a=i.parentElement,d=0;for(;a&&!a.classList.contains("react-flow__node")&&d<10;)a=a.parentElement,d++;a&&a.classList.contains("react-flow__node")&&a.setAttribute("data-type",e);}},[e]);return lt.useEffect(()=>{if(o.current){let i=o.current.parentElement,a=0;for(;i&&!i.classList.contains("react-flow__node")&&a<10;)i=i.parentElement,a++;i&&i.classList.contains("react-flow__node")&&i.setAttribute("data-type",e);}},[e]),jsx("div",{ref:r,style:{width:"100%",height:"100%"},children:t})},Hi=(e,t,o)=>({rack:r=>jsx(Fe,{type:"rack",children:jsx(pr,{...r,onViewChange:e,onRackFaceChange:t,isDragOver:o?o()===r.id:false})}),fiber:r=>jsx(Fe,{type:"fiber",children:jsx(gr,{...r})}),device:r=>jsx(Fe,{type:"device",children:jsx($t,{...r})}),server:r=>jsx(Fe,{type:"server",children:jsx($t,{...r})}),switch:r=>jsx(Fe,{type:"switch",children:jsx($t,{...r})}),router:r=>jsx(Fe,{type:"router",children:jsx($t,{...r})}),"vertical-pdu":r=>jsx(Fe,{type:"vertical-pdu",children:jsx(vr,{...r})}),splice:r=>jsx(Fe,{type:"splice",children:jsx(Pr,{...r})}),"splice-tray":r=>jsx(Fe,{type:"splice-tray",children:jsx(Ir,{...r})}),tube:r=>jsx(Fe,{type:"tube",children:jsx(Dr,{...r})}),cable:r=>jsx(Fe,{type:"cable",children:jsx($r,{...r})}),"multi-tube-cable":r=>jsx(Fe,{type:"multi-tube-cable",children:jsx(Wr,{...r})}),coupler:r=>jsx(Fe,{type:"coupler",children:jsx(Ar,{...r})}),"patch-panel":r=>jsx(Fe,{type:"patch-panel",children:jsx(jr,{...r})}),closure:r=>jsx(Fe,{type:"closure",children:jsx(Yr,{...r})}),"fibre-split":r=>jsx(Fe,{type:"fibre-split",children:jsx(Zr,{...r})})});function Pi(e){if(!e)return false;if(e.type==="switch")return true;if(e.type!=="device")return false;let t=e.data?.deviceType;return typeof t=="string"&&t.toLowerCase().replace(/_/g,"-")==="switch"}function Si(e,t,o){let r=e.sourceHandle,i=e.targetHandle;return Pi(t)&&r&&!Et(t,r)&&(r=Te(r)),Pi(o)&&i&&!Et(o,i)&&(i=`${Te(i)}-target`),r===e.sourceHandle&&i===e.targetHandle?e:{...e,sourceHandle:r,targetHandle:i}}var Vs={fiber:Eo,ethernet:Eo,power:br,smoothstep:Mn,step:On,"thick-cable":Bn},js=8192,Gs=8192,Xs=2048,Ys=4;function go(e,t,o){if(!(typeof e!="number"||Number.isNaN(e)))return Math.min(o,Math.max(t,e))}function Ks(e){if(e)return {...e,width:go(e.width,1,js),height:go(e.height,1,Gs),padding:go(e.padding,0,Xs),pixelRatio:go(e.pixelRatio,.1,Ys),quality:go(e.quality,0,1)}}var Zs=({nodes:e,edges:t,initialNodes:o,initialEdges:r,onNodesChange:i,onEdgesChange:a,store:d,debug:s,onNodeClick:l,onEdgeClick:p,nodeTypes:m,edgeTypes:f,onConnect:c,onEdgeUpdate:b,isValidConnection:x,connectionMode:k,onViewChange:C,onRackFaceChange:v,className:T,style:E,alignRacksToBottom:F,reAssignable:y=true,colorMode:w="dark",onInit:_,onFlowMethods:S,showDownloadButton:D=false,downloadButtonPosition:A="top-right",downloadButtonText:U="Download Image",downloadButtonStyle:le,useSmoothstepEdgesForTubes:ee=false,readOnly:re=false,interaction:ne,actionPanel:z,connectOnClick:B=true,panOnDrag:O=true,panOnScroll:L=true,zoomOnScroll:X=true,fitViewOptions:J})=>{let $=useCallback((n,u)=>{let h=new Map,g=[],H=[],R=(I,W)=>!I||!W?false:!!(I.startsWith("tube-")||W.type==="splice"&&(I==="left"||I==="right")||I==="cable-button");for(let I of n){if(!I.source||!I.target||!I.sourceHandle||!I.targetHandle){s&&console.warn("Invalid edge skipped (missing source/target/handles):",I);continue}let W=u.find(he=>he.id===I.source),P=u.find(he=>he.id===I.target),K=`${I.source}:${I.sourceHandle}`,se=h.get(K),ke=R(I.sourceHandle,W),Re=`${I.target}:${I.targetHandle}`,ve=h.get(Re),Ue=R(I.targetHandle,P);if(se&&!ke){s&&console.warn("Duplicate connection detected on source handle, removing:",{handle:K,existingEdge:se.id,duplicateEdge:I.id}),H.push(I);continue}if(ve&&!Ue){s&&console.warn("Duplicate connection detected on target handle, removing:",{handle:Re,existingEdge:ve.id,duplicateEdge:I.id}),H.push(I);continue}g.push(I),se||h.set(K,I),ve||h.set(Re,I);}return s&&H.length>0&&console.log(`Filtered ${H.length} duplicate edge(s) from initial edges`),g},[s]),M=Array.isArray(e)&&Array.isArray(t),oe=lt.useMemo(()=>M?e||[]:o||e||[],[M,e,o]),ie=lt.useMemo(()=>M?t||[]:r||t||[],[M,t,r]),Q=lt.useMemo(()=>$(ie,oe),[ie,oe,$]),j=lt.useMemo(()=>d||qr({nodes:oe,edges:Q,debug:s}),[d,M,s,Q]),ae=Qr(j),Ne=en(j),[ye,ce]=useNodesState(ae),[qe,Ge,jt]=useEdgesState(Ne),ue=wi(j),$e=useRef(null),[Ae,Yi]=useState(false);useEffect(()=>{let n=()=>{Yi(window.innerWidth<=768||/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));};return n(),window.addEventListener("resize",n),()=>window.removeEventListener("resize",n)},[]);let xe=re===true,Ie=useMemo(()=>{let u={...{nodesDraggable:true,nodesConnectable:true,elementsSelectable:!Ae,edgesFocusable:!Ae,edgesReconnectable:true,connectOnClick:B,panOnDrag:O,panOnScroll:L&&!Ae,zoomOnScroll:X&&!Ae,zoomOnPinch:!Ae,zoomOnDoubleClick:!Ae,allowKeyboardDelete:true,showControls:true,showMiniMap:!Ae,showInteractiveControl:true},...ne??{}};return xe?{...u,nodesDraggable:false,nodesConnectable:false,elementsSelectable:false,edgesFocusable:false,edgesReconnectable:false,connectOnClick:false,panOnDrag:false,panOnScroll:false,zoomOnScroll:false,zoomOnPinch:false,zoomOnDoubleClick:false,allowKeyboardDelete:false,showInteractiveControl:false}:u},[Ae,B,O,L,X,ne,xe]),bo=useMemo(()=>({enabled:z?.enabled??true,showRearToggle:z?.showRearToggle??true,showDeRack:z?.showDeRack??true}),[z]),{toObject:ln,setViewport:cn,setNodes:un,setEdges:pn,getNodes:gt,getEdges:gn,fitView:Zo,flowToScreenPosition:qo}=useReactFlow();useEffect(()=>{S&&S({toObject:()=>ln(),setViewport:cn,setNodes:n=>{un(n),j.setState({nodes:n});},setEdges:n=>{pn(n),j.setState({edges:n});},toImage:n=>$e.current?toPng($e.current,Ks(n)):Promise.reject(new Error("ReactFlow wrapper not available")),getNodes:()=>gt(),getEdges:()=>gn(),fitView:n=>{if(n?.nodes&&Array.isArray(n.nodes)&&n.nodes.length>0){let u=n.nodes.map(H=>gt().find(R=>R.id===H)).filter(H=>H!==void 0),{nodes:h,...g}=n;Zo({...g,nodes:u});}else {let{nodes:u,...h}=n||{};Zo(h);}}});},[S,ln,cn,un,pn,j,Zo,gt,gn]);let[ft,fn]=useState(false),Ki=useCallback(()=>{if(!ft){if(!$e.current){s&&console.error("ReactFlow wrapper ref is not available");return}fn(true),toPng($e.current,{filter:n=>!(n?.classList?.contains("react-flow__minimap")||n?.classList?.contains("react-flow__controls")||n?.classList?.contains("react-flow__attribution")||n?.classList?.contains("download-button")||n?.tagName==="BUTTON"),backgroundColor:w==="light"?"#ffffff":"#1a1a1a",pixelRatio:2}).then(n=>{let u=document.createElement("a");u.download=`network-diagram-${new Date().toISOString().split("T")[0]}.png`,u.href=n,u.click();}).catch(n=>{s&&console.error("Error downloading image:",n);}).finally(()=>{fn(false);});}},[w,s,ft]),[bn,ho]=useState(null),hn=useRef(null),mn=useRef(C),yn=useRef(v);useEffect(()=>{mn.current=C;},[C]),useEffect(()=>{yn.current=v;},[v]),useEffect(()=>{hn.current=bn;},[bn]);let Jo=useCallback((n,u)=>{mn.current?.(n,u);},[]),Qo=useCallback((n,u)=>{yn.current?.(n,u);},[]),er=useCallback(()=>hn.current,[]),wn=useRef({...Hi(Jo,Qo,er),...m??{}});useEffect(()=>{wn.current={...Hi(Jo,Qo,er),...m??{}};},[Jo,Qo,er,m]);let Zi=useMemo(()=>({...Vs,...f??{}}),[f]),Xe=useRef(ye);useEffect(()=>{Xe.current=ye;},[ye]);let Y=useRef(qe);useEffect(()=>{Y.current=qe;},[qe]),useEffect(()=>{ce(ae);},[ae,ce]),useEffect(()=>{Ge(Ne);},[Ne,Ge]),useEffect(()=>{if(M&&t){let n=$(t,e||[]);n.length!==t.length&&(s&&console.warn(`Controlled edges had ${t.length-n.length} duplicate(s) removed`),a?.(n));}},[M,t,e,$,a,s]),useEffect(()=>{M&&j.setState({nodes:e||[]});},[M,e,j]),useEffect(()=>{M&&j.setState({edges:t||[]});},[M,t,j]),useEffect(()=>{if(!F||!ye||ye.length===0)return;let n=ye.filter(P=>P.type==="rack");if(n.length===0)return;let u=n.map(P=>{let se=P.data?.uHeight||42,ke=60+se*20;return (P.position?.y||0)+ke}),h=Math.min(...u),g=Math.max(...u);if(g-h<20)return;let R=g,I=ye.map(P=>{if(P.type!=="rack")return P;let se=P.data?.uHeight||42,ke=60+se*20,Re=(P.position?.y||0)+ke,ve=R-Re;return Math.abs(ve)<5?P:{...P,position:{x:P.position?.x||0,y:(P.position?.y||0)+ve}}});I.some((P,K)=>P.position!==ye[K].position)&&ce(I);},[F,ye,ce]);let Gt=useRef(new Map);useEffect(()=>{let n=new Map;ye.forEach(u=>{n.set(u.id,u);}),Gt.current=n;},[ye]);let pe=useCallback(n=>Gt.current.get(n),[]),Oe=useCallback(n=>{if(!n)return;if(typeof n.parentId=="string")return n.parentId;let u=n.parentNode;if(typeof u=="string")return u},[]),tr=useCallback(n=>{if(!n||n.type!=="device")return false;let u=n.data?.deviceType;return typeof u=="string"&&u.toLowerCase().replace(/_/g,"-")==="patch-panel"},[]),mo=useCallback(n=>{Xe.current=n;let u=new Map;n.forEach(h=>{u.set(h.id,h);}),Gt.current=u,ce(n),M?i?.(n):j.setState({nodes:n});},[M,j,ce,i]),we=useCallback(n=>{Y.current=n,Ge(n),M?a?.(n):j.setState({edges:n});},[M,j,Ge,a]),it=useCallback(n=>{if(n.positionAbsolute)return n.positionAbsolute;let u=n.position?.x||0,h=n.position?.y||0,g=Oe(n),H=new Set;for(;g&&!H.has(g);){H.add(g);let R=pe(g);if(!R)break;if(R.positionAbsolute){u+=R.positionAbsolute.x,h+=R.positionAbsolute.y;break}u+=R.position?.x||0,h+=R.position?.y||0,g=Oe(R);}return {x:u,y:h}},[pe,Oe]),yo=useCallback(n=>{let u=it(n),h=n.width||0,g=n.height||0;return {x:u.x+h/2,y:u.y+g/2}},[it]),Xt=useCallback((n,u)=>{if(!n||!u)return;let h=pe(n);if(!h)return;let g=u.replace(/-(source|target)$/i,"");if(h.type==="fibre-split"&&g.startsWith("output-")){let R=Y.current.filter(I=>I.target===n&&(I.targetHandle||"").replace(/-(source|target)$/i,"").startsWith("input-"));if(R.length>0){let I=R[0]?.data?.color;if(I)return {color:I}}}if((h.type==="tube"||h.type==="cable")&&u.startsWith("fiber-")){let R=u.replace("fiber-",""),I=parseInt(R,10);if(I>=1&&I<=24){let W=wt(I),P=I>12;return {color:W,striped:P}}}if((h.type==="multi-tube-cable"||h.type==="tube")&&u.startsWith("tube-")){let R=u.replace("tube-",""),I=parseInt(R,10);if(I>=1&&I<=24){let W=De(I),P=I>12;return {color:W,striped:P}}}let H=h.data;if(H.color)return {color:H.color}},[pe]),Nn=useRef(new Map);useEffect(()=>{Ge(n=>{let u=false,h=n.map(g=>{let H=ue(g);return Nn.current.get(g.id)!==H?(u=true,Nn.current.set(g.id,H),{...g,zIndex:H,style:{...g.style,zIndex:H}}):g});return u?h:n});},[ye,Ge,ue]),useEffect(()=>{let n=ye.map(h=>{if(h.type==="coupler"&&h.parentId){let g=pe(h.parentId);if(g&&(g.type==="patch-panel"||g.type==="closure")&&(!h.extent||h.extent!=="parent"))return {...h,extent:"parent"}}if(h.type==="splice"&&h.parentId&&h.data.holderPosition&&(!h.position||h.position.x===0&&h.position.y===0)){let g=pe(h.parentId);if(g&&g.type==="splice-tray"){let H=h.data.mode==="ribbon",R=uo(g,h.data.holderPosition,H);return {...h,position:R}}}if(We(h)&&h.parentId&&h.data.uPosition&&(!h.position||h.position.x===0&&h.position.y===0)){let g=pe(h.parentId);if(g){let H=h.data.uHeight||1,R=_t(g,h.data.uPosition,H);return {...h,position:R}}}return h});n.some((h,g)=>{let H=ye[g];return h.extent!==H.extent||h.position?.x!==H.position?.x||h.position?.y!==H.position?.y})&&ce(n);},[ye,ce,pe]);let qi=useCallback(n=>{if(xe)return null;let u=new Map,h=new Map,g=new Set,H=n.map(W=>{if(W.type==="position"&&W.position){let P=pe(W.id);if(P&&P.type==="coupler"&&P.parentId){let K=pe(P.parentId);if(K&&(K.type==="patch-panel"||K.type==="closure"))return (!P.extent||P.extent!=="parent")&&g.add(P.id),{...W,position:P.position||{x:0,y:0}}}if(P&&(P.type==="tube"||P.type==="splice-tray")&&P.parentId){let K=pe(P.parentId);if(K&&K.type==="closure")return (!P.extent||P.extent!=="parent")&&g.add(P.id),{...W,position:P.position||{x:0,y:0}}}if(P&&P.type==="splice"&&P.parentId){let K=pe(P.parentId);if(K&&K.type==="splice-tray"){let se=Er(P,K,W.position,Xe.current);return se.holderPosition!==void 0&&u.set(P.id,se.holderPosition),{...W,position:{x:se.x,y:se.y}}}}if(P&&We(P)&&P.parentId){let K=pe(P.parentId);if(K&&K.type==="rack"){let se=Co(P,K,W.position,Xe.current);return se.uPosition!==void 0&&h.set(P.id,se.uPosition),{...W,position:{x:se.x,y:se.y}}}}}return W}),R=applyNodeChanges(H,Xe.current).map(W=>{let P=W;g.has(W.id)&&(P={...P,extent:"parent"});let K=u.get(W.id);K!==void 0&&(P={...P,data:{...P.data,holderPosition:K}});let se=h.get(W.id);return se!==void 0&&(P={...P,data:{...P.data,uPosition:se}}),P});Xe.current=R;let I=new Map;return R.forEach(W=>{I.set(W.id,W);}),Gt.current=I,ce(R),R},[ce,pe,xe]),Ji=useCallback((n,u)=>{ho(null);},[]),Qi=useCallback((n,u,h)=>{let g=Oe(u);if(!y||!We(u)||g){ho(null);return}let H=Xe.current.filter(P=>P.type==="rack").map(P=>P),R=yo(u),W=Go(R,H)?.id??null;ho(P=>P===W?P:W);},[y,yo,Oe]),ea=useCallback((n,u,h)=>{ho(null);let g=Oe(u);if(!y||!We(u)||g)return;let H=it(u),R=Xe.current.filter(he=>he.type==="rack").map(he=>he),I=yo(u),W=Go(I,R),P=Xe.current;if(!W)return;let K={x:H.x-W.position.x,y:H.y-W.position.y},se=P.find(he=>he.id===u.id)||u,ke={...se,parentId:W.id,extent:"parent",position:{x:0,y:K.y},data:{...se.data}},Re=P.filter(he=>he.id!==u.id).concat(ke),ve=Co(ke,W,ke.position,Re),Ue=P.map(he=>he.id!==u.id?he:{...he,parentId:W.id,extent:"parent",position:{x:ve.x,y:ve.y},data:{...he.data,uPosition:ve.uPosition??he.data.uPosition}});mo(Ue);},[y,it,yo,mo,Oe]),ta=useCallback(n=>{if(!n.source||!n.target||!n.sourceHandle||!n.targetHandle)return true;let u=pe(n.source),h=pe(n.target),g=te(u,n.sourceHandle),H=te(h,n.targetHandle),R=Y.current.some(G=>G.source===n.source?te(u,G.sourceHandle)===g:G.target===n.source?te(u,G.targetHandle)===g:false),I=Y.current.some(G=>G.target===n.target?te(h,G.targetHandle)===H:G.source===n.target?te(h,G.sourceHandle)===H:false);if(R&&s&&console.log("Connection will replace: Source handle already connected",{source:n.source,sourceHandle:n.sourceHandle,existingEdges:Y.current.filter(G=>G.source===n.source&&G.sourceHandle===n.sourceHandle||G.target===n.source&&G.targetHandle===n.sourceHandle)}),I&&s&&console.log("Connection will replace: Target handle already connected",{target:n.target,targetHandle:n.targetHandle,existingEdges:Y.current.filter(G=>G.target===n.target&&G.targetHandle===n.targetHandle||G.source===n.target&&G.sourceHandle===n.targetHandle)}),!Uo(u,h))return true;if(u?.type==="splice"&&h?.type==="splice"){let G=u.data?.mode==="ribbon",ge=h.data?.mode==="ribbon";if(G!==ge)return s&&console.log("Connection rejected: Ribbon splices can only connect to other ribbon splices",n),false}let P=(G,ge)=>(G?.type==="tube"||G?.type==="cable")&&!!ge&&ge.startsWith("fiber-"),K=(G,ge)=>(G?.type==="tube"||G?.type==="multi-tube-cable")&&!!ge&&ge.startsWith("tube-"),se=(G,ge)=>G?.type==="multi-tube-cable"&&!!ge&&ge.startsWith("tube-"),ke=(G,ge)=>G?.type==="tube"&&!!ge&&ge.startsWith("tube-"),Re=(G,ge)=>(G?.type==="cable"||G?.type==="multi-tube-cable")&&ge==="cable-button",ve=(G,ge)=>G?.type==="splice"&&(ge==="left"||ge==="right"),Ue=(G,ge)=>G?.type==="coupler"&&!!ge&&(ge.startsWith("left-")||ge.startsWith("right-")),he=(G,ge)=>{if(G?.type!=="fibre-split"||!ge)return false;let N=ge.replace(/-(source|target)$/i,"");return N.startsWith("input-")||N.startsWith("output-")},_e=P(u,n.sourceHandle),Ve=P(h,n.targetHandle),Le=ve(u,n.sourceHandle),Ce=ve(h,n.targetHandle),Je=Ue(u,n.sourceHandle),Z=Ue(h,n.targetHandle),He=he(u,n.sourceHandle),de=he(h,n.targetHandle),wo=Re(u,n.sourceHandle),ir=Re(h,n.targetHandle),Dt=se(u,n.sourceHandle),Ft=se(h,n.targetHandle),ar=ke(u,n.sourceHandle),sr=ke(h,n.targetHandle),No=K(u,n.sourceHandle),dr=K(h,n.targetHandle);return _e&&Ce||Ve&&Le||(Le&&(Z||de)||Ce&&(Je||He))||(Je&&(Z||de||Ce)||Z&&(Je||He||Le))||wo&&ir||(Dt&&sr||Ft&&ar)?true:No&&dr?(s&&console.log("Connection rejected: Tube handles can only connect between cable and tube nodes",n),false):(s&&console.log("Connection rejected: Connection not allowed by fiber rules",n),false)},[pe,s]),oa=useCallback(n=>{if(xe)return;s&&console.log("onConnect called:",n);let u=pe(n.source),h=pe(n.target);s&&(console.log("onConnect: sourceNode type:",u?.type,"targetNode type:",h?.type),console.log("onConnect: sourceHandle:",n.sourceHandle,"targetHandle:",n.targetHandle));let g=Si(n,u,h),H=j.validateConnection({source:g.source??null,target:g.target??null,sourceHandle:g.sourceHandle,targetHandle:g.targetHandle});if(!H.valid&&!(H.reason??"").includes("already connected")){s&&console.warn(`Connection rejected: ${H.reason}`);return}let R=u?.type==="vertical-pdu",I=u?.type==="vertical-pdu"||h?.type==="vertical-pdu",W=Et(u,g.sourceHandle),P=Et(h,g.targetHandle),K=W&&P&&I,se=u?.data,ke=u?.type==="switch"||u?.type==="device"&&se?.deviceType==="switch",Re=P,ve=!!g.targetHandle&&(g.targetHandle.startsWith("net-")||g.targetHandle.startsWith("port-")||/^[A-Z0-9]+-\d+$/i.test(Te(g.targetHandle))),Ue=!!g.sourceHandle&&(g.sourceHandle.startsWith("net-")||g.sourceHandle.startsWith("port-")||/^[A-Z0-9]+-\d+$/i.test(Te(g.sourceHandle))),he=h?.type==="switch"||h?.type==="device"&&h.data?.deviceType==="switch",_e=h?.type==="vertical-pdu",Ve=W,Le=u?.type==="tube"&&h?.type==="multi-tube-cable",Ce=u?.type==="multi-tube-cable"&&h?.type==="tube",Je=Le||Ce,Z=g.sourceHandle==="cable-button"&&g.targetHandle==="cable-button",He="fiber";K?He="power":Z?He="thick-cable":Je&&(He=ee?"smoothstep":"fiber");let de,wo=Ci(h),ir=Ci(u);if(wo||ir){let N=h?.data,V=u?.data,me=wo?N.ribbonFiberIds:V.ribbonFiberIds;me&&Array.isArray(me)&&me.length>=6&&me.length<=12&&(de={ribbonFiberIds:me,isRibbon:true});}if(!de&&(He==="fiber"||He==="smoothstep")&&!R){let N;Le?N=Xt(g.target,g.targetHandle):N=Xt(g.source,g.sourceHandle),N&&(de={color:N.color,striped:N.striped,isRibbon:false});}else if(He==="thick-cable"&&Z){let N=u?.data;de={color:N?.color||(N?.tubeStartIndex?De(N.tubeStartIndex):"#6366f1")};}let Dt=te(u,g.sourceHandle),Ft=te(h,g.targetHandle),ar=Y.current.some(N=>N.source===g.source?te(u,N.sourceHandle)===Dt:N.target===g.source?te(u,N.targetHandle)===Dt:false),sr=Y.current.some(N=>N.target===g.target?te(h,N.targetHandle)===Ft:N.source===g.target?te(h,N.sourceHandle)===Ft:false);if(ar||sr){let N=new Set;for(let V of Y.current){if(V.source===g.source&&te(u,V.sourceHandle)===Dt){N.add(V.id);continue}if(V.target===g.source&&te(u,V.targetHandle)===Dt){N.add(V.id);continue}if(V.source===g.target&&te(h,V.sourceHandle)===Ft){N.add(V.id);continue}V.target===g.target&&te(h,V.targetHandle)===Ft&&N.add(V.id);}if(N.size>0){let V=Y.current.filter(Ye=>!N.has(Ye.id)),me=addEdge(g,V);if(me.length===V.length)s&&console.warn("Handle replacement skipped: addEdge did not create a new edge",g);else {let Ye=me[me.length-1],at=ue({...g,id:Ye.id,type:He}),bt={...Ye,type:He,zIndex:at,style:{...Ye.style,zIndex:at},data:de!==void 0?de:Ye.data};we([...me.slice(0,-1),bt]),s&&console.log("Handle replacement: Replaced",N.size,"edge(s)");return}}}if(h?.type==="splice"&&(n.targetHandle==="left"||n.targetHandle==="right")&&n.target&&n.targetHandle){let N=Y.current.find(V=>V.target===n.target&&V.targetHandle===n.targetHandle||V.source===n.target&&V.sourceHandle===n.targetHandle);if(N){s&&(console.log("Splice target handle replacement: Found existing edge",N.id,"on splice handle",n.targetHandle),console.log("Existing edge details:",{id:N.id,source:N.source,target:N.target,sourceHandle:N.sourceHandle,targetHandle:N.targetHandle,data:N.data}));let V=n.source&&n.sourceHandle?Y.current.find(Qe=>Qe.source===n.source&&Qe.sourceHandle===n.sourceHandle):null;s&&V&&console.log("Splice target handle replacement: Also found existing source edge",V.id);let me=new Set;N&&me.add(N.id),V&&V.id!==N.id&&me.add(V.id);let Ye=Y.current.filter(Qe=>!me.has(Qe.id));s&&console.log("Splice target handle replacement: Removing",me.size,"edge(s), creating new connection");let at=`edge-${n.source}-${n.sourceHandle}-${n.target}-${n.targetHandle}-${Date.now()}`,bt=ue({...n,id:at,type:"fiber"}),Kt={id:at,source:n.source,target:n.target,sourceHandle:n.sourceHandle,targetHandle:n.targetHandle,type:"fiber",zIndex:bt,style:{zIndex:bt},data:de!==void 0?de:{}},cr=[...Ye,Kt];we(cr),s&&console.log("Splice target handle replacement: Successfully replaced edge with new edge",Kt.id);return}}if(u?.type==="splice"&&n.sourceHandle==="right"&&n.source&&n.sourceHandle){let N=Y.current.find(V=>V.source===n.source&&V.sourceHandle===n.sourceHandle||V.target===n.source&&V.targetHandle===n.sourceHandle);if(N){s&&console.log("Splice source handle replacement: Found existing edge",N.id,"on splice handle",n.sourceHandle);let V=n.target&&n.targetHandle?Y.current.find(Qe=>Qe.target===n.target&&Qe.targetHandle===n.targetHandle):null;s&&V&&console.log("Splice source handle replacement: Also found existing target edge",V.id);let me=new Set;N&&me.add(N.id),V&&V.id!==N.id&&me.add(V.id);let Ye=Y.current.filter(Qe=>!me.has(Qe.id));s&&console.log("Splice source handle replacement: Removing",me.size,"edge(s), creating new connection");let at=`edge-${n.source}-${n.sourceHandle}-${n.target}-${n.targetHandle}-${Date.now()}`,bt=ue({...n,id:at,type:"fiber"}),Kt={id:at,source:n.source,target:n.target,sourceHandle:n.sourceHandle,targetHandle:n.targetHandle,type:"fiber",zIndex:bt,style:{zIndex:bt},data:de!==void 0?de:{}},cr=[...Ye,Kt];we(cr),s&&console.log("Splice source handle replacement: Successfully replaced edge with new edge",Kt.id);return}}if((u?.type==="tube"||u?.type==="cable")&&n.sourceHandle?.startsWith("fiber-")&&n.source&&n.sourceHandle){let N=Pe({edges:Y.current,connection:g,edgeType:"fiber",selectEdgeZIndex:ue,findBy:"source",data:de});if(N){we(N);return}}if((h?.type==="tube"||h?.type==="cable")&&n.targetHandle?.startsWith("fiber-")&&n.target&&n.targetHandle){let N=Pe({edges:Y.current,connection:g,edgeType:"fiber",selectEdgeZIndex:ue,findBy:"target",data:de});if(N){we(N);return}}if((u?.type==="multi-tube-cable"||u?.type==="tube")&&n.sourceHandle?.startsWith("tube-")&&n.source&&n.sourceHandle){let N=Pe({edges:Y.current,connection:g,edgeType:He,selectEdgeZIndex:ue,findBy:"source",data:de});if(N){we(N);return}}if((h?.type==="multi-tube-cable"||h?.type==="tube")&&n.targetHandle?.startsWith("tube-")&&n.target&&n.targetHandle){let N=Pe({edges:Y.current,connection:g,edgeType:He,selectEdgeZIndex:ue,findBy:"target",data:de});if(N){we(N);return}}if(u?.type==="coupler"&&(n.sourceHandle?.startsWith("left-")||n.sourceHandle?.startsWith("right-"))){let N=Pe({edges:Y.current,connection:g,edgeType:"fiber",selectEdgeZIndex:ue,findBy:"source",data:de});if(N){we(N);return}}if(h?.type==="coupler"&&(n.targetHandle?.startsWith("left-")||n.targetHandle?.startsWith("right-"))){let N=Pe({edges:Y.current,connection:g,edgeType:"fiber",selectEdgeZIndex:ue,findBy:"target",data:de});if(N){we(N);return}}if(Z&&n.source&&n.sourceHandle&&n.target&&n.targetHandle){let N=u?.data,V=N?.color||(N?.tubeStartIndex?De(N.tubeStartIndex):"#6366f1"),me=Pe({edges:Y.current,connection:g,edgeType:"thick-cable",selectEdgeZIndex:ue,findBy:"source",data:{color:V}});if(me){we(me);return}if(me=Pe({edges:Y.current,connection:g,edgeType:"thick-cable",selectEdgeZIndex:ue,findBy:"target",data:{color:V}}),me){we(me);return}}if(R&&Re&&n.target&&n.targetHandle){let N=Pe({edges:Y.current,connection:g,edgeType:"power",selectEdgeZIndex:ue,findBy:"target",data:de});if(N){we(N);return}}if(_e&&Ve&&n.source&&n.sourceHandle&&n.target&&n.targetHandle){let N=Pe({edges:Y.current,connection:g,edgeType:"power",selectEdgeZIndex:ue,findBy:"source",matchOn:"target",data:de});if(N){we(N);return}}if(ke&&ve&&n.target&&n.targetHandle){let N=Pe({edges:Y.current,connection:g,edgeType:"fiber",selectEdgeZIndex:ue,findBy:"target",data:de});if(N){we(N);return}}if(he&&Ue&&n.source&&n.sourceHandle&&n.target&&n.targetHandle){let N=Pe({edges:Y.current,connection:g,edgeType:"fiber",selectEdgeZIndex:ue,findBy:"target",matchOn:"source",data:de});if(N){we(N);return}}let No=j.validateConnection({source:g.source??null,target:g.target??null,sourceHandle:g.sourceHandle,targetHandle:g.targetHandle});if(!No.valid){if(R&&n.source&&n.sourceHandle){let N=Pe({edges:Y.current,connection:g,edgeType:Re?"power":"fiber",selectEdgeZIndex:ue,findBy:"source",data:de});if(N){we(N);return}}if(_e&&n.source&&n.sourceHandle){let N=Pe({edges:Y.current,connection:g,edgeType:"power",selectEdgeZIndex:ue,findBy:"source",matchOn:"target",data:de});if(N){we(N);return}}if(ke&&n.source&&n.sourceHandle){let N=Pe({edges:Y.current,connection:g,edgeType:"fiber",selectEdgeZIndex:ue,findBy:"source",data:de});if(N){we(N);return}}if(he&&n.target&&n.targetHandle){let N=Pe({edges:Y.current,connection:g,edgeType:"fiber",selectEdgeZIndex:ue,findBy:"target",matchOn:"source",data:de});if(N){we(N);return}}s&&console.warn(`Connection rejected: ${No.reason}`);return}let dr=Y.current.some(N=>N.source===g.source&&N.sourceHandle===g.sourceHandle||N.target===g.source&&N.targetHandle===g.sourceHandle),vn=Y.current.some(N=>N.target===g.target&&N.targetHandle===g.targetHandle||N.source===g.target&&N.sourceHandle===g.targetHandle),lr=(N,V)=>!N||!V?false:!!(N.startsWith("tube-")||V.type==="splice"&&(N==="left"||N==="right")||N==="cable-button"),Cn=lr(g.sourceHandle||"",u),Hn=lr(g.targetHandle||"",h);if(dr&&!Cn){s&&console.warn("FINAL SAFETY CHECK: Source handle already connected, rejecting duplicate connection",{source:n.source,sourceHandle:g.sourceHandle,existingEdges:Y.current.filter(N=>N.source===g.source&&N.sourceHandle===g.sourceHandle||N.target===g.source&&N.targetHandle===g.sourceHandle)});return}if(vn&&!Hn){s&&console.warn("FINAL SAFETY CHECK: Target handle already connected, rejecting duplicate connection",{target:g.target,targetHandle:g.targetHandle,existingEdges:Y.current.filter(N=>N.target===g.target&&N.targetHandle===g.targetHandle||N.source===g.target&&N.sourceHandle===g.targetHandle)});return}let Pn={...g,type:He,zIndex:ue({...g,id:"temp-id"}),data:de},G=addEdge(Pn,Y.current),ge=G[G.length-1];ge&&(kn(N=>new Set(N).add(ge.id)),setTimeout(()=>{kn(N=>{let V=new Set(N);return V.delete(ge.id),V});},1e3)),we(G);},[we,j,ue,pe,s,Xt,ee,xe]),ra=useCallback((n,u)=>{if(xe||!u.source||!u.target||!u.sourceHandle||!u.targetHandle)return;let h=pe(u.source),g=pe(u.target),H=Si(u,h,g),R=te(h,H.sourceHandle),I=te(g,H.targetHandle),W=Y.current.some(Z=>{if(Z.id===n.id)return false;let He=Z.source===H.source&&te(h,Z.sourceHandle)===R||Z.target===H.source&&te(h,Z.targetHandle)===R,de=Z.target===H.target&&te(g,Z.targetHandle)===I||Z.source===H.target&&te(g,Z.sourceHandle)===I;return He||de}),P=j.validateConnection({source:H.source??null,target:H.target??null,sourceHandle:H.sourceHandle,targetHandle:H.targetHandle,ignoreEdgeId:n.id});if(!P.valid&&!((P.reason??"").includes("already connected")&&W)){s&&console.warn(`Edge update rejected: ${P.reason}`);return}let K=h?.type==="vertical-pdu"||g?.type==="vertical-pdu",se=Et(h,H.sourceHandle),ke=Et(g,H.targetHandle),Re=se&&ke&&K,ve=h?.type==="tube"&&g?.type==="multi-tube-cable",Ue=h?.type==="multi-tube-cable"&&g?.type==="tube",he=ve||Ue,_e;Re?_e="power":he?_e=ee?"smoothstep":"fiber":_e="fiber";let Ve;if(_e==="fiber"||_e==="smoothstep"){let Z=Xt(H.source,H.sourceHandle);Z&&(Ve={color:Z.color,striped:Z.striped});}let Je=Y.current.filter(Z=>{if(Z.id===n.id)return true;let He=Z.source===H.source&&te(h,Z.sourceHandle)===R||Z.target===H.source&&te(h,Z.targetHandle)===R,de=Z.target===H.target&&te(g,Z.targetHandle)===I||Z.source===H.target&&te(g,Z.sourceHandle)===I;return !(He||de)}).map(Z=>Z.id===n.id?{...Z,source:H.source,target:H.target,sourceHandle:H.sourceHandle,targetHandle:H.targetHandle,type:_e,data:Ve!==void 0?{...Z.data,...Ve}:Z.data,zIndex:ue({...H,id:Z.id,type:_e}),style:{...Z.style,zIndex:ue({...H,id:Z.id,type:_e})}}:Z);we(Je);},[we,pe,Xt,ue,ee,s,j,xe]),na=useCallback((n,u)=>{if(Ae){l&&l(u);return}let h=n.metaKey||n.ctrlKey,g=gt(),H=u,R=Oe(u);if(u.type==="tube"&&R&&!h){let I=g.find(W=>W.id===R&&(W.type==="cable"||W.type==="multi-tube-cable"));I&&(H=I);}if(or(H),Yt([]),ce(I=>I.map(W=>{let P=W.id===H.id;return W.selected===P?W:{...W,selected:P}})),h&&We(H)){let I=H.data||{},W=I.view||(Array.isArray(I.rearPorts)&&I.rearPorts.length>0?"rear":"front"),P=W==="front"?"rear":"front";s&&console.log(`Command+click: Toggling device ${H.id} from ${W} to ${P}`),C&&C(H.id,P);}l&&l(H);},[C,l,s,gt,ce,Ae,Oe]),ia=useCallback(()=>{},[]),aa=useCallback((n,u)=>{or(null),Yt([u]),ce(h=>h.map(g=>g.selected?{...g,selected:false}:g)),l?.(null),p&&p(u);},[p,l,ce]),sa=useCallback(()=>{or(null),Yt([]),ce(n=>n.map(u=>u.selected?{...u,selected:false}:u)),l?.(null);},[l,ce]),[Be,or]=useState(null),[xn,kn]=useState(new Set);useOnSelectionChange({onChange:({edges:n})=>{Yt(n||[]);}});let[rr,Yt]=useState([]);useEffect(()=>{let n=u=>{if(Ie.allowKeyboardDelete&&(u.key==="Backspace"||u.key==="Delete")&&rr.length>0){if(document.activeElement?.tagName==="INPUT"||document.activeElement?.tagName==="TEXTAREA")return;let h=rr.filter(g=>{let H=g.sourceHandle||"",R=g.targetHandle||"";return H.startsWith("tube-")||R.startsWith("tube-")?(s&&console.log("Cannot delete edge connected to tube handle",g),false):true});if(h.length>0){let g=new Set(h.map(R=>R.id)),H=Y.current.filter(R=>!g.has(R.id));we(H),Yt([]),s&&console.log("Deleted edges:",h.map(R=>R.id));}}};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[rr,we,s,Ie.allowKeyboardDelete]);let da=useCallback((n,{nodeId:u,handleType:h})=>{s&&console.log("Connection started from",{nodeId:u,handleType:h});},[s]),la=useCallback(n=>{s&&console.log("Connection ended",n);},[s]),ca=useCallback(()=>{if(xe||!Be)return;let n=pe(Be.id);if(n){if(n.type==="rack"){let g=((n.data||{}).face||"front")==="front"?"rear":"front";v?(v(n.id,g),C&>().filter(R=>R.parentId===n.id).forEach(R=>{C(R.id,g);})):ce(H=>H.map(R=>R.id===n.id?{...R,data:{...R.data,face:g}}:R.parentId===n.id?{...R,data:{...R.data,view:g}}:R));return}if(We(n)){let u=n.data||{},h=Array.isArray(u.rearPorts)&&u.rearPorts.length>0,g=Array.isArray(u.ports)&&u.ports.length>0,R=(u.view||(h&&!g?"rear":"front"))==="front"?"rear":"front";C?C(n.id,R):ce(I=>I.map(W=>W.id===n.id?{...W,data:{...W.data,view:R}}:W));}}},[Be,pe,v,C,ce,gt,xe]),ua=useCallback(()=>{if(xe||!y||!Be||!We(Be))return;let n=pe(Be.id),u=Oe(n);if(!n||!We(n)||!u)return;let h=it(n),H=Xe.current.map(R=>R.id!==n.id?R:{...R,parentId:void 0,parentNode:void 0,extent:void 0,position:h,data:{...R.data,uPosition:void 0}});mo(H);},[xe,y,Be,pe,it,mo,Oe]),pa=useMemo(()=>{let n=Gt.current;return qe.map(u=>{let h=u,g=n.get(String(h.source)),H=n.get(String(h.target)),R=jo(h.sourceHandle||"",g),I=jo(h.targetHandle||"",H),W=Le=>{if(!Le||!We(Le))return;let Ce=Le.data??{},Je=Array.isArray(Ce.rearPorts)&&Ce.rearPorts.length>0,Z=Array.isArray(Ce.ports)&&Ce.ports.length>0;return Ce.view||(Je&&!Z?"rear":"front")},P=W(g),K=W(H),se=tr(g),ke=tr(H),Re=We(g)&&!se&&!!P&&!!R&&R!==P,ve=We(H)&&!ke&&!!K&&!!I&&I!==K,_e=Re||ve,Ve=u.style;if(_e)Ve={...u.style,opacity:0,pointerEvents:"none",zIndex:0};else if(u.style&&u.style.opacity===0&&u.style.pointerEvents==="none"&&u.style.zIndex===0){let Ce={...u.style};delete Ce.opacity,delete Ce.pointerEvents,delete Ce.zIndex,Ve=Object.keys(Ce).length>0?Ce:void 0;}return {...u,style:Ve,className:xn.has(u.id)?"edge-connecting":u.className}})},[qe,xn,tr]),Ee=useMemo(()=>Be?pe(Be.id)??Be:null,[Be,pe]),It=useMemo(()=>{if(!Ee||!bo.enabled||xe)return {showRearToggle:false,showDeRack:false,count:0};let n=Ee.type==="rack"||We(Ee),u=bo.showRearToggle&&n,h=bo.showDeRack&&y&&!xe&&We(Ee)&&!!Oe(Ee);return {showRearToggle:u,showDeRack:h,count:(u?1:0)+(h?1:0)}},[Ee,bo,y,xe,Oe]),nr=useMemo(()=>{if(!Ee||It.count===0||!$e.current)return null;let n=$e.current.getBoundingClientRect();if(n.width<=0||n.height<=0)return null;let u=Ee.positionAbsolute??it(Ee),h=Ee.width||0,g=Ee.height||0,H=It.count>1?220:110,R=34;try{let I=qo({x:u.x+h/2,y:u.y}),W=qo({x:u.x+h/2,y:u.y+g}),P=I.x-n.left-H/2,K=I.y-n.top-R-10;return K<8&&(K=W.y-n.top+10),P=Math.max(8,Math.min(P,n.width-H-8)),K=Math.max(8,Math.min(K,n.height-R-8)),{left:P,top:K}}catch{return null}},[Ee,It,it,qo]),ga=En(w,T),fa=Tn(w,{touchAction:"none",...E});return jsxs("div",{ref:$e,className:ga,style:fa,children:[jsxs(ReactFlow,{nodes:ye,edges:pa,onNodesChange:n=>{if(xe)return;let u=qi(n);u&&(M?i&&i(u):j.setState({nodes:u}));},onEdgesChange:n=>{if(xe)return;let u=n.filter(h=>{if(h.type==="remove"){let g=Y.current.find(H=>H.id===h.id);if(g){let H=g.sourceHandle||"",R=g.targetHandle||"";if(H.startsWith("tube-")||R.startsWith("tube-"))return s&&console.log("Edge deletion blocked: Edge connected to tube handle is not detachable",g),false}}return true});if(u.length>0){let h=applyEdgeChanges(u,Y.current);jt(u),M?a&&a(h):j.setState({edges:h});}},onConnect:xe?void 0:c??oa,onConnectStart:da,onConnectEnd:la,onEdgeUpdate:xe?void 0:b??ra,isValidConnection:x??ta,connectionMode:k,onNodeClick:na,onNodeDoubleClick:ia,onPaneClick:sa,onNodeDragStart:Ji,onNodeDrag:Qi,onNodeDragStop:ea,onEdgeClick:aa,onInit:_,nodeTypes:wn.current,edgeTypes:Zi,defaultEdgeOptions:{zIndex:1e3,reconnectable:Ie.edgesReconnectable},nodesDraggable:Ie.nodesDraggable,nodesConnectable:Ie.nodesConnectable,elementsSelectable:Ie.elementsSelectable,edgesFocusable:Ie.edgesFocusable,elevateNodesOnSelect:false,selectNodesOnDrag:false,connectOnClick:Ie.connectOnClick,panOnDrag:Ie.panOnDrag,panOnScroll:Ie.panOnScroll,zoomOnScroll:Ie.zoomOnScroll,zoomOnPinch:Ie.zoomOnPinch,zoomOnDoubleClick:Ie.zoomOnDoubleClick,preventScrolling:Ae,onlyRenderVisibleElements:true,fitView:true,fitViewOptions:J,proOptions:{hideAttribution:true},children:[jsx(Background,{color:Rn(w)}),Ie.showControls&&jsx(Controls,{showInteractive:Ie.showInteractiveControl}),Ie.showMiniMap&&jsx(MiniMap,{}),jsx(Panel,{position:"bottom-right",className:"react-networks-attribution",children:jsx("a",{href:"https://github.com/MP70/react-networks",target:"_blank",rel:"noopener noreferrer",className:"react-networks-attribution-link",children:"react-networks"})})]}),D&&jsx("button",{className:"download-button",onClick:Ki,disabled:ft,"aria-busy":ft,style:{position:"absolute",top:A.includes("top")?"10px":"auto",bottom:A.includes("bottom")?"10px":"auto",right:A.includes("right")?"10px":"auto",left:A.includes("left")?"10px":"auto",zIndex:1e3,background:"#374151",color:"#e5e7eb",border:"1px solid #4b5563",borderRadius:"4px",padding:"0.5rem 0.75rem",fontSize:"0.875rem",cursor:ft?"not-allowed":"pointer",opacity:ft?.7:1,transition:"all 0.2s ease",...le},children:ft?`${U}...`:U}),Ee&&nr&&It.count>0&&jsxs("div",{style:{position:"absolute",top:nr.top,left:nr.left,display:"flex",gap:8,zIndex:2e3},children:[It.showRearToggle&&jsx("button",{onClick:n=>{n.preventDefault(),ca();},style:{background:"#374151",color:"#e5e7eb",border:"1px solid #4b5563",borderRadius:4,padding:"6px 10px",fontSize:11,fontFamily:"monospace",cursor:"pointer"},title:(()=>{let n=Ee.data;if(Ee.type==="rack")return (n?.face||"front")==="front"?"Switch to rear":"Switch to front";{let u=Array.isArray(n?.rearPorts)&&n.rearPorts.length>0,h=Array.isArray(n?.ports)&&n.ports.length>0;return (n?.view||(u&&!h?"rear":"front"))==="front"?"Switch to rear":"Switch to front"}})(),children:(()=>{let n=Ee.data;if(Ee.type==="rack")return (n?.face||"front")==="front"?"\u21C4 Rear":"\u21C4 Front";{let u=Array.isArray(n?.rearPorts)&&n.rearPorts.length>0,h=Array.isArray(n?.ports)&&n.ports.length>0;return (n?.view||(u&&!h?"rear":"front"))==="front"?"\u21C4 Rear":"\u21C4 Front"}})()}),It.showDeRack&&jsx("button",{onClick:n=>{n.preventDefault(),ua();},style:{background:"#7f1d1d",color:"#fee2e2",border:"1px solid #b91c1c",borderRadius:4,padding:"6px 10px",fontSize:11,fontFamily:"monospace",cursor:"pointer"},title:"Remove device from rack so it can be moved/reassigned",children:"De-rack"})]})]})},on=e=>jsx(ReactFlowProvider,{children:jsx(Zs,{...e})});var rn=class extends Component{constructor(){super(...arguments);this.state={error:null};this.reset=()=>{this.setState({error:null});};}static getDerivedStateFromError(o){return {error:o}}componentDidCatch(o,r){this.props.onError?.(o,r);}render(){let{error:o}=this.state,{children:r,fallback:i}=this.props;return o?typeof i=="function"?i(o,this.reset):i??jsxs("div",{role:"alert",style:{padding:16,margin:8,border:"1px solid #e53e3e",borderRadius:4,backgroundColor:"#fff5f5",color:"#c53030"},children:[jsx("strong",{children:"Diagram error"}),": ",o.message,jsx("button",{type:"button",onClick:this.reset,style:{marginLeft:12,padding:"4px 8px",cursor:"pointer"},children:"Try again"})]}):r}};function fo(e,{rowHeight:t,tubeGap:o}){let r=[],i=[],a=e.kind??(e.tubeCount?"tube":"simple"),d=a==="tube"?Math.max(1,Math.min(24,e.tubeCount??1)):1,s=a==="tube"?Math.max(1,Math.min(24,e.fibersPerTube??12)):Math.max(1,Math.min(24,e.fiberCount??12)),l=Math.max(1,e.tubeStartIndex??1),p=Math.max(1,e.fiberStartIndex??1),m=0;for(let f=0;f<d;f+=1){let c=l+f,b=e.tubeColorMap?.[c];i.push({tubeIndex:c,y:m,label:`T${c}`,color:b??De(c)});for(let x=0;x<s;x+=1){let k=p+x,C=fr(k);r.push({key:`${c}-${k}`,tubeIndex:a==="tube"?c:void 0,fiberIndex:k,y:m,color:wt(k),striped:yt(k),backgroundImage:typeof C.backgroundImage=="string"?C.backgroundImage:void 0}),m+=t;}f<d-1&&(m+=o);}return {rows:r,tubeLabels:i,height:m}}var nn=e=>typeof e=="object"&&e!==null,td=e=>{if(!nn(e.data))return false;if(e.type==="fibre-flow-cable"){let t=e.data;return typeof t.label=="string"&&nn(t.cable)&&(t.side==="left"||t.side==="right")&&typeof t.rowHeight=="number"&&typeof t.columnWidth=="number"&&typeof t.showTubeLabels=="boolean"&&typeof t.showFiberNumbers=="boolean"&&nn(t.layout)}if(e.type==="fibre-flow-closure"){let t=e.data;return typeof t.label=="string"&&typeof t.width=="number"&&typeof t.height=="number"&&typeof t.headerHeight=="number"}return false},od=e=>e==="fibre-flow"||e==="fibre-flow-link",rd=e=>typeof e.id=="string"&&e.id.length>0&&typeof e.source=="string"&&e.source.length>0&&typeof e.target=="string"&&e.target.length>0,nd=e=>e.sourceHandle==="cable-run"||e.targetHandle==="cable-run"?"fibre-flow-link":"fibre-flow",id=(e,t=[])=>{let o=new Map(t.map(i=>[i.id,i])),r=[];return e.forEach(i=>{if(!rd(i))return;let a=o.get(i.id),d=od(i.type)?i.type:a?.type??nd(i);r.push({...a??{},...i,type:d});}),r},Di=e=>`fiber-${e.tube??1}-${e.fiber}`,Fi=e=>wt(e.fiber),_i=e=>yt(e.fiber),ad=(e,t)=>{if(t)return t;if(!(typeof e!="number"||Number.isNaN(e)))return e>=1e3?`${(e/1e3).toFixed(1)} km`:`${Math.round(e)} m`},sd=(e,t,o,r,i,a)=>e?`${o} ${a}`:t?`0 ${i} ${r} ${a}`:"6 6",dd=({id:e,sourceX:t,sourceY:o,targetX:r,targetY:i,sourcePosition:a,targetPosition:d,data:s})=>{let[l,p,m]=getBezierPath({sourceX:t,sourceY:o,targetX:r,targetY:i,sourcePosition:a,targetPosition:d,curvature:.35}),f=typeof s?.lossDb=="number"?`${s.lossDb.toFixed(2)} dB`:"",c=s?.label??f,b=s?.sourceColor,x=s?.targetColor,k=s?.color??b??x??"#94a3b8",C=s?.sourceStriped??false,v=s?.targetStriped??false,T=s?.highlighted??true,E=s?.dimmed??false,F=s?.circuitId,y=s?.circuitLabel??F,w=s?.showCircuitId??false,_=b&&x&&b!==x,S=r-t,D=i-o,A=Math.sqrt(S*S+D*D),U=p-t,le=m-o,ee=Math.sqrt(U*U+le*le),re=A>0?ee/A*100:50,ne=`fibre-flow-gradient-${e}`,z=C&&!v,B=v&&!C,O=C&&v,L=A*1.25,X=L/2,J=12,$=Math.ceil(X*1.2/J),M=Array($).fill("6 6").join(" "),oe=Math.ceil(X*1.2/J),ie=Array(oe).fill("6 6").join(" "),Q=w&&y,j=Math.max(c?c.length*6.2+16:0,Q?(y?.length||0)*5.5+16:0),ae=Q?32:16;return jsxs(Fragment,{children:[jsx("defs",{children:_&&jsxs("linearGradient",{id:ne,x1:t,y1:o,x2:r,y2:i,gradientUnits:"userSpaceOnUse",children:[jsx("stop",{offset:"0%",stopColor:b}),jsx("stop",{offset:`${re}%`,stopColor:b}),jsx("stop",{offset:`${re}%`,stopColor:x}),jsx("stop",{offset:"100%",stopColor:x})]})}),_?jsx("path",{id:e,d:l,fill:"none",stroke:`url(#${ne})`,strokeWidth:T?4:3,strokeLinecap:"round",strokeLinejoin:"round",opacity:E?.25:1,strokeOpacity:E?.25:1,style:{mixBlendMode:"normal"}}):jsx(BaseEdge,{id:e,path:l,style:{stroke:k,strokeWidth:T?4:3,strokeLinecap:"round",strokeLinejoin:"round",opacity:E?.25:1,strokeOpacity:E?.25:1,mixBlendMode:"normal"}}),(O||z||B)&&jsx("path",{id:`${e}-stripe`,d:l,fill:"none",stroke:"#000",strokeWidth:T?1.6:1.3,strokeLinecap:"round",strokeLinejoin:"round",strokeDasharray:sd(z,B,M,ie,X,L),strokeDashoffset:0,opacity:E?.2:.9,style:{mixBlendMode:"normal"}}),(c||Q)&&T&&jsx(EdgeLabelRenderer,{children:jsxs("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${p}px, ${m}px)`,width:j,height:ae,background:"rgba(248, 250, 252, 0.92)",border:"1px solid rgba(15, 23, 42, 0.4)",borderRadius:4,fontSize:10,fontFamily:"monospace",color:"rgba(15, 23, 42, 0.9)",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",pointerEvents:"none",padding:"2px 4px",zIndex:9999},children:[c&&jsx("div",{style:{lineHeight:1.2},children:c}),Q&&jsx("div",{style:{fontSize:8,opacity:.8,lineHeight:1.2,marginTop:c?2:0},children:y})]})})]})},ld=({id:e,sourceX:t,sourceY:o,targetX:r,targetY:i,sourcePosition:a,targetPosition:d,data:s})=>{let[l,p,m]=getBezierPath({sourceX:t,sourceY:o,targetX:r,targetY:i,sourcePosition:a,targetPosition:d,curvature:.2}),f=s?.label,c=s?.color??"#64748b";return jsxs(Fragment,{children:[jsx(BaseEdge,{id:e,path:l,style:{stroke:c,strokeWidth:3,opacity:.85,strokeDasharray:"8 10"}}),f&&jsx(EdgeLabelRenderer,{children:jsx("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${p}px, ${m}px)`,padding:"2px 8px",background:"rgba(30, 41, 59, 0.9)",border:`1px solid ${c}`,borderRadius:10,fontSize:10,fontFamily:"monospace",color:"#e2e8f0",letterSpacing:.2,whiteSpace:"nowrap",pointerEvents:"none",zIndex:9999},children:f})})]})},cd=({data:e})=>{let{cable:t,side:o,rowHeight:r,columnWidth:i,showTubeLabels:a,showFiberNumbers:d,layout:s,colorMode:l="dark"}=e,p=l==="light",m=8,f=12,c=-1,b=0,x=t.jacketColor??"#facc15",k=(t.kind??(t.tubeCount?"tube":"simple"))==="tube",C=a&&k,v=o==="left"?m+b:b,T=o==="right"?m+b:b,E=o==="left"?Position.Right:Position.Left,F={width:4,height:4,borderRadius:"50%",background:x,border:`1px solid ${x}`,boxShadow:"0 0 1px rgba(0,0,0,0.4)",top:"50%",position:"absolute",...o==="left"?{left:0,transform:"translate(-50%, -50%)"}:{right:0,transform:"translate(50%, -50%)"}};return jsxs("div",{style:{position:"relative",width:i,height:s.height,fontFamily:"monospace",color:"inherit",overflow:"visible"},children:[jsx("div",{style:{position:"absolute",top:-18,left:o==="left"?0:void 0,right:o==="right"?0:void 0,fontSize:10,fontWeight:700,letterSpacing:.4,textTransform:"uppercase",background:p?"rgba(248, 250, 252, 0.95)":"rgba(15, 23, 42, 0.9)",color:p?"#1a1a1a":"#f8fafc",padding:"2px 6px",borderRadius:4,whiteSpace:"nowrap",maxWidth:i,overflow:"hidden",textOverflow:"ellipsis",zIndex:10,...o==="right"?{textAlign:"right"}:{}},children:t.label}),jsx("div",{style:{position:"absolute",top:0,bottom:0,width:m,left:o==="left"?0:void 0,right:o==="right"?0:void 0,borderRadius:4,background:k?"transparent":x,border:`1px solid ${x}`,boxShadow:k?"none":"inset 0 0 3px rgba(0,0,0,0.3)",overflow:"hidden"},children:k&&s.tubeLabels.map((y,w)=>{let _=s.rows.filter(ee=>ee.tubeIndex===y.tubeIndex);if(_.length===0)return null;let S=_[0].y,D=_[_.length-1].y+r,A=D-S,U=s.tubeLabels[w+1],le=U&&U.y-D>0;return jsx("div",{style:{position:"absolute",top:S,left:0,right:0,height:A,background:y.color,borderLeft:`2px solid ${y.color}`,borderRight:`2px solid ${y.color}`,borderTop:w===0?`2px solid ${y.color}`:"1px solid rgba(0,0,0,0.15)",borderBottom:le?"1px solid rgba(0,0,0,0.15)":`2px solid ${y.color}`,boxShadow:"inset 0 0 3px rgba(0,0,0,0.1)",borderRadius:w===0&&!le||w===0?"4px 4px 0 0":le?"0":"0 0 4px 4px",zIndex:2}},`tube-segment-${y.tubeIndex}`)})}),!C&&jsx("div",{style:{position:"absolute",top:0,bottom:0,left:v,right:T,...o==="left"?{borderRight:`1px solid ${x}`}:{borderLeft:`1px solid ${x}`},pointerEvents:"none",zIndex:0}}),k&&s.tubeLabels.map((y,w)=>{let _=s.rows.filter(U=>U.tubeIndex===y.tubeIndex);if(_.length===0)return null;let S=_[0].y,A=_[_.length-1].y+r-S;return jsx("div",{style:{position:"absolute",top:S,left:v,right:T,height:A,...o==="left"?{borderRight:`2px solid ${y.color}`}:{borderLeft:`2px solid ${y.color}`},opacity:.5,pointerEvents:"none"}},`tube-border-${y.tubeIndex}`)}),s.rows.map(y=>{let w=`fiber-${y.tubeIndex??1}-${y.fiberIndex}`,_=y.y+r/2,S={position:"absolute",width:f,height:f,borderRadius:"50%",top:_,background:y.backgroundImage?y.backgroundImage:y.color,backgroundColor:y.color,border:`2px solid ${y.color}`,boxShadow:"0 0 6px rgba(0,0,0,0.3)",...o==="left"?{right:-f/2}:{left:-f/2},transform:"translateY(-50%)",zIndex:1e3,cursor:"crosshair","--fiber-bg":y.color,minWidth:f,minHeight:f};y.backgroundImage&&(S["--fiber-bg-image"]=y.backgroundImage);let D=o==="left"?{right:f+c,textAlign:"right"}:{left:f+c,textAlign:"left"};return jsxs(lt.Fragment,{children:[jsx(Handle,{id:w,type:"source",position:E,className:"fibre-flow-handle",style:S,isConnectable:true,"data-fiber-idx":y.fiberIndex,"data-tube-idx":y.tubeIndex,"data-fiber-color":y.color}),jsx(Handle,{id:w,type:"target",position:E,className:"fibre-flow-handle",style:S,isConnectable:true,"data-fiber-idx":y.fiberIndex,"data-tube-idx":y.tubeIndex,"data-fiber-color":y.color}),d&&jsx("div",{style:{position:"absolute",top:y.y+r/2-6,...D,fontSize:8,fontWeight:600,color:p?"rgba(15, 23, 42, 0.7)":"rgba(148, 163, 184, 0.95)",whiteSpace:"nowrap",lineHeight:1},children:y.fiberIndex})]},y.key)}),jsx(Handle,{id:"cable-run",type:"source",position:o==="left"?Position.Left:Position.Right,className:"cable-run-handle",style:F,isConnectable:true,"data-handle-type":"cable-run"}),jsx(Handle,{id:"cable-run",type:"target",position:o==="left"?Position.Left:Position.Right,className:"cable-run-handle",style:F,isConnectable:true,"data-handle-type":"cable-run"})]})},ud=({data:e})=>{let t=e.colorMode==="light";return jsx("div",{style:{width:e.width,height:e.height,background:"transparent",border:t?"1px solid rgba(148, 163, 184, 0.3)":"1px solid rgba(148, 163, 184, 0.5)",borderRadius:12,boxShadow:t?"0 12px 24px rgba(0, 0, 0, 0.1)":"0 12px 24px rgba(15, 23, 42, 0.2)",position:"relative",pointerEvents:"none"},children:jsx("div",{style:{height:e.headerHeight,display:"flex",alignItems:"center",justifyContent:"center",fontFamily:"monospace",fontWeight:700,fontSize:12,letterSpacing:.6,textTransform:"uppercase",color:t?"rgba(15, 23, 42, 0.9)":"rgba(226, 232, 240, 0.9)",background:t?"rgba(241, 245, 249, 0.7)":"rgba(15, 23, 42, 0.6)",borderBottom:t?"1px solid rgba(148, 163, 184, 0.2)":"1px solid rgba(148, 163, 184, 0.35)",borderTopLeftRadius:12,borderTopRightRadius:12},children:e.label})})},pd=(e,t,o,r,i,a,d,s,l,p="dark")=>{let m=[],f=0;return e.forEach(c=>{let b=fo(c.leftCable,{rowHeight:o,tubeGap:r}),x=fo(c.rightCable,{rowHeight:o,tubeGap:r}),k=Math.max(b.height,x.height),C=a*2+d,v=32,T=16,E=C+T*2,F=k+v+T*2,y=`flow-closure-${c.id}`,w=`flow-cable-${c.id}-left`,_=`flow-cable-${c.id}-right`,S=t==="horizontal"?{x:f,y:0}:{x:0,y:f};f+=(t==="horizontal"?E:F)+i;let D=c.chamberId?`${c.id} - ${c.chamberId}`:c.id;m.push({id:y,type:"fibre-flow-closure",position:S,data:{label:D,width:E,height:F,headerHeight:v,colorMode:p},selectable:false,draggable:false,style:{width:E,height:F}});let A=v+T+(k-b.height)/2,U=v+T+(k-x.height)/2;m.push({id:w,type:"fibre-flow-cable",position:{x:T,y:A},parentId:y,extent:"parent",data:{label:c.leftCable.label,cable:c.leftCable,side:"left",rowHeight:o,columnWidth:a,showTubeLabels:s,showFiberNumbers:l,layout:b,colorMode:p},style:{width:a,height:b.height}}),m.push({id:_,type:"fibre-flow-cable",position:{x:T+C-a,y:U},parentId:y,extent:"parent",data:{label:c.rightCable.label,cable:c.rightCable,side:"right",rowHeight:o,columnWidth:a,showTubeLabels:s,showFiberNumbers:l,layout:x,colorMode:p},style:{width:a,height:x.height}});}),m},gd=(e,t,o,r=false)=>{let i=[],a=new Map,d=new Map,s=new Map;return (t??[]).forEach(l=>{l.color&&a.set(l.id,l.color),l.label&&d.set(l.id,l.label);}),e.forEach(l=>{let p=`flow-cable-${l.id}-left`,m=`flow-cable-${l.id}-right`;[{nodeId:p,cable:l.leftCable},{nodeId:m,cable:l.rightCable}].forEach(({nodeId:c,cable:b})=>{let x=s.get(b.id);if(x&&x.closureId!==l.id){let k=ad(b.distanceMeters??x.distanceMeters,b.distanceLabel??x.distanceLabel),C=b.jacketColor??x.jacketColor??"#64748b";i.push({id:`flow-link-${x.nodeId}-${c}`,type:"fibre-flow-link",source:x.nodeId,target:c,sourceHandle:"cable-run",targetHandle:"cable-run",data:{label:k,color:C}});}s.set(b.id,{nodeId:c,closureId:l.id,jacketColor:b.jacketColor,distanceLabel:b.distanceLabel,distanceMeters:b.distanceMeters});}),l.splices.forEach(c=>{let b=o?c.circuitId===o:true,x=!!o&&!b,k=c.circuitId?a.get(c.circuitId):void 0,C=c.circuitId?d.get(c.circuitId):void 0,v=c.color??k,T=Fi(c.from),E=Fi(c.to),F=_i(c.from),y=_i(c.to);i.push({id:`flow-edge-${l.id}-${c.id}`,type:"fibre-flow",source:p,target:m,sourceHandle:Di(c.from),targetHandle:Di(c.to),data:{lossDb:c.lossDb,label:c.label,color:v,sourceColor:T,targetColor:E,sourceStriped:F,targetStriped:y,highlighted:b,dimmed:x,circuitId:c.circuitId,circuitLabel:C,showCircuitId:r}});});}),i},fd=({closures:e,circuits:t,highlightedCircuitId:o,layout:r="horizontal",rowHeight:i=20,tubeGap:a=10,closureGap:d=140,cableColumnWidth:s=32,spliceAreaWidth:l=260,showTubeLabels:p=true,showFiberNumbers:m=true,colorMode:f="dark",showCircuitId:c=false,className:b,style:x,readOnly:k=false,panOnDrag:C=true,panOnScroll:v=true,zoomOnScroll:T=true})=>{let E=useMemo(()=>pd(e,r,i,a,d,s,l,p,m,f),[e,r,i,a,d,s,l,p,m,f]),F=useMemo(()=>gd(e,t,o,c),[e,t,o,c]),[y,w]=useState(E),[_,S]=useState(F);useEffect(()=>{w(E);},[E,w]),useEffect(()=>{S(F);},[F,S]);let D=useCallback((O,L)=>{if(!O||!L||!L.startsWith("fiber-"))return;let X=y.find(Q=>Q.id===O);if(!X||X.type!=="fibre-flow-cable")return;let J=/^fiber-(\d+)-(\d+)$/.exec(L);if(!J)return;let $=Number(J[1]),M=Number(J[2]),ie=X.data.layout.rows.find(Q=>(Q.tubeIndex??1)===$&&Q.fiberIndex===M);if(ie)return {color:ie.color,striped:ie.striped??false}},[y]),A=useCallback(O=>{if(k||!O.source||!O.target||!O.sourceHandle||!O.targetHandle)return false;let L=y.find(oe=>oe.id===O.source),X=y.find(oe=>oe.id===O.target);if(!L||!X)return false;let J=typeof O.sourceHandle=="string"&&O.sourceHandle.startsWith("fiber-"),$=typeof O.targetHandle=="string"&&O.targetHandle.startsWith("fiber-");return O.sourceHandle==="cable-run"||O.targetHandle==="cable-run"?true:J&&$?L.type==="fibre-flow-cable"&&X.type==="fibre-flow-cable":false},[y,k]),U=useCallback(O=>{if(k)return;let L=O.sourceHandle==="cable-run"||O.targetHandle==="cable-run",X=j=>typeof j=="string"&&j.startsWith("fiber-"),J=X(O.sourceHandle),$=X(O.targetHandle),M=(j,ae,Ne)=>j.source===ae&&j.sourceHandle===Ne||j.target===ae&&j.targetHandle===Ne,oe=L?void 0:D(O.source,O.sourceHandle),ie=L?void 0:D(O.target,O.targetHandle),Q=L?void 0:{sourceColor:oe?.color,targetColor:ie?.color,color:oe?.color??ie?.color,sourceStriped:oe?.striped,targetStriped:ie?.striped};S(j=>{let ae=j.filter(Ne=>{let ye=J&&M(Ne,O.source,O.sourceHandle),ce=$&&M(Ne,O.target,O.targetHandle);return !(ye||ce)});return addEdge({...O,type:L?"fibre-flow-link":"fibre-flow",data:Q},ae)});},[D,k,S]),le=useCallback((O,L)=>{if(k)return;let X=L.sourceHandle==="cable-run"||L.targetHandle==="cable-run",J=X?void 0:D(L.source,L.sourceHandle),$=X?void 0:D(L.target,L.targetHandle),M=X?void 0:{sourceColor:J?.color,targetColor:$?.color,color:J?.color??$?.color,sourceStriped:J?.striped,targetStriped:$?.striped},oe=Q=>typeof Q=="string"&&Q.startsWith("fiber-"),ie=(Q,j,ae)=>Q.source===j&&Q.sourceHandle===ae||Q.target===j&&Q.targetHandle===ae;S(Q=>{let j=Q.filter(ce=>ce.id!==O.id),ae=oe(L.sourceHandle),Ne=oe(L.targetHandle),ye=j.filter(ce=>{let qe=ae&&ie(ce,L.source,L.sourceHandle),Ge=Ne&&ie(ce,L.target,L.targetHandle);return !(qe||Ge)});return addEdge({...L,type:X?"fibre-flow-link":"fibre-flow",data:M},ye)});},[D,k,S]),ee=useCallback(O=>{k||w(O.filter(td));},[k,w]),re=useCallback(O=>{k||S(L=>id(O,L));},[k,S]),ne=useMemo(()=>({"fibre-flow-cable":cd,"fibre-flow-closure":ud}),[]),z=useMemo(()=>({"fibre-flow":dd,"fibre-flow-link":ld}),[]),B={borderRadius:8,overflow:"hidden",...x};return jsx(on,{nodes:y,edges:_,onNodesChange:ee,onEdgesChange:re,onConnect:U,onEdgeUpdate:le,isValidConnection:A,connectionMode:ConnectionMode.Loose,nodeTypes:ne,edgeTypes:z,className:b,style:B,colorMode:f,readOnly:k,panOnDrag:C,panOnScroll:v,zoomOnScroll:T,fitViewOptions:{padding:.2}})},bd=e=>jsx(fd,{...e});var yd=({cable:e,side:t,rowHeight:o=22,tubeGap:r=10,columnWidth:i=150,layout:a,showTubeLabels:d,showFiberNumbers:s=true,showCableLabel:l=true})=>{let p=useMemo(()=>a??fo(e,{rowHeight:o,tubeGap:r}),[a,e,o,r]),m=26,f=10,c=18,b=t==="left"?i-c:c,x=8,k=t==="left"?6:i-m-18,C=e.jacketColor??"#facc15",v=d??(e.kind??(e.tubeCount?"tube":"simple"))==="tube";return jsxs("div",{style:{position:"relative",width:i,height:p.height,fontFamily:"monospace",color:"inherit"},children:[l&&jsx("div",{style:{position:"absolute",top:-18,left:t==="left"?0:void 0,right:t==="right"?0:void 0,fontSize:10,fontWeight:700,letterSpacing:.4,textTransform:"uppercase",background:"rgba(15, 23, 42, 0.85)",color:"#f8fafc",padding:"2px 6px",borderRadius:4},children:e.label}),jsx("div",{style:{position:"absolute",top:0,bottom:0,width:m,left:t==="left"?0:void 0,right:t==="right"?0:void 0,borderRadius:14,background:`linear-gradient(90deg, ${C} 0%, ${C} 60%, rgba(0,0,0,0.25) 100%)`,border:`2px solid ${C}`,boxShadow:"inset 0 0 6px rgba(0,0,0,0.4)"}}),v&&p.tubeLabels.map(T=>jsxs("div",{style:{position:"absolute",top:T.y+o/2-6,left:k,fontSize:9,fontWeight:700,textTransform:"uppercase",color:"rgba(15, 23, 42, 0.75)",background:"rgba(255, 255, 255, 0.6)",padding:"1px 6px 1px 4px",borderRadius:10,display:"flex",alignItems:"center",gap:4},children:[jsx("span",{style:{width:8,height:8,borderRadius:"50%",backgroundColor:T.color,border:"1px solid rgba(0, 0, 0, 0.4)",boxShadow:"0 0 3px rgba(0,0,0,0.25)"}}),jsx("span",{children:T.label})]},`tube-${T.tubeIndex}`)),p.rows.map(T=>{let E=T.y+o/2-f/2,F=t==="left"?b-f/2-x:b+f/2+x;return jsxs(lt.Fragment,{children:[jsx("div",{style:{position:"absolute",top:E,left:b-f/2,width:f,height:f,borderRadius:"50%",backgroundColor:T.color,backgroundImage:T.backgroundImage,border:"1px solid rgba(0, 0, 0, 0.4)",boxShadow:"0 0 4px rgba(0,0,0,0.25)"}}),s&&jsx("div",{style:{position:"absolute",top:T.y+o/2-6,left:F,transform:t==="left"?"translateX(-100%)":"none",fontSize:10,fontWeight:600,color:"rgba(15, 23, 42, 0.75)"},children:T.fiberIndex})]},T.key)})]})};var Oi=e=>({id:`rack-${e.id}`,type:"rack",position:{x:0,y:0},data:{label:e.name,status:typeof e.status=="object"&&e.status?e.status.value:e.status,uHeight:e.u_height??e.units??42,inventoryId:e.id,inventoryType:"rack",facilityId:e.facility_id,serial:e.serial,assetTag:e.asset_tag,site:typeof e.site=="object"&&e.site?e.site.name:e.site,role:typeof e.role=="object"&&e.role?e.role.name:e.role,tenant:typeof e.tenant=="object"&&e.tenant?e.tenant.name:e.tenant}}),Li=e=>({id:`device-${e.id}`,type:"device",position:{x:0,y:0},parentId:e.rack?`rack-${typeof e.rack=="object"&&e.rack?e.rack.id:e.rack}`:void 0,extent:e.rack?"parent":void 0,data:{label:e.name,status:typeof e.status=="object"&&e.status?e.status.value:e.status,deviceType:e.device_type?.model??e.model,manufacturer:e.device_type?.manufacturer?.name??e.manufacturer,role:typeof e.device_role=="object"&&e.device_role?e.device_role.name:e.role,uHeight:e.device_type?.u_height??e.u_height??1,uPosition:e.position||1,view:e.face||"front",inventoryId:e.id,inventoryType:"device",primaryIp4:typeof e.primary_ip4=="object"&&e.primary_ip4?e.primary_ip4.address:e.primary_ip4,primaryIp6:typeof e.primary_ip6=="object"&&e.primary_ip6?e.primary_ip6.address:e.primary_ip6,site:typeof e.site=="object"&&e.site?e.site.name:e.site,rack:typeof e.rack=="object"&&e.rack?e.rack.name:e.rack}}),zi=e=>{let t=i=>{if(!i)return;if(typeof i=="string")return i;let a=i.device;return typeof a=="object"&&a?a.id:a},o=t(e.termination_a),r=t(e.termination_b);return {id:`cable-${e.id}`,source:`device-${o}`,target:`device-${r}`,type:"fiber",data:{bandwidth:e.type?.label??e.bandwidth,length:e.length||0,color:e.color,inventoryId:e.id,inventoryType:"cable",status:typeof e.status=="object"&&e.status?e.status.value:e.status,terminationA:typeof e.termination_a=="object"&&e.termination_a?e.termination_a.name:e.termination_a,terminationB:typeof e.termination_b=="object"&&e.termination_b?e.termination_b.name:e.termination_b}}},wd=e=>{let t=[],o=[];return e.racks.forEach(r=>t.push(Oi(r))),e.devices.forEach(r=>t.push(Li(r))),e.cables.forEach(r=>o.push(zi(r))),{nodes:t,edges:o}},Nd=e=>{let t=e.filter(i=>i.type==="rack"),o=e.filter(i=>i.type==="device"),r=e.filter(i=>!["rack","device"].includes(i.type));return t.forEach((i,a)=>{i.position={x:a*300,y:100};}),o.forEach(i=>{if(i.parentId){let a=t.find(d=>d.id===i.parentId);if(a){let d=i.data.uPosition||1,s=i.data.uHeight||1;i.position={x:a.position.x+50,y:a.position.y+d*20-s*10};}}else i.position={x:Math.random()*400+100,y:Math.random()*200+50};}),r.forEach((i,a)=>{i.position={x:a*150+100,y:300};}),e};var Bi=e=>typeof e.id=="number"?`device-${e.id}`:`device-${e.name}`,Ui=e=>({id:`rack-${e.id}`,type:"rack",position:{x:0,y:0},data:{label:e.name,status:e.status.value,uHeight:e.u_height,netboxId:e.id,netboxType:"rack",facilityId:e.facility_id,serial:e.serial,assetTag:e.asset_tag,site:e.site.name,role:e.role?.name,tenant:e.tenant?.name}}),Vi=e=>({id:`device-${e.id}`,type:"device",position:{x:0,y:0},parentId:e.rack?`rack-${e.rack.id}`:void 0,extent:e.rack?"parent":void 0,data:{label:e.name,status:e.status.value,deviceType:e.device_type.model,manufacturer:e.device_type.manufacturer.name,role:e.device_role.name,uHeight:1,uPosition:e.position||1,face:e.face||"front",netboxId:e.id,netboxType:"device",primaryIp4:e.primary_ip4?.address,primaryIp6:e.primary_ip6?.address,site:e.site.name,rack:e.rack?.name}}),ji=e=>({id:`cable-${e.id}`,source:Bi(e.termination_a.device),target:Bi(e.termination_b.device),type:"fiber",data:{bandwidth:e.type.label,length:e.length||0,color:e.color,netboxId:e.id,netboxType:"cable",status:e.status.value,terminationA:e.termination_a.name,terminationB:e.termination_b.name}}),xd=e=>{let t=[],o=[],r=new Map;return e.racks.forEach(i=>{t.push(Ui(i));}),e.devices.forEach(i=>{let a=Vi(i);t.push(a),r.set(i.name,a.id);}),e.cables.forEach(i=>{let a=ji(i),d=(typeof i.termination_a.device.id=="number"?`device-${i.termination_a.device.id}`:void 0)??r.get(i.termination_a.device.name)??a.source,s=(typeof i.termination_b.device.id=="number"?`device-${i.termination_b.device.id}`:void 0)??r.get(i.termination_b.device.name)??a.target;o.push({...a,source:d,target:s});}),{nodes:t,edges:o}},kd=(e,t)=>{let o=new Map,r=new Set;return e.filter(a=>a.position!==null).sort((a,d)=>(a.position||0)-(d.position||0)).forEach(a=>{a.position&&(o.set(a.id,a.position),r.add(a.position));}),o};function Ko(e){let{items:t,checkOutOfBounds:o,checkConflicts:r}=e,i=[],a=[];for(let d of t){let s=o(d);s&&!s.isValid&&s.error&&a.push(s.error);}for(let d=0;d<t.length;d++){let s=t[d];for(let l=d+1;l<t.length;l++){let p=t[l],m=r(s,p);m&&m.hasConflict&&m.conflict&&i.push(m.conflict);}}return {isValid:i.length===0&&a.length===0,conflicts:i,outOfBounds:a}}var Ut=class extends Error{constructor(o,r,i,a,d){super(`Device placement conflict: ${r} at U${i}-${i+a-1} in rack ${o}${d?` conflicts with ${d}`:""}`);this.rackId=o;this.deviceId=r;this.uPosition=i;this.uHeight=a;this.conflictWith=d;this.name="DevicePlacementError";}};function sn(e,t={}){return Ko({items:e.devices,checkOutOfBounds:o=>o.unit+o.height-1>e.units?{isValid:false,error:{deviceId:o.id,uPosition:o.unit,uHeight:o.height,rackUHeight:e.units}}:null,checkConflicts:(o,r)=>{let i=o.unit,a=o.unit+o.height-1,d=r.unit,s=r.unit+r.height-1;return i<=s&&a>=d?{hasConflict:true,conflict:{deviceId:o.id,uPosition:o.unit,uHeight:o.height,conflictWith:r.id}}:null}})}function Gi(e,t,o={}){let{deviceTypeMapping:r={}}=o,i=r[e.type]||"device",a=_t(t,e.unit,e.height);return {id:e.id,type:i,position:a,parentId:t.id,extent:"parent",data:{label:e.name,status:e.status||"active",deviceType:e.type,uHeight:e.height,uPosition:e.unit,width:e.width||"full",role:e.role,ports:e.ports,rearPorts:e.rearPorts,connections:e.connections,frontImageUrl:e.frontImageUrl,rearImageUrl:e.rearImageUrl,frontImageAttribution:e.frontImageAttribution,rearImageAttribution:e.rearImageAttribution,imageFit:e.imageFit,imagePosition:e.imagePosition,imageRepeat:e.imageRepeat,stretchToFit:e.stretchToFit,rackWidthPx:t.data.rackWidthPx}}}function vd(e){return {id:e.id,type:"rack",position:e.position,data:{label:e.name,status:"active",uHeight:e.units,uNumberingDirection:e.uNumberingDirection||"bottom-up",customHeaderText:e.customHeaderText,ports:[],rackWidthPx:e.rackWidthPx}}}function Cd(e,t={}){let{conflictPolicy:o="strict",validatePlacements:r=true}=t,i=[],a=[];if(r)for(let d of e){let s=sn(d,t);if(!s.isValid&&o==="strict"){let l=[];throw s.conflicts.forEach(p=>{l.push(`Device ${p.deviceId} at U${p.uPosition}-${p.uPosition+p.uHeight-1} conflicts with ${p.conflictWith}`);}),s.outOfBounds.forEach(p=>{l.push(`Device ${p.deviceId} at U${p.uPosition}-${p.uPosition+p.uHeight-1} exceeds rack height (${p.rackUHeight}U)`);}),new Ut(d.id,s.conflicts[0]?.deviceId||s.outOfBounds[0]?.deviceId||"unknown",s.conflicts[0]?.uPosition||s.outOfBounds[0]?.uPosition||1,s.conflicts[0]?.uHeight||s.outOfBounds[0]?.uHeight||1)}}for(let d of e){let s=vd(d);i.push(s);for(let l of d.devices)try{let p=Gi(l,s,t);a.push(p);}catch(p){if(o==="strict")throw p;if(o==="nearest"){let m=Ho(s,{id:l.id,data:{label:l.name,uHeight:l.height}},a,l.unit);if(m!==l.unit){console.warn(`Device ${l.id} moved from U${l.unit} to U${m} due to conflict`);let f={...l,unit:m},c=Gi(f,s,t);a.push(c);}else throw new Ut(d.id,l.id,l.unit,l.height)}}}return i.push(...a),i}function Hd(e){let t=[],o=e.filter(r=>r.type==="rack");for(let r of o){let a=e.filter(d=>qt(d.type)&&d.parentId===r.id).map(d=>({id:d.id,name:d.data.label,unit:d.data.uPosition||1,height:d.data.uHeight||1,type:d.data.deviceType||"server",width:d.data.width==="full"||d.data.width==="half"?d.data.width:void 0,ports:Array.isArray(d.data.ports)?d.data.ports:void 0,connections:d.data.connections,frontImageUrl:d.data.frontImageUrl,rearImageUrl:d.data.rearImageUrl,frontImageAttribution:d.data.frontImageAttribution,rearImageAttribution:d.data.rearImageAttribution,imageFit:d.data.imageFit,imagePosition:d.data.imagePosition,imageRepeat:d.data.imageRepeat,stretchToFit:d.data.stretchToFit}));t.push({id:r.id,name:r.data.label,position:r.position,units:r.data.uHeight||42,uNumberingDirection:r.data.uNumberingDirection||"bottom-up",customHeaderText:r.data.customHeaderText,devices:a,rackWidthPx:r.data.rackWidthPx});}return t}function Pd(e,t,o,r){return e.map(i=>i.id!==t?i:{...i,devices:i.devices.map(a=>a.id!==o?a:{...a,unit:r})})}function Sd(e,t,o,r={}){let{conflictPolicy:i="strict"}=r;return e.map(a=>{if(a.id!==t)return a;if(i==="strict"&&!sn({...a,devices:[...a.devices,o]},r).isValid)throw new Ut(t,o.id,o.unit,o.height);return {...a,devices:[...a.devices,o]}})}function Ed(e,t,o){return e.map(r=>r.id!==t?r:{...r,devices:r.devices.filter(i=>i.id!==o)})}var Vt=class extends Error{constructor(o,r,i,a){super(`Splice placement conflict: ${r} at holder ${i} in tray ${o}${a?` conflicts with ${a}`:""}`);this.trayId=o;this.spliceId=r;this.holder=i;this.conflictWith=a;this.name="SplicePlacementError";}};function dn(e,t={}){return Ko({items:e.splices,checkOutOfBounds:o=>o.holder<1||o.holder>ct?{isValid:false,error:{spliceId:o.id,holder:o.holder,max:ct}}:null,checkConflicts:(o,r)=>o.holder===r.holder?{hasConflict:true,conflict:{spliceId:o.id,holder:o.holder,conflictWith:r.id}}:null})}function Xi(e,t){let o=e.mode==="ribbon",r=uo(t,e.holder,o);return {id:e.id,type:"splice",position:r,parentId:t.id,extent:"parent",data:{label:e.name,holderPosition:e.holder,lossDb:e.lossDb,mode:e.mode||"single",ribbonFiberIds:e.ribbonFiberIds}}}function Rd(e){return {id:e.id,type:"splice-tray",position:e.position,data:{label:e.name,status:"active"}}}function Td(e,t={}){let{conflictPolicy:o="strict",validatePlacements:r=true}=t,i=[],a=[];if(r)for(let d of e){let s=dn(d,t);if(!s.isValid&&o==="strict"){let l=[];throw s.conflicts.forEach(p=>{l.push(`Splice ${p.spliceId} at holder ${p.holder} conflicts with ${p.conflictWith}`);}),s.outOfBounds.forEach(p=>{l.push(`Splice ${p.spliceId} at holder ${p.holder} is out of bounds (max: ${p.max})`);}),new Vt(d.id,s.conflicts[0]?.spliceId||s.outOfBounds[0]?.spliceId||"unknown",s.conflicts[0]?.holder||s.outOfBounds[0]?.holder||1)}}for(let d of e){let s=Rd(d);i.push(s);for(let l of d.splices)try{let p=l.holder;if(o==="nearest"){let c={id:l.id,type:"splice",position:{x:0,y:0},data:{label:l.name,holderPosition:l.holder}},b=[...i,...a];so(s,c,l.holder,b)||(p=co(s,c,b,l.holder));}let m=p!==l.holder?{...l,holder:p}:l,f=Xi(m,s);a.push(f);}catch(p){if(o==="strict")throw p;if(o==="nearest"){let m=[...i,...a],f=co(s,{id:l.id,data:{label:l.name,holderPosition:l.holder}},m,l.holder);if(f!==l.holder){console.warn(`Splice ${l.id} moved from holder ${l.holder} to holder ${f} due to conflict`);let c={...l,holder:f},b=Xi(c,s);a.push(b);}else throw new Vt(d.id,l.id,l.holder)}}}return i.push(...a),i}function Id(e){let t=[],o=e.filter(r=>r.type==="splice-tray");for(let r of o){let a=e.filter(d=>d.type==="splice"&&d.parentId===r.id).map(d=>({id:d.id,name:d.data.label,holder:d.data.holderPosition||1,lossDb:d.data.lossDb,mode:d.data.mode||"single",ribbonFiberIds:d.data.ribbonFiberIds}));t.push({id:r.id,name:r.data.label,position:r.position,splices:a});}return t}function Dd(e,t,o,r){return e.map(i=>i.id!==t?i:{...i,splices:i.splices.map(a=>a.id!==o?a:{...a,holder:r})})}function Fd(e,t,o,r={}){let{conflictPolicy:i="strict"}=r;return e.map(a=>{if(a.id!==t)return a;if(i==="strict"&&!dn({...a,splices:[...a.splices,o]},r).isValid)throw new Vt(t,o.id,o.holder);return {...a,splices:[...a.splices,o]}})}function _d(e,t,o){return e.map(r=>r.id!==t?r:{...r,splices:r.splices.filter(i=>i.id!==o)})}
|
|
2
|
+
export{hs as COUPLERS_PER_PANEL,Oo as COUPLER_SLOT_HEIGHT_PX,ms as COUPLER_WIDTH_PX,$r as CableNode,Yr as ClosureNode,Ar as CouplerNode,$t as DeviceNode,Ut as DevicePlacementError,rn as DiagramErrorBoundary,Dn as FIBER_COLORS_12,Eo as FiberEdge,gr as FiberNode,yd as FibreCableWithTubesExpanded,bd as FibreFlowMap,Zr as FibreSplitNode,Zt as HANDLE_EXTENSION_PX,Wr as MultiTubeCableNode,on as NetworkDiagram,ii as PANEL_BORDER_WIDTH,St as PANEL_HEADER_HEIGHT,Ao as PANEL_HEIGHT_PX,Pt as PANEL_PADDING,ai as PANEL_TUBE_TRAY_SPACING,Wo as PANEL_WIDTH_PX,mr as POWER_CONNECTORS,jr as PatchPanelNode,br as PowerEdge,et as RACK_HEADER_HEIGHT,xo as RACK_WIDTH_PX,pr as RackNode,Pr as SpliceNode,Vt as SplicePlacementError,Ir as SpliceTrayNode,Dr as TubeNode,Me as U_HEIGHT_PX,vr as VerticalPDU,Un as Width,Sd as addDeviceToRack,Fd as addSpliceToTray,De as baseColorFor,Cd as buildNodesFromRackConfig,Td as buildNodesFromSpliceConfig,Br as calculateClosureDimensions,ws as calculateCouplerRightX,xs as calculateCouplerSlotSpacing,fi as calculateCouplerSpacing,_t as calculateDevicePositionFromU,zr as calculatePanelDimensions,pi as calculateSlotPositionFromY,ds as calculateSplicePositionFromNumber,kd as calculateUPositions,gi as calculateYFromSlotPosition,qr as createNetworkDiagramStore,Hd as createRackConfigFromNodes,Id as createSpliceConfigFromNodes,fr as fiberSolidOrStriped,Go as findNearestRack,co as findNextAvailableHolderPosition,Ho as findNextAvailableUPosition,Nd as generateLayout,Vn as getConnectorConfig,Lr as getCouplerDimensions,wr as getDeviceConnectorType,wt as getFiberColor,ui as getInnerContentWidth,yr as getPDUPortType,ys as getPanelHeight,ci as getPanelWidth,ro as getPowerPortStyle,Ni as getRackBounds,Ke as getStatusColor,si as getTrayDimensions,Lo as getTubeDimensions,zi as inventoryCableToNetworkEdge,Li as inventoryDeviceToNetworkNode,Oi as inventoryRackToNetworkNode,wd as inventoryToNetworkDiagram,Wa as isHighPowerConnector,xi as isPointInRack,yt as isStriped,ur as isUPositionAvailable,ji as netboxCableToNetworkEdge,Vi as netboxDeviceToNetworkNode,Ui as netboxRackToNetworkNode,xd as netboxToNetworkDiagram,Ed as removeDeviceFromRack,_d as removeSpliceFromTray,Pe as replaceEdge,Ns as snapToCouplerPosition,Er as snapToSplicePosition,Co as snapToUPosition,In as updateDeviceUPosition,Pd as updateDeviceUPositionInSchema,Dd as updateSpliceHolderPosition,en as useDiagramEdges,Qr as useDiagramNodes,Ts as useNetworkDiagram,ya as validateAndSnapDevice,sn as validateRackDevicePlacements,dn as validateSplicePlacements};//# sourceMappingURL=index.mjs.map
|
|
3
3
|
//# sourceMappingURL=index.mjs.map
|