@mp70/react-networks 0.1.9-beta → 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/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- 'use strict';var gt=require('react'),reactflow=require('reactflow'),htmlToImage=require('html-to-image'),jsxRuntime=require('react/jsx-runtime');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var gt__default=/*#__PURE__*/_interopDefault(gt);var He=20,Xe=60,Jt=300,Rt=5;function Or(e){return e==="system"?typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: light)").matches?"light":"dark":e}function Br(e,o){let n=Or(e)==="light"?"react-flow-light":"react-flow-dark";return o?`${n} ${o}`:n}function Ur(e){return Or(e)==="light"?"#e5e5e5":"#2a2a2a"}function Vr(e,o){return {width:"100%",height:"100%",...o}}var wi=()=>"bottom-up",ot=e=>e.data.uNumberingDirection||wi(),Qt=(e,o,t)=>t==="bottom-up"?o-e+1:e,eo=(e,o,t)=>t==="bottom-up"?o-e+1:e;var Lo=(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,p=Math.round(d/20)+1,h;l==="bottom-up"?h=Qt(p,a,l)-s+1:h=Qt(p,a,l);let u=a-s+1,c=Math.max(1,Math.min(u,h));if(l==="top-down"&&h<=1&&(c=1),!zo(o,e,c,n)){let x=to(o,e,n,c);x!==c&&(c=x);}let g;if(l==="bottom-up"){let x=c+s-1,C=eo(x,a,l);g=i+(C-1)*20-1;}else {let x=eo(c,a,l);g=i+(x-1)*20-1;}return {x:t.x,y:g,uPosition:c}},zo=(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,p=i.data.uHeight||1,h=t,u=t+s-1,c=d,g=d+p-1;if(h<=g&&u>=c)return false}return true},to=(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(zo(e,o,l,t))return l;return 1},ft=(e,o,t=1)=>{let n=60,s=ot(e),a=e.data.uHeight||42,l=eo(o,a,s),i;if(s==="bottom-up"){let d=o+t-1,p=eo(d,a,s);i=n+(p-1)*20-1;}else i=n+(l-1)*20-1;return {x:0,y:i}},jr=(e,o,t)=>{let n=e.data.uHeight||1,s=ft(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?jr(e,o,a):e};function _e(e){switch(e){case "active":return "#10b981";case "inactive":return "#6b7280";case "maintenance":return "#f59e0b";default:return "#6b7280"}}var Ao=({data:e,selected:o,id:t,onViewChange:n,onRackFaceChange:s,isDragOver:a=false})=>{let{label:l,ports:i=0,status:d="active",uHeight:p=42,face:h="front",customHeaderText:u,rackWidthPx:c}=e,g=c||300,{getNodes:x,setNodes:C}=reactflow.useReactFlow(),k=x(),[E,F]=gt.useState(e.showUMarkers!==void 0?e.showUMarkers:true),I=()=>{let H=ot({data:e})==="bottom-up"?"top-down":"bottom-up";C(D=>D.map(z=>z.id===t?{...z,data:{...z.data,uNumberingDirection:H}}:z));},W=()=>{let y=h==="front"?"rear":"front";s?(s(t,y),n&&k.filter(D=>D.parentId===t).forEach(D=>{n(D.id,y);})):n?k.filter(D=>D.parentId===t).forEach(D=>{n(D.id,y);}):C(H=>H.map(D=>D.id===t?{...D,data:{...D.data,face:y}}:D.parentId===t?{...D,data:{...D.data,view:y}}:D));},m=()=>{let y=[],H=60,D=ot({data:e});for(let z=1;z<=p;z++){let A=H+(z-1)*20-4,X=Qt(z,p,D);y.push(jsxRuntime.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:X},z));}return y};return jsxRuntime.jsxs("div",{className:`rack-node ${o?"selected":""} ${a?"drag-over":""}`,style:{background:"transparent",border:`2px solid ${_e(d)}`,borderRadius:"8px",padding:0,width:`${g}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":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:[jsxRuntime.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:[jsxRuntime.jsx("div",{style:{fontWeight:"bold",marginBottom:"4px"},children:l}),jsxRuntime.jsxs("div",{style:{fontSize:"10px",color:"#9ca3af"},children:[u?jsxRuntime.jsx("span",{style:{color:"#fbbf24",fontWeight:"bold"},children:u}):jsxRuntime.jsxs("span",{children:[typeof i=="number"?i:0," ports"]})," \u2022 ",p,"U \u2022 ",h]}),jsxRuntime.jsxs("div",{style:{display:"flex",gap:"4px",position:"absolute",top:"4px",right:"4px"},children:[jsxRuntime.jsx("button",{onPointerDown:y=>{y.stopPropagation();},onMouseDown:y=>{y.stopPropagation();},onClick:y=>{y.stopPropagation(),y.preventDefault(),F(!E);},style:{background:E?"#10b981":"#374151",color:E?"#ffffff":"#9ca3af",border:"1px solid #4b5563",borderRadius:"2px",padding:"2px 6px",fontSize:"8px",cursor:"pointer",fontFamily:"monospace"},title:`${E?"Hide":"Show"} U markers`,children:"U"}),jsxRuntime.jsx("button",{onPointerDown:y=>{y.stopPropagation();},onMouseDown:y=>{y.stopPropagation();},onClick:y=>{y.stopPropagation(),y.preventDefault(),I();},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"}),jsxRuntime.jsx("button",{onPointerDown:y=>{y.stopPropagation();},onMouseDown:y=>{y.stopPropagation();},onClick:y=>{y.stopPropagation(),y.preventDefault(),W();},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"})]})]}),jsxRuntime.jsx("div",{style:{flex:1,background:"transparent",position:"relative",minHeight:`${p*20}px`,overflow:"hidden"}}),E&&jsxRuntime.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none"},children:m()})]})};var Oo=({data:e,selected:o})=>{let{label:t,status:n="active"}=e;return jsxRuntime.jsxs("div",{className:`fiber-node ${o?"selected":""}`,style:{background:"#1f2937",border:`2px solid ${_e(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:[jsxRuntime.jsx(reactflow.Handle,{type:"target",position:reactflow.Position.Top}),jsxRuntime.jsx(reactflow.Handle,{type:"source",position:reactflow.Position.Bottom}),jsxRuntime.jsx(reactflow.Handle,{type:"target",position:reactflow.Position.Left}),jsxRuntime.jsx(reactflow.Handle,{type:"source",position:reactflow.Position.Right}),jsxRuntime.jsx("div",{style:{textAlign:"center"},children:jsxRuntime.jsx("div",{style:{fontSize:"8px",lineHeight:"1.2"},children:t})}),jsxRuntime.jsx("div",{style:{position:"absolute",bottom:"4px",left:"50%",transform:"translateX(-50%)",width:"8px",height:"8px",background:_e(n),borderRadius:"50%"}})]})};var Yr=["#1f77b4","#ff7f0e","#2ca02c","#8c564b","#708090","#ffffff","#d62728","#000000","#ffdf00","#8a2be2","#ff69b4","#00ffff"];function xe(e){let o=(e-1)%12;return Yr[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),p=d.length,h=n?1.2:1,u=!!i?.highlight,c=n?2:1.5,g=i?.highlightWidth??c*3,x=i?.highlightColor??d[0]?.base??"#22d3ee";return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[u&&jsxRuntime.jsx(reactflow.BaseEdge,{id:`${e}-highlight`,path:o,style:{...s,stroke:x,strokeWidth:g,opacity:.7,strokeDasharray:"14 10","--rn-edge-highlight-from":`${c}px`,"--rn-edge-highlight-to":`${g}px`}}),d.map((C,k)=>{let F=(p-k)*h;return jsxRuntime.jsx("path",{d:o,stroke:C.base,strokeWidth:F,fill:"none",strokeLinecap:"butt",opacity:C.striped?.9:1,style:s},`${e}-ribbon-${k}`)}),d.some(C=>C.striped)&&jsxRuntime.jsx(reactflow.BaseEdge,{id:`${e}-ribbon-stripe`,path:o,style:{...s,stroke:"#000",strokeWidth:1,strokeDasharray:"3 3",opacity:.4}}),jsxRuntime.jsx(reactflow.EdgeLabelRenderer,{children:n&&i&&(i.bandwidth||i.length)&&jsxRuntime.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&&jsxRuntime.jsx("div",{children:i.bandwidth}),i.length&&jsxRuntime.jsxs("div",{children:[i.length,"m"]}),jsxRuntime.jsxs("div",{style:{fontSize:"8px",opacity:.8},children:[t.length,"F"]})]})})]})}var no=({id:e,sourceX:o,sourceY:t,targetX:n,targetY:s,sourcePosition:a,targetPosition:l,data:i,selected:d,style:p={},className:h})=>{let[u,c,g]=reactflow.getBezierPath({sourceX:o,sourceY:t,sourcePosition:a,targetX:n,targetY:s,targetPosition:l}),{bandwidth:x,length:C,color:k="#00FFFF",striped:E=false,ribbonFiberIds:F,isRibbon:I,highlight:W,highlightColor:m,highlightWidth:y}=i||{},H=!!W;if((I||F&&F.length>=6&&F.length<=12)&&F)return Si(e,u,F,d??false,p??{},c,g,i);let z=d?3:2,A=y??z*3,X={...p,stroke:k,strokeWidth:z,strokeDasharray:"none"};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[H&&jsxRuntime.jsx(reactflow.BaseEdge,{id:`${e}-highlight`,path:u,style:{...p,stroke:m??k,strokeWidth:A,opacity:.7,strokeDasharray:"14 10","--rn-edge-highlight-from":`${z}px`,"--rn-edge-highlight-to":`${A}px`}}),jsxRuntime.jsx(reactflow.BaseEdge,{id:e,path:u,style:X}),E&&jsxRuntime.jsx(reactflow.BaseEdge,{id:`${e}-stripe`,path:u,style:{...p,stroke:"#000",strokeWidth:1.5,strokeDasharray:"6 6",opacity:.9}}),jsxRuntime.jsx(reactflow.EdgeLabelRenderer,{children:d&&i&&(x||C)&&jsxRuntime.jsxs("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${c}px,${g}px)`,background:"#1f2937",padding:"4px 8px",borderRadius:"4px",fontSize:"10px",color:"white",fontFamily:"monospace",border:`1px solid ${k}`,pointerEvents:"none",zIndex:9999},children:[x&&jsxRuntime.jsx("div",{children:x}),C&&jsxRuntime.jsxs("div",{children:[C,"m"]})]})})]})};var Bo=({id:e,sourceX:o,sourceY:t,targetX:n,targetY:s,sourcePosition:a,targetPosition:l,style:i={},data:d,markerEnd:p})=>{let[h]=reactflow.getBezierPath({sourceX:o,sourceY:t,sourcePosition:a,targetX:n,targetY:s,targetPosition:l}),u=d?.connectorType||"C13";return jsxRuntime.jsx(reactflow.BaseEdge,{id:e,path:h,markerEnd:p,style:(()=>{let g={stroke:d?.color||"#f59e0b",strokeWidth:u==="C19"?5:3,strokeLinecap:"round",strokeLinejoin:"round",...i};return u==="C19"?{...g,strokeDasharray:"none"}:{...g,strokeDasharray:"6,3"}})()})};function Fi(e,o,t,n,s,a,l,i,d,p,h){let u=Ae(i),c=u.length,g=d?1.8:1.5,x=!!h?.highlight,C=d?3:2.5,k=h?.highlightWidth??C*3,E=h?.highlightColor??u[0]?.base??"#22d3ee",[F,I,W]=reactflow.getSmoothStepPath({sourceX:o,sourceY:t,targetX:n,targetY:s,sourcePosition:a,targetPosition:l});return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[x&&jsxRuntime.jsx(reactflow.BaseEdge,{id:`${e}-highlight`,path:F,style:{...p,stroke:E,strokeWidth:k,opacity:.7,strokeDasharray:"14 10","--rn-edge-highlight-from":`${C}px`,"--rn-edge-highlight-to":`${k}px`}}),u.map((m,y)=>{let D=(c-y)*g;return jsxRuntime.jsx("path",{d:F,stroke:m.base,strokeWidth:D,fill:"none",strokeLinecap:"butt",opacity:m.striped?.9:1,style:p},`${e}-ribbon-${y}`)}),u.some(m=>m.striped)&&jsxRuntime.jsx(reactflow.BaseEdge,{id:`${e}-ribbon-stripe`,path:F,style:{...p,stroke:"#000",strokeWidth:1,strokeDasharray:"3 3",opacity:.4}}),jsxRuntime.jsx(reactflow.EdgeLabelRenderer,{children:d&&h&&(h.bandwidth||h.length)&&jsxRuntime.jsxs("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${I}px,${W}px)`,background:"#1f2937",padding:"4px 8px",borderRadius:"4px",fontSize:"10px",color:"white",fontFamily:"monospace",border:`1px solid ${u[0]?.base||"#00FFFF"}`,pointerEvents:"none",zIndex:9999},children:[h.bandwidth&&jsxRuntime.jsx("div",{children:h.bandwidth}),h.length&&jsxRuntime.jsxs("div",{children:[h.length,"m"]}),jsxRuntime.jsxs("div",{style:{fontSize:"8px",opacity:.8},children:[i.length,"F"]})]})})]})}var Zr=({id:e,sourceX:o,sourceY:t,targetX:n,targetY:s,sourcePosition:a,targetPosition:l,data:i,selected:d,style:p={},...h})=>{let{color:u="#00FFFF",ribbonFiberIds:c,isRibbon:g,highlight:x,highlightColor:C,highlightWidth:k}=i||{},E=!!x;if((g||c&&c.length>=6&&c.length<=12)&&c)return Fi(e,o,t,n,s,a,l,c,d??false,p??{},i);let I=d?4:3,W=k??I*3,m={...p,stroke:u,strokeWidth:I};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[E&&jsxRuntime.jsx(reactflow.BaseEdge,{id:`${e}-highlight`,path:reactflow.getSmoothStepPath({sourceX:o,sourceY:t,targetX:n,targetY:s,sourcePosition:a,targetPosition:l})[0],style:{...p,stroke:C??u,strokeWidth:W,opacity:.7,strokeDasharray:"14 10","--rn-edge-highlight-from":`${I}px`,"--rn-edge-highlight-to":`${W}px`}}),jsxRuntime.jsx(reactflow.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===reactflow.Position.Left||s===reactflow.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,p=!!a?.highlight,h=n?2:1.5,u=a?.highlightWidth??h*3,c=a?.highlightColor??l[0]?.base??"#22d3ee",g=o.match(/M\s+([\d.]+),([\d.]+).*L\s+([\d.]+),([\d.]+)/),x=g?(parseFloat(g[1])+parseFloat(g[3]))/2:0,C=g?(parseFloat(g[2])+parseFloat(g[4]))/2:0;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[p&&jsxRuntime.jsx(reactflow.BaseEdge,{id:`${e}-highlight`,path:o,style:{...s,stroke:c,strokeWidth:u,opacity:.7,strokeDasharray:"14 10","--rn-edge-highlight-from":`${h}px`,"--rn-edge-highlight-to":`${u}px`}}),l.map((k,E)=>{let I=(i-E)*d;return jsxRuntime.jsx("path",{d:o,stroke:k.base,strokeWidth:I,fill:"none",strokeLinecap:"butt",opacity:k.striped?.9:1,style:s},`${e}-ribbon-${E}`)}),l.some(k=>k.striped)&&jsxRuntime.jsx(reactflow.BaseEdge,{id:`${e}-ribbon-stripe`,path:o,style:{...s,stroke:"#000",strokeWidth:1,strokeDasharray:"3 3",opacity:.4}}),jsxRuntime.jsx(reactflow.EdgeLabelRenderer,{children:n&&a&&(a.bandwidth||a.length)&&jsxRuntime.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&&jsxRuntime.jsx("div",{children:a.bandwidth}),a.length&&jsxRuntime.jsxs("div",{children:[a.length,"m"]}),jsxRuntime.jsxs("div",{style:{fontSize:"8px",opacity:.8},children:[t.length,"F"]})]})})]})}var Qr=({id:e,sourceX:o,sourceY:t,targetX:n,targetY:s,sourcePosition:a,targetPosition:l,data:i,selected:d,style:p={},...h})=>{let{color:u="#00FFFF",striped:c=false,ribbonFiberIds:g,isRibbon:x,highlight:C,highlightColor:k,highlightWidth:E}=i||{},F=!!C,I=Di({sourceX:o,sourceY:t,sourcePosition:a,targetX:n,targetY:s,targetPosition:l});if((x||g&&g.length>=6&&g.length<=12)&&g)return $i(e,I,g,d??false,p??{},i);let m=d?3:2,y=E??m*3,H={...p,stroke:u,strokeWidth:m,strokeDasharray:"none"};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[F&&jsxRuntime.jsx(reactflow.BaseEdge,{id:`${e}-highlight`,path:I,style:{...p,stroke:k??u,strokeWidth:y,opacity:.7,strokeDasharray:"14 10","--rn-edge-highlight-from":`${m}px`,"--rn-edge-highlight-to":`${y}px`}}),jsxRuntime.jsx(reactflow.BaseEdge,{id:e,path:I,style:H}),c&&jsxRuntime.jsx(reactflow.BaseEdge,{id:`${e}-stripe`,path:I,style:{...p,stroke:"#000",strokeWidth:1.5,strokeDasharray:"6 6",opacity:.9}})]})};var on=({id:e,sourceX:o,sourceY:t,targetX:n,targetY:s,sourcePosition:a,targetPosition:l,style:i={},data:d,markerEnd:p,selected:h})=>{let{color:u="#6366f1",label:c,highlight:g,highlightColor:x,highlightWidth:C}=d||{},k=!!g,E=8,F=C??E*1.8,[I,W,m]=reactflow.getBezierPath({sourceX:o,sourceY:t,sourcePosition:a,targetX:n,targetY:s,targetPosition:l}),y={...i,stroke:u,strokeWidth:E,strokeLinecap:"round",strokeLinejoin:"round",strokeDasharray:"none"};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[k&&jsxRuntime.jsx(reactflow.BaseEdge,{id:`${e}-highlight`,path:I,style:{...i,stroke:x??u,strokeWidth:F,opacity:.85,strokeDasharray:"18 12",filter:`drop-shadow(0 0 8px ${x??u}) drop-shadow(0 0 16px ${x??u})`,"--rn-edge-highlight-from":`${E}px`,"--rn-edge-highlight-to":`${F}px`}}),jsxRuntime.jsx(reactflow.BaseEdge,{id:e,path:I,markerEnd:p,style:y}),c&&jsxRuntime.jsx(reactflow.EdgeLabelRenderer,{children:jsxRuntime.jsx("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${W}px,${m}px)`,background:"#1f2937",padding:"4px 8px",borderRadius:"4px",fontSize:"10px",color:"white",fontFamily:"monospace",border:`1px solid ${u}`,pointerEvents:"none",zIndex:9999},children:c})})]})};var rn=(t=>(t.FULL="full",t.HALF="half",t))(rn||{});var Vo={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 bt(e){let o=Vo[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 ao(e){let o=Vo[e];if(!o)throw new Error(`Unknown connector type: ${e}`);return o}function zi(e){return ao(e).amperage===16}function jo(e){return e%10<8?"C13":"C19"}function so(e){let o=e.toLowerCase();return o.includes("mx304")||o.includes("mx480")||o.includes("mx960")?"C20":"C14"}var ht=({data:e,selected:o})=>{let{label:t,status:n="active",deviceType:s="server",manufacturer:a,role:l,uHeight:i=1,width:d="full",ports:p=[],rearPorts:h=[],view:u,rackWidthPx:c,frontImageUrl:g,rearImageUrl:x,imageFit:C,imagePosition:k,imageRepeat:E}=e,F=c||300,I=u||(h.length>0&&p.length===0?"rear":"front"),W=I==="rear"?x:g,m=W?{backgroundImage:`url(${W})`,backgroundSize:C??"cover",backgroundPosition:k??"center",backgroundRepeat:E??"no-repeat"}:{},y={};y["net-top"]="front",y["net-bottom"]="front",p.length>0&&p.forEach(B=>{B.ports.forEach(M=>{let v=M.type?.includes("power")?M.label:`${B.name}-${M.label}`;y[v]="front";});}),y["pwr-left-1"]="rear",y["pwr-left-2"]="rear",y["net-right-1"]="rear",y["net-right-2"]="rear",h.length>0&&h.forEach(B=>{B.ports.forEach(M=>{let v=M.type?.includes("power")?M.label:`${B.name}-${M.label}`;y[v]="rear";});});let H=i*20,D=F+4,z=Math.floor(F/2),A=d==="half"?`${z}px`:`${D}px`,X=d==="half"?`${z}px`:void 0,oe=(B,M)=>{let v=[];if(B.length===0)return v;let $=Math.max(4,Math.floor(H*.4)),L=Math.max(2,Math.floor(H*.2));return B.forEach((j,Q)=>{j.ports.forEach((T,P)=>{let J=!!T.type&&T.type.includes("power");if(M==="front"&&J)return;let q=J?`${T.label}`:`${j.name}-${T.label}`,Y=T.connected,O="#6b7280";if(Y)if(T.type?.includes("power"))O=T.type==="power_c19"?"#fbbf24":"#f59e0b";else if(T.type==="console"||T.type==="mgmt")O="#8b5cf6";else if(T.type==="usb")O="#10b981";else switch(T.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 ce=reactflow.Position.Top,pe={width:`${$}px`,height:`${L}px`,background:Y?O:"#6b7280",border:`1px solid ${Y?O:"#374151"}`,borderRadius:"1px",cursor:"pointer"};if(M==="front")P%2===0?(ce=reactflow.Position.Top,pe.transform="translateY(50%)",pe.left=`${P/2*($+2)}px`):(ce=reactflow.Position.Bottom,pe.transform="translateY(-50%)",pe.left=`${(P-1)/2*($+2)}px`);else if((s?.toLowerCase().replace(/_/g,"-")||"")==="patch-panel"||s==="switch")P%2===0?(ce=reactflow.Position.Top,pe.transform="translateY(50%)",pe.left=`${P/2*($+2)}px`):(ce=reactflow.Position.Bottom,pe.transform="translateY(-50%)",pe.left=`${(P-1)/2*($+2)}px`);else if(T.type?.includes("power")){ce=reactflow.Position.Left,pe.transform="translateX(50%)";let Ut=H<=20?10:20,Vt=H<=20?30:50;pe.top=`${Ut+P*Vt}%`;let jt=so(t),Be=bt(jt);pe={...pe,width:`${Be.width}px`,height:`${Be.height}px`,zIndex:10,display:"flex",alignItems:"center",justifyContent:"center",fontSize:Be.fontSize,color:"#1a1a1a",fontFamily:"monospace",fontWeight:"bold",borderRadius:Be.borderRadius,clipPath:Be.clipPath};}else ce=reactflow.Position.Right,pe.transform="translateX(-50%)",pe.top=`${25+P*50}%`;let Ht=(s?.toLowerCase().replace(/_/g,"-")||"")==="patch-panel",se;if(J)se="target";else if(s==="switch"||s==="router")se="source",v.push(jsxRuntime.jsx(reactflow.Handle,{id:`${q}-target`,type:"target",position:ce,style:pe,title:`${j.name} - ${T.label} (input) ${Y?"(connected)":"(disconnected)"}`},`${q}-target`));else if(Ht){se=M==="rear"?"source":"target";let De=M==="rear"?"target":"source";v.push(jsxRuntime.jsx(reactflow.Handle,{id:`${q}-${De}`,type:De,position:ce,style:pe,title:`${j.name} - ${T.label} (${De}) ${Y?"(connected)":"(disconnected)"}`},`${q}-${De}`));}else se=Y?"source":"target";v.push(jsxRuntime.jsx(reactflow.Handle,{id:q,type:se,position:ce,style:pe,title:`${j.name} - ${T.label} ${Y?"(connected)":"(disconnected)"}`,children:J?P+1:void 0},q));});}),v},de=()=>{let B=[],M=Math.max(4,Math.floor(H*.4)),v=Math.max(2,Math.floor(H*.2));if(I==="front"){if(p.length>0)return oe(p,"front");if(s==="switch"&&(t.toLowerCase().includes("agg")||t.toLowerCase().includes("core")||l==="agg"||l==="core"))return ae();B.push(jsxRuntime.jsx(reactflow.Handle,{id:"net-top",type:"target",position:reactflow.Position.Top,style:{width:`${M}px`,height:`${v}px`,background:"#10b981",border:"0.5px solid #059669",borderRadius:"1px",cursor:"pointer",transform:"translateY(50%)"},title:"Network Port (Top)"},"net-top")),B.push(jsxRuntime.jsx(reactflow.Handle,{id:"net-bottom",type:"target",position:reactflow.Position.Bottom,style:{width:`${M}px`,height:`${v}px`,background:"#10b981",border:"0.5px solid #059669",borderRadius:"1px",cursor:"pointer",transform:"translateY(-50%)"},title:"Network Port (Bottom)"},"net-bottom"));}else if(I==="rear"){if(h.length>0)return oe(h,"rear");let $=s==="switch",j=(s?.toLowerCase().replace(/_/g,"-")||"")==="patch-panel";if(!j){let Q=so(t),T=ao(Q),P=bt(Q),J=H<=20?"10%":"25%";B.push(jsxRuntime.jsx(reactflow.Handle,{id:"pwr-left-1",type:"target",position:reactflow.Position.Left,style:{width:`${P.width}px`,height:`${P.height}px`,background:P.color,border:`1px solid ${P.borderColor}`,cursor:"pointer",transform:"translateX(50%)",top:J,zIndex:10,display:"flex",alignItems:"center",justifyContent:"center",fontSize:P.fontSize,color:"#1a1a1a",fontFamily:"monospace",fontWeight:"bold",borderRadius:P.borderRadius,clipPath:P.clipPath},title:`Power Port 1 (${T.type}) - ${T.voltage}V, ${T.amperage}A`,children:"1"},"pwr-1"));let q=H<=20?"50%":"75%";B.push(jsxRuntime.jsx(reactflow.Handle,{id:"pwr-left-2",type:"target",position:reactflow.Position.Left,style:{width:`${P.width}px`,height:`${P.height}px`,background:P.color,border:`1px solid ${P.borderColor}`,cursor:"pointer",transform:"translateX(50%)",top:q,zIndex:10,display:"flex",alignItems:"center",justifyContent:"center",fontSize:P.fontSize,color:"#1a1a1a",fontFamily:"monospace",fontWeight:"bold",borderRadius:P.borderRadius,clipPath:P.clipPath},title:`Power Port 2 (${T.type}) - ${T.voltage}V, ${T.amperage}A`,children:"2"},"pwr-2"));}!$&&!j&&(B.push(jsxRuntime.jsx(reactflow.Handle,{id:"net-right-1",type:"target",position:reactflow.Position.Right,style:{width:`${M}px`,height:`${v}px`,background:"#10b981",border:"0.5px solid #059669",borderRadius:"1px",cursor:"pointer",transform:"translateX(-50%)",top:"25%"},title:"Network Port 1 (Right)"},"net-right-1")),B.push(jsxRuntime.jsx(reactflow.Handle,{id:"net-right-2",type:"target",position:reactflow.Position.Right,style:{width:`${M}px`,height:`${v}px`,background:"#10b981",border:"0.5px solid #059669",borderRadius:"1px",cursor:"pointer",transform:"translateX(-50%)",top:"75%"},title:"Network Port 2 (Right)"},"net-right-2")));}return B},ae=()=>{let B=[],M=Math.max(10,Math.floor(H*.45)),v=Math.max(5,Math.floor(H*.25));for(let $=1;$<=16;$++){let L=jsxRuntime.jsx(reactflow.Handle,{id:`port-${$}`,type:"source",position:reactflow.Position.Top,style:{width:`${M}px`,height:`${v}px`,background:"#10b981",border:"1px solid #059669",borderRadius:"2px",cursor:"pointer",transform:"translateY(50%)",zIndex:1e3,left:`${($-1)*(M+2)}px`},title:`Port ${$}`},`port-${$}`);B.push(L);}for(let $=17;$<=32;$++){let L=$-16,j=jsxRuntime.jsx(reactflow.Handle,{id:`port-${$}`,type:"source",position:reactflow.Position.Bottom,style:{width:`${M}px`,height:`${v}px`,background:"#10b981",border:"1px solid #059669",borderRadius:"2px",cursor:"pointer",transform:"translateY(-50%)",zIndex:1e3,left:`${(L-1)*(M+2)}px`},title:`Port ${$}`},`port-${$}`);B.push(j);}for(let $=1;$<=4;$++){let L=Math.max(4,Math.floor(H*.3)),j=Math.max(3,Math.floor(H*.15));B.push(jsxRuntime.jsx(reactflow.Handle,{id:`uplink-${$}`,type:"source",position:reactflow.Position.Right,style:{width:`${L}px`,height:`${j}px`,background:"#8b5cf6",border:"0.5px solid #7c3aed",borderRadius:"0.5px",cursor:"pointer",transform:"translateX(-50%)"},title:`Uplink ${$}`},`uplink-${$}`));}return B};return jsxRuntime.jsxs("div",{className:`device-node ${o?"selected":""}`,style:{backgroundColor:"#1f2937",...m,border:`1px solid ${_e(n)}`,borderRadius:"2px",padding:"0px",width:A,...X&&{left:X},height:`${H}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:[jsxRuntime.jsxs("div",{style:{textAlign:"center",flex:1,display:"flex",flexDirection:"column",justifyContent:"center",overflow:"hidden",padding:"2px"},children:[jsxRuntime.jsx("div",{style:{fontWeight:"bold",fontSize:"7px",lineHeight:"1.1",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:t}),i>1&&jsxRuntime.jsx("div",{style:{fontSize:"6px",color:"#9ca3af",lineHeight:"1"},children:a})]}),i>1&&jsxRuntime.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"]}),jsxRuntime.jsx("div",{style:{position:"absolute",bottom:"1px",left:"1px",width:"4px",height:"4px",background:_e(n),borderRadius:"50%"}}),de()]})};var Xo=({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,p=()=>{let c=Math.ceil(a/10),g=Array(10).fill(0).map((y,H)=>H<8?"10A":"16A");for(let y=0,H=0;y<c;++y)for(let D=0;D<10&&H<a;++D,++H){g[D];}let E=[],F=15,m=(d-F-3)/(a-9)*.5;for(let y=0;y<a;y++){let H=F-2+m*y,D=`${y+1}`;if(i&&(i==="top"&&y===0||i==="middle"&&y===Math.floor(a/2)||i==="bottom"&&y===a-1)){E.push(h(H));continue}let A=jo(y),X=bt(A),oe=Math.round((l-X.width)/2-1);E.push(jsxRuntime.jsx(reactflow.Handle,{type:"source",position:reactflow.Position.Right,id:D,style:{position:"absolute",left:`${oe}px`,top:`${H-X.height/2}px`,width:`${X.width}px`,height:`${X.height}px`,background:X.color,border:`1px solid ${X.borderColor}`,cursor:"pointer",zIndex:10,display:"flex",alignItems:"center",justifyContent:"center",fontSize:X.fontSize,color:"#1a1a1a",fontFamily:"monospace",fontWeight:"bold",borderRadius:X.borderRadius,clipPath:X.clipPath},title:`Power Port ${y+1} (${A})`,children:y+1},`handle-${D}`));}return E},h=u=>jsxRuntime.jsxs("div",{style:{position:"absolute",left:`${(l-16)/2}px`,top:`${u-12/2}px`,width:"16px",height:"12px",background:"#1a1a1a",border:"1px solid #374151",borderRadius:"1px",display:"flex",flexDirection:"column",padding:"1px",zIndex:10},children:[jsxRuntime.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"}),jsxRuntime.jsx(reactflow.Handle,{type:"source",position:reactflow.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 jsxRuntime.jsxs("div",{className:`vertical-pdu-node ${o?"selected":""}`,style:{background:"linear-gradient(90deg, #2d3748 0%, #1a202c 50%, #2d3748 100%)",border:`1px solid ${_e(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:[jsxRuntime.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:jsxRuntime.jsx("div",{style:{fontWeight:"bold",fontSize:"6px",color:"#e2e8f0"},children:t})}),jsxRuntime.jsx("div",{style:{flex:1,background:"linear-gradient(180deg, #2d3748 0%, #1a202c 50%, #2d3748 100%)",position:"relative",minHeight:`${d-20}px`,overflow:"hidden"},children:p()})]})};var Zo=({data:e,selected:o,id:t})=>{let{lossDb:n,mode:s="single",ribbonFiberIds:a}=e||{},l=reactflow.useEdges(),i=l.find(m=>m.target===t&&m.targetHandle==="left"),d=l.find(m=>m.source===t&&m.sourceHandle==="right"),p=l.find(m=>m.target===t&&m.targetHandle==="right"),h=d||p,u=i?.data?.color||"#555",c=h?.data?.color||"#555",g=s==="ribbon",x=i?.data?.ribbonFiberIds||a,C=h?.data?.ribbonFiberIds||a,k=g&&x?Ae(x):null,E=g&&C?Ae(C):null,F=!!i&&!!h;return jsxRuntime.jsxs("div",{className:`splice-node ${o?"selected":""}`,style:{width:g?85:69,height:g?20:16,borderRadius:8,border:"none",outline:"none",position:"relative",background:"transparent",boxShadow:o?"0 0 0 2px #3b82f6":"none"},children:[g&&k&&E?jsxRuntime.jsxs("div",{style:{position:"absolute",inset:0,borderRadius:8,overflow:"hidden",opacity:.75,pointerEvents:"none",display:"grid",gridTemplateColumns:"1fr 1fr"},children:[jsxRuntime.jsx("div",{style:{display:"flex",flexDirection:"column",width:"100%",height:"100%"},children:k.map((m,y)=>jsxRuntime.jsx("div",{style:{flex:1,background:m.base,opacity:m.striped?.9:1}},`left-${y}`))}),jsxRuntime.jsx("div",{style:{display:"flex",flexDirection:"column",width:"100%",height:"100%"},children:E.map((m,y)=>jsxRuntime.jsx("div",{style:{flex:1,background:m.base,opacity:m.striped?.9:1}},`right-${y}`))})]}):jsxRuntime.jsxs("div",{style:{position:"absolute",inset:0,display:"grid",gridTemplateColumns:"1fr 1fr",borderRadius:8,overflow:"hidden",opacity:.75,pointerEvents:"none"},children:[jsxRuntime.jsx("div",{style:{background:u}}),jsxRuntime.jsx("div",{style:{background:c}})]}),jsxRuntime.jsx("div",{className:"splice-text-overlay",style:{position:"absolute",inset:0,borderRadius:8,pointerEvents:"none",zIndex:1,background:"transparent"}}),F&&jsxRuntime.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}}),F&&typeof n=="number"&&jsxRuntime.jsxs("div",{className:"splice-text-label animate-in",style:{position:"absolute",inset:0,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",fontSize:g?8:9,fontFamily:"monospace",pointerEvents:"none",zIndex:3,fontWeight:"bold",gap:"2px"},children:[jsxRuntime.jsx("div",{children:`${n.toFixed(2)} dB`}),g&&a&&jsxRuntime.jsxs("div",{style:{fontSize:"7px",opacity:.8},children:[a.length,"F"]})]}),jsxRuntime.jsx(reactflow.Handle,{type:"target",position:reactflow.Position.Left,id:"left",isConnectable:true,style:{width:12,height:g&&k?20:12,borderRadius:g&&k?"6px":"50%",border:"none",background:g&&k?`linear-gradient(to bottom, ${k.map(m=>m.base).join(", ")})`:u,zIndex:100,cursor:"crosshair",left:-6,top:"50%",transform:"translateY(-50%)"}}),jsxRuntime.jsx(reactflow.Handle,{type:"source",position:reactflow.Position.Right,id:"right",isConnectable:true,style:{width:12,height:g&&E?20:12,borderRadius:g&&E?"6px":"50%",border:"none",background:g&&E?`linear-gradient(to bottom, ${E.map(m=>m.base).join(", ")})`:c,zIndex:100,cursor:"crosshair",right:-6,top:"50%",transform:"translateY(-50%)"}}),jsxRuntime.jsx(reactflow.Handle,{type:"target",position:reactflow.Position.Right,id:"right",isConnectable:true,style:{width:12,height:g&&E?20:12,borderRadius:g&&E?"6px":"50%",border:"none",background:g&&E?`linear-gradient(to bottom, ${E.map(m=>m.base).join(", ")})`:c,zIndex:100,cursor:"crosshair",right:-6,top:"50%",transform:"translateY(-50%)"}})]})};var Mt=20,lo=36;var dt=32,dn=4,Ze=12,Oi=69,lt=80,qo=(lt-Oi)/2;var Jo=(e,o,t,n)=>{if(!e.parentId||e.parentId!==o.id)return t;let s=e.data?.mode==="ribbon",a=s?lo:Mt,l=s?32:16,i=dt,d=t.y-i,p=Math.round(d/a)+1,u=Math.max(1,Math.min(Ze,p));if(!Wt(o,e,u,n)){let x=Lt(o,e,n,u);if(x!==u){let C=(a-l)/2;return {x:qo,y:i+(x-1)*a+C,holderPosition:x}}}let c=(a-l)/2,g=i+(u-1)*a+c;return {x:qo,y:g,holderPosition:u}},Wt=(e,o,t,n)=>!n.filter(a=>a.parentId===e.id&&a.type==="splice"&&a.id!==o.id).some(a=>a.data.holderPosition===t),Lt=(e,o,t,n=1)=>{for(let s=n;s<=Ze;s++)if(Wt(e,o,s,t))return s;for(let s=n-1;s>=1;s--)if(Wt(e,o,s,t))return s;return 1},Bi=(e,o)=>zt(e,o,false),zt=(e,o,t=false)=>{let n=dt,s=t?lo:Mt,l=(s-(t?32:16))/2,i=n+(o-1)*s+l;return {x:qo,y:i}};var tr=({data:e,selected:o})=>{let{label:t="Splice Tray"}=e||{},[n,s]=gt.useState(false),a=()=>{if(!n)return null;let l=[],i=dt;for(let d=1;d<=Ze;d++){let p=i+(d-1)*Mt;l.push(jsxRuntime.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:`${Mt}px`,display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1},children:["H",d]},d));}return l};return jsxRuntime.jsxs("div",{className:`splice-tray-node ${o?"selected":""}`,style:{background:"transparent",border:"none",borderRadius:"8px",padding:0,width:`${lt}px`,height:`${dt+Ze*lo+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:[jsxRuntime.jsxs("div",{style:{textAlign:"center",marginBottom:0,zIndex:2,background:"#1f2937",padding:"2px",position:"relative",height:`${dt}px`,display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"center",gap:"6px",borderRadius:"8px"},children:[jsxRuntime.jsx("div",{style:{fontWeight:"bold",fontSize:"10px"},children:t}),jsxRuntime.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(),jsxRuntime.jsx("div",{style:{position:"absolute",top:dt,left:0,right:0,bottom:0,pointerEvents:"none"}})]})};var or=({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=reactflow.useEdges(),d=`tube-${s}`,p=i.find(de=>de.source===t&&de.sourceHandle===d||de.target===t&&de.targetHandle===d),h=p?.data?.color,u=xe((s-1)%12+1),c=h||u,g=Math.max(1,Math.min(24,Number(n)||12)),x=14,C=4,k=1,E=2,F=20,I=g*x+(g-1)*C,W=Math.max(60,I+k*2+E*2),m=a==="left"?reactflow.Position.Left:a==="right"?reactflow.Position.Right:reactflow.Position.Bottom,y=m!==reactflow.Position.Bottom,H=y?14:20,D=y?8:20,z=y?`inset ${m===reactflow.Position.Left?"-4px":"4px"} 0 0 rgba(0, 0, 0, 0.35)`:"none",A=p?c:y?`linear-gradient(${m===reactflow.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%)`,X={width:H,height:D,borderRadius:y?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?z:`${z}${z!=="none"?", ":""}0 0 8px ${c}`,transition:"opacity 0.2s, box-shadow 0.2s",...m===reactflow.Position.Left?{left:-(H-4)}:m===reactflow.Position.Right?{right:-(H-4)}:{}},oe=gt.useMemo(()=>{let de=[],ae=W-E*2-k*2,B,M,v=false;a==="left"?(B=k,M=reactflow.Position.Top):a==="right"?(B=k+ae-I,M=reactflow.Position.Top,v=true):(B=k+(ae-I)/2,M=reactflow.Position.Top);for(let $=0;$<g;$++){let L=v?g-$:$+1,j=ze(L),Q=xe(L),T=`fiber-${L}`,P=i.find(ce=>ce.source===t&&ce.sourceHandle===T||ce.target===t&&ce.targetHandle===T),J=null;P&&(P.data?.isRibbon||P.data?.ribbonFiberIds&&Array.isArray(P.data.ribbonFiberIds)?J="#808080":J=P.data?.color||null);let q=B+$*(x+C),Y=k,O={position:"absolute",left:`${q}px`,top:`${Y}px`,width:x,height:x,borderRadius:"50%",border:"none",zIndex:10,cursor:"pointer","--fiber-bg":J||(l?"#808080":Q)};J?O.backgroundColor=J:l?O.backgroundColor="#808080":j.backgroundImage?O["--fiber-bg-image"]=j.backgroundImage:O.backgroundColor=Q,de.push(jsxRuntime.jsxs(gt__default.default.Fragment,{children:[jsxRuntime.jsx(reactflow.Handle,{id:T,type:"target",position:M,className:"tube-fiber-handle",isConnectable:true,style:O,"data-fiber-idx":L,"data-fiber-color":J||(l?"#808080":Q)}),jsxRuntime.jsx(reactflow.Handle,{id:T,type:"source",position:M,className:"tube-fiber-handle",isConnectable:true,style:O,"data-fiber-idx":L,"data-fiber-color":J||(l?"#808080":Q)})]},`fiber-${L}`));}return de},[g,a,W,i,t,x,C,k,E,I,l]);return jsxRuntime.jsxs("div",{style:{width:W,height:F,borderRadius:4,background:"#111827",border:`${E}px solid ${o?"#3b82f6":c}`,position:"relative",boxShadow:o?`0 0 0 ${E}px #3b82f6`:"0 2px 4px rgba(0,0,0,0.2)",padding:k,boxSizing:"border-box",overflow:"visible"},children:[oe,jsxRuntime.jsx(reactflow.Handle,{id:d,type:"target",position:m,isConnectable:true,className:"tube-connection-handle",style:X,"data-tube-idx":s,"data-tube-color":c,title:p?"Connected - drag to reconnect":"Drag to connect cable tube"}),jsxRuntime.jsx(reactflow.Handle,{id:d,type:"source",position:m,isConnectable:true,className:"tube-connection-handle",style:X,"data-tube-idx":s,"data-tube-color":c,title:p?"Connected - drag to reconnect":"Drag to connect cable tube"})]})};var ir=({data:e,selected:o})=>{let{fiberCount:t,cableId:n="CBL-002",label:s,color:a,rotation:l}=e||{},i=gt__default.default.useRef(null);gt__default.default.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)),p=10,h=2,u=6,c=u+p+4,g=60,x=Math.max(120,d*(p+h)+u*2),k=s??`${d}f Cable`,E=n?`Cable ID ${n}`:void 0,F=xe(1),I=a||F,W=o?"#3b82f6":I,m=typeof l=="number"?l:0,y=M=>{let v=(M%360+360)%360;return v>=315||v<45?reactflow.Position.Top:v>=45&&v<135?reactflow.Position.Right:v>=135&&v<225?reactflow.Position.Bottom:reactflow.Position.Left},H=()=>{let M=[],v=y(m);for(let $=0;$<d;$++){let L=$+1,j=ze(L),Q=xe(L),T=u+$*(p+h),P=-5,J=j.backgroundImage?j.backgroundImage:Q,q={position:"absolute",left:`${T}px`,top:`${P}px`,width:p,height:p,borderRadius:"50%",border:"none",background:J,backgroundColor:Q,zIndex:10,cursor:"pointer","--fiber-bg":Q};j.backgroundImage&&(q["--fiber-bg-image"]=j.backgroundImage);let Y=`fiber-${L}`;M.push(jsxRuntime.jsxs(gt__default.default.Fragment,{children:[jsxRuntime.jsx(reactflow.Handle,{id:Y,type:"target",position:v,className:"tube-fiber-handle",isConnectable:true,style:q,"data-fiber-idx":L,"data-fiber-color":Q}),jsxRuntime.jsx(reactflow.Handle,{id:Y,type:"source",position:v,className:"tube-fiber-handle",isConnectable:true,style:q,"data-fiber-idx":L,"data-fiber-color":Q})]},`fiber-${L}`));}return M},D="cable-button",z=8,A={width:z,height:z,borderRadius:"50%",background:I,backgroundColor:I,border:`1px solid ${I}`,cursor:"pointer",zIndex:10},X=2,de=(M=>{let v=(M%360+360)%360;return v>=315||v<45?reactflow.Position.Bottom:v>=45&&v<135?reactflow.Position.Left:v>=135&&v<225?reactflow.Position.Top:reactflow.Position.Right})(m),ae={width:x,height:g,position:"relative",transform:`rotate(${m}deg)`,transformOrigin:"center center","--rotation":`${m}deg`},B={width:"100%",height:"100%",borderRadius:4,background:"#111827",border:`${X}px solid ${W}`,boxShadow:o?"0 0 0 2px #3b82f6":"0 2px 4px rgba(0,0,0,0.2)",padding:u,paddingTop:c,boxSizing:"border-box",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",color:"#e5e7eb",fontFamily:"monospace",textAlign:"center",gap:2};return jsxRuntime.jsx("div",{ref:i,style:ae,children:jsxRuntime.jsxs("div",{style:B,children:[H(),jsxRuntime.jsx(reactflow.Handle,{id:D,type:"source",position:de,className:"cable-button-handle",isConnectable:true,style:A,"data-handle-type":"cable-button","data-cable-color":I}),jsxRuntime.jsx(reactflow.Handle,{id:D,type:"target",position:de,className:"cable-button-handle",isConnectable:true,style:A,"data-handle-type":"cable-button","data-cable-color":I}),jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:2,transform:"translateX(2px)"},children:[jsxRuntime.jsx("div",{style:{fontSize:11,fontWeight:600,textTransform:"uppercase",letterSpacing:.5},children:k}),E&&jsxRuntime.jsx("div",{style:{fontSize:10,opacity:.8},children:E})]})]})})};var sr=({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||{},p=Math.max(1,Math.min(24,Number(t)||12)),h=Math.max(1,Number(i)||1),u=14,c=10,g=3,x=6,C=x+c+4,k=60,E=Math.max(120,p*(u+g)+x*2),F=s??p*(Number(n)||12),I=l??`${F}f Cable`,W=a?`Cable ID ${a}`:void 0,m=xe(h),y=d||m,H=o?"#3b82f6":y,D=()=>{let de=[];for(let ae=0;ae<p;ae++){let B=h+ae,M=ze(B),v=xe(B),$=x+ae*(u+g),L=-5,j=M.backgroundImage?M.backgroundImage:v,Q={position:"absolute",left:`${$}px`,top:`${L}px`,width:u,height:c,borderRadius:6,border:"none",background:j,backgroundColor:v,zIndex:10,cursor:"pointer","--fiber-bg":v};M.backgroundImage&&(Q["--fiber-bg-image"]=M.backgroundImage);let T=`tube-${B}`;de.push(jsxRuntime.jsxs(gt__default.default.Fragment,{children:[jsxRuntime.jsx(reactflow.Handle,{id:T,type:"target",position:reactflow.Position.Top,className:"tube-fiber-handle",isConnectable:true,style:Q,"data-fiber-idx":B,"data-tube-idx":B,"data-tube-color":v}),jsxRuntime.jsx(reactflow.Handle,{id:T,type:"source",position:reactflow.Position.Top,className:"tube-fiber-handle",isConnectable:true,style:Q,"data-fiber-idx":B,"data-tube-idx":B,"data-tube-color":v})]},`tube-${B}`));}return de},z="cable-button",A=8,X={width:A,height:A,borderRadius:"50%",background:y,backgroundColor:y,border:`1px solid ${y}`,cursor:"pointer",zIndex:10};return jsxRuntime.jsxs("div",{style:{width:E,height:k,borderRadius:4,background:"#111827",border:`2px solid ${H}`,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:[D(),jsxRuntime.jsx(reactflow.Handle,{id:z,type:"source",position:reactflow.Position.Bottom,className:"cable-button-handle",isConnectable:true,style:X,"data-handle-type":"cable-button","data-cable-color":y}),jsxRuntime.jsx(reactflow.Handle,{id:z,type:"target",position:reactflow.Position.Bottom,className:"cable-button-handle",isConnectable:true,style:X,"data-handle-type":"cable-button","data-cable-color":y}),jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:2},children:[jsxRuntime.jsx("div",{style:{fontSize:11,fontWeight:600,textTransform:"uppercase",letterSpacing:.5},children:I}),W&&jsxRuntime.jsx("div",{style:{fontSize:10,opacity:.8},children:W})]})]})};var dr=({data:e,selected:o,id:t})=>{let{connector:n="LC",couplerFiberCount:s,label:a,portLabelsLeft:l,portLabelsRight:i}=e||{},d=reactflow.useEdges(),p=typeof s=="number"&&[1,2,4].includes(s)?s:2,h=Math.max(1,Math.min(4,p)),u=9,c=3,g=3,x=60,C=30,k=h*u+(h-1)*c,E=Math.max(C,k+g*2),F=Math.max(x,80),I=(y,H)=>{let D=`${y}-${H+1}`;return d.find(A=>A.source===t&&A.sourceHandle===D||A.target===t&&A.targetHandle===D)?.data?.color||"#555"},W=y=>{let H=[],D=y==="left"?reactflow.Position.Left:reactflow.Position.Right,z=y==="left"?l:i;for(let A=0;A<h;A++){let X=A+1,oe=`${y}-${X}`,de=I(y,A),M=g+(E-k)/2+A*(u+c),v={position:"absolute",left:y==="left"?-5:void 0,right:y==="right"?-5:void 0,top:`${M}px`,width:u,height:u,borderRadius:"50%",border:"none",background:de,zIndex:100,cursor:"crosshair",transform:"translateY(-50%)"};H.push(jsxRuntime.jsxs(gt__default.default.Fragment,{children:[jsxRuntime.jsx(reactflow.Handle,{id:oe,type:"target",position:D,isConnectable:true,style:v}),jsxRuntime.jsx(reactflow.Handle,{id:oe,type:"source",position:D,isConnectable:true,style:v})]},oe)),z&&z[A]&&H.push(jsxRuntime.jsx("div",{style:{position:"absolute",left:y==="left"?-30:void 0,right:y==="right"?-30:void 0,top:`${M}px`,transform:"translateY(-50%)",fontSize:"8px",color:"#9ca3af",fontFamily:"monospace",pointerEvents:"none",textAlign:y==="left"?"right":"left",width:"25px"},children:z[A]},`${oe}-label`));}return H},m=a||`${n}-${h}f`;return jsxRuntime.jsxs("div",{className:`coupler-node ${o?"selected":""}`,style:{width:F,height:E,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:`${g}px`,boxSizing:"border-box"},children:[W("left"),jsxRuntime.jsx("div",{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",textAlign:"center",pointerEvents:"none",zIndex:1},children:jsxRuntime.jsx("div",{style:{fontWeight:"bold",fontSize:"9px"},children:m})}),W("right")]})};var ut=32,mo=30,Zi=24,qi=80,bo=400,ho=300,hn=2,pt=8,mn=120;function cr(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,p=n*s+(n-1)*a,h=Math.max(d,p+l*2);return {width:Math.max(i,80),height:h}}function yo(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:lt,height:0}}function wn(e){return e.type==="coupler"?cr(e):e.type==="tube"?yo(e):e.type==="splice-tray"?yn():{width:80,height:30}}function lr(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||bo}function Ji(e){return e.data?.panelHeight||ho}function kn(e){return Nn(e)-hn*2-pt*2}function Qi(e,o){return kn(e)-o}function Cn(e,o=mo){return Math.floor(e/o)+1}function vn(e,o=mo){return (e-1)*o}function ea(e,o,t){let n=mo,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||bo,height:e.data?.panelHeight||ho};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,p=0;for(let c of o)if(c.type==="tube"){let g=yo(c);g.width>d&&(d=g.width);}else if(c.type==="coupler"){let g=cr(c);g.width>p&&(p=g.width);}let h=d+mn+lt+p+5,u=0;a=u+h+u;}else a=lr(o)+4;a=Math.max(e.data?.panelWidth||bo,a);let l=xn(o,ut),i=Math.max(e.data?.panelHeight||ho,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,p=0,h=o.filter(c=>c.type==="tube"),u=o.filter(c=>c.type==="splice-tray");if(h.length>0&&u.length>0){let c=u.map(x=>x.position?.x||0),g=c.reduce((x,C)=>x+C,0)/c.length;for(let x of h){let C=yo(x);(x.position?.x||0)<g?C.width>i&&(i=C.width):C.width>d&&(d=C.width);}u.length>0&&(p=lt),s=pt+i+gn+p+gn+d+5;}else s=lr(o)+pt+5;}else s=lr(o)+pt+5;s=Math.max(e.data?.closureWidth||e.data?.panelWidth||fn,s);let a=xn(o,ut),l=Math.max(e.data?.closureHeight||e.data?.panelHeight||bn,a+pt);return {width:s,height:l}}var fr=({data:e,selected:o,id:t})=>{let{label:n="Patch Panel",header:s,panelWidth:a,panelHeight:l}=e||{},{getNodes:i,setNodes:d}=reactflow.useReactFlow(),p=gt.useRef(false),h=gt.useRef([]),u=gt.useMemo(()=>{let I=i().filter(W=>W.parentId===t);return (I.length!==h.current.length||I.some((W,m)=>W.id!==h.current[m]?.id))&&(h.current=I),h.current},[i,t]),c=gt.useMemo(()=>({id:t,type:"patch-panel",position:{x:0,y:0},data:{...e,panelWidth:a,panelHeight:l}}),[t,e,a,l]),g=gt.useMemo(()=>a&&l?{width:a,height:l}:u.length===0?{width:a||400,height:l||300}:pr(c,u),[u,c,a,l]);gt.useEffect(()=>{if(a&&l||p.current)return;let F=a,I=l,W=Math.abs((F||0)-g.width),m=Math.abs((I||0)-g.height);(W>1||m>1)&&(p.current=true,d(y=>y.map(H=>H.id===t?{...H,data:{...H.data,panelWidth:g.width,panelHeight:g.height}}:H)),setTimeout(()=>{p.current=false;},0));},[t,g.width,g.height,a,l,d]);let x=g.width,C=g.height,k=ut,E=s||n;return jsxRuntime.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:[jsxRuntime.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:jsxRuntime.jsx("div",{style:{fontWeight:"bold",fontSize:"11px"},children:E})}),jsxRuntime.jsx("div",{style:{position:"absolute",top:k,left:0,right:0,bottom:0,pointerEvents:"none",overflow:"visible"}})]})};var mr=({data:e,selected:o,id:t})=>{let{label:n="Closure",header:s,closureWidth:a,closureHeight:l,panelWidth:i,panelHeight:d}=e||{},{getNodes:p,setNodes:h}=reactflow.useReactFlow(),u=gt.useRef(false),c=gt.useRef([]),g=gt.useMemo(()=>{let y=p().filter(H=>H.parentId===t);return (y.length!==c.current.length||y.some((H,D)=>H.id!==c.current[D]?.id))&&(c.current=y),c.current},[p,t]),x=gt.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=gt.useMemo(()=>a&&l?{width:a,height:l}:i&&d?{width:i,height:d}:g.length===0?{width:a||i||400,height:l||d||300}:Hn(x,g),[g,x,a,l,i,d]);gt.useEffect(()=>{if(a&&l||i&&d||u.current)return;let m=a||i,y=l||d,H=Math.abs((m||0)-C.width),D=Math.abs((y||0)-C.height);(H>1||D>1)&&(u.current=true,h(z=>z.map(A=>A.id===t?{...A,data:{...A.data,closureWidth:C.width,closureHeight:C.height}}:A)),setTimeout(()=>{u.current=false;},0));},[t,C.width,C.height,a,l,i,d,h]);let k=C.width,E=C.height,F=ut,I=s||n,W=k/2;return jsxRuntime.jsxs("div",{className:`closure-node ${o?"selected":""}`,style:{background:"transparent",border:"none",borderRadius:`${W}px ${W}px 12px 12px`,padding:0,width:`${k}px`,height:`${E}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:[jsxRuntime.jsx("div",{style:{textAlign:"center",marginBottom:0,zIndex:2,background:"#374151",padding:"6px 12px",position:"relative",height:`${F}px`,display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"center",gap:"6px",borderRadius:`${W}px ${W}px 0 0`,borderBottom:"1px solid #4b5563"},children:jsxRuntime.jsx("div",{style:{fontWeight:"bold",fontSize:"11px"},children:I})}),jsxRuntime.jsx("div",{style:{position:"absolute",top:F,left:0,right:0,bottom:0,pointerEvents:"none",overflow:"visible"}})]})};var wr=({data:e,selected:o,id:t})=>{let{label:n,splitterType:s="splitter",inputCount:a=1,outputCount:l=8}=e||{},i=reactflow.useEdges(),d=n||(s==="WDM"?"WDM":"Splitter"),p=9,h=3,u=3,c=50,g=30,x=Math.min(Math.max(a||1,1),2),C=x*p+(x-1)*h,k=Math.min(l||8,48),E=k*p+(k-1)*h,F=Math.max(C,E),I=Math.max(g,F+u*2),W=Math.max(c,50),m=ae=>i.find(M=>M.source===t&&M.sourceHandle===ae||M.target===t&&M.targetHandle===ae)?.data?.color||"#555",y=()=>{let ae=[],B=u+(I-C)/2;for(let M=0;M<x;M++){let v=`input-${M+1}`,$=B+M*(p+h),L=m(v),j={position:"absolute",left:-5,top:`${$}px`,width:p,height:p,borderRadius:"50%",border:"none",background:L,zIndex:100,cursor:"crosshair",transform:"translateY(-50%)"};ae.push(jsxRuntime.jsxs(gt__default.default.Fragment,{children:[jsxRuntime.jsx(reactflow.Handle,{id:`${v}-target`,type:"target",position:reactflow.Position.Left,isConnectable:true,style:j}),jsxRuntime.jsx(reactflow.Handle,{id:`${v}-source`,type:"source",position:reactflow.Position.Left,isConnectable:true,style:j})]},v));}return ae},H=()=>{let ae=[],B=u+(I-E)/2;for(let M=0;M<k;M++){let v=`output-${M+1}`,$=B+M*(p+h),L=m(v),j={position:"absolute",right:-5,top:`${$}px`,width:p,height:p,borderRadius:"50%",border:"none",background:L,zIndex:100,cursor:"crosshair",transform:"translateY(-50%)"};ae.push(jsxRuntime.jsxs(gt__default.default.Fragment,{children:[jsxRuntime.jsx(reactflow.Handle,{id:`${v}-target`,type:"target",position:reactflow.Position.Right,isConnectable:true,style:j}),jsxRuntime.jsx(reactflow.Handle,{id:`${v}-source`,type:"source",position:reactflow.Position.Right,isConnectable:true,style:j})]},v));}return ae},D=Math.max(C+u*4,g*.6),z=(I-D)/2,A=z+D,X=0,oe=I,de=o?"#3b82f6":"#4b5563";return jsxRuntime.jsxs("div",{className:`trapezoid-node ${o?"selected":""}`,style:{width:W,height:I,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:`${u}px`,boxSizing:"border-box"},children:[jsxRuntime.jsx("svg",{width:W,height:I,viewBox:`0 0 ${W} ${I}`,style:{position:"absolute",top:0,left:0,width:`${W}px`,height:`${I}px`,pointerEvents:"none",zIndex:0},children:jsxRuntime.jsx("polygon",{points:`0,${z} 0,${A} ${W},${oe} ${W},${X}`,fill:"#1f2937",stroke:de,strokeWidth:"2"})}),y(),jsxRuntime.jsx("div",{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",textAlign:"center",pointerEvents:"none",zIndex:1},children:jsxRuntime.jsx("div",{style:{fontWeight:"bold",fontSize:"9px"},children:d})}),H()]})};var In=e=>e?.type==="tube"||e?.type==="splice"||e?.type==="coupler"||e?.type==="fibre-split"||e?.type==="cable"||e?.type==="multi-tube-cable",wt=(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(T=>T.id===e.source),n=o.nodes.find(T=>T.id===e.target),s=ie(t,e.sourceHandle),a=ie(n,e.targetHandle),l=o.edges.some(T=>T.source===e.source?ie(t,T.sourceHandle)===s:T.target===e.source?ie(t,T.targetHandle)===s:false),i=o.edges.some(T=>T.target===e.target?ie(n,T.targetHandle)===a:T.source===e.target?ie(n,T.sourceHandle)===a:false),d=wt(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 p=(T,P)=>(T?.type==="tube"||T?.type==="cable")&&!!P&&P.startsWith("fiber-"),h=(T,P)=>(T?.type==="tube"||T?.type==="multi-tube-cable")&&!!P&&P.startsWith("tube-"),u=(T,P)=>T?.type==="multi-tube-cable"&&!!P&&P.startsWith("tube-"),c=(T,P)=>T?.type==="tube"&&!!P&&P.startsWith("tube-"),g=(T,P)=>(T?.type==="cable"||T?.type==="multi-tube-cable")&&P==="cable-button",x=(T,P)=>T?.type==="splice"&&(P==="left"||P==="right"),C=(T,P)=>T?.type==="coupler"&&!!P&&(P.startsWith("left-")||P.startsWith("right-")),k=(T,P)=>{if(T?.type!=="fibre-split"||!P)return false;let J=ie(T,P);return J.startsWith("input-")||J.startsWith("output-")};if(!d)return {valid:true};if(t?.type==="splice"&&n?.type==="splice"){let T=t.data?.mode==="ribbon",P=n.data?.mode==="ribbon";if(T!==P)return {valid:false,reason:"Ribbon splices can only connect to other ribbon splices"}}let E=p(t,e.sourceHandle),F=p(n,e.targetHandle),I=x(t,e.sourceHandle),W=x(n,e.targetHandle),m=C(t,e.sourceHandle),y=C(n,e.targetHandle),H=k(t,e.sourceHandle),D=k(n,e.targetHandle),z=g(t,e.sourceHandle),A=g(n,e.targetHandle),X=u(t,e.sourceHandle),oe=u(n,e.targetHandle),de=c(t,e.sourceHandle),ae=c(n,e.targetHandle),B=h(t,e.sourceHandle),M=h(n,e.targetHandle);return E&&W||F&&I||(I&&(y||D)||W&&(m||H))||(m&&(y||D||W)||y&&(m||H||I))||z&&A||(X&&ae||oe&&de)?{valid:true}:B&&M?{valid:false,reason:"Tube handles can only connect between cable and tube nodes"}:{valid:false,reason:"Connection not allowed by fiber rules"}}function No(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 p of d.ports||[])if((!!p.type&&String(p.type).includes("power")?p.label:`${d.name}-${p.label}`)===t)return "front";for(let d of l)for(let p of d.ports||[])if((!!p.type&&String(p.type).includes("power")?p.label:`${d.name}-${p.label}`)===t)return "rear"}function xr(e={},o={}){let t={nodes:e.nodes??[],edges:e.edges??[],debug:e.debug??false},n=new Set;return {getState:()=>t,setState:u=>{t={...t,...u},n.forEach(c=>c(t));},subscribe:u=>(n.add(u),()=>n.delete(u)),selectEdgeZIndex:u=>{let c=t.nodes.find(m=>m.id===u.target);if(!c||c.type!=="device")return 1e3;let g=c.data?.view||"front",x=No(u.targetHandle||"",c);if(x)return g===x?1e3:500;let C=(u.targetHandle||"").toString(),k=C.toLowerCase(),E=k.startsWith("pwr")||k.startsWith("power"),F=k.startsWith("net-")||k.startsWith("port-")||k.startsWith("uplink-")||k.includes("fiber")||k.includes("ports"),I=/^[A-Z0-9]+-\d+$/i.test(C)&&!k.startsWith("pwr")&&!k.startsWith("power"),W=F||I;return E?g==="rear"?1e3:500:W?g==="front"?1e3:500:1e3},validateConnection:u=>(o.validateConnection||la)(u,t),selectNodeById:u=>t.nodes.find(c=>c.id===u),selectConnectedEdges:u=>t.edges.filter(c=>c.source===u||c.target===u)}}function ca(e){let o=s=>e.subscribe(s),t=()=>e.getState();return gt.useSyncExternalStore(o,t,t)}function kr(e){let o=n=>e.subscribe(n),t=()=>e.getState().nodes;return gt.useSyncExternalStore(o,t,t)}function Cr(e){let o=n=>e.subscribe(n),t=()=>e.getState().edges;return gt.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 ko(e,o){let t=Tn(o);return e.x>=t.left&&e.x<=t.right&&e.y>=t.top&&e.y<=t.bottom}function Co(e,o){let t=null,n=1/0;for(let s of o){if(!ko(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 Pe(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 p=o.find(C=>a==="source"?C.source===d&&C.sourceHandle===i:C.target===d&&C.targetHandle===i);if(!p)return null;let h=o.filter(C=>C.id!==p.id),u=reactflow.addEdge(t,h),c=u[u.length-1],g=s({...t,id:c.id,type:n}),x={...c,type:n,zIndex:g,style:{...c.style,zIndex:g},data:l!==void 0?l:c.data};return [...u.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=gt__default.default.useRef(null),n=gt__default.default.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 gt__default.default.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]),jsxRuntime.jsx("div",{ref:n,style:{width:"100%",height:"100%"},children:o})},Mn=(e,o,t)=>({rack:n=>jsxRuntime.jsx(Ce,{type:"rack",children:jsxRuntime.jsx(Ao,{...n,onViewChange:e,onRackFaceChange:o,isDragOver:t?t()===n.id:false})}),fiber:n=>jsxRuntime.jsx(Ce,{type:"fiber",children:jsxRuntime.jsx(Oo,{...n})}),device:n=>jsxRuntime.jsx(Ce,{type:"device",children:jsxRuntime.jsx(ht,{...n})}),server:n=>jsxRuntime.jsx(Ce,{type:"server",children:jsxRuntime.jsx(ht,{...n})}),switch:n=>jsxRuntime.jsx(Ce,{type:"switch",children:jsxRuntime.jsx(ht,{...n})}),router:n=>jsxRuntime.jsx(Ce,{type:"router",children:jsxRuntime.jsx(ht,{...n})}),"vertical-pdu":n=>jsxRuntime.jsx(Ce,{type:"vertical-pdu",children:jsxRuntime.jsx(Xo,{...n})}),splice:n=>jsxRuntime.jsx(Ce,{type:"splice",children:jsxRuntime.jsx(Zo,{...n})}),"splice-tray":n=>jsxRuntime.jsx(Ce,{type:"splice-tray",children:jsxRuntime.jsx(tr,{...n})}),tube:n=>jsxRuntime.jsx(Ce,{type:"tube",children:jsxRuntime.jsx(or,{...n})}),cable:n=>jsxRuntime.jsx(Ce,{type:"cable",children:jsxRuntime.jsx(ir,{...n})}),"multi-tube-cable":n=>jsxRuntime.jsx(Ce,{type:"multi-tube-cable",children:jsxRuntime.jsx(sr,{...n})}),coupler:n=>jsxRuntime.jsx(Ce,{type:"coupler",children:jsxRuntime.jsx(dr,{...n})}),"patch-panel":n=>jsxRuntime.jsx(Ce,{type:"patch-panel",children:jsxRuntime.jsx(fr,{...n})}),closure:n=>jsxRuntime.jsx(Ce,{type:"closure",children:jsxRuntime.jsx(mr,{...n})}),"fibre-split":n=>jsxRuntime.jsx(Ce,{type:"fibre-split",children:jsxRuntime.jsx(wr,{...n})})}),Ca={fiber:no,ethernet:no,power:Bo,smoothstep:Zr,step:Qr,"thick-cable":on},va=({nodes:e,edges:o,initialNodes:t,initialEdges:n,onNodesChange:s,onEdgesChange:a,store:l,debug:i,onNodeClick:d,onEdgeClick:p,nodeTypes:h,edgeTypes:u,onConnect:c,onEdgeUpdate:g,isValidConnection:x,connectionMode:C,onViewChange:k,onRackFaceChange:E,className:F,style:I,alignRacksToBottom:W,colorMode:m="dark",onInit:y,onFlowMethods:H,showDownloadButton:D=false,downloadButtonPosition:z="top-right",downloadButtonText:A="Download Image",downloadButtonStyle:X,useSmoothstepEdgesForTubes:oe=false,connectOnClick:de=true,panOnDrag:ae=true,panOnScroll:B=true,zoomOnScroll:M=true,fitViewOptions:v})=>{let $=gt.useCallback((r,f)=>{let b=new Map,w=[],S=[],R=(_,Z)=>!_||!Z?false:!!(_.startsWith("tube-")||Z.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 Z=f.find(Re=>Re.id===_.source),K=f.find(Re=>Re.id===_.target),me=`${_.source}:${_.sourceHandle}`,ge=b.get(me),ve=R(_.sourceHandle,Z),ye=`${_.target}:${_.targetHandle}`,he=b.get(ye),re=R(_.targetHandle,K);if(ge&&!ve){i&&console.warn("Duplicate connection detected on source handle, removing:",{handle:me,existingEdge:ge.id,duplicateEdge:_.id}),S.push(_);continue}if(he&&!re){i&&console.warn("Duplicate connection detected on target handle, removing:",{handle:ye,existingEdge:he.id,duplicateEdge:_.id}),S.push(_);continue}w.push(_),ge||b.set(me,_),he||b.set(ye,_);}return i&&S.length>0&&console.log(`Filtered ${S.length} duplicate edge(s) from initial edges`),w},[i]),L=Array.isArray(e)&&Array.isArray(o),j=gt__default.default.useMemo(()=>L?e||[]:t||e||[],[L,e,t]),Q=gt__default.default.useMemo(()=>L?o||[]:n||o||[],[L,o,n]),T=gt__default.default.useMemo(()=>$(Q,j),[Q,j,$]),P=gt__default.default.useMemo(()=>l||xr({nodes:j,edges:T,debug:i}),[l,L,i,T]),J=kr(P),q=Cr(P),[Y,O,ce]=reactflow.useNodesState(J),[pe,te,Ht]=reactflow.useEdgesState(q),se=Fn(P),De=gt.useRef(null),[$e,Rr]=gt.useState(false);gt.useEffect(()=>{let r=()=>{Rr(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:Ut,setViewport:Vt,setNodes:jt,setEdges:Be,getNodes:Ue,getEdges:Ir,fitView:Po}=reactflow.useReactFlow();gt.useEffect(()=>{H&&H({toObject:Ut,setViewport:Vt,setNodes:r=>{jt(r),P.setState({nodes:r});},setEdges:r=>{Be(r),P.setState({edges:r});},toImage:r=>De.current?htmlToImage.toPng(De.current,r):Promise.reject(new Error("ReactFlow wrapper not available")),getNodes:()=>Ue(),getEdges:()=>Ir(),fitView:r=>{if(r?.nodes&&Array.isArray(r.nodes)&&r.nodes.length>0){let f=r.nodes.map(S=>Ue().find(R=>R.id===S)).filter(S=>S!==void 0),{nodes:b,...w}=r;Po({...w,nodes:f});}else {let{nodes:f,...b}=r||{};Po(b);}}});},[H,Ut,Vt,jt,Be,P,Po,Ue,Ir]);let ti=gt.useCallback(()=>{if(!De.current){i&&console.error("ReactFlow wrapper ref is not available");return}htmlToImage.toPng(De.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 f=document.createElement("a");f.download=`network-diagram-${new Date().toISOString().split("T")[0]}.png`,f.href=r,f.click();}).catch(r=>{i&&console.error("Error downloading image:",r);});},[m,i]),[Fr,Yt]=gt.useState(null),Tr=gt.useRef(null),Dr=gt.useRef(k),$r=gt.useRef(E);gt.useEffect(()=>{Dr.current=k;},[k]),gt.useEffect(()=>{$r.current=E;},[E]),gt.useEffect(()=>{Tr.current=Fr;},[Fr]);let Eo=gt.useCallback((r,f)=>{Dr.current?.(r,f);},[]),Ro=gt.useCallback((r,f)=>{$r.current?.(r,f);},[]),Io=gt.useCallback(()=>Tr.current,[]),_r=gt.useRef({...Mn(Eo,Ro,Io),...h??{}});gt.useEffect(()=>{_r.current={...Mn(Eo,Ro,Io),...h??{}};},[Eo,Ro,Io,h]);let oi=gt.useMemo(()=>({...Ca,...u??{}}),[u]),Ve=gt.useRef(Y);gt.useEffect(()=>{Ve.current=Y;},[Y]);let ee=gt.useRef(pe);gt.useEffect(()=>{ee.current=pe;},[pe]),gt.useEffect(()=>{O(J);},[J,O]),gt.useEffect(()=>{te(q);},[q,te]),gt.useEffect(()=>{if(L&&o){let r=$(o,e||[]);r.length!==o.length&&(i&&console.warn(`Controlled edges had ${o.length-r.length} duplicate(s) removed`),a?.(r));}},[L,o,e,$,a,i]),gt.useEffect(()=>{L&&P.setState({nodes:e||[]});},[L,e,P]),gt.useEffect(()=>{L&&P.setState({edges:o||[]});},[L,o,P]),gt.useEffect(()=>{if(!W||!Y||Y.length===0)return;let r=Y.filter(K=>K.type==="rack");if(r.length===0)return;let f=r.map(K=>{let ge=K.data?.uHeight||42,ve=60+ge*20;return (K.position?.y||0)+ve}),b=Math.min(...f),w=Math.max(...f);if(w-b<20)return;let R=w,_=Y.map(K=>{if(K.type!=="rack")return K;let ge=K.data?.uHeight||42,ve=60+ge*20,ye=(K.position?.y||0)+ve,he=R-ye;return Math.abs(he)<5?K:{...K,position:{x:K.position?.x||0,y:(K.position?.y||0)+he}}});_.some((K,me)=>K.position!==Y[me].position)&&O(_);},[W,Y,O]);let Fo=gt.useRef(new Map);gt.useEffect(()=>{let r=new Map;Y.forEach(f=>{r.set(f.id,f);}),Fo.current=r;},[Y]);let be=gt.useCallback(r=>Fo.current.get(r),[]),Pt=gt.useCallback((r,f)=>{if(!r||!f)return;let b=be(r);if(!b)return;let w=f.replace(/-(source|target)$/i,"");if(b.type==="fibre-split"&&w.startsWith("output-")){let R=ee.current.filter(_=>_.target===r&&(_.targetHandle||"").replace(/-(source|target)$/i,"").startsWith("input-"));if(R.length>0){let _=R[0]?.data?.color;if(_)return {color:_}}}if((b.type==="tube"||b.type==="cable")&&f.startsWith("fiber-")){let R=f.replace("fiber-",""),_=parseInt(R,10);if(_>=1&&_<=24){let Z=it(_),K=_>12;return {color:Z,striped:K}}}if((b.type==="multi-tube-cable"||b.type==="tube")&&f.startsWith("tube-")){let R=f.replace("tube-",""),_=parseInt(R,10);if(_>=1&&_<=24){let Z=xe(_),K=_>12;return {color:Z,striped:K}}}let S=b.data;if(S.color)return {color:S.color}},[be]),Wr=gt.useRef(new Map);gt.useEffect(()=>{te(r=>{let f=false,b=r.map(w=>{let S=se(w);return Wr.current.get(w.id)!==S?(f=true,Wr.current.set(w.id,S),{...w,zIndex:S,style:{...w.style,zIndex:S}}):w});return f?b:r});},[Y,te,se]),gt.useEffect(()=>{let r=Y.map(b=>{if(b.type==="coupler"&&b.parentId){let w=be(b.parentId);if(w&&(w.type==="patch-panel"||w.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 w=be(b.parentId);if(w&&w.type==="splice-tray"){let S=b.data.mode==="ribbon",R=zt(w,b.data.holderPosition,S);return {...b,position:R}}}if(b.type==="device"&&b.parentId&&b.data.uPosition&&(!b.position||b.position.x===0&&b.position.y===0)){let w=be(b.parentId);if(w){let S=ft(w,b.data.uPosition);return {...b,position:S}}}return b});r.some((b,w)=>{let S=Y[w];return b.extent!==S.extent||b.position?.x!==S.position?.x||b.position?.y!==S.position?.y})&&O(r);},[Y,O,be]);let ri=gt.useCallback(r=>{let f=r.map(b=>{if(b.type==="position"&&b.position){let w=be(b.id);if(w&&w.type==="coupler"&&w.parentId){let S=be(w.parentId);if(S&&(S.type==="patch-panel"||S.type==="closure")){if(!w.extent||w.extent!=="parent"){let R={...w,extent:"parent"};O(_=>_.map(Z=>Z.id===w.id?R:Z));}return {...b,position:w.position||{x:0,y:0}}}}if(w&&(w.type==="tube"||w.type==="splice-tray")&&w.parentId){let S=be(w.parentId);if(S&&S.type==="closure"){if(!w.extent||w.extent!=="parent"){let R={...w,extent:"parent"};O(_=>_.map(Z=>Z.id===w.id?R:Z));}return {...b,position:w.position||{x:0,y:0}}}}if(w&&w.type==="splice"&&w.parentId){let S=be(w.parentId);if(S&&S.type==="splice-tray"){let R=Jo(w,S,b.position,Ve.current);if(R.holderPosition!==void 0){let _={...w,data:{...w.data,holderPosition:R.holderPosition}};O(Z=>Z.map(K=>K.id===w.id?_:K));}return {...b,position:{x:R.x,y:R.y}}}}if(w&&w.type==="device"&&w.parentId){let S=be(w.parentId);if(S){let R=Lo(w,S,b.position,Ve.current);if(R.uPosition!==void 0){let _={...w,data:{...w.data,uPosition:R.uPosition}};O(Z=>Z.map(K=>K.id===w.id?_:K));}return {...b,position:{x:R.x,y:R.y}}}}if(w&&w.type==="device"&&w.parentId){let S=be(w.parentId);if(S){let R=S;if(!ko(b.position,R)){let _=b.position.x+R.position.x,Z=b.position.y+R.position.y,K={...w,parentId:void 0,extent:void 0,data:{...w.data,uPosition:void 0}};return O(me=>me.map(ge=>ge.id===w.id?K:ge)),{...b,position:{x:_,y:Z}}}}}}return b});ce(f);},[ce,O,be]),ni=gt.useCallback((r,f)=>{Yt(null);},[]),ii=gt.useCallback((r,f,b)=>{if(f.type==="device"&&!f.parentId){let w=Ve.current.filter(R=>R.type==="rack").map(R=>R),S=Co(f.position,w);Yt(S?.id??null);}else Yt(null);},[]),ai=gt.useCallback((r,f,b)=>{if(f.type==="device"&&!f.parentId){let w=Ve.current.filter(R=>R.type==="rack").map(R=>R),S=Co(f.position,w);if(S){let R=f.position.x-S.position.x,_=f.position.y-S.position.y,Z={...f,parentId:S.id,extent:"parent",position:{x:R,y:_},data:{...f.data,uPosition:1}},K=Ve.current.map(me=>me.id===f.id?Z:me);O(K),L||P.setState({nodes:K});}}Yt(null);},[O,L,P]),si=gt.useCallback(r=>{if(!r.source||!r.target||!r.sourceHandle||!r.targetHandle)return true;let f=be(r.source),b=be(r.target),w=ie(f,r.sourceHandle),S=ie(b,r.targetHandle),R=ee.current.some(V=>V.source===r.source?ie(f,V.sourceHandle)===w:V.target===r.source?ie(f,V.targetHandle)===w:false),_=ee.current.some(V=>V.target===r.target?ie(b,V.targetHandle)===S:V.source===r.target?ie(b,V.sourceHandle)===S:false);R&&i&&console.log("Connection will replace: Source handle already connected",{source:r.source,sourceHandle:r.sourceHandle,existingEdges:ee.current.filter(V=>V.source===r.source&&V.sourceHandle===r.sourceHandle||V.target===r.source&&V.targetHandle===r.sourceHandle)}),_&&i&&console.log("Connection will replace: Target handle already connected",{target:r.target,targetHandle:r.targetHandle,existingEdges:ee.current.filter(V=>V.target===r.target&&V.targetHandle===r.targetHandle||V.source===r.target&&V.sourceHandle===r.targetHandle)});let Z=wt(f,b);if((R||_)&&!Z)return i&&console.log("Connection rejected: Non-fiber handle already connected",r),false;if(!Z)return true;if(f?.type==="splice"&&b?.type==="splice"){let V=f.data?.mode==="ribbon",fe=b.data?.mode==="ribbon";if(V!==fe)return i&&console.log("Connection rejected: Ribbon splices can only connect to other ribbon splices",r),false}let K=(V,fe)=>(V?.type==="tube"||V?.type==="cable")&&!!fe&&fe.startsWith("fiber-"),me=(V,fe)=>(V?.type==="tube"||V?.type==="multi-tube-cable")&&!!fe&&fe.startsWith("tube-"),ge=(V,fe)=>V?.type==="multi-tube-cable"&&!!fe&&fe.startsWith("tube-"),ve=(V,fe)=>V?.type==="tube"&&!!fe&&fe.startsWith("tube-"),ye=(V,fe)=>(V?.type==="cable"||V?.type==="multi-tube-cable")&&fe==="cable-button",he=(V,fe)=>V?.type==="splice"&&(fe==="left"||fe==="right"),re=(V,fe)=>V?.type==="coupler"&&!!fe&&(fe.startsWith("left-")||fe.startsWith("right-")),Re=(V,fe)=>{if(V?.type!=="fibre-split"||!fe)return false;let Ar=fe.replace(/-(source|target)$/i,"");return Ar.startsWith("input-")||Ar.startsWith("output-")},Xt=K(f,r.sourceHandle),Qe=K(b,r.targetHandle),ue=he(f,r.sourceHandle),et=he(b,r.targetHandle),tt=re(f,r.sourceHandle),Gt=re(b,r.targetHandle),Et=Re(f,r.sourceHandle),Kt=Re(b,r.targetHandle),$o=ye(f,r.sourceHandle),Zt=ye(b,r.targetHandle),_o=ge(f,r.sourceHandle),Wo=ge(b,r.targetHandle),Mo=ve(f,r.sourceHandle),N=ve(b,r.targetHandle),U=me(f,r.sourceHandle),ne=me(b,r.targetHandle);return Xt&&et||Qe&&ue||(ue&&(Gt||Kt)||et&&(tt||Et))||(tt&&(Gt||Kt||et)||Gt&&(tt||Et||ue))||$o&&Zt||(_o&&N||Wo&&Mo)?true:U&&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)},[be,i]),di=gt.useCallback(r=>{i&&console.log("onConnect called:",r);let f=be(r.source),b=be(r.target);i&&(console.log("onConnect: sourceNode type:",f?.type,"targetNode type:",b?.type),console.log("onConnect: sourceHandle:",r.sourceHandle,"targetHandle:",r.targetHandle));let w=P.validateConnection({source:r.source??null,target:r.target??null,sourceHandle:r.sourceHandle??null,targetHandle:r.targetHandle??null});if(!w.valid){i&&console.warn(`Connection rejected: ${w.reason}`);return}let S=f?.type==="vertical-pdu",R=f?.data,_=f?.type==="device"&&R?.deviceType==="switch",Z=!!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)),me=f?.type==="tube"&&b?.type==="multi-tube-cable",ge=f?.type==="multi-tube-cable"&&b?.type==="tube",ve=me||ge,ye=r.sourceHandle==="cable-button"&&r.targetHandle==="cable-button",he="fiber";S&&Z?he="power":ye?he="thick-cable":ve&&(he=oe?"smoothstep":"fiber");let re,Re=Wn(b),Xt=Wn(f);if(Re||Xt){let N=b?.data,U=f?.data,ne=Re?N.ribbonFiberIds:U.ribbonFiberIds;ne&&Array.isArray(ne)&&ne.length>=6&&ne.length<=12&&(re={ribbonFiberIds:ne,isRibbon:true});}if(!re&&(he==="fiber"||he==="smoothstep")&&!S){let N;me?N=Pt(r.target,r.targetHandle):N=Pt(r.source,r.sourceHandle),N&&(re={color:N.color,striped:N.striped,isRibbon:false});}else if(he==="thick-cable"&&ye){let N=f?.data;re={color:N?.color||(N?.tubeStartIndex?xe(N.tubeStartIndex):"#6366f1")};}let Qe=ie(f,r.sourceHandle),ue=ie(b,r.targetHandle),et=ee.current.some(N=>N.source===r.source?ie(f,N.sourceHandle)===Qe:N.target===r.source?ie(f,N.targetHandle)===Qe:false),tt=ee.current.some(N=>N.target===r.target?ie(b,N.targetHandle)===ue:N.source===r.target?ie(b,N.sourceHandle)===ue:false);if(wt(f,b)&&(et||tt)){let N=new Set;for(let U of ee.current){if(U.source===r.source&&ie(f,U.sourceHandle)===Qe){N.add(U.id);continue}if(U.target===r.source&&ie(f,U.targetHandle)===Qe){N.add(U.id);continue}if(U.source===r.target&&ie(b,U.sourceHandle)===ue){N.add(U.id);continue}U.target===r.target&&ie(b,U.targetHandle)===ue&&N.add(U.id);}if(N.size>0){let U=ee.current.filter(Ye=>!N.has(Ye.id)),ne=reactflow.addEdge(r,U),Ee=ne[ne.length-1],Ie=se({...r,id:Ee.id,type:he}),je={...Ee,type:he,zIndex:Ie,style:{...Ee.style,zIndex:Ie},data:re!==void 0?re:Ee.data};te([...ne.slice(0,-1),je]),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(U=>U.target===r.target&&U.targetHandle===r.targetHandle||U.source===r.target&&U.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 U=r.source&&r.sourceHandle?ee.current.find(V=>V.source===r.source&&V.sourceHandle===r.sourceHandle):null;i&&U&&console.log("Splice target handle replacement: Also found existing source edge",U.id);let ne=new Set;N&&ne.add(N.id),U&&U.id!==N.id&&ne.add(U.id);let Ee=ee.current.filter(V=>!ne.has(V.id));i&&console.log("Splice target handle replacement: Removing",ne.size,"edge(s), creating new connection");let Ie=`edge-${r.source}-${r.sourceHandle}-${r.target}-${r.targetHandle}-${Date.now()}`,je=se({...r,id:Ie,type:"fiber"}),Ye={id:Ie,source:r.source,target:r.target,sourceHandle:r.sourceHandle,targetHandle:r.targetHandle,type:"fiber",zIndex:je,style:{zIndex:je},data:re!==void 0?re:{}},qt=[...Ee,Ye];te(qt),i&&console.log("Splice target handle replacement: Successfully replaced edge with new edge",Ye.id);return}}if(f?.type==="splice"&&r.sourceHandle==="right"&&r.source&&r.sourceHandle){let N=ee.current.find(U=>U.source===r.source&&U.sourceHandle===r.sourceHandle||U.target===r.source&&U.targetHandle===r.sourceHandle);if(N){i&&console.log("Splice source handle replacement: Found existing edge",N.id,"on splice handle",r.sourceHandle);let U=r.target&&r.targetHandle?ee.current.find(V=>V.target===r.target&&V.targetHandle===r.targetHandle):null;i&&U&&console.log("Splice source handle replacement: Also found existing target edge",U.id);let ne=new Set;N&&ne.add(N.id),U&&U.id!==N.id&&ne.add(U.id);let Ee=ee.current.filter(V=>!ne.has(V.id));i&&console.log("Splice source handle replacement: Removing",ne.size,"edge(s), creating new connection");let Ie=`edge-${r.source}-${r.sourceHandle}-${r.target}-${r.targetHandle}-${Date.now()}`,je=se({...r,id:Ie,type:"fiber"}),Ye={id:Ie,source:r.source,target:r.target,sourceHandle:r.sourceHandle,targetHandle:r.targetHandle,type:"fiber",zIndex:je,style:{zIndex:je},data:re!==void 0?re:{}},qt=[...Ee,Ye];te(qt),i&&console.log("Splice source handle replacement: Successfully replaced edge with new edge",Ye.id);return}}if((f?.type==="tube"||f?.type==="cable")&&r.sourceHandle?.startsWith("fiber-")&&r.source&&r.sourceHandle){let N=Pe({edges:ee.current,connection:r,edgeType:"fiber",selectEdgeZIndex:se,findBy:"source",data:re});if(N){te(N);return}}if((b?.type==="tube"||b?.type==="cable")&&r.targetHandle?.startsWith("fiber-")&&r.target&&r.targetHandle){let N=Pe({edges:ee.current,connection:r,edgeType:"fiber",selectEdgeZIndex:se,findBy:"target",data:re});if(N){te(N);return}}if((f?.type==="multi-tube-cable"||f?.type==="tube")&&r.sourceHandle?.startsWith("tube-")&&r.source&&r.sourceHandle){let N=Pe({edges:ee.current,connection:r,edgeType:he,selectEdgeZIndex:se,findBy:"source",data:re});if(N){te(N);return}}if((b?.type==="multi-tube-cable"||b?.type==="tube")&&r.targetHandle?.startsWith("tube-")&&r.target&&r.targetHandle){let N=Pe({edges:ee.current,connection:r,edgeType:he,selectEdgeZIndex:se,findBy:"target",data:re});if(N){te(N);return}}if(f?.type==="coupler"&&(r.sourceHandle?.startsWith("left-")||r.sourceHandle?.startsWith("right-"))){let N=Pe({edges:ee.current,connection:r,edgeType:"fiber",selectEdgeZIndex:se,findBy:"source",data:re});if(N){te(N);return}}if(b?.type==="coupler"&&(r.targetHandle?.startsWith("left-")||r.targetHandle?.startsWith("right-"))){let N=Pe({edges:ee.current,connection:r,edgeType:"fiber",selectEdgeZIndex:se,findBy:"target",data:re});if(N){te(N);return}}if(ye&&r.source&&r.sourceHandle&&r.target&&r.targetHandle){let N=f?.data,U=N?.color||(N?.tubeStartIndex?xe(N.tubeStartIndex):"#6366f1"),ne=Pe({edges:ee.current,connection:r,edgeType:"thick-cable",selectEdgeZIndex:se,findBy:"source",data:{color:U}});if(ne){te(ne);return}if(ne=Pe({edges:ee.current,connection:r,edgeType:"thick-cable",selectEdgeZIndex:se,findBy:"target",data:{color:U}}),ne){te(ne);return}}if(S&&Z&&r.target&&r.targetHandle){let N=Pe({edges:ee.current,connection:r,edgeType:"power",selectEdgeZIndex:se,findBy:"target",data:re});if(N){te(N);return}}if(_&&K&&r.target&&r.targetHandle){let N=Pe({edges:ee.current,connection:r,edgeType:"fiber",selectEdgeZIndex:se,findBy:"target",data:re});if(N){te(N);return}}let Et=P.validateConnection({source:r.source??null,target:r.target??null,sourceHandle:r.sourceHandle??null,targetHandle:r.targetHandle??null});if(!Et.valid){if(S&&r.source&&r.sourceHandle){let N=Pe({edges:ee.current,connection:r,edgeType:Z?"power":"fiber",selectEdgeZIndex:se,findBy:"source",data:re});if(N){te(N);return}}if(_&&r.source&&r.sourceHandle){let N=Pe({edges:ee.current,connection:r,edgeType:"fiber",selectEdgeZIndex:se,findBy:"source",data:re});if(N){te(N);return}}i&&console.warn(`Connection rejected: ${Et.reason}`);return}let Kt=ee.current.some(N=>N.source===r.source&&N.sourceHandle===r.sourceHandle||N.target===r.source&&N.targetHandle===r.sourceHandle),$o=ee.current.some(N=>N.target===r.target&&N.targetHandle===r.targetHandle||N.source===r.target&&N.sourceHandle===r.targetHandle),Zt=(N,U)=>!N||!U?false:!!(N.startsWith("tube-")||U.type==="splice"&&(N==="left"||N==="right")||N==="cable-button"),_o=Zt(r.sourceHandle||"",f),Wo=Zt(r.targetHandle||"",b);if(Kt&&!_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($o&&!Wo){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 Mo={...r,type:he,zIndex:se({...r,id:"temp-id"}),data:re};te(N=>{let U=reactflow.addEdge(Mo,N),ne=U[U.length-1];return ne&&(Lr(Ee=>new Set(Ee).add(ne.id)),setTimeout(()=>{Lr(Ee=>{let Ie=new Set(Ee);return Ie.delete(ne.id),Ie});},1e3)),U});},[te,P,se,be,i,Pt,oe]),li=gt.useCallback((r,f)=>{if(!f.source||!f.target||!f.sourceHandle||!f.targetHandle)return;let b=P.validateConnection({source:f.source??null,target:f.target??null,sourceHandle:f.sourceHandle??null,targetHandle:f.targetHandle??null});if(!b.valid){i&&console.warn(`Edge update rejected: ${b.reason}`);return}let w=be(f.source),S=be(f.target),R=w?.type==="vertical-pdu",_=!!f.targetHandle&&(f.targetHandle.startsWith("pwr")||f.targetHandle.startsWith("power")),Z=w?.type==="tube"&&S?.type==="multi-tube-cable",K=w?.type==="multi-tube-cable"&&S?.type==="tube",me=Z||K,ge;R&&_?ge="power":me?ge=oe?"smoothstep":"fiber":ge="fiber";let ve;if((ge==="fiber"||ge==="smoothstep")&&!R){let ye=Pt(f.source,f.sourceHandle);ye&&(ve={color:ye.color,striped:ye.striped});}te(ye=>{let he=wt(w,S),re=ie(w,f.sourceHandle),Re=ie(S,f.targetHandle);return (he?ye.filter(ue=>{if(ue.id===r.id)return true;let et=ue.source===f.source&&ie(w,ue.sourceHandle)===re||ue.target===f.source&&ie(w,ue.targetHandle)===re,tt=ue.target===f.target&&ie(S,ue.targetHandle)===Re||ue.source===f.target&&ie(S,ue.sourceHandle)===Re;return !(et||tt)}):ye).map(ue=>ue.id===r.id?{...ue,source:f.source,target:f.target,sourceHandle:f.sourceHandle,targetHandle:f.targetHandle,type:ge,data:ve!==void 0?{...ue.data,...ve}:ue.data,zIndex:se({...f,id:ue.id,type:ge}),style:{...ue.style,zIndex:se({...f,id:ue.id,type:ge})}}:ue)});},[te,be,Pt,se,oe,i,P]),ci=gt.useCallback((r,f)=>{if($e){d&&d(f);return}let b=r.metaKey||r.ctrlKey;if(f.type==="tube"&&f.parentId&&!b){let S=Ue().find(R=>R.id===f.parentId&&(R.type==="cable"||R.type==="multi-tube-cable"));if(S){O(R=>R.map(_=>({..._,selected:_.id===S.id}))),d&&d(S);return}}if(b&&f.type==="device"){let w=f.data||{},S=w.view||(Array.isArray(w.rearPorts)&&w.rearPorts.length>0?"rear":"front"),R=S==="front"?"rear":"front";i&&console.log(`Command+click: Toggling device ${f.id} from ${S} to ${R}`),k&&k(f.id,R),d&&d(f);}else d&&d(f);},[k,d,i,Ue,O,$e]),pi=gt.useCallback(()=>{},[]),ui=gt.useCallback((r,f)=>{p&&p(f);},[p]),[Me,To]=gt.useState(null),[Mr,Lr]=gt.useState(new Set);reactflow.useOnSelectionChange({onChange:({nodes:r,edges:f})=>{if(zr(f||[]),!$e)if(r&&r.length===1){let b=r[0];if(b.type==="tube"&&b.parentId){let S=Ue().find(R=>R.id===b.parentId&&(R.type==="cable"||R.type==="multi-tube-cable"));if(S){To(S),O(R=>R.map(_=>({..._,selected:_.id===S.id}))),d&&d(S);return}}To(b),d&&d(b);}else To(null),d&&d(null);}});let[Do,zr]=gt.useState([]);gt.useEffect(()=>{let r=f=>{if((f.key==="Backspace"||f.key==="Delete")&&Do.length>0){if(document.activeElement?.tagName==="INPUT"||document.activeElement?.tagName==="TEXTAREA")return;let b=Do.filter(w=>{let S=w.sourceHandle||"",R=w.targetHandle||"";return S.startsWith("tube-")||R.startsWith("tube-")?(i&&console.log("Cannot delete edge connected to tube handle",w),false):true});if(b.length>0){let w=new Set(b.map(S=>S.id));te(S=>S.filter(R=>!w.has(R.id))),zr([]),i&&console.log("Deleted edges:",b.map(S=>S.id));}}};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[Do,te,i]);let gi=gt.useCallback((r,{nodeId:f,handleType:b})=>{i&&console.log("Connection started from",{nodeId:f,handleType:b});},[i]),fi=gt.useCallback(r=>{i&&console.log("Connection ended",r);},[i]),bi=gt.useCallback(()=>{if(!Me)return;let r=be(Me.id);if(r){if(r.type==="rack"){let w=((r.data||{}).face||"front")==="front"?"rear":"front";E?(E(r.id,w),k&&Ue().filter(R=>R.parentId===r.id).forEach(R=>{k(R.id,w);})):O(S=>S.map(R=>R.id===r.id?{...R,data:{...R.data,face:w}}:R.parentId===r.id?{...R,data:{...R.data,view:w}}:R));return}if(r.type==="device"){let f=r.data||{},b=Array.isArray(f.rearPorts)&&f.rearPorts.length>0,w=Array.isArray(f.ports)&&f.ports.length>0,R=(f.view||(b&&!w?"rear":"front"))==="front"?"rear":"front";k?k(r.id,R):O(_=>_.map(Z=>Z.id===r.id?{...Z,data:{...Z.data,view:R}}:Z));}}},[Me,be,E,k,O,Ue]),hi=gt.useMemo(()=>{let r=Fo.current;return pe.map(f=>{let b=f,w=r.get(String(b.source)),S=r.get(String(b.target)),R=No(b.sourceHandle||"",w),_=No(b.targetHandle||"",S),Z=w&&w.data?.view,K=S&&S.data?.view,me=w?.type==="device"&&Z==="rear",ge=S?.type==="device"&&K==="rear",re=me&&R!=="rear"||ge&&_!=="rear"?{...f.style,opacity:0,pointerEvents:"none",zIndex:0}:f.style;return {...f,style:re,className:Mr.has(f.id)?"edge-connecting":f.className}})},[pe,Mr]),mi=Br(m,F),yi=Vr(m,{touchAction:"none",...I});return jsxRuntime.jsxs("div",{ref:De,className:mi,style:yi,children:[jsxRuntime.jsxs(reactflow.ReactFlow,{nodes:Y,edges:hi,onNodesChange:r=>{ri(r),L?s&&s(Ve.current):P.setState({nodes:Ve.current});},onEdgesChange:r=>{let f=r.filter(b=>{if(b.type==="remove"){let w=ee.current.find(S=>S.id===b.id);if(w){let S=w.sourceHandle||"",R=w.targetHandle||"";if(S.startsWith("tube-")||R.startsWith("tube-"))return i&&console.log("Edge deletion blocked: Edge connected to tube handle is not detachable",w),false}}return true});if(f.length>0){let b=reactflow.applyEdgeChanges(f,ee.current);Ht(f),L?a&&a(b):P.setState({edges:b});}},onConnect:c??di,onConnectStart:gi,onConnectEnd:fi,onEdgeUpdate:g??li,isValidConnection:x??si,connectionMode:C,onNodeClick:ci,onNodeDoubleClick:pi,onNodeDragStart:ni,onNodeDrag:ii,onNodeDragStop:ai,onEdgeClick:ui,onInit:y,nodeTypes:_r.current,edgeTypes:oi,defaultEdgeOptions:{zIndex:1e3,reconnectable:true},nodesDraggable:!$e,nodesConnectable:true,elementsSelectable:!$e,edgesFocusable:!$e,selectNodesOnDrag:false,connectOnClick:de,panOnDrag:ae,panOnScroll:B&&!$e,zoomOnScroll:M&&!$e,preventScrolling:$e,onlyRenderVisibleElements:true,fitView:true,fitViewOptions:v,proOptions:{hideAttribution:true},children:[jsxRuntime.jsx(reactflow.Background,{color:Ur(m)}),jsxRuntime.jsx(reactflow.Controls,{}),!$e&&jsxRuntime.jsx(reactflow.MiniMap,{}),jsxRuntime.jsx(reactflow.Panel,{position:"bottom-right",className:"react-networks-attribution",children:jsxRuntime.jsx("a",{href:"https://github.com/MP70/react-networks",target:"_blank",rel:"noopener noreferrer",className:"react-networks-attribution-link",children:"react-networks"})})]}),D&&jsxRuntime.jsx("button",{className:"download-button",onClick:ti,style:{position:"absolute",top:z.includes("top")?"10px":"auto",bottom:z.includes("bottom")?"10px":"auto",right:z.includes("right")?"10px":"auto",left:z.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",...X},children:A}),Me&&(Me.type==="rack"||Me.type==="device")&&jsxRuntime.jsx("div",{style:{position:"absolute",top:12,right:12,display:"flex",gap:8,zIndex:2e3},children:jsxRuntime.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=Me.data;if(Me.type==="rack")return (r?.face||"front")==="front"?"Switch to rear":"Switch to front";{let f=Array.isArray(r?.rearPorts)&&r.rearPorts.length>0,b=Array.isArray(r?.ports)&&r.ports.length>0;return (r?.view||(f&&!b?"rear":"front"))==="front"?"Switch to rear":"Switch to front"}})(),children:(()=>{let r=Me.data;if(Me.type==="rack")return (r?.face||"front")==="front"?"\u21C4 Rear":"\u21C4 Front";{let f=Array.isArray(r?.rearPorts)&&r.rearPorts.length>0,b=Array.isArray(r?.ports)&&r.ports.length>0;return (r?.view||(f&&!b?"rear":"front"))==="front"?"\u21C4 Rear":"\u21C4 Front"}})()})})]})},vr=e=>jsxRuntime.jsx(reactflow.ReactFlowProvider,{children:jsxRuntime.jsx(va,{...e})});var Sr=class extends gt.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??jsxRuntime.jsxs("div",{role:"alert",style:{padding:16,margin:8,border:"1px solid #e53e3e",borderRadius:4,backgroundColor:"#fff5f5",color:"#c53030"},children:[jsxRuntime.jsx("strong",{children:"Diagram error"}),": ",t.message,jsxRuntime.jsx("button",{type:"button",onClick:this.reset,style:{marginLeft:12,padding:"4px 8px",cursor:"pointer"},children:"Try again"})]}):n}};function Bt(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),p=Math.max(1,e.fiberStartIndex??1),h=0;for(let u=0;u<l;u+=1){let c=d+u,g=e.tubeColorMap?.[c];s.push({tubeIndex:c,y:h,label:`T${c}`,color:g??xe(c)});for(let x=0;x<i;x+=1){let C=p+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;}u<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,p,h]=reactflow.getBezierPath({sourceX:o,sourceY:t,targetX:n,targetY:s,sourcePosition:a,targetPosition:l,curvature:.35}),u=typeof i?.lossDb=="number"?`${i.lossDb.toFixed(2)} dB`:"",c=i?.label??u,g=i?.sourceColor,x=i?.targetColor,C=i?.color??g??x??"#94a3b8",k=i?.sourceStriped??false,E=i?.targetStriped??false,F=i?.highlighted??true,I=i?.dimmed??false,W=i?.circuitId,m=i?.circuitLabel??W,y=i?.showCircuitId??false,H=g&&x&&g!==x,D=n-o,z=s-t,A=Math.sqrt(D*D+z*z),X=p-o,oe=h-t,de=Math.sqrt(X*X+oe*oe),ae=A>0?de/A*100:50,B=`fibre-flow-gradient-${e}`,M=k&&!E,v=E&&!k,$=k&&E,L=A*1.25,j=L/2,Q=12,T=Math.ceil(j*1.2/Q),P=Array(T).fill("6 6").join(" "),J=Math.ceil(j*1.2/Q),q=Array(J).fill("6 6").join(" "),Y=y&&m,O=Math.max(c?c.length*6.2+16:0,Y?(m?.length||0)*5.5+16:0),ce=Y?32:16;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("defs",{children:H&&jsxRuntime.jsxs("linearGradient",{id:B,x1:o,y1:t,x2:n,y2:s,gradientUnits:"userSpaceOnUse",children:[jsxRuntime.jsx("stop",{offset:"0%",stopColor:g}),jsxRuntime.jsx("stop",{offset:`${ae}%`,stopColor:g}),jsxRuntime.jsx("stop",{offset:`${ae}%`,stopColor:x}),jsxRuntime.jsx("stop",{offset:"100%",stopColor:x})]})}),H?jsxRuntime.jsx("path",{id:e,d,fill:"none",stroke:`url(#${B})`,strokeWidth:F?4:3,strokeLinecap:"round",strokeLinejoin:"round",opacity:I?.25:1,strokeOpacity:I?.25:1,style:{mixBlendMode:"normal"}}):jsxRuntime.jsx(reactflow.BaseEdge,{id:e,path:d,style:{stroke:C,strokeWidth:F?4:3,strokeLinecap:"round",strokeLinejoin:"round",opacity:I?.25:1,strokeOpacity:I?.25:1,mixBlendMode:"normal"}}),($||M||v)&&jsxRuntime.jsx("path",{id:`${e}-stripe`,d,fill:"none",stroke:"#000",strokeWidth:F?1.6:1.3,strokeLinecap:"round",strokeLinejoin:"round",strokeDasharray:M?`${P} ${L}`:v?`${j} ${q} ${L}`:"6 6",strokeDashoffset:0,opacity:I?.2:.9,style:{mixBlendMode:"normal"}}),(c||Y)&&F&&jsxRuntime.jsx(reactflow.EdgeLabelRenderer,{children:jsxRuntime.jsxs("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${p}px, ${h}px)`,width:O,height:ce,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&&jsxRuntime.jsx("div",{style:{lineHeight:1.2},children:c}),Y&&jsxRuntime.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,p,h]=reactflow.getBezierPath({sourceX:o,sourceY:t,targetX:n,targetY:s,sourcePosition:a,targetPosition:l,curvature:.2}),u=i?.label,c=i?.color??"#64748b";return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(reactflow.BaseEdge,{id:e,path:d,style:{stroke:c,strokeWidth:3,opacity:.85,strokeDasharray:"8 10"}}),u&&jsxRuntime.jsx(reactflow.EdgeLabelRenderer,{children:jsxRuntime.jsx("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${p}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:u})})]})},Ta=({data:e})=>{let{cable:o,side:t,rowHeight:n,columnWidth:s,showTubeLabels:a,showFiberNumbers:l,layout:i,colorMode:d="dark"}=e,p=d==="light",h=8,u=12,c=-1,g=0,x=o.jacketColor??"#facc15",C=(o.kind??(o.tubeCount?"tube":"simple"))==="tube",k=a&&C,E=t==="left"?h+g:g,F=t==="right"?h+g:g,I=t==="left"?reactflow.Position.Right:reactflow.Position.Left,W={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 jsxRuntime.jsxs("div",{style:{position:"relative",width:s,height:i.height,fontFamily:"monospace",color:"inherit",overflow:"visible"},children:[jsxRuntime.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: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:s,overflow:"hidden",textOverflow:"ellipsis",zIndex:10,...t==="right"?{textAlign:"right"}:{}},children:o.label}),jsxRuntime.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,y)=>{let H=i.rows.filter(de=>de.tubeIndex===m.tubeIndex);if(H.length===0)return null;let D=H[0].y,z=H[H.length-1].y+n,A=z-D,X=i.tubeLabels[y+1],oe=X&&X.y-z>0;return jsxRuntime.jsx("div",{style:{position:"absolute",top:D,left:0,right:0,height:A,background:m.color,borderLeft:`2px solid ${m.color}`,borderRight:`2px solid ${m.color}`,borderTop:y===0?`2px solid ${m.color}`:"1px solid rgba(0,0,0,0.15)",borderBottom:oe?"1px solid rgba(0,0,0,0.15)":`2px solid ${m.color}`,boxShadow:"inset 0 0 3px rgba(0,0,0,0.1)",borderRadius:y===0&&!oe||y===0?"4px 4px 0 0":oe?"0":"0 0 4px 4px",zIndex:2}},`tube-segment-${m.tubeIndex}`)})}),!k&&jsxRuntime.jsx("div",{style:{position:"absolute",top:0,bottom:0,left:E,right:F,...t==="left"?{borderRight:`1px solid ${x}`}:{borderLeft:`1px solid ${x}`},pointerEvents:"none",zIndex:0}}),C&&i.tubeLabels.map((m,y)=>{let H=i.rows.filter(X=>X.tubeIndex===m.tubeIndex);if(H.length===0)return null;let D=H[0].y,A=H[H.length-1].y+n-D;return jsxRuntime.jsx("div",{style:{position:"absolute",top:D,left:E,right:F,height:A,...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 y=`fiber-${m.tubeIndex??1}-${m.fiberIndex}`,H=m.y+n/2,D={position:"absolute",width:u,height:u,borderRadius:"50%",top:H,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:-u/2}:{left:-u/2},transform:"translateY(-50%)",zIndex:1e3,cursor:"crosshair","--fiber-bg":m.color,minWidth:u,minHeight:u};m.backgroundImage&&(D["--fiber-bg-image"]=m.backgroundImage);let z=t==="left"?{right:u+c,textAlign:"right"}:{left:u+c,textAlign:"left"};return jsxRuntime.jsxs(gt__default.default.Fragment,{children:[jsxRuntime.jsx(reactflow.Handle,{id:y,type:"source",position:I,className:"fibre-flow-handle",style:D,isConnectable:true,"data-fiber-idx":m.fiberIndex,"data-tube-idx":m.tubeIndex,"data-fiber-color":m.color}),jsxRuntime.jsx(reactflow.Handle,{id:y,type:"target",position:I,className:"fibre-flow-handle",style:D,isConnectable:true,"data-fiber-idx":m.fiberIndex,"data-tube-idx":m.tubeIndex,"data-fiber-color":m.color}),l&&jsxRuntime.jsx("div",{style:{position:"absolute",top:m.y+n/2-6,...z,fontSize:8,fontWeight:600,color:p?"rgba(15, 23, 42, 0.7)":"rgba(148, 163, 184, 0.95)",whiteSpace:"nowrap",lineHeight:1},children:m.fiberIndex})]},m.key)}),jsxRuntime.jsx(reactflow.Handle,{id:"cable-run",type:"source",position:t==="left"?reactflow.Position.Left:reactflow.Position.Right,className:"cable-run-handle",style:W,isConnectable:true,"data-handle-type":"cable-run"}),jsxRuntime.jsx(reactflow.Handle,{id:"cable-run",type:"target",position:t==="left"?reactflow.Position.Left:reactflow.Position.Right,className:"cable-run-handle",style:W,isConnectable:true,"data-handle-type":"cable-run"})]})},Da=({data:e})=>{let o=e.colorMode==="light";return jsxRuntime.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:jsxRuntime.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,p="dark")=>{let h=[],u=0;return e.forEach(c=>{let g=Bt(c.leftCable,{rowHeight:t,tubeGap:n}),x=Bt(c.rightCable,{rowHeight:t,tubeGap:n}),C=Math.max(g.height,x.height),k=a*2+l,E=32,F=16,I=k+F*2,W=C+E+F*2,m=`flow-closure-${c.id}`,y=`flow-cable-${c.id}-left`,H=`flow-cable-${c.id}-right`,D=o==="horizontal"?{x:u,y:0}:{x:0,y:u};u+=(o==="horizontal"?I:W)+s;let z=c.chamberId?`${c.id} - ${c.chamberId}`:c.id;h.push({id:m,type:"fibre-flow-closure",position:D,data:{label:z,width:I,height:W,headerHeight:E,colorMode:p},selectable:false,draggable:false,style:{width:I,height:W}});let A=E+F+(C-g.height)/2,X=E+F+(C-x.height)/2;h.push({id:y,type:"fibre-flow-cable",position:{x:F,y:A},parentId:m,extent:"parent",data:{label:c.leftCable.label,cable:c.leftCable,side:"left",rowHeight:t,columnWidth:a,showTubeLabels:i,showFiberNumbers:d,layout:g,colorMode:p},style:{width:a,height:g.height}}),h.push({id:H,type:"fibre-flow-cable",position:{x:F+k-a,y:X},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:p},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 p=`flow-cable-${d.id}-left`,h=`flow-cable-${d.id}-right`;[{nodeId:p,cable:d.leftCable},{nodeId:h,cable:d.rightCable}].forEach(({nodeId:c,cable:g})=>{let x=i.get(g.id);if(x&&x.closureId!==d.id){let C=Ra(g.distanceMeters??x.distanceMeters,g.distanceLabel??x.distanceLabel),k=g.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(g.id,{nodeId:c,closureId:d.id,jacketColor:g.jacketColor,distanceLabel:g.distanceLabel,distanceMeters:g.distanceMeters});}),d.splices.forEach(c=>{let g=t?c.circuitId===t:true,x=!!t&&!g,C=c.circuitId?a.get(c.circuitId):void 0,k=c.circuitId?l.get(c.circuitId):void 0,E=c.color??C,F=Vn(c.from),I=Vn(c.to),W=jn(c.from),m=jn(c.to);s.push({id:`flow-edge-${d.id}-${c.id}`,type:"fibre-flow",source:p,target:h,sourceHandle:Un(c.from),targetHandle:Un(c.to),data:{lossDb:c.lossDb,label:c.label,color:E,sourceColor:F,targetColor:I,sourceStriped:W,targetStriped:m,highlighted:g,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:p=true,showFiberNumbers:h=true,colorMode:u="dark",showCircuitId:c=false,className:g,style:x,panOnDrag:C=true,panOnScroll:k=true,zoomOnScroll:E=true})=>{let F=gt.useMemo(()=>$a(e,n,s,a,l,i,d,p,h,u),[e,n,s,a,l,i,d,p,h,u]),I=gt.useMemo(()=>_a(e,o,t,c),[e,o,t,c]),[W,m]=gt.useState(F),[y,H]=gt.useState(I);gt.useEffect(()=>{m(F);},[F,m]),gt.useEffect(()=>{H(I);},[I,H]);let D=gt.useCallback((v,$)=>{if(!v||!$||!$.startsWith("fiber-"))return;let L=W.find(q=>q.id===v);if(!L||L.type!=="fibre-flow-cable")return;let j=/^fiber-(\d+)-(\d+)$/.exec($);if(!j)return;let Q=Number(j[1]),T=Number(j[2]),J=L.data.layout.rows.find(q=>(q.tubeIndex??1)===Q&&q.fiberIndex===T);if(J)return {color:J.color,striped:J.striped??false}},[W]),z=gt.useCallback(v=>{if(!v.source||!v.target||!v.sourceHandle||!v.targetHandle)return false;let $=W.find(P=>P.id===v.source),L=W.find(P=>P.id===v.target);if(!$||!L)return false;let j=typeof v.sourceHandle=="string"&&v.sourceHandle.startsWith("fiber-"),Q=typeof v.targetHandle=="string"&&v.targetHandle.startsWith("fiber-");return v.sourceHandle==="cable-run"||v.targetHandle==="cable-run"?true:j&&Q?$.type==="fibre-flow-cable"&&L.type==="fibre-flow-cable":false},[W]),A=gt.useCallback(v=>{let $=v.sourceHandle==="cable-run"||v.targetHandle==="cable-run",L=Y=>typeof Y=="string"&&Y.startsWith("fiber-"),j=L(v.sourceHandle),Q=L(v.targetHandle),T=(Y,O,ce)=>Y.source===O&&Y.sourceHandle===ce||Y.target===O&&Y.targetHandle===ce,P=$?void 0:D(v.source,v.sourceHandle),J=$?void 0:D(v.target,v.targetHandle),q=$?void 0:{sourceColor:P?.color,targetColor:J?.color,color:P?.color??J?.color,sourceStriped:P?.striped,targetStriped:J?.striped};H(Y=>{let O=Y.filter(ce=>{let pe=j&&T(ce,v.source,v.sourceHandle),te=Q&&T(ce,v.target,v.targetHandle);return !(pe||te)});return reactflow.addEdge({...v,type:$?"fibre-flow-link":"fibre-flow",data:q},O)});},[D,H]),X=gt.useCallback((v,$)=>{let L=$.sourceHandle==="cable-run"||$.targetHandle==="cable-run",j=L?void 0:D($.source,$.sourceHandle),Q=L?void 0:D($.target,$.targetHandle),T=L?void 0:{sourceColor:j?.color,targetColor:Q?.color,color:j?.color??Q?.color,sourceStriped:j?.striped,targetStriped:Q?.striped},P=q=>typeof q=="string"&&q.startsWith("fiber-"),J=(q,Y,O)=>q.source===Y&&q.sourceHandle===O||q.target===Y&&q.targetHandle===O;H(q=>{let Y=q.filter(te=>te.id!==v.id),O=P($.sourceHandle),ce=P($.targetHandle),pe=Y.filter(te=>{let Ht=O&&J(te,$.source,$.sourceHandle),se=ce&&J(te,$.target,$.targetHandle);return !(Ht||se)});return reactflow.addEdge({...$,type:L?"fibre-flow-link":"fibre-flow",data:T},pe)});},[D,H]),oe=gt.useCallback(v=>{m(v);},[m]),de=gt.useCallback(v=>{H(v);},[H]),ae=gt.useMemo(()=>({"fibre-flow-cable":Ta,"fibre-flow-closure":Da}),[]),B=gt.useMemo(()=>({"fibre-flow":Ia,"fibre-flow-link":Fa}),[]),M={borderRadius:8,overflow:"hidden",...x};return jsxRuntime.jsx(vr,{nodes:W,edges:y,onNodesChange:oe,onEdgesChange:de,onConnect:A,onEdgeUpdate:X,isValidConnection:z,connectionMode:reactflow.ConnectionMode.Loose,nodeTypes:ae,edgeTypes:B,className:g,style:M,colorMode:u,panOnDrag:C,panOnScroll:k,zoomOnScroll:E,fitViewOptions:{padding:.2}})},Ma=e=>jsxRuntime.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 p=gt.useMemo(()=>a??Bt(e,{rowHeight:t,tubeGap:n}),[a,e,t,n]),h=26,u=10,c=18,g=o==="left"?s-c:c,x=8,C=o==="left"?6:s-h-18,k=e.jacketColor??"#facc15",E=l??(e.kind??(e.tubeCount?"tube":"simple"))==="tube";return jsxRuntime.jsxs("div",{style:{position:"relative",width:s,height:p.height,fontFamily:"monospace",color:"inherit"},children:[d&&jsxRuntime.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}),jsxRuntime.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)"}}),E&&p.tubeLabels.map(F=>jsxRuntime.jsxs("div",{style:{position:"absolute",top:F.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:[jsxRuntime.jsx("span",{style:{width:8,height:8,borderRadius:"50%",backgroundColor:F.color,border:"1px solid rgba(0, 0, 0, 0.4)",boxShadow:"0 0 3px rgba(0,0,0,0.25)"}}),jsxRuntime.jsx("span",{children:F.label})]},`tube-${F.tubeIndex}`)),p.rows.map(F=>{let I=F.y+t/2-u/2,W=o==="left"?g-u/2-x:g+u/2+x;return jsxRuntime.jsxs(gt__default.default.Fragment,{children:[jsxRuntime.jsx("div",{style:{position:"absolute",top:I,left:g-u/2,width:u,height:u,borderRadius:"50%",backgroundColor:F.color,backgroundImage:F.backgroundImage,border:"1px solid rgba(0, 0, 0, 0.4)",boxShadow:"0 0 4px rgba(0,0,0,0.25)"}}),i&&jsxRuntime.jsx("div",{style:{position:"absolute",top:F.y+t/2-6,left:W,transform:o==="left"?"translateX(-100%)":"none",fontSize:10,fontWeight:600,color:"rgba(15, 23, 42, 0.75)"},children:F.fiberIndex})]},F.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 Ho(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 p=o[d],h=n(i,p);h&&h.hasConflict&&h.conflict&&s.push(h.conflict);}}return {isValid:s.length===0&&a.length===0,conflicts:s,outOfBounds:a}}var vt=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 Pr(e,o={}){return Ho({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=ft(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,imageFit:e.imageFit,imagePosition:e.imagePosition,imageRepeat:e.imageRepeat,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=Pr(l,o);if(!i.isValid&&t==="strict"){let d=[];throw i.conflicts.forEach(p=>{d.push(`Device ${p.deviceId} at U${p.uPosition}-${p.uPosition+p.uHeight-1} conflicts with ${p.conflictWith}`);}),i.outOfBounds.forEach(p=>{d.push(`Device ${p.deviceId} at U${p.uPosition}-${p.uPosition+p.uHeight-1} exceeds rack height (${p.rackUHeight}U)`);}),new vt(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 p=Qn(d,i,o);a.push(p);}catch(p){if(t==="strict")throw p;if(t==="nearest"){let h=to(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 u={...d,unit:h},c=Qn(u,i,o);a.push(c);}else throw new vt(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,imageFit:l.data.imageFit,imagePosition:l.data.imagePosition,imageRepeat:l.data.imageRepeat}));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"&&!Pr({...a,devices:[...a.devices,t]},n).isValid)throw new vt(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 St=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 Er(e,o={}){return Ho({items:e.splices,checkOutOfBounds:t=>t.holder<1||t.holder>Ze?{isValid:false,error:{spliceId:t.id,holder:t.holder,max:Ze}}: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=zt(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=Er(l,o);if(!i.isValid&&t==="strict"){let d=[];throw i.conflicts.forEach(p=>{d.push(`Splice ${p.spliceId} at holder ${p.holder} conflicts with ${p.conflictWith}`);}),i.outOfBounds.forEach(p=>{d.push(`Splice ${p.spliceId} at holder ${p.holder} is out of bounds (max: ${p.max})`);}),new St(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 p=d.holder;if(t==="nearest"){let c={id:d.id,type:"splice",position:{x:0,y:0},data:{label:d.name,holderPosition:d.holder}},g=[...s,...a];Wt(i,c,d.holder,g)||(p=Lt(i,c,g,d.holder));}let h=p!==d.holder?{...d,holder:p}:d,u=ei(h,i);a.push(u);}catch(p){if(t==="strict")throw p;if(t==="nearest"){let h=[...s,...a],u=Lt(i,{id:d.id,data:{label:d.name,holderPosition:d.holder}},h,d.holder);if(u!==d.holder){console.warn(`Splice ${d.id} moved from holder ${d.holder} to holder ${u} due to conflict`);let c={...d,holder:u},g=ei(c,i);a.push(g);}else throw new St(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"&&!Er({...a,splices:[...a.splices,t]},n).isValid)throw new St(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
- exports.COUPLERS_PER_PANEL=Zi;exports.COUPLER_SLOT_HEIGHT_PX=mo;exports.COUPLER_WIDTH_PX=qi;exports.CableNode=ir;exports.ClosureNode=mr;exports.CouplerNode=dr;exports.DeviceNode=ht;exports.DevicePlacementError=vt;exports.DiagramErrorBoundary=Sr;exports.FIBER_COLORS_12=Yr;exports.FiberEdge=no;exports.FiberNode=Oo;exports.FibreCableWithTubesExpanded=Aa;exports.FibreFlowMap=Ma;exports.FibreSplitNode=wr;exports.HANDLE_EXTENSION_PX=Rt;exports.MultiTubeCableNode=sr;exports.NetworkDiagram=vr;exports.PANEL_BORDER_WIDTH=hn;exports.PANEL_HEADER_HEIGHT=ut;exports.PANEL_HEIGHT_PX=ho;exports.PANEL_PADDING=pt;exports.PANEL_TUBE_TRAY_SPACING=mn;exports.PANEL_WIDTH_PX=bo;exports.POWER_CONNECTORS=Vo;exports.PatchPanelNode=fr;exports.PowerEdge=Bo;exports.RACK_HEADER_HEIGHT=Xe;exports.RACK_WIDTH_PX=Jt;exports.RackNode=Ao;exports.SpliceNode=Zo;exports.SplicePlacementError=St;exports.SpliceTrayNode=tr;exports.TubeNode=or;exports.U_HEIGHT_PX=He;exports.VerticalPDU=Xo;exports.Width=rn;exports.addDeviceToRack=Xa;exports.addSpliceToTray=Qa;exports.baseColorFor=xe;exports.buildNodesFromRackConfig=Va;exports.buildNodesFromSpliceConfig=Za;exports.calculateCouplerRightX=Qi;exports.calculateCouplerSlotSpacing=ta;exports.calculateCouplerSpacing=Sn;exports.calculateDevicePositionFromU=ft;exports.calculatePanelDimensions=pr;exports.calculateSlotPositionFromY=Cn;exports.calculateSplicePositionFromNumber=Bi;exports.calculateYFromSlotPosition=vn;exports.createNetworkDiagramStore=xr;exports.createRackConfigFromNodes=ja;exports.createSpliceConfigFromNodes=qa;exports.fiberSolidOrStriped=ze;exports.findNearestRack=Co;exports.findNextAvailableHolderPosition=Lt;exports.findNextAvailableUPosition=to;exports.generateLayout=Ba;exports.getConnectorConfig=ao;exports.getCouplerDimensions=cr;exports.getDeviceConnectorType=so;exports.getFiberColor=it;exports.getInnerContentWidth=kn;exports.getPDUPortType=jo;exports.getPanelHeight=Ji;exports.getPanelWidth=Nn;exports.getPowerPortStyle=bt;exports.getRackBounds=Tn;exports.getStatusColor=_e;exports.getTrayDimensions=yn;exports.getTubeDimensions=yo;exports.inventoryCableToNetworkEdge=Jn;exports.inventoryDeviceToNetworkNode=qn;exports.inventoryRackToNetworkNode=Zn;exports.inventoryToNetworkDiagram=Oa;exports.isHighPowerConnector=zi;exports.isPointInRack=ko;exports.isStriped=nt;exports.isUPositionAvailable=zo;exports.removeDeviceFromRack=Ga;exports.removeSpliceFromTray=es;exports.replaceEdge=Pe;exports.snapToCouplerPosition=ea;exports.snapToSplicePosition=Jo;exports.snapToUPosition=Lo;exports.updateDeviceUPosition=jr;exports.updateDeviceUPositionInSchema=Ya;exports.updateSpliceHolderPosition=Ja;exports.useDiagramEdges=Cr;exports.useDiagramNodes=kr;exports.useNetworkDiagram=ca;exports.validateAndSnapDevice=xi;exports.validateRackDevicePlacements=Pr;exports.validateSplicePlacements=Er;//# sourceMappingURL=index.js.map
1
+ 'use strict';var lt=require('react'),reactflow=require('reactflow'),htmlToImage=require('html-to-image'),jsxRuntime=require('react/jsx-runtime');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var lt__default=/*#__PURE__*/_interopDefault(lt);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}=reactflow.useReactFlow(),C=x(),[v,T]=lt.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(jsxRuntime.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 jsxRuntime.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:[jsxRuntime.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:[jsxRuntime.jsx("div",{style:{fontWeight:"bold",marginBottom:"4px"},children:d}),jsxRuntime.jsxs("div",{style:{fontSize:"10px",color:"#9ca3af"},children:[f?jsxRuntime.jsx("span",{style:{color:"#fbbf24",fontWeight:"bold"},children:f}):jsxRuntime.jsxs("span",{children:[typeof s=="number"?s:0," ports"]})," \u2022 ",p,"U \u2022 ",m]}),jsxRuntime.jsxs("div",{style:{display:"flex",gap:"4px",position:"absolute",top:"4px",right:"4px"},children:[jsxRuntime.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"}),jsxRuntime.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"}),jsxRuntime.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"})]})]}),jsxRuntime.jsx("div",{style:{flex:1,background:"transparent",position:"relative",minHeight:`${p*20}px`,overflow:"hidden"}}),v&&jsxRuntime.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 jsxRuntime.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:[jsxRuntime.jsx(reactflow.Handle,{type:"target",position:reactflow.Position.Top}),jsxRuntime.jsx(reactflow.Handle,{type:"source",position:reactflow.Position.Bottom}),jsxRuntime.jsx(reactflow.Handle,{type:"target",position:reactflow.Position.Left}),jsxRuntime.jsx(reactflow.Handle,{type:"source",position:reactflow.Position.Right}),jsxRuntime.jsx("div",{style:{textAlign:"center"},children:jsxRuntime.jsx("div",{style:{fontSize:"8px",lineHeight:"1.2"},children:o})}),jsxRuntime.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 jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[f&&jsxRuntime.jsx(reactflow.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 jsxRuntime.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)&&jsxRuntime.jsx(reactflow.BaseEdge,{id:`${e}-ribbon-stripe`,path:t,style:{...i,stroke:"#000",strokeWidth:1,strokeDasharray:"3 3",opacity:.4}}),jsxRuntime.jsx(reactflow.EdgeLabelRenderer,{children:r&&s&&(s.bandwidth||s.length)&&jsxRuntime.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&&jsxRuntime.jsx("div",{children:s.bandwidth}),s.length&&jsxRuntime.jsxs("div",{children:[s.length,"m"]}),jsxRuntime.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]=reactflow.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 jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[_&&jsxRuntime.jsx(reactflow.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`}}),jsxRuntime.jsx(reactflow.BaseEdge,{id:e,path:f,style:U}),v&&jsxRuntime.jsx(reactflow.BaseEdge,{id:`${e}-stripe`,path:f,style:{...p,stroke:"#000",strokeWidth:1.5,strokeDasharray:"6 6",opacity:.9}}),jsxRuntime.jsx(reactflow.EdgeLabelRenderer,{children:l&&s&&(x||k)&&jsxRuntime.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&&jsxRuntime.jsx("div",{children:x}),k&&jsxRuntime.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]=reactflow.getBezierPath({sourceX:t,sourceY:o,sourcePosition:a,targetX:r,targetY:i,targetPosition:d}),f=l?.connectorType||"C13";return jsxRuntime.jsx(reactflow.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]=reactflow.getSmoothStepPath({sourceX:t,sourceY:o,targetX:r,targetY:i,sourcePosition:a,targetPosition:d});return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[x&&jsxRuntime.jsx(reactflow.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 jsxRuntime.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)&&jsxRuntime.jsx(reactflow.BaseEdge,{id:`${e}-ribbon-stripe`,path:T,style:{...p,stroke:"#000",strokeWidth:1,strokeDasharray:"3 3",opacity:.4}}),jsxRuntime.jsx(reactflow.EdgeLabelRenderer,{children:l&&m&&(m.bandwidth||m.length)&&jsxRuntime.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&&jsxRuntime.jsx("div",{children:m.bandwidth}),m.length&&jsxRuntime.jsxs("div",{children:[m.length,"m"]}),jsxRuntime.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 jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[v&&jsxRuntime.jsx(reactflow.BaseEdge,{id:`${e}-highlight`,path:reactflow.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`}}),jsxRuntime.jsx(reactflow.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===reactflow.Position.Left||i===reactflow.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 jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[p&&jsxRuntime.jsx(reactflow.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 jsxRuntime.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)&&jsxRuntime.jsx(reactflow.BaseEdge,{id:`${e}-ribbon-stripe`,path:t,style:{...i,stroke:"#000",strokeWidth:1,strokeDasharray:"3 3",opacity:.4}}),jsxRuntime.jsx(reactflow.EdgeLabelRenderer,{children:r&&a&&(a.bandwidth||a.length)&&jsxRuntime.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&&jsxRuntime.jsx("div",{children:a.bandwidth}),a.length&&jsxRuntime.jsxs("div",{children:[a.length,"m"]}),jsxRuntime.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 jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[T&&jsxRuntime.jsx(reactflow.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`}}),jsxRuntime.jsx(reactflow.BaseEdge,{id:e,path:E,style:_}),c&&jsxRuntime.jsx(reactflow.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]=reactflow.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 jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[C&&jsxRuntime.jsx(reactflow.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`}}),jsxRuntime.jsx(reactflow.BaseEdge,{id:e,path:E,markerEnd:p,style:w}),c&&jsxRuntime.jsx(reactflow.EdgeLabelRenderer,{children:jsxRuntime.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__default.default.useLayoutEffect:lt__default.default.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:reactflow.Position.Top,style:{transform:"translateY(50%)",left:`${e/2*(t+2)}px`}}:{position:reactflow.Position.Bottom,style:{transform:"translateY(-50%)",left:`${(e-1)/2*(t+2)}px`}}}function rs(e,t,o){return t===1?{position:reactflow.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:reactflow.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:reactflow.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=reactflow.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__default.default.useMemo(()=>Array.isArray(m)?m:[],[m]),y=lt__default.default.useMemo(()=>Array.isArray(f)?f:[],[f]),w=Xa(d),_=b??300,S=Ja(c,F,y,x,k),D=l*20,A=lt__default.default.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__default.default.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__default.default.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(jsxRuntime.jsx(reactflow.Handle,{id:`${ye}-${$e.secondary}`,type:$e.secondary,position:jt.position,style:ue,title:Ae},`${ye}-${$e.secondary}`));}M.push(jsxRuntime.jsx(reactflow.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__default.default.useMemo(()=>S==="front"?F.length>0?L(F,"front"):[]:S==="rear"?y.length>0?L(y,"rear"):[]:[],[S,F,y,L]);return jsxRuntime.jsxs("div",{className:`device-node ${o?"selected":""}`,style:O,children:[jsxRuntime.jsxs("div",{className:"device-node__content",children:[jsxRuntime.jsx("div",{className:"device-node__label",children:i}),l>1&&jsxRuntime.jsx("div",{className:"device-node__manufacturer",children:s})]}),l>1&&jsxRuntime.jsxs("div",{className:"device-node__u-indicator",children:[l,"U"]}),jsxRuntime.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(jsxRuntime.jsx(reactflow.Handle,{type:"source",position:reactflow.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=>jsxRuntime.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:[jsxRuntime.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"}),jsxRuntime.jsx(reactflow.Handle,{type:"source",position:reactflow.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 jsxRuntime.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:[jsxRuntime.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:jsxRuntime.jsx("div",{style:{fontWeight:"bold",fontSize:"6px",color:"#e2e8f0"},children:o})}),jsxRuntime.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=reactflow.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 jsxRuntime.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?jsxRuntime.jsxs("div",{style:{position:"absolute",inset:0,borderRadius:8,overflow:"hidden",opacity:.75,pointerEvents:"none",display:"grid",gridTemplateColumns:"1fr 1fr"},children:[jsxRuntime.jsx("div",{style:{display:"flex",flexDirection:"column",width:"100%",height:"100%"},children:C.map((y,w)=>jsxRuntime.jsx("div",{style:{flex:1,background:y.base,opacity:y.striped?.9:1}},`left-${w}`))}),jsxRuntime.jsx("div",{style:{display:"flex",flexDirection:"column",width:"100%",height:"100%"},children:v.map((y,w)=>jsxRuntime.jsx("div",{style:{flex:1,background:y.base,opacity:y.striped?.9:1}},`right-${w}`))})]}):jsxRuntime.jsxs("div",{style:{position:"absolute",inset:0,display:"grid",gridTemplateColumns:"1fr 1fr",borderRadius:8,overflow:"hidden",opacity:.75,pointerEvents:"none"},children:[jsxRuntime.jsx("div",{style:{background:f}}),jsxRuntime.jsx("div",{style:{background:c}})]}),jsxRuntime.jsx("div",{className:"splice-text-overlay",style:{position:"absolute",inset:0,borderRadius:8,pointerEvents:"none",zIndex:1,background:"transparent"}}),T&&jsxRuntime.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"&&jsxRuntime.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:[jsxRuntime.jsx("div",{children:`${r.toFixed(2)} dB`}),b&&a&&jsxRuntime.jsxs("div",{style:{fontSize:"7px",opacity:.8},children:[a.length,"F"]})]}),jsxRuntime.jsx(reactflow.Handle,{type:"target",position:reactflow.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%)"}}),jsxRuntime.jsx(reactflow.Handle,{type:"source",position:reactflow.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%)"}}),jsxRuntime.jsx(reactflow.Handle,{type:"target",position:reactflow.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]=lt.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(jsxRuntime.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 jsxRuntime.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:[jsxRuntime.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:[jsxRuntime.jsx("div",{style:{fontWeight:"bold",fontSize:"10px"},children:o}),jsxRuntime.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(),jsxRuntime.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=reactflow.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"?reactflow.Position.Left:a==="right"?reactflow.Position.Right:reactflow.Position.Bottom,w=y!==reactflow.Position.Bottom,_=w?14:20,S=w?8:20,D=w?`inset ${y===reactflow.Position.Left?"-4px":"4px"} 0 0 rgba(0, 0, 0, 0.35)`:"none",A=p?c:w?`linear-gradient(${y===reactflow.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===reactflow.Position.Left?{left:-(_-4)}:y===reactflow.Position.Right?{right:-(_-4)}:{}},le=lt.useMemo(()=>{let ee=[],re=F-v*2-C*2,ne,z,B=false;a==="left"?(ne=C,z=reactflow.Position.Top):a==="right"?(ne=C+re-E,z=reactflow.Position.Top,B=true):(ne=C+(re-E)/2,z=reactflow.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(jsxRuntime.jsxs(lt__default.default.Fragment,{children:[jsxRuntime.jsx(reactflow.Handle,{id:X,type:"target",position:z,className:"tube-fiber-handle",isConnectable:true,style:ae,"data-fiber-idx":L,"data-fiber-color":ie.base}),jsxRuntime.jsx(reactflow.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 jsxRuntime.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,jsxRuntime.jsx(reactflow.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"}),jsxRuntime.jsx(reactflow.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__default.default.useRef(null);lt__default.default.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?reactflow.Position.Top:B>=45&&B<135?reactflow.Position.Right:B>=135&&B<225?reactflow.Position.Bottom:reactflow.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(jsxRuntime.jsxs(lt__default.default.Fragment,{children:[jsxRuntime.jsx(reactflow.Handle,{id:Q,type:"target",position:B,className:"tube-fiber-handle",isConnectable:true,style:ie,"data-fiber-idx":L,"data-fiber-color":J}),jsxRuntime.jsx(reactflow.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?reactflow.Position.Bottom:B>=45&&B<135?reactflow.Position.Left:B>=135&&B<225?reactflow.Position.Top:reactflow.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 jsxRuntime.jsx("div",{ref:s,style:re,children:jsxRuntime.jsxs("div",{style:ne,children:[_(),jsxRuntime.jsx(reactflow.Handle,{id:S,type:"source",position:ee,className:"cable-button-handle",isConnectable:true,style:A,"data-handle-type":"cable-button","data-cable-color":E}),jsxRuntime.jsx(reactflow.Handle,{id:S,type:"target",position:ee,className:"cable-button-handle",isConnectable:true,style:A,"data-handle-type":"cable-button","data-cable-color":E}),jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:2,transform:"translateX(2px)"},children:[jsxRuntime.jsx("div",{style:{fontSize:11,fontWeight:600,textTransform:"uppercase",letterSpacing:.5},children:C}),v&&jsxRuntime.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(jsxRuntime.jsxs(lt__default.default.Fragment,{children:[jsxRuntime.jsx(reactflow.Handle,{id:$,type:"target",position:reactflow.Position.Top,className:"tube-fiber-handle",isConnectable:true,style:J,"data-fiber-idx":ne,"data-tube-idx":ne,"data-tube-color":B}),jsxRuntime.jsx(reactflow.Handle,{id:$,type:"source",position:reactflow.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 jsxRuntime.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(),jsxRuntime.jsx(reactflow.Handle,{id:D,type:"source",position:reactflow.Position.Bottom,className:"cable-button-handle",isConnectable:true,style:U,"data-handle-type":"cable-button","data-cable-color":w}),jsxRuntime.jsx(reactflow.Handle,{id:D,type:"target",position:reactflow.Position.Bottom,className:"cable-button-handle",isConnectable:true,style:U,"data-handle-type":"cable-button","data-cable-color":w}),jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:2},children:[jsxRuntime.jsx("div",{style:{fontSize:11,fontWeight:600,textTransform:"uppercase",letterSpacing:.5},children:E}),F&&jsxRuntime.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=reactflow.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"?reactflow.Position.Left:reactflow.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(jsxRuntime.jsxs(lt__default.default.Fragment,{children:[jsxRuntime.jsx(reactflow.Handle,{id:le,type:"target",position:S,isConnectable:true,style:B}),jsxRuntime.jsx(reactflow.Handle,{id:le,type:"source",position:S,isConnectable:true,style:B})]},le)),D&&D[A]&&_.push(jsxRuntime.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 jsxRuntime.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"),jsxRuntime.jsx("div",{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",textAlign:"center",pointerEvents:"none",zIndex:1},children:jsxRuntime.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}=reactflow.useReactFlow(),p=lt.useRef(false),m=lt.useRef([]),f=lt.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=lt.useMemo(()=>({id:o,type:"patch-panel",position:{x:0,y:0},data:{...e,panelWidth:a,panelHeight:d}}),[o,e,a,d]),b=lt.useMemo(()=>a&&d?{width:a,height:d}:f.length===0?{width:a||400,height:d||300}:zr(c,f),[f,c,a,d]);lt.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 jsxRuntime.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:[jsxRuntime.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:jsxRuntime.jsx("div",{style:{fontWeight:"bold",fontSize:"11px"},children:v})}),jsxRuntime.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}=reactflow.useReactFlow(),f=lt.useRef(false),c=lt.useRef([]),b=lt.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=lt.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=lt.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]);lt.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 jsxRuntime.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:[jsxRuntime.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:jsxRuntime.jsx("div",{style:{fontWeight:"bold",fontSize:"11px"},children:E})}),jsxRuntime.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=reactflow.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(jsxRuntime.jsxs(lt__default.default.Fragment,{children:[jsxRuntime.jsx(reactflow.Handle,{id:`${B}-target`,type:"target",position:reactflow.Position.Left,isConnectable:true,style:X}),jsxRuntime.jsx(reactflow.Handle,{id:`${B}-source`,type:"source",position:reactflow.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(jsxRuntime.jsxs(lt__default.default.Fragment,{children:[jsxRuntime.jsx(reactflow.Handle,{id:`${B}-target`,type:"target",position:reactflow.Position.Right,isConnectable:true,style:X}),jsxRuntime.jsx(reactflow.Handle,{id:`${B}-source`,type:"source",position:reactflow.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 jsxRuntime.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:[jsxRuntime.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:jsxRuntime.jsx("polygon",{points:`0,${D} 0,${A} ${F},${le} ${F},${U}`,fill:"#1f2937",stroke:ee,strokeWidth:"2"})}),w(),jsxRuntime.jsx("div",{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",textAlign:"center",pointerEvents:"none",zIndex:1},children:jsxRuntime.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 lt.useSyncExternalStore(t,o,o)}function Qr(e){let t=r=>e.subscribe(i=>r()),o=()=>e.getState().nodes;return lt.useSyncExternalStore(t,o,o)}function en(e){let t=r=>e.subscribe(i=>r()),o=()=>e.getState().edges;return lt.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=reactflow.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__default.default.useRef(null),r=lt__default.default.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__default.default.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]),jsxRuntime.jsx("div",{ref:r,style:{width:"100%",height:"100%"},children:t})},Hi=(e,t,o)=>({rack:r=>jsxRuntime.jsx(Fe,{type:"rack",children:jsxRuntime.jsx(pr,{...r,onViewChange:e,onRackFaceChange:t,isDragOver:o?o()===r.id:false})}),fiber:r=>jsxRuntime.jsx(Fe,{type:"fiber",children:jsxRuntime.jsx(gr,{...r})}),device:r=>jsxRuntime.jsx(Fe,{type:"device",children:jsxRuntime.jsx($t,{...r})}),server:r=>jsxRuntime.jsx(Fe,{type:"server",children:jsxRuntime.jsx($t,{...r})}),switch:r=>jsxRuntime.jsx(Fe,{type:"switch",children:jsxRuntime.jsx($t,{...r})}),router:r=>jsxRuntime.jsx(Fe,{type:"router",children:jsxRuntime.jsx($t,{...r})}),"vertical-pdu":r=>jsxRuntime.jsx(Fe,{type:"vertical-pdu",children:jsxRuntime.jsx(vr,{...r})}),splice:r=>jsxRuntime.jsx(Fe,{type:"splice",children:jsxRuntime.jsx(Pr,{...r})}),"splice-tray":r=>jsxRuntime.jsx(Fe,{type:"splice-tray",children:jsxRuntime.jsx(Ir,{...r})}),tube:r=>jsxRuntime.jsx(Fe,{type:"tube",children:jsxRuntime.jsx(Dr,{...r})}),cable:r=>jsxRuntime.jsx(Fe,{type:"cable",children:jsxRuntime.jsx($r,{...r})}),"multi-tube-cable":r=>jsxRuntime.jsx(Fe,{type:"multi-tube-cable",children:jsxRuntime.jsx(Wr,{...r})}),coupler:r=>jsxRuntime.jsx(Fe,{type:"coupler",children:jsxRuntime.jsx(Ar,{...r})}),"patch-panel":r=>jsxRuntime.jsx(Fe,{type:"patch-panel",children:jsxRuntime.jsx(jr,{...r})}),closure:r=>jsxRuntime.jsx(Fe,{type:"closure",children:jsxRuntime.jsx(Yr,{...r})}),"fibre-split":r=>jsxRuntime.jsx(Fe,{type:"fibre-split",children:jsxRuntime.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 $=lt.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__default.default.useMemo(()=>M?e||[]:o||e||[],[M,e,o]),ie=lt__default.default.useMemo(()=>M?t||[]:r||t||[],[M,t,r]),Q=lt__default.default.useMemo(()=>$(ie,oe),[ie,oe,$]),j=lt__default.default.useMemo(()=>d||qr({nodes:oe,edges:Q,debug:s}),[d,M,s,Q]),ae=Qr(j),Ne=en(j),[ye,ce]=reactflow.useNodesState(ae),[qe,Ge,jt]=reactflow.useEdgesState(Ne),ue=wi(j),$e=lt.useRef(null),[Ae,Yi]=lt.useState(false);lt.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=lt.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=lt.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}=reactflow.useReactFlow();lt.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?htmlToImage.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]=lt.useState(false),Ki=lt.useCallback(()=>{if(!ft){if(!$e.current){s&&console.error("ReactFlow wrapper ref is not available");return}fn(true),htmlToImage.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]=lt.useState(null),hn=lt.useRef(null),mn=lt.useRef(C),yn=lt.useRef(v);lt.useEffect(()=>{mn.current=C;},[C]),lt.useEffect(()=>{yn.current=v;},[v]),lt.useEffect(()=>{hn.current=bn;},[bn]);let Jo=lt.useCallback((n,u)=>{mn.current?.(n,u);},[]),Qo=lt.useCallback((n,u)=>{yn.current?.(n,u);},[]),er=lt.useCallback(()=>hn.current,[]),wn=lt.useRef({...Hi(Jo,Qo,er),...m??{}});lt.useEffect(()=>{wn.current={...Hi(Jo,Qo,er),...m??{}};},[Jo,Qo,er,m]);let Zi=lt.useMemo(()=>({...Vs,...f??{}}),[f]),Xe=lt.useRef(ye);lt.useEffect(()=>{Xe.current=ye;},[ye]);let Y=lt.useRef(qe);lt.useEffect(()=>{Y.current=qe;},[qe]),lt.useEffect(()=>{ce(ae);},[ae,ce]),lt.useEffect(()=>{Ge(Ne);},[Ne,Ge]),lt.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]),lt.useEffect(()=>{M&&j.setState({nodes:e||[]});},[M,e,j]),lt.useEffect(()=>{M&&j.setState({edges:t||[]});},[M,t,j]),lt.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=lt.useRef(new Map);lt.useEffect(()=>{let n=new Map;ye.forEach(u=>{n.set(u.id,u);}),Gt.current=n;},[ye]);let pe=lt.useCallback(n=>Gt.current.get(n),[]),Oe=lt.useCallback(n=>{if(!n)return;if(typeof n.parentId=="string")return n.parentId;let u=n.parentNode;if(typeof u=="string")return u},[]),tr=lt.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=lt.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=lt.useCallback(n=>{Y.current=n,Ge(n),M?a?.(n):j.setState({edges:n});},[M,j,Ge,a]),it=lt.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=lt.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=lt.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=lt.useRef(new Map);lt.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]),lt.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=lt.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=reactflow.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=lt.useCallback((n,u)=>{ho(null);},[]),Qi=lt.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=lt.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=lt.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=lt.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=reactflow.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=reactflow.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=lt.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=lt.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=lt.useCallback(()=>{},[]),aa=lt.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=lt.useCallback(()=>{or(null),Yt([]),ce(n=>n.map(u=>u.selected?{...u,selected:false}:u)),l?.(null);},[l,ce]),[Be,or]=lt.useState(null),[xn,kn]=lt.useState(new Set);reactflow.useOnSelectionChange({onChange:({edges:n})=>{Yt(n||[]);}});let[rr,Yt]=lt.useState([]);lt.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=lt.useCallback((n,{nodeId:u,handleType:h})=>{s&&console.log("Connection started from",{nodeId:u,handleType:h});},[s]),la=lt.useCallback(n=>{s&&console.log("Connection ended",n);},[s]),ca=lt.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&&gt().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=lt.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=lt.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=lt.useMemo(()=>Be?pe(Be.id)??Be:null,[Be,pe]),It=lt.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=lt.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 jsxRuntime.jsxs("div",{ref:$e,className:ga,style:fa,children:[jsxRuntime.jsxs(reactflow.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=reactflow.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:[jsxRuntime.jsx(reactflow.Background,{color:Rn(w)}),Ie.showControls&&jsxRuntime.jsx(reactflow.Controls,{showInteractive:Ie.showInteractiveControl}),Ie.showMiniMap&&jsxRuntime.jsx(reactflow.MiniMap,{}),jsxRuntime.jsx(reactflow.Panel,{position:"bottom-right",className:"react-networks-attribution",children:jsxRuntime.jsx("a",{href:"https://github.com/MP70/react-networks",target:"_blank",rel:"noopener noreferrer",className:"react-networks-attribution-link",children:"react-networks"})})]}),D&&jsxRuntime.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&&jsxRuntime.jsxs("div",{style:{position:"absolute",top:nr.top,left:nr.left,display:"flex",gap:8,zIndex:2e3},children:[It.showRearToggle&&jsxRuntime.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&&jsxRuntime.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=>jsxRuntime.jsx(reactflow.ReactFlowProvider,{children:jsxRuntime.jsx(Zs,{...e})});var rn=class extends lt.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??jsxRuntime.jsxs("div",{role:"alert",style:{padding:16,margin:8,border:"1px solid #e53e3e",borderRadius:4,backgroundColor:"#fff5f5",color:"#c53030"},children:[jsxRuntime.jsx("strong",{children:"Diagram error"}),": ",o.message,jsxRuntime.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]=reactflow.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 jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("defs",{children:_&&jsxRuntime.jsxs("linearGradient",{id:ne,x1:t,y1:o,x2:r,y2:i,gradientUnits:"userSpaceOnUse",children:[jsxRuntime.jsx("stop",{offset:"0%",stopColor:b}),jsxRuntime.jsx("stop",{offset:`${re}%`,stopColor:b}),jsxRuntime.jsx("stop",{offset:`${re}%`,stopColor:x}),jsxRuntime.jsx("stop",{offset:"100%",stopColor:x})]})}),_?jsxRuntime.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"}}):jsxRuntime.jsx(reactflow.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)&&jsxRuntime.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&&jsxRuntime.jsx(reactflow.EdgeLabelRenderer,{children:jsxRuntime.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&&jsxRuntime.jsx("div",{style:{lineHeight:1.2},children:c}),Q&&jsxRuntime.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]=reactflow.getBezierPath({sourceX:t,sourceY:o,targetX:r,targetY:i,sourcePosition:a,targetPosition:d,curvature:.2}),f=s?.label,c=s?.color??"#64748b";return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(reactflow.BaseEdge,{id:e,path:l,style:{stroke:c,strokeWidth:3,opacity:.85,strokeDasharray:"8 10"}}),f&&jsxRuntime.jsx(reactflow.EdgeLabelRenderer,{children:jsxRuntime.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"?reactflow.Position.Right:reactflow.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 jsxRuntime.jsxs("div",{style:{position:"relative",width:i,height:s.height,fontFamily:"monospace",color:"inherit",overflow:"visible"},children:[jsxRuntime.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}),jsxRuntime.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 jsxRuntime.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&&jsxRuntime.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 jsxRuntime.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 jsxRuntime.jsxs(lt__default.default.Fragment,{children:[jsxRuntime.jsx(reactflow.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}),jsxRuntime.jsx(reactflow.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&&jsxRuntime.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)}),jsxRuntime.jsx(reactflow.Handle,{id:"cable-run",type:"source",position:o==="left"?reactflow.Position.Left:reactflow.Position.Right,className:"cable-run-handle",style:F,isConnectable:true,"data-handle-type":"cable-run"}),jsxRuntime.jsx(reactflow.Handle,{id:"cable-run",type:"target",position:o==="left"?reactflow.Position.Left:reactflow.Position.Right,className:"cable-run-handle",style:F,isConnectable:true,"data-handle-type":"cable-run"})]})},ud=({data:e})=>{let t=e.colorMode==="light";return jsxRuntime.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:jsxRuntime.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=lt.useMemo(()=>pd(e,r,i,a,d,s,l,p,m,f),[e,r,i,a,d,s,l,p,m,f]),F=lt.useMemo(()=>gd(e,t,o,c),[e,t,o,c]),[y,w]=lt.useState(E),[_,S]=lt.useState(F);lt.useEffect(()=>{w(E);},[E,w]),lt.useEffect(()=>{S(F);},[F,S]);let D=lt.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=lt.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=lt.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 reactflow.addEdge({...O,type:L?"fibre-flow-link":"fibre-flow",data:Q},ae)});},[D,k,S]),le=lt.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 reactflow.addEdge({...L,type:X?"fibre-flow-link":"fibre-flow",data:M},ye)});},[D,k,S]),ee=lt.useCallback(O=>{k||w(O.filter(td));},[k,w]),re=lt.useCallback(O=>{k||S(L=>id(O,L));},[k,S]),ne=lt.useMemo(()=>({"fibre-flow-cable":cd,"fibre-flow-closure":ud}),[]),z=lt.useMemo(()=>({"fibre-flow":dd,"fibre-flow-link":ld}),[]),B={borderRadius:8,overflow:"hidden",...x};return jsxRuntime.jsx(on,{nodes:y,edges:_,onNodesChange:ee,onEdgesChange:re,onConnect:U,onEdgeUpdate:le,isValidConnection:A,connectionMode:reactflow.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=>jsxRuntime.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=lt.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 jsxRuntime.jsxs("div",{style:{position:"relative",width:i,height:p.height,fontFamily:"monospace",color:"inherit"},children:[l&&jsxRuntime.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}),jsxRuntime.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=>jsxRuntime.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:[jsxRuntime.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)"}}),jsxRuntime.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 jsxRuntime.jsxs(lt__default.default.Fragment,{children:[jsxRuntime.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&&jsxRuntime.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
+ exports.COUPLERS_PER_PANEL=hs;exports.COUPLER_SLOT_HEIGHT_PX=Oo;exports.COUPLER_WIDTH_PX=ms;exports.CableNode=$r;exports.ClosureNode=Yr;exports.CouplerNode=Ar;exports.DeviceNode=$t;exports.DevicePlacementError=Ut;exports.DiagramErrorBoundary=rn;exports.FIBER_COLORS_12=Dn;exports.FiberEdge=Eo;exports.FiberNode=gr;exports.FibreCableWithTubesExpanded=yd;exports.FibreFlowMap=bd;exports.FibreSplitNode=Zr;exports.HANDLE_EXTENSION_PX=Zt;exports.MultiTubeCableNode=Wr;exports.NetworkDiagram=on;exports.PANEL_BORDER_WIDTH=ii;exports.PANEL_HEADER_HEIGHT=St;exports.PANEL_HEIGHT_PX=Ao;exports.PANEL_PADDING=Pt;exports.PANEL_TUBE_TRAY_SPACING=ai;exports.PANEL_WIDTH_PX=Wo;exports.POWER_CONNECTORS=mr;exports.PatchPanelNode=jr;exports.PowerEdge=br;exports.RACK_HEADER_HEIGHT=et;exports.RACK_WIDTH_PX=xo;exports.RackNode=pr;exports.SpliceNode=Pr;exports.SplicePlacementError=Vt;exports.SpliceTrayNode=Ir;exports.TubeNode=Dr;exports.U_HEIGHT_PX=Me;exports.VerticalPDU=vr;exports.Width=Un;exports.addDeviceToRack=Sd;exports.addSpliceToTray=Fd;exports.baseColorFor=De;exports.buildNodesFromRackConfig=Cd;exports.buildNodesFromSpliceConfig=Td;exports.calculateClosureDimensions=Br;exports.calculateCouplerRightX=ws;exports.calculateCouplerSlotSpacing=xs;exports.calculateCouplerSpacing=fi;exports.calculateDevicePositionFromU=_t;exports.calculatePanelDimensions=zr;exports.calculateSlotPositionFromY=pi;exports.calculateSplicePositionFromNumber=ds;exports.calculateUPositions=kd;exports.calculateYFromSlotPosition=gi;exports.createNetworkDiagramStore=qr;exports.createRackConfigFromNodes=Hd;exports.createSpliceConfigFromNodes=Id;exports.fiberSolidOrStriped=fr;exports.findNearestRack=Go;exports.findNextAvailableHolderPosition=co;exports.findNextAvailableUPosition=Ho;exports.generateLayout=Nd;exports.getConnectorConfig=Vn;exports.getCouplerDimensions=Lr;exports.getDeviceConnectorType=wr;exports.getFiberColor=wt;exports.getInnerContentWidth=ui;exports.getPDUPortType=yr;exports.getPanelHeight=ys;exports.getPanelWidth=ci;exports.getPowerPortStyle=ro;exports.getRackBounds=Ni;exports.getStatusColor=Ke;exports.getTrayDimensions=si;exports.getTubeDimensions=Lo;exports.inventoryCableToNetworkEdge=zi;exports.inventoryDeviceToNetworkNode=Li;exports.inventoryRackToNetworkNode=Oi;exports.inventoryToNetworkDiagram=wd;exports.isHighPowerConnector=Wa;exports.isPointInRack=xi;exports.isStriped=yt;exports.isUPositionAvailable=ur;exports.netboxCableToNetworkEdge=ji;exports.netboxDeviceToNetworkNode=Vi;exports.netboxRackToNetworkNode=Ui;exports.netboxToNetworkDiagram=xd;exports.removeDeviceFromRack=Ed;exports.removeSpliceFromTray=_d;exports.replaceEdge=Pe;exports.snapToCouplerPosition=Ns;exports.snapToSplicePosition=Er;exports.snapToUPosition=Co;exports.updateDeviceUPosition=In;exports.updateDeviceUPositionInSchema=Pd;exports.updateSpliceHolderPosition=Dd;exports.useDiagramEdges=en;exports.useDiagramNodes=Qr;exports.useNetworkDiagram=Ts;exports.validateAndSnapDevice=ya;exports.validateRackDevicePlacements=sn;exports.validateSplicePlacements=dn;//# sourceMappingURL=index.js.map
3
3
  //# sourceMappingURL=index.js.map