@mp70/react-networks 0.1.7-alpha → 0.1.8-alpha
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 +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import Or,{useState,useRef,useMemo,useEffect,useSyncExternalStore,useCallback}from'react';import {useReactFlow,Handle,Position,getBezierPath,BaseEdge,EdgeLabelRenderer,useEdges,addEdge,ReactFlowProvider,useNodesState,useEdgesState,useOnSelectionChange,ReactFlow,Background,Controls,MiniMap,Panel,SmoothStepEdge}from'reactflow';import {toPng}from'html-to-image';import {jsx,jsxs,Fragment}from'react/jsx-runtime';var mr=()=>"bottom-up",Pe=e=>e.data.uNumberingDirection||mr(),Xe=(e,o,r)=>r==="bottom-up"?o-e+1:e,je=(e,o,r)=>r==="bottom-up"?o-e+1:e;var mt=(e,o,r,a)=>{if(!e.parentId||e.parentId!==o.id)return r;let n=e.data.uHeight||1,i=o.data.uHeight||42,d=Pe(o),s=60,c=r.y-s,l=Math.round(c/20)+1,h;d==="bottom-up"?h=Xe(l,i,d)-n+1:h=Xe(l,i,d);let f=i-n+1,m=Math.max(1,Math.min(f,h));if(d==="top-down"&&h<=1&&(m=1),!yt(o,e,m,a)){let k=Ge(o,e,a,m);k!==m&&(m=k);}let v;if(d==="bottom-up"){let k=m+n-1,E=je(k,i,d);v=s+(E-1)*20-1;}else {let k=je(m,i,d);v=s+(k-1)*20-1;}return {x:r.x,y:v,uPosition:m}},yt=(e,o,r,a)=>{let n=o.data.uHeight||1,i=e.data.uHeight||42;if(r<1||r+n-1>i)return false;let d=a.filter(s=>s.type==="device"&&s.parentId===e.id&&s.id!==o.id);for(let s of d){let c=s.data.uPosition||1,l=s.data.uHeight||1,h=r,f=r+n-1,m=c,v=c+l-1;if(h<=v&&f>=m)return false}return true},Ge=(e,o,r,a=1)=>{let n=o.data.uHeight||1,i=e.data.uHeight||42;for(let d=a;d<=i-n+1;d++)if(yt(e,o,d,r))return d;return 1},De=(e,o,r=1)=>{let a=60,n=Pe(e),i=e.data.uHeight||42,d=je(o,i,n),s;if(n==="bottom-up"){let c=o+r-1,l=je(c,i,n);s=a+(l-1)*20-1;}else s=a+(d-1)*20-1;return {x:0,y:s}},fo=(e,o,r)=>{let a=e.data.uHeight||1,n=De(o,r,a);return {...e,position:n,data:{...e.data,uPosition:r}}},yr=(e,o)=>{let r=e.data.uPosition||1,a=e.data.uHeight||1,n=o.data.uHeight||42,i=Math.max(1,Math.min(n-a+1,r));return i!==r?fo(e,o,i):e};function ce(e){switch(e){case "active":return "#10b981";case "inactive":return "#6b7280";case "maintenance":return "#f59e0b";default:return "#6b7280"}}var xt=({data:e,selected:o,id:r,onViewChange:a,onRackFaceChange:n,isDragOver:i=false})=>{let{label:d,ports:s=0,status:c="active",uHeight:l=42,face:h="front",customHeaderText:f}=e,{getNodes:m,setNodes:v}=useReactFlow(),k=m(),[E,w]=useState(true),T=()=>{let H=Pe({data:e})==="bottom-up"?"top-down":"bottom-up";v(y=>y.map(P=>P.id===r?{...P,data:{...P.data,uNumberingDirection:H}}:P));},A=()=>{let x=h==="front"?"rear":"front";n?(n(r,x),a&&k.filter(y=>y.parentId===r).forEach(y=>{a(y.id,x);})):a?k.filter(y=>y.parentId===r).forEach(y=>{a(y.id,x);}):v(H=>H.map(y=>y.id===r?{...y,data:{...y.data,face:x}}:y.parentId===r?{...y,data:{...y.data,view:x}}:y));},W=()=>{let x=[],H=60,y=Pe({data:e});for(let P=1;P<=l;P++){let M=H+(P-1)*20-4,R=Xe(P,l,y);x.push(jsx("div",{style:{position:"absolute",left:"-35px",top:`${M}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:R},P));}return x};return jsxs("div",{className:`rack-node ${o?"selected":""} ${i?"drag-over":""}`,style:{background:"transparent",border:`2px solid ${ce(c)}`,borderRadius:"8px",padding:0,width:`${300}px`,height:`${60+l*20}px`,color:"white",fontFamily:"monospace",fontSize:"12px",boxShadow:i?"0 0 20px #3b82f6, 0 0 40px #3b82f6, 0 0 60px #3b82f6":o?"0 0 0 2px #3b82f6":"0 2px 4px rgba(0,0,0,0.1)",position:"relative",display:"flex",flexDirection:"column",transition:"box-shadow 0.2s ease-in-out"},children:[jsxs("div",{style:{textAlign:"center",marginBottom:0,zIndex:2,background:"#1f2937",padding:"8px",position:"relative",height:`${60}px`,display:"flex",flexDirection:"column",justifyContent:"center"},children:[jsx("div",{style:{fontWeight:"bold",marginBottom:"4px"},children:d}),jsxs("div",{style:{fontSize:"10px",color:"#9ca3af"},children:[f?jsx("span",{style:{color:"#fbbf24",fontWeight:"bold"},children:f}):jsxs("span",{children:[typeof s=="number"?s:0," ports"]})," \u2022 ",l,"U \u2022 ",h]}),jsxs("div",{style:{display:"flex",gap:"4px",position:"absolute",top:"4px",right:"4px"},children:[jsx("button",{onPointerDown:x=>{x.stopPropagation();},onMouseDown:x=>{x.stopPropagation();},onClick:x=>{x.stopPropagation(),x.preventDefault(),w(!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"}),jsx("button",{onPointerDown:x=>{x.stopPropagation();},onMouseDown:x=>{x.stopPropagation();},onClick:x=>{x.stopPropagation(),x.preventDefault(),T();},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 ${Pe({data:e})==="bottom-up"?"top-down":"bottom-up"}`,children:Pe({data:e})==="bottom-up"?"\u2191\u2193":"\u2193\u2191"}),jsx("button",{onPointerDown:x=>{x.stopPropagation();},onMouseDown:x=>{x.stopPropagation();},onClick:x=>{x.stopPropagation(),x.preventDefault(),A();},style:{background:"#374151",color:"#9ca3af",border:"1px solid #4b5563",borderRadius:"2px",padding:"2px 6px",fontSize:"8px",cursor:"pointer",fontFamily:"monospace"},title:`Switch to ${h==="front"?"rear":"front"} view`,children:h==="front"?"\u21C4 Rear":"\u21C4 Front"})]})]}),jsx("div",{style:{flex:1,background:"transparent",position:"relative",minHeight:`${l*20}px`,overflow:"hidden"}}),E&&jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none"},children:W()})]})};var wt=({data:e,selected:o})=>{let{label:r,status:a="active"}=e;return jsxs("div",{className:`fiber-node ${o?"selected":""}`,style:{background:"#1f2937",border:`2px solid ${ce(a)}`,borderRadius:"50%",width:"60px",height:"60px",display:"flex",alignItems:"center",justifyContent:"center",color:"white",fontFamily:"monospace",fontSize:"10px",fontWeight:"bold",boxShadow:o?"0 0 0 2px #3b82f6":"0 2px 4px rgba(0,0,0,0.1)",position:"relative"},children:[jsx(Handle,{type:"target",position:Position.Top}),jsx(Handle,{type:"source",position:Position.Bottom}),jsx(Handle,{type:"target",position:Position.Left}),jsx(Handle,{type:"source",position:Position.Right}),jsx("div",{style:{textAlign:"center"},children:jsx("div",{style:{fontSize:"8px",lineHeight:"1.2"},children:r})}),jsx("div",{style:{position:"absolute",bottom:"4px",left:"50%",transform:"translateX(-50%)",width:"8px",height:"8px",background:ce(a),borderRadius:"50%"}})]})};var kt=({id:e,sourceX:o,sourceY:r,targetX:a,targetY:n,sourcePosition:i,targetPosition:d,data:s,selected:c,style:l={},className:h})=>{let[f,m,v]=getBezierPath({sourceX:o,sourceY:r,sourcePosition:i,targetX:a,targetY:n,targetPosition:d}),{bandwidth:k,length:E,color:w="#00FFFF",striped:T=false}=s||{},A={...l,stroke:w,strokeWidth:c?3:2,strokeDasharray:"none"};return jsxs(Fragment,{children:[jsx(BaseEdge,{id:e,path:f,style:A}),T&&jsx(BaseEdge,{id:`${e}-stripe`,path:f,style:{...l,stroke:"#000",strokeWidth:1.5,strokeDasharray:"6 6",opacity:.9}}),jsx(EdgeLabelRenderer,{children:c&&s&&(k||E)&&jsxs("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${m}px,${v}px)`,background:"#1f2937",padding:"4px 8px",borderRadius:"4px",fontSize:"10px",color:"white",fontFamily:"monospace",border:`1px solid ${w}`,pointerEvents:"none",zIndex:9999},children:[k&&jsx("div",{children:k}),E&&jsxs("div",{children:[E,"m"]})]})})]})};var vt=({id:e,sourceX:o,sourceY:r,targetX:a,targetY:n,sourcePosition:i,targetPosition:d,style:s={},data:c,markerEnd:l})=>{let[h]=getBezierPath({sourceX:o,sourceY:r,sourcePosition:i,targetX:a,targetY:n,targetPosition:d}),f=c?.connectorType||"C13";return jsx(BaseEdge,{id:e,path:h,markerEnd:l,style:(()=>{let v={stroke:c?.color||"#f59e0b",strokeWidth:f==="C19"?5:3,strokeLinecap:"round",strokeLinejoin:"round",...s};return f==="C19"?{...v,strokeDasharray:"none"}:{...v,strokeDasharray:"6,3"}})()})};var bo=({data:e,selected:o,style:r={},...a})=>{let{color:n="#00FFFF"}=e||{},i={...r,stroke:n,strokeWidth:o?4:3};return jsx(SmoothStepEdge,{...a,data:e,selected:o,style:i})};function Dr({sourceX:e,sourceY:o,targetX:r,targetY:a,sourcePosition:n,targetPosition:i}){let d=n===Position.Left||n===Position.Right,s;if(d){let c=(e+r)/2;s=`M ${e},${o} L ${c},${o} L ${c},${a} L ${r},${a}`;}else {let c=(o+a)/2;s=`M ${e},${o} L ${e},${c} L ${r},${c} L ${r},${a}`;}return s}var xo=({id:e,sourceX:o,sourceY:r,targetX:a,targetY:n,sourcePosition:i,targetPosition:d,data:s,selected:c,style:l={},...h})=>{let{color:f="#00FFFF",striped:m=false}=s||{},v=Dr({sourceX:o,sourceY:r,sourcePosition:i,targetX:a,targetY:n,targetPosition:d}),k={...l,stroke:f,strokeWidth:c?3:2,strokeDasharray:"none"};return jsxs(Fragment,{children:[jsx(BaseEdge,{id:e,path:v,style:k}),m&&jsx(BaseEdge,{id:`${e}-stripe`,path:v,style:{...l,stroke:"#000",strokeWidth:1.5,strokeDasharray:"6 6",opacity:.9}})]})};var wo=({id:e,sourceX:o,sourceY:r,targetX:a,targetY:n,sourcePosition:i,targetPosition:d,style:s={},data:c,markerEnd:l,selected:h})=>{let{color:f="#6366f1",label:m}=c||{},[v,k,E]=getBezierPath({sourceX:o,sourceY:r,sourcePosition:i,targetX:a,targetY:n,targetPosition:d}),w={...s,stroke:f,strokeWidth:8,strokeLinecap:"round",strokeLinejoin:"round",strokeDasharray:"none"};return jsxs(Fragment,{children:[jsx(BaseEdge,{id:e,path:v,markerEnd:l,style:w}),m&&jsx(EdgeLabelRenderer,{children:jsx("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${k}px,${E}px)`,background:"#1f2937",padding:"4px 8px",borderRadius:"4px",fontSize:"10px",color:"white",fontFamily:"monospace",border:`1px solid ${f}`,pointerEvents:"none",zIndex:9999},children:m})})]})};var No=(r=>(r.FULL="full",r.HALF="half",r))(No||{});var St={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 Ie(e){let o=St[e];if(!o)throw new Error(`Unknown connector type: ${e}`);let r=o.amperage===16,a=r?12:8,n=r?10:5,i=r?{borderRadius:"3px"}:{clipPath:"polygon(2px 0, calc(100% - 2px) 0, 100% 2px, 100% 100%, 0 100%, 0 2px)",borderRadius:"0px"};return {width:a,height:n,color:o.color,borderColor:o.borderColor,fontSize:r?"3px":"4px",...i}}function Je(e){let o=St[e];if(!o)throw new Error(`Unknown connector type: ${e}`);return o}function Lr(e){return Je(e).amperage===16}function Ht(e){return e%10<8?"C13":"C19"}function Qe(e){let o=e.toLowerCase();return o.includes("mx304")||o.includes("mx480")||o.includes("mx960")?"C20":"C14"}var Et=({data:e,selected:o})=>{let{label:r,status:a="active",deviceType:n="server",manufacturer:i,role:d,uHeight:s=1,width:c="full",ports:l=[],rearPorts:h=[],view:f}=e,m=f||(h.length>0&&l.length===0?"rear":"front"),v={};v["net-top"]="front",v["net-bottom"]="front",l.length>0&&l.forEach(x=>{x.ports.forEach(H=>{let y=H.type?.includes("power")?H.label:`${x.name}-${H.label}`;v[y]="front";});}),v["pwr-left-1"]="rear",v["pwr-left-2"]="rear",v["net-right-1"]="rear",v["net-right-2"]="rear",h.length>0&&h.forEach(x=>{x.ports.forEach(H=>{let y=H.type?.includes("power")?H.label:`${x.name}-${H.label}`;v[y]="rear";});});let k=s*20,E=c==="half"?"150px":"304px",w=c==="half"?"150px":void 0,T=(x,H)=>{let y=[];if(x.length===0)return y;let P=Math.max(4,Math.floor(k*.4)),M=Math.max(2,Math.floor(k*.2));return x.forEach((R,C)=>{R.ports.forEach((D,I)=>{let O=!!D.type&&D.type.includes("power");if(H==="front"&&O)return;let _=O?`${D.label}`:`${R.name}-${D.label}`,Z=D.connected,L="#6b7280";if(Z)if(D.type?.includes("power"))L=D.type==="power_c19"?"#fbbf24":"#f59e0b";else if(D.type==="console"||D.type==="mgmt")L="#8b5cf6";else if(D.type==="usb")L="#10b981";else switch(D.cableType){case "smf":L="#fbbf24";break;case "cat6":L="#8b5cf6";break;case "om3":L="#06b6d4";break;case "om4":L="#8b5cf6";break;case "om5":L="#84cc16";break;case "cat5e":L="#3b82f6";break;case "cat6a":L="#ef4444";break;case "cat7":L="#f97316";break;case "fiber":L="#3b82f6";break;case "ethernet":L="#10b981";break;default:L="#10b981";}let $=Position.Top,j={width:`${P}px`,height:`${M}px`,background:Z?L:"#6b7280",border:`1px solid ${Z?L:"#374151"}`,borderRadius:"1px",cursor:"pointer"};if(H==="front")I%2===0?($=Position.Top,j.transform="translateY(50%)",j.left=`${I/2*(P+2)}px`):($=Position.Bottom,j.transform="translateY(-50%)",j.left=`${(I-1)/2*(P+2)}px`);else if((n?.toLowerCase().replace(/_/g,"-")||"")==="patch-panel"||n==="switch")I%2===0?($=Position.Top,j.transform="translateY(50%)",j.left=`${I/2*(P+2)}px`):($=Position.Bottom,j.transform="translateY(-50%)",j.left=`${(I-1)/2*(P+2)}px`);else if(D.type?.includes("power")){$=Position.Left,j.transform="translateX(50%)";let ke=k<=20?10:20,gt=k<=20?30:50;j.top=`${ke+I*gt}%`;let Ye=Qe(r),pe=Ie(Ye);j={...j,width:`${pe.width}px`,height:`${pe.height}px`,zIndex:10,display:"flex",alignItems:"center",justifyContent:"center",fontSize:pe.fontSize,color:"#1a1a1a",fontFamily:"monospace",fontWeight:"bold",borderRadius:pe.borderRadius,clipPath:pe.clipPath};}else $=Position.Right,j.transform="translateX(-50%)",j.top=`${25+I*50}%`;let ae=(n?.toLowerCase().replace(/_/g,"-")||"")==="patch-panel",se;if(O)se="target";else if(n==="switch"||n==="router")se="source",y.push(jsx(Handle,{id:`${_}-target`,type:"target",position:$,style:j,title:`${R.name} - ${D.label} (input) ${Z?"(connected)":"(disconnected)"}`},`${_}-target`));else if(ae){se=H==="rear"?"source":"target";let me=H==="rear"?"target":"source";y.push(jsx(Handle,{id:`${_}-${me}`,type:me,position:$,style:j,title:`${R.name} - ${D.label} (${me}) ${Z?"(connected)":"(disconnected)"}`},`${_}-${me}`));}else se=Z?"source":"target";y.push(jsx(Handle,{id:_,type:se,position:$,style:j,title:`${R.name} - ${D.label} ${Z?"(connected)":"(disconnected)"}`,children:O?I+1:void 0},_));});}),y},A=()=>{let x=[],H=Math.max(4,Math.floor(k*.4)),y=Math.max(2,Math.floor(k*.2));if(m==="front"){if(l.length>0)return T(l,"front");if(n==="switch"&&(r.toLowerCase().includes("agg")||r.toLowerCase().includes("core")||d==="agg"||d==="core"))return W();x.push(jsx(Handle,{id:"net-top",type:"target",position:Position.Top,style:{width:`${H}px`,height:`${y}px`,background:"#10b981",border:"0.5px solid #059669",borderRadius:"1px",cursor:"pointer",transform:"translateY(50%)"},title:"Network Port (Top)"},"net-top")),x.push(jsx(Handle,{id:"net-bottom",type:"target",position:Position.Bottom,style:{width:`${H}px`,height:`${y}px`,background:"#10b981",border:"0.5px solid #059669",borderRadius:"1px",cursor:"pointer",transform:"translateY(-50%)"},title:"Network Port (Bottom)"},"net-bottom"));}else if(m==="rear"){if(h.length>0)return T(h,"rear");let P=n==="switch",R=(n?.toLowerCase().replace(/_/g,"-")||"")==="patch-panel";if(!R){let C=Qe(r),D=Je(C),I=Ie(C),O=k<=20?"10%":"25%";x.push(jsx(Handle,{id:"pwr-left-1",type:"target",position:Position.Left,style:{width:`${I.width}px`,height:`${I.height}px`,background:I.color,border:`1px solid ${I.borderColor}`,cursor:"pointer",transform:"translateX(50%)",top:O,zIndex:10,display:"flex",alignItems:"center",justifyContent:"center",fontSize:I.fontSize,color:"#1a1a1a",fontFamily:"monospace",fontWeight:"bold",borderRadius:I.borderRadius,clipPath:I.clipPath},title:`Power Port 1 (${D.type}) - ${D.voltage}V, ${D.amperage}A`,children:"1"},"pwr-1"));let _=k<=20?"50%":"75%";x.push(jsx(Handle,{id:"pwr-left-2",type:"target",position:Position.Left,style:{width:`${I.width}px`,height:`${I.height}px`,background:I.color,border:`1px solid ${I.borderColor}`,cursor:"pointer",transform:"translateX(50%)",top:_,zIndex:10,display:"flex",alignItems:"center",justifyContent:"center",fontSize:I.fontSize,color:"#1a1a1a",fontFamily:"monospace",fontWeight:"bold",borderRadius:I.borderRadius,clipPath:I.clipPath},title:`Power Port 2 (${D.type}) - ${D.voltage}V, ${D.amperage}A`,children:"2"},"pwr-2"));}!P&&!R&&(x.push(jsx(Handle,{id:"net-right-1",type:"target",position:Position.Right,style:{width:`${H}px`,height:`${y}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")),x.push(jsx(Handle,{id:"net-right-2",type:"target",position:Position.Right,style:{width:`${H}px`,height:`${y}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 x},W=()=>{let x=[],H=Math.max(10,Math.floor(k*.45)),y=Math.max(5,Math.floor(k*.25));for(let P=1;P<=16;P++){let M=jsx(Handle,{id:`port-${P}`,type:"source",position:Position.Top,style:{width:`${H}px`,height:`${y}px`,background:"#10b981",border:"1px solid #059669",borderRadius:"2px",cursor:"pointer",transform:"translateY(50%)",zIndex:1e3,left:`${(P-1)*(H+2)}px`},title:`Port ${P}`},`port-${P}`);x.push(M);}for(let P=17;P<=32;P++){let M=P-16,R=jsx(Handle,{id:`port-${P}`,type:"source",position:Position.Bottom,style:{width:`${H}px`,height:`${y}px`,background:"#10b981",border:"1px solid #059669",borderRadius:"2px",cursor:"pointer",transform:"translateY(-50%)",zIndex:1e3,left:`${(M-1)*(H+2)}px`},title:`Port ${P}`},`port-${P}`);x.push(R);}for(let P=1;P<=4;P++){let M=Math.max(4,Math.floor(k*.3)),R=Math.max(3,Math.floor(k*.15));x.push(jsx(Handle,{id:`uplink-${P}`,type:"source",position:Position.Right,style:{width:`${M}px`,height:`${R}px`,background:"#8b5cf6",border:"0.5px solid #7c3aed",borderRadius:"0.5px",cursor:"pointer",transform:"translateX(-50%)"},title:`Uplink ${P}`},`uplink-${P}`));}return x};return jsxs("div",{className:`device-node ${o?"selected":""}`,style:{background:"#1f2937",border:`1px solid ${ce(a)}`,borderRadius:"2px",padding:"0px",width:E,...w&&{left:w},height:`${k}px`,color:"white",fontFamily:"monospace",fontSize:"8px",boxShadow:o?"0 0 0 1px #3b82f6":"0 1px 2px rgba(0,0,0,0.1)",position:"relative",display:"flex",flexDirection:"column",justifyContent:"center",cursor:"grab",marginBottom:"0px",boxSizing:"border-box",marginTop:"0px",marginLeft:"0px",marginRight:"0px"},children:[jsxs("div",{style:{textAlign:"center",flex:1,display:"flex",flexDirection:"column",justifyContent:"center",overflow:"hidden",padding:"2px"},children:[jsx("div",{style:{fontWeight:"bold",fontSize:"7px",lineHeight:"1.1",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:r}),s>1&&jsx("div",{style:{fontSize:"6px",color:"#9ca3af",lineHeight:"1"},children:i})]}),s>1&&jsxs("div",{style:{position:"absolute",bottom:"1px",right:"1px",background:"#374151",color:"#9ca3af",padding:"1px 2px",borderRadius:"1px",fontSize:"6px",lineHeight:"1"},children:[s,"U"]}),jsx("div",{style:{position:"absolute",bottom:"1px",left:"1px",width:"4px",height:"4px",background:ce(a),borderRadius:"50%"}}),A()]})};var Rt=({data:e,selected:o})=>{let{label:r,status:a="active",heightCm:n=100,powerPorts:i=36,widthPx:d=15,mgmt_unit:s}=e,c=n*4.2,l=()=>{let m=Math.ceil(i/10),v=Array(10).fill(0).map((y,P)=>P<8?"10A":"16A");for(let y=0,P=0;y<m;++y)for(let M=0;M<10&&P<i;++M,++P){v[M];}let T=[],A=15,H=(c-A-3)/(i-9)*.5;for(let y=0;y<i;y++){let P=A-2+H*y,M=`${y+1}`;if(s&&(s==="top"&&y===0||s==="middle"&&y===Math.floor(i/2)||s==="bottom"&&y===i-1)){T.push(h(P));continue}let C=Ht(y),D=Ie(C),I=Math.round((d-D.width)/2-1);T.push(jsx(Handle,{type:"source",position:Position.Right,id:M,style:{position:"absolute",left:`${I}px`,top:`${P-D.height/2}px`,width:`${D.width}px`,height:`${D.height}px`,background:D.color,border:`1px solid ${D.borderColor}`,cursor:"pointer",zIndex:10,display:"flex",alignItems:"center",justifyContent:"center",fontSize:D.fontSize,color:"#1a1a1a",fontFamily:"monospace",fontWeight:"bold",borderRadius:D.borderRadius,clipPath:D.clipPath},title:`Power Port ${y+1} (${C})`,children:y+1},`handle-${M}`));}return T},h=f=>jsxs("div",{style:{position:"absolute",left:`${(d-16)/2}px`,top:`${f-12/2}px`,width:"16px",height:"12px",background:"#1a1a1a",border:"1px solid #374151",borderRadius:"1px",display:"flex",flexDirection:"column",padding:"1px",zIndex:10},children:[jsx("div",{style:{position:"absolute",left:"-10px",top:"1px",background:"#ffffff",border:"0.5px solid #6b7280",borderRadius:"0.5px",width:"8px",height:"10px",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"3px",color:"#10b981",fontFamily:"monospace",fontWeight:"bold",transform:"rotate(90deg)",transformOrigin:"center"},children:"APC"}),jsx(Handle,{type:"source",position:Position.Right,id:"mgmt-net-1",style:{width:"70%",height:"6px",background:"#10b981",border:"1px solid #059669",borderRadius:"1px",cursor:"pointer",zIndex:11,margin:"0 auto"},title:"Management Network Port"},"mgmt-net-1")]},"mgmt-unit");return jsxs("div",{className:`vertical-pdu-node ${o?"selected":""}`,style:{background:"linear-gradient(90deg, #2d3748 0%, #1a202c 50%, #2d3748 100%)",border:`1px solid ${ce(a)}`,borderRadius:"2px",padding:0,width:`${d}px`,height:`${c}px`,color:"white",fontFamily:"monospace",fontSize:"12px",boxShadow:o?"0 0 0 2px #3b82f6":"0 1px 3px rgba(0,0,0,0.3)",position:"relative",display:"flex",flexDirection:"column"},children:[jsx("div",{style:{textAlign:"center",marginBottom:0,zIndex:2,background:"linear-gradient(90deg, #4a5568 0%, #2d3748 50%, #4a5568 100%)",padding:"2px",position:"relative",height:"20px",display:"flex",flexDirection:"column",justifyContent:"center",borderBottom:"1px solid #4a5568"},children:jsx("div",{style:{fontWeight:"bold",fontSize:"6px",color:"#e2e8f0"},children:r})}),jsx("div",{style:{flex:1,background:"linear-gradient(180deg, #2d3748 0%, #1a202c 50%, #2d3748 100%)",position:"relative",minHeight:`${c-20}px`,overflow:"hidden"},children:l()})]})};var It=({data:e,selected:o,id:r})=>{let{lossDb:a}=e||{},n=useEdges(),i=n.find(m=>m.target===r&&m.targetHandle==="left"),d=n.find(m=>m.source===r&&m.sourceHandle==="right"),s=n.find(m=>m.target===r&&m.targetHandle==="right"),c=d||s,l=i?.data?.color||"#555",h=c?.data?.color||"#555",f=!!i&&!!c;return jsxs("div",{className:`splice-node ${o?"selected":""}`,style:{width:69,height:16,borderRadius:8,border:"none",outline:"none",position:"relative",background:"transparent",boxShadow:o?"0 0 0 2px #3b82f6":"none"},children:[jsxs("div",{style:{position:"absolute",inset:0,display:"grid",gridTemplateColumns:"1fr 1fr",borderRadius:8,overflow:"hidden",opacity:.75,pointerEvents:"none"},children:[jsx("div",{style:{background:l}}),jsx("div",{style:{background:h}})]}),jsx("div",{className:"splice-text-overlay",style:{position:"absolute",inset:0,borderRadius:8,pointerEvents:"none",zIndex:1}}),f&&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 a=="number"&&jsx("div",{className:"splice-text-label animate-in",style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",fontSize:9,fontFamily:"monospace",pointerEvents:"none",zIndex:3,fontWeight:"bold"},children:`${a.toFixed(2)} dB`}),jsx(Handle,{type:"target",position:Position.Left,id:"left",isConnectable:true,style:{width:12,height:12,borderRadius:"50%",border:"none",background:l,zIndex:100,cursor:"crosshair",left:-6,top:"50%",transform:"translateY(-50%)"}}),jsx(Handle,{type:"source",position:Position.Right,id:"right",isConnectable:true,style:{width:12,height:12,borderRadius:"50%",border:"none",background:h,zIndex:100,cursor:"crosshair",right:-6,top:"50%",transform:"translateY(-50%)"}}),jsx(Handle,{type:"target",position:Position.Right,id:"right",isConnectable:true,style:{width:12,height:12,borderRadius:"50%",border:"none",background:h,zIndex:100,cursor:"crosshair",right:-6,top:"50%",transform:"translateY(-50%)"}})]})};var we=20,He=32,Ho=4,Ne=12,Ur=69,Ce=80,$t=(Ce-Ur)/2;var Ft=(e,o,r,a)=>{if(!e.parentId||e.parentId!==o.id)return r;let n=He,i=r.y-n,d=Math.round(i/we)+1,c=Math.max(1,Math.min(Ne,d));if(!_t(o,e,c,a)){let f=et(o,e,a,c);if(f!==c)return {x:$t,y:n+(f-1)*we+5,holderPosition:f}}let h=n+(c-1)*we+5;return {x:$t,y:h,holderPosition:c}},_t=(e,o,r,a)=>!a.filter(i=>i.parentId===e.id&&i.type==="splice"&&i.id!==o.id).some(i=>i.data.holderPosition===r),et=(e,o,r,a=1)=>{for(let n=a;n<=Ne;n++)if(_t(e,o,n,r))return n;for(let n=a-1;n>=1;n--)if(_t(e,o,n,r))return n;return 1},Me=(e,o)=>{let n=He+(o-1)*we+5;return {x:$t,y:n}};var zt=({data:e,selected:o})=>{let{label:r="Splice Tray"}=e||{},[a,n]=useState(false),i=()=>{if(!a)return null;let d=[],s=He;for(let c=1;c<=Ne;c++){let l=s+(c-1)*we;d.push(jsxs("div",{style:{position:"absolute",left:"-35px",top:`${l}px`,background:"#374151",color:"#9ca3af",padding:"2px 4px",borderRadius:"2px",fontSize:"8px",fontWeight:"bold",width:"28px",textAlign:"center",border:"1px solid #4b5563",zIndex:10,height:`${we}px`,display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1},children:["H",c]},c));}return d};return jsxs("div",{className:`splice-tray-node ${o?"selected":""}`,style:{background:"transparent",border:"none",borderRadius:"8px",padding:0,width:`${Ce}px`,height:`${He+Ne*we+Ho}px`,color:"white",fontFamily:"monospace",fontSize:"12px",boxShadow:o?"0 0 0 2px #3b82f6":"0 2px 4px rgba(0,0,0,0.1)",position:"relative",display:"flex",flexDirection:"column"},children:[jsxs("div",{style:{textAlign:"center",marginBottom:0,zIndex:2,background:"#1f2937",padding:"2px",position:"relative",height:`${He}px`,display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"center",gap:"6px",borderRadius:"8px"},children:[jsx("div",{style:{fontWeight:"bold",fontSize:"10px"},children:r}),jsx("button",{onPointerDown:d=>{d.stopPropagation();},onMouseDown:d=>{d.stopPropagation();},onClick:d=>{d.stopPropagation(),d.preventDefault(),n(!a);},style:{background:a?"#10b981":"#374151",color:a?"#ffffff":"#9ca3af",border:"1px solid #4b5563",borderRadius:"2px",padding:"2px 6px",fontSize:"8px",cursor:"pointer",fontFamily:"monospace"},title:`${a?"Hide":"Show"} holder markers`,children:"H"})]}),i(),jsx("div",{style:{position:"absolute",top:He,left:0,right:0,bottom:0,pointerEvents:"none"}})]})};var Co=["#1f77b4","#ff7f0e","#2ca02c","#8c564b","#708090","#ffffff","#d62728","#000000","#ffdf00","#8a2be2","#ff69b4","#00ffff"];function oe(e){let o=(e-1)%12;return Co[o]}function Eo(e){return e>12}function Ue(e){let o=oe(e);return Eo(e)?{background:o,backgroundImage:`repeating-linear-gradient(45deg, ${o} 0 6px, #000 6px 9px)`}:{background:o}}function Lt(e){return oe(e)}var Mt=({data:e,selected:o,id:r})=>{let{fibersPerTube:a=12,tubeIndex:n=1,startOn:i="left-center"}=e||{},d=Math.max(1,Math.min(24,Number(a)||12)),s=14,c=4,l=1,h=2,f=20,m=d*s+(d-1)*c,v=Math.max(60,m+l*2+h*2),k=oe((n-1)%12+1),E=`tube-${n}`,w=18,T={width:w,height:w,borderRadius:"50%",opacity:.25,pointerEvents:"auto",background:k,backgroundColor:k,border:`2px solid ${k}`,"--fiber-bg":k},A=()=>i==="left"?Position.Left:i==="right"?Position.Right:Position.Bottom,W=()=>{let x=[],H=v-h*2-l*2,y,P,M=false;i==="left"?(y=l,P=Position.Top):i==="right"?(y=l+H-m,P=Position.Top,M=true):(y=l+(H-m)/2,P=Position.Top);for(let R=0;R<d;R++){let C=M?d-R:R+1,D=Ue(C),I=oe(C),O=y+R*(s+c),_=l,Z=D.backgroundImage?D.backgroundImage:I,L={position:"absolute",left:`${O}px`,top:`${_}px`,width:s,height:s,borderRadius:"50%",border:"none",background:Z,backgroundColor:I,zIndex:10,cursor:"pointer","--fiber-bg":I};D.backgroundImage&&(L["--fiber-bg-image"]=D.backgroundImage);let $=`fiber-${C}`;x.push(jsxs(Or.Fragment,{children:[jsx(Handle,{id:$,type:"target",position:P,className:"tube-fiber-handle",isConnectable:true,style:L,"data-fiber-idx":C,"data-fiber-color":I}),jsx(Handle,{id:$,type:"source",position:P,className:"tube-fiber-handle",isConnectable:true,style:L,"data-fiber-idx":C,"data-fiber-color":I})]},`fiber-${C}`));}return x};return jsxs("div",{style:{width:v,height:f,borderRadius:4,background:"#111827",border:`${h}px solid ${o?"#3b82f6":k}`,position:"relative",boxShadow:o?`0 0 0 ${h}px #3b82f6`:"0 2px 4px rgba(0,0,0,0.2)",padding:l,boxSizing:"border-box"},children:[W(),jsx(Handle,{id:E,type:"target",position:A(),isConnectable:true,style:T,"data-tube-idx":n,"data-tube-color":k}),jsx(Handle,{id:E,type:"source",position:A(),isConnectable:true,style:T,"data-tube-idx":n,"data-tube-color":k})]})};var Ut=({data:e,selected:o})=>{let{tubeCount:r=12,fibersPerTube:a=12,fiberCount:n,cableId:i="CBL-002",label:d,tubeStartIndex:s=1,color:c}=e||{},l=Math.max(1,Math.min(24,Number(r)||12)),h=Math.max(1,Number(s)||1),f=8,m=2,v=6,k=v+f+4,E=60,w=Math.max(120,l*(f+m)+v*2),T=n??l*(Number(a)||12),A=d??`${T}f Cable`,W=i?`Cable ID ${i}`:void 0,x=oe(h),H=c||x,y=o?"#3b82f6":H,P=()=>{let I=[];for(let O=0;O<l;O++){let _=h+O,Z=Ue(_),L=oe(_),$=v+O*(f+m),j=-4,V=Z.backgroundImage?Z.backgroundImage:L,ae={position:"absolute",left:`${$}px`,top:`${j}px`,width:f,height:f,borderRadius:"50%",border:"none",background:V,backgroundColor:L,zIndex:10,cursor:"pointer","--fiber-bg":L};Z.backgroundImage&&(ae["--fiber-bg-image"]=Z.backgroundImage);let se=`tube-${_}`;I.push(jsxs(Or.Fragment,{children:[jsx(Handle,{id:se,type:"target",position:Position.Top,className:"tube-fiber-handle",isConnectable:true,style:ae,"data-fiber-idx":_,"data-tube-idx":_,"data-tube-color":L}),jsx(Handle,{id:se,type:"source",position:Position.Top,className:"tube-fiber-handle",isConnectable:true,style:ae,"data-fiber-idx":_,"data-tube-idx":_,"data-tube-color":L})]},`tube-${_}`));}return I},M="cable-button",R=8,C={width:R,height:R,borderRadius:"50%",background:H,backgroundColor:H,border:`1px solid ${H}`,cursor:"pointer",zIndex:10};return jsxs("div",{style:{width:w,height:E,borderRadius:4,background:"#111827",border:`2px solid ${y}`,position:"relative",boxShadow:o?"0 0 0 2px #3b82f6":"0 2px 4px rgba(0,0,0,0.2)",padding:v,paddingTop:k,boxSizing:"border-box",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",color:"#e5e7eb",fontFamily:"monospace",textAlign:"center",gap:2},children:[P(),jsx(Handle,{id:M,type:"source",position:Position.Bottom,className:"cable-button-handle",isConnectable:true,style:C,"data-handle-type":"cable-button","data-cable-color":H}),jsx(Handle,{id:M,type:"target",position:Position.Bottom,className:"cable-button-handle",isConnectable:true,style:C,"data-handle-type":"cable-button","data-cable-color":H}),jsx("div",{style:{fontSize:11,fontWeight:600,textTransform:"uppercase",letterSpacing:.5},children:A}),W&&jsx("div",{style:{fontSize:10,opacity:.8},children:W})]})};var Bt=({data:e,selected:o,id:r})=>{let{connector:a="LC",couplerFiberCount:n,label:i,portLabelsLeft:d,portLabelsRight:s}=e||{},c=useEdges(),l=typeof n=="number"&&[1,2,4].includes(n)?n:2,h=Math.max(1,Math.min(4,l)),f=7,m=3,v=3,k=60,E=30,w=h*f+(h-1)*m,T=Math.max(E,w+v*2),A=Math.max(k,80),W=(y,P)=>{let M=`${y}-${P+1}`;return c.find(C=>C.source===r&&C.sourceHandle===M||C.target===r&&C.targetHandle===M)?.data?.color||"#555"},x=y=>{let P=[],M=y==="left"?Position.Left:Position.Right,R=y==="left"?d:s;for(let C=0;C<h;C++){let D=C+1,I=`${y}-${D}`,O=W(y,C),L=v+(T-w)/2+C*(f+m),$={position:"absolute",left:y==="left"?-5:void 0,right:y==="right"?-5:void 0,top:`${L}px`,width:f,height:f,borderRadius:"50%",border:"none",background:O,zIndex:100,cursor:"crosshair",transform:"translateY(-50%)"};P.push(jsxs(Or.Fragment,{children:[jsx(Handle,{id:I,type:"target",position:M,isConnectable:true,style:$}),jsx(Handle,{id:I,type:"source",position:M,isConnectable:true,style:$})]},I)),R&&R[C]&&P.push(jsx("div",{style:{position:"absolute",left:y==="left"?-30:void 0,right:y==="right"?-30:void 0,top:`${L}px`,transform:"translateY(-50%)",fontSize:"8px",color:"#9ca3af",fontFamily:"monospace",pointerEvents:"none",textAlign:y==="left"?"right":"left",width:"25px"},children:R[C]},`${I}-label`));}return P},H=i||`${a}-${h}f`;return jsxs("div",{className:`coupler-node ${o?"selected":""}`,style:{width:A,height:T,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:`${v}px`,boxSizing:"border-box"},children:[x("left"),jsx("div",{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",textAlign:"center",pointerEvents:"none",zIndex:1},children:jsx("div",{style:{fontWeight:"bold",fontSize:"9px"},children:H})}),x("right")]})};var Ee=32,st=30,jr=24,Gr=80,it=400,at=300,Wo=2,he=8,zo=120;function Ot(e){let{couplerFiberCount:o}=e.data||{},r=typeof o=="number"&&[1,2,4].includes(o)?o:2,a=Math.max(1,Math.min(4,r)),n=7,i=3,d=3,s=60,c=30,l=a*n+(a-1)*i,h=Math.max(c,l+d*2);return {width:Math.max(s,80),height:h}}function dt(e){let{fibersPerTube:o=12}=e.data||{},r=Math.max(1,Math.min(24,Number(o)||12)),a=14,n=4,i=1,d=2,s=20,c=r*a+(r-1)*n;return {width:Math.max(60,c+i*2+d*2),height:s}}function Lo(e){return {width:Ce,height:0}}function Oe(e){return e.type==="coupler"?Ot(e):e.type==="tube"?dt(e):e.type==="splice-tray"?Lo():{width:80,height:30}}function Mo(e){return e.data?.panelWidth||it}function Zr(e){return e.data?.panelHeight||at}function Uo(e){return Mo(e)-Wo*2-he*2}function Kr(e,o){return Uo(e)-o}function Bo(e,o=st){return Math.floor(e/o)+1}function Oo(e,o=st){return (e-1)*o}function qr(e,o,r){let a=st,n=Bo(r.y,a),i=Oo(n,a);return {x:r.x,y:i,slotPosition:n}}function Yt(e,o){if(o.length===0)return {width:e.data?.panelWidth||it,height:e.data?.panelHeight||at};let r=o.some(l=>l.type==="tube"),a=o.some(l=>l.type==="splice-tray"),n=o.some(l=>l.type==="coupler"),i,d=5;if(r&&a&&n){let l=0,h=0;for(let f of o)if(f.type==="tube"){let m=dt(f);m.width>l&&(l=m.width);}else if(f.type==="coupler"){let m=Ot(f);m.width>h&&(h=m.width);}i=he+l+zo+Ce+h+d;}else {let l=0;for(let h of o){let f=Oe(h),m=(h.position?.x||0)+f.width;m>l&&(l=m);}i=l+he+d;}i=Math.max(e.data?.panelWidth||it,i);let s=Ee;for(let l of o){let h=Oe(l),f=(l.position?.y||0)+h.height;f>s&&(s=f);}let c=Math.max(e.data?.panelHeight||at,s+he);return {width:i,height:c}}function Yo(e,o,r){if(e===0)return 0;if(e===1)return o;let a=e*o,n=r-a,i=Math.max(5,n/(e-1));return o+i}function Jr(e,o,r){return Yo(e,o,r)}var _o=20,Fo=400,Ao=300;function Vo(e,o){if(o.length===0)return {width:e.data?.closureWidth||e.data?.panelWidth||Fo,height:e.data?.closureHeight||e.data?.panelHeight||Ao};let r=o.some(c=>c.type==="tube"),a=o.some(c=>c.type==="splice-tray"),n,i=5;if(r&&a){let c=0,l=0,h=0,f=o.filter(v=>v.type==="tube"),m=o.filter(v=>v.type==="splice-tray");if(f.length>0&&m.length>0){let v=f.map(A=>A.position?.x||0);Math.min(...v);Math.max(...v);let w=m.map(A=>A.position?.x||0),T=w.reduce((A,W)=>A+W,0)/w.length;for(let A of f){let W=dt(A);(A.position?.x||0)<T?W.width>c&&(c=W.width):W.width>l&&(l=W.width);}m.length>0&&(h=Ce),n=he+c+_o+h+_o+l+i;}else {let v=0;for(let k of o){let E=Oe(k),w=(k.position?.x||0)+E.width;w>v&&(v=w);}n=v+he+i;}}else {let c=0;for(let l of o){let h=Oe(l),f=(l.position?.x||0)+h.width;f>c&&(c=f);}n=c+he+i;}n=Math.max(e.data?.closureWidth||e.data?.panelWidth||Fo,n);let d=Ee;for(let c of o){let l=Oe(c),h=(c.position?.y||0)+l.height;h>d&&(d=h);}let s=Math.max(e.data?.closureHeight||e.data?.panelHeight||Ao,d+he);return {width:n,height:s}}var jt=({data:e,selected:o,id:r})=>{let{label:a="Patch Panel",header:n,panelWidth:i,panelHeight:d}=e||{},{getNodes:s,setNodes:c}=useReactFlow(),l=useRef(false),h=useMemo(()=>s().filter(A=>A.parentId===r),[s,r]),f=useMemo(()=>({id:r,type:"patch-panel",position:{x:0,y:0},data:{...e,panelWidth:i,panelHeight:d}}),[r,e,i,d]),m=useMemo(()=>i&&d?{width:i,height:d}:h.length===0?{width:i||400,height:d||300}:Yt(f,h),[h,f,i,d]);useEffect(()=>{if(i&&d||l.current)return;let T=i,A=d,W=Math.abs((T||0)-m.width),x=Math.abs((A||0)-m.height);(W>1||x>1)&&(l.current=true,c(H=>H.map(y=>y.id===r?{...y,data:{...y.data,panelWidth:m.width,panelHeight:m.height}}:y)),setTimeout(()=>{l.current=false;},0));},[r,m.width,m.height,i,d,c]);let v=m.width,k=m.height,E=Ee,w=n||a;return jsxs("div",{className:`patch-panel-node ${o?"selected":""}`,style:{background:"transparent",border:"none",borderRadius:"8px",padding:0,width:`${v}px`,height:`${k}px`,color:"white",fontFamily:"monospace",fontSize:"12px",boxShadow:o?"0 0 0 2px #3b82f6":"0 2px 4px rgba(0,0,0,0.1)",position:"relative",display:"flex",flexDirection:"column",backgroundColor:"#1f2937",boxSizing:"border-box"},children:[jsx("div",{style:{textAlign:"center",marginBottom:0,zIndex:2,background:"#374151",padding:"6px 12px",position:"relative",height:`${E}px`,display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"center",gap:"6px",borderRadius:"6px 6px 0 0",borderBottom:"1px solid #4b5563"},children:jsx("div",{style:{fontWeight:"bold",fontSize:"11px"},children:w})}),jsx("div",{style:{position:"absolute",top:E,left:0,right:0,bottom:0,pointerEvents:"none",overflow:"visible"}})]})};var Kt=({data:e,selected:o,id:r})=>{let{label:a="Closure",header:n,closureWidth:i,closureHeight:d,panelWidth:s,panelHeight:c}=e||{},{getNodes:l,setNodes:h}=useReactFlow(),f=useRef(false),m=useMemo(()=>l().filter(H=>H.parentId===r),[l,r]),v=useMemo(()=>({id:r,type:"closure",position:{x:0,y:0},data:{...e,closureWidth:i||s,closureHeight:d||c}}),[r,e,i,d,s,c]),k=useMemo(()=>i&&d?{width:i,height:d}:s&&c?{width:s,height:c}:m.length===0?{width:i||s||400,height:d||c||300}:Vo(v,m),[m,v,i,d,s,c]);useEffect(()=>{if(i&&d||s&&c||f.current)return;let x=i||s,H=d||c,y=Math.abs((x||0)-k.width),P=Math.abs((H||0)-k.height);(y>1||P>1)&&(f.current=true,h(M=>M.map(R=>R.id===r?{...R,data:{...R.data,closureWidth:k.width,closureHeight:k.height}}:R)),setTimeout(()=>{f.current=false;},0));},[r,k.width,k.height,i,d,s,c,h]);let E=k.width,w=k.height,T=Ee,A=n||a,W=E/2;return jsxs("div",{className:`closure-node ${o?"selected":""}`,style:{background:"transparent",border:"none",borderRadius:`${W}px ${W}px 12px 12px`,padding:0,width:`${E}px`,height:`${w}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",transform:"translateX(-4px)"},children:[jsx("div",{style:{textAlign:"center",marginBottom:0,zIndex:2,background:"#374151",padding:"6px 12px",position:"relative",height:`${T}px`,display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"center",gap:"6px",borderRadius:`${W}px ${W}px 0 0`,borderBottom:"1px solid #4b5563",transform:"translateX(4px)"},children:jsx("div",{style:{fontWeight:"bold",fontSize:"11px"},children:A})}),jsx("div",{style:{position:"absolute",top:T,left:0,right:0,bottom:0,pointerEvents:"none",overflow:"visible"}})]})};function dn(e,o){if(!e.source||!e.target||!e.sourceHandle||!e.targetHandle)return {valid:true};let r=o.edges.some(w=>w.source===e.source&&w.sourceHandle===e.sourceHandle),a=o.edges.some(w=>w.target===e.target&&w.targetHandle===e.targetHandle);if(r)return {valid:false,reason:"Source port is already connected"};if(a)return {valid:false,reason:"Target port is already connected"};let n=e.sourceHandle,i=e.targetHandle,d=o.nodes.find(w=>w.id===e.source),s=o.nodes.find(w=>w.id===e.target),c=(w,T)=>{if(!w)return false;let A=w.startsWith("pwr")||w.startsWith("power"),W=T?.type==="vertical-pdu"&&w!=="mgmt-net-1";return A||W},l=(w,T)=>{if(!w)return false;if(T?.type==="vertical-pdu"&&w==="mgmt-net-1"||T?.type==="tube"&&w.startsWith("fiber-")||(T?.type==="tube"||T?.type==="cable")&&w.startsWith("tube-")||T?.type==="splice"&&(w==="left"||w==="right"))return true;let A=w.startsWith("net-")||w.startsWith("port-")||w.startsWith("uplink-")||w.includes("Fiber")||w.includes("Ports"),W=/^[A-Z0-9]+-\d+$/.test(w)&&!w.startsWith("pwr")&&!w.startsWith("power");return A||W},h=c(n,d),f=c(i,s),m=l(n,d),v=l(i,s);if(h&&v||f&&m)return {valid:false,reason:"Cannot connect network cable to power port"};if(h&&!f||f&&!h)return {valid:false,reason:"Power ports must connect to power-compatible ports"};let k=d?.type==="vertical-pdu",E=s?.type==="vertical-pdu";if(h||f){let w=k?s:E?d:null,T=k?d:E?s:null;if(w&&T&&o.edges.filter(x=>{let H=c(x.sourceHandle||""),y=c(x.targetHandle||""),P=x.source===w.id||x.target===w.id;return (H||y)&&P}).some(x=>x.source===T.id||x.target===T.id))return {valid:false,reason:"Dual-feed required: connect second power to a different PDU"}}return {valid:true}}function ct(e,o){if(!o)return;let r=typeof e=="string"?e.replace(/-(target|source)$/i,""):e,a=o.data??{},n=a.handleSideMap;if(n&&n[r])return n[r];if(r==="net-top"||r==="net-bottom")return "front";if(r==="pwr-left-1"||r==="pwr-left-2"||r==="net-right-1"||r==="net-right-2")return "rear";let i=Array.isArray(a.ports)?a.ports:[],d=Array.isArray(a.rearPorts)?a.rearPorts:[];if(r.startsWith("pwr")||r.includes("power"))return "rear";for(let c of i)for(let l of c.ports||[])if((!!l.type&&String(l.type).includes("power")?l.label:`${c.name}-${l.label}`)===r)return "front";for(let c of d)for(let l of c.ports||[])if((!!l.type&&String(l.type).includes("power")?l.label:`${c.name}-${l.label}`)===r)return "rear"}function qt(e={},o={}){let r={nodes:e.nodes??[],edges:e.edges??[],debug:e.debug??false},a=new Set;return {getState:()=>r,setState:f=>{r={...r,...f},a.forEach(m=>m(r));},subscribe:f=>(a.add(f),()=>a.delete(f)),selectEdgeZIndex:f=>{let m=r.nodes.find(H=>H.id===f.target);if(!m||m.type!=="device")return 1e3;let v=m.data?.view||"front",k=ct(f.targetHandle||"",m);if(k)return v===k?1e3:500;let E=(f.targetHandle||"").toString(),w=E.toLowerCase(),T=w.startsWith("pwr")||w.startsWith("power"),A=w.startsWith("net-")||w.startsWith("port-")||w.startsWith("uplink-")||w.includes("fiber")||w.includes("ports"),W=/^[A-Z0-9]+-\d+$/i.test(E)&&!w.startsWith("pwr")&&!w.startsWith("power"),x=A||W;return T?v==="rear"?1e3:500:x?v==="front"?1e3:500:1e3},validateConnection:f=>(o.validateConnection||dn)(f,r),selectNodeById:f=>r.nodes.find(m=>m.id===f),selectConnectedEdges:f=>r.edges.filter(m=>m.source===f||m.target===f)}}function cn(e){let o=n=>e.subscribe(n),r=()=>e.getState();return useSyncExternalStore(o,r,r)}function Qt(e){let o=a=>e.subscribe(a),r=()=>e.getState().nodes;return useSyncExternalStore(o,r,r)}function eo(e){let o=a=>e.subscribe(a),r=()=>e.getState().edges;return useSyncExternalStore(o,r,r)}function Xo(e){return e.selectEdgeZIndex}function jo(e){let o=300,r=(e.data.uHeight||42)*20,a=e.position.x,n=e.position.x+o,i=e.position.y,d=e.position.y+r;return {left:a,right:n,top:i,bottom:d}}function lt(e,o){let r=jo(o);return e.x>=r.left&&e.x<=r.right&&e.y>=r.top&&e.y<=r.bottom}function pt(e,o){let r=null,a=1/0;for(let n of o){if(!lt(e,n))continue;let i=Math.sqrt(Math.pow(e.x-n.position.x,2)+Math.pow(e.y-n.position.y,2));i<a&&(a=i,r=n);}return r}function G(e){let{edges:o,connection:r,edgeType:a,selectEdgeZIndex:n,findBy:i,data:d}=e,s=i==="source"?r.sourceHandle:r.targetHandle,c=i==="source"?r.source:r.target;if(!s||!c)return null;let l=o.find(E=>i==="source"?E.source===c&&E.sourceHandle===s:E.target===c&&E.targetHandle===s);if(!l)return null;let h=o.filter(E=>E.id!==l.id),f=addEdge(r,h),m=f[f.length-1],v=n({...r,id:m.id,type:a}),k={...m,type:a,zIndex:v,style:{...m.style,zIndex:v},data:d!==void 0?d:m.data};return [...f.slice(0,-1),k]}var vn=(e,o,r)=>({rack:a=>jsx(xt,{...a,onViewChange:e,onRackFaceChange:o,isDragOver:r?r()===a.id:false}),fiber:wt,device:Et,"vertical-pdu":Rt,splice:It,"splice-tray":zt,tube:Mt,cable:Ut,coupler:Bt,"patch-panel":jt,closure:Kt}),Pn={fiber:kt,power:vt,smoothstep:bo,step:xo,"thick-cable":wo},Sn=({nodes:e,edges:o,initialNodes:r,initialEdges:a,onNodesChange:n,onEdgesChange:i,store:d,debug:s,onNodeClick:c,onEdgeClick:l,onViewChange:h,onRackFaceChange:f,className:m,style:v,alignRacksToBottom:k,colorMode:E="dark",onInit:w,onFlowMethods:T,showDownloadButton:A=false,downloadButtonPosition:W="top-right",downloadButtonText:x="Download Image",downloadButtonStyle:H,allowReconnectExisting:y=false,useSmoothstepEdgesForTubes:P=false,connectOnClick:M=true})=>{let R=Array.isArray(e)&&Array.isArray(o),C=Or.useMemo(()=>d||qt({nodes:R?e||[]:r||e||[],edges:R?o||[]:a||o||[],debug:s}),[d,R,s]),D=Qt(C),I=eo(C),[O,_,Z]=useNodesState(D),[L,$,j]=useEdgesState(I),V=Xo(C),ae=useRef(null),{toObject:se,setViewport:me,setNodes:ut,setEdges:ft,getNodes:ke}=useReactFlow();useEffect(()=>{T&&T({toObject:se,setViewport:me,setNodes:t=>{ut(t),C.setState({nodes:t});},setEdges:t=>{ft(t),C.setState({edges:t});},toImage:t=>ae.current?toPng(ae.current,t):Promise.reject(new Error("ReactFlow wrapper not available"))});},[T,se,me,ut,ft,C]);let gt=useCallback(()=>{if(!ae.current){s&&console.error("ReactFlow wrapper ref is not available");return}toPng(ae.current,{filter:t=>!(t?.classList?.contains("react-flow__minimap")||t?.classList?.contains("react-flow__controls")||t?.classList?.contains("react-flow__attribution")||t?.classList?.contains("download-button")||t?.tagName==="BUTTON"),backgroundColor:E==="light"?"#ffffff":"#1a1a1a",pixelRatio:2}).then(t=>{let p=document.createElement("a");p.download=`network-diagram-${new Date().toISOString().split("T")[0]}.png`,p.href=t,p.click();}).catch(t=>{s&&console.error("Error downloading image:",t);});},[E,s]),[Ye,pe]=useState(null),io=useRef(null),ao=useRef(h),so=useRef(f);useEffect(()=>{ao.current=h;},[h]),useEffect(()=>{so.current=f;},[f]),useEffect(()=>{io.current=Ye;},[Ye]);let co=useCallback(()=>io.current,[]),tr=useMemo(()=>vn((t,p)=>ao.current?.(t,p),(t,p)=>so.current?.(t,p),co),[co]),or=useMemo(()=>Pn,[]),ge=useRef(O);useEffect(()=>{ge.current=O;},[O]);let z=useRef(L);useEffect(()=>{z.current=L;},[L]),useEffect(()=>{_(D);},[D,_]),useEffect(()=>{$(I);},[I,$]),useEffect(()=>{R&&C.setState({nodes:e||[]});},[R,e,C]),useEffect(()=>{R&&C.setState({edges:o||[]});},[R,o,C]),useEffect(()=>{if(!k||!O||O.length===0)return;let t=O.filter(U=>U.type==="rack");if(t.length===0)return;let p=t.map(U=>{let de=U.data?.uHeight||42,fe=60+de*20;return (U.position?.y||0)+fe}),b=Math.min(...p),g=Math.max(...p);if(g-b<20)return;let u=g,F=O.map(U=>{if(U.type!=="rack")return U;let de=U.data?.uHeight||42,fe=60+de*20,K=(U.position?.y||0)+fe,B=u-K;return Math.abs(B)<5?U:{...U,position:{x:U.position?.x||0,y:(U.position?.y||0)+B}}});F.some((U,te)=>U.position!==O[te].position)&&_(F);},[k,O,_]);let X=useCallback(t=>ge.current.find(p=>p.id===t),[]),Ve=useCallback((t,p)=>{if(!t||!p)return;let b=X(t);if(!b)return;if(b.type==="tube"&&p.startsWith("fiber-")){let N=p.replace("fiber-",""),u=parseInt(N,10);if(u>=1&&u<=24){let F=Lt(u),Y=u>12;return {color:F,striped:Y}}}if((b.type==="cable"||b.type==="tube")&&p.startsWith("tube-")){let N=p.replace("tube-",""),u=parseInt(N,10);if(u>=1&&u<=24){let F=oe(u),Y=u>12;return {color:F,striped:Y}}}let g=b.data;if(g.color)return {color:g.color}},[X]);useEffect(()=>{$(t=>t.map(p=>{let b=V(p);return {...p,zIndex:b,style:{...p.style,zIndex:b}}}));},[O,$,V]),useEffect(()=>{let t=O.map(b=>{if(b.type==="coupler"&&b.parentId){let g=X(b.parentId);if(g&&(g.type==="patch-panel"||g.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 g=X(b.parentId);if(g&&g.type==="splice-tray"){let N=Me(g,b.data.holderPosition);return {...b,position:N}}}if(b.type==="device"&&b.parentId&&b.data.uPosition&&(!b.position||b.position.x===0&&b.position.y===0)){let g=X(b.parentId);if(g){let N=De(g,b.data.uPosition);return {...b,position:N}}}return b});t.some((b,g)=>{let N=O[g];return b.extent!==N.extent||b.position?.x!==N.position?.x||b.position?.y!==N.position?.y})&&_(t);},[O,_,X]);let rr=useCallback(t=>{let p=t.map(b=>{if(b.type==="position"&&b.position){let g=X(b.id);if(g&&g.type==="coupler"&&g.parentId){let N=X(g.parentId);if(N&&(N.type==="patch-panel"||N.type==="closure")){if(!g.extent||g.extent!=="parent"){let u={...g,extent:"parent"};_(F=>F.map(Y=>Y.id===g.id?u:Y));}return {...b,position:g.position||{x:0,y:0}}}}if(g&&(g.type==="tube"||g.type==="splice-tray")&&g.parentId){let N=X(g.parentId);if(N&&N.type==="closure"){if(!g.extent||g.extent!=="parent"){let u={...g,extent:"parent"};_(F=>F.map(Y=>Y.id===g.id?u:Y));}return {...b,position:g.position||{x:0,y:0}}}}if(g&&g.type==="splice"&&g.parentId){let N=X(g.parentId);if(N&&N.type==="splice-tray"){let u=Ft(g,N,b.position,ge.current);if(u.holderPosition!==void 0){let F={...g,data:{...g.data,holderPosition:u.holderPosition}};_(Y=>Y.map(U=>U.id===g.id?F:U));}return {...b,position:{x:u.x,y:u.y}}}}if(g&&g.type==="device"&&g.parentId){let N=X(g.parentId);if(N){let u=mt(g,N,b.position,ge.current);if(u.uPosition!==void 0){let F={...g,data:{...g.data,uPosition:u.uPosition}};_(Y=>Y.map(U=>U.id===g.id?F:U));}return {...b,position:{x:u.x,y:u.y}}}}if(g&&g.type==="device"&&g.parentId){let N=X(g.parentId);if(N){let u=N;if(!lt(b.position,u)){let F=b.position.x+u.position.x,Y=b.position.y+u.position.y,U={...g,parentId:void 0,extent:void 0,data:{...g.data,uPosition:void 0}};return _(te=>te.map(de=>de.id===g.id?U:de)),{...b,position:{x:F,y:Y}}}}}}return b});Z(p);},[Z,_,X]),nr=useCallback((t,p)=>{pe(null);},[]),ir=useCallback((t,p,b)=>{if(p.type==="device"&&!p.parentId){let g=ge.current.filter(u=>u.type==="rack").map(u=>u),N=pt(p.position,g);pe(N?.id??null);}else pe(null);},[]),ar=useCallback((t,p,b)=>{if(p.type==="device"&&!p.parentId){let g=ge.current.filter(u=>u.type==="rack").map(u=>u),N=pt(p.position,g);if(N){let u=p.position.x-N.position.x,F=p.position.y-N.position.y,Y={...p,parentId:N.id,extent:"parent",position:{x:u,y:F},data:{...p.data,uPosition:1}},U=ge.current.map(te=>te.id===p.id?Y:te);_(U),R||C.setState({nodes:U});}}pe(null);},[_,R,C]),sr=useCallback(t=>{if(!t.source||!t.target||!t.sourceHandle||!t.targetHandle)return true;let p=X(t.source),b=X(t.target);if(p?.type==="tube"&&b?.type==="tube"&&t.sourceHandle.startsWith("fiber-")&&t.targetHandle.startsWith("fiber-"))return s&&console.log("Connection rejected: Cannot connect fibres within tubes",t),false;if(p?.type==="tube"&&t.sourceHandle.startsWith("fiber-")&&(b?.type==="cable"||b?.type==="tube")&&t.targetHandle.startsWith("tube-"))return s&&console.log("Connection rejected: Cannot connect individual fibre to cable/tube tube handle",t),false;if((p?.type==="cable"||p?.type==="tube")&&t.sourceHandle.startsWith("tube-")&&b?.type==="tube"&&t.targetHandle.startsWith("fiber-"))return s&&console.log("Connection rejected: Cannot connect cable/tube tube handle to individual fibre",t),false;if(b?.type==="splice"&&(t.targetHandle==="left"||t.targetHandle==="right")){if(z.current.find(u=>u.target===t.target&&u.targetHandle===t.targetHandle||u.source===t.target&&u.sourceHandle===t.targetHandle))return s&&console.log("Splice handle already connected, will replace",t),true;s&&console.log("Allowing connection to splice handle",t);}if(p?.type==="tube"&&t.sourceHandle.startsWith("fiber-"))return b?.type!=="splice"?(s&&console.log("Connection rejected: Tube fiber handles can only connect to splices",t),false):z.current.find(u=>u.source===t.source&&u.sourceHandle===t.sourceHandle)?(s&&console.log("Tube fiber handle already connected, will replace",t),true):(s&&console.log("Allowing connection from tube fiber handle to splice",t),true);if((p?.type==="cable"||p?.type==="tube")&&t.sourceHandle.startsWith("tube-"))return t.targetHandle.startsWith("tube-")?z.current.find(u=>u.source===t.source&&u.sourceHandle===t.sourceHandle)?(s&&console.log("Tube-level handle already connected, will replace",t),true):(s&&console.log("Allowing connection from tube-level handle to tube handle",t),true):(s&&console.log("Connection rejected: Tube handles can only connect to other tube handles",t),false);if(p?.type==="splice"&&t.sourceHandle==="right"){if(z.current.find(u=>u.source===t.source&&u.sourceHandle===t.sourceHandle||u.target===t.source&&u.targetHandle===t.sourceHandle))return s&&console.log("Splice source handle already connected, will replace",t),true;s&&console.log("Allowing connection from splice source handle",t);}if(b?.type==="tube"&&t.targetHandle.startsWith("fiber-"))return p?.type!=="splice"?(s&&console.log("Connection rejected: Tube fiber handles can only connect from splices",t),false):z.current.find(u=>u.target===t.target&&u.targetHandle===t.targetHandle)?(s&&console.log("Tube fiber target handle already connected, will replace",t),true):(s&&console.log("Allowing connection from splice to tube fiber handle",t),true);if((b?.type==="cable"||b?.type==="tube")&&t.targetHandle.startsWith("tube-"))return t.sourceHandle.startsWith("tube-")?z.current.find(u=>u.target===t.target&&u.targetHandle===t.targetHandle)?(s&&console.log("Tube-level target handle already connected, will replace",t),true):(s&&console.log("Allowing connection from tube handle to tube-level handle",t),true):(s&&console.log("Connection rejected: Tube handles can only connect from other tube handles",t),false);if(p?.type==="coupler"&&(t.sourceHandle?.startsWith("left-")||t.sourceHandle?.startsWith("right-")))return b?.type!=="splice"?(s&&console.log("Connection rejected: Coupler handles can only connect to splices",t),false):t.targetHandle!=="left"&&t.targetHandle!=="right"?(s&&console.log("Connection rejected: Coupler can only connect to splice left/right handles",t),false):z.current.find(u=>u.source===t.source&&u.sourceHandle===t.sourceHandle)?(s&&console.log("Coupler handle already connected, will replace",t),true):(s&&console.log("Allowing connection from coupler handle to splice",t),true);if(b?.type==="coupler"&&(t.targetHandle?.startsWith("left-")||t.targetHandle?.startsWith("right-")))return p?.type!=="splice"?(s&&console.log("Connection rejected: Coupler handles can only connect from splices",t),false):t.sourceHandle!=="left"&&t.sourceHandle!=="right"?(s&&console.log("Connection rejected: Coupler can only connect from splice left/right handles",t),false):z.current.find(u=>u.target===t.target&&u.targetHandle===t.targetHandle)?(s&&console.log("Coupler target handle already connected, will replace",t),true):(s&&console.log("Allowing connection from splice to coupler handle",t),true);if(t.source&&t.sourceHandle&&z.current.find(u=>u.source===t.source&&u.sourceHandle===t.sourceHandle))return s&&console.log("Source handle already connected, will replace",t),true;if(t.target&&t.targetHandle&&z.current.find(u=>u.target===t.target&&u.targetHandle===t.targetHandle))return s&&console.log("Target handle already connected, will replace",t),true;if((p?.type==="cable"||b?.type==="cable")&&(t.sourceHandle==="cable-button"||t.targetHandle==="cable-button"))return t.sourceHandle!=="cable-button"||t.targetHandle!=="cable-button"?(s&&console.log("Connection rejected: Cable button handles can only connect to other cable button handles",t),false):z.current.find(F=>F.source===t.source&&F.sourceHandle===t.sourceHandle)?(s&&console.log("Cable button source handle already connected, will replace",t),true):z.current.find(F=>F.target===t.target&&F.targetHandle===t.targetHandle)?(s&&console.log("Cable button target handle already connected, will replace",t),true):(s&&console.log("Allowing connection between cable button handles",t),true);let g=C.validateConnection({source:t.source??null,target:t.target??null,sourceHandle:t.sourceHandle??null,targetHandle:t.targetHandle??null});if(!g.valid&&y){if(t.source&&t.sourceHandle&&z.current.find(u=>u.source===t.source&&u.sourceHandle===t.sourceHandle))return s&&console.log("Source handle has existing edge, will replace",t),true;if(t.target&&t.targetHandle&&z.current.find(u=>u.target===t.target&&u.targetHandle===t.targetHandle))return s&&console.log("Target handle has existing edge, will replace",t),true}return s&&!g.valid&&console.log("Connection rejected by store validation:",g.reason,t),g.valid},[X,C,s,y]),dr=useCallback(t=>{let p=X(t.source),b=X(t.target),g=p?.type==="vertical-pdu",N=p?.data,u=p?.type==="device"&&N?.deviceType==="switch",F=!!t.targetHandle&&(t.targetHandle.startsWith("pwr")||t.targetHandle.startsWith("power")),Y=!!t.targetHandle&&(t.targetHandle.startsWith("net-")||t.targetHandle.startsWith("port-")||/^[A-Z0-9]+-\d+$/i.test(t.targetHandle)),U=p?.type==="tube"&&b?.type==="cable",te=p?.type==="cable"&&b?.type==="tube",de=U||te,fe=t.sourceHandle==="cable-button"&&t.targetHandle==="cable-button",K="fiber";g&&F?K="power":fe?K="thick-cable":de&&(K=P?"smoothstep":"fiber");let B;if((K==="fiber"||K==="smoothstep")&&!g){let S=Ve(t.source,t.sourceHandle);S&&(B={color:S.color,striped:S.striped});}else if(K==="thick-cable"&&fe){let S=p?.data;B={color:S?.color||(S?.tubeStartIndex?oe(S.tubeStartIndex):"#6366f1")};}if(t.source&&t.sourceHandle){let S=G({edges:z.current,connection:t,edgeType:K,selectEdgeZIndex:V,findBy:"source",data:B});if(S){$(S);return}}if(t.target&&t.targetHandle){let S=G({edges:z.current,connection:t,edgeType:K,selectEdgeZIndex:V,findBy:"target",data:B});if(S){$(S);return}}if(b?.type==="splice"&&(t.targetHandle==="left"||t.targetHandle==="right")&&t.target&&t.targetHandle){let S=G({edges:z.current,connection:t,edgeType:"fiber",selectEdgeZIndex:V,findBy:"target",data:B});if(S){$(S);return}if(t.targetHandle==="right"&&(S=G({edges:z.current,connection:t,edgeType:"fiber",selectEdgeZIndex:V,findBy:"source",data:B}),S)){$(S);return}}if(p?.type==="splice"&&t.sourceHandle==="right"&&t.source&&t.sourceHandle){let S=G({edges:z.current,connection:t,edgeType:"fiber",selectEdgeZIndex:V,findBy:"source",data:B});if(S){$(S);return}if(S=G({edges:z.current,connection:t,edgeType:"fiber",selectEdgeZIndex:V,findBy:"target",data:B}),S){$(S);return}}if(p?.type==="tube"&&t.sourceHandle?.startsWith("fiber-")&&t.source&&t.sourceHandle){let S=G({edges:z.current,connection:t,edgeType:"fiber",selectEdgeZIndex:V,findBy:"source",data:B});if(S){$(S);return}}if(b?.type==="tube"&&t.targetHandle?.startsWith("fiber-")&&t.target&&t.targetHandle){let S=G({edges:z.current,connection:t,edgeType:"fiber",selectEdgeZIndex:V,findBy:"target",data:B});if(S){$(S);return}}if((p?.type==="cable"||p?.type==="tube")&&t.sourceHandle?.startsWith("tube-")&&t.source&&t.sourceHandle){let S=G({edges:z.current,connection:t,edgeType:K,selectEdgeZIndex:V,findBy:"source",data:B});if(S){$(S);return}}if((b?.type==="cable"||b?.type==="tube")&&t.targetHandle?.startsWith("tube-")&&t.target&&t.targetHandle){let S=G({edges:z.current,connection:t,edgeType:K,selectEdgeZIndex:V,findBy:"target",data:B});if(S){$(S);return}}if(fe&&t.source&&t.sourceHandle&&t.target&&t.targetHandle){let S=p?.data,J=S?.color||(S?.tubeStartIndex?oe(S.tubeStartIndex):"#6366f1"),be=G({edges:z.current,connection:t,edgeType:"thick-cable",selectEdgeZIndex:V,findBy:"source",data:{color:J}});if(be){$(be);return}if(be=G({edges:z.current,connection:t,edgeType:"thick-cable",selectEdgeZIndex:V,findBy:"target",data:{color:J}}),be){$(be);return}}if(g&&F&&t.target&&t.targetHandle){let S=G({edges:z.current,connection:t,edgeType:"power",selectEdgeZIndex:V,findBy:"target",data:B});if(S){$(S);return}}if(u&&Y&&t.target&&t.targetHandle){let S=G({edges:z.current,connection:t,edgeType:"fiber",selectEdgeZIndex:V,findBy:"target",data:B});if(S){$(S);return}}let Re=C.validateConnection({source:t.source??null,target:t.target??null,sourceHandle:t.sourceHandle??null,targetHandle:t.targetHandle??null});if(!Re.valid){if(y){if(t.source&&t.sourceHandle){let S=G({edges:z.current,connection:t,edgeType:K,selectEdgeZIndex:V,findBy:"source",data:B});if(S){$(S);return}}if(t.target&&t.targetHandle){let S=G({edges:z.current,connection:t,edgeType:K,selectEdgeZIndex:V,findBy:"target",data:B});if(S){$(S);return}}}if(g&&t.source&&t.sourceHandle){let S=G({edges:z.current,connection:t,edgeType:F?"power":"fiber",selectEdgeZIndex:V,findBy:"source",data:B});if(S){$(S);return}}if(u&&t.source&&t.sourceHandle){let S=G({edges:z.current,connection:t,edgeType:"fiber",selectEdgeZIndex:V,findBy:"source",data:B});if(S){$(S);return}}s&&console.warn(`Connection rejected: ${Re.reason}`);return}let ve={...t,type:K,zIndex:V({...t,id:"temp-id"}),data:B};$(S=>{let J=addEdge(ve,S),be=J[J.length-1];return be&&(po(ht=>new Set(ht).add(be.id)),setTimeout(()=>{po(ht=>{let uo=new Set(ht);return uo.delete(be.id),uo});},1e3)),J});},[$,C,V,X,s,Ve,y,P]),cr=useCallback((t,p)=>{if(!p.source||!p.target||!p.sourceHandle||!p.targetHandle)return;let b=t.sourceHandle||"",g=t.targetHandle||"",N=p.sourceHandle||"",u=p.targetHandle||"";if(b.startsWith("tube-")&&N!==b){s&&console.log("Edge update blocked: Cannot disconnect tube handle",{oldEdge:t,newConnection:p});return}if(g.startsWith("tube-")&&u!==g){s&&console.log("Edge update blocked: Cannot disconnect tube handle",{oldEdge:t,newConnection:p});return}let F=X(p.source),Y=X(p.target),U=F?.type==="vertical-pdu",te=!!p.targetHandle&&(p.targetHandle.startsWith("pwr")||p.targetHandle.startsWith("power")),de=F?.type==="tube"&&Y?.type==="cable",fe=F?.type==="cable"&&Y?.type==="tube",K=de||fe,B;U&&te?B="power":K?B=P?"smoothstep":"fiber":B="fiber";let Re;if((B==="fiber"||B==="smoothstep")&&!U){let ve=Ve(p.source,p.sourceHandle);ve&&(Re={color:ve.color,striped:ve.striped});}$(ve=>ve.map(J=>J.id===t.id?{...J,source:p.source,target:p.target,sourceHandle:p.sourceHandle,targetHandle:p.targetHandle,type:B,data:Re!==void 0?{...J.data,...Re}:J.data,zIndex:V({...p,id:J.id,type:B}),style:{...J.style,zIndex:V({...p,id:J.id,type:B})}}:J));},[$,X,Ve,V,P,s]),lr=useCallback((t,p)=>{let b=t.metaKey||t.ctrlKey;if(p.type==="tube"&&p.parentId&&!b){let N=ke().find(u=>u.id===p.parentId&&u.type==="cable");if(N){_(u=>u.map(F=>({...F,selected:F.id===N.id}))),c&&c(N);return}}if(b&&p.type==="device"){let g=p.data||{},N=g.view||(Array.isArray(g.rearPorts)&&g.rearPorts.length>0?"rear":"front"),u=N==="front"?"rear":"front";s&&console.log(`Command+click: Toggling device ${p.id} from ${N} to ${u}`),h&&h(p.id,u),c&&c(p);}else c&&c(p);},[h,c,s,ke,_]),pr=useCallback(()=>{},[]),ur=useCallback((t,p)=>{l&&l(p);},[l]),[ue,bt]=useState(null),[lo,po]=useState(new Set);useOnSelectionChange({onChange:({nodes:t})=>{if(t&&t.length===1){let p=t[0];if(p.type==="tube"&&p.parentId){let g=ke().find(N=>N.id===p.parentId&&N.type==="cable");if(g){bt(g),_(N=>N.map(u=>({...u,selected:u.id===g.id}))),c&&c(g);return}}bt(p),c&&c(p);}else bt(null),c&&c(null);}});let fr=useCallback((t,{nodeId:p,handleType:b})=>{s&&console.log("Connection started from",{nodeId:p,handleType:b});},[s]),gr=useCallback(t=>{s&&console.log("Connection ended",t);},[s]),br=useCallback(()=>{if(!ue)return;let t=X(ue.id);if(t){if(t.type==="rack"){let g=((t.data||{}).face||"front")==="front"?"rear":"front";f?(f(t.id,g),h&&ke().filter(u=>u.parentId===t.id).forEach(u=>{h(u.id,g);})):_(N=>N.map(u=>u.id===t.id?{...u,data:{...u.data,face:g}}:u.parentId===t.id?{...u,data:{...u.data,view:g}}:u));return}if(t.type==="device"){let p=t.data||{},b=Array.isArray(p.rearPorts)&&p.rearPorts.length>0,g=Array.isArray(p.ports)&&p.ports.length>0,u=(p.view||(b&&!g?"rear":"front"))==="front"?"rear":"front";h?h(t.id,u):_(F=>F.map(Y=>Y.id===t.id?{...Y,data:{...Y.data,view:u}}:Y));}}},[ue,X,f,h,_,ke]),hr=useMemo(()=>L.map(t=>{let p=t,b=X(String(p.source)),g=X(String(p.target)),N=ct(p.sourceHandle||"",b),u=ct(p.targetHandle||"",g),F=b&&b.data?.view,Y=g&&g.data?.view,U=b?.type==="device"&&F==="rear",te=g?.type==="device"&&Y==="rear",B=U&&N!=="rear"&&(te&&u!=="rear")?{...t.style,opacity:0,pointerEvents:"none",zIndex:0}:t.style;return {...t,style:B,className:lo.has(t.id)?"edge-connecting":t.className}}),[L,lo,X]);return jsxs("div",{ref:ae,className:`${m||""} ${E==="light"?"react-flow-light":"react-flow-dark"}`,style:{width:"100%",height:"100%",...v},children:[jsxs(ReactFlow,{nodes:O,edges:hr,onNodesChange:t=>{rr(t),R?n&&n(ge.current):C.setState({nodes:ge.current});},onEdgesChange:t=>{let p=t.filter(b=>{if(b.type==="remove"){let g=z.current.find(N=>N.id===b.id);if(g){let N=g.sourceHandle||"",u=g.targetHandle||"";if(N.startsWith("tube-")||u.startsWith("tube-"))return s&&console.log("Edge deletion blocked: Edge connected to tube handle is not detachable",g),false}}return true});p.length>0&&(j(p),R?i&&i(z.current):C.setState({edges:z.current}));},onConnect:dr,onConnectStart:fr,onConnectEnd:gr,onEdgeUpdate:cr,isValidConnection:sr,onNodeClick:lr,onNodeDoubleClick:pr,onNodeDragStart:nr,onNodeDrag:ir,onNodeDragStop:ar,onEdgeClick:ur,onInit:w,nodeTypes:tr,edgeTypes:or,defaultEdgeOptions:{zIndex:1e3,reconnectable:true},nodesDraggable:true,nodesConnectable:true,elementsSelectable:true,selectNodesOnDrag:false,connectOnClick:M,fitView:true,proOptions:{hideAttribution:true},children:[jsx(Background,{color:E==="light"?"#e5e5e5":"#2a2a2a"}),jsx(Controls,{}),jsx(MiniMap,{}),jsx(Panel,{position:"bottom-right",className:"react-networks-attribution",children:jsx("a",{href:"https://github.com/MP70/react-networks",target:"_blank",rel:"noopener noreferrer",className:"react-networks-attribution-link",children:"react-networks"})})]}),A&&jsx("button",{className:"download-button",onClick:gt,style:{position:"absolute",top:W.includes("top")?"10px":"auto",bottom:W.includes("bottom")?"10px":"auto",right:W.includes("right")?"10px":"auto",left:W.includes("left")?"10px":"auto",zIndex:1e3,background:"#374151",color:"#e5e7eb",border:"1px solid #4b5563",borderRadius:"4px",padding:"0.5rem 0.75rem",fontSize:"0.875rem",cursor:"pointer",transition:"all 0.2s ease",...H},children:x}),ue&&(ue.type==="rack"||ue.type==="device")&&jsx("div",{style:{position:"absolute",top:12,right:12,display:"flex",gap:8,zIndex:2e3},children:jsx("button",{onClick:t=>{t.preventDefault(),br();},style:{background:"#374151",color:"#e5e7eb",border:"1px solid #4b5563",borderRadius:4,padding:"6px 10px",fontSize:11,fontFamily:"monospace",cursor:"pointer"},title:(()=>{let t=ue.data;if(ue.type==="rack")return (t?.face||"front")==="front"?"Switch to rear":"Switch to front";{let p=Array.isArray(t?.rearPorts)&&t.rearPorts.length>0,b=Array.isArray(t?.ports)&&t.ports.length>0;return (t?.view||(p&&!b?"rear":"front"))==="front"?"Switch to rear":"Switch to front"}})(),children:(()=>{let t=ue.data;if(ue.type==="rack")return (t?.face||"front")==="front"?"\u21C4 Rear":"\u21C4 Front";{let p=Array.isArray(t?.rearPorts)&&t.rearPorts.length>0,b=Array.isArray(t?.ports)&&t.ports.length>0;return (t?.view||(p&&!b?"rear":"front"))==="front"?"\u21C4 Rear":"\u21C4 Front"}})()})})]})},Hn=e=>jsx(ReactFlowProvider,{children:jsx(Sn,{...e})});var Ko=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}}),qo=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}}),Jo=e=>{let o=n=>{if(!n)return;if(typeof n=="string")return n;let i=n.device;return typeof i=="object"&&i?i.id:i},r=o(e.termination_a),a=o(e.termination_b);return {id:`cable-${e.id}`,source:`device-${r}`,target:`device-${a}`,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}}},Cn=e=>{let o=[],r=[];return e.racks.forEach(a=>o.push(Ko(a))),e.devices.forEach(a=>o.push(qo(a))),e.cables.forEach(a=>r.push(Jo(a))),{nodes:o,edges:r}},En=e=>{let o=e.filter(n=>n.type==="rack"),r=e.filter(n=>n.type==="device"),a=e.filter(n=>!["rack","device"].includes(n.type));return o.forEach((n,i)=>{n.position={x:i*300,y:100};}),r.forEach(n=>{if(n.parentId){let i=o.find(d=>d.id===n.parentId);if(i){let d=n.data.uPosition||1,s=n.data.uHeight||1;n.position={x:i.position.x+50,y:i.position.y+d*20-s*10};}}else n.position={x:Math.random()*400+100,y:Math.random()*200+50};}),a.forEach((n,i)=>{n.position={x:i*150+100,y:300};}),e};var We=class extends Error{constructor(r,a,n,i,d){super(`Device placement conflict: ${a} at U${n}-${n+i-1} in rack ${r}${d?` conflicts with ${d}`:""}`);this.rackId=r;this.deviceId=a;this.uPosition=n;this.uHeight=i;this.conflictWith=d;this.name="DevicePlacementError";}};function ro(e,o={}){let r=[],a=[];for(let n of e.devices)n.unit+n.height-1>e.units&&a.push({deviceId:n.id,uPosition:n.unit,uHeight:n.height,rackUHeight:e.units});for(let n=0;n<e.devices.length;n++){let i=e.devices[n],d=i.unit,s=i.unit+i.height-1;for(let c=n+1;c<e.devices.length;c++){let l=e.devices[c],h=l.unit,f=l.unit+l.height-1;d<=f&&s>=h&&r.push({deviceId:i.id,uPosition:i.unit,uHeight:i.height,conflictWith:l.id});}}return {isValid:r.length===0&&a.length===0,conflicts:r,outOfBounds:a}}function Qo(e,o,r={}){let{deviceTypeMapping:a={}}=r,n=a[e.type]||"device",i=De(o,e.unit,e.height);return {id:e.id,type:n,position:i,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}}}function Rn(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:[]}}}function Tn(e,o={}){let{conflictPolicy:r="strict",validatePlacements:a=true}=o,n=[],i=[];if(a)for(let d of e){let s=ro(d,o);if(!s.isValid&&r==="strict"){let c=[];throw s.conflicts.forEach(l=>{c.push(`Device ${l.deviceId} at U${l.uPosition}-${l.uPosition+l.uHeight-1} conflicts with ${l.conflictWith}`);}),s.outOfBounds.forEach(l=>{c.push(`Device ${l.deviceId} at U${l.uPosition}-${l.uPosition+l.uHeight-1} exceeds rack height (${l.rackUHeight}U)`);}),new We(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=Rn(d);n.push(s);for(let c of d.devices)try{let l=Qo(c,s,o);i.push(l);}catch(l){if(r==="strict")throw l;if(r==="nearest"){let h=Ge(s,{id:c.id,data:{label:c.name,uHeight:c.height}},i,c.unit);if(h!==c.unit){console.warn(`Device ${c.id} moved from U${c.unit} to U${h} due to conflict`);let f={...c,unit:h},m=Qo(f,s,o);i.push(m);}else throw new We(d.id,c.id,c.unit,c.height)}}}return n.push(...i),n}function Dn(e){let o=[],r=e.filter(a=>a.type==="rack");for(let a of r){let i=e.filter(d=>d.type==="device"&&d.parentId===a.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,ports:d.data.ports,connections:d.data.connections}));o.push({id:a.id,name:a.data.label,position:a.position,units:a.data.uHeight||42,uNumberingDirection:a.data.uNumberingDirection||"bottom-up",customHeaderText:a.data.customHeaderText,devices:i});}return o}function In(e,o,r,a){return e.map(n=>n.id!==o?n:{...n,devices:n.devices.map(i=>i.id!==r?i:{...i,unit:a})})}function $n(e,o,r,a={}){let{conflictPolicy:n="strict"}=a;return e.map(i=>{if(i.id!==o)return i;if(n==="strict"&&!ro({...i,devices:[...i.devices,r]},a).isValid)throw new We(o,r.id,r.unit,r.height);return {...i,devices:[...i.devices,r]}})}function _n(e,o,r){return e.map(a=>a.id!==o?a:{...a,devices:a.devices.filter(n=>n.id!==r)})}var ze=class extends Error{constructor(r,a,n,i){super(`Splice placement conflict: ${a} at holder ${n} in tray ${r}${i?` conflicts with ${i}`:""}`);this.trayId=r;this.spliceId=a;this.holder=n;this.conflictWith=i;this.name="SplicePlacementError";}};function no(e,o={}){let r=[],a=[];for(let n of e.splices)(n.holder<1||n.holder>Ne)&&a.push({spliceId:n.id,holder:n.holder,max:Ne});for(let n=0;n<e.splices.length;n++){let i=e.splices[n];for(let d=n+1;d<e.splices.length;d++){let s=e.splices[d];i.holder===s.holder&&r.push({spliceId:i.id,holder:i.holder,conflictWith:s.id});}}return {isValid:r.length===0&&a.length===0,conflicts:r,outOfBounds:a}}function er(e,o){let r=Me(o,e.holder);return {id:e.id,type:"splice",position:r,parentId:o.id,extent:"parent",data:{label:e.name,holderPosition:e.holder,lossDb:e.lossDb}}}function Fn(e){return {id:e.id,type:"splice-tray",position:e.position,data:{label:e.name,status:"active"}}}function An(e,o={}){let{conflictPolicy:r="strict",validatePlacements:a=true}=o,n=[],i=[];if(a)for(let d of e){let s=no(d,o);if(!s.isValid&&r==="strict"){let c=[];throw s.conflicts.forEach(l=>{c.push(`Splice ${l.spliceId} at holder ${l.holder} conflicts with ${l.conflictWith}`);}),s.outOfBounds.forEach(l=>{c.push(`Splice ${l.spliceId} at holder ${l.holder} is out of bounds (max: ${l.max})`);}),new ze(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=Fn(d);n.push(s);for(let c of d.splices)try{let l=er(c,s);i.push(l);}catch(l){if(r==="strict")throw l;if(r==="nearest"){let h=[...n,...i],f=et(s,{id:c.id,data:{label:c.name,holderPosition:c.holder}},h,c.holder);if(f!==c.holder){console.warn(`Splice ${c.id} moved from holder ${c.holder} to holder ${f} due to conflict`);let m={...c,holder:f},v=er(m,s);i.push(v);}else throw new ze(d.id,c.id,c.holder)}}}return n.push(...i),n}function Wn(e){let o=[],r=e.filter(a=>a.type==="splice-tray");for(let a of r){let i=e.filter(d=>d.type==="splice"&&d.parentId===a.id).map(d=>({id:d.id,name:d.data.label,holder:d.data.holderPosition||1,lossDb:d.data.lossDb}));o.push({id:a.id,name:a.data.label,position:a.position,splices:i});}return o}function zn(e,o,r,a){return e.map(n=>n.id!==o?n:{...n,splices:n.splices.map(i=>i.id!==r?i:{...i,holder:a})})}function Ln(e,o,r,a={}){let{conflictPolicy:n="strict"}=a;return e.map(i=>{if(i.id!==o)return i;if(n==="strict"&&!no({...i,splices:[...i.splices,r]},a).isValid)throw new ze(o,r.id,r.holder);return {...i,splices:[...i.splices,r]}})}function Mn(e,o,r){return e.map(a=>a.id!==o?a:{...a,splices:a.splices.filter(n=>n.id!==r)})}
|
|
2
|
-
export{
|
|
1
|
+
import Yr,{useState,useRef,useMemo,useEffect,useSyncExternalStore,useCallback}from'react';import {useReactFlow,Handle,Position,getBezierPath,BaseEdge,EdgeLabelRenderer,useEdges,addEdge,ReactFlowProvider,useNodesState,useEdgesState,useOnSelectionChange,ReactFlow,Background,Controls,MiniMap,Panel,SmoothStepEdge}from'reactflow';import {toPng}from'html-to-image';import {jsx,jsxs,Fragment}from'react/jsx-runtime';var yr=()=>"bottom-up",Pe=e=>e.data.uNumberingDirection||yr(),Xe=(e,o,r)=>r==="bottom-up"?o-e+1:e,je=(e,o,r)=>r==="bottom-up"?o-e+1:e;var mt=(e,o,r,a)=>{if(!e.parentId||e.parentId!==o.id)return r;let n=e.data.uHeight||1,i=o.data.uHeight||42,d=Pe(o),s=60,c=r.y-s,l=Math.round(c/20)+1,h;d==="bottom-up"?h=Xe(l,i,d)-n+1:h=Xe(l,i,d);let f=i-n+1,m=Math.max(1,Math.min(f,h));if(d==="top-down"&&h<=1&&(m=1),!yt(o,e,m,a)){let k=Ge(o,e,a,m);k!==m&&(m=k);}let v;if(d==="bottom-up"){let k=m+n-1,E=je(k,i,d);v=s+(E-1)*20-1;}else {let k=je(m,i,d);v=s+(k-1)*20-1;}return {x:r.x,y:v,uPosition:m}},yt=(e,o,r,a)=>{let n=o.data.uHeight||1,i=e.data.uHeight||42;if(r<1||r+n-1>i)return false;let d=a.filter(s=>s.type==="device"&&s.parentId===e.id&&s.id!==o.id);for(let s of d){let c=s.data.uPosition||1,l=s.data.uHeight||1,h=r,f=r+n-1,m=c,v=c+l-1;if(h<=v&&f>=m)return false}return true},Ge=(e,o,r,a=1)=>{let n=o.data.uHeight||1,i=e.data.uHeight||42;for(let d=a;d<=i-n+1;d++)if(yt(e,o,d,r))return d;return 1},De=(e,o,r=1)=>{let a=60,n=Pe(e),i=e.data.uHeight||42,d=je(o,i,n),s;if(n==="bottom-up"){let c=o+r-1,l=je(c,i,n);s=a+(l-1)*20-1;}else s=a+(d-1)*20-1;return {x:0,y:s}},go=(e,o,r)=>{let a=e.data.uHeight||1,n=De(o,r,a);return {...e,position:n,data:{...e.data,uPosition:r}}},xr=(e,o)=>{let r=e.data.uPosition||1,a=e.data.uHeight||1,n=o.data.uHeight||42,i=Math.max(1,Math.min(n-a+1,r));return i!==r?go(e,o,i):e};function ce(e){switch(e){case "active":return "#10b981";case "inactive":return "#6b7280";case "maintenance":return "#f59e0b";default:return "#6b7280"}}var xt=({data:e,selected:o,id:r,onViewChange:a,onRackFaceChange:n,isDragOver:i=false})=>{let{label:d,ports:s=0,status:c="active",uHeight:l=42,face:h="front",customHeaderText:f}=e,{getNodes:m,setNodes:v}=useReactFlow(),k=m(),[E,w]=useState(true),T=()=>{let H=Pe({data:e})==="bottom-up"?"top-down":"bottom-up";v(y=>y.map(P=>P.id===r?{...P,data:{...P.data,uNumberingDirection:H}}:P));},A=()=>{let x=h==="front"?"rear":"front";n?(n(r,x),a&&k.filter(y=>y.parentId===r).forEach(y=>{a(y.id,x);})):a?k.filter(y=>y.parentId===r).forEach(y=>{a(y.id,x);}):v(H=>H.map(y=>y.id===r?{...y,data:{...y.data,face:x}}:y.parentId===r?{...y,data:{...y.data,view:x}}:y));},W=()=>{let x=[],H=60,y=Pe({data:e});for(let P=1;P<=l;P++){let M=H+(P-1)*20-4,R=Xe(P,l,y);x.push(jsx("div",{style:{position:"absolute",left:"-35px",top:`${M}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:R},P));}return x};return jsxs("div",{className:`rack-node ${o?"selected":""} ${i?"drag-over":""}`,style:{background:"transparent",border:`2px solid ${ce(c)}`,borderRadius:"8px",padding:0,width:`${300}px`,height:`${60+l*20}px`,color:"white",fontFamily:"monospace",fontSize:"12px",boxShadow:i?"0 0 20px #3b82f6, 0 0 40px #3b82f6, 0 0 60px #3b82f6":o?"0 0 0 2px #3b82f6":"0 2px 4px rgba(0,0,0,0.1)",position:"relative",display:"flex",flexDirection:"column",transition:"box-shadow 0.2s ease-in-out"},children:[jsxs("div",{style:{textAlign:"center",marginBottom:0,zIndex:2,background:"#1f2937",padding:"8px",position:"relative",height:`${60}px`,display:"flex",flexDirection:"column",justifyContent:"center"},children:[jsx("div",{style:{fontWeight:"bold",marginBottom:"4px"},children:d}),jsxs("div",{style:{fontSize:"10px",color:"#9ca3af"},children:[f?jsx("span",{style:{color:"#fbbf24",fontWeight:"bold"},children:f}):jsxs("span",{children:[typeof s=="number"?s:0," ports"]})," \u2022 ",l,"U \u2022 ",h]}),jsxs("div",{style:{display:"flex",gap:"4px",position:"absolute",top:"4px",right:"4px"},children:[jsx("button",{onPointerDown:x=>{x.stopPropagation();},onMouseDown:x=>{x.stopPropagation();},onClick:x=>{x.stopPropagation(),x.preventDefault(),w(!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"}),jsx("button",{onPointerDown:x=>{x.stopPropagation();},onMouseDown:x=>{x.stopPropagation();},onClick:x=>{x.stopPropagation(),x.preventDefault(),T();},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 ${Pe({data:e})==="bottom-up"?"top-down":"bottom-up"}`,children:Pe({data:e})==="bottom-up"?"\u2191\u2193":"\u2193\u2191"}),jsx("button",{onPointerDown:x=>{x.stopPropagation();},onMouseDown:x=>{x.stopPropagation();},onClick:x=>{x.stopPropagation(),x.preventDefault(),A();},style:{background:"#374151",color:"#9ca3af",border:"1px solid #4b5563",borderRadius:"2px",padding:"2px 6px",fontSize:"8px",cursor:"pointer",fontFamily:"monospace"},title:`Switch to ${h==="front"?"rear":"front"} view`,children:h==="front"?"\u21C4 Rear":"\u21C4 Front"})]})]}),jsx("div",{style:{flex:1,background:"transparent",position:"relative",minHeight:`${l*20}px`,overflow:"hidden"}}),E&&jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none"},children:W()})]})};var wt=({data:e,selected:o})=>{let{label:r,status:a="active"}=e;return jsxs("div",{className:`fiber-node ${o?"selected":""}`,style:{background:"#1f2937",border:`2px solid ${ce(a)}`,borderRadius:"50%",width:"60px",height:"60px",display:"flex",alignItems:"center",justifyContent:"center",color:"white",fontFamily:"monospace",fontSize:"10px",fontWeight:"bold",boxShadow:o?"0 0 0 2px #3b82f6":"0 2px 4px rgba(0,0,0,0.1)",position:"relative"},children:[jsx(Handle,{type:"target",position:Position.Top}),jsx(Handle,{type:"source",position:Position.Bottom}),jsx(Handle,{type:"target",position:Position.Left}),jsx(Handle,{type:"source",position:Position.Right}),jsx("div",{style:{textAlign:"center"},children:jsx("div",{style:{fontSize:"8px",lineHeight:"1.2"},children:r})}),jsx("div",{style:{position:"absolute",bottom:"4px",left:"50%",transform:"translateX(-50%)",width:"8px",height:"8px",background:ce(a),borderRadius:"50%"}})]})};var kt=({id:e,sourceX:o,sourceY:r,targetX:a,targetY:n,sourcePosition:i,targetPosition:d,data:s,selected:c,style:l={},className:h})=>{let[f,m,v]=getBezierPath({sourceX:o,sourceY:r,sourcePosition:i,targetX:a,targetY:n,targetPosition:d}),{bandwidth:k,length:E,color:w="#00FFFF",striped:T=false}=s||{},A={...l,stroke:w,strokeWidth:c?3:2,strokeDasharray:"none"};return jsxs(Fragment,{children:[jsx(BaseEdge,{id:e,path:f,style:A}),T&&jsx(BaseEdge,{id:`${e}-stripe`,path:f,style:{...l,stroke:"#000",strokeWidth:1.5,strokeDasharray:"6 6",opacity:.9}}),jsx(EdgeLabelRenderer,{children:c&&s&&(k||E)&&jsxs("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${m}px,${v}px)`,background:"#1f2937",padding:"4px 8px",borderRadius:"4px",fontSize:"10px",color:"white",fontFamily:"monospace",border:`1px solid ${w}`,pointerEvents:"none",zIndex:9999},children:[k&&jsx("div",{children:k}),E&&jsxs("div",{children:[E,"m"]})]})})]})};var vt=({id:e,sourceX:o,sourceY:r,targetX:a,targetY:n,sourcePosition:i,targetPosition:d,style:s={},data:c,markerEnd:l})=>{let[h]=getBezierPath({sourceX:o,sourceY:r,sourcePosition:i,targetX:a,targetY:n,targetPosition:d}),f=c?.connectorType||"C13";return jsx(BaseEdge,{id:e,path:h,markerEnd:l,style:(()=>{let v={stroke:c?.color||"#f59e0b",strokeWidth:f==="C19"?5:3,strokeLinecap:"round",strokeLinejoin:"round",...s};return f==="C19"?{...v,strokeDasharray:"none"}:{...v,strokeDasharray:"6,3"}})()})};var ho=({data:e,selected:o,style:r={},...a})=>{let{color:n="#00FFFF"}=e||{},i={...r,stroke:n,strokeWidth:o?4:3};return jsx(SmoothStepEdge,{...a,data:e,selected:o,style:i})};function Ir({sourceX:e,sourceY:o,targetX:r,targetY:a,sourcePosition:n,targetPosition:i}){let d=n===Position.Left||n===Position.Right,s;if(d){let c=(e+r)/2;s=`M ${e},${o} L ${c},${o} L ${c},${a} L ${r},${a}`;}else {let c=(o+a)/2;s=`M ${e},${o} L ${e},${c} L ${r},${c} L ${r},${a}`;}return s}var wo=({id:e,sourceX:o,sourceY:r,targetX:a,targetY:n,sourcePosition:i,targetPosition:d,data:s,selected:c,style:l={},...h})=>{let{color:f="#00FFFF",striped:m=false}=s||{},v=Ir({sourceX:o,sourceY:r,sourcePosition:i,targetX:a,targetY:n,targetPosition:d}),k={...l,stroke:f,strokeWidth:c?3:2,strokeDasharray:"none"};return jsxs(Fragment,{children:[jsx(BaseEdge,{id:e,path:v,style:k}),m&&jsx(BaseEdge,{id:`${e}-stripe`,path:v,style:{...l,stroke:"#000",strokeWidth:1.5,strokeDasharray:"6 6",opacity:.9}})]})};var No=({id:e,sourceX:o,sourceY:r,targetX:a,targetY:n,sourcePosition:i,targetPosition:d,style:s={},data:c,markerEnd:l,selected:h})=>{let{color:f="#6366f1",label:m}=c||{},[v,k,E]=getBezierPath({sourceX:o,sourceY:r,sourcePosition:i,targetX:a,targetY:n,targetPosition:d}),w={...s,stroke:f,strokeWidth:8,strokeLinecap:"round",strokeLinejoin:"round",strokeDasharray:"none"};return jsxs(Fragment,{children:[jsx(BaseEdge,{id:e,path:v,markerEnd:l,style:w}),m&&jsx(EdgeLabelRenderer,{children:jsx("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${k}px,${E}px)`,background:"#1f2937",padding:"4px 8px",borderRadius:"4px",fontSize:"10px",color:"white",fontFamily:"monospace",border:`1px solid ${f}`,pointerEvents:"none",zIndex:9999},children:m})})]})};var ko=(r=>(r.FULL="full",r.HALF="half",r))(ko||{});var St={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 Ie(e){let o=St[e];if(!o)throw new Error(`Unknown connector type: ${e}`);let r=o.amperage===16,a=r?12:8,n=r?10:5,i=r?{borderRadius:"3px"}:{clipPath:"polygon(2px 0, calc(100% - 2px) 0, 100% 2px, 100% 100%, 0 100%, 0 2px)",borderRadius:"0px"};return {width:a,height:n,color:o.color,borderColor:o.borderColor,fontSize:r?"3px":"4px",...i}}function Je(e){let o=St[e];if(!o)throw new Error(`Unknown connector type: ${e}`);return o}function Mr(e){return Je(e).amperage===16}function Ht(e){return e%10<8?"C13":"C19"}function Qe(e){let o=e.toLowerCase();return o.includes("mx304")||o.includes("mx480")||o.includes("mx960")?"C20":"C14"}var Et=({data:e,selected:o})=>{let{label:r,status:a="active",deviceType:n="server",manufacturer:i,role:d,uHeight:s=1,width:c="full",ports:l=[],rearPorts:h=[],view:f}=e,m=f||(h.length>0&&l.length===0?"rear":"front"),v={};v["net-top"]="front",v["net-bottom"]="front",l.length>0&&l.forEach(x=>{x.ports.forEach(H=>{let y=H.type?.includes("power")?H.label:`${x.name}-${H.label}`;v[y]="front";});}),v["pwr-left-1"]="rear",v["pwr-left-2"]="rear",v["net-right-1"]="rear",v["net-right-2"]="rear",h.length>0&&h.forEach(x=>{x.ports.forEach(H=>{let y=H.type?.includes("power")?H.label:`${x.name}-${H.label}`;v[y]="rear";});});let k=s*20,E=c==="half"?"150px":"304px",w=c==="half"?"150px":void 0,T=(x,H)=>{let y=[];if(x.length===0)return y;let P=Math.max(4,Math.floor(k*.4)),M=Math.max(2,Math.floor(k*.2));return x.forEach((R,C)=>{R.ports.forEach((D,I)=>{let O=!!D.type&&D.type.includes("power");if(H==="front"&&O)return;let _=O?`${D.label}`:`${R.name}-${D.label}`,K=D.connected,L="#6b7280";if(K)if(D.type?.includes("power"))L=D.type==="power_c19"?"#fbbf24":"#f59e0b";else if(D.type==="console"||D.type==="mgmt")L="#8b5cf6";else if(D.type==="usb")L="#10b981";else switch(D.cableType){case "smf":L="#fbbf24";break;case "cat6":L="#8b5cf6";break;case "om3":L="#06b6d4";break;case "om4":L="#8b5cf6";break;case "om5":L="#84cc16";break;case "cat5e":L="#3b82f6";break;case "cat6a":L="#ef4444";break;case "cat7":L="#f97316";break;case "fiber":L="#3b82f6";break;case "ethernet":L="#10b981";break;default:L="#10b981";}let $=Position.Top,j={width:`${P}px`,height:`${M}px`,background:K?L:"#6b7280",border:`1px solid ${K?L:"#374151"}`,borderRadius:"1px",cursor:"pointer"};if(H==="front")I%2===0?($=Position.Top,j.transform="translateY(50%)",j.left=`${I/2*(P+2)}px`):($=Position.Bottom,j.transform="translateY(-50%)",j.left=`${(I-1)/2*(P+2)}px`);else if((n?.toLowerCase().replace(/_/g,"-")||"")==="patch-panel"||n==="switch")I%2===0?($=Position.Top,j.transform="translateY(50%)",j.left=`${I/2*(P+2)}px`):($=Position.Bottom,j.transform="translateY(-50%)",j.left=`${(I-1)/2*(P+2)}px`);else if(D.type?.includes("power")){$=Position.Left,j.transform="translateX(50%)";let ke=k<=20?10:20,gt=k<=20?30:50;j.top=`${ke+I*gt}%`;let Ye=Qe(r),pe=Ie(Ye);j={...j,width:`${pe.width}px`,height:`${pe.height}px`,zIndex:10,display:"flex",alignItems:"center",justifyContent:"center",fontSize:pe.fontSize,color:"#1a1a1a",fontFamily:"monospace",fontWeight:"bold",borderRadius:pe.borderRadius,clipPath:pe.clipPath};}else $=Position.Right,j.transform="translateX(-50%)",j.top=`${25+I*50}%`;let ae=(n?.toLowerCase().replace(/_/g,"-")||"")==="patch-panel",se;if(O)se="target";else if(n==="switch"||n==="router")se="source",y.push(jsx(Handle,{id:`${_}-target`,type:"target",position:$,style:j,title:`${R.name} - ${D.label} (input) ${K?"(connected)":"(disconnected)"}`},`${_}-target`));else if(ae){se=H==="rear"?"source":"target";let me=H==="rear"?"target":"source";y.push(jsx(Handle,{id:`${_}-${me}`,type:me,position:$,style:j,title:`${R.name} - ${D.label} (${me}) ${K?"(connected)":"(disconnected)"}`},`${_}-${me}`));}else se=K?"source":"target";y.push(jsx(Handle,{id:_,type:se,position:$,style:j,title:`${R.name} - ${D.label} ${K?"(connected)":"(disconnected)"}`,children:O?I+1:void 0},_));});}),y},A=()=>{let x=[],H=Math.max(4,Math.floor(k*.4)),y=Math.max(2,Math.floor(k*.2));if(m==="front"){if(l.length>0)return T(l,"front");if(n==="switch"&&(r.toLowerCase().includes("agg")||r.toLowerCase().includes("core")||d==="agg"||d==="core"))return W();x.push(jsx(Handle,{id:"net-top",type:"target",position:Position.Top,style:{width:`${H}px`,height:`${y}px`,background:"#10b981",border:"0.5px solid #059669",borderRadius:"1px",cursor:"pointer",transform:"translateY(50%)"},title:"Network Port (Top)"},"net-top")),x.push(jsx(Handle,{id:"net-bottom",type:"target",position:Position.Bottom,style:{width:`${H}px`,height:`${y}px`,background:"#10b981",border:"0.5px solid #059669",borderRadius:"1px",cursor:"pointer",transform:"translateY(-50%)"},title:"Network Port (Bottom)"},"net-bottom"));}else if(m==="rear"){if(h.length>0)return T(h,"rear");let P=n==="switch",R=(n?.toLowerCase().replace(/_/g,"-")||"")==="patch-panel";if(!R){let C=Qe(r),D=Je(C),I=Ie(C),O=k<=20?"10%":"25%";x.push(jsx(Handle,{id:"pwr-left-1",type:"target",position:Position.Left,style:{width:`${I.width}px`,height:`${I.height}px`,background:I.color,border:`1px solid ${I.borderColor}`,cursor:"pointer",transform:"translateX(50%)",top:O,zIndex:10,display:"flex",alignItems:"center",justifyContent:"center",fontSize:I.fontSize,color:"#1a1a1a",fontFamily:"monospace",fontWeight:"bold",borderRadius:I.borderRadius,clipPath:I.clipPath},title:`Power Port 1 (${D.type}) - ${D.voltage}V, ${D.amperage}A`,children:"1"},"pwr-1"));let _=k<=20?"50%":"75%";x.push(jsx(Handle,{id:"pwr-left-2",type:"target",position:Position.Left,style:{width:`${I.width}px`,height:`${I.height}px`,background:I.color,border:`1px solid ${I.borderColor}`,cursor:"pointer",transform:"translateX(50%)",top:_,zIndex:10,display:"flex",alignItems:"center",justifyContent:"center",fontSize:I.fontSize,color:"#1a1a1a",fontFamily:"monospace",fontWeight:"bold",borderRadius:I.borderRadius,clipPath:I.clipPath},title:`Power Port 2 (${D.type}) - ${D.voltage}V, ${D.amperage}A`,children:"2"},"pwr-2"));}!P&&!R&&(x.push(jsx(Handle,{id:"net-right-1",type:"target",position:Position.Right,style:{width:`${H}px`,height:`${y}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")),x.push(jsx(Handle,{id:"net-right-2",type:"target",position:Position.Right,style:{width:`${H}px`,height:`${y}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 x},W=()=>{let x=[],H=Math.max(10,Math.floor(k*.45)),y=Math.max(5,Math.floor(k*.25));for(let P=1;P<=16;P++){let M=jsx(Handle,{id:`port-${P}`,type:"source",position:Position.Top,style:{width:`${H}px`,height:`${y}px`,background:"#10b981",border:"1px solid #059669",borderRadius:"2px",cursor:"pointer",transform:"translateY(50%)",zIndex:1e3,left:`${(P-1)*(H+2)}px`},title:`Port ${P}`},`port-${P}`);x.push(M);}for(let P=17;P<=32;P++){let M=P-16,R=jsx(Handle,{id:`port-${P}`,type:"source",position:Position.Bottom,style:{width:`${H}px`,height:`${y}px`,background:"#10b981",border:"1px solid #059669",borderRadius:"2px",cursor:"pointer",transform:"translateY(-50%)",zIndex:1e3,left:`${(M-1)*(H+2)}px`},title:`Port ${P}`},`port-${P}`);x.push(R);}for(let P=1;P<=4;P++){let M=Math.max(4,Math.floor(k*.3)),R=Math.max(3,Math.floor(k*.15));x.push(jsx(Handle,{id:`uplink-${P}`,type:"source",position:Position.Right,style:{width:`${M}px`,height:`${R}px`,background:"#8b5cf6",border:"0.5px solid #7c3aed",borderRadius:"0.5px",cursor:"pointer",transform:"translateX(-50%)"},title:`Uplink ${P}`},`uplink-${P}`));}return x};return jsxs("div",{className:`device-node ${o?"selected":""}`,style:{background:"#1f2937",border:`1px solid ${ce(a)}`,borderRadius:"2px",padding:"0px",width:E,...w&&{left:w},height:`${k}px`,color:"white",fontFamily:"monospace",fontSize:"8px",boxShadow:o?"0 0 0 1px #3b82f6":"0 1px 2px rgba(0,0,0,0.1)",position:"relative",display:"flex",flexDirection:"column",justifyContent:"center",cursor:"grab",marginBottom:"0px",boxSizing:"border-box",marginTop:"0px",marginLeft:"0px",marginRight:"0px"},children:[jsxs("div",{style:{textAlign:"center",flex:1,display:"flex",flexDirection:"column",justifyContent:"center",overflow:"hidden",padding:"2px"},children:[jsx("div",{style:{fontWeight:"bold",fontSize:"7px",lineHeight:"1.1",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:r}),s>1&&jsx("div",{style:{fontSize:"6px",color:"#9ca3af",lineHeight:"1"},children:i})]}),s>1&&jsxs("div",{style:{position:"absolute",bottom:"1px",right:"1px",background:"#374151",color:"#9ca3af",padding:"1px 2px",borderRadius:"1px",fontSize:"6px",lineHeight:"1"},children:[s,"U"]}),jsx("div",{style:{position:"absolute",bottom:"1px",left:"1px",width:"4px",height:"4px",background:ce(a),borderRadius:"50%"}}),A()]})};var Rt=({data:e,selected:o})=>{let{label:r,status:a="active",heightCm:n=100,powerPorts:i=36,widthPx:d=15,mgmt_unit:s}=e,c=n*4.2,l=()=>{let m=Math.ceil(i/10),v=Array(10).fill(0).map((y,P)=>P<8?"10A":"16A");for(let y=0,P=0;y<m;++y)for(let M=0;M<10&&P<i;++M,++P){v[M];}let T=[],A=15,H=(c-A-3)/(i-9)*.5;for(let y=0;y<i;y++){let P=A-2+H*y,M=`${y+1}`;if(s&&(s==="top"&&y===0||s==="middle"&&y===Math.floor(i/2)||s==="bottom"&&y===i-1)){T.push(h(P));continue}let C=Ht(y),D=Ie(C),I=Math.round((d-D.width)/2-1);T.push(jsx(Handle,{type:"source",position:Position.Right,id:M,style:{position:"absolute",left:`${I}px`,top:`${P-D.height/2}px`,width:`${D.width}px`,height:`${D.height}px`,background:D.color,border:`1px solid ${D.borderColor}`,cursor:"pointer",zIndex:10,display:"flex",alignItems:"center",justifyContent:"center",fontSize:D.fontSize,color:"#1a1a1a",fontFamily:"monospace",fontWeight:"bold",borderRadius:D.borderRadius,clipPath:D.clipPath},title:`Power Port ${y+1} (${C})`,children:y+1},`handle-${M}`));}return T},h=f=>jsxs("div",{style:{position:"absolute",left:`${(d-16)/2}px`,top:`${f-12/2}px`,width:"16px",height:"12px",background:"#1a1a1a",border:"1px solid #374151",borderRadius:"1px",display:"flex",flexDirection:"column",padding:"1px",zIndex:10},children:[jsx("div",{style:{position:"absolute",left:"-10px",top:"1px",background:"#ffffff",border:"0.5px solid #6b7280",borderRadius:"0.5px",width:"8px",height:"10px",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"3px",color:"#10b981",fontFamily:"monospace",fontWeight:"bold",transform:"rotate(90deg)",transformOrigin:"center"},children:"APC"}),jsx(Handle,{type:"source",position:Position.Right,id:"mgmt-net-1",style:{width:"70%",height:"6px",background:"#10b981",border:"1px solid #059669",borderRadius:"1px",cursor:"pointer",zIndex:11,margin:"0 auto"},title:"Management Network Port"},"mgmt-net-1")]},"mgmt-unit");return jsxs("div",{className:`vertical-pdu-node ${o?"selected":""}`,style:{background:"linear-gradient(90deg, #2d3748 0%, #1a202c 50%, #2d3748 100%)",border:`1px solid ${ce(a)}`,borderRadius:"2px",padding:0,width:`${d}px`,height:`${c}px`,color:"white",fontFamily:"monospace",fontSize:"12px",boxShadow:o?"0 0 0 2px #3b82f6":"0 1px 3px rgba(0,0,0,0.3)",position:"relative",display:"flex",flexDirection:"column"},children:[jsx("div",{style:{textAlign:"center",marginBottom:0,zIndex:2,background:"linear-gradient(90deg, #4a5568 0%, #2d3748 50%, #4a5568 100%)",padding:"2px",position:"relative",height:"20px",display:"flex",flexDirection:"column",justifyContent:"center",borderBottom:"1px solid #4a5568"},children:jsx("div",{style:{fontWeight:"bold",fontSize:"6px",color:"#e2e8f0"},children:r})}),jsx("div",{style:{flex:1,background:"linear-gradient(180deg, #2d3748 0%, #1a202c 50%, #2d3748 100%)",position:"relative",minHeight:`${c-20}px`,overflow:"hidden"},children:l()})]})};var It=({data:e,selected:o,id:r})=>{let{lossDb:a}=e||{},n=useEdges(),i=n.find(m=>m.target===r&&m.targetHandle==="left"),d=n.find(m=>m.source===r&&m.sourceHandle==="right"),s=n.find(m=>m.target===r&&m.targetHandle==="right"),c=d||s,l=i?.data?.color||"#555",h=c?.data?.color||"#555",f=!!i&&!!c;return jsxs("div",{className:`splice-node ${o?"selected":""}`,style:{width:69,height:16,borderRadius:8,border:"none",outline:"none",position:"relative",background:"transparent",boxShadow:o?"0 0 0 2px #3b82f6":"none"},children:[jsxs("div",{style:{position:"absolute",inset:0,display:"grid",gridTemplateColumns:"1fr 1fr",borderRadius:8,overflow:"hidden",opacity:.75,pointerEvents:"none"},children:[jsx("div",{style:{background:l}}),jsx("div",{style:{background:h}})]}),jsx("div",{className:"splice-text-overlay",style:{position:"absolute",inset:0,borderRadius:8,pointerEvents:"none",zIndex:1}}),f&&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 a=="number"&&jsx("div",{className:"splice-text-label animate-in",style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",fontSize:9,fontFamily:"monospace",pointerEvents:"none",zIndex:3,fontWeight:"bold"},children:`${a.toFixed(2)} dB`}),jsx(Handle,{type:"target",position:Position.Left,id:"left",isConnectable:true,style:{width:12,height:12,borderRadius:"50%",border:"none",background:l,zIndex:100,cursor:"crosshair",left:-6,top:"50%",transform:"translateY(-50%)"}}),jsx(Handle,{type:"source",position:Position.Right,id:"right",isConnectable:true,style:{width:12,height:12,borderRadius:"50%",border:"none",background:h,zIndex:100,cursor:"crosshair",right:-6,top:"50%",transform:"translateY(-50%)"}}),jsx(Handle,{type:"target",position:Position.Right,id:"right",isConnectable:true,style:{width:12,height:12,borderRadius:"50%",border:"none",background:h,zIndex:100,cursor:"crosshair",right:-6,top:"50%",transform:"translateY(-50%)"}})]})};var we=20,He=32,Co=4,Ne=12,Br=69,Ce=80,$t=(Ce-Br)/2;var Ft=(e,o,r,a)=>{if(!e.parentId||e.parentId!==o.id)return r;let n=He,i=r.y-n,d=Math.round(i/we)+1,c=Math.max(1,Math.min(Ne,d));if(!_t(o,e,c,a)){let f=et(o,e,a,c);if(f!==c)return {x:$t,y:n+(f-1)*we+5,holderPosition:f}}let h=n+(c-1)*we+5;return {x:$t,y:h,holderPosition:c}},_t=(e,o,r,a)=>!a.filter(i=>i.parentId===e.id&&i.type==="splice"&&i.id!==o.id).some(i=>i.data.holderPosition===r),et=(e,o,r,a=1)=>{for(let n=a;n<=Ne;n++)if(_t(e,o,n,r))return n;for(let n=a-1;n>=1;n--)if(_t(e,o,n,r))return n;return 1},Me=(e,o)=>{let n=He+(o-1)*we+5;return {x:$t,y:n}};var zt=({data:e,selected:o})=>{let{label:r="Splice Tray"}=e||{},[a,n]=useState(false),i=()=>{if(!a)return null;let d=[],s=He;for(let c=1;c<=Ne;c++){let l=s+(c-1)*we;d.push(jsxs("div",{style:{position:"absolute",left:"-35px",top:`${l}px`,background:"#374151",color:"#9ca3af",padding:"2px 4px",borderRadius:"2px",fontSize:"8px",fontWeight:"bold",width:"28px",textAlign:"center",border:"1px solid #4b5563",zIndex:10,height:`${we}px`,display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1},children:["H",c]},c));}return d};return jsxs("div",{className:`splice-tray-node ${o?"selected":""}`,style:{background:"transparent",border:"none",borderRadius:"8px",padding:0,width:`${Ce}px`,height:`${He+Ne*we+Co}px`,color:"white",fontFamily:"monospace",fontSize:"12px",boxShadow:o?"0 0 0 2px #3b82f6":"0 2px 4px rgba(0,0,0,0.1)",position:"relative",display:"flex",flexDirection:"column"},children:[jsxs("div",{style:{textAlign:"center",marginBottom:0,zIndex:2,background:"#1f2937",padding:"2px",position:"relative",height:`${He}px`,display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"center",gap:"6px",borderRadius:"8px"},children:[jsx("div",{style:{fontWeight:"bold",fontSize:"10px"},children:r}),jsx("button",{onPointerDown:d=>{d.stopPropagation();},onMouseDown:d=>{d.stopPropagation();},onClick:d=>{d.stopPropagation(),d.preventDefault(),n(!a);},style:{background:a?"#10b981":"#374151",color:a?"#ffffff":"#9ca3af",border:"1px solid #4b5563",borderRadius:"2px",padding:"2px 6px",fontSize:"8px",cursor:"pointer",fontFamily:"monospace"},title:`${a?"Hide":"Show"} holder markers`,children:"H"})]}),i(),jsx("div",{style:{position:"absolute",top:He,left:0,right:0,bottom:0,pointerEvents:"none"}})]})};var Eo=["#1f77b4","#ff7f0e","#2ca02c","#8c564b","#708090","#ffffff","#d62728","#000000","#ffdf00","#8a2be2","#ff69b4","#00ffff"];function oe(e){let o=(e-1)%12;return Eo[o]}function Ro(e){return e>12}function Ue(e){let o=oe(e);return Ro(e)?{background:o,backgroundImage:`repeating-linear-gradient(45deg, ${o} 0 6px, #000 6px 9px)`}:{background:o}}function Lt(e){return oe(e)}var Mt=({data:e,selected:o,id:r})=>{let{fibersPerTube:a=12,tubeIndex:n=1,startOn:i="left-center"}=e||{},d=Math.max(1,Math.min(24,Number(a)||12)),s=14,c=4,l=1,h=2,f=20,m=d*s+(d-1)*c,v=Math.max(60,m+l*2+h*2),k=oe((n-1)%12+1),E=`tube-${n}`,w=18,T={width:w,height:w,borderRadius:"50%",opacity:.25,pointerEvents:"auto",background:k,backgroundColor:k,border:`2px solid ${k}`,"--fiber-bg":k},A=()=>i==="left"?Position.Left:i==="right"?Position.Right:Position.Bottom,W=()=>{let x=[],H=v-h*2-l*2,y,P,M=false;i==="left"?(y=l,P=Position.Top):i==="right"?(y=l+H-m,P=Position.Top,M=true):(y=l+(H-m)/2,P=Position.Top);for(let R=0;R<d;R++){let C=M?d-R:R+1,D=Ue(C),I=oe(C),O=y+R*(s+c),_=l,K=D.backgroundImage?D.backgroundImage:I,L={position:"absolute",left:`${O}px`,top:`${_}px`,width:s,height:s,borderRadius:"50%",border:"none",background:K,backgroundColor:I,zIndex:10,cursor:"pointer","--fiber-bg":I};D.backgroundImage&&(L["--fiber-bg-image"]=D.backgroundImage);let $=`fiber-${C}`;x.push(jsxs(Yr.Fragment,{children:[jsx(Handle,{id:$,type:"target",position:P,className:"tube-fiber-handle",isConnectable:true,style:L,"data-fiber-idx":C,"data-fiber-color":I}),jsx(Handle,{id:$,type:"source",position:P,className:"tube-fiber-handle",isConnectable:true,style:L,"data-fiber-idx":C,"data-fiber-color":I})]},`fiber-${C}`));}return x};return jsxs("div",{style:{width:v,height:f,borderRadius:4,background:"#111827",border:`${h}px solid ${o?"#3b82f6":k}`,position:"relative",boxShadow:o?`0 0 0 ${h}px #3b82f6`:"0 2px 4px rgba(0,0,0,0.2)",padding:l,boxSizing:"border-box"},children:[W(),jsx(Handle,{id:E,type:"target",position:A(),isConnectable:true,style:T,"data-tube-idx":n,"data-tube-color":k}),jsx(Handle,{id:E,type:"source",position:A(),isConnectable:true,style:T,"data-tube-idx":n,"data-tube-color":k})]})};var Ut=({data:e,selected:o})=>{let{tubeCount:r=12,fibersPerTube:a=12,fiberCount:n,cableId:i="CBL-002",label:d,tubeStartIndex:s=1,color:c}=e||{},l=Math.max(1,Math.min(24,Number(r)||12)),h=Math.max(1,Number(s)||1),f=8,m=2,v=6,k=v+f+4,E=60,w=Math.max(120,l*(f+m)+v*2),T=n??l*(Number(a)||12),A=d??`${T}f Cable`,W=i?`Cable ID ${i}`:void 0,x=oe(h),H=c||x,y=o?"#3b82f6":H,P=()=>{let I=[];for(let O=0;O<l;O++){let _=h+O,K=Ue(_),L=oe(_),$=v+O*(f+m),j=-4,V=K.backgroundImage?K.backgroundImage:L,ae={position:"absolute",left:`${$}px`,top:`${j}px`,width:f,height:f,borderRadius:"50%",border:"none",background:V,backgroundColor:L,zIndex:10,cursor:"pointer","--fiber-bg":L};K.backgroundImage&&(ae["--fiber-bg-image"]=K.backgroundImage);let se=`tube-${_}`;I.push(jsxs(Yr.Fragment,{children:[jsx(Handle,{id:se,type:"target",position:Position.Top,className:"tube-fiber-handle",isConnectable:true,style:ae,"data-fiber-idx":_,"data-tube-idx":_,"data-tube-color":L}),jsx(Handle,{id:se,type:"source",position:Position.Top,className:"tube-fiber-handle",isConnectable:true,style:ae,"data-fiber-idx":_,"data-tube-idx":_,"data-tube-color":L})]},`tube-${_}`));}return I},M="cable-button",R=8,C={width:R,height:R,borderRadius:"50%",background:H,backgroundColor:H,border:`1px solid ${H}`,cursor:"pointer",zIndex:10};return jsxs("div",{style:{width:w,height:E,borderRadius:4,background:"#111827",border:`2px solid ${y}`,position:"relative",boxShadow:o?"0 0 0 2px #3b82f6":"0 2px 4px rgba(0,0,0,0.2)",padding:v,paddingTop:k,boxSizing:"border-box",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",color:"#e5e7eb",fontFamily:"monospace",textAlign:"center",gap:2},children:[P(),jsx(Handle,{id:M,type:"source",position:Position.Bottom,className:"cable-button-handle",isConnectable:true,style:C,"data-handle-type":"cable-button","data-cable-color":H}),jsx(Handle,{id:M,type:"target",position:Position.Bottom,className:"cable-button-handle",isConnectable:true,style:C,"data-handle-type":"cable-button","data-cable-color":H}),jsx("div",{style:{fontSize:11,fontWeight:600,textTransform:"uppercase",letterSpacing:.5},children:A}),W&&jsx("div",{style:{fontSize:10,opacity:.8},children:W})]})};var Bt=({data:e,selected:o,id:r})=>{let{connector:a="LC",couplerFiberCount:n,label:i,portLabelsLeft:d,portLabelsRight:s}=e||{},c=useEdges(),l=typeof n=="number"&&[1,2,4].includes(n)?n:2,h=Math.max(1,Math.min(4,l)),f=7,m=3,v=3,k=60,E=30,w=h*f+(h-1)*m,T=Math.max(E,w+v*2),A=Math.max(k,80),W=(y,P)=>{let M=`${y}-${P+1}`;return c.find(C=>C.source===r&&C.sourceHandle===M||C.target===r&&C.targetHandle===M)?.data?.color||"#555"},x=y=>{let P=[],M=y==="left"?Position.Left:Position.Right,R=y==="left"?d:s;for(let C=0;C<h;C++){let D=C+1,I=`${y}-${D}`,O=W(y,C),L=v+(T-w)/2+C*(f+m),$={position:"absolute",left:y==="left"?-5:void 0,right:y==="right"?-5:void 0,top:`${L}px`,width:f,height:f,borderRadius:"50%",border:"none",background:O,zIndex:100,cursor:"crosshair",transform:"translateY(-50%)"};P.push(jsxs(Yr.Fragment,{children:[jsx(Handle,{id:I,type:"target",position:M,isConnectable:true,style:$}),jsx(Handle,{id:I,type:"source",position:M,isConnectable:true,style:$})]},I)),R&&R[C]&&P.push(jsx("div",{style:{position:"absolute",left:y==="left"?-30:void 0,right:y==="right"?-30:void 0,top:`${L}px`,transform:"translateY(-50%)",fontSize:"8px",color:"#9ca3af",fontFamily:"monospace",pointerEvents:"none",textAlign:y==="left"?"right":"left",width:"25px"},children:R[C]},`${I}-label`));}return P},H=i||`${a}-${h}f`;return jsxs("div",{className:`coupler-node ${o?"selected":""}`,style:{width:A,height:T,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:`${v}px`,boxSizing:"border-box"},children:[x("left"),jsx("div",{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",textAlign:"center",pointerEvents:"none",zIndex:1},children:jsx("div",{style:{fontWeight:"bold",fontSize:"9px"},children:H})}),x("right")]})};var Ee=32,st=30,Gr=24,Zr=80,it=400,at=300,zo=2,he=8,Lo=120;function Ot(e){let{couplerFiberCount:o}=e.data||{},r=typeof o=="number"&&[1,2,4].includes(o)?o:2,a=Math.max(1,Math.min(4,r)),n=7,i=3,d=3,s=60,c=30,l=a*n+(a-1)*i,h=Math.max(c,l+d*2);return {width:Math.max(s,80),height:h}}function dt(e){let{fibersPerTube:o=12}=e.data||{},r=Math.max(1,Math.min(24,Number(o)||12)),a=14,n=4,i=1,d=2,s=20,c=r*a+(r-1)*n;return {width:Math.max(60,c+i*2+d*2),height:s}}function Mo(e){return {width:Ce,height:0}}function Oe(e){return e.type==="coupler"?Ot(e):e.type==="tube"?dt(e):e.type==="splice-tray"?Mo():{width:80,height:30}}function Uo(e){return e.data?.panelWidth||it}function Kr(e){return e.data?.panelHeight||at}function Bo(e){return Uo(e)-zo*2-he*2}function qr(e,o){return Bo(e)-o}function Oo(e,o=st){return Math.floor(e/o)+1}function Yo(e,o=st){return (e-1)*o}function Jr(e,o,r){let a=st,n=Oo(r.y,a),i=Yo(n,a);return {x:r.x,y:i,slotPosition:n}}function Yt(e,o){if(o.length===0)return {width:e.data?.panelWidth||it,height:e.data?.panelHeight||at};let r=o.some(l=>l.type==="tube"),a=o.some(l=>l.type==="splice-tray"),n=o.some(l=>l.type==="coupler"),i,d=5;if(r&&a&&n){let l=0,h=0;for(let f of o)if(f.type==="tube"){let m=dt(f);m.width>l&&(l=m.width);}else if(f.type==="coupler"){let m=Ot(f);m.width>h&&(h=m.width);}i=he+l+Lo+Ce+h+d;}else {let l=0;for(let h of o){let f=Oe(h),m=(h.position?.x||0)+f.width;m>l&&(l=m);}i=l+he+d;}i=Math.max(e.data?.panelWidth||it,i);let s=Ee;for(let l of o){let h=Oe(l),f=(l.position?.y||0)+h.height;f>s&&(s=f);}let c=Math.max(e.data?.panelHeight||at,s+he);return {width:i,height:c}}function Vo(e,o,r){if(e===0)return 0;if(e===1)return o;let a=e*o,n=r-a,i=Math.max(5,n/(e-1));return o+i}function Qr(e,o,r){return Vo(e,o,r)}var Fo=20,Ao=400,Wo=300;function Xo(e,o){if(o.length===0)return {width:e.data?.closureWidth||e.data?.panelWidth||Ao,height:e.data?.closureHeight||e.data?.panelHeight||Wo};let r=o.some(c=>c.type==="tube"),a=o.some(c=>c.type==="splice-tray"),n,i=5;if(r&&a){let c=0,l=0,h=0,f=o.filter(v=>v.type==="tube"),m=o.filter(v=>v.type==="splice-tray");if(f.length>0&&m.length>0){let v=f.map(A=>A.position?.x||0);Math.min(...v);Math.max(...v);let w=m.map(A=>A.position?.x||0),T=w.reduce((A,W)=>A+W,0)/w.length;for(let A of f){let W=dt(A);(A.position?.x||0)<T?W.width>c&&(c=W.width):W.width>l&&(l=W.width);}m.length>0&&(h=Ce),n=he+c+Fo+h+Fo+l+i;}else {let v=0;for(let k of o){let E=Oe(k),w=(k.position?.x||0)+E.width;w>v&&(v=w);}n=v+he+i;}}else {let c=0;for(let l of o){let h=Oe(l),f=(l.position?.x||0)+h.width;f>c&&(c=f);}n=c+he+i;}n=Math.max(e.data?.closureWidth||e.data?.panelWidth||Ao,n);let d=Ee;for(let c of o){let l=Oe(c),h=(c.position?.y||0)+l.height;h>d&&(d=h);}let s=Math.max(e.data?.closureHeight||e.data?.panelHeight||Wo,d+he);return {width:n,height:s}}var jt=({data:e,selected:o,id:r})=>{let{label:a="Patch Panel",header:n,panelWidth:i,panelHeight:d}=e||{},{getNodes:s,setNodes:c}=useReactFlow(),l=useRef(false),h=useMemo(()=>s().filter(A=>A.parentId===r),[s,r]),f=useMemo(()=>({id:r,type:"patch-panel",position:{x:0,y:0},data:{...e,panelWidth:i,panelHeight:d}}),[r,e,i,d]),m=useMemo(()=>i&&d?{width:i,height:d}:h.length===0?{width:i||400,height:d||300}:Yt(f,h),[h,f,i,d]);useEffect(()=>{if(i&&d||l.current)return;let T=i,A=d,W=Math.abs((T||0)-m.width),x=Math.abs((A||0)-m.height);(W>1||x>1)&&(l.current=true,c(H=>H.map(y=>y.id===r?{...y,data:{...y.data,panelWidth:m.width,panelHeight:m.height}}:y)),setTimeout(()=>{l.current=false;},0));},[r,m.width,m.height,i,d,c]);let v=m.width,k=m.height,E=Ee,w=n||a;return jsxs("div",{className:`patch-panel-node ${o?"selected":""}`,style:{background:"transparent",border:"none",borderRadius:"8px",padding:0,width:`${v}px`,height:`${k}px`,color:"white",fontFamily:"monospace",fontSize:"12px",boxShadow:o?"0 0 0 2px #3b82f6":"0 2px 4px rgba(0,0,0,0.1)",position:"relative",display:"flex",flexDirection:"column",backgroundColor:"#1f2937",boxSizing:"border-box"},children:[jsx("div",{style:{textAlign:"center",marginBottom:0,zIndex:2,background:"#374151",padding:"6px 12px",position:"relative",height:`${E}px`,display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"center",gap:"6px",borderRadius:"6px 6px 0 0",borderBottom:"1px solid #4b5563"},children:jsx("div",{style:{fontWeight:"bold",fontSize:"11px"},children:w})}),jsx("div",{style:{position:"absolute",top:E,left:0,right:0,bottom:0,pointerEvents:"none",overflow:"visible"}})]})};var Kt=({data:e,selected:o,id:r})=>{let{label:a="Closure",header:n,closureWidth:i,closureHeight:d,panelWidth:s,panelHeight:c}=e||{},{getNodes:l,setNodes:h}=useReactFlow(),f=useRef(false),m=useMemo(()=>l().filter(H=>H.parentId===r),[l,r]),v=useMemo(()=>({id:r,type:"closure",position:{x:0,y:0},data:{...e,closureWidth:i||s,closureHeight:d||c}}),[r,e,i,d,s,c]),k=useMemo(()=>i&&d?{width:i,height:d}:s&&c?{width:s,height:c}:m.length===0?{width:i||s||400,height:d||c||300}:Xo(v,m),[m,v,i,d,s,c]);useEffect(()=>{if(i&&d||s&&c||f.current)return;let x=i||s,H=d||c,y=Math.abs((x||0)-k.width),P=Math.abs((H||0)-k.height);(y>1||P>1)&&(f.current=true,h(M=>M.map(R=>R.id===r?{...R,data:{...R.data,closureWidth:k.width,closureHeight:k.height}}:R)),setTimeout(()=>{f.current=false;},0));},[r,k.width,k.height,i,d,s,c,h]);let E=k.width,w=k.height,T=Ee,A=n||a,W=E/2;return jsxs("div",{className:`closure-node ${o?"selected":""}`,style:{background:"transparent",border:"none",borderRadius:`${W}px ${W}px 12px 12px`,padding:0,width:`${E}px`,height:`${w}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",transform:"translateX(-4px)"},children:[jsx("div",{style:{textAlign:"center",marginBottom:0,zIndex:2,background:"#374151",padding:"6px 12px",position:"relative",height:`${T}px`,display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"center",gap:"6px",borderRadius:`${W}px ${W}px 0 0`,borderBottom:"1px solid #4b5563",transform:"translateX(4px)"},children:jsx("div",{style:{fontWeight:"bold",fontSize:"11px"},children:A})}),jsx("div",{style:{position:"absolute",top:T,left:0,right:0,bottom:0,pointerEvents:"none",overflow:"visible"}})]})};function cn(e,o){if(!e.source||!e.target||!e.sourceHandle||!e.targetHandle)return {valid:true};let r=o.edges.some(w=>w.source===e.source&&w.sourceHandle===e.sourceHandle),a=o.edges.some(w=>w.target===e.target&&w.targetHandle===e.targetHandle);if(r)return {valid:false,reason:"Source port is already connected"};if(a)return {valid:false,reason:"Target port is already connected"};let n=e.sourceHandle,i=e.targetHandle,d=o.nodes.find(w=>w.id===e.source),s=o.nodes.find(w=>w.id===e.target),c=(w,T)=>{if(!w)return false;let A=w.startsWith("pwr")||w.startsWith("power"),W=T?.type==="vertical-pdu"&&w!=="mgmt-net-1";return A||W},l=(w,T)=>{if(!w)return false;if(T?.type==="vertical-pdu"&&w==="mgmt-net-1"||T?.type==="tube"&&w.startsWith("fiber-")||(T?.type==="tube"||T?.type==="cable")&&w.startsWith("tube-")||T?.type==="splice"&&(w==="left"||w==="right"))return true;let A=w.startsWith("net-")||w.startsWith("port-")||w.startsWith("uplink-")||w.includes("Fiber")||w.includes("Ports"),W=/^[A-Z0-9]+-\d+$/.test(w)&&!w.startsWith("pwr")&&!w.startsWith("power");return A||W},h=c(n,d),f=c(i,s),m=l(n,d),v=l(i,s);if(h&&v||f&&m)return {valid:false,reason:"Cannot connect network cable to power port"};if(h&&!f||f&&!h)return {valid:false,reason:"Power ports must connect to power-compatible ports"};let k=d?.type==="vertical-pdu",E=s?.type==="vertical-pdu";if(h||f){let w=k?s:E?d:null,T=k?d:E?s:null;if(w&&T&&o.edges.filter(x=>{let H=c(x.sourceHandle||""),y=c(x.targetHandle||""),P=x.source===w.id||x.target===w.id;return (H||y)&&P}).some(x=>x.source===T.id||x.target===T.id))return {valid:false,reason:"Dual-feed required: connect second power to a different PDU"}}return {valid:true}}function ct(e,o){if(!o)return;let r=typeof e=="string"?e.replace(/-(target|source)$/i,""):e,a=o.data??{},n=a.handleSideMap;if(n&&n[r])return n[r];if(r==="net-top"||r==="net-bottom")return "front";if(r==="pwr-left-1"||r==="pwr-left-2"||r==="net-right-1"||r==="net-right-2")return "rear";let i=Array.isArray(a.ports)?a.ports:[],d=Array.isArray(a.rearPorts)?a.rearPorts:[];if(r.startsWith("pwr")||r.includes("power"))return "rear";for(let c of i)for(let l of c.ports||[])if((!!l.type&&String(l.type).includes("power")?l.label:`${c.name}-${l.label}`)===r)return "front";for(let c of d)for(let l of c.ports||[])if((!!l.type&&String(l.type).includes("power")?l.label:`${c.name}-${l.label}`)===r)return "rear"}function qt(e={},o={}){let r={nodes:e.nodes??[],edges:e.edges??[],debug:e.debug??false},a=new Set;return {getState:()=>r,setState:f=>{r={...r,...f},a.forEach(m=>m(r));},subscribe:f=>(a.add(f),()=>a.delete(f)),selectEdgeZIndex:f=>{let m=r.nodes.find(H=>H.id===f.target);if(!m||m.type!=="device")return 1e3;let v=m.data?.view||"front",k=ct(f.targetHandle||"",m);if(k)return v===k?1e3:500;let E=(f.targetHandle||"").toString(),w=E.toLowerCase(),T=w.startsWith("pwr")||w.startsWith("power"),A=w.startsWith("net-")||w.startsWith("port-")||w.startsWith("uplink-")||w.includes("fiber")||w.includes("ports"),W=/^[A-Z0-9]+-\d+$/i.test(E)&&!w.startsWith("pwr")&&!w.startsWith("power"),x=A||W;return T?v==="rear"?1e3:500:x?v==="front"?1e3:500:1e3},validateConnection:f=>(o.validateConnection||cn)(f,r),selectNodeById:f=>r.nodes.find(m=>m.id===f),selectConnectedEdges:f=>r.edges.filter(m=>m.source===f||m.target===f)}}function ln(e){let o=n=>e.subscribe(n),r=()=>e.getState();return useSyncExternalStore(o,r,r)}function Qt(e){let o=a=>e.subscribe(a),r=()=>e.getState().nodes;return useSyncExternalStore(o,r,r)}function eo(e){let o=a=>e.subscribe(a),r=()=>e.getState().edges;return useSyncExternalStore(o,r,r)}function jo(e){return e.selectEdgeZIndex}function Go(e){let o=300,r=(e.data.uHeight||42)*20,a=e.position.x,n=e.position.x+o,i=e.position.y,d=e.position.y+r;return {left:a,right:n,top:i,bottom:d}}function lt(e,o){let r=Go(o);return e.x>=r.left&&e.x<=r.right&&e.y>=r.top&&e.y<=r.bottom}function pt(e,o){let r=null,a=1/0;for(let n of o){if(!lt(e,n))continue;let i=Math.sqrt(Math.pow(e.x-n.position.x,2)+Math.pow(e.y-n.position.y,2));i<a&&(a=i,r=n);}return r}function G(e){let{edges:o,connection:r,edgeType:a,selectEdgeZIndex:n,findBy:i,data:d}=e,s=i==="source"?r.sourceHandle:r.targetHandle,c=i==="source"?r.source:r.target;if(!s||!c)return null;let l=o.find(E=>i==="source"?E.source===c&&E.sourceHandle===s:E.target===c&&E.targetHandle===s);if(!l)return null;let h=o.filter(E=>E.id!==l.id),f=addEdge(r,h),m=f[f.length-1],v=n({...r,id:m.id,type:a}),k={...m,type:a,zIndex:v,style:{...m.style,zIndex:v},data:d!==void 0?d:m.data};return [...f.slice(0,-1),k]}var Pn=(e,o,r)=>({rack:a=>jsx(xt,{...a,onViewChange:e,onRackFaceChange:o,isDragOver:r?r()===a.id:false}),fiber:wt,device:Et,"vertical-pdu":Rt,splice:It,"splice-tray":zt,tube:Mt,cable:Ut,coupler:Bt,"patch-panel":jt,closure:Kt}),Sn={fiber:kt,power:vt,smoothstep:ho,step:wo,"thick-cable":No},Hn=({nodes:e,edges:o,initialNodes:r,initialEdges:a,onNodesChange:n,onEdgesChange:i,store:d,debug:s,onNodeClick:c,onEdgeClick:l,onViewChange:h,onRackFaceChange:f,className:m,style:v,alignRacksToBottom:k,colorMode:E="dark",onInit:w,onFlowMethods:T,showDownloadButton:A=false,downloadButtonPosition:W="top-right",downloadButtonText:x="Download Image",downloadButtonStyle:H,allowReconnectExisting:y=false,useSmoothstepEdgesForTubes:P=false,connectOnClick:M=true})=>{let R=Array.isArray(e)&&Array.isArray(o),C=Yr.useMemo(()=>d||qt({nodes:R?e||[]:r||e||[],edges:R?o||[]:a||o||[],debug:s}),[d,R,s]),D=Qt(C),I=eo(C),[O,_,K]=useNodesState(D),[L,$,j]=useEdgesState(I),V=jo(C),ae=useRef(null),{toObject:se,setViewport:me,setNodes:ut,setEdges:ft,getNodes:ke}=useReactFlow();useEffect(()=>{T&&T({toObject:se,setViewport:me,setNodes:t=>{ut(t),C.setState({nodes:t});},setEdges:t=>{ft(t),C.setState({edges:t});},toImage:t=>ae.current?toPng(ae.current,t):Promise.reject(new Error("ReactFlow wrapper not available"))});},[T,se,me,ut,ft,C]);let gt=useCallback(()=>{if(!ae.current){s&&console.error("ReactFlow wrapper ref is not available");return}toPng(ae.current,{filter:t=>!(t?.classList?.contains("react-flow__minimap")||t?.classList?.contains("react-flow__controls")||t?.classList?.contains("react-flow__attribution")||t?.classList?.contains("download-button")||t?.tagName==="BUTTON"),backgroundColor:E==="light"?"#ffffff":"#1a1a1a",pixelRatio:2}).then(t=>{let p=document.createElement("a");p.download=`network-diagram-${new Date().toISOString().split("T")[0]}.png`,p.href=t,p.click();}).catch(t=>{s&&console.error("Error downloading image:",t);});},[E,s]),[Ye,pe]=useState(null),no=useRef(null),io=useRef(h),ao=useRef(f);useEffect(()=>{io.current=h;},[h]),useEffect(()=>{ao.current=f;},[f]),useEffect(()=>{no.current=Ye;},[Ye]);let so=useCallback((t,p)=>{io.current?.(t,p);},[]),co=useCallback((t,p)=>{ao.current?.(t,p);},[]),lo=useCallback(()=>no.current,[]),rr=useMemo(()=>Pn(so,co,lo),[so,co,lo]),ge=useRef(O);useEffect(()=>{ge.current=O;},[O]);let z=useRef(L);useEffect(()=>{z.current=L;},[L]),useEffect(()=>{_(D);},[D,_]),useEffect(()=>{$(I);},[I,$]),useEffect(()=>{R&&C.setState({nodes:e||[]});},[R,e,C]),useEffect(()=>{R&&C.setState({edges:o||[]});},[R,o,C]),useEffect(()=>{if(!k||!O||O.length===0)return;let t=O.filter(U=>U.type==="rack");if(t.length===0)return;let p=t.map(U=>{let de=U.data?.uHeight||42,fe=60+de*20;return (U.position?.y||0)+fe}),b=Math.min(...p),g=Math.max(...p);if(g-b<20)return;let u=g,F=O.map(U=>{if(U.type!=="rack")return U;let de=U.data?.uHeight||42,fe=60+de*20,q=(U.position?.y||0)+fe,B=u-q;return Math.abs(B)<5?U:{...U,position:{x:U.position?.x||0,y:(U.position?.y||0)+B}}});F.some((U,te)=>U.position!==O[te].position)&&_(F);},[k,O,_]);let X=useCallback(t=>ge.current.find(p=>p.id===t),[]),Ve=useCallback((t,p)=>{if(!t||!p)return;let b=X(t);if(!b)return;if(b.type==="tube"&&p.startsWith("fiber-")){let N=p.replace("fiber-",""),u=parseInt(N,10);if(u>=1&&u<=24){let F=Lt(u),Y=u>12;return {color:F,striped:Y}}}if((b.type==="cable"||b.type==="tube")&&p.startsWith("tube-")){let N=p.replace("tube-",""),u=parseInt(N,10);if(u>=1&&u<=24){let F=oe(u),Y=u>12;return {color:F,striped:Y}}}let g=b.data;if(g.color)return {color:g.color}},[X]);useEffect(()=>{$(t=>t.map(p=>{let b=V(p);return {...p,zIndex:b,style:{...p.style,zIndex:b}}}));},[O,$,V]),useEffect(()=>{let t=O.map(b=>{if(b.type==="coupler"&&b.parentId){let g=X(b.parentId);if(g&&(g.type==="patch-panel"||g.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 g=X(b.parentId);if(g&&g.type==="splice-tray"){let N=Me(g,b.data.holderPosition);return {...b,position:N}}}if(b.type==="device"&&b.parentId&&b.data.uPosition&&(!b.position||b.position.x===0&&b.position.y===0)){let g=X(b.parentId);if(g){let N=De(g,b.data.uPosition);return {...b,position:N}}}return b});t.some((b,g)=>{let N=O[g];return b.extent!==N.extent||b.position?.x!==N.position?.x||b.position?.y!==N.position?.y})&&_(t);},[O,_,X]);let nr=useCallback(t=>{let p=t.map(b=>{if(b.type==="position"&&b.position){let g=X(b.id);if(g&&g.type==="coupler"&&g.parentId){let N=X(g.parentId);if(N&&(N.type==="patch-panel"||N.type==="closure")){if(!g.extent||g.extent!=="parent"){let u={...g,extent:"parent"};_(F=>F.map(Y=>Y.id===g.id?u:Y));}return {...b,position:g.position||{x:0,y:0}}}}if(g&&(g.type==="tube"||g.type==="splice-tray")&&g.parentId){let N=X(g.parentId);if(N&&N.type==="closure"){if(!g.extent||g.extent!=="parent"){let u={...g,extent:"parent"};_(F=>F.map(Y=>Y.id===g.id?u:Y));}return {...b,position:g.position||{x:0,y:0}}}}if(g&&g.type==="splice"&&g.parentId){let N=X(g.parentId);if(N&&N.type==="splice-tray"){let u=Ft(g,N,b.position,ge.current);if(u.holderPosition!==void 0){let F={...g,data:{...g.data,holderPosition:u.holderPosition}};_(Y=>Y.map(U=>U.id===g.id?F:U));}return {...b,position:{x:u.x,y:u.y}}}}if(g&&g.type==="device"&&g.parentId){let N=X(g.parentId);if(N){let u=mt(g,N,b.position,ge.current);if(u.uPosition!==void 0){let F={...g,data:{...g.data,uPosition:u.uPosition}};_(Y=>Y.map(U=>U.id===g.id?F:U));}return {...b,position:{x:u.x,y:u.y}}}}if(g&&g.type==="device"&&g.parentId){let N=X(g.parentId);if(N){let u=N;if(!lt(b.position,u)){let F=b.position.x+u.position.x,Y=b.position.y+u.position.y,U={...g,parentId:void 0,extent:void 0,data:{...g.data,uPosition:void 0}};return _(te=>te.map(de=>de.id===g.id?U:de)),{...b,position:{x:F,y:Y}}}}}}return b});K(p);},[K,_,X]),ir=useCallback((t,p)=>{pe(null);},[]),ar=useCallback((t,p,b)=>{if(p.type==="device"&&!p.parentId){let g=ge.current.filter(u=>u.type==="rack").map(u=>u),N=pt(p.position,g);pe(N?.id??null);}else pe(null);},[]),sr=useCallback((t,p,b)=>{if(p.type==="device"&&!p.parentId){let g=ge.current.filter(u=>u.type==="rack").map(u=>u),N=pt(p.position,g);if(N){let u=p.position.x-N.position.x,F=p.position.y-N.position.y,Y={...p,parentId:N.id,extent:"parent",position:{x:u,y:F},data:{...p.data,uPosition:1}},U=ge.current.map(te=>te.id===p.id?Y:te);_(U),R||C.setState({nodes:U});}}pe(null);},[_,R,C]),dr=useCallback(t=>{if(!t.source||!t.target||!t.sourceHandle||!t.targetHandle)return true;let p=X(t.source),b=X(t.target);if(p?.type==="tube"&&b?.type==="tube"&&t.sourceHandle.startsWith("fiber-")&&t.targetHandle.startsWith("fiber-"))return s&&console.log("Connection rejected: Cannot connect fibres within tubes",t),false;if(p?.type==="tube"&&t.sourceHandle.startsWith("fiber-")&&(b?.type==="cable"||b?.type==="tube")&&t.targetHandle.startsWith("tube-"))return s&&console.log("Connection rejected: Cannot connect individual fibre to cable/tube tube handle",t),false;if((p?.type==="cable"||p?.type==="tube")&&t.sourceHandle.startsWith("tube-")&&b?.type==="tube"&&t.targetHandle.startsWith("fiber-"))return s&&console.log("Connection rejected: Cannot connect cable/tube tube handle to individual fibre",t),false;if(b?.type==="splice"&&(t.targetHandle==="left"||t.targetHandle==="right")){if(z.current.find(u=>u.target===t.target&&u.targetHandle===t.targetHandle||u.source===t.target&&u.sourceHandle===t.targetHandle))return s&&console.log("Splice handle already connected, will replace",t),true;s&&console.log("Allowing connection to splice handle",t);}if(p?.type==="tube"&&t.sourceHandle.startsWith("fiber-"))return b?.type!=="splice"?(s&&console.log("Connection rejected: Tube fiber handles can only connect to splices",t),false):z.current.find(u=>u.source===t.source&&u.sourceHandle===t.sourceHandle)?(s&&console.log("Tube fiber handle already connected, will replace",t),true):(s&&console.log("Allowing connection from tube fiber handle to splice",t),true);if((p?.type==="cable"||p?.type==="tube")&&t.sourceHandle.startsWith("tube-"))return t.targetHandle.startsWith("tube-")?z.current.find(u=>u.source===t.source&&u.sourceHandle===t.sourceHandle)?(s&&console.log("Tube-level handle already connected, will replace",t),true):(s&&console.log("Allowing connection from tube-level handle to tube handle",t),true):(s&&console.log("Connection rejected: Tube handles can only connect to other tube handles",t),false);if(p?.type==="splice"&&t.sourceHandle==="right"){if(z.current.find(u=>u.source===t.source&&u.sourceHandle===t.sourceHandle||u.target===t.source&&u.targetHandle===t.sourceHandle))return s&&console.log("Splice source handle already connected, will replace",t),true;s&&console.log("Allowing connection from splice source handle",t);}if(b?.type==="tube"&&t.targetHandle.startsWith("fiber-"))return p?.type!=="splice"?(s&&console.log("Connection rejected: Tube fiber handles can only connect from splices",t),false):z.current.find(u=>u.target===t.target&&u.targetHandle===t.targetHandle)?(s&&console.log("Tube fiber target handle already connected, will replace",t),true):(s&&console.log("Allowing connection from splice to tube fiber handle",t),true);if((b?.type==="cable"||b?.type==="tube")&&t.targetHandle.startsWith("tube-"))return t.sourceHandle.startsWith("tube-")?z.current.find(u=>u.target===t.target&&u.targetHandle===t.targetHandle)?(s&&console.log("Tube-level target handle already connected, will replace",t),true):(s&&console.log("Allowing connection from tube handle to tube-level handle",t),true):(s&&console.log("Connection rejected: Tube handles can only connect from other tube handles",t),false);if(p?.type==="coupler"&&(t.sourceHandle?.startsWith("left-")||t.sourceHandle?.startsWith("right-")))return b?.type!=="splice"?(s&&console.log("Connection rejected: Coupler handles can only connect to splices",t),false):t.targetHandle!=="left"&&t.targetHandle!=="right"?(s&&console.log("Connection rejected: Coupler can only connect to splice left/right handles",t),false):z.current.find(u=>u.source===t.source&&u.sourceHandle===t.sourceHandle)?(s&&console.log("Coupler handle already connected, will replace",t),true):(s&&console.log("Allowing connection from coupler handle to splice",t),true);if(b?.type==="coupler"&&(t.targetHandle?.startsWith("left-")||t.targetHandle?.startsWith("right-")))return p?.type!=="splice"?(s&&console.log("Connection rejected: Coupler handles can only connect from splices",t),false):t.sourceHandle!=="left"&&t.sourceHandle!=="right"?(s&&console.log("Connection rejected: Coupler can only connect from splice left/right handles",t),false):z.current.find(u=>u.target===t.target&&u.targetHandle===t.targetHandle)?(s&&console.log("Coupler target handle already connected, will replace",t),true):(s&&console.log("Allowing connection from splice to coupler handle",t),true);if(t.source&&t.sourceHandle&&z.current.find(u=>u.source===t.source&&u.sourceHandle===t.sourceHandle))return s&&console.log("Source handle already connected, will replace",t),true;if(t.target&&t.targetHandle&&z.current.find(u=>u.target===t.target&&u.targetHandle===t.targetHandle))return s&&console.log("Target handle already connected, will replace",t),true;if((p?.type==="cable"||b?.type==="cable")&&(t.sourceHandle==="cable-button"||t.targetHandle==="cable-button"))return t.sourceHandle!=="cable-button"||t.targetHandle!=="cable-button"?(s&&console.log("Connection rejected: Cable button handles can only connect to other cable button handles",t),false):z.current.find(F=>F.source===t.source&&F.sourceHandle===t.sourceHandle)?(s&&console.log("Cable button source handle already connected, will replace",t),true):z.current.find(F=>F.target===t.target&&F.targetHandle===t.targetHandle)?(s&&console.log("Cable button target handle already connected, will replace",t),true):(s&&console.log("Allowing connection between cable button handles",t),true);let g=C.validateConnection({source:t.source??null,target:t.target??null,sourceHandle:t.sourceHandle??null,targetHandle:t.targetHandle??null});if(!g.valid&&y){if(t.source&&t.sourceHandle&&z.current.find(u=>u.source===t.source&&u.sourceHandle===t.sourceHandle))return s&&console.log("Source handle has existing edge, will replace",t),true;if(t.target&&t.targetHandle&&z.current.find(u=>u.target===t.target&&u.targetHandle===t.targetHandle))return s&&console.log("Target handle has existing edge, will replace",t),true}return s&&!g.valid&&console.log("Connection rejected by store validation:",g.reason,t),g.valid},[X,C,s,y]),cr=useCallback(t=>{let p=X(t.source),b=X(t.target),g=p?.type==="vertical-pdu",N=p?.data,u=p?.type==="device"&&N?.deviceType==="switch",F=!!t.targetHandle&&(t.targetHandle.startsWith("pwr")||t.targetHandle.startsWith("power")),Y=!!t.targetHandle&&(t.targetHandle.startsWith("net-")||t.targetHandle.startsWith("port-")||/^[A-Z0-9]+-\d+$/i.test(t.targetHandle)),U=p?.type==="tube"&&b?.type==="cable",te=p?.type==="cable"&&b?.type==="tube",de=U||te,fe=t.sourceHandle==="cable-button"&&t.targetHandle==="cable-button",q="fiber";g&&F?q="power":fe?q="thick-cable":de&&(q=P?"smoothstep":"fiber");let B;if((q==="fiber"||q==="smoothstep")&&!g){let S=Ve(t.source,t.sourceHandle);S&&(B={color:S.color,striped:S.striped});}else if(q==="thick-cable"&&fe){let S=p?.data;B={color:S?.color||(S?.tubeStartIndex?oe(S.tubeStartIndex):"#6366f1")};}if(t.source&&t.sourceHandle){let S=G({edges:z.current,connection:t,edgeType:q,selectEdgeZIndex:V,findBy:"source",data:B});if(S){$(S);return}}if(t.target&&t.targetHandle){let S=G({edges:z.current,connection:t,edgeType:q,selectEdgeZIndex:V,findBy:"target",data:B});if(S){$(S);return}}if(b?.type==="splice"&&(t.targetHandle==="left"||t.targetHandle==="right")&&t.target&&t.targetHandle){let S=G({edges:z.current,connection:t,edgeType:"fiber",selectEdgeZIndex:V,findBy:"target",data:B});if(S){$(S);return}if(t.targetHandle==="right"&&(S=G({edges:z.current,connection:t,edgeType:"fiber",selectEdgeZIndex:V,findBy:"source",data:B}),S)){$(S);return}}if(p?.type==="splice"&&t.sourceHandle==="right"&&t.source&&t.sourceHandle){let S=G({edges:z.current,connection:t,edgeType:"fiber",selectEdgeZIndex:V,findBy:"source",data:B});if(S){$(S);return}if(S=G({edges:z.current,connection:t,edgeType:"fiber",selectEdgeZIndex:V,findBy:"target",data:B}),S){$(S);return}}if(p?.type==="tube"&&t.sourceHandle?.startsWith("fiber-")&&t.source&&t.sourceHandle){let S=G({edges:z.current,connection:t,edgeType:"fiber",selectEdgeZIndex:V,findBy:"source",data:B});if(S){$(S);return}}if(b?.type==="tube"&&t.targetHandle?.startsWith("fiber-")&&t.target&&t.targetHandle){let S=G({edges:z.current,connection:t,edgeType:"fiber",selectEdgeZIndex:V,findBy:"target",data:B});if(S){$(S);return}}if((p?.type==="cable"||p?.type==="tube")&&t.sourceHandle?.startsWith("tube-")&&t.source&&t.sourceHandle){let S=G({edges:z.current,connection:t,edgeType:q,selectEdgeZIndex:V,findBy:"source",data:B});if(S){$(S);return}}if((b?.type==="cable"||b?.type==="tube")&&t.targetHandle?.startsWith("tube-")&&t.target&&t.targetHandle){let S=G({edges:z.current,connection:t,edgeType:q,selectEdgeZIndex:V,findBy:"target",data:B});if(S){$(S);return}}if(fe&&t.source&&t.sourceHandle&&t.target&&t.targetHandle){let S=p?.data,J=S?.color||(S?.tubeStartIndex?oe(S.tubeStartIndex):"#6366f1"),be=G({edges:z.current,connection:t,edgeType:"thick-cable",selectEdgeZIndex:V,findBy:"source",data:{color:J}});if(be){$(be);return}if(be=G({edges:z.current,connection:t,edgeType:"thick-cable",selectEdgeZIndex:V,findBy:"target",data:{color:J}}),be){$(be);return}}if(g&&F&&t.target&&t.targetHandle){let S=G({edges:z.current,connection:t,edgeType:"power",selectEdgeZIndex:V,findBy:"target",data:B});if(S){$(S);return}}if(u&&Y&&t.target&&t.targetHandle){let S=G({edges:z.current,connection:t,edgeType:"fiber",selectEdgeZIndex:V,findBy:"target",data:B});if(S){$(S);return}}let Re=C.validateConnection({source:t.source??null,target:t.target??null,sourceHandle:t.sourceHandle??null,targetHandle:t.targetHandle??null});if(!Re.valid){if(y){if(t.source&&t.sourceHandle){let S=G({edges:z.current,connection:t,edgeType:q,selectEdgeZIndex:V,findBy:"source",data:B});if(S){$(S);return}}if(t.target&&t.targetHandle){let S=G({edges:z.current,connection:t,edgeType:q,selectEdgeZIndex:V,findBy:"target",data:B});if(S){$(S);return}}}if(g&&t.source&&t.sourceHandle){let S=G({edges:z.current,connection:t,edgeType:F?"power":"fiber",selectEdgeZIndex:V,findBy:"source",data:B});if(S){$(S);return}}if(u&&t.source&&t.sourceHandle){let S=G({edges:z.current,connection:t,edgeType:"fiber",selectEdgeZIndex:V,findBy:"source",data:B});if(S){$(S);return}}s&&console.warn(`Connection rejected: ${Re.reason}`);return}let ve={...t,type:q,zIndex:V({...t,id:"temp-id"}),data:B};$(S=>{let J=addEdge(ve,S),be=J[J.length-1];return be&&(uo(ht=>new Set(ht).add(be.id)),setTimeout(()=>{uo(ht=>{let fo=new Set(ht);return fo.delete(be.id),fo});},1e3)),J});},[$,C,V,X,s,Ve,y,P]),lr=useCallback((t,p)=>{if(!p.source||!p.target||!p.sourceHandle||!p.targetHandle)return;let b=t.sourceHandle||"",g=t.targetHandle||"",N=p.sourceHandle||"",u=p.targetHandle||"";if(b.startsWith("tube-")&&N!==b){s&&console.log("Edge update blocked: Cannot disconnect tube handle",{oldEdge:t,newConnection:p});return}if(g.startsWith("tube-")&&u!==g){s&&console.log("Edge update blocked: Cannot disconnect tube handle",{oldEdge:t,newConnection:p});return}let F=X(p.source),Y=X(p.target),U=F?.type==="vertical-pdu",te=!!p.targetHandle&&(p.targetHandle.startsWith("pwr")||p.targetHandle.startsWith("power")),de=F?.type==="tube"&&Y?.type==="cable",fe=F?.type==="cable"&&Y?.type==="tube",q=de||fe,B;U&&te?B="power":q?B=P?"smoothstep":"fiber":B="fiber";let Re;if((B==="fiber"||B==="smoothstep")&&!U){let ve=Ve(p.source,p.sourceHandle);ve&&(Re={color:ve.color,striped:ve.striped});}$(ve=>ve.map(J=>J.id===t.id?{...J,source:p.source,target:p.target,sourceHandle:p.sourceHandle,targetHandle:p.targetHandle,type:B,data:Re!==void 0?{...J.data,...Re}:J.data,zIndex:V({...p,id:J.id,type:B}),style:{...J.style,zIndex:V({...p,id:J.id,type:B})}}:J));},[$,X,Ve,V,P,s]),pr=useCallback((t,p)=>{let b=t.metaKey||t.ctrlKey;if(p.type==="tube"&&p.parentId&&!b){let N=ke().find(u=>u.id===p.parentId&&u.type==="cable");if(N){_(u=>u.map(F=>({...F,selected:F.id===N.id}))),c&&c(N);return}}if(b&&p.type==="device"){let g=p.data||{},N=g.view||(Array.isArray(g.rearPorts)&&g.rearPorts.length>0?"rear":"front"),u=N==="front"?"rear":"front";s&&console.log(`Command+click: Toggling device ${p.id} from ${N} to ${u}`),h&&h(p.id,u),c&&c(p);}else c&&c(p);},[h,c,s,ke,_]),ur=useCallback(()=>{},[]),fr=useCallback((t,p)=>{l&&l(p);},[l]),[ue,bt]=useState(null),[po,uo]=useState(new Set);useOnSelectionChange({onChange:({nodes:t})=>{if(t&&t.length===1){let p=t[0];if(p.type==="tube"&&p.parentId){let g=ke().find(N=>N.id===p.parentId&&N.type==="cable");if(g){bt(g),_(N=>N.map(u=>({...u,selected:u.id===g.id}))),c&&c(g);return}}bt(p),c&&c(p);}else bt(null),c&&c(null);}});let gr=useCallback((t,{nodeId:p,handleType:b})=>{s&&console.log("Connection started from",{nodeId:p,handleType:b});},[s]),br=useCallback(t=>{s&&console.log("Connection ended",t);},[s]),hr=useCallback(()=>{if(!ue)return;let t=X(ue.id);if(t){if(t.type==="rack"){let g=((t.data||{}).face||"front")==="front"?"rear":"front";f?(f(t.id,g),h&&ke().filter(u=>u.parentId===t.id).forEach(u=>{h(u.id,g);})):_(N=>N.map(u=>u.id===t.id?{...u,data:{...u.data,face:g}}:u.parentId===t.id?{...u,data:{...u.data,view:g}}:u));return}if(t.type==="device"){let p=t.data||{},b=Array.isArray(p.rearPorts)&&p.rearPorts.length>0,g=Array.isArray(p.ports)&&p.ports.length>0,u=(p.view||(b&&!g?"rear":"front"))==="front"?"rear":"front";h?h(t.id,u):_(F=>F.map(Y=>Y.id===t.id?{...Y,data:{...Y.data,view:u}}:Y));}}},[ue,X,f,h,_,ke]),mr=useMemo(()=>L.map(t=>{let p=t,b=X(String(p.source)),g=X(String(p.target)),N=ct(p.sourceHandle||"",b),u=ct(p.targetHandle||"",g),F=b&&b.data?.view,Y=g&&g.data?.view,U=b?.type==="device"&&F==="rear",te=g?.type==="device"&&Y==="rear",B=U&&N!=="rear"&&(te&&u!=="rear")?{...t.style,opacity:0,pointerEvents:"none",zIndex:0}:t.style;return {...t,style:B,className:po.has(t.id)?"edge-connecting":t.className}}),[L,po,X]);return jsxs("div",{ref:ae,className:`${m||""} ${E==="light"?"react-flow-light":"react-flow-dark"}`,style:{width:"100%",height:"100%",...v},children:[jsxs(ReactFlow,{nodes:O,edges:mr,onNodesChange:t=>{nr(t),R?n&&n(ge.current):C.setState({nodes:ge.current});},onEdgesChange:t=>{let p=t.filter(b=>{if(b.type==="remove"){let g=z.current.find(N=>N.id===b.id);if(g){let N=g.sourceHandle||"",u=g.targetHandle||"";if(N.startsWith("tube-")||u.startsWith("tube-"))return s&&console.log("Edge deletion blocked: Edge connected to tube handle is not detachable",g),false}}return true});p.length>0&&(j(p),R?i&&i(z.current):C.setState({edges:z.current}));},onConnect:cr,onConnectStart:gr,onConnectEnd:br,onEdgeUpdate:lr,isValidConnection:dr,onNodeClick:pr,onNodeDoubleClick:ur,onNodeDragStart:ir,onNodeDrag:ar,onNodeDragStop:sr,onEdgeClick:fr,onInit:w,nodeTypes:rr,edgeTypes:Sn,defaultEdgeOptions:{zIndex:1e3,reconnectable:true},nodesDraggable:true,nodesConnectable:true,elementsSelectable:true,selectNodesOnDrag:false,connectOnClick:M,fitView:true,proOptions:{hideAttribution:true},children:[jsx(Background,{color:E==="light"?"#e5e5e5":"#2a2a2a"}),jsx(Controls,{}),jsx(MiniMap,{}),jsx(Panel,{position:"bottom-right",className:"react-networks-attribution",children:jsx("a",{href:"https://github.com/MP70/react-networks",target:"_blank",rel:"noopener noreferrer",className:"react-networks-attribution-link",children:"react-networks"})})]}),A&&jsx("button",{className:"download-button",onClick:gt,style:{position:"absolute",top:W.includes("top")?"10px":"auto",bottom:W.includes("bottom")?"10px":"auto",right:W.includes("right")?"10px":"auto",left:W.includes("left")?"10px":"auto",zIndex:1e3,background:"#374151",color:"#e5e7eb",border:"1px solid #4b5563",borderRadius:"4px",padding:"0.5rem 0.75rem",fontSize:"0.875rem",cursor:"pointer",transition:"all 0.2s ease",...H},children:x}),ue&&(ue.type==="rack"||ue.type==="device")&&jsx("div",{style:{position:"absolute",top:12,right:12,display:"flex",gap:8,zIndex:2e3},children:jsx("button",{onClick:t=>{t.preventDefault(),hr();},style:{background:"#374151",color:"#e5e7eb",border:"1px solid #4b5563",borderRadius:4,padding:"6px 10px",fontSize:11,fontFamily:"monospace",cursor:"pointer"},title:(()=>{let t=ue.data;if(ue.type==="rack")return (t?.face||"front")==="front"?"Switch to rear":"Switch to front";{let p=Array.isArray(t?.rearPorts)&&t.rearPorts.length>0,b=Array.isArray(t?.ports)&&t.ports.length>0;return (t?.view||(p&&!b?"rear":"front"))==="front"?"Switch to rear":"Switch to front"}})(),children:(()=>{let t=ue.data;if(ue.type==="rack")return (t?.face||"front")==="front"?"\u21C4 Rear":"\u21C4 Front";{let p=Array.isArray(t?.rearPorts)&&t.rearPorts.length>0,b=Array.isArray(t?.ports)&&t.ports.length>0;return (t?.view||(p&&!b?"rear":"front"))==="front"?"\u21C4 Rear":"\u21C4 Front"}})()})})]})},Cn=e=>jsx(ReactFlowProvider,{children:jsx(Hn,{...e})});var Jo=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}}),Qo=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}}),er=e=>{let o=n=>{if(!n)return;if(typeof n=="string")return n;let i=n.device;return typeof i=="object"&&i?i.id:i},r=o(e.termination_a),a=o(e.termination_b);return {id:`cable-${e.id}`,source:`device-${r}`,target:`device-${a}`,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}}},En=e=>{let o=[],r=[];return e.racks.forEach(a=>o.push(Jo(a))),e.devices.forEach(a=>o.push(Qo(a))),e.cables.forEach(a=>r.push(er(a))),{nodes:o,edges:r}},Rn=e=>{let o=e.filter(n=>n.type==="rack"),r=e.filter(n=>n.type==="device"),a=e.filter(n=>!["rack","device"].includes(n.type));return o.forEach((n,i)=>{n.position={x:i*300,y:100};}),r.forEach(n=>{if(n.parentId){let i=o.find(d=>d.id===n.parentId);if(i){let d=n.data.uPosition||1,s=n.data.uHeight||1;n.position={x:i.position.x+50,y:i.position.y+d*20-s*10};}}else n.position={x:Math.random()*400+100,y:Math.random()*200+50};}),a.forEach((n,i)=>{n.position={x:i*150+100,y:300};}),e};var We=class extends Error{constructor(r,a,n,i,d){super(`Device placement conflict: ${a} at U${n}-${n+i-1} in rack ${r}${d?` conflicts with ${d}`:""}`);this.rackId=r;this.deviceId=a;this.uPosition=n;this.uHeight=i;this.conflictWith=d;this.name="DevicePlacementError";}};function oo(e,o={}){let r=[],a=[];for(let n of e.devices)n.unit+n.height-1>e.units&&a.push({deviceId:n.id,uPosition:n.unit,uHeight:n.height,rackUHeight:e.units});for(let n=0;n<e.devices.length;n++){let i=e.devices[n],d=i.unit,s=i.unit+i.height-1;for(let c=n+1;c<e.devices.length;c++){let l=e.devices[c],h=l.unit,f=l.unit+l.height-1;d<=f&&s>=h&&r.push({deviceId:i.id,uPosition:i.unit,uHeight:i.height,conflictWith:l.id});}}return {isValid:r.length===0&&a.length===0,conflicts:r,outOfBounds:a}}function tr(e,o,r={}){let{deviceTypeMapping:a={}}=r,n=a[e.type]||"device",i=De(o,e.unit,e.height);return {id:e.id,type:n,position:i,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}}}function Tn(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:[]}}}function Dn(e,o={}){let{conflictPolicy:r="strict",validatePlacements:a=true}=o,n=[],i=[];if(a)for(let d of e){let s=oo(d,o);if(!s.isValid&&r==="strict"){let c=[];throw s.conflicts.forEach(l=>{c.push(`Device ${l.deviceId} at U${l.uPosition}-${l.uPosition+l.uHeight-1} conflicts with ${l.conflictWith}`);}),s.outOfBounds.forEach(l=>{c.push(`Device ${l.deviceId} at U${l.uPosition}-${l.uPosition+l.uHeight-1} exceeds rack height (${l.rackUHeight}U)`);}),new We(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=Tn(d);n.push(s);for(let c of d.devices)try{let l=tr(c,s,o);i.push(l);}catch(l){if(r==="strict")throw l;if(r==="nearest"){let h=Ge(s,{id:c.id,data:{label:c.name,uHeight:c.height}},i,c.unit);if(h!==c.unit){console.warn(`Device ${c.id} moved from U${c.unit} to U${h} due to conflict`);let f={...c,unit:h},m=tr(f,s,o);i.push(m);}else throw new We(d.id,c.id,c.unit,c.height)}}}return n.push(...i),n}function In(e){let o=[],r=e.filter(a=>a.type==="rack");for(let a of r){let i=e.filter(d=>d.type==="device"&&d.parentId===a.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,ports:d.data.ports,connections:d.data.connections}));o.push({id:a.id,name:a.data.label,position:a.position,units:a.data.uHeight||42,uNumberingDirection:a.data.uNumberingDirection||"bottom-up",customHeaderText:a.data.customHeaderText,devices:i});}return o}function $n(e,o,r,a){return e.map(n=>n.id!==o?n:{...n,devices:n.devices.map(i=>i.id!==r?i:{...i,unit:a})})}function _n(e,o,r,a={}){let{conflictPolicy:n="strict"}=a;return e.map(i=>{if(i.id!==o)return i;if(n==="strict"&&!oo({...i,devices:[...i.devices,r]},a).isValid)throw new We(o,r.id,r.unit,r.height);return {...i,devices:[...i.devices,r]}})}function Fn(e,o,r){return e.map(a=>a.id!==o?a:{...a,devices:a.devices.filter(n=>n.id!==r)})}var ze=class extends Error{constructor(r,a,n,i){super(`Splice placement conflict: ${a} at holder ${n} in tray ${r}${i?` conflicts with ${i}`:""}`);this.trayId=r;this.spliceId=a;this.holder=n;this.conflictWith=i;this.name="SplicePlacementError";}};function ro(e,o={}){let r=[],a=[];for(let n of e.splices)(n.holder<1||n.holder>Ne)&&a.push({spliceId:n.id,holder:n.holder,max:Ne});for(let n=0;n<e.splices.length;n++){let i=e.splices[n];for(let d=n+1;d<e.splices.length;d++){let s=e.splices[d];i.holder===s.holder&&r.push({spliceId:i.id,holder:i.holder,conflictWith:s.id});}}return {isValid:r.length===0&&a.length===0,conflicts:r,outOfBounds:a}}function or(e,o){let r=Me(o,e.holder);return {id:e.id,type:"splice",position:r,parentId:o.id,extent:"parent",data:{label:e.name,holderPosition:e.holder,lossDb:e.lossDb}}}function An(e){return {id:e.id,type:"splice-tray",position:e.position,data:{label:e.name,status:"active"}}}function Wn(e,o={}){let{conflictPolicy:r="strict",validatePlacements:a=true}=o,n=[],i=[];if(a)for(let d of e){let s=ro(d,o);if(!s.isValid&&r==="strict"){let c=[];throw s.conflicts.forEach(l=>{c.push(`Splice ${l.spliceId} at holder ${l.holder} conflicts with ${l.conflictWith}`);}),s.outOfBounds.forEach(l=>{c.push(`Splice ${l.spliceId} at holder ${l.holder} is out of bounds (max: ${l.max})`);}),new ze(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=An(d);n.push(s);for(let c of d.splices)try{let l=or(c,s);i.push(l);}catch(l){if(r==="strict")throw l;if(r==="nearest"){let h=[...n,...i],f=et(s,{id:c.id,data:{label:c.name,holderPosition:c.holder}},h,c.holder);if(f!==c.holder){console.warn(`Splice ${c.id} moved from holder ${c.holder} to holder ${f} due to conflict`);let m={...c,holder:f},v=or(m,s);i.push(v);}else throw new ze(d.id,c.id,c.holder)}}}return n.push(...i),n}function zn(e){let o=[],r=e.filter(a=>a.type==="splice-tray");for(let a of r){let i=e.filter(d=>d.type==="splice"&&d.parentId===a.id).map(d=>({id:d.id,name:d.data.label,holder:d.data.holderPosition||1,lossDb:d.data.lossDb}));o.push({id:a.id,name:a.data.label,position:a.position,splices:i});}return o}function Ln(e,o,r,a){return e.map(n=>n.id!==o?n:{...n,splices:n.splices.map(i=>i.id!==r?i:{...i,holder:a})})}function Mn(e,o,r,a={}){let{conflictPolicy:n="strict"}=a;return e.map(i=>{if(i.id!==o)return i;if(n==="strict"&&!ro({...i,splices:[...i.splices,r]},a).isValid)throw new ze(o,r.id,r.holder);return {...i,splices:[...i.splices,r]}})}function Un(e,o,r){return e.map(a=>a.id!==o?a:{...a,splices:a.splices.filter(n=>n.id!==r)})}
|
|
2
|
+
export{Gr as COUPLERS_PER_PANEL,st as COUPLER_SLOT_HEIGHT_PX,Zr as COUPLER_WIDTH_PX,Ut as CableNode,Kt as ClosureNode,Bt as CouplerNode,Et as DeviceNode,We as DevicePlacementError,Eo as FIBER_COLORS_12,kt as FiberEdge,wt as FiberNode,Cn as NetworkDiagram,zo as PANEL_BORDER_WIDTH,Ee as PANEL_HEADER_HEIGHT,at as PANEL_HEIGHT_PX,he as PANEL_PADDING,Lo as PANEL_TUBE_TRAY_SPACING,it as PANEL_WIDTH_PX,St as POWER_CONNECTORS,jt as PatchPanelNode,vt as PowerEdge,xt as RackNode,It as SpliceNode,ze as SplicePlacementError,zt as SpliceTrayNode,Mt as TubeNode,Rt as VerticalPDU,ko as Width,_n as addDeviceToRack,Mn as addSpliceToTray,oe as baseColorFor,Dn as buildNodesFromRackConfig,Wn as buildNodesFromSpliceConfig,qr as calculateCouplerRightX,Qr as calculateCouplerSlotSpacing,Vo as calculateCouplerSpacing,De as calculateDevicePositionFromU,Yt as calculatePanelDimensions,Oo as calculateSlotPositionFromY,Me as calculateSplicePositionFromNumber,Yo as calculateYFromSlotPosition,qt as createNetworkDiagramStore,In as createRackConfigFromNodes,zn as createSpliceConfigFromNodes,Ue as fiberSolidOrStriped,pt as findNearestRack,et as findNextAvailableHolderPosition,Ge as findNextAvailableUPosition,Rn as generateLayout,Je as getConnectorConfig,Ot as getCouplerDimensions,Qe as getDeviceConnectorType,Lt as getFiberColor,Bo as getInnerContentWidth,Ht as getPDUPortType,Kr as getPanelHeight,Uo as getPanelWidth,Ie as getPowerPortStyle,Go as getRackBounds,ce as getStatusColor,Mo as getTrayDimensions,dt as getTubeDimensions,er as inventoryCableToNetworkEdge,Qo as inventoryDeviceToNetworkNode,Jo as inventoryRackToNetworkNode,En as inventoryToNetworkDiagram,Mr as isHighPowerConnector,lt as isPointInRack,Ro as isStriped,yt as isUPositionAvailable,Fn as removeDeviceFromRack,Un as removeSpliceFromTray,G as replaceEdge,Jr as snapToCouplerPosition,Ft as snapToSplicePosition,mt as snapToUPosition,go as updateDeviceUPosition,$n as updateDeviceUPositionInSchema,Ln as updateSpliceHolderPosition,eo as useDiagramEdges,Qt as useDiagramNodes,ln as useNetworkDiagram,xr as validateAndSnapDevice,oo as validateRackDevicePlacements,ro as validateSplicePlacements};//# sourceMappingURL=index.mjs.map
|
|
3
3
|
//# sourceMappingURL=index.mjs.map
|