@tscircuit/runframe 0.0.1944 → 0.0.1946
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.
|
@@ -1821,7 +1821,7 @@ var useErrorTelemetry = ({
|
|
|
1821
1821
|
};
|
|
1822
1822
|
|
|
1823
1823
|
// package.json
|
|
1824
|
-
var version = "0.0.
|
|
1824
|
+
var version = "0.0.1945";
|
|
1825
1825
|
var package_default = {
|
|
1826
1826
|
name: "@tscircuit/runframe",
|
|
1827
1827
|
main: "dist/preview.js",
|
|
@@ -1876,7 +1876,7 @@ var package_default = {
|
|
|
1876
1876
|
"@tscircuit/fake-snippets": "^0.0.163",
|
|
1877
1877
|
"@tscircuit/file-server": "^0.0.32",
|
|
1878
1878
|
"@tscircuit/internal-dynamic-import": "^0.0.0",
|
|
1879
|
-
"@tscircuit/pcb-viewer": "1.11.
|
|
1879
|
+
"@tscircuit/pcb-viewer": "1.11.369",
|
|
1880
1880
|
"@tscircuit/schematic-viewer": "^2.0.61",
|
|
1881
1881
|
"@types/bun": "latest",
|
|
1882
1882
|
"@types/debug": "^4.1.12",
|
|
@@ -1937,7 +1937,7 @@ var package_default = {
|
|
|
1937
1937
|
yargs: "^17.7.2"
|
|
1938
1938
|
},
|
|
1939
1939
|
dependencies: {
|
|
1940
|
-
"@tscircuit/eval": "^0.0.
|
|
1940
|
+
"@tscircuit/eval": "^0.0.837",
|
|
1941
1941
|
"@tscircuit/solver-utils": "^0.0.7"
|
|
1942
1942
|
}
|
|
1943
1943
|
};
|
package/dist/preview.js
CHANGED
package/dist/runner.js
CHANGED
|
@@ -5513,7 +5513,7 @@ $1`).replace(/>(\s*)(?=<!--\s*\/)/g,"> ")}}});function Y2t(t,e,n){if(!e||!n)retu
|
|
|
5513
5513
|
transition: opacity 0.2s;
|
|
5514
5514
|
margin-bottom: 10px;
|
|
5515
5515
|
color: red;
|
|
5516
|
-
`,$co=({children:t,transform:e=Cl(),elements:n})=>{const o=te.useRef(null),{isShowingDRCErrors:r,hoveredErrorId:i,focusedErrorId:s}=O_(p=>({isShowingDRCErrors:p.is_showing_drc_errors,hoveredErrorId:p.hovered_error_id,focusedErrorId:p.focused_error_id})),a=s??i;if(!n)return G.jsx("div",{style:{position:"relative"},ref:o,children:t});const c=n.filter(p=>p.type==="pcb_trace_error"&&!p.message?.includes("Multiple components found with name")),l=n.filter(p=>p.type==="pcb_via_clearance_error"),u=n.filter(p=>p.type==="pcb_trace_error"&&p.message?.includes("Multiple components found with name")),_=rxt(n),d=oxt(n,a),m=p=>{const x=lao({error:p,indexes:_});if(!x||typeof x.x!="number"||typeof x.y!="number")return null;const f=pt(e,x);return Number.isNaN(f.x)||Number.isNaN(f.y)?null:f};let h=null;return d&&(h=m(d)),G.jsxs("div",{style:{position:"relative"},ref:o,children:[t,c.map((p,x)=>{const f=qA(p,x),g=a===f;if(!g&&!r)return null;const y=m(p);if(!y)return null;const b=d4e(y,o);return G.jsxs(te.Fragment,{children:[G.jsx(Dxt,{errorCenter:y,isHighlighted:g}),G.jsx("div",{style:{position:"absolute",left:y.x-15,top:y.y-15,width:30,height:30,zIndex:gu.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:v=>{const S=v.currentTarget.nextElementSibling;if(S){const C=S.querySelector(".error-message");C&&(C.style.opacity="1")}},onMouseLeave:v=>{if(!g){const S=v.currentTarget.nextElementSibling;if(S){const C=S.querySelector(".error-message");C&&(C.style.opacity="0")}}}}),G.jsx("div",{style:{position:"absolute",zIndex:g?200:100,left:b.left,top:b.top,color:g?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:r||g?"flex":"none",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:b.transform},children:G.jsx("div",{className:`error-message ${h4e}`,style:{opacity:g?1:0,border:`1px solid ${g?"#ff4444":"red"}`},children:p.message})})]},f)}),l.map((p,x)=>{const f=qA(p,x),g=a===f;if(!g&&!r)return null;const y=m(p);if(!y)return null;const b=d4e({x:y.x,y:y.y},o);return G.jsxs(te.Fragment,{children:[G.jsx(Dxt,{errorCenter:y,isHighlighted:g}),G.jsx("div",{style:{position:"absolute",left:y.x-15,top:y.y-15,width:30,height:30,zIndex:gu.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:v=>{const S=v.currentTarget.nextElementSibling;if(S){const C=S.querySelector(".error-message");C&&(C.style.opacity="1")}},onMouseLeave:v=>{if(!g){const S=v.currentTarget.nextElementSibling;if(S){const C=S.querySelector(".error-message");C&&(C.style.opacity="0")}}}}),G.jsx("div",{style:{position:"absolute",zIndex:g?gu.errorOverlay+10:gu.errorOverlay+1,left:b.left,top:b.top,color:g?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:"flex",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:b.transform},children:G.jsx("div",{className:`error-message ${h4e}`,style:{opacity:g?1:0,border:`1px solid ${g?"#ff4444":"red"}`},children:p.message})})]},f)}),u.map((p,x)=>{const f=p.component_name||p.message?.match(/name "([^"]+)"/)?.[1];if(!f)return null;const g=n?.filter(v=>v.type==="source_component"&&v.name===f||v.type==="pcb_component"&&n?.find(S=>S.type==="source_component"&&S.source_component_id===v.source_component_id&&S.name===f))||[],y=qA(p,x),b=a===y;return!b&&!r?null:g.map((v,S)=>{let C={x:0,y:0};if(v.type==="pcb_component")C=v.center||{x:0,y:0};else if(v.type==="source_component"){const V=n?.find(j=>j.type==="pcb_component"&&j.source_component_id===v.source_component_id);V&&V.type==="pcb_component"&&(C=V.center||{x:0,y:0})}const w=pt(e,C);if(Number.isNaN(w.x)||Number.isNaN(w.y))return null;const D=Math.abs(e.a),F=Math.max(8,Math.min(30,.5*D)),z=d4e(w,o);return G.jsxs(te.Fragment,{children:[G.jsx("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none",mixBlendMode:"difference",zIndex:gu.errorOverlay},width:"100%",height:"100%",children:b?G.jsx("polygon",{points:`${w.x},${w.y-F*1.25} ${w.x+F},${w.y} ${w.x},${w.y+F*1.25} ${w.x-F},${w.y}`,fill:"#ff4444"}):G.jsx("circle",{cx:w.x,cy:w.y,r:F,fill:"none",stroke:b?"#ff4444":"red",strokeWidth:b?Math.max(2,F*.15):Math.max(1,F*.1),opacity:1})}),G.jsx("div",{style:{position:"absolute",left:w.x-(F+10),top:w.y-(F+10),width:(F+10)*2,height:(F+10)*2,zIndex:gu.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:V=>{const j=V.currentTarget.nextElementSibling;if(j){const q=j.querySelector(".error-message");q&&(q.style.opacity="1")}},onMouseLeave:V=>{if(!b){const j=V.currentTarget.nextElementSibling;if(j){const q=j.querySelector(".error-message");q&&(q.style.opacity="0")}}}}),G.jsx("div",{style:{position:"absolute",zIndex:b?gu.errorOverlay+20:gu.errorOverlay+10,left:z.left,top:z.top,color:b?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:r||b?"flex":"none",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:z.transform},children:G.jsx("div",{className:`error-message ${h4e}`,style:{opacity:b?1:0,border:`1px solid ${b?"#ff4444":"red"}`},children:p.message})})]},`${y}_${S}`)})}),h&&G.jsx(Vco,{center:h})]})};function Wco(t,e){return t.size!==e.size?!1:Array.from(t).every(n=>e.has(n))}function Uco({primitiveElement:t,elements:e}){let n=t.trace_length?`${t.trace_length.toFixed(3)}`:"";const o=Z9(e).source_trace.get(t?.source_trace_id);if(o?.display_name&&(o?.max_length?n+=` / ${o.max_length}mm `:n+=" mm ",n+=`(${o.display_name})`),!n)return null;const r=t.trace_length&&o?.max_length&&t.trace_length>o.max_length;return{text:n,isOverLength:r}}function Xco(t){const{primitives:e,is_showing_multiple_traces_length:n,elements:o}=t,r=e.filter(c=>c._element.type==="pcb_trace"),i=o.filter(c=>c.type==="source_trace"),s=e.filter(c=>c._element.type!=="pcb_trace"),a=r.filter(c=>i.some(l=>c._element.type==="pcb_trace"&&c._element.source_trace_id===l.source_trace_id&&l.max_length!==void 0));if(!n)return[...s,...a];if(r.length>1){const c=r.reduce((l,u)=>{const _=l._element.trace_length;return u._element.trace_length<_?u:l},r[0]);return[...s,c]}return e}var jco={position:"absolute",left:0,top:0,pointerEvents:"none",color:"red",fontFamily:"sans-serif",fontSize:12,textShadow:"0 0 2px black"},Gco=t=>{const{_element:e,_parent_pcb_component:n,_parent_source_component:o,_source_port:r}=t;switch(e.type){case"pcb_trace":return e.trace_length?`${e.trace_length.toFixed(3)}`:"";case"pcb_smtpad":case"pcb_plated_hole":{const i=[],s=Array.from(new Set((e.port_hints??[]).concat(r?.port_hints??[]))).filter(c=>!/^[0-9]+$/.test(c)).filter(c=>!c.includes("unnamed_")).sort((c,l)=>l.localeCompare(c)),a=o&&"name"in o&&o.name&&!o.name.includes("unnamed_")?o.name:null;return s.length>0?a?i.push(...s.map(c=>`${a}.${c}`)):i.push(...s):a&&i.push(a),i.join(", ")}default:return""}},Yco={top:"red",bottom:"aqua"},qco=({primitive:t,mousePos:e,elements:n})=>{const[o,r]=te.useState(!1),i=t._element;te.useEffect(()=>{setTimeout(()=>{r(!0)},100)},[]);const[s,a,c,l]=[t.screen_x,t.screen_y,t.screen_w,t.screen_h],u=t.same_space_index??0,_=26,d=Yco[t?._element?.layer]??"red";let m=0;if(i.type==="pcb_smtpad"&&i?.shape==="rotated_rect"?m=i?.ccw_rotation??0:(i.type==="pcb_smtpad"&&(i?.shape==="pill"||i?.shape==="rotated_pill")&&"ccw_rotation"in t||i.type==="pcb_plated_hole"&&(i?.shape==="pill"||i?.shape==="oval")&&"ccw_rotation"in t)&&(m=i.ccw_rotation??0),i.type==="pcb_trace"){const x=Uco({primitiveElement:i,elements:n});if(!x)return null;const f=e.y-35;return G.jsx("div",{style:{zIndex:gu.elementOverlay,position:"absolute",left:e.x,top:f,color:d,pointerEvents:"none",transform:"translateX(-50%)"},children:G.jsx("div",{style:{backgroundColor:"#f2efcc",color:x.isOverLength?"red":"black",textShadow:"none",WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale",padding:"6px 6px",borderRadius:"6px",fontSize:"14px",minWidth:"45px",textAlign:"center",whiteSpace:"nowrap"},children:x.text})})}const h=Gco(t);return h.trim().length===0?null:G.jsx("div",{style:{zIndex:gu.elementOverlay,position:"absolute",left:s-c/2-8,top:a-l/2-8,width:c+16,height:l+16,color:d,transform:`rotate(${-m}deg)`,transformOrigin:"center center"},children:G.jsx("div",{style:{width:o?`calc(100% + ${_*2*u}px)`:"100%",height:o?`calc(100% + ${_*2*u}px)`:"100%",marginLeft:o?`${-_*u}px`:0,marginTop:o?`${-_*u}px`:0,border:`1px solid ${d}`,opacity:o||u===0?1:0,transition:"width 0.2s, height 0.2s, margin-left 0.2s, margin-top 0.2s, opacity 0.2s"},children:G.jsx("div",{style:{position:"absolute",bottom:l+20+_*u,marginRight:o?`${-_*u}px`:0,marginBottom:o?0:-_*u,transition:"margin-right 0.2s, margin-bottom 0.2s",backgroundColor:"#f2efcc",color:"black",textShadow:"none",WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale",padding:"6px 6px",borderRadius:"6px",fontSize:"14px",transform:`rotate(${m}deg)`,minWidth:"45px",textAlign:"center"},children:h})})})},Kco=({highlightedPrimitives:t,mousePos:e,elements:n})=>{const[o,r]=O_(a=>[a.is_moving_component,a.is_showing_multiple_traces_length]),i=t.some(a=>a._element.type==="pcb_smtpad")&&t.some(a=>a._element.type==="pcb_trace");let s=t;return i&&(s=s.filter(a=>a._element.type==="pcb_smtpad")),s=Xco({primitives:s,is_showing_multiple_traces_length:r,elements:n}),G.jsx("div",{style:jco,children:!o&&s.map((a,c)=>G.jsx(qco,{primitive:a,mousePos:e,elements:n},c))})},e8=t=>t?.type==="pcb_component",Axt=t=>t?.type==="pcb_group",Jco=t=>t?.type==="pcb_panel",m4e=t=>t?.type==="pcb_board",Ku={MIN_LINE_LENGTH_FOR_LABEL:40,LABEL_OFFSET_ABOVE:2,LABEL_OFFSET_BELOW:-18,LABEL_OFFSET_RIGHT:8,LABEL_OFFSET_LEFT:-120,Y_LABEL_MIN_WIDTH:110,LINE_STROKE_WIDTH:1.5,LINE_DASH_PATTERN:"4,4",COMPONENT_MARKER_RADIUS:3,LABEL_FONT_SIZE:11,ANCHOR_MARKER_SIZE:6,ANCHOR_MARKER_STROKE_WIDTH:1.5},zy={OFFSET_LINE:"white",COMPONENT_MARKER_FILL:"#66ccff",COMPONENT_MARKER_STROKE:"white",LABEL_TEXT:"white"},p4e=({targets:t,transform:e,containerWidth:n,containerHeight:o})=>{if(t.length===0)return null;const r={color:zy.LABEL_TEXT,mixBlendMode:"difference",pointerEvents:"none",fontSize:Ku.LABEL_FONT_SIZE,fontFamily:"monospace",fontWeight:"bold"},i=new Map;return t.forEach(s=>{if(!i.has(s.anchor_id)){const a=pt(e,s.anchor);i.set(s.anchor_id,a)}}),G.jsx("div",{style:{position:"absolute",left:0,top:0,width:n,height:o,overflow:"hidden",pointerEvents:"none",zIndex:gu.dimensionOverlay},children:G.jsxs("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none"},width:n,height:o,children:[t.map(s=>{const a=s.anchor,c=s.anchor_id,l=s.target,u=i.get(c),_=pt(e,l),d=l.x-a.x,m=l.y-a.y,h=Math.abs(_.x-u.x),p=Math.abs(_.y-u.y),x=_.y<u.y,f=_.x>u.x,g=x?Ku.LABEL_OFFSET_ABOVE:Ku.LABEL_OFFSET_BELOW,y=f?Ku.LABEL_OFFSET_RIGHT:Ku.LABEL_OFFSET_LEFT,b=h>Ku.MIN_LINE_LENGTH_FOR_LABEL,v=p>Ku.MIN_LINE_LENGTH_FOR_LABEL,S=`${s.display_offset_x??d.toFixed(2)}mm`,C=`${s.display_offset_y??m.toFixed(2)}mm`;return G.jsxs("g",{children:[G.jsx("line",{x1:u.x,y1:u.y,x2:_.x,y2:u.y,stroke:zy.OFFSET_LINE,strokeWidth:Ku.LINE_STROKE_WIDTH,strokeDasharray:Ku.LINE_DASH_PATTERN}),G.jsx("line",{x1:_.x,y1:u.y,x2:_.x,y2:_.y,stroke:zy.OFFSET_LINE,strokeWidth:Ku.LINE_STROKE_WIDTH,strokeDasharray:Ku.LINE_DASH_PATTERN}),s.type==="component"||s.type==="board"?G.jsx("circle",{cx:_.x,cy:_.y,r:Ku.COMPONENT_MARKER_RADIUS,fill:zy.COMPONENT_MARKER_FILL,stroke:zy.COMPONENT_MARKER_STROKE,strokeWidth:1}):G.jsxs(G.Fragment,{children:[G.jsx("line",{x1:_.x-Ku.ANCHOR_MARKER_SIZE,y1:_.y,x2:_.x+Ku.ANCHOR_MARKER_SIZE,y2:_.y,stroke:zy.OFFSET_LINE,strokeWidth:Ku.ANCHOR_MARKER_STROKE_WIDTH}),G.jsx("line",{x1:_.x,y1:_.y-Ku.ANCHOR_MARKER_SIZE,x2:_.x,y2:_.y+Ku.ANCHOR_MARKER_SIZE,stroke:zy.OFFSET_LINE,strokeWidth:Ku.ANCHOR_MARKER_STROKE_WIDTH})]}),b&&G.jsx("foreignObject",{x:Math.min(u.x,_.x),y:u.y+g,width:Math.abs(_.x-u.x),height:20,style:{overflow:"visible"},children:G.jsx("div",{style:{...r,textAlign:"center"},children:S})}),v&&G.jsx("foreignObject",{x:_.x+y,y:Math.min(u.y,_.y),width:Ku.Y_LABEL_MIN_WIDTH,height:Math.abs(_.y-u.y),style:{overflow:"visible"},children:G.jsx("div",{style:{...r,display:"flex",alignItems:"center",justifyContent:f?"flex-start":"flex-end",whiteSpace:"nowrap",padding:"0 4px",height:"100%"},children:C})})]},s.id)}),Array.from(i.entries()).map(([s,a])=>G.jsxs("g",{children:[G.jsx("line",{x1:a.x-Ku.ANCHOR_MARKER_SIZE,y1:a.y,x2:a.x+Ku.ANCHOR_MARKER_SIZE,y2:a.y,stroke:zy.OFFSET_LINE,strokeWidth:Ku.ANCHOR_MARKER_STROKE_WIDTH}),G.jsx("line",{x1:a.x,y1:a.y-Ku.ANCHOR_MARKER_SIZE,x2:a.x,y2:a.y+Ku.ANCHOR_MARKER_SIZE,stroke:zy.OFFSET_LINE,strokeWidth:Ku.ANCHOR_MARKER_STROKE_WIDTH})]},`anchor-${s}`))]})})},Qco=({elements:t,highlightedPrimitives:e,transform:n,containerWidth:o,containerHeight:r})=>{const i=t.filter(f=>m4e(f)),s=t.filter(f=>e8(f)),a=t.filter(f=>Axt(f)),c=e.map(f=>e8(f._parent_pcb_component)?f._parent_pcb_component.pcb_component_id:e8(f._element)?f._element.pcb_component_id:null).filter(f=>!!f),l=new Set;if(c.forEach(f=>{const g=s.find(y=>y.pcb_component_id===f);g?.pcb_group_id&&l.add(g.pcb_group_id)}),!O_(f=>f.is_showing_group_anchor_offsets)&&c.length===0)return null;const _=s.map(f=>{const g=f.positioned_relative_to_pcb_board_id;if(!g)return null;const y=i.find(b=>b.pcb_board_id===g);return y?{component:f,board:y,type:"component"}:null}).filter(f=>!!f),d=a.map(f=>{const g=f.positioned_relative_to_pcb_board_id;if(!g||!f.center)return null;const y=i.find(b=>b.pcb_board_id===g);return y?{group:f,board:y,type:"group"}:null}).filter(f=>!!f),m=[..._,...d];if(m.length===0)return null;const h=c.length===0,p=m.filter(f=>f.type==="component"?h||c.includes(f.component.pcb_component_id):h||l.has(f.group.pcb_group_id));if(p.length===0)return null;const x=p.map(f=>f.type==="component"?{id:`${f.board.pcb_board_id}-${f.component.pcb_component_id}-${f.type}`,anchor:f.board.center,anchor_id:f.board.pcb_board_id,target:f.component.center,type:"component",display_offset_x:f.component.display_offset_x,display_offset_y:f.component.display_offset_y}:{id:`${f.board.pcb_board_id}-${f.group.pcb_group_id}-${f.type}`,anchor:f.board.center,anchor_id:f.board.pcb_board_id,target:{x:f.group.anchor_position?.x??f.group.center.x,y:f.group.anchor_position?.y??f.group.center.y},type:"group",display_offset_x:f.group.display_offset_x,display_offset_y:f.group.display_offset_y}).filter(f=>!!f);return G.jsx(p4e,{targets:x,transform:n,containerWidth:o,containerHeight:r})},Zco=({elements:t,highlightedPrimitives:e,transform:n,containerWidth:o,containerHeight:r})=>{const i=t.filter(f=>Axt(f)),s=t.filter(f=>e8(f)),a=e.map(f=>e8(f._parent_pcb_component)?f._parent_pcb_component.pcb_component_id:e8(f._element)?f._element.pcb_component_id:null).filter(f=>!!f),c=(f,g)=>{if(g.has(f))return;g.add(f);const y=i.find(b=>b.pcb_group_id===f);y?.position_mode==="relative_to_group_anchor"&&y.positioned_relative_to_pcb_group_id&&c(y.positioned_relative_to_pcb_group_id,g)},l=new Set;if(a.forEach(f=>{const g=s.find(y=>y.pcb_component_id===f);g&&(g.position_mode==="relative_to_group_anchor"&&g.positioned_relative_to_pcb_group_id&&c(g.positioned_relative_to_pcb_group_id,l),g.pcb_group_id&&c(g.pcb_group_id,l))}),!O_(f=>f.is_showing_group_anchor_offsets)&&a.length===0)return null;const _=s.map(f=>{if(f.position_mode==="relative_to_group_anchor"&&f.positioned_relative_to_pcb_group_id){const g=i.find(y=>y.pcb_group_id===f.positioned_relative_to_pcb_group_id);return g&&g.anchor_position?{component:f,parentGroup:g,type:"component"}:null}if(f.pcb_group_id){const g=i.find(y=>y.pcb_group_id===f.pcb_group_id);return g&&g.anchor_position?{component:f,parentGroup:g,type:"component"}:null}return null}).filter(f=>!!f),d=i.map(f=>{if(f.position_mode==="relative_to_group_anchor"&&f.positioned_relative_to_pcb_group_id){const g=i.find(y=>y.pcb_group_id===f.positioned_relative_to_pcb_group_id);if(g&&g.anchor_position&&f.anchor_position)return{group:f,parentGroup:g,type:"group"}}return null}).filter(f=>!!f),m=[..._,...d];if(m.length===0)return null;const h=a.length===0,p=m.filter(f=>f.type==="component"?h||a.includes(f.component.pcb_component_id):h||l.has(f.group.pcb_group_id)||l.has(f.parentGroup.pcb_group_id));if(p.length===0)return null;const x=p.map(f=>{const g=f.parentGroup.anchor_position;return g?f.type==="component"?f.component.center?{id:`${f.parentGroup.pcb_group_id}-${f.component.pcb_component_id}-${f.type}`,anchor:g,anchor_id:f.parentGroup.pcb_group_id,target:f.component.center,type:"component",display_offset_x:f.component.display_offset_x,display_offset_y:f.component.display_offset_y}:null:f.group.anchor_position?{id:`${f.parentGroup.pcb_group_id}-${f.group.pcb_group_id}-${f.type}`,anchor:g,anchor_id:f.parentGroup.pcb_group_id,target:f.group.anchor_position,type:"group",display_offset_x:f.group.display_offset_x,display_offset_y:f.group.display_offset_y}:null:null}).filter(f=>!!f);return G.jsx(p4e,{targets:x,transform:n,containerWidth:o,containerHeight:r})},elo=(t,e)=>{const n=t.pcb_component_id,o=e.filter(r=>(r.type==="pcb_smtpad"||r.type==="pcb_plated_hole")&&r.pcb_component_id===n||r.type==="pcb_hole"&&r.pcb_component_id===n);return o.length===0?u4e([t]):u4e(o)},tlo=({elements:t,highlightedPrimitives:e,transform:n,containerWidth:o,containerHeight:r})=>{const i=new Map;for(const a of e)e8(a._parent_pcb_component)&&i.set(a._parent_pcb_component.pcb_component_id,a._parent_pcb_component),e8(a._element)&&i.set(a._element.pcb_component_id,a._element);if(i.size===0)return null;const s=[];for(const a of i.values()){const c=elo(a,t);if(!c)continue;const l=a.positioned_relative_to_pcb_group_id??a.pcb_group_id,u=l?Z9(t).pcb_group.get(l):null;s.push({component:a,bbox:c,group:u})}return s.length===0?null:G.jsx("div",{style:{position:"absolute",left:0,top:0,width:o,height:r,overflow:"hidden",pointerEvents:"none",zIndex:gu.dimensionOverlay},children:G.jsx("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none"},width:o,height:r,children:s.map(({component:a,bbox:c,group:l})=>{const u=pt(n,{x:c.minX,y:c.maxY}),_=pt(n,{x:c.maxX,y:c.minY}),d={x:Math.min(u.x,_.x),y:Math.min(u.y,_.y),width:Math.abs(_.x-u.x),height:Math.abs(_.y-u.y)},m=a.center??{x:(c.minX+c.maxX)/2,y:(c.minY+c.maxY)/2},h=pt(n,m);return G.jsxs("g",{children:[G.jsx("rect",{x:d.x,y:d.y,width:d.width,height:d.height,fill:"none",stroke:"white",strokeWidth:1.5,strokeDasharray:"4,4"}),G.jsx("line",{x1:h.x-6,y1:h.y,x2:h.x+6,y2:h.y,stroke:zy.COMPONENT_MARKER_STROKE,strokeWidth:1.5}),G.jsx("line",{x1:h.x,y1:h.y-6,x2:h.x,y2:h.y+6,stroke:zy.COMPONENT_MARKER_STROKE,strokeWidth:1.5}),G.jsx("circle",{cx:h.x,cy:h.y,r:Ku.COMPONENT_MARKER_RADIUS,fill:zy.COMPONENT_MARKER_FILL,stroke:zy.COMPONENT_MARKER_STROKE,strokeWidth:1})]},a.pcb_component_id)})})})},nlo=({elements:t,highlightedPrimitives:e,transform:n,containerWidth:o,containerHeight:r})=>{const i=t.filter(m=>Jco(m)),s=t.filter(m=>m4e(m)),a=e.map(m=>m4e(m._element)?m._element.pcb_board_id:null).filter(m=>!!m);if(!O_(m=>m.is_showing_group_anchor_offsets)&&a.length===0)return null;const l=s.map(m=>{const h=m.pcb_panel_id,p=m.position_mode;if(!h||p!=="relative_to_panel_anchor")return null;const x=i.find(f=>f.pcb_panel_id===h);return x?{board:m,panel:x,type:"board"}:null}).filter(m=>!!m);if(l.length===0)return null;const u=a.length===0,_=l.filter(m=>u||a.includes(m.board.pcb_board_id));if(_.length===0)return null;const d=_.map(m=>m.board.center?{id:`${m.panel.pcb_panel_id}-${m.board.pcb_board_id}-${m.type}`,anchor:m.panel.center,anchor_id:m.panel.pcb_panel_id,target:m.board.center,type:"board",display_offset_x:m.board.display_offset_x,display_offset_y:m.board.display_offset_y}:null).filter(m=>!!m);return G.jsx(p4e,{targets:d,transform:n,containerWidth:o,containerHeight:r})},gJ=t=>{if(t.length===0)return null;let e=t[0].x,n=t[0].y,o=t[0].x,r=t[0].y;for(const i of t)i.x<e&&(e=i.x),i.y<n&&(n=i.y),i.x>o&&(o=i.x),i.y>r&&(r=i.y);return{center:{x:(e+o)/2,y:(n+r)/2},width:o-e,height:r-n}},kxt=(t,e)=>{if(e.length<3)return!1;let n=!1;for(let o=0,r=e.length-1;o<e.length;r=o++){const i=e[o].x,s=e[o].y,a=e[r].x,c=e[r].y;s>t.y!=c>t.y&&t.x<(a-i)*(t.y-s)/(c-s||Number.EPSILON)+i&&(n=!n)}return n},olo=(t,e,n)=>{const o=[];for(const r of t){if(!r._element)continue;if("x1"in r&&r._element?.type==="pcb_trace"){const a=wf({x:e.x,y:e.y},{x:r.x1,y:r.y1},{x:r.x2,y:r.y2}),c=r.width||.5,l=Math.max(c*25,2)/n.a;a<l&&o.push(r);continue}if(r.pcb_drawing_type==="polygon"){const a=r.points.map(l=>({x:Ze.parse(l.x),y:Ze.parse(l.y)})),c=gJ(a);if(!c||e.x<c.center.x-c.width/2||e.x>c.center.x+c.width/2||e.y<c.center.y-c.height/2||e.y>c.center.y+c.height/2)continue;kxt(e,a)&&o.push(r);continue}if(r.pcb_drawing_type==="polygon_with_arcs"){const a=r.brep_shape.outer_ring.vertices.map(l=>({x:Ze.parse(l.x),y:Ze.parse(l.y)})),c=gJ(a);if(!c||e.x<c.center.x-c.width/2||e.x>c.center.x+c.width/2||e.y<c.center.y-c.height/2||e.y>c.center.y+c.height/2)continue;kxt(e,a)&&o.push(r);continue}if(!("x"in r&&"y"in r))continue;let i=0,s=0;if("w"in r&&"h"in r)i=r.w,s=r.h;else if("r"in r)i=r.r*2,s=r.r*2;else if("rX"in r&&"rY"in r)i=r.rX*2,s=r.rY*2;else continue;Math.abs(r.x-e.x)<i/2&&Math.abs(r.y-e.y)<s/2&&o.push(r)}return o},rlo=({elements:t,children:e,transform:n,primitives:o,onMouseHoverOverPrimitives:r})=>{const[i,s]=te.useState([]),[a,c]=te.useState({x:0,y:0}),[l,{width:u,height:_}]=NO(),d=te.useMemo(()=>{const h=[];for(const p of i){if(p._element?.type==="pcb_via"||p._element?.type==="pcb_component"||p?.layer==="drill"||p?.is_hoverable===!1)continue;let x=null,f=0,g=0;if(p.pcb_drawing_type==="polygon"){const S=gJ(p.points);if(!S)continue;x=S.center,f=S.width,g=S.height}else if(p.pcb_drawing_type==="polygon_with_arcs"){const S=p.brep_shape.outer_ring.vertices.map(w=>({x:w.x,y:w.y})),C=gJ(S);if(!C)continue;x=C.center,f=C.width,g=C.height}else"x"in p&&"y"in p&&(x={x:p.x,y:p.y},f="w"in p?p.w:"r"in p?p.r*2:"rX"in p&&"rY"in p?p.rX*2:0,g="h"in p?p.h:"r"in p?p.r*2:"rX"in p&&"rY"in p?p.rY*2:0);if(!x)continue;const y=pt(n,x),b={w:f*n.a,h:g*n.a},v=h.filter(S=>y.x===S.screen_x&&y.y===S.screen_y&&b.w===S.screen_w&&b.h===S.screen_h).length;h.push({...p,x:x.x,y:x.y,w:f,h:g,screen_x:y.x,screen_y:y.y,screen_w:b.w,screen_h:b.h,same_space_index:v})}return h},[i,n]),m=(h,p,x,f)=>{c({x:h,y:p});const g=pt(L5(x),{x:h,y:p}),y=olo(f,g,x);Wco(new Set(y.map(b=>b._pcb_drawing_object_id)),new Set(i.map(b=>b._pcb_drawing_object_id)))||(s(y),r(y))};return G.jsxs("div",{ref:l,style:{position:"relative",width:"100%",height:"100%"},onMouseMove:h=>{if(n){const p=h.currentTarget.getBoundingClientRect(),x=h.clientX-p.left,f=h.clientY-p.top;m(x,f,n,o)}},onTouchStart:h=>{if(n){const p=h.touches[0],x=h.currentTarget.getBoundingClientRect(),f=p.clientX-x.left,g=p.clientY-x.top;m(f,g,n,o)}},children:[e,G.jsx(Kco,{elements:t,mousePos:a,highlightedPrimitives:d}),n&&G.jsxs(G.Fragment,{children:[G.jsx(Qco,{elements:t,highlightedPrimitives:d,transform:n,containerWidth:u,containerHeight:_}),G.jsx(Zco,{elements:t,highlightedPrimitives:d,transform:n,containerWidth:u,containerHeight:_}),G.jsx(tlo,{elements:t,highlightedPrimitives:d,transform:n,containerWidth:u,containerHeight:_}),G.jsx(nlo,{elements:t,highlightedPrimitives:d,transform:n,containerWidth:u,containerHeight:_})]})]})},Rxt=["rgb(255, 100, 100)","rgb(100, 255, 100)","rgb(100, 100, 255)","rgb(255, 255, 100)","rgb(255, 100, 255)","rgb(100, 255, 255)","rgb(255, 150, 100)","rgb(150, 100, 255)","rgb(100, 255, 150)","rgb(255, 100, 150)"],ilo=({children:t,transform:e=Cl(),elements:n=[],hoveredComponentIds:o=[]})=>{const[r,{width:i,height:s}]=NO(),a=te.useRef(null),{is_showing_pcb_groups:c,pcb_group_view_mode:l,is_showing_group_anchor_offsets:u}=O_(_=>({is_showing_pcb_groups:_.is_showing_pcb_groups,pcb_group_view_mode:_.pcb_group_view_mode,is_showing_group_anchor_offsets:_.is_showing_group_anchor_offsets}));return te.useEffect(()=>{const _=a.current;if(!_||!i||!s)return;_.width=i,_.height=s;const d=_.getContext("2d");if(!d||(d.clearRect(0,0,i,s),!c))return;const m=n.filter(S=>S.type==="pcb_group"),h=n.filter(S=>S.type==="pcb_component"),p=n.filter(S=>S.type==="source_group"),x=new Map(p.map(S=>[S.source_group_id,S])),f=m.filter(S=>{if(S.name?.toLowerCase().includes("subpanel"))return!1;if(l==="all")return!0;if(!S.source_group_id)return!1;const C=x.get(S.source_group_id);return C?C.was_automatically_named!==!0:!1}),g=new Map;p.forEach(S=>{const C=S;if(C.parent_source_group_id){const w=g.get(C.parent_source_group_id)||[];w.push(S.source_group_id),g.set(C.parent_source_group_id,w)}});const y=S=>{const C=[],w=g.get(S)||[];for(const D of w)C.push(D),C.push(...y(D));return C},b=S=>{const C=p.find(w=>w.source_group_id===S);return C?.parent_source_group_id?1+b(C.parent_source_group_id):0},v=new Set;if(o.length>0)for(const S of h){if(!o.includes(S.pcb_component_id))continue;const C=S.positioned_relative_to_pcb_group_id??S.pcb_group_id;C&&v.add(C)}f.forEach((S,C)=>{let w=h.filter(Oe=>Oe.pcb_group_id===S.pcb_group_id);if(S.source_group_id){const Oe=y(S.source_group_id),$e=m.filter(He=>He.source_group_id&&Oe.includes(He.source_group_id));for(const He of $e){const Te=h.filter(Ae=>Ae.pcb_group_id===He.pcb_group_id);w=[...w,...Te]}}let D,A,L,H,F=!1;if(S.center&&S.width&&S.height){F=!0;const Oe=S.width/2,$e=S.height/2;D=S.center.x-Oe,L=S.center.x+Oe,A=S.center.y-$e,H=S.center.y+$e}else if(w.length===0||(D=1/0,A=1/0,L=-1/0,H=-1/0,w.forEach(Oe=>{if(Oe.center&&typeof Oe.width=="number"&&typeof Oe.height=="number"){const $e=Oe.center.x-Oe.width/2,He=Oe.center.x+Oe.width/2,Te=Oe.center.y+Oe.height/2,Ae=Oe.center.y-Oe.height/2;D=Math.min(D,$e),L=Math.max(L,He),A=Math.min(A,Ae),H=Math.max(H,Te)}}),D===1/0||L===-1/0))return;const z=S.source_group_id?b(S.source_group_id):0,V=S.source_group_id?y(S.source_group_id).length>0:!1;if(!F){const He=1+(V?.5:0);D-=He,L+=He,A-=He,H+=He}const j=pt(e,{x:D,y:H}),q=pt(e,{x:L,y:H}),J=pt(e,{x:D,y:A}),oe=pt(e,{x:L,y:A}),ue=Rxt[C%Rxt.length];d.strokeStyle=ue,d.lineWidth=2;const ne=Math.max(4,Math.min(12,8*Math.abs(e.a))),se=Math.max(2,Math.min(6,4*Math.abs(e.a))),ce=ne*(V?1.3:1),fe=se;d.setLineDash([ce,fe]),d.beginPath(),d.moveTo(j.x,j.y),d.lineTo(q.x,q.y),d.lineTo(oe.x,oe.y),d.lineTo(J.x,J.y),d.closePath(),d.stroke();const Se=Math.max(8,Math.min(12,10*Math.abs(e.a))),we=z==0||z==1?0:z*.11,Ee=Se*(1-we),pe=4,Ce=S.name||`Group ${C+1}`;d.font=`${Ee}px sans-serif`,d.setLineDash([]);const Be=d.measureText(Ce).width+pe*2,Ye=Ee+pe*2,nt=j.x-5,ge=j.y-5,Ke=3;if(d.fillStyle="rgba(0, 0, 0, 0.8)",d.beginPath(),d.roundRect(nt,ge-Ye,Be,Ye,Ke),d.fill(),d.fillStyle=ue,d.textAlign="left",d.textBaseline="middle",d.fillText(Ce,nt+pe,ge-Ye/2),u&&v.has(S.pcb_group_id)&&!!S.anchor_position&&S.anchor_position){const Oe=Array.isArray(S.anchor_position)?{x:S.anchor_position[0]??0,y:S.anchor_position[1]??0}:{x:S.anchor_position.x,y:S.anchor_position.y},$e=pt(e,Oe);d.strokeStyle="white",d.lineWidth=1.5,d.setLineDash([]);const He=Math.max(4,Math.min(8,6*Math.abs(e.a)));d.beginPath(),d.moveTo($e.x-He,$e.y),d.lineTo($e.x+He,$e.y),d.stroke(),d.beginPath(),d.moveTo($e.x,$e.y-He),d.lineTo($e.x,$e.y+He),d.stroke()}})},[n,e,i,s,c,l,u,o]),G.jsxs("div",{ref:r,style:{position:"relative",width:"100%",height:"100%"},children:[t,G.jsx("canvas",{ref:a,style:{position:"absolute",top:0,left:0,pointerEvents:"none",zIndex:gu.pcbGroupOverlay,display:c?"block":"none"}})]})},slo=({transform:t,soup:e,children:n})=>{const o=O_(a=>a.is_showing_rats_nest),{netMap:r,idToNetMap:i}=te.useMemo(()=>nxt(e||[]),[e]),s=te.useMemo(()=>{if(!e||!o)return[];const a=d=>{const m=Z9(e)[d.replace(/_\d+$/,"")].get(d);return m&&"x"in m&&"y"in m?{x:m.x,y:m.y}:null},c=(d,m)=>{const h=r[m]||[];let p=null,x=1/0;return h.forEach(f=>{const g=a(f);if(g){const y=Math.sqrt((d.x-g.x)**2+(d.y-g.y)**2);y<x&&y>0&&(x=y,p=g)}}),p},l=Z9(e).pcb_port.list(),u=Z9(e).source_trace.list(),_=[];return l.forEach((d,m)=>{const h=i[d.pcb_port_id];let p=!1;for(const g of u)g.connected_source_port_ids.includes(d.source_port_id)&&g.connected_source_net_ids.length>0&&(p=!0);if(!h)return;const x={x:d.x,y:d.y},f=c(x,h);f&&_.push({key:`${d.pcb_port_id}-${m}`,startPoint:x,endPoint:f,isInNet:p})}),_},[e,r,i,o]);return!e||!o?n:(t||(t=Cl()),G.jsxs("div",{style:{position:"relative"},children:[n,G.jsx("svg",{style:{position:"absolute",left:0,top:0,width:"100%",height:"100%",pointerEvents:"none",opacity:.5,zIndex:gu.ratsNestOverlay},children:s.map(({key:a,startPoint:c,endPoint:l,isInNet:u})=>{const _=pt(t,c),d=pt(t,l);return G.jsx("line",{x1:_.x,y1:_.y,x2:d.x,y2:d.y,stroke:"white",strokeWidth:"1",strokeDasharray:u?"6,6":void 0},a)})})]}))},alo={version:"1.11.367"},t8=(t,e,n)=>{const o=O_(s=>s.is_mouse_over_container),r=te.useRef(o),i=te.useRef(e);te.useEffect(()=>{r.current=o},[o]),te.useEffect(()=>{i.current=e},[e]),te.useEffect(()=>{if(!t)return;const s=a=>{const c=a.target;if(c.tagName==="INPUT"||c.tagName==="TEXTAREA"||c.isContentEditable)return;const l=t.split("+"),u=l.includes("ctrl"),_=l.includes("shift"),d=l.includes("alt"),m=l.includes("meta"),h=l[l.length-1],p=n?.current?n.current.contains(document.activeElement)||document.activeElement===n.current:!1;(r.current||p)&&(!u||a.ctrlKey)&&(!_||a.shiftKey)&&(!d||a.altKey)&&(!m||a.metaKey)&&a.key.toLowerCase()===h.toLowerCase()&&(a.preventDefault(),i.current())};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s)}},[t])},clo=()=>{const[t,e]=te.useState(!1);return te.useEffect(()=>{const n=()=>{e(window.innerWidth<=768)};return n(),window.addEventListener("resize",n),()=>window.removeEventListener("resize",n)},[]),t},HO=(t,e={stopPropagation:!0})=>{const n=te.useRef(0),o=te.useCallback(s=>{e.stopPropagation&&s.stopPropagation();const a=Date.now();a-n.current<300||(n.current=a,t?.(s))},[t,e.stopPropagation]),r=te.useCallback(s=>{s.preventDefault(),o(s)},[o]);return{onClick:o,onTouchEnd:r,style:{touchAction:"manipulation"}}},TM=({children:t,isSmallScreen:e,onClick:n,...o})=>{const{style:r,...i}=HO(n);return G.jsx("div",{...o,...i,style:{backgroundColor:"#1F1F1F",border:"1px solid #666",margin:0,padding:4,paddingLeft:e?8:6,paddingRight:e?8:6,borderRadius:2,color:"#eee",cursor:"pointer",fontSize:12,height:"fit-content",userSelect:"none",whiteSpace:"nowrap",...r,...o.style},children:t})},llo=t=>{const e=new Map;return t.forEach((n,o)=>{const r=n.error_type||"unknown_error",i=e.get(r)||[];i.push({error:n,index:o,errorId:qA(n,o)}),e.set(r,i)}),Array.from(e.entries()).map(([n,o])=>({errorType:n,errors:o}))},ulo=({onClose:t,setHoveredErrorId:e,setFocusedErrorId:n,highlightDurationMs:o=3e3})=>{const r=te.useRef(null),i=te.useRef(null),s=te.useRef(null),a=te.useCallback(()=>{r.current!==null&&(window.clearTimeout(r.current),r.current=null),i.current!==null&&(window.cancelAnimationFrame(i.current),i.current=null)},[]);te.useEffect(()=>a,[a]);const c=te.useCallback(u=>{a(),s.current=u,e(u),n(null),i.current=window.requestAnimationFrame(()=>{n(u),i.current=null}),t(),r.current=window.setTimeout(()=>{s.current=null,e(null),n(null),r.current=null},o)},[a,o,t,n,e]),l=te.useCallback(u=>s.current===u,[]);return{handleErrorSelect:c,isSelectedError:l}},_lo=({errorId:t,errorMessage:e,copiedErrorId:n,onCopy:o})=>{const{style:r,...i}=HO(()=>o(e,t));return G.jsx("button",{type:"button","aria-label":n===t?"Error message copied":"Copy error message",style:{position:"absolute",top:12,right:16,cursor:"pointer",color:"#888",fontSize:16,background:"none",border:"none",padding:0,display:"flex",alignItems:"center",...r},...i,children:n===t?G.jsx("span",{style:{color:"#4caf50",fontSize:12},children:"Copied!"}):G.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:G.jsx("path",{d:"M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"})})})},dlo=({elements:t,isOpen:e,isSmallScreen:n,onToggle:o,onClose:r,setHoveredErrorId:i,setFocusedErrorId:s})=>{const[a,c]=te.useState(null),[l,u]=te.useState(new Set),[_,d]=te.useState(new Set),[,m]=Kso(),{handleErrorSelect:h,isSelectedError:p}=ulo({onClose:r,setHoveredErrorId:i,setFocusedErrorId:s}),x=te.useMemo(()=>t?.filter(v=>v.type.includes("error"))??[],[t]),f=x.length,g=te.useMemo(()=>llo(x),[x]),y=te.useCallback(v=>{u(S=>{const C=new Set(S);return C.has(v)?C.delete(v):C.add(v),C})},[]),b=te.useCallback(v=>{d(S=>{const C=new Set(S);return C.has(v)?C.delete(v):C.add(v),C})},[]);return G.jsxs("div",{style:{position:"relative"},children:[G.jsx(TM,{isSmallScreen:n,style:f>0?{color:"red"}:void 0,onClick:o,children:G.jsxs("div",{children:[f," errors"]})}),e&&f>0&&G.jsx("div",{style:{position:"absolute",top:"100%",left:0,backgroundColor:"#2a2a2a",border:"1px solid #666",borderRadius:4,marginTop:4,zIndex:1e3,minWidth:n?"280px":"400px",maxWidth:n?"90vw":"600px",maxHeight:"400px",overflow:"auto",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.3)"},children:g.map(({errorType:v,errors:S},C)=>{const w=l.has(v);return G.jsxs("div",{style:{borderBottom:C<g.length-1?"1px solid #444":"none"},children:[G.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 16px",cursor:"pointer",backgroundColor:"#232323",transition:"background-color 0.2s ease",touchAction:"manipulation",position:"sticky",top:0,zIndex:1},onMouseEnter:D=>{D.currentTarget.style.backgroundColor="#303030"},onMouseLeave:D=>{D.currentTarget.style.backgroundColor="#232323"},onTouchStart:D=>{D.stopPropagation(),D.currentTarget.style.backgroundColor="#303030"},onTouchEnd:D=>{D.stopPropagation(),D.preventDefault(),D.currentTarget.style.backgroundColor="#232323",y(v)},onClick:D=>{D.stopPropagation(),y(v)},children:[G.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,color:"#ff6b6b"},children:[G.jsx("div",{style:{color:"#888",fontSize:"16px",transform:w?"rotate(90deg)":"rotate(0deg)",transition:"transform 0.2s ease",flexShrink:0},children:"›"}),G.jsx("div",{style:{fontWeight:"bold",fontSize:n?"12px":"13px"},children:v})]}),G.jsx("div",{style:{fontSize:n?"12px":"13px",color:"#aaa",whiteSpace:"nowrap",marginLeft:12},children:S.length})]}),!w&&S.map(({error:D,index:A,errorId:L})=>{const H=_.has(L),F=D.message??"No error message";return G.jsxs("div",{style:{borderTop:"1px solid #3a3a3a"},children:[G.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"12px 16px 12px 24px",cursor:"pointer",backgroundColor:"#2a2a2a",transition:"background-color 0.2s ease",touchAction:"manipulation"},onMouseEnter:z=>{z.currentTarget.style.backgroundColor="#333",i(L)},onMouseLeave:z=>{z.currentTarget.style.backgroundColor="#2a2a2a",p(L)||i(null)},onTouchStart:z=>{z.stopPropagation(),z.currentTarget.style.backgroundColor="#333",i(L)},onTouchEnd:z=>{z.stopPropagation(),z.preventDefault(),z.currentTarget.style.backgroundColor="#2a2a2a",h(L)},onClick:z=>{z.stopPropagation(),h(L)},children:[G.jsx("div",{style:{flex:1,fontSize:n?"12px":"13px",color:"#ddd",lineHeight:1.4,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",userSelect:"text"},children:F}),G.jsx("button",{type:"button","aria-label":H?"Collapse error details":"Expand error details",style:{color:"#888",fontSize:"16px",transform:H?"rotate(0deg)":"rotate(90deg)",transition:"transform 0.2s ease",flexShrink:0,background:"none",border:"none",padding:0,cursor:"pointer"},onMouseDown:z=>z.stopPropagation(),onClick:z=>{z.stopPropagation(),b(L)},onTouchEnd:z=>{z.stopPropagation(),z.preventDefault(),b(L)},children:"›"})]}),H&&G.jsxs("div",{"data-error-id":A,style:{display:"block",padding:"12px 16px 12px 24px",backgroundColor:"#1a1a1a",borderTop:"1px solid #444",position:"relative"},children:[G.jsx("div",{style:{fontSize:n?"11px":"12px",color:"#ccc",lineHeight:1.5,wordWrap:"break-word",overflowWrap:"break-word",hyphens:"auto",userSelect:"text",paddingRight:30},onMouseDown:z=>z.stopPropagation(),onClick:z=>z.stopPropagation(),children:F}),G.jsx(_lo,{errorId:L,errorMessage:F,copiedErrorId:a,onCopy:(z,V)=>{m(z),c(V),setTimeout(()=>c(null),2e3)}})]})]},L)})]},v)})})]})},hlo=({name:t,selected:e,onClick:n})=>{const{style:o,...r}=HO(n);return G.jsxs("div",{className:YA`
|
|
5516
|
+
`,$co=({children:t,transform:e=Cl(),elements:n})=>{const o=te.useRef(null),{isShowingDRCErrors:r,hoveredErrorId:i,focusedErrorId:s}=O_(p=>({isShowingDRCErrors:p.is_showing_drc_errors,hoveredErrorId:p.hovered_error_id,focusedErrorId:p.focused_error_id})),a=s??i;if(!n)return G.jsx("div",{style:{position:"relative"},ref:o,children:t});const c=n.filter(p=>p.type==="pcb_trace_error"&&!p.message?.includes("Multiple components found with name")),l=n.filter(p=>p.type==="pcb_via_clearance_error"),u=n.filter(p=>p.type==="pcb_trace_error"&&p.message?.includes("Multiple components found with name")),_=rxt(n),d=oxt(n,a),m=p=>{const x=lao({error:p,indexes:_});if(!x||typeof x.x!="number"||typeof x.y!="number")return null;const f=pt(e,x);return Number.isNaN(f.x)||Number.isNaN(f.y)?null:f};let h=null;return d&&(h=m(d)),G.jsxs("div",{style:{position:"relative"},ref:o,children:[t,c.map((p,x)=>{const f=qA(p,x),g=a===f;if(!g&&!r)return null;const y=m(p);if(!y)return null;const b=d4e(y,o);return G.jsxs(te.Fragment,{children:[G.jsx(Dxt,{errorCenter:y,isHighlighted:g}),G.jsx("div",{style:{position:"absolute",left:y.x-15,top:y.y-15,width:30,height:30,zIndex:gu.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:v=>{const S=v.currentTarget.nextElementSibling;if(S){const C=S.querySelector(".error-message");C&&(C.style.opacity="1")}},onMouseLeave:v=>{if(!g){const S=v.currentTarget.nextElementSibling;if(S){const C=S.querySelector(".error-message");C&&(C.style.opacity="0")}}}}),G.jsx("div",{style:{position:"absolute",zIndex:g?200:100,left:b.left,top:b.top,color:g?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:r||g?"flex":"none",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:b.transform},children:G.jsx("div",{className:`error-message ${h4e}`,style:{opacity:g?1:0,border:`1px solid ${g?"#ff4444":"red"}`},children:p.message})})]},f)}),l.map((p,x)=>{const f=qA(p,x),g=a===f;if(!g&&!r)return null;const y=m(p);if(!y)return null;const b=d4e({x:y.x,y:y.y},o);return G.jsxs(te.Fragment,{children:[G.jsx(Dxt,{errorCenter:y,isHighlighted:g}),G.jsx("div",{style:{position:"absolute",left:y.x-15,top:y.y-15,width:30,height:30,zIndex:gu.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:v=>{const S=v.currentTarget.nextElementSibling;if(S){const C=S.querySelector(".error-message");C&&(C.style.opacity="1")}},onMouseLeave:v=>{if(!g){const S=v.currentTarget.nextElementSibling;if(S){const C=S.querySelector(".error-message");C&&(C.style.opacity="0")}}}}),G.jsx("div",{style:{position:"absolute",zIndex:g?gu.errorOverlay+10:gu.errorOverlay+1,left:b.left,top:b.top,color:g?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:"flex",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:b.transform},children:G.jsx("div",{className:`error-message ${h4e}`,style:{opacity:g?1:0,border:`1px solid ${g?"#ff4444":"red"}`},children:p.message})})]},f)}),u.map((p,x)=>{const f=p.component_name||p.message?.match(/name "([^"]+)"/)?.[1];if(!f)return null;const g=n?.filter(v=>v.type==="source_component"&&v.name===f||v.type==="pcb_component"&&n?.find(S=>S.type==="source_component"&&S.source_component_id===v.source_component_id&&S.name===f))||[],y=qA(p,x),b=a===y;return!b&&!r?null:g.map((v,S)=>{let C={x:0,y:0};if(v.type==="pcb_component")C=v.center||{x:0,y:0};else if(v.type==="source_component"){const V=n?.find(j=>j.type==="pcb_component"&&j.source_component_id===v.source_component_id);V&&V.type==="pcb_component"&&(C=V.center||{x:0,y:0})}const w=pt(e,C);if(Number.isNaN(w.x)||Number.isNaN(w.y))return null;const D=Math.abs(e.a),F=Math.max(8,Math.min(30,.5*D)),z=d4e(w,o);return G.jsxs(te.Fragment,{children:[G.jsx("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none",mixBlendMode:"difference",zIndex:gu.errorOverlay},width:"100%",height:"100%",children:b?G.jsx("polygon",{points:`${w.x},${w.y-F*1.25} ${w.x+F},${w.y} ${w.x},${w.y+F*1.25} ${w.x-F},${w.y}`,fill:"#ff4444"}):G.jsx("circle",{cx:w.x,cy:w.y,r:F,fill:"none",stroke:b?"#ff4444":"red",strokeWidth:b?Math.max(2,F*.15):Math.max(1,F*.1),opacity:1})}),G.jsx("div",{style:{position:"absolute",left:w.x-(F+10),top:w.y-(F+10),width:(F+10)*2,height:(F+10)*2,zIndex:gu.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:V=>{const j=V.currentTarget.nextElementSibling;if(j){const q=j.querySelector(".error-message");q&&(q.style.opacity="1")}},onMouseLeave:V=>{if(!b){const j=V.currentTarget.nextElementSibling;if(j){const q=j.querySelector(".error-message");q&&(q.style.opacity="0")}}}}),G.jsx("div",{style:{position:"absolute",zIndex:b?gu.errorOverlay+20:gu.errorOverlay+10,left:z.left,top:z.top,color:b?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:r||b?"flex":"none",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:z.transform},children:G.jsx("div",{className:`error-message ${h4e}`,style:{opacity:b?1:0,border:`1px solid ${b?"#ff4444":"red"}`},children:p.message})})]},`${y}_${S}`)})}),h&&G.jsx(Vco,{center:h})]})};function Wco(t,e){return t.size!==e.size?!1:Array.from(t).every(n=>e.has(n))}function Uco({primitiveElement:t,elements:e}){let n=t.trace_length?`${t.trace_length.toFixed(3)}`:"";const o=Z9(e).source_trace.get(t?.source_trace_id);if(o?.display_name&&(o?.max_length?n+=` / ${o.max_length}mm `:n+=" mm ",n+=`(${o.display_name})`),!n)return null;const r=t.trace_length&&o?.max_length&&t.trace_length>o.max_length;return{text:n,isOverLength:r}}function Xco(t){const{primitives:e,is_showing_multiple_traces_length:n,elements:o}=t,r=e.filter(c=>c._element.type==="pcb_trace"),i=o.filter(c=>c.type==="source_trace"),s=e.filter(c=>c._element.type!=="pcb_trace"),a=r.filter(c=>i.some(l=>c._element.type==="pcb_trace"&&c._element.source_trace_id===l.source_trace_id&&l.max_length!==void 0));if(!n)return[...s,...a];if(r.length>1){const c=r.reduce((l,u)=>{const _=l._element.trace_length;return u._element.trace_length<_?u:l},r[0]);return[...s,c]}return e}var jco={position:"absolute",left:0,top:0,pointerEvents:"none",color:"red",fontFamily:"sans-serif",fontSize:12,textShadow:"0 0 2px black"},Gco=t=>{const{_element:e,_parent_pcb_component:n,_parent_source_component:o,_source_port:r}=t;switch(e.type){case"pcb_trace":return e.trace_length?`${e.trace_length.toFixed(3)}`:"";case"pcb_smtpad":case"pcb_plated_hole":{const i=[],s=Array.from(new Set((e.port_hints??[]).concat(r?.port_hints??[]))).filter(c=>!/^[0-9]+$/.test(c)).filter(c=>!c.includes("unnamed_")).sort((c,l)=>l.localeCompare(c)),a=o&&"name"in o&&o.name&&!o.name.includes("unnamed_")?o.name:null;return s.length>0?a?i.push(...s.map(c=>`${a}.${c}`)):i.push(...s):a&&i.push(a),i.join(", ")}default:return""}},Yco={top:"red",bottom:"aqua"},qco=({primitive:t,mousePos:e,elements:n})=>{const[o,r]=te.useState(!1),i=t._element;te.useEffect(()=>{setTimeout(()=>{r(!0)},100)},[]);const[s,a,c,l]=[t.screen_x,t.screen_y,t.screen_w,t.screen_h],u=t.same_space_index??0,_=26,d=Yco[t?._element?.layer]??"red";let m=0;if(i.type==="pcb_smtpad"&&i?.shape==="rotated_rect"?m=i?.ccw_rotation??0:(i.type==="pcb_smtpad"&&(i?.shape==="pill"||i?.shape==="rotated_pill")&&"ccw_rotation"in t||i.type==="pcb_plated_hole"&&(i?.shape==="pill"||i?.shape==="oval")&&"ccw_rotation"in t)&&(m=i.ccw_rotation??0),i.type==="pcb_trace"){const x=Uco({primitiveElement:i,elements:n});if(!x)return null;const f=e.y-35;return G.jsx("div",{style:{zIndex:gu.elementOverlay,position:"absolute",left:e.x,top:f,color:d,pointerEvents:"none",transform:"translateX(-50%)"},children:G.jsx("div",{style:{backgroundColor:"#f2efcc",color:x.isOverLength?"red":"black",textShadow:"none",WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale",padding:"6px 6px",borderRadius:"6px",fontSize:"14px",minWidth:"45px",textAlign:"center",whiteSpace:"nowrap"},children:x.text})})}const h=Gco(t);return h.trim().length===0?null:G.jsx("div",{style:{zIndex:gu.elementOverlay,position:"absolute",left:s-c/2-8,top:a-l/2-8,width:c+16,height:l+16,color:d,transform:`rotate(${-m}deg)`,transformOrigin:"center center"},children:G.jsx("div",{style:{width:o?`calc(100% + ${_*2*u}px)`:"100%",height:o?`calc(100% + ${_*2*u}px)`:"100%",marginLeft:o?`${-_*u}px`:0,marginTop:o?`${-_*u}px`:0,border:`1px solid ${d}`,opacity:o||u===0?1:0,transition:"width 0.2s, height 0.2s, margin-left 0.2s, margin-top 0.2s, opacity 0.2s"},children:G.jsx("div",{style:{position:"absolute",bottom:l+20+_*u,marginRight:o?`${-_*u}px`:0,marginBottom:o?0:-_*u,transition:"margin-right 0.2s, margin-bottom 0.2s",backgroundColor:"#f2efcc",color:"black",textShadow:"none",WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale",padding:"6px 6px",borderRadius:"6px",fontSize:"14px",transform:`rotate(${m}deg)`,minWidth:"45px",textAlign:"center"},children:h})})})},Kco=({highlightedPrimitives:t,mousePos:e,elements:n})=>{const[o,r]=O_(a=>[a.is_moving_component,a.is_showing_multiple_traces_length]),i=t.some(a=>a._element.type==="pcb_smtpad")&&t.some(a=>a._element.type==="pcb_trace");let s=t;return i&&(s=s.filter(a=>a._element.type==="pcb_smtpad")),s=Xco({primitives:s,is_showing_multiple_traces_length:r,elements:n}),G.jsx("div",{style:jco,children:!o&&s.map((a,c)=>G.jsx(qco,{primitive:a,mousePos:e,elements:n},c))})},e8=t=>t?.type==="pcb_component",Axt=t=>t?.type==="pcb_group",Jco=t=>t?.type==="pcb_panel",m4e=t=>t?.type==="pcb_board",Ku={MIN_LINE_LENGTH_FOR_LABEL:40,LABEL_OFFSET_ABOVE:2,LABEL_OFFSET_BELOW:-18,LABEL_OFFSET_RIGHT:8,LABEL_OFFSET_LEFT:-120,Y_LABEL_MIN_WIDTH:110,LINE_STROKE_WIDTH:1.5,LINE_DASH_PATTERN:"4,4",COMPONENT_MARKER_RADIUS:3,LABEL_FONT_SIZE:11,ANCHOR_MARKER_SIZE:6,ANCHOR_MARKER_STROKE_WIDTH:1.5},zy={OFFSET_LINE:"white",COMPONENT_MARKER_FILL:"#66ccff",COMPONENT_MARKER_STROKE:"white",LABEL_TEXT:"white"},p4e=({targets:t,transform:e,containerWidth:n,containerHeight:o})=>{if(t.length===0)return null;const r={color:zy.LABEL_TEXT,mixBlendMode:"difference",pointerEvents:"none",fontSize:Ku.LABEL_FONT_SIZE,fontFamily:"monospace",fontWeight:"bold"},i=new Map;return t.forEach(s=>{if(!i.has(s.anchor_id)){const a=pt(e,s.anchor);i.set(s.anchor_id,a)}}),G.jsx("div",{style:{position:"absolute",left:0,top:0,width:n,height:o,overflow:"hidden",pointerEvents:"none",zIndex:gu.dimensionOverlay},children:G.jsxs("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none"},width:n,height:o,children:[t.map(s=>{const a=s.anchor,c=s.anchor_id,l=s.target,u=i.get(c),_=pt(e,l),d=l.x-a.x,m=l.y-a.y,h=Math.abs(_.x-u.x),p=Math.abs(_.y-u.y),x=_.y<u.y,f=_.x>u.x,g=x?Ku.LABEL_OFFSET_ABOVE:Ku.LABEL_OFFSET_BELOW,y=f?Ku.LABEL_OFFSET_RIGHT:Ku.LABEL_OFFSET_LEFT,b=h>Ku.MIN_LINE_LENGTH_FOR_LABEL,v=p>Ku.MIN_LINE_LENGTH_FOR_LABEL,S=`${s.display_offset_x??d.toFixed(2)}mm`,C=`${s.display_offset_y??m.toFixed(2)}mm`;return G.jsxs("g",{children:[G.jsx("line",{x1:u.x,y1:u.y,x2:_.x,y2:u.y,stroke:zy.OFFSET_LINE,strokeWidth:Ku.LINE_STROKE_WIDTH,strokeDasharray:Ku.LINE_DASH_PATTERN}),G.jsx("line",{x1:_.x,y1:u.y,x2:_.x,y2:_.y,stroke:zy.OFFSET_LINE,strokeWidth:Ku.LINE_STROKE_WIDTH,strokeDasharray:Ku.LINE_DASH_PATTERN}),s.type==="component"||s.type==="board"?G.jsx("circle",{cx:_.x,cy:_.y,r:Ku.COMPONENT_MARKER_RADIUS,fill:zy.COMPONENT_MARKER_FILL,stroke:zy.COMPONENT_MARKER_STROKE,strokeWidth:1}):G.jsxs(G.Fragment,{children:[G.jsx("line",{x1:_.x-Ku.ANCHOR_MARKER_SIZE,y1:_.y,x2:_.x+Ku.ANCHOR_MARKER_SIZE,y2:_.y,stroke:zy.OFFSET_LINE,strokeWidth:Ku.ANCHOR_MARKER_STROKE_WIDTH}),G.jsx("line",{x1:_.x,y1:_.y-Ku.ANCHOR_MARKER_SIZE,x2:_.x,y2:_.y+Ku.ANCHOR_MARKER_SIZE,stroke:zy.OFFSET_LINE,strokeWidth:Ku.ANCHOR_MARKER_STROKE_WIDTH})]}),b&&G.jsx("foreignObject",{x:Math.min(u.x,_.x),y:u.y+g,width:Math.abs(_.x-u.x),height:20,style:{overflow:"visible"},children:G.jsx("div",{style:{...r,textAlign:"center"},children:S})}),v&&G.jsx("foreignObject",{x:_.x+y,y:Math.min(u.y,_.y),width:Ku.Y_LABEL_MIN_WIDTH,height:Math.abs(_.y-u.y),style:{overflow:"visible"},children:G.jsx("div",{style:{...r,display:"flex",alignItems:"center",justifyContent:f?"flex-start":"flex-end",whiteSpace:"nowrap",padding:"0 4px",height:"100%"},children:C})})]},s.id)}),Array.from(i.entries()).map(([s,a])=>G.jsxs("g",{children:[G.jsx("line",{x1:a.x-Ku.ANCHOR_MARKER_SIZE,y1:a.y,x2:a.x+Ku.ANCHOR_MARKER_SIZE,y2:a.y,stroke:zy.OFFSET_LINE,strokeWidth:Ku.ANCHOR_MARKER_STROKE_WIDTH}),G.jsx("line",{x1:a.x,y1:a.y-Ku.ANCHOR_MARKER_SIZE,x2:a.x,y2:a.y+Ku.ANCHOR_MARKER_SIZE,stroke:zy.OFFSET_LINE,strokeWidth:Ku.ANCHOR_MARKER_STROKE_WIDTH})]},`anchor-${s}`))]})})},Qco=({elements:t,highlightedPrimitives:e,transform:n,containerWidth:o,containerHeight:r})=>{const i=t.filter(f=>m4e(f)),s=t.filter(f=>e8(f)),a=t.filter(f=>Axt(f)),c=e.map(f=>e8(f._parent_pcb_component)?f._parent_pcb_component.pcb_component_id:e8(f._element)?f._element.pcb_component_id:null).filter(f=>!!f),l=new Set;if(c.forEach(f=>{const g=s.find(y=>y.pcb_component_id===f);g?.pcb_group_id&&l.add(g.pcb_group_id)}),!O_(f=>f.is_showing_group_anchor_offsets)&&c.length===0)return null;const _=s.map(f=>{const g=f.positioned_relative_to_pcb_board_id;if(!g)return null;const y=i.find(b=>b.pcb_board_id===g);return y?{component:f,board:y,type:"component"}:null}).filter(f=>!!f),d=a.map(f=>{const g=f.positioned_relative_to_pcb_board_id;if(!g||!f.center)return null;const y=i.find(b=>b.pcb_board_id===g);return y?{group:f,board:y,type:"group"}:null}).filter(f=>!!f),m=[..._,...d];if(m.length===0)return null;const h=c.length===0,p=m.filter(f=>f.type==="component"?h||c.includes(f.component.pcb_component_id):h||l.has(f.group.pcb_group_id));if(p.length===0)return null;const x=p.map(f=>f.type==="component"?{id:`${f.board.pcb_board_id}-${f.component.pcb_component_id}-${f.type}`,anchor:f.board.center,anchor_id:f.board.pcb_board_id,target:f.component.center,type:"component",display_offset_x:f.component.display_offset_x,display_offset_y:f.component.display_offset_y}:{id:`${f.board.pcb_board_id}-${f.group.pcb_group_id}-${f.type}`,anchor:f.board.center,anchor_id:f.board.pcb_board_id,target:{x:f.group.anchor_position?.x??f.group.center.x,y:f.group.anchor_position?.y??f.group.center.y},type:"group",display_offset_x:f.group.display_offset_x,display_offset_y:f.group.display_offset_y}).filter(f=>!!f);return G.jsx(p4e,{targets:x,transform:n,containerWidth:o,containerHeight:r})},Zco=({elements:t,highlightedPrimitives:e,transform:n,containerWidth:o,containerHeight:r})=>{const i=t.filter(f=>Axt(f)),s=t.filter(f=>e8(f)),a=e.map(f=>e8(f._parent_pcb_component)?f._parent_pcb_component.pcb_component_id:e8(f._element)?f._element.pcb_component_id:null).filter(f=>!!f),c=(f,g)=>{if(g.has(f))return;g.add(f);const y=i.find(b=>b.pcb_group_id===f);y?.position_mode==="relative_to_group_anchor"&&y.positioned_relative_to_pcb_group_id&&c(y.positioned_relative_to_pcb_group_id,g)},l=new Set;if(a.forEach(f=>{const g=s.find(y=>y.pcb_component_id===f);g&&(g.position_mode==="relative_to_group_anchor"&&g.positioned_relative_to_pcb_group_id&&c(g.positioned_relative_to_pcb_group_id,l),g.pcb_group_id&&c(g.pcb_group_id,l))}),!O_(f=>f.is_showing_group_anchor_offsets)&&a.length===0)return null;const _=s.map(f=>{if(f.position_mode==="relative_to_group_anchor"&&f.positioned_relative_to_pcb_group_id){const g=i.find(y=>y.pcb_group_id===f.positioned_relative_to_pcb_group_id);return g&&g.anchor_position?{component:f,parentGroup:g,type:"component"}:null}if(f.pcb_group_id){const g=i.find(y=>y.pcb_group_id===f.pcb_group_id);return g&&g.anchor_position?{component:f,parentGroup:g,type:"component"}:null}return null}).filter(f=>!!f),d=i.map(f=>{if(f.position_mode==="relative_to_group_anchor"&&f.positioned_relative_to_pcb_group_id){const g=i.find(y=>y.pcb_group_id===f.positioned_relative_to_pcb_group_id);if(g&&g.anchor_position&&f.anchor_position)return{group:f,parentGroup:g,type:"group"}}return null}).filter(f=>!!f),m=[..._,...d];if(m.length===0)return null;const h=a.length===0,p=m.filter(f=>f.type==="component"?h||a.includes(f.component.pcb_component_id):h||l.has(f.group.pcb_group_id)||l.has(f.parentGroup.pcb_group_id));if(p.length===0)return null;const x=p.map(f=>{const g=f.parentGroup.anchor_position;return g?f.type==="component"?f.component.center?{id:`${f.parentGroup.pcb_group_id}-${f.component.pcb_component_id}-${f.type}`,anchor:g,anchor_id:f.parentGroup.pcb_group_id,target:f.component.center,type:"component",display_offset_x:f.component.display_offset_x,display_offset_y:f.component.display_offset_y}:null:f.group.anchor_position?{id:`${f.parentGroup.pcb_group_id}-${f.group.pcb_group_id}-${f.type}`,anchor:g,anchor_id:f.parentGroup.pcb_group_id,target:f.group.anchor_position,type:"group",display_offset_x:f.group.display_offset_x,display_offset_y:f.group.display_offset_y}:null:null}).filter(f=>!!f);return G.jsx(p4e,{targets:x,transform:n,containerWidth:o,containerHeight:r})},elo=(t,e)=>{const n=t.pcb_component_id,o=e.filter(r=>(r.type==="pcb_smtpad"||r.type==="pcb_plated_hole")&&r.pcb_component_id===n||r.type==="pcb_hole"&&r.pcb_component_id===n);return o.length===0?u4e([t]):u4e(o)},tlo=({elements:t,highlightedPrimitives:e,transform:n,containerWidth:o,containerHeight:r})=>{const i=new Map;for(const a of e)e8(a._parent_pcb_component)&&i.set(a._parent_pcb_component.pcb_component_id,a._parent_pcb_component),e8(a._element)&&i.set(a._element.pcb_component_id,a._element);if(i.size===0)return null;const s=[];for(const a of i.values()){const c=elo(a,t);if(!c)continue;const l=a.positioned_relative_to_pcb_group_id??a.pcb_group_id,u=l?Z9(t).pcb_group.get(l):null;s.push({component:a,bbox:c,group:u})}return s.length===0?null:G.jsx("div",{style:{position:"absolute",left:0,top:0,width:o,height:r,overflow:"hidden",pointerEvents:"none",zIndex:gu.dimensionOverlay},children:G.jsx("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none"},width:o,height:r,children:s.map(({component:a,bbox:c,group:l})=>{const u=pt(n,{x:c.minX,y:c.maxY}),_=pt(n,{x:c.maxX,y:c.minY}),d={x:Math.min(u.x,_.x),y:Math.min(u.y,_.y),width:Math.abs(_.x-u.x),height:Math.abs(_.y-u.y)},m=a.center??{x:(c.minX+c.maxX)/2,y:(c.minY+c.maxY)/2},h=pt(n,m);return G.jsxs("g",{children:[G.jsx("rect",{x:d.x,y:d.y,width:d.width,height:d.height,fill:"none",stroke:"white",strokeWidth:1.5,strokeDasharray:"4,4"}),G.jsx("line",{x1:h.x-6,y1:h.y,x2:h.x+6,y2:h.y,stroke:zy.COMPONENT_MARKER_STROKE,strokeWidth:1.5}),G.jsx("line",{x1:h.x,y1:h.y-6,x2:h.x,y2:h.y+6,stroke:zy.COMPONENT_MARKER_STROKE,strokeWidth:1.5}),G.jsx("circle",{cx:h.x,cy:h.y,r:Ku.COMPONENT_MARKER_RADIUS,fill:zy.COMPONENT_MARKER_FILL,stroke:zy.COMPONENT_MARKER_STROKE,strokeWidth:1})]},a.pcb_component_id)})})})},nlo=({elements:t,highlightedPrimitives:e,transform:n,containerWidth:o,containerHeight:r})=>{const i=t.filter(m=>Jco(m)),s=t.filter(m=>m4e(m)),a=e.map(m=>m4e(m._element)?m._element.pcb_board_id:null).filter(m=>!!m);if(!O_(m=>m.is_showing_group_anchor_offsets)&&a.length===0)return null;const l=s.map(m=>{const h=m.pcb_panel_id,p=m.position_mode;if(!h||p!=="relative_to_panel_anchor")return null;const x=i.find(f=>f.pcb_panel_id===h);return x?{board:m,panel:x,type:"board"}:null}).filter(m=>!!m);if(l.length===0)return null;const u=a.length===0,_=l.filter(m=>u||a.includes(m.board.pcb_board_id));if(_.length===0)return null;const d=_.map(m=>m.board.center?{id:`${m.panel.pcb_panel_id}-${m.board.pcb_board_id}-${m.type}`,anchor:m.panel.center,anchor_id:m.panel.pcb_panel_id,target:m.board.center,type:"board",display_offset_x:m.board.display_offset_x,display_offset_y:m.board.display_offset_y}:null).filter(m=>!!m);return G.jsx(p4e,{targets:d,transform:n,containerWidth:o,containerHeight:r})},gJ=t=>{if(t.length===0)return null;let e=t[0].x,n=t[0].y,o=t[0].x,r=t[0].y;for(const i of t)i.x<e&&(e=i.x),i.y<n&&(n=i.y),i.x>o&&(o=i.x),i.y>r&&(r=i.y);return{center:{x:(e+o)/2,y:(n+r)/2},width:o-e,height:r-n}},kxt=(t,e)=>{if(e.length<3)return!1;let n=!1;for(let o=0,r=e.length-1;o<e.length;r=o++){const i=e[o].x,s=e[o].y,a=e[r].x,c=e[r].y;s>t.y!=c>t.y&&t.x<(a-i)*(t.y-s)/(c-s||Number.EPSILON)+i&&(n=!n)}return n},olo=(t,e,n)=>{const o=[];for(const r of t){if(!r._element)continue;if("x1"in r&&r._element?.type==="pcb_trace"){const a=wf({x:e.x,y:e.y},{x:r.x1,y:r.y1},{x:r.x2,y:r.y2}),c=r.width||.5,l=Math.max(c*25,2)/n.a;a<l&&o.push(r);continue}if(r.pcb_drawing_type==="polygon"){const a=r.points.map(l=>({x:Ze.parse(l.x),y:Ze.parse(l.y)})),c=gJ(a);if(!c||e.x<c.center.x-c.width/2||e.x>c.center.x+c.width/2||e.y<c.center.y-c.height/2||e.y>c.center.y+c.height/2)continue;kxt(e,a)&&o.push(r);continue}if(r.pcb_drawing_type==="polygon_with_arcs"){const a=r.brep_shape.outer_ring.vertices.map(l=>({x:Ze.parse(l.x),y:Ze.parse(l.y)})),c=gJ(a);if(!c||e.x<c.center.x-c.width/2||e.x>c.center.x+c.width/2||e.y<c.center.y-c.height/2||e.y>c.center.y+c.height/2)continue;kxt(e,a)&&o.push(r);continue}if(!("x"in r&&"y"in r))continue;let i=0,s=0;if("w"in r&&"h"in r)i=r.w,s=r.h;else if("r"in r)i=r.r*2,s=r.r*2;else if("rX"in r&&"rY"in r)i=r.rX*2,s=r.rY*2;else continue;Math.abs(r.x-e.x)<i/2&&Math.abs(r.y-e.y)<s/2&&o.push(r)}return o},rlo=({elements:t,children:e,transform:n,primitives:o,onMouseHoverOverPrimitives:r})=>{const[i,s]=te.useState([]),[a,c]=te.useState({x:0,y:0}),[l,{width:u,height:_}]=NO(),d=te.useMemo(()=>{const h=[];for(const p of i){if(p._element?.type==="pcb_via"||p._element?.type==="pcb_component"||p?.layer==="drill"||p?.is_hoverable===!1)continue;let x=null,f=0,g=0;if(p.pcb_drawing_type==="polygon"){const S=gJ(p.points);if(!S)continue;x=S.center,f=S.width,g=S.height}else if(p.pcb_drawing_type==="polygon_with_arcs"){const S=p.brep_shape.outer_ring.vertices.map(w=>({x:w.x,y:w.y})),C=gJ(S);if(!C)continue;x=C.center,f=C.width,g=C.height}else"x"in p&&"y"in p&&(x={x:p.x,y:p.y},f="w"in p?p.w:"r"in p?p.r*2:"rX"in p&&"rY"in p?p.rX*2:0,g="h"in p?p.h:"r"in p?p.r*2:"rX"in p&&"rY"in p?p.rY*2:0);if(!x)continue;const y=pt(n,x),b={w:f*n.a,h:g*n.a},v=h.filter(S=>y.x===S.screen_x&&y.y===S.screen_y&&b.w===S.screen_w&&b.h===S.screen_h).length;h.push({...p,x:x.x,y:x.y,w:f,h:g,screen_x:y.x,screen_y:y.y,screen_w:b.w,screen_h:b.h,same_space_index:v})}return h},[i,n]),m=(h,p,x,f)=>{c({x:h,y:p});const g=pt(L5(x),{x:h,y:p}),y=olo(f,g,x);Wco(new Set(y.map(b=>b._pcb_drawing_object_id)),new Set(i.map(b=>b._pcb_drawing_object_id)))||(s(y),r(y))};return G.jsxs("div",{ref:l,style:{position:"relative",width:"100%",height:"100%"},onMouseMove:h=>{if(n){const p=h.currentTarget.getBoundingClientRect(),x=h.clientX-p.left,f=h.clientY-p.top;m(x,f,n,o)}},onTouchStart:h=>{if(n){const p=h.touches[0],x=h.currentTarget.getBoundingClientRect(),f=p.clientX-x.left,g=p.clientY-x.top;m(f,g,n,o)}},children:[e,G.jsx(Kco,{elements:t,mousePos:a,highlightedPrimitives:d}),n&&G.jsxs(G.Fragment,{children:[G.jsx(Qco,{elements:t,highlightedPrimitives:d,transform:n,containerWidth:u,containerHeight:_}),G.jsx(Zco,{elements:t,highlightedPrimitives:d,transform:n,containerWidth:u,containerHeight:_}),G.jsx(tlo,{elements:t,highlightedPrimitives:d,transform:n,containerWidth:u,containerHeight:_}),G.jsx(nlo,{elements:t,highlightedPrimitives:d,transform:n,containerWidth:u,containerHeight:_})]})]})},Rxt=["rgb(255, 100, 100)","rgb(100, 255, 100)","rgb(100, 100, 255)","rgb(255, 255, 100)","rgb(255, 100, 255)","rgb(100, 255, 255)","rgb(255, 150, 100)","rgb(150, 100, 255)","rgb(100, 255, 150)","rgb(255, 100, 150)"],ilo=({children:t,transform:e=Cl(),elements:n=[],hoveredComponentIds:o=[]})=>{const[r,{width:i,height:s}]=NO(),a=te.useRef(null),{is_showing_pcb_groups:c,pcb_group_view_mode:l,is_showing_group_anchor_offsets:u}=O_(_=>({is_showing_pcb_groups:_.is_showing_pcb_groups,pcb_group_view_mode:_.pcb_group_view_mode,is_showing_group_anchor_offsets:_.is_showing_group_anchor_offsets}));return te.useEffect(()=>{const _=a.current;if(!_||!i||!s)return;_.width=i,_.height=s;const d=_.getContext("2d");if(!d||(d.clearRect(0,0,i,s),!c))return;const m=n.filter(S=>S.type==="pcb_group"),h=n.filter(S=>S.type==="pcb_component"),p=n.filter(S=>S.type==="source_group"),x=new Map(p.map(S=>[S.source_group_id,S])),f=m.filter(S=>{if(S.name?.toLowerCase().includes("subpanel"))return!1;if(l==="all")return!0;if(!S.source_group_id)return!1;const C=x.get(S.source_group_id);return C?C.was_automatically_named!==!0:!1}),g=new Map;p.forEach(S=>{const C=S;if(C.parent_source_group_id){const w=g.get(C.parent_source_group_id)||[];w.push(S.source_group_id),g.set(C.parent_source_group_id,w)}});const y=S=>{const C=[],w=g.get(S)||[];for(const D of w)C.push(D),C.push(...y(D));return C},b=S=>{const C=p.find(w=>w.source_group_id===S);return C?.parent_source_group_id?1+b(C.parent_source_group_id):0},v=new Set;if(o.length>0)for(const S of h){if(!o.includes(S.pcb_component_id))continue;const C=S.positioned_relative_to_pcb_group_id??S.pcb_group_id;C&&v.add(C)}f.forEach((S,C)=>{let w=h.filter(Oe=>Oe.pcb_group_id===S.pcb_group_id);if(S.source_group_id){const Oe=y(S.source_group_id),$e=m.filter(He=>He.source_group_id&&Oe.includes(He.source_group_id));for(const He of $e){const Te=h.filter(Ae=>Ae.pcb_group_id===He.pcb_group_id);w=[...w,...Te]}}let D,A,L,H,F=!1;if(S.center&&S.width&&S.height){F=!0;const Oe=S.width/2,$e=S.height/2;D=S.center.x-Oe,L=S.center.x+Oe,A=S.center.y-$e,H=S.center.y+$e}else if(w.length===0||(D=1/0,A=1/0,L=-1/0,H=-1/0,w.forEach(Oe=>{if(Oe.center&&typeof Oe.width=="number"&&typeof Oe.height=="number"){const $e=Oe.center.x-Oe.width/2,He=Oe.center.x+Oe.width/2,Te=Oe.center.y+Oe.height/2,Ae=Oe.center.y-Oe.height/2;D=Math.min(D,$e),L=Math.max(L,He),A=Math.min(A,Ae),H=Math.max(H,Te)}}),D===1/0||L===-1/0))return;const z=S.source_group_id?b(S.source_group_id):0,V=S.source_group_id?y(S.source_group_id).length>0:!1;if(!F){const He=1+(V?.5:0);D-=He,L+=He,A-=He,H+=He}const j=pt(e,{x:D,y:H}),q=pt(e,{x:L,y:H}),J=pt(e,{x:D,y:A}),oe=pt(e,{x:L,y:A}),ue=Rxt[C%Rxt.length];d.strokeStyle=ue,d.lineWidth=2;const ne=Math.max(4,Math.min(12,8*Math.abs(e.a))),se=Math.max(2,Math.min(6,4*Math.abs(e.a))),ce=ne*(V?1.3:1),fe=se;d.setLineDash([ce,fe]),d.beginPath(),d.moveTo(j.x,j.y),d.lineTo(q.x,q.y),d.lineTo(oe.x,oe.y),d.lineTo(J.x,J.y),d.closePath(),d.stroke();const Se=Math.max(8,Math.min(12,10*Math.abs(e.a))),we=z==0||z==1?0:z*.11,Ee=Se*(1-we),pe=4,Ce=S.name||`Group ${C+1}`;d.font=`${Ee}px sans-serif`,d.setLineDash([]);const Be=d.measureText(Ce).width+pe*2,Ye=Ee+pe*2,nt=j.x-5,ge=j.y-5,Ke=3;if(d.fillStyle="rgba(0, 0, 0, 0.8)",d.beginPath(),d.roundRect(nt,ge-Ye,Be,Ye,Ke),d.fill(),d.fillStyle=ue,d.textAlign="left",d.textBaseline="middle",d.fillText(Ce,nt+pe,ge-Ye/2),u&&v.has(S.pcb_group_id)&&!!S.anchor_position&&S.anchor_position){const Oe=Array.isArray(S.anchor_position)?{x:S.anchor_position[0]??0,y:S.anchor_position[1]??0}:{x:S.anchor_position.x,y:S.anchor_position.y},$e=pt(e,Oe);d.strokeStyle="white",d.lineWidth=1.5,d.setLineDash([]);const He=Math.max(4,Math.min(8,6*Math.abs(e.a)));d.beginPath(),d.moveTo($e.x-He,$e.y),d.lineTo($e.x+He,$e.y),d.stroke(),d.beginPath(),d.moveTo($e.x,$e.y-He),d.lineTo($e.x,$e.y+He),d.stroke()}})},[n,e,i,s,c,l,u,o]),G.jsxs("div",{ref:r,style:{position:"relative",width:"100%",height:"100%"},children:[t,G.jsx("canvas",{ref:a,style:{position:"absolute",top:0,left:0,pointerEvents:"none",zIndex:gu.pcbGroupOverlay,display:c?"block":"none"}})]})},slo=({transform:t,soup:e,children:n})=>{const o=O_(a=>a.is_showing_rats_nest),{netMap:r,idToNetMap:i}=te.useMemo(()=>nxt(e||[]),[e]),s=te.useMemo(()=>{if(!e||!o)return[];const a=d=>{const m=Z9(e)[d.replace(/_\d+$/,"")].get(d);return m&&"x"in m&&"y"in m?{x:m.x,y:m.y}:null},c=(d,m)=>{const h=r[m]||[];let p=null,x=1/0;return h.forEach(f=>{const g=a(f);if(g){const y=Math.sqrt((d.x-g.x)**2+(d.y-g.y)**2);y<x&&y>0&&(x=y,p=g)}}),p},l=Z9(e).pcb_port.list(),u=Z9(e).source_trace.list(),_=[];return l.forEach((d,m)=>{const h=i[d.pcb_port_id];let p=!1;for(const g of u)g.connected_source_port_ids.includes(d.source_port_id)&&g.connected_source_net_ids.length>0&&(p=!0);if(!h)return;const x={x:d.x,y:d.y},f=c(x,h);f&&_.push({key:`${d.pcb_port_id}-${m}`,startPoint:x,endPoint:f,isInNet:p})}),_},[e,r,i,o]);return!e||!o?n:(t||(t=Cl()),G.jsxs("div",{style:{position:"relative"},children:[n,G.jsx("svg",{style:{position:"absolute",left:0,top:0,width:"100%",height:"100%",pointerEvents:"none",opacity:.5,zIndex:gu.ratsNestOverlay},children:s.map(({key:a,startPoint:c,endPoint:l,isInNet:u})=>{const _=pt(t,c),d=pt(t,l);return G.jsx("line",{x1:_.x,y1:_.y,x2:d.x,y2:d.y,stroke:"white",strokeWidth:"1",strokeDasharray:u?"6,6":void 0},a)})})]}))},alo={version:"1.11.368"},t8=(t,e,n)=>{const o=O_(s=>s.is_mouse_over_container),r=te.useRef(o),i=te.useRef(e);te.useEffect(()=>{r.current=o},[o]),te.useEffect(()=>{i.current=e},[e]),te.useEffect(()=>{if(!t)return;const s=a=>{const c=a.target;if(c.tagName==="INPUT"||c.tagName==="TEXTAREA"||c.isContentEditable)return;const l=t.split("+"),u=l.includes("ctrl"),_=l.includes("shift"),d=l.includes("alt"),m=l.includes("meta"),h=l[l.length-1],p=n?.current?n.current.contains(document.activeElement)||document.activeElement===n.current:!1;(r.current||p)&&(!u||a.ctrlKey)&&(!_||a.shiftKey)&&(!d||a.altKey)&&(!m||a.metaKey)&&a.key.toLowerCase()===h.toLowerCase()&&(a.preventDefault(),i.current())};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s)}},[t])},clo=()=>{const[t,e]=te.useState(!1);return te.useEffect(()=>{const n=()=>{e(window.innerWidth<=768)};return n(),window.addEventListener("resize",n),()=>window.removeEventListener("resize",n)},[]),t},HO=(t,e={stopPropagation:!0})=>{const n=te.useRef(0),o=te.useCallback(s=>{e.stopPropagation&&s.stopPropagation();const a=Date.now();a-n.current<300||(n.current=a,t?.(s))},[t,e.stopPropagation]),r=te.useCallback(s=>{s.preventDefault(),o(s)},[o]);return{onClick:o,onTouchEnd:r,style:{touchAction:"manipulation"}}},TM=({children:t,isSmallScreen:e,onClick:n,...o})=>{const{style:r,...i}=HO(n);return G.jsx("div",{...o,...i,style:{backgroundColor:"#1F1F1F",border:"1px solid #666",margin:0,padding:4,paddingLeft:e?8:6,paddingRight:e?8:6,borderRadius:2,color:"#eee",cursor:"pointer",fontSize:12,height:"fit-content",userSelect:"none",whiteSpace:"nowrap",...r,...o.style},children:t})},llo=t=>{const e=new Map;return t.forEach((n,o)=>{const r=n.error_type||"unknown_error",i=e.get(r)||[];i.push({error:n,index:o,errorId:qA(n,o)}),e.set(r,i)}),Array.from(e.entries()).map(([n,o])=>({errorType:n,errors:o}))},ulo=({onClose:t,setHoveredErrorId:e,setFocusedErrorId:n,highlightDurationMs:o=3e3})=>{const r=te.useRef(null),i=te.useRef(null),s=te.useRef(null),a=te.useCallback(()=>{r.current!==null&&(window.clearTimeout(r.current),r.current=null),i.current!==null&&(window.cancelAnimationFrame(i.current),i.current=null)},[]);te.useEffect(()=>a,[a]);const c=te.useCallback(u=>{a(),s.current=u,e(u),n(null),i.current=window.requestAnimationFrame(()=>{n(u),i.current=null}),t(),r.current=window.setTimeout(()=>{s.current=null,e(null),n(null),r.current=null},o)},[a,o,t,n,e]),l=te.useCallback(u=>s.current===u,[]);return{handleErrorSelect:c,isSelectedError:l}},_lo=({errorId:t,errorMessage:e,copiedErrorId:n,onCopy:o})=>{const{style:r,...i}=HO(()=>o(e,t));return G.jsx("button",{type:"button","aria-label":n===t?"Error message copied":"Copy error message",style:{position:"absolute",top:12,right:16,cursor:"pointer",color:"#888",fontSize:16,background:"none",border:"none",padding:0,display:"flex",alignItems:"center",...r},...i,children:n===t?G.jsx("span",{style:{color:"#4caf50",fontSize:12},children:"Copied!"}):G.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:G.jsx("path",{d:"M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"})})})},dlo=({elements:t,isOpen:e,isSmallScreen:n,onToggle:o,onClose:r,setHoveredErrorId:i,setFocusedErrorId:s})=>{const[a,c]=te.useState(null),[l,u]=te.useState(new Set),[_,d]=te.useState(new Set),[,m]=Kso(),{handleErrorSelect:h,isSelectedError:p}=ulo({onClose:r,setHoveredErrorId:i,setFocusedErrorId:s}),x=te.useMemo(()=>t?.filter(v=>v.type.includes("error"))??[],[t]),f=x.length,g=te.useMemo(()=>llo(x),[x]),y=te.useCallback(v=>{u(S=>{const C=new Set(S);return C.has(v)?C.delete(v):C.add(v),C})},[]),b=te.useCallback(v=>{d(S=>{const C=new Set(S);return C.has(v)?C.delete(v):C.add(v),C})},[]);return G.jsxs("div",{style:{position:"relative"},children:[G.jsx(TM,{isSmallScreen:n,style:f>0?{color:"red"}:void 0,onClick:o,children:G.jsxs("div",{children:[f," errors"]})}),e&&f>0&&G.jsx("div",{style:{position:"absolute",top:"100%",left:0,backgroundColor:"#2a2a2a",border:"1px solid #666",borderRadius:4,marginTop:4,zIndex:1e3,minWidth:n?"280px":"400px",maxWidth:n?"90vw":"600px",maxHeight:"400px",overflow:"auto",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.3)"},children:g.map(({errorType:v,errors:S},C)=>{const w=l.has(v);return G.jsxs("div",{style:{borderBottom:C<g.length-1?"1px solid #444":"none"},children:[G.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 16px",cursor:"pointer",backgroundColor:"#232323",transition:"background-color 0.2s ease",touchAction:"manipulation",position:"sticky",top:0,zIndex:1},onMouseEnter:D=>{D.currentTarget.style.backgroundColor="#303030"},onMouseLeave:D=>{D.currentTarget.style.backgroundColor="#232323"},onTouchStart:D=>{D.stopPropagation(),D.currentTarget.style.backgroundColor="#303030"},onTouchEnd:D=>{D.stopPropagation(),D.preventDefault(),D.currentTarget.style.backgroundColor="#232323",y(v)},onClick:D=>{D.stopPropagation(),y(v)},children:[G.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,color:"#ff6b6b"},children:[G.jsx("div",{style:{color:"#888",fontSize:"16px",transform:w?"rotate(90deg)":"rotate(0deg)",transition:"transform 0.2s ease",flexShrink:0},children:"›"}),G.jsx("div",{style:{fontWeight:"bold",fontSize:n?"12px":"13px"},children:v})]}),G.jsx("div",{style:{fontSize:n?"12px":"13px",color:"#aaa",whiteSpace:"nowrap",marginLeft:12},children:S.length})]}),!w&&S.map(({error:D,index:A,errorId:L})=>{const H=_.has(L),F=D.message??"No error message";return G.jsxs("div",{style:{borderTop:"1px solid #3a3a3a"},children:[G.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"12px 16px 12px 24px",cursor:"pointer",backgroundColor:"#2a2a2a",transition:"background-color 0.2s ease",touchAction:"manipulation"},onMouseEnter:z=>{z.currentTarget.style.backgroundColor="#333",i(L)},onMouseLeave:z=>{z.currentTarget.style.backgroundColor="#2a2a2a",p(L)||i(null)},onTouchStart:z=>{z.stopPropagation(),z.currentTarget.style.backgroundColor="#333",i(L)},onTouchEnd:z=>{z.stopPropagation(),z.preventDefault(),z.currentTarget.style.backgroundColor="#2a2a2a",h(L)},onClick:z=>{z.stopPropagation(),h(L)},children:[G.jsx("div",{style:{flex:1,fontSize:n?"12px":"13px",color:"#ddd",lineHeight:1.4,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",userSelect:"text"},children:F}),G.jsx("button",{type:"button","aria-label":H?"Collapse error details":"Expand error details",style:{color:"#888",fontSize:"16px",transform:H?"rotate(0deg)":"rotate(90deg)",transition:"transform 0.2s ease",flexShrink:0,background:"none",border:"none",padding:0,cursor:"pointer"},onMouseDown:z=>z.stopPropagation(),onClick:z=>{z.stopPropagation(),b(L)},onTouchEnd:z=>{z.stopPropagation(),z.preventDefault(),b(L)},children:"›"})]}),H&&G.jsxs("div",{"data-error-id":A,style:{display:"block",padding:"12px 16px 12px 24px",backgroundColor:"#1a1a1a",borderTop:"1px solid #444",position:"relative"},children:[G.jsx("div",{style:{fontSize:n?"11px":"12px",color:"#ccc",lineHeight:1.5,wordWrap:"break-word",overflowWrap:"break-word",hyphens:"auto",userSelect:"text",paddingRight:30},onMouseDown:z=>z.stopPropagation(),onClick:z=>z.stopPropagation(),children:F}),G.jsx(_lo,{errorId:L,errorMessage:F,copiedErrorId:a,onCopy:(z,V)=>{m(z),c(V),setTimeout(()=>c(null),2e3)}})]})]},L)})]},v)})})]})},hlo=({name:t,selected:e,onClick:n})=>{const{style:o,...r}=HO(n);return G.jsxs("div",{className:YA`
|
|
5517
5517
|
margin-top: 2px;
|
|
5518
5518
|
padding: 4px;
|
|
5519
5519
|
padding-left: 8px;
|
|
@@ -5730,7 +5730,7 @@ test("${l} should solve problem correctly", () => {
|
|
|
5730
5730
|
// Add more specific assertions based on expected output
|
|
5731
5731
|
// expect(solver.netLabelPlacementSolver!.netLabelPlacements).toMatchInlineSnapshot()
|
|
5732
5732
|
})
|
|
5733
|
-
`,_=new Blob([u],{type:"text/plain"}),d=URL.createObjectURL(_),m=document.createElement("a");m.href=d,m.download=`${l}.test.ts`,m.click(),URL.revokeObjectURL(d)}catch(c){alert(`Error generating test.ts for ${t.constructor.name}: ${c instanceof Error?c.message:String(c)}`)}o(!1)};return G.jsxs("div",{className:`relative ${e}`,ref:r,children:[G.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>o(!n),title:`Download options for ${t.constructor.name}`,children:t.constructor.name}),n&&G.jsxs("div",{className:"absolute top-full left-0 mt-1 bg-white border border-gray-300 rounded shadow-lg z-10 min-w-[150px]",children:[G.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:i,children:"Download JSON"}),G.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),G.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:a,children:"Download test.ts"})]})]})},Uxt=t=>t.activeSubSolver?[t,...Uxt(t.activeSubSolver)]:[t],juo=({solver:t})=>{const e=Uxt(t);return G.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:e.map((n,o)=>G.jsxs("div",{className:"flex items-center",children:[o>0&&G.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),G.jsx(Xuo,{solver:n})]},n.constructor.name))})},Guo=({solver:t,triggerRender:e,animationSpeed:n=25,onSolverStarted:o,onSolverCompleted:r})=>{const[i,s]=te.useReducer(p=>!p,!1),a=te.useRef(void 0),c=()=>{!t.solved&&!t.failed&&(t.step(),e())},l=()=>{!t.solved&&!t.failed&&(o&&o(t),t.solve(),e(),r&&r(t))},u=()=>{i?(a.current&&(clearInterval(a.current),a.current=void 0),s()):(s(),a.current=setInterval(()=>{if(t.solved||t.failed){a.current&&(clearInterval(a.current),a.current=void 0),s(),e(),r&&t.solved&&r(t);return}t.step(),e()},n))},_=()=>{const p=t;if(p.getCurrentPhase&&!t.solved&&!t.failed){const x=p.getCurrentPhase();for(;p.getCurrentPhase()===x&&!t.solved&&!t.failed;)t.step();e()}},d=()=>{if(t.solved||t.failed||i)return;const p=window.prompt("Step until which iteration?",`${t.iterations}`);if(p===null)return;const x=Number(p);if(!Number.isFinite(x)){window.alert("Please enter a valid number for the iteration");return}for(;t.iterations<x&&!t.solved&&!t.failed;)t.step();e(),t.solved&&r&&r(t)};te.useEffect(()=>()=>{a.current&&clearInterval(a.current)},[]),te.useEffect(()=>{(t.solved||t.failed)&&i&&(a.current&&(clearInterval(a.current),a.current=void 0),s())},[t.solved,t.failed,i]);const m=t.getCurrentPhase!==void 0,h=m?t.getCurrentPhase():null;return G.jsxs("div",{className:"space-y-2 p-2 border-b",children:[G.jsx("div",{className:"flex items-center",children:G.jsx(juo,{solver:t})}),G.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[G.jsx("button",{onClick:c,disabled:t.solved||t.failed||i,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),G.jsx("button",{onClick:l,disabled:t.solved||t.failed||i,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),G.jsx("button",{onClick:u,disabled:t.solved||t.failed,className:`px-3 py-1 rounded text-white text-sm ${i?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:i?"Stop":"Animate"}),G.jsx("button",{onClick:d,disabled:t.solved||t.failed||i,className:"bg-orange-500 hover:bg-orange-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step Until Iteration"}),m&&G.jsx("button",{onClick:_,disabled:t.solved||t.failed||i,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),G.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&G.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),h&&G.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",G.jsx("span",{className:"font-medium",children:h})]}),t.solved&&G.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&G.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&G.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},Yuo=(t,e,n)=>{const o=t.currentPipelineStepIndex;return e<o?"Completed":e===o&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},quo=(t,e)=>{const o=t.pipelineDef[e].solverName,r=Yuo(t,e),i=t[o],s=t.firstIterationOfPhase?.[o]??null,a=t.iterations;let c=0;if(r==="Completed"){const d=t.pipelineDef[e+1],m=d?t.firstIterationOfPhase?.[d.solverName]:void 0;m!==void 0&&s!==null?c=m-s:s!==null&&(c=a-s)}else r==="In Progress"&&s!==null&&(c=a-s);const l=t.timeSpentOnPhase?.[o]??0;let u=0;r==="Completed"?u=1:r==="In Progress"&&i&&(u=i.progress??0);const _=i?.stats??null;return{index:e,name:o,status:r,firstIteration:s,iterations:c,progress:u,timeSpent:l,stats:_&&Object.keys(_).length>0?_:null,solverInstance:i??null}},Kuo=({status:t})=>{const e={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return G.jsx("span",{className:`font-medium ${e[t]}`,children:t})},Juo=({progress:t})=>{if(t===0)return null;const e=Math.round(t*100);return G.jsxs("div",{className:"flex items-center gap-2",children:[G.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:G.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${e}%`}})}),G.jsxs("span",{className:"text-xs text-gray-500",children:[e,"%"]})]})},Quo=t=>Object.entries(t).map(([e,n])=>`${e}: ${n}`).join(", "),Zuo=({stats:t})=>{if(!t||Object.keys(t).length===0)return G.jsx("span",{children:"-"});const e=Object.entries(t),n=Quo(t);return G.jsxs("details",{className:"cursor-pointer",children:[G.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:n}),G.jsx("div",{className:"mt-1 text-xs",children:e.map(([o,r])=>G.jsxs("div",{children:[o,": ",String(r)]},o))})]})},S4e=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(S4e);const e={};for(const[n,o]of Object.entries(t))n.startsWith("_")||(e[n]=S4e(o));return e},e0o=(t,e)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${e}`);return}const n=S4e(t.getConstructorParams()),o=new Blob([JSON.stringify(n,null,2)],{type:"application/json"}),r=URL.createObjectURL(o),i=document.createElement("a");i.href=r,i.download=`${e}_input.json`,i.click(),URL.revokeObjectURL(r)}catch(n){alert(`Error downloading input for ${e}: ${n instanceof Error?n.message:String(n)}`)}},t0o=({solver:t,onStepUntilPhase:e,onDownloadInput:n})=>{const o=t.pipelineDef.map((a,c)=>quo(t,c)),r=a=>{e?.(a)},i=a=>{a.solverInstance&&(n?n(a.solverInstance,a.name):e0o(a.solverInstance,a.name))},s=a=>`${(a/1e3).toFixed(2)}s`;return G.jsxs("div",{className:"border-t border-gray-200",children:[G.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:G.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),G.jsx("div",{className:"overflow-x-auto",children:G.jsxs("table",{className:"w-full text-sm",children:[G.jsx("thead",{children:G.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),G.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",G.jsx("sub",{children:"0"})]}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),G.jsx("tbody",{children:o.map(a=>G.jsxs("tr",{className:`border-b border-gray-100 ${a.status==="In Progress"?"bg-yellow-50":""}`,children:[G.jsx("td",{className:"px-4 py-2",children:G.jsxs("div",{className:"flex items-center gap-2",children:[G.jsx("span",{className:"text-gray-400 w-6",children:String(a.index+1).padStart(2,"0")}),G.jsx("button",{onClick:()=>r(a.name),disabled:a.status==="Completed"||t.solved||t.failed,className:"text-blue-500 hover:text-blue-700 disabled:text-gray-300 disabled:cursor-not-allowed",title:`Step until ${a.name} completes`,children:G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:G.jsx("path",{fillRule:"evenodd",d:"M4.5 5.653c0-1.426 1.529-2.33 2.779-1.643l11.54 6.348c1.295.712 1.295 2.573 0 3.285L7.28 19.991c-1.25.687-2.779-.217-2.779-1.643V5.653z",clipRule:"evenodd"})})}),G.jsx("span",{className:"font-medium text-gray-900",children:a.name})]})}),G.jsx("td",{className:"px-4 py-2",children:G.jsx(Kuo,{status:a.status})}),G.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:a.firstIteration!==null?a.firstIteration:""}),G.jsx("td",{className:"px-4 py-2 text-gray-600",children:a.iterations}),G.jsx("td",{className:"px-4 py-2",children:G.jsx(Juo,{progress:a.progress})}),G.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(a.timeSpent)}),G.jsx("td",{className:"px-4 py-2 text-gray-500",children:G.jsx(Zuo,{stats:a.stats})}),G.jsx("td",{className:"px-4 py-2",children:a.solverInstance?G.jsxs("button",{onClick:()=>i(a),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${a.name}`,children:[G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:G.jsx("path",{fillRule:"evenodd",d:"M12 2.25a.75.75 0 01.75.75v11.69l3.22-3.22a.75.75 0 111.06 1.06l-4.5 4.5a.75.75 0 01-1.06 0l-4.5-4.5a.75.75 0 111.06-1.06l3.22 3.22V3a.75.75 0 01.75-.75zm-9 13.5a.75.75 0 01.75.75v2.25a1.5 1.5 0 001.5 1.5h13.5a1.5 1.5 0 001.5-1.5V16.5a.75.75 0 011.5 0v2.25a3 3 0 01-3 3H5.25a3 3 0 01-3-3V16.5a.75.75 0 01.75-.75z",clipRule:"evenodd"})}),G.jsx("span",{children:"Input"})]}):null})]},a.name))})]})})]})},n0o=class extends pr.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t){console.error("InteractiveGraphics render error:",t)}render(){return this.state.hasError?this.props.fallback:this.props.children}};function o0o({graphics:t}){const e=t.points??[],n=t.lines??[],o=t.rects??[],r=t.circles??[],i=t.texts??[];let s=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY,l=Number.NEGATIVE_INFINITY;const u=(x,f)=>{typeof x=="number"&&(x<s&&(s=x),x>c&&(c=x)),typeof f=="number"&&(f<a&&(a=f),f>l&&(l=f))};for(const x of e)u(x.x,x.y);for(const x of n){const f=x.points??[];for(const g of f)u(g.x,g.y)}for(const x of o){const f=x.x??0,g=x.y??0,y=x.width??0,b=x.height??0;u(f,g),u(f+y,g+b)}for(const x of r){const f=x.x??0,g=x.y??0,y=x.radius??1;u(f-y,g-y),u(f+y,g+y)}for(const x of i)u(x.x,x.y);(!isFinite(s)||!isFinite(a)||!isFinite(c)||!isFinite(l))&&(s=-20,a=-20,c=20,l=20);const _=10,d=s-_,m=a-_,h=Math.max(1,c-s+2*_),p=Math.max(1,l-a+2*_);return G.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${d} ${m} ${h} ${p}`,role:"img","aria-label":"Graphics fallback",children:[o.map((x,f)=>G.jsx("rect",{x:x.x??0,y:x.y??0,width:x.width??0,height:x.height??0,fill:"none",stroke:x.strokeColor??"black",strokeWidth:x.strokeWidth??1},`rect-${f}`)),n.map((x,f)=>G.jsx("polyline",{fill:"none",stroke:x.strokeColor??"black",strokeWidth:x.strokeWidth??1,points:(x.points??[]).map(g=>`${g.x??0},${g.y??0}`).join(" ")},`line-${f}`)),r.map((x,f)=>G.jsx("circle",{cx:x.x??0,cy:x.y??0,r:x.radius??1.5,fill:x.fillColor??"none",stroke:x.strokeColor??"black",strokeWidth:x.strokeWidth??1},`circle-${f}`)),e.map((x,f)=>G.jsx("circle",{cx:x.x??0,cy:x.y??0,r:x.radius??1.5,fill:x.color??"black"},`point-${f}`)),i.map((x,f)=>G.jsx("text",{x:x.x??0,y:x.y??0,fontSize:x.fontSize??10,fill:x.color??"black",children:x.text??""},`text-${f}`))]})}var r0o=({solver:t,animationSpeed:e=25,onSolverStarted:n,onSolverCompleted:o})=>{const[r,i]=te.useReducer(u=>u+1,0),s=te.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(u){return console.error("Visualization error:",u),{points:[],lines:[],rects:[],circles:[]}}},[t,r]),a=te.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);te.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const u=document.createElement("script");u.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(u)}},[]);const c=t.pipelineDef!==void 0,l=u=>{const _=t;if(!t.solved&&!t.failed){for(;!t.solved&&!t.failed&&_.currentPipelineStepIndex<=_.pipelineDef.findIndex(d=>d.solverName===u);)t.step();i()}};return G.jsxs("div",{children:[G.jsx(Guo,{solver:t,triggerRender:i,animationSpeed:e,onSolverStarted:n,onSolverCompleted:o}),a?G.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):G.jsx(n0o,{fallback:G.jsx(o0o,{graphics:s}),children:G.jsx(Uuo,{graphics:s})}),c&&G.jsx(t0o,{solver:t,onStepUntilPhase:l})]})};const i0o=()=>{te.useEffect(()=>{const t="tailwind-cdn-script";if(document.getElementById(t)||window.tailwind)return;const e=document.createElement("div");e.className="hidden",document.body.appendChild(e);const n=window.getComputedStyle(e).display==="none";if(document.body.removeChild(e),n)return;const o=document.createElement("script");o.id=t,o.src="https://cdn.tailwindcss.com",document.head.appendChild(o)},[])},s0o=t=>t.toLowerCase().includes("pack")?IUn:t.toLowerCase().includes("rout")?zUn:MUn,a0o=({solverEvents:t=[]})=>{const[e,n]=te.useState(null);i0o();const o=te.useMemo(()=>{const a=new Map;for(const c of t){const l=`${c.componentName}-${c.solverName}`;a.set(l,c)}return a},[t]),r=te.useMemo(()=>Array.from(o.keys()),[o]),i=e?o.get(e):null,s=te.useMemo(()=>{if(!i)return{instance:null,error:null,classFound:!1};const a=fde[i.solverName];if(!a)return{instance:null,error:`Solver class "${i.solverName}" not found in SOLVERS registry. Available: ${Object.keys(fde).join(", ")}`,classFound:!1};try{const c=i.solverParams,l=c?.input!==void 0?c.input:c;return{instance:new a(l),error:null,classFound:!0}}catch(c){const l=c instanceof Error?c.message:String(c);return console.error("Failed to reconstruct solver:",c),{instance:null,error:`Failed to instantiate solver: ${l}`,classFound:!0}}},[i]);return t.length===0?G.jsx("div",{className:"rf-p-4",children:G.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:G.jsxs("div",{className:"rf-p-4",children:[G.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),G.jsx("p",{className:"rf-text-sm rf-text-gray-600",children:"Solvers will appear here when the circuit runs. Solvers are used for tasks like component packing and autorouting."})]})})}):G.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[G.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[G.jsxs("div",{className:"rf-text-xs rf-font-semibold rf-text-gray-500 rf-px-3 rf-py-2 rf-bg-gray-50 rf-border-b rf-border-gray-200",children:[r.length," ",r.length===1?"Solver":"Solvers"]}),r.map(a=>{const c=o.get(a),l=e===a;return G.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${l?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>n(a),children:(()=>{const u=s0o(c.solverName);return G.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[G.jsx(u,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),G.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[G.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:c.componentName}),G.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:c.solverName})]})]})})()},a)})]}),G.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:i?s.instance?G.jsx(Q4,{fallback:G.jsx("div",{className:"rf-p-4",children:G.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[G.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),G.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",i.solverName]})]})}),children:G.jsx(r0o,{solver:s.instance})}):G.jsxs("div",{className:"rf-p-4",children:[G.jsxs("div",{className:"rf-mb-4",children:[G.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:i.solverName}),G.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",i.componentName]})]}),s.error&&G.jsx("div",{className:`rf-rounded-md rf-border rf-p-4 rf-mb-4 ${s.classFound?"rf-bg-red-50 rf-border-red-200":"rf-bg-yellow-50 rf-border-yellow-200"}`,children:G.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),G.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[G.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:G.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),G.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:G.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(i.solverParams,null,2)})})]})]}):G.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:G.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},Xxt=({errorMessage:t,errorStack:e,circuitJsonErrors:n})=>{te.useEffect(()=>{if(t){const o=new Error(t);e&&(o.stack=e);try{bB.captureException(o)}catch{}}},[t,e]),te.useEffect(()=>{if(n&&n.length>0)for(const o of n){const r=new Error(o.message||"Circuit JSON Error");o.stack&&(r.stack=o.stack);try{bB.captureException(r,{error_type:o.type})}catch{}}},[n])},jxt="0.0.1943",c0o={version:jxt},C4e={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},M4e=new Map,vJ=t=>{const e=M4e.get(t);return e?Object.fromEntries(Object.entries(e.stores).map(([n,o])=>[n,o.getState()])):{}},l0o=(t,e,n)=>{if(t===void 0)return{type:"untracked",connection:e.connect(n)};const o=M4e.get(n.name);if(o)return{type:"tracked",store:t,...o};const r={connection:e.connect(n),stores:{}};return M4e.set(n.name,r),{type:"tracked",store:t,...r}},Gxt=(t,e={})=>(n,o,r)=>{const{enabled:i,anonymousActionType:s,store:a,...c}=e;let l;try{l=(i??(C4e?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!l)return(C4e?"production":void 0)!=="production"&&i&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),t(n,o,r);const{connection:u,..._}=l0o(a,l,c);let d=!0;r.setState=(p,x,f)=>{const g=n(p,x);if(!d)return g;const y=f===void 0?{type:s||"anonymous"}:typeof f=="string"?{type:f}:f;return a===void 0?(u?.send(y,o()),g):(u?.send({...y,type:`${a}/${y.type}`},{...vJ(c.name),[a]:r.getState()}),g)};const m=(...p)=>{const x=d;d=!1,n(...p),d=x},h=t(r.setState,o,r);if(_.type==="untracked"?u?.init(h):(_.stores[_.store]=r,u?.init(Object.fromEntries(Object.entries(_.stores).map(([p,x])=>[p,p===_.store?h:x.getState()])))),r.dispatchFromDevtools&&typeof r.dispatch=="function"){let p=!1;const x=r.dispatch;r.dispatch=(...f)=>{(C4e?"production":void 0)!=="production"&&f[0].type==="__setState"&&!p&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),p=!0),x(...f)}}return u.subscribe(p=>{var x;switch(p.type){case"ACTION":if(typeof p.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return T4e(p.payload,f=>{if(f.type==="__setState"){if(a===void 0){m(f.state);return}Object.keys(f.state).length!==1&&console.error(`
|
|
5733
|
+
`,_=new Blob([u],{type:"text/plain"}),d=URL.createObjectURL(_),m=document.createElement("a");m.href=d,m.download=`${l}.test.ts`,m.click(),URL.revokeObjectURL(d)}catch(c){alert(`Error generating test.ts for ${t.constructor.name}: ${c instanceof Error?c.message:String(c)}`)}o(!1)};return G.jsxs("div",{className:`relative ${e}`,ref:r,children:[G.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>o(!n),title:`Download options for ${t.constructor.name}`,children:t.constructor.name}),n&&G.jsxs("div",{className:"absolute top-full left-0 mt-1 bg-white border border-gray-300 rounded shadow-lg z-10 min-w-[150px]",children:[G.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:i,children:"Download JSON"}),G.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),G.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:a,children:"Download test.ts"})]})]})},Uxt=t=>t.activeSubSolver?[t,...Uxt(t.activeSubSolver)]:[t],juo=({solver:t})=>{const e=Uxt(t);return G.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:e.map((n,o)=>G.jsxs("div",{className:"flex items-center",children:[o>0&&G.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),G.jsx(Xuo,{solver:n})]},n.constructor.name))})},Guo=({solver:t,triggerRender:e,animationSpeed:n=25,onSolverStarted:o,onSolverCompleted:r})=>{const[i,s]=te.useReducer(p=>!p,!1),a=te.useRef(void 0),c=()=>{!t.solved&&!t.failed&&(t.step(),e())},l=()=>{!t.solved&&!t.failed&&(o&&o(t),t.solve(),e(),r&&r(t))},u=()=>{i?(a.current&&(clearInterval(a.current),a.current=void 0),s()):(s(),a.current=setInterval(()=>{if(t.solved||t.failed){a.current&&(clearInterval(a.current),a.current=void 0),s(),e(),r&&t.solved&&r(t);return}t.step(),e()},n))},_=()=>{const p=t;if(p.getCurrentPhase&&!t.solved&&!t.failed){const x=p.getCurrentPhase();for(;p.getCurrentPhase()===x&&!t.solved&&!t.failed;)t.step();e()}},d=()=>{if(t.solved||t.failed||i)return;const p=window.prompt("Step until which iteration?",`${t.iterations}`);if(p===null)return;const x=Number(p);if(!Number.isFinite(x)){window.alert("Please enter a valid number for the iteration");return}for(;t.iterations<x&&!t.solved&&!t.failed;)t.step();e(),t.solved&&r&&r(t)};te.useEffect(()=>()=>{a.current&&clearInterval(a.current)},[]),te.useEffect(()=>{(t.solved||t.failed)&&i&&(a.current&&(clearInterval(a.current),a.current=void 0),s())},[t.solved,t.failed,i]);const m=t.getCurrentPhase!==void 0,h=m?t.getCurrentPhase():null;return G.jsxs("div",{className:"space-y-2 p-2 border-b",children:[G.jsx("div",{className:"flex items-center",children:G.jsx(juo,{solver:t})}),G.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[G.jsx("button",{onClick:c,disabled:t.solved||t.failed||i,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),G.jsx("button",{onClick:l,disabled:t.solved||t.failed||i,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),G.jsx("button",{onClick:u,disabled:t.solved||t.failed,className:`px-3 py-1 rounded text-white text-sm ${i?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:i?"Stop":"Animate"}),G.jsx("button",{onClick:d,disabled:t.solved||t.failed||i,className:"bg-orange-500 hover:bg-orange-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step Until Iteration"}),m&&G.jsx("button",{onClick:_,disabled:t.solved||t.failed||i,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),G.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&G.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),h&&G.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",G.jsx("span",{className:"font-medium",children:h})]}),t.solved&&G.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&G.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&G.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},Yuo=(t,e,n)=>{const o=t.currentPipelineStepIndex;return e<o?"Completed":e===o&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},quo=(t,e)=>{const o=t.pipelineDef[e].solverName,r=Yuo(t,e),i=t[o],s=t.firstIterationOfPhase?.[o]??null,a=t.iterations;let c=0;if(r==="Completed"){const d=t.pipelineDef[e+1],m=d?t.firstIterationOfPhase?.[d.solverName]:void 0;m!==void 0&&s!==null?c=m-s:s!==null&&(c=a-s)}else r==="In Progress"&&s!==null&&(c=a-s);const l=t.timeSpentOnPhase?.[o]??0;let u=0;r==="Completed"?u=1:r==="In Progress"&&i&&(u=i.progress??0);const _=i?.stats??null;return{index:e,name:o,status:r,firstIteration:s,iterations:c,progress:u,timeSpent:l,stats:_&&Object.keys(_).length>0?_:null,solverInstance:i??null}},Kuo=({status:t})=>{const e={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return G.jsx("span",{className:`font-medium ${e[t]}`,children:t})},Juo=({progress:t})=>{if(t===0)return null;const e=Math.round(t*100);return G.jsxs("div",{className:"flex items-center gap-2",children:[G.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:G.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${e}%`}})}),G.jsxs("span",{className:"text-xs text-gray-500",children:[e,"%"]})]})},Quo=t=>Object.entries(t).map(([e,n])=>`${e}: ${n}`).join(", "),Zuo=({stats:t})=>{if(!t||Object.keys(t).length===0)return G.jsx("span",{children:"-"});const e=Object.entries(t),n=Quo(t);return G.jsxs("details",{className:"cursor-pointer",children:[G.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:n}),G.jsx("div",{className:"mt-1 text-xs",children:e.map(([o,r])=>G.jsxs("div",{children:[o,": ",String(r)]},o))})]})},S4e=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(S4e);const e={};for(const[n,o]of Object.entries(t))n.startsWith("_")||(e[n]=S4e(o));return e},e0o=(t,e)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${e}`);return}const n=S4e(t.getConstructorParams()),o=new Blob([JSON.stringify(n,null,2)],{type:"application/json"}),r=URL.createObjectURL(o),i=document.createElement("a");i.href=r,i.download=`${e}_input.json`,i.click(),URL.revokeObjectURL(r)}catch(n){alert(`Error downloading input for ${e}: ${n instanceof Error?n.message:String(n)}`)}},t0o=({solver:t,onStepUntilPhase:e,onDownloadInput:n})=>{const o=t.pipelineDef.map((a,c)=>quo(t,c)),r=a=>{e?.(a)},i=a=>{a.solverInstance&&(n?n(a.solverInstance,a.name):e0o(a.solverInstance,a.name))},s=a=>`${(a/1e3).toFixed(2)}s`;return G.jsxs("div",{className:"border-t border-gray-200",children:[G.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:G.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),G.jsx("div",{className:"overflow-x-auto",children:G.jsxs("table",{className:"w-full text-sm",children:[G.jsx("thead",{children:G.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),G.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",G.jsx("sub",{children:"0"})]}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),G.jsx("tbody",{children:o.map(a=>G.jsxs("tr",{className:`border-b border-gray-100 ${a.status==="In Progress"?"bg-yellow-50":""}`,children:[G.jsx("td",{className:"px-4 py-2",children:G.jsxs("div",{className:"flex items-center gap-2",children:[G.jsx("span",{className:"text-gray-400 w-6",children:String(a.index+1).padStart(2,"0")}),G.jsx("button",{onClick:()=>r(a.name),disabled:a.status==="Completed"||t.solved||t.failed,className:"text-blue-500 hover:text-blue-700 disabled:text-gray-300 disabled:cursor-not-allowed",title:`Step until ${a.name} completes`,children:G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:G.jsx("path",{fillRule:"evenodd",d:"M4.5 5.653c0-1.426 1.529-2.33 2.779-1.643l11.54 6.348c1.295.712 1.295 2.573 0 3.285L7.28 19.991c-1.25.687-2.779-.217-2.779-1.643V5.653z",clipRule:"evenodd"})})}),G.jsx("span",{className:"font-medium text-gray-900",children:a.name})]})}),G.jsx("td",{className:"px-4 py-2",children:G.jsx(Kuo,{status:a.status})}),G.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:a.firstIteration!==null?a.firstIteration:""}),G.jsx("td",{className:"px-4 py-2 text-gray-600",children:a.iterations}),G.jsx("td",{className:"px-4 py-2",children:G.jsx(Juo,{progress:a.progress})}),G.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(a.timeSpent)}),G.jsx("td",{className:"px-4 py-2 text-gray-500",children:G.jsx(Zuo,{stats:a.stats})}),G.jsx("td",{className:"px-4 py-2",children:a.solverInstance?G.jsxs("button",{onClick:()=>i(a),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${a.name}`,children:[G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:G.jsx("path",{fillRule:"evenodd",d:"M12 2.25a.75.75 0 01.75.75v11.69l3.22-3.22a.75.75 0 111.06 1.06l-4.5 4.5a.75.75 0 01-1.06 0l-4.5-4.5a.75.75 0 111.06-1.06l3.22 3.22V3a.75.75 0 01.75-.75zm-9 13.5a.75.75 0 01.75.75v2.25a1.5 1.5 0 001.5 1.5h13.5a1.5 1.5 0 001.5-1.5V16.5a.75.75 0 011.5 0v2.25a3 3 0 01-3 3H5.25a3 3 0 01-3-3V16.5a.75.75 0 01.75-.75z",clipRule:"evenodd"})}),G.jsx("span",{children:"Input"})]}):null})]},a.name))})]})})]})},n0o=class extends pr.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t){console.error("InteractiveGraphics render error:",t)}render(){return this.state.hasError?this.props.fallback:this.props.children}};function o0o({graphics:t}){const e=t.points??[],n=t.lines??[],o=t.rects??[],r=t.circles??[],i=t.texts??[];let s=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY,l=Number.NEGATIVE_INFINITY;const u=(x,f)=>{typeof x=="number"&&(x<s&&(s=x),x>c&&(c=x)),typeof f=="number"&&(f<a&&(a=f),f>l&&(l=f))};for(const x of e)u(x.x,x.y);for(const x of n){const f=x.points??[];for(const g of f)u(g.x,g.y)}for(const x of o){const f=x.x??0,g=x.y??0,y=x.width??0,b=x.height??0;u(f,g),u(f+y,g+b)}for(const x of r){const f=x.x??0,g=x.y??0,y=x.radius??1;u(f-y,g-y),u(f+y,g+y)}for(const x of i)u(x.x,x.y);(!isFinite(s)||!isFinite(a)||!isFinite(c)||!isFinite(l))&&(s=-20,a=-20,c=20,l=20);const _=10,d=s-_,m=a-_,h=Math.max(1,c-s+2*_),p=Math.max(1,l-a+2*_);return G.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${d} ${m} ${h} ${p}`,role:"img","aria-label":"Graphics fallback",children:[o.map((x,f)=>G.jsx("rect",{x:x.x??0,y:x.y??0,width:x.width??0,height:x.height??0,fill:"none",stroke:x.strokeColor??"black",strokeWidth:x.strokeWidth??1},`rect-${f}`)),n.map((x,f)=>G.jsx("polyline",{fill:"none",stroke:x.strokeColor??"black",strokeWidth:x.strokeWidth??1,points:(x.points??[]).map(g=>`${g.x??0},${g.y??0}`).join(" ")},`line-${f}`)),r.map((x,f)=>G.jsx("circle",{cx:x.x??0,cy:x.y??0,r:x.radius??1.5,fill:x.fillColor??"none",stroke:x.strokeColor??"black",strokeWidth:x.strokeWidth??1},`circle-${f}`)),e.map((x,f)=>G.jsx("circle",{cx:x.x??0,cy:x.y??0,r:x.radius??1.5,fill:x.color??"black"},`point-${f}`)),i.map((x,f)=>G.jsx("text",{x:x.x??0,y:x.y??0,fontSize:x.fontSize??10,fill:x.color??"black",children:x.text??""},`text-${f}`))]})}var r0o=({solver:t,animationSpeed:e=25,onSolverStarted:n,onSolverCompleted:o})=>{const[r,i]=te.useReducer(u=>u+1,0),s=te.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(u){return console.error("Visualization error:",u),{points:[],lines:[],rects:[],circles:[]}}},[t,r]),a=te.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);te.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const u=document.createElement("script");u.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(u)}},[]);const c=t.pipelineDef!==void 0,l=u=>{const _=t;if(!t.solved&&!t.failed){for(;!t.solved&&!t.failed&&_.currentPipelineStepIndex<=_.pipelineDef.findIndex(d=>d.solverName===u);)t.step();i()}};return G.jsxs("div",{children:[G.jsx(Guo,{solver:t,triggerRender:i,animationSpeed:e,onSolverStarted:n,onSolverCompleted:o}),a?G.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):G.jsx(n0o,{fallback:G.jsx(o0o,{graphics:s}),children:G.jsx(Uuo,{graphics:s})}),c&&G.jsx(t0o,{solver:t,onStepUntilPhase:l})]})};const i0o=()=>{te.useEffect(()=>{const t="tailwind-cdn-script";if(document.getElementById(t)||window.tailwind)return;const e=document.createElement("div");e.className="hidden",document.body.appendChild(e);const n=window.getComputedStyle(e).display==="none";if(document.body.removeChild(e),n)return;const o=document.createElement("script");o.id=t,o.src="https://cdn.tailwindcss.com",document.head.appendChild(o)},[])},s0o=t=>t.toLowerCase().includes("pack")?IUn:t.toLowerCase().includes("rout")?zUn:MUn,a0o=({solverEvents:t=[]})=>{const[e,n]=te.useState(null);i0o();const o=te.useMemo(()=>{const a=new Map;for(const c of t){const l=`${c.componentName}-${c.solverName}`;a.set(l,c)}return a},[t]),r=te.useMemo(()=>Array.from(o.keys()),[o]),i=e?o.get(e):null,s=te.useMemo(()=>{if(!i)return{instance:null,error:null,classFound:!1};const a=fde[i.solverName];if(!a)return{instance:null,error:`Solver class "${i.solverName}" not found in SOLVERS registry. Available: ${Object.keys(fde).join(", ")}`,classFound:!1};try{const c=i.solverParams,l=c?.input!==void 0?c.input:c;return{instance:new a(l),error:null,classFound:!0}}catch(c){const l=c instanceof Error?c.message:String(c);return console.error("Failed to reconstruct solver:",c),{instance:null,error:`Failed to instantiate solver: ${l}`,classFound:!0}}},[i]);return t.length===0?G.jsx("div",{className:"rf-p-4",children:G.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:G.jsxs("div",{className:"rf-p-4",children:[G.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),G.jsx("p",{className:"rf-text-sm rf-text-gray-600",children:"Solvers will appear here when the circuit runs. Solvers are used for tasks like component packing and autorouting."})]})})}):G.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[G.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[G.jsxs("div",{className:"rf-text-xs rf-font-semibold rf-text-gray-500 rf-px-3 rf-py-2 rf-bg-gray-50 rf-border-b rf-border-gray-200",children:[r.length," ",r.length===1?"Solver":"Solvers"]}),r.map(a=>{const c=o.get(a),l=e===a;return G.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${l?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>n(a),children:(()=>{const u=s0o(c.solverName);return G.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[G.jsx(u,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),G.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[G.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:c.componentName}),G.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:c.solverName})]})]})})()},a)})]}),G.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:i?s.instance?G.jsx(Q4,{fallback:G.jsx("div",{className:"rf-p-4",children:G.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[G.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),G.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",i.solverName]})]})}),children:G.jsx(r0o,{solver:s.instance})}):G.jsxs("div",{className:"rf-p-4",children:[G.jsxs("div",{className:"rf-mb-4",children:[G.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:i.solverName}),G.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",i.componentName]})]}),s.error&&G.jsx("div",{className:`rf-rounded-md rf-border rf-p-4 rf-mb-4 ${s.classFound?"rf-bg-red-50 rf-border-red-200":"rf-bg-yellow-50 rf-border-yellow-200"}`,children:G.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),G.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[G.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:G.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),G.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:G.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(i.solverParams,null,2)})})]})]}):G.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:G.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},Xxt=({errorMessage:t,errorStack:e,circuitJsonErrors:n})=>{te.useEffect(()=>{if(t){const o=new Error(t);e&&(o.stack=e);try{bB.captureException(o)}catch{}}},[t,e]),te.useEffect(()=>{if(n&&n.length>0)for(const o of n){const r=new Error(o.message||"Circuit JSON Error");o.stack&&(r.stack=o.stack);try{bB.captureException(r,{error_type:o.type})}catch{}}},[n])},jxt="0.0.1945",c0o={version:jxt},C4e={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},M4e=new Map,vJ=t=>{const e=M4e.get(t);return e?Object.fromEntries(Object.entries(e.stores).map(([n,o])=>[n,o.getState()])):{}},l0o=(t,e,n)=>{if(t===void 0)return{type:"untracked",connection:e.connect(n)};const o=M4e.get(n.name);if(o)return{type:"tracked",store:t,...o};const r={connection:e.connect(n),stores:{}};return M4e.set(n.name,r),{type:"tracked",store:t,...r}},Gxt=(t,e={})=>(n,o,r)=>{const{enabled:i,anonymousActionType:s,store:a,...c}=e;let l;try{l=(i??(C4e?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!l)return(C4e?"production":void 0)!=="production"&&i&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),t(n,o,r);const{connection:u,..._}=l0o(a,l,c);let d=!0;r.setState=(p,x,f)=>{const g=n(p,x);if(!d)return g;const y=f===void 0?{type:s||"anonymous"}:typeof f=="string"?{type:f}:f;return a===void 0?(u?.send(y,o()),g):(u?.send({...y,type:`${a}/${y.type}`},{...vJ(c.name),[a]:r.getState()}),g)};const m=(...p)=>{const x=d;d=!1,n(...p),d=x},h=t(r.setState,o,r);if(_.type==="untracked"?u?.init(h):(_.stores[_.store]=r,u?.init(Object.fromEntries(Object.entries(_.stores).map(([p,x])=>[p,p===_.store?h:x.getState()])))),r.dispatchFromDevtools&&typeof r.dispatch=="function"){let p=!1;const x=r.dispatch;r.dispatch=(...f)=>{(C4e?"production":void 0)!=="production"&&f[0].type==="__setState"&&!p&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),p=!0),x(...f)}}return u.subscribe(p=>{var x;switch(p.type){case"ACTION":if(typeof p.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return T4e(p.payload,f=>{if(f.type==="__setState"){if(a===void 0){m(f.state);return}Object.keys(f.state).length!==1&&console.error(`
|
|
5734
5734
|
[zustand devtools middleware] Unsupported __setState action format.
|
|
5735
5735
|
When using 'store' option in devtools(), the 'state' should have only one key, which is a value of 'store' that was passed in devtools(),
|
|
5736
5736
|
and value of this only key should be a state object. Example: { "type": "__setState", "state": { "abc123Store": { "foo": "bar" } } }
|
package/dist/standalone.min.js
CHANGED
|
@@ -5517,7 +5517,7 @@ $1`).replace(/>(\s*)(?=<!--\s*\/)/g,"> ")}}});function ygt(t,e,n){if(!e||!n)retu
|
|
|
5517
5517
|
transition: opacity 0.2s;
|
|
5518
5518
|
margin-bottom: 10px;
|
|
5519
5519
|
color: red;
|
|
5520
|
-
`,$0o=({children:t,transform:e=Sl(),elements:n})=>{const o=Y.useRef(null),{isShowingDRCErrors:r,hoveredErrorId:i,focusedErrorId:s}=B_(p=>({isShowingDRCErrors:p.is_showing_drc_errors,hoveredErrorId:p.hovered_error_id,focusedErrorId:p.focused_error_id})),a=s??i;if(!n)return G.jsx("div",{style:{position:"relative"},ref:o,children:t});const c=n.filter(p=>p.type==="pcb_trace_error"&&!p.message?.includes("Multiple components found with name")),l=n.filter(p=>p.type==="pcb_via_clearance_error"),u=n.filter(p=>p.type==="pcb_trace_error"&&p.message?.includes("Multiple components found with name")),_=Dgt(n),d=Egt(n,a),m=p=>{const x=luo({error:p,indexes:_});if(!x||typeof x.x!="number"||typeof x.y!="number")return null;const f=pt(e,x);return Number.isNaN(f.x)||Number.isNaN(f.y)?null:f};let h=null;return d&&(h=m(d)),G.jsxs("div",{style:{position:"relative"},ref:o,children:[t,c.map((p,x)=>{const f=dk(p,x),g=a===f;if(!g&&!r)return null;const y=m(p);if(!y)return null;const b=yPe(y,o);return G.jsxs(Y.Fragment,{children:[G.jsx(eyt,{errorCenter:y,isHighlighted:g}),G.jsx("div",{style:{position:"absolute",left:y.x-15,top:y.y-15,width:30,height:30,zIndex:bu.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:v=>{const S=v.currentTarget.nextElementSibling;if(S){const M=S.querySelector(".error-message");M&&(M.style.opacity="1")}},onMouseLeave:v=>{if(!g){const S=v.currentTarget.nextElementSibling;if(S){const M=S.querySelector(".error-message");M&&(M.style.opacity="0")}}}}),G.jsx("div",{style:{position:"absolute",zIndex:g?200:100,left:b.left,top:b.top,color:g?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:r||g?"flex":"none",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:b.transform},children:G.jsx("div",{className:`error-message ${bPe}`,style:{opacity:g?1:0,border:`1px solid ${g?"#ff4444":"red"}`},children:p.message})})]},f)}),l.map((p,x)=>{const f=dk(p,x),g=a===f;if(!g&&!r)return null;const y=m(p);if(!y)return null;const b=yPe({x:y.x,y:y.y},o);return G.jsxs(Y.Fragment,{children:[G.jsx(eyt,{errorCenter:y,isHighlighted:g}),G.jsx("div",{style:{position:"absolute",left:y.x-15,top:y.y-15,width:30,height:30,zIndex:bu.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:v=>{const S=v.currentTarget.nextElementSibling;if(S){const M=S.querySelector(".error-message");M&&(M.style.opacity="1")}},onMouseLeave:v=>{if(!g){const S=v.currentTarget.nextElementSibling;if(S){const M=S.querySelector(".error-message");M&&(M.style.opacity="0")}}}}),G.jsx("div",{style:{position:"absolute",zIndex:g?bu.errorOverlay+10:bu.errorOverlay+1,left:b.left,top:b.top,color:g?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:"flex",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:b.transform},children:G.jsx("div",{className:`error-message ${bPe}`,style:{opacity:g?1:0,border:`1px solid ${g?"#ff4444":"red"}`},children:p.message})})]},f)}),u.map((p,x)=>{const f=p.component_name||p.message?.match(/name "([^"]+)"/)?.[1];if(!f)return null;const g=n?.filter(v=>v.type==="source_component"&&v.name===f||v.type==="pcb_component"&&n?.find(S=>S.type==="source_component"&&S.source_component_id===v.source_component_id&&S.name===f))||[],y=dk(p,x),b=a===y;return!b&&!r?null:g.map((v,S)=>{let M={x:0,y:0};if(v.type==="pcb_component")M=v.center||{x:0,y:0};else if(v.type==="source_component"){const V=n?.find(X=>X.type==="pcb_component"&&X.source_component_id===v.source_component_id);V&&V.type==="pcb_component"&&(M=V.center||{x:0,y:0})}const T=pt(e,M);if(Number.isNaN(T.x)||Number.isNaN(T.y))return null;const D=Math.abs(e.a),F=Math.max(8,Math.min(30,.5*D)),B=yPe(T,o);return G.jsxs(Y.Fragment,{children:[G.jsx("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none",mixBlendMode:"difference",zIndex:bu.errorOverlay},width:"100%",height:"100%",children:b?G.jsx("polygon",{points:`${T.x},${T.y-F*1.25} ${T.x+F},${T.y} ${T.x},${T.y+F*1.25} ${T.x-F},${T.y}`,fill:"#ff4444"}):G.jsx("circle",{cx:T.x,cy:T.y,r:F,fill:"none",stroke:b?"#ff4444":"red",strokeWidth:b?Math.max(2,F*.15):Math.max(1,F*.1),opacity:1})}),G.jsx("div",{style:{position:"absolute",left:T.x-(F+10),top:T.y-(F+10),width:(F+10)*2,height:(F+10)*2,zIndex:bu.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:V=>{const X=V.currentTarget.nextElementSibling;if(X){const K=X.querySelector(".error-message");K&&(K.style.opacity="1")}},onMouseLeave:V=>{if(!b){const X=V.currentTarget.nextElementSibling;if(X){const K=X.querySelector(".error-message");K&&(K.style.opacity="0")}}}}),G.jsx("div",{style:{position:"absolute",zIndex:b?bu.errorOverlay+20:bu.errorOverlay+10,left:B.left,top:B.top,color:b?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:r||b?"flex":"none",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:B.transform},children:G.jsx("div",{className:`error-message ${bPe}`,style:{opacity:b?1:0,border:`1px solid ${b?"#ff4444":"red"}`},children:p.message})})]},`${y}_${S}`)})}),h&&G.jsx(V0o,{center:h})]})};function W0o(t,e){return t.size!==e.size?!1:Array.from(t).every(n=>e.has(n))}function j0o({primitiveElement:t,elements:e}){let n=t.trace_length?`${t.trace_length.toFixed(3)}`:"";const o=s8(e).source_trace.get(t?.source_trace_id);if(o?.display_name&&(o?.max_length?n+=` / ${o.max_length}mm `:n+=" mm ",n+=`(${o.display_name})`),!n)return null;const r=t.trace_length&&o?.max_length&&t.trace_length>o.max_length;return{text:n,isOverLength:r}}function U0o(t){const{primitives:e,is_showing_multiple_traces_length:n,elements:o}=t,r=e.filter(c=>c._element.type==="pcb_trace"),i=o.filter(c=>c.type==="source_trace"),s=e.filter(c=>c._element.type!=="pcb_trace"),a=r.filter(c=>i.some(l=>c._element.type==="pcb_trace"&&c._element.source_trace_id===l.source_trace_id&&l.max_length!==void 0));if(!n)return[...s,...a];if(r.length>1){const c=r.reduce((l,u)=>{const _=l._element.trace_length;return u._element.trace_length<_?u:l},r[0]);return[...s,c]}return e}var X0o={position:"absolute",left:0,top:0,pointerEvents:"none",color:"red",fontFamily:"sans-serif",fontSize:12,textShadow:"0 0 2px black"},G0o=t=>{const{_element:e,_parent_pcb_component:n,_parent_source_component:o,_source_port:r}=t;switch(e.type){case"pcb_trace":return e.trace_length?`${e.trace_length.toFixed(3)}`:"";case"pcb_smtpad":case"pcb_plated_hole":{const i=[],s=Array.from(new Set((e.port_hints??[]).concat(r?.port_hints??[]))).filter(c=>!/^[0-9]+$/.test(c)).filter(c=>!c.includes("unnamed_")).sort((c,l)=>l.localeCompare(c)),a=o&&"name"in o&&o.name&&!o.name.includes("unnamed_")?o.name:null;return s.length>0?a?i.push(...s.map(c=>`${a}.${c}`)):i.push(...s):a&&i.push(a),i.join(", ")}default:return""}},Y0o={top:"red",bottom:"aqua"},q0o=({primitive:t,mousePos:e,elements:n})=>{const[o,r]=Y.useState(!1),i=t._element;Y.useEffect(()=>{setTimeout(()=>{r(!0)},100)},[]);const[s,a,c,l]=[t.screen_x,t.screen_y,t.screen_w,t.screen_h],u=t.same_space_index??0,_=26,d=Y0o[t?._element?.layer]??"red";let m=0;if(i.type==="pcb_smtpad"&&i?.shape==="rotated_rect"?m=i?.ccw_rotation??0:(i.type==="pcb_smtpad"&&(i?.shape==="pill"||i?.shape==="rotated_pill")&&"ccw_rotation"in t||i.type==="pcb_plated_hole"&&(i?.shape==="pill"||i?.shape==="oval")&&"ccw_rotation"in t)&&(m=i.ccw_rotation??0),i.type==="pcb_trace"){const x=j0o({primitiveElement:i,elements:n});if(!x)return null;const f=e.y-35;return G.jsx("div",{style:{zIndex:bu.elementOverlay,position:"absolute",left:e.x,top:f,color:d,pointerEvents:"none",transform:"translateX(-50%)"},children:G.jsx("div",{style:{backgroundColor:"#f2efcc",color:x.isOverLength?"red":"black",textShadow:"none",WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale",padding:"6px 6px",borderRadius:"6px",fontSize:"14px",minWidth:"45px",textAlign:"center",whiteSpace:"nowrap"},children:x.text})})}const h=G0o(t);return h.trim().length===0?null:G.jsx("div",{style:{zIndex:bu.elementOverlay,position:"absolute",left:s-c/2-8,top:a-l/2-8,width:c+16,height:l+16,color:d,transform:`rotate(${-m}deg)`,transformOrigin:"center center"},children:G.jsx("div",{style:{width:o?`calc(100% + ${_*2*u}px)`:"100%",height:o?`calc(100% + ${_*2*u}px)`:"100%",marginLeft:o?`${-_*u}px`:0,marginTop:o?`${-_*u}px`:0,border:`1px solid ${d}`,opacity:o||u===0?1:0,transition:"width 0.2s, height 0.2s, margin-left 0.2s, margin-top 0.2s, opacity 0.2s"},children:G.jsx("div",{style:{position:"absolute",bottom:l+20+_*u,marginRight:o?`${-_*u}px`:0,marginBottom:o?0:-_*u,transition:"margin-right 0.2s, margin-bottom 0.2s",backgroundColor:"#f2efcc",color:"black",textShadow:"none",WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale",padding:"6px 6px",borderRadius:"6px",fontSize:"14px",transform:`rotate(${m}deg)`,minWidth:"45px",textAlign:"center"},children:h})})})},K0o=({highlightedPrimitives:t,mousePos:e,elements:n})=>{const[o,r]=B_(a=>[a.is_moving_component,a.is_showing_multiple_traces_length]),i=t.some(a=>a._element.type==="pcb_smtpad")&&t.some(a=>a._element.type==="pcb_trace");let s=t;return i&&(s=s.filter(a=>a._element.type==="pcb_smtpad")),s=U0o({primitives:s,is_showing_multiple_traces_length:r,elements:n}),G.jsx("div",{style:X0o,children:!o&&s.map((a,c)=>G.jsx(q0o,{primitive:a,mousePos:e,elements:n},c))})},a8=t=>t?.type==="pcb_component",tyt=t=>t?.type==="pcb_group",J0o=t=>t?.type==="pcb_panel",PPe=t=>t?.type==="pcb_board",Ju={MIN_LINE_LENGTH_FOR_LABEL:40,LABEL_OFFSET_ABOVE:2,LABEL_OFFSET_BELOW:-18,LABEL_OFFSET_RIGHT:8,LABEL_OFFSET_LEFT:-120,Y_LABEL_MIN_WIDTH:110,LINE_STROKE_WIDTH:1.5,LINE_DASH_PATTERN:"4,4",COMPONENT_MARKER_RADIUS:3,LABEL_FONT_SIZE:11,ANCHOR_MARKER_SIZE:6,ANCHOR_MARKER_STROKE_WIDTH:1.5},Ky={OFFSET_LINE:"white",COMPONENT_MARKER_FILL:"#66ccff",COMPONENT_MARKER_STROKE:"white",LABEL_TEXT:"white"},vPe=({targets:t,transform:e,containerWidth:n,containerHeight:o})=>{if(t.length===0)return null;const r={color:Ky.LABEL_TEXT,mixBlendMode:"difference",pointerEvents:"none",fontSize:Ju.LABEL_FONT_SIZE,fontFamily:"monospace",fontWeight:"bold"},i=new Map;return t.forEach(s=>{if(!i.has(s.anchor_id)){const a=pt(e,s.anchor);i.set(s.anchor_id,a)}}),G.jsx("div",{style:{position:"absolute",left:0,top:0,width:n,height:o,overflow:"hidden",pointerEvents:"none",zIndex:bu.dimensionOverlay},children:G.jsxs("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none"},width:n,height:o,children:[t.map(s=>{const a=s.anchor,c=s.anchor_id,l=s.target,u=i.get(c),_=pt(e,l),d=l.x-a.x,m=l.y-a.y,h=Math.abs(_.x-u.x),p=Math.abs(_.y-u.y),x=_.y<u.y,f=_.x>u.x,g=x?Ju.LABEL_OFFSET_ABOVE:Ju.LABEL_OFFSET_BELOW,y=f?Ju.LABEL_OFFSET_RIGHT:Ju.LABEL_OFFSET_LEFT,b=h>Ju.MIN_LINE_LENGTH_FOR_LABEL,v=p>Ju.MIN_LINE_LENGTH_FOR_LABEL,S=`${s.display_offset_x??d.toFixed(2)}mm`,M=`${s.display_offset_y??m.toFixed(2)}mm`;return G.jsxs("g",{children:[G.jsx("line",{x1:u.x,y1:u.y,x2:_.x,y2:u.y,stroke:Ky.OFFSET_LINE,strokeWidth:Ju.LINE_STROKE_WIDTH,strokeDasharray:Ju.LINE_DASH_PATTERN}),G.jsx("line",{x1:_.x,y1:u.y,x2:_.x,y2:_.y,stroke:Ky.OFFSET_LINE,strokeWidth:Ju.LINE_STROKE_WIDTH,strokeDasharray:Ju.LINE_DASH_PATTERN}),s.type==="component"||s.type==="board"?G.jsx("circle",{cx:_.x,cy:_.y,r:Ju.COMPONENT_MARKER_RADIUS,fill:Ky.COMPONENT_MARKER_FILL,stroke:Ky.COMPONENT_MARKER_STROKE,strokeWidth:1}):G.jsxs(G.Fragment,{children:[G.jsx("line",{x1:_.x-Ju.ANCHOR_MARKER_SIZE,y1:_.y,x2:_.x+Ju.ANCHOR_MARKER_SIZE,y2:_.y,stroke:Ky.OFFSET_LINE,strokeWidth:Ju.ANCHOR_MARKER_STROKE_WIDTH}),G.jsx("line",{x1:_.x,y1:_.y-Ju.ANCHOR_MARKER_SIZE,x2:_.x,y2:_.y+Ju.ANCHOR_MARKER_SIZE,stroke:Ky.OFFSET_LINE,strokeWidth:Ju.ANCHOR_MARKER_STROKE_WIDTH})]}),b&&G.jsx("foreignObject",{x:Math.min(u.x,_.x),y:u.y+g,width:Math.abs(_.x-u.x),height:20,style:{overflow:"visible"},children:G.jsx("div",{style:{...r,textAlign:"center"},children:S})}),v&&G.jsx("foreignObject",{x:_.x+y,y:Math.min(u.y,_.y),width:Ju.Y_LABEL_MIN_WIDTH,height:Math.abs(_.y-u.y),style:{overflow:"visible"},children:G.jsx("div",{style:{...r,display:"flex",alignItems:"center",justifyContent:f?"flex-start":"flex-end",whiteSpace:"nowrap",padding:"0 4px",height:"100%"},children:M})})]},s.id)}),Array.from(i.entries()).map(([s,a])=>G.jsxs("g",{children:[G.jsx("line",{x1:a.x-Ju.ANCHOR_MARKER_SIZE,y1:a.y,x2:a.x+Ju.ANCHOR_MARKER_SIZE,y2:a.y,stroke:Ky.OFFSET_LINE,strokeWidth:Ju.ANCHOR_MARKER_STROKE_WIDTH}),G.jsx("line",{x1:a.x,y1:a.y-Ju.ANCHOR_MARKER_SIZE,x2:a.x,y2:a.y+Ju.ANCHOR_MARKER_SIZE,stroke:Ky.OFFSET_LINE,strokeWidth:Ju.ANCHOR_MARKER_STROKE_WIDTH})]},`anchor-${s}`))]})})},Q0o=({elements:t,highlightedPrimitives:e,transform:n,containerWidth:o,containerHeight:r})=>{const i=t.filter(f=>PPe(f)),s=t.filter(f=>a8(f)),a=t.filter(f=>tyt(f)),c=e.map(f=>a8(f._parent_pcb_component)?f._parent_pcb_component.pcb_component_id:a8(f._element)?f._element.pcb_component_id:null).filter(f=>!!f),l=new Set;if(c.forEach(f=>{const g=s.find(y=>y.pcb_component_id===f);g?.pcb_group_id&&l.add(g.pcb_group_id)}),!B_(f=>f.is_showing_group_anchor_offsets)&&c.length===0)return null;const _=s.map(f=>{const g=f.positioned_relative_to_pcb_board_id;if(!g)return null;const y=i.find(b=>b.pcb_board_id===g);return y?{component:f,board:y,type:"component"}:null}).filter(f=>!!f),d=a.map(f=>{const g=f.positioned_relative_to_pcb_board_id;if(!g||!f.center)return null;const y=i.find(b=>b.pcb_board_id===g);return y?{group:f,board:y,type:"group"}:null}).filter(f=>!!f),m=[..._,...d];if(m.length===0)return null;const h=c.length===0,p=m.filter(f=>f.type==="component"?h||c.includes(f.component.pcb_component_id):h||l.has(f.group.pcb_group_id));if(p.length===0)return null;const x=p.map(f=>f.type==="component"?{id:`${f.board.pcb_board_id}-${f.component.pcb_component_id}-${f.type}`,anchor:f.board.center,anchor_id:f.board.pcb_board_id,target:f.component.center,type:"component",display_offset_x:f.component.display_offset_x,display_offset_y:f.component.display_offset_y}:{id:`${f.board.pcb_board_id}-${f.group.pcb_group_id}-${f.type}`,anchor:f.board.center,anchor_id:f.board.pcb_board_id,target:{x:f.group.anchor_position?.x??f.group.center.x,y:f.group.anchor_position?.y??f.group.center.y},type:"group",display_offset_x:f.group.display_offset_x,display_offset_y:f.group.display_offset_y}).filter(f=>!!f);return G.jsx(vPe,{targets:x,transform:n,containerWidth:o,containerHeight:r})},Z0o=({elements:t,highlightedPrimitives:e,transform:n,containerWidth:o,containerHeight:r})=>{const i=t.filter(f=>tyt(f)),s=t.filter(f=>a8(f)),a=e.map(f=>a8(f._parent_pcb_component)?f._parent_pcb_component.pcb_component_id:a8(f._element)?f._element.pcb_component_id:null).filter(f=>!!f),c=(f,g)=>{if(g.has(f))return;g.add(f);const y=i.find(b=>b.pcb_group_id===f);y?.position_mode==="relative_to_group_anchor"&&y.positioned_relative_to_pcb_group_id&&c(y.positioned_relative_to_pcb_group_id,g)},l=new Set;if(a.forEach(f=>{const g=s.find(y=>y.pcb_component_id===f);g&&(g.position_mode==="relative_to_group_anchor"&&g.positioned_relative_to_pcb_group_id&&c(g.positioned_relative_to_pcb_group_id,l),g.pcb_group_id&&c(g.pcb_group_id,l))}),!B_(f=>f.is_showing_group_anchor_offsets)&&a.length===0)return null;const _=s.map(f=>{if(f.position_mode==="relative_to_group_anchor"&&f.positioned_relative_to_pcb_group_id){const g=i.find(y=>y.pcb_group_id===f.positioned_relative_to_pcb_group_id);return g&&g.anchor_position?{component:f,parentGroup:g,type:"component"}:null}if(f.pcb_group_id){const g=i.find(y=>y.pcb_group_id===f.pcb_group_id);return g&&g.anchor_position?{component:f,parentGroup:g,type:"component"}:null}return null}).filter(f=>!!f),d=i.map(f=>{if(f.position_mode==="relative_to_group_anchor"&&f.positioned_relative_to_pcb_group_id){const g=i.find(y=>y.pcb_group_id===f.positioned_relative_to_pcb_group_id);if(g&&g.anchor_position&&f.anchor_position)return{group:f,parentGroup:g,type:"group"}}return null}).filter(f=>!!f),m=[..._,...d];if(m.length===0)return null;const h=a.length===0,p=m.filter(f=>f.type==="component"?h||a.includes(f.component.pcb_component_id):h||l.has(f.group.pcb_group_id)||l.has(f.parentGroup.pcb_group_id));if(p.length===0)return null;const x=p.map(f=>{const g=f.parentGroup.anchor_position;return g?f.type==="component"?f.component.center?{id:`${f.parentGroup.pcb_group_id}-${f.component.pcb_component_id}-${f.type}`,anchor:g,anchor_id:f.parentGroup.pcb_group_id,target:f.component.center,type:"component",display_offset_x:f.component.display_offset_x,display_offset_y:f.component.display_offset_y}:null:f.group.anchor_position?{id:`${f.parentGroup.pcb_group_id}-${f.group.pcb_group_id}-${f.type}`,anchor:g,anchor_id:f.parentGroup.pcb_group_id,target:f.group.anchor_position,type:"group",display_offset_x:f.group.display_offset_x,display_offset_y:f.group.display_offset_y}:null:null}).filter(f=>!!f);return G.jsx(vPe,{targets:x,transform:n,containerWidth:o,containerHeight:r})},e_o=(t,e)=>{const n=t.pcb_component_id,o=e.filter(r=>(r.type==="pcb_smtpad"||r.type==="pcb_plated_hole")&&r.pcb_component_id===n||r.type==="pcb_hole"&&r.pcb_component_id===n);return o.length===0?xPe([t]):xPe(o)},t_o=({elements:t,highlightedPrimitives:e,transform:n,containerWidth:o,containerHeight:r})=>{const i=new Map;for(const a of e)a8(a._parent_pcb_component)&&i.set(a._parent_pcb_component.pcb_component_id,a._parent_pcb_component),a8(a._element)&&i.set(a._element.pcb_component_id,a._element);if(i.size===0)return null;const s=[];for(const a of i.values()){const c=e_o(a,t);if(!c)continue;const l=a.positioned_relative_to_pcb_group_id??a.pcb_group_id,u=l?s8(t).pcb_group.get(l):null;s.push({component:a,bbox:c,group:u})}return s.length===0?null:G.jsx("div",{style:{position:"absolute",left:0,top:0,width:o,height:r,overflow:"hidden",pointerEvents:"none",zIndex:bu.dimensionOverlay},children:G.jsx("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none"},width:o,height:r,children:s.map(({component:a,bbox:c,group:l})=>{const u=pt(n,{x:c.minX,y:c.maxY}),_=pt(n,{x:c.maxX,y:c.minY}),d={x:Math.min(u.x,_.x),y:Math.min(u.y,_.y),width:Math.abs(_.x-u.x),height:Math.abs(_.y-u.y)},m=a.center??{x:(c.minX+c.maxX)/2,y:(c.minY+c.maxY)/2},h=pt(n,m);return G.jsxs("g",{children:[G.jsx("rect",{x:d.x,y:d.y,width:d.width,height:d.height,fill:"none",stroke:"white",strokeWidth:1.5,strokeDasharray:"4,4"}),G.jsx("line",{x1:h.x-6,y1:h.y,x2:h.x+6,y2:h.y,stroke:Ky.COMPONENT_MARKER_STROKE,strokeWidth:1.5}),G.jsx("line",{x1:h.x,y1:h.y-6,x2:h.x,y2:h.y+6,stroke:Ky.COMPONENT_MARKER_STROKE,strokeWidth:1.5}),G.jsx("circle",{cx:h.x,cy:h.y,r:Ju.COMPONENT_MARKER_RADIUS,fill:Ky.COMPONENT_MARKER_FILL,stroke:Ky.COMPONENT_MARKER_STROKE,strokeWidth:1})]},a.pcb_component_id)})})})},n_o=({elements:t,highlightedPrimitives:e,transform:n,containerWidth:o,containerHeight:r})=>{const i=t.filter(m=>J0o(m)),s=t.filter(m=>PPe(m)),a=e.map(m=>PPe(m._element)?m._element.pcb_board_id:null).filter(m=>!!m);if(!B_(m=>m.is_showing_group_anchor_offsets)&&a.length===0)return null;const l=s.map(m=>{const h=m.pcb_panel_id,p=m.position_mode;if(!h||p!=="relative_to_panel_anchor")return null;const x=i.find(f=>f.pcb_panel_id===h);return x?{board:m,panel:x,type:"board"}:null}).filter(m=>!!m);if(l.length===0)return null;const u=a.length===0,_=l.filter(m=>u||a.includes(m.board.pcb_board_id));if(_.length===0)return null;const d=_.map(m=>m.board.center?{id:`${m.panel.pcb_panel_id}-${m.board.pcb_board_id}-${m.type}`,anchor:m.panel.center,anchor_id:m.panel.pcb_panel_id,target:m.board.center,type:"board",display_offset_x:m.board.display_offset_x,display_offset_y:m.board.display_offset_y}:null).filter(m=>!!m);return G.jsx(vPe,{targets:d,transform:n,containerWidth:o,containerHeight:r})},iQ=t=>{if(t.length===0)return null;let e=t[0].x,n=t[0].y,o=t[0].x,r=t[0].y;for(const i of t)i.x<e&&(e=i.x),i.y<n&&(n=i.y),i.x>o&&(o=i.x),i.y>r&&(r=i.y);return{center:{x:(e+o)/2,y:(n+r)/2},width:o-e,height:r-n}},nyt=(t,e)=>{if(e.length<3)return!1;let n=!1;for(let o=0,r=e.length-1;o<e.length;r=o++){const i=e[o].x,s=e[o].y,a=e[r].x,c=e[r].y;s>t.y!=c>t.y&&t.x<(a-i)*(t.y-s)/(c-s||Number.EPSILON)+i&&(n=!n)}return n},o_o=(t,e,n)=>{const o=[];for(const r of t){if(!r._element)continue;if("x1"in r&&r._element?.type==="pcb_trace"){const a=vf({x:e.x,y:e.y},{x:r.x1,y:r.y1},{x:r.x2,y:r.y2}),c=r.width||.5,l=Math.max(c*25,2)/n.a;a<l&&o.push(r);continue}if(r.pcb_drawing_type==="polygon"){const a=r.points.map(l=>({x:Ze.parse(l.x),y:Ze.parse(l.y)})),c=iQ(a);if(!c||e.x<c.center.x-c.width/2||e.x>c.center.x+c.width/2||e.y<c.center.y-c.height/2||e.y>c.center.y+c.height/2)continue;nyt(e,a)&&o.push(r);continue}if(r.pcb_drawing_type==="polygon_with_arcs"){const a=r.brep_shape.outer_ring.vertices.map(l=>({x:Ze.parse(l.x),y:Ze.parse(l.y)})),c=iQ(a);if(!c||e.x<c.center.x-c.width/2||e.x>c.center.x+c.width/2||e.y<c.center.y-c.height/2||e.y>c.center.y+c.height/2)continue;nyt(e,a)&&o.push(r);continue}if(!("x"in r&&"y"in r))continue;let i=0,s=0;if("w"in r&&"h"in r)i=r.w,s=r.h;else if("r"in r)i=r.r*2,s=r.r*2;else if("rX"in r&&"rY"in r)i=r.rX*2,s=r.rY*2;else continue;Math.abs(r.x-e.x)<i/2&&Math.abs(r.y-e.y)<s/2&&o.push(r)}return o},r_o=({elements:t,children:e,transform:n,primitives:o,onMouseHoverOverPrimitives:r})=>{const[i,s]=Y.useState([]),[a,c]=Y.useState({x:0,y:0}),[l,{width:u,height:_}]=nF(),d=Y.useMemo(()=>{const h=[];for(const p of i){if(p._element?.type==="pcb_via"||p._element?.type==="pcb_component"||p?.layer==="drill"||p?.is_hoverable===!1)continue;let x=null,f=0,g=0;if(p.pcb_drawing_type==="polygon"){const S=iQ(p.points);if(!S)continue;x=S.center,f=S.width,g=S.height}else if(p.pcb_drawing_type==="polygon_with_arcs"){const S=p.brep_shape.outer_ring.vertices.map(T=>({x:T.x,y:T.y})),M=iQ(S);if(!M)continue;x=M.center,f=M.width,g=M.height}else"x"in p&&"y"in p&&(x={x:p.x,y:p.y},f="w"in p?p.w:"r"in p?p.r*2:"rX"in p&&"rY"in p?p.rX*2:0,g="h"in p?p.h:"r"in p?p.r*2:"rX"in p&&"rY"in p?p.rY*2:0);if(!x)continue;const y=pt(n,x),b={w:f*n.a,h:g*n.a},v=h.filter(S=>y.x===S.screen_x&&y.y===S.screen_y&&b.w===S.screen_w&&b.h===S.screen_h).length;h.push({...p,x:x.x,y:x.y,w:f,h:g,screen_x:y.x,screen_y:y.y,screen_w:b.w,screen_h:b.h,same_space_index:v})}return h},[i,n]),m=(h,p,x,f)=>{c({x:h,y:p});const g=pt(z5(x),{x:h,y:p}),y=o_o(f,g,x);W0o(new Set(y.map(b=>b._pcb_drawing_object_id)),new Set(i.map(b=>b._pcb_drawing_object_id)))||(s(y),r(y))};return G.jsxs("div",{ref:l,style:{position:"relative",width:"100%",height:"100%"},onMouseMove:h=>{if(n){const p=h.currentTarget.getBoundingClientRect(),x=h.clientX-p.left,f=h.clientY-p.top;m(x,f,n,o)}},onTouchStart:h=>{if(n){const p=h.touches[0],x=h.currentTarget.getBoundingClientRect(),f=p.clientX-x.left,g=p.clientY-x.top;m(f,g,n,o)}},children:[e,G.jsx(K0o,{elements:t,mousePos:a,highlightedPrimitives:d}),n&&G.jsxs(G.Fragment,{children:[G.jsx(Q0o,{elements:t,highlightedPrimitives:d,transform:n,containerWidth:u,containerHeight:_}),G.jsx(Z0o,{elements:t,highlightedPrimitives:d,transform:n,containerWidth:u,containerHeight:_}),G.jsx(t_o,{elements:t,highlightedPrimitives:d,transform:n,containerWidth:u,containerHeight:_}),G.jsx(n_o,{elements:t,highlightedPrimitives:d,transform:n,containerWidth:u,containerHeight:_})]})]})},oyt=["rgb(255, 100, 100)","rgb(100, 255, 100)","rgb(100, 100, 255)","rgb(255, 255, 100)","rgb(255, 100, 255)","rgb(100, 255, 255)","rgb(255, 150, 100)","rgb(150, 100, 255)","rgb(100, 255, 150)","rgb(255, 100, 150)"],i_o=({children:t,transform:e=Sl(),elements:n=[],hoveredComponentIds:o=[]})=>{const[r,{width:i,height:s}]=nF(),a=Y.useRef(null),{is_showing_pcb_groups:c,pcb_group_view_mode:l,is_showing_group_anchor_offsets:u}=B_(_=>({is_showing_pcb_groups:_.is_showing_pcb_groups,pcb_group_view_mode:_.pcb_group_view_mode,is_showing_group_anchor_offsets:_.is_showing_group_anchor_offsets}));return Y.useEffect(()=>{const _=a.current;if(!_||!i||!s)return;_.width=i,_.height=s;const d=_.getContext("2d");if(!d||(d.clearRect(0,0,i,s),!c))return;const m=n.filter(S=>S.type==="pcb_group"),h=n.filter(S=>S.type==="pcb_component"),p=n.filter(S=>S.type==="source_group"),x=new Map(p.map(S=>[S.source_group_id,S])),f=m.filter(S=>{if(S.name?.toLowerCase().includes("subpanel"))return!1;if(l==="all")return!0;if(!S.source_group_id)return!1;const M=x.get(S.source_group_id);return M?M.was_automatically_named!==!0:!1}),g=new Map;p.forEach(S=>{const M=S;if(M.parent_source_group_id){const T=g.get(M.parent_source_group_id)||[];T.push(S.source_group_id),g.set(M.parent_source_group_id,T)}});const y=S=>{const M=[],T=g.get(S)||[];for(const D of T)M.push(D),M.push(...y(D));return M},b=S=>{const M=p.find(T=>T.source_group_id===S);return M?.parent_source_group_id?1+b(M.parent_source_group_id):0},v=new Set;if(o.length>0)for(const S of h){if(!o.includes(S.pcb_component_id))continue;const M=S.positioned_relative_to_pcb_group_id??S.pcb_group_id;M&&v.add(M)}f.forEach((S,M)=>{let T=h.filter(Oe=>Oe.pcb_group_id===S.pcb_group_id);if(S.source_group_id){const Oe=y(S.source_group_id),$e=m.filter(Ie=>Ie.source_group_id&&Oe.includes(Ie.source_group_id));for(const Ie of $e){const Te=h.filter(Ae=>Ae.pcb_group_id===Ie.pcb_group_id);T=[...T,...Te]}}let D,A,L,H,F=!1;if(S.center&&S.width&&S.height){F=!0;const Oe=S.width/2,$e=S.height/2;D=S.center.x-Oe,L=S.center.x+Oe,A=S.center.y-$e,H=S.center.y+$e}else if(T.length===0||(D=1/0,A=1/0,L=-1/0,H=-1/0,T.forEach(Oe=>{if(Oe.center&&typeof Oe.width=="number"&&typeof Oe.height=="number"){const $e=Oe.center.x-Oe.width/2,Ie=Oe.center.x+Oe.width/2,Te=Oe.center.y+Oe.height/2,Ae=Oe.center.y-Oe.height/2;D=Math.min(D,$e),L=Math.max(L,Ie),A=Math.min(A,Ae),H=Math.max(H,Te)}}),D===1/0||L===-1/0))return;const B=S.source_group_id?b(S.source_group_id):0,V=S.source_group_id?y(S.source_group_id).length>0:!1;if(!F){const Ie=1+(V?.5:0);D-=Ie,L+=Ie,A-=Ie,H+=Ie}const X=pt(e,{x:D,y:H}),K=pt(e,{x:L,y:H}),J=pt(e,{x:D,y:A}),oe=pt(e,{x:L,y:A}),ue=oyt[M%oyt.length];d.strokeStyle=ue,d.lineWidth=2;const ne=Math.max(4,Math.min(12,8*Math.abs(e.a))),re=Math.max(2,Math.min(6,4*Math.abs(e.a))),se=ne*(V?1.3:1),me=re;d.setLineDash([se,me]),d.beginPath(),d.moveTo(X.x,X.y),d.lineTo(K.x,K.y),d.lineTo(oe.x,oe.y),d.lineTo(J.x,J.y),d.closePath(),d.stroke();const Pe=Math.max(8,Math.min(12,10*Math.abs(e.a))),Me=B==0||B==1?0:B*.11,Ee=Pe*(1-Me),_e=4,Ce=S.name||`Group ${M+1}`;d.font=`${Ee}px sans-serif`,d.setLineDash([]);const Fe=d.measureText(Ce).width+_e*2,Xe=Ee+_e*2,et=X.x-5,ge=X.y-5,Ke=3;if(d.fillStyle="rgba(0, 0, 0, 0.8)",d.beginPath(),d.roundRect(et,ge-Xe,Fe,Xe,Ke),d.fill(),d.fillStyle=ue,d.textAlign="left",d.textBaseline="middle",d.fillText(Ce,et+_e,ge-Xe/2),u&&v.has(S.pcb_group_id)&&!!S.anchor_position&&S.anchor_position){const Oe=Array.isArray(S.anchor_position)?{x:S.anchor_position[0]??0,y:S.anchor_position[1]??0}:{x:S.anchor_position.x,y:S.anchor_position.y},$e=pt(e,Oe);d.strokeStyle="white",d.lineWidth=1.5,d.setLineDash([]);const Ie=Math.max(4,Math.min(8,6*Math.abs(e.a)));d.beginPath(),d.moveTo($e.x-Ie,$e.y),d.lineTo($e.x+Ie,$e.y),d.stroke(),d.beginPath(),d.moveTo($e.x,$e.y-Ie),d.lineTo($e.x,$e.y+Ie),d.stroke()}})},[n,e,i,s,c,l,u,o]),G.jsxs("div",{ref:r,style:{position:"relative",width:"100%",height:"100%"},children:[t,G.jsx("canvas",{ref:a,style:{position:"absolute",top:0,left:0,pointerEvents:"none",zIndex:bu.pcbGroupOverlay,display:c?"block":"none"}})]})},s_o=({transform:t,soup:e,children:n})=>{const o=B_(a=>a.is_showing_rats_nest),{netMap:r,idToNetMap:i}=Y.useMemo(()=>wgt(e||[]),[e]),s=Y.useMemo(()=>{if(!e||!o)return[];const a=d=>{const m=s8(e)[d.replace(/_\d+$/,"")].get(d);return m&&"x"in m&&"y"in m?{x:m.x,y:m.y}:null},c=(d,m)=>{const h=r[m]||[];let p=null,x=1/0;return h.forEach(f=>{const g=a(f);if(g){const y=Math.sqrt((d.x-g.x)**2+(d.y-g.y)**2);y<x&&y>0&&(x=y,p=g)}}),p},l=s8(e).pcb_port.list(),u=s8(e).source_trace.list(),_=[];return l.forEach((d,m)=>{const h=i[d.pcb_port_id];let p=!1;for(const g of u)g.connected_source_port_ids.includes(d.source_port_id)&&g.connected_source_net_ids.length>0&&(p=!0);if(!h)return;const x={x:d.x,y:d.y},f=c(x,h);f&&_.push({key:`${d.pcb_port_id}-${m}`,startPoint:x,endPoint:f,isInNet:p})}),_},[e,r,i,o]);return!e||!o?n:(t||(t=Sl()),G.jsxs("div",{style:{position:"relative"},children:[n,G.jsx("svg",{style:{position:"absolute",left:0,top:0,width:"100%",height:"100%",pointerEvents:"none",opacity:.5,zIndex:bu.ratsNestOverlay},children:s.map(({key:a,startPoint:c,endPoint:l,isInNet:u})=>{const _=pt(t,c),d=pt(t,l);return G.jsx("line",{x1:_.x,y1:_.y,x2:d.x,y2:d.y,stroke:"white",strokeWidth:"1",strokeDasharray:u?"6,6":void 0},a)})})]}))},a_o={version:"1.11.367"},c8=(t,e,n)=>{const o=B_(s=>s.is_mouse_over_container),r=Y.useRef(o),i=Y.useRef(e);Y.useEffect(()=>{r.current=o},[o]),Y.useEffect(()=>{i.current=e},[e]),Y.useEffect(()=>{if(!t)return;const s=a=>{const c=a.target;if(c.tagName==="INPUT"||c.tagName==="TEXTAREA"||c.isContentEditable)return;const l=t.split("+"),u=l.includes("ctrl"),_=l.includes("shift"),d=l.includes("alt"),m=l.includes("meta"),h=l[l.length-1],p=n?.current?n.current.contains(document.activeElement)||document.activeElement===n.current:!1;(r.current||p)&&(!u||a.ctrlKey)&&(!_||a.shiftKey)&&(!d||a.altKey)&&(!m||a.metaKey)&&a.key.toLowerCase()===h.toLowerCase()&&(a.preventDefault(),i.current())};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s)}},[t])},c_o=()=>{const[t,e]=Y.useState(!1);return Y.useEffect(()=>{const n=()=>{e(window.innerWidth<=768)};return n(),window.addEventListener("resize",n),()=>window.removeEventListener("resize",n)},[]),t},rF=(t,e={stopPropagation:!0})=>{const n=Y.useRef(0),o=Y.useCallback(s=>{e.stopPropagation&&s.stopPropagation();const a=Date.now();a-n.current<300||(n.current=a,t?.(s))},[t,e.stopPropagation]),r=Y.useCallback(s=>{s.preventDefault(),o(s)},[o]);return{onClick:o,onTouchEnd:r,style:{touchAction:"manipulation"}}},BM=({children:t,isSmallScreen:e,onClick:n,...o})=>{const{style:r,...i}=rF(n);return G.jsx("div",{...o,...i,style:{backgroundColor:"#1F1F1F",border:"1px solid #666",margin:0,padding:4,paddingLeft:e?8:6,paddingRight:e?8:6,borderRadius:2,color:"#eee",cursor:"pointer",fontSize:12,height:"fit-content",userSelect:"none",whiteSpace:"nowrap",...r,...o.style},children:t})},l_o=t=>{const e=new Map;return t.forEach((n,o)=>{const r=n.error_type||"unknown_error",i=e.get(r)||[];i.push({error:n,index:o,errorId:dk(n,o)}),e.set(r,i)}),Array.from(e.entries()).map(([n,o])=>({errorType:n,errors:o}))},u_o=({onClose:t,setHoveredErrorId:e,setFocusedErrorId:n,highlightDurationMs:o=3e3})=>{const r=Y.useRef(null),i=Y.useRef(null),s=Y.useRef(null),a=Y.useCallback(()=>{r.current!==null&&(window.clearTimeout(r.current),r.current=null),i.current!==null&&(window.cancelAnimationFrame(i.current),i.current=null)},[]);Y.useEffect(()=>a,[a]);const c=Y.useCallback(u=>{a(),s.current=u,e(u),n(null),i.current=window.requestAnimationFrame(()=>{n(u),i.current=null}),t(),r.current=window.setTimeout(()=>{s.current=null,e(null),n(null),r.current=null},o)},[a,o,t,n,e]),l=Y.useCallback(u=>s.current===u,[]);return{handleErrorSelect:c,isSelectedError:l}},__o=({errorId:t,errorMessage:e,copiedErrorId:n,onCopy:o})=>{const{style:r,...i}=rF(()=>o(e,t));return G.jsx("button",{type:"button","aria-label":n===t?"Error message copied":"Copy error message",style:{position:"absolute",top:12,right:16,cursor:"pointer",color:"#888",fontSize:16,background:"none",border:"none",padding:0,display:"flex",alignItems:"center",...r},...i,children:n===t?G.jsx("span",{style:{color:"#4caf50",fontSize:12},children:"Copied!"}):G.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:G.jsx("path",{d:"M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"})})})},d_o=({elements:t,isOpen:e,isSmallScreen:n,onToggle:o,onClose:r,setHoveredErrorId:i,setFocusedErrorId:s})=>{const[a,c]=Y.useState(null),[l,u]=Y.useState(new Set),[_,d]=Y.useState(new Set),[,m]=Klo(),{handleErrorSelect:h,isSelectedError:p}=u_o({onClose:r,setHoveredErrorId:i,setFocusedErrorId:s}),x=Y.useMemo(()=>t?.filter(v=>v.type.includes("error"))??[],[t]),f=x.length,g=Y.useMemo(()=>l_o(x),[x]),y=Y.useCallback(v=>{u(S=>{const M=new Set(S);return M.has(v)?M.delete(v):M.add(v),M})},[]),b=Y.useCallback(v=>{d(S=>{const M=new Set(S);return M.has(v)?M.delete(v):M.add(v),M})},[]);return G.jsxs("div",{style:{position:"relative"},children:[G.jsx(BM,{isSmallScreen:n,style:f>0?{color:"red"}:void 0,onClick:o,children:G.jsxs("div",{children:[f," errors"]})}),e&&f>0&&G.jsx("div",{style:{position:"absolute",top:"100%",left:0,backgroundColor:"#2a2a2a",border:"1px solid #666",borderRadius:4,marginTop:4,zIndex:1e3,minWidth:n?"280px":"400px",maxWidth:n?"90vw":"600px",maxHeight:"400px",overflow:"auto",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.3)"},children:g.map(({errorType:v,errors:S},M)=>{const T=l.has(v);return G.jsxs("div",{style:{borderBottom:M<g.length-1?"1px solid #444":"none"},children:[G.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 16px",cursor:"pointer",backgroundColor:"#232323",transition:"background-color 0.2s ease",touchAction:"manipulation",position:"sticky",top:0,zIndex:1},onMouseEnter:D=>{D.currentTarget.style.backgroundColor="#303030"},onMouseLeave:D=>{D.currentTarget.style.backgroundColor="#232323"},onTouchStart:D=>{D.stopPropagation(),D.currentTarget.style.backgroundColor="#303030"},onTouchEnd:D=>{D.stopPropagation(),D.preventDefault(),D.currentTarget.style.backgroundColor="#232323",y(v)},onClick:D=>{D.stopPropagation(),y(v)},children:[G.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,color:"#ff6b6b"},children:[G.jsx("div",{style:{color:"#888",fontSize:"16px",transform:T?"rotate(90deg)":"rotate(0deg)",transition:"transform 0.2s ease",flexShrink:0},children:"›"}),G.jsx("div",{style:{fontWeight:"bold",fontSize:n?"12px":"13px"},children:v})]}),G.jsx("div",{style:{fontSize:n?"12px":"13px",color:"#aaa",whiteSpace:"nowrap",marginLeft:12},children:S.length})]}),!T&&S.map(({error:D,index:A,errorId:L})=>{const H=_.has(L),F=D.message??"No error message";return G.jsxs("div",{style:{borderTop:"1px solid #3a3a3a"},children:[G.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"12px 16px 12px 24px",cursor:"pointer",backgroundColor:"#2a2a2a",transition:"background-color 0.2s ease",touchAction:"manipulation"},onMouseEnter:B=>{B.currentTarget.style.backgroundColor="#333",i(L)},onMouseLeave:B=>{B.currentTarget.style.backgroundColor="#2a2a2a",p(L)||i(null)},onTouchStart:B=>{B.stopPropagation(),B.currentTarget.style.backgroundColor="#333",i(L)},onTouchEnd:B=>{B.stopPropagation(),B.preventDefault(),B.currentTarget.style.backgroundColor="#2a2a2a",h(L)},onClick:B=>{B.stopPropagation(),h(L)},children:[G.jsx("div",{style:{flex:1,fontSize:n?"12px":"13px",color:"#ddd",lineHeight:1.4,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",userSelect:"text"},children:F}),G.jsx("button",{type:"button","aria-label":H?"Collapse error details":"Expand error details",style:{color:"#888",fontSize:"16px",transform:H?"rotate(0deg)":"rotate(90deg)",transition:"transform 0.2s ease",flexShrink:0,background:"none",border:"none",padding:0,cursor:"pointer"},onMouseDown:B=>B.stopPropagation(),onClick:B=>{B.stopPropagation(),b(L)},onTouchEnd:B=>{B.stopPropagation(),B.preventDefault(),b(L)},children:"›"})]}),H&&G.jsxs("div",{"data-error-id":A,style:{display:"block",padding:"12px 16px 12px 24px",backgroundColor:"#1a1a1a",borderTop:"1px solid #444",position:"relative"},children:[G.jsx("div",{style:{fontSize:n?"11px":"12px",color:"#ccc",lineHeight:1.5,wordWrap:"break-word",overflowWrap:"break-word",hyphens:"auto",userSelect:"text",paddingRight:30},onMouseDown:B=>B.stopPropagation(),onClick:B=>B.stopPropagation(),children:F}),G.jsx(__o,{errorId:L,errorMessage:F,copiedErrorId:a,onCopy:(B,V)=>{m(B),c(V),setTimeout(()=>c(null),2e3)}})]})]},L)})]},v)})})]})},h_o=({name:t,selected:e,onClick:n})=>{const{style:o,...r}=rF(n);return G.jsxs("div",{className:_k`
|
|
5520
|
+
`,$0o=({children:t,transform:e=Sl(),elements:n})=>{const o=Y.useRef(null),{isShowingDRCErrors:r,hoveredErrorId:i,focusedErrorId:s}=B_(p=>({isShowingDRCErrors:p.is_showing_drc_errors,hoveredErrorId:p.hovered_error_id,focusedErrorId:p.focused_error_id})),a=s??i;if(!n)return G.jsx("div",{style:{position:"relative"},ref:o,children:t});const c=n.filter(p=>p.type==="pcb_trace_error"&&!p.message?.includes("Multiple components found with name")),l=n.filter(p=>p.type==="pcb_via_clearance_error"),u=n.filter(p=>p.type==="pcb_trace_error"&&p.message?.includes("Multiple components found with name")),_=Dgt(n),d=Egt(n,a),m=p=>{const x=luo({error:p,indexes:_});if(!x||typeof x.x!="number"||typeof x.y!="number")return null;const f=pt(e,x);return Number.isNaN(f.x)||Number.isNaN(f.y)?null:f};let h=null;return d&&(h=m(d)),G.jsxs("div",{style:{position:"relative"},ref:o,children:[t,c.map((p,x)=>{const f=dk(p,x),g=a===f;if(!g&&!r)return null;const y=m(p);if(!y)return null;const b=yPe(y,o);return G.jsxs(Y.Fragment,{children:[G.jsx(eyt,{errorCenter:y,isHighlighted:g}),G.jsx("div",{style:{position:"absolute",left:y.x-15,top:y.y-15,width:30,height:30,zIndex:bu.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:v=>{const S=v.currentTarget.nextElementSibling;if(S){const M=S.querySelector(".error-message");M&&(M.style.opacity="1")}},onMouseLeave:v=>{if(!g){const S=v.currentTarget.nextElementSibling;if(S){const M=S.querySelector(".error-message");M&&(M.style.opacity="0")}}}}),G.jsx("div",{style:{position:"absolute",zIndex:g?200:100,left:b.left,top:b.top,color:g?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:r||g?"flex":"none",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:b.transform},children:G.jsx("div",{className:`error-message ${bPe}`,style:{opacity:g?1:0,border:`1px solid ${g?"#ff4444":"red"}`},children:p.message})})]},f)}),l.map((p,x)=>{const f=dk(p,x),g=a===f;if(!g&&!r)return null;const y=m(p);if(!y)return null;const b=yPe({x:y.x,y:y.y},o);return G.jsxs(Y.Fragment,{children:[G.jsx(eyt,{errorCenter:y,isHighlighted:g}),G.jsx("div",{style:{position:"absolute",left:y.x-15,top:y.y-15,width:30,height:30,zIndex:bu.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:v=>{const S=v.currentTarget.nextElementSibling;if(S){const M=S.querySelector(".error-message");M&&(M.style.opacity="1")}},onMouseLeave:v=>{if(!g){const S=v.currentTarget.nextElementSibling;if(S){const M=S.querySelector(".error-message");M&&(M.style.opacity="0")}}}}),G.jsx("div",{style:{position:"absolute",zIndex:g?bu.errorOverlay+10:bu.errorOverlay+1,left:b.left,top:b.top,color:g?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:"flex",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:b.transform},children:G.jsx("div",{className:`error-message ${bPe}`,style:{opacity:g?1:0,border:`1px solid ${g?"#ff4444":"red"}`},children:p.message})})]},f)}),u.map((p,x)=>{const f=p.component_name||p.message?.match(/name "([^"]+)"/)?.[1];if(!f)return null;const g=n?.filter(v=>v.type==="source_component"&&v.name===f||v.type==="pcb_component"&&n?.find(S=>S.type==="source_component"&&S.source_component_id===v.source_component_id&&S.name===f))||[],y=dk(p,x),b=a===y;return!b&&!r?null:g.map((v,S)=>{let M={x:0,y:0};if(v.type==="pcb_component")M=v.center||{x:0,y:0};else if(v.type==="source_component"){const V=n?.find(X=>X.type==="pcb_component"&&X.source_component_id===v.source_component_id);V&&V.type==="pcb_component"&&(M=V.center||{x:0,y:0})}const T=pt(e,M);if(Number.isNaN(T.x)||Number.isNaN(T.y))return null;const D=Math.abs(e.a),F=Math.max(8,Math.min(30,.5*D)),B=yPe(T,o);return G.jsxs(Y.Fragment,{children:[G.jsx("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none",mixBlendMode:"difference",zIndex:bu.errorOverlay},width:"100%",height:"100%",children:b?G.jsx("polygon",{points:`${T.x},${T.y-F*1.25} ${T.x+F},${T.y} ${T.x},${T.y+F*1.25} ${T.x-F},${T.y}`,fill:"#ff4444"}):G.jsx("circle",{cx:T.x,cy:T.y,r:F,fill:"none",stroke:b?"#ff4444":"red",strokeWidth:b?Math.max(2,F*.15):Math.max(1,F*.1),opacity:1})}),G.jsx("div",{style:{position:"absolute",left:T.x-(F+10),top:T.y-(F+10),width:(F+10)*2,height:(F+10)*2,zIndex:bu.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:V=>{const X=V.currentTarget.nextElementSibling;if(X){const K=X.querySelector(".error-message");K&&(K.style.opacity="1")}},onMouseLeave:V=>{if(!b){const X=V.currentTarget.nextElementSibling;if(X){const K=X.querySelector(".error-message");K&&(K.style.opacity="0")}}}}),G.jsx("div",{style:{position:"absolute",zIndex:b?bu.errorOverlay+20:bu.errorOverlay+10,left:B.left,top:B.top,color:b?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:r||b?"flex":"none",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:B.transform},children:G.jsx("div",{className:`error-message ${bPe}`,style:{opacity:b?1:0,border:`1px solid ${b?"#ff4444":"red"}`},children:p.message})})]},`${y}_${S}`)})}),h&&G.jsx(V0o,{center:h})]})};function W0o(t,e){return t.size!==e.size?!1:Array.from(t).every(n=>e.has(n))}function j0o({primitiveElement:t,elements:e}){let n=t.trace_length?`${t.trace_length.toFixed(3)}`:"";const o=s8(e).source_trace.get(t?.source_trace_id);if(o?.display_name&&(o?.max_length?n+=` / ${o.max_length}mm `:n+=" mm ",n+=`(${o.display_name})`),!n)return null;const r=t.trace_length&&o?.max_length&&t.trace_length>o.max_length;return{text:n,isOverLength:r}}function U0o(t){const{primitives:e,is_showing_multiple_traces_length:n,elements:o}=t,r=e.filter(c=>c._element.type==="pcb_trace"),i=o.filter(c=>c.type==="source_trace"),s=e.filter(c=>c._element.type!=="pcb_trace"),a=r.filter(c=>i.some(l=>c._element.type==="pcb_trace"&&c._element.source_trace_id===l.source_trace_id&&l.max_length!==void 0));if(!n)return[...s,...a];if(r.length>1){const c=r.reduce((l,u)=>{const _=l._element.trace_length;return u._element.trace_length<_?u:l},r[0]);return[...s,c]}return e}var X0o={position:"absolute",left:0,top:0,pointerEvents:"none",color:"red",fontFamily:"sans-serif",fontSize:12,textShadow:"0 0 2px black"},G0o=t=>{const{_element:e,_parent_pcb_component:n,_parent_source_component:o,_source_port:r}=t;switch(e.type){case"pcb_trace":return e.trace_length?`${e.trace_length.toFixed(3)}`:"";case"pcb_smtpad":case"pcb_plated_hole":{const i=[],s=Array.from(new Set((e.port_hints??[]).concat(r?.port_hints??[]))).filter(c=>!/^[0-9]+$/.test(c)).filter(c=>!c.includes("unnamed_")).sort((c,l)=>l.localeCompare(c)),a=o&&"name"in o&&o.name&&!o.name.includes("unnamed_")?o.name:null;return s.length>0?a?i.push(...s.map(c=>`${a}.${c}`)):i.push(...s):a&&i.push(a),i.join(", ")}default:return""}},Y0o={top:"red",bottom:"aqua"},q0o=({primitive:t,mousePos:e,elements:n})=>{const[o,r]=Y.useState(!1),i=t._element;Y.useEffect(()=>{setTimeout(()=>{r(!0)},100)},[]);const[s,a,c,l]=[t.screen_x,t.screen_y,t.screen_w,t.screen_h],u=t.same_space_index??0,_=26,d=Y0o[t?._element?.layer]??"red";let m=0;if(i.type==="pcb_smtpad"&&i?.shape==="rotated_rect"?m=i?.ccw_rotation??0:(i.type==="pcb_smtpad"&&(i?.shape==="pill"||i?.shape==="rotated_pill")&&"ccw_rotation"in t||i.type==="pcb_plated_hole"&&(i?.shape==="pill"||i?.shape==="oval")&&"ccw_rotation"in t)&&(m=i.ccw_rotation??0),i.type==="pcb_trace"){const x=j0o({primitiveElement:i,elements:n});if(!x)return null;const f=e.y-35;return G.jsx("div",{style:{zIndex:bu.elementOverlay,position:"absolute",left:e.x,top:f,color:d,pointerEvents:"none",transform:"translateX(-50%)"},children:G.jsx("div",{style:{backgroundColor:"#f2efcc",color:x.isOverLength?"red":"black",textShadow:"none",WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale",padding:"6px 6px",borderRadius:"6px",fontSize:"14px",minWidth:"45px",textAlign:"center",whiteSpace:"nowrap"},children:x.text})})}const h=G0o(t);return h.trim().length===0?null:G.jsx("div",{style:{zIndex:bu.elementOverlay,position:"absolute",left:s-c/2-8,top:a-l/2-8,width:c+16,height:l+16,color:d,transform:`rotate(${-m}deg)`,transformOrigin:"center center"},children:G.jsx("div",{style:{width:o?`calc(100% + ${_*2*u}px)`:"100%",height:o?`calc(100% + ${_*2*u}px)`:"100%",marginLeft:o?`${-_*u}px`:0,marginTop:o?`${-_*u}px`:0,border:`1px solid ${d}`,opacity:o||u===0?1:0,transition:"width 0.2s, height 0.2s, margin-left 0.2s, margin-top 0.2s, opacity 0.2s"},children:G.jsx("div",{style:{position:"absolute",bottom:l+20+_*u,marginRight:o?`${-_*u}px`:0,marginBottom:o?0:-_*u,transition:"margin-right 0.2s, margin-bottom 0.2s",backgroundColor:"#f2efcc",color:"black",textShadow:"none",WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale",padding:"6px 6px",borderRadius:"6px",fontSize:"14px",transform:`rotate(${m}deg)`,minWidth:"45px",textAlign:"center"},children:h})})})},K0o=({highlightedPrimitives:t,mousePos:e,elements:n})=>{const[o,r]=B_(a=>[a.is_moving_component,a.is_showing_multiple_traces_length]),i=t.some(a=>a._element.type==="pcb_smtpad")&&t.some(a=>a._element.type==="pcb_trace");let s=t;return i&&(s=s.filter(a=>a._element.type==="pcb_smtpad")),s=U0o({primitives:s,is_showing_multiple_traces_length:r,elements:n}),G.jsx("div",{style:X0o,children:!o&&s.map((a,c)=>G.jsx(q0o,{primitive:a,mousePos:e,elements:n},c))})},a8=t=>t?.type==="pcb_component",tyt=t=>t?.type==="pcb_group",J0o=t=>t?.type==="pcb_panel",PPe=t=>t?.type==="pcb_board",Ju={MIN_LINE_LENGTH_FOR_LABEL:40,LABEL_OFFSET_ABOVE:2,LABEL_OFFSET_BELOW:-18,LABEL_OFFSET_RIGHT:8,LABEL_OFFSET_LEFT:-120,Y_LABEL_MIN_WIDTH:110,LINE_STROKE_WIDTH:1.5,LINE_DASH_PATTERN:"4,4",COMPONENT_MARKER_RADIUS:3,LABEL_FONT_SIZE:11,ANCHOR_MARKER_SIZE:6,ANCHOR_MARKER_STROKE_WIDTH:1.5},Ky={OFFSET_LINE:"white",COMPONENT_MARKER_FILL:"#66ccff",COMPONENT_MARKER_STROKE:"white",LABEL_TEXT:"white"},vPe=({targets:t,transform:e,containerWidth:n,containerHeight:o})=>{if(t.length===0)return null;const r={color:Ky.LABEL_TEXT,mixBlendMode:"difference",pointerEvents:"none",fontSize:Ju.LABEL_FONT_SIZE,fontFamily:"monospace",fontWeight:"bold"},i=new Map;return t.forEach(s=>{if(!i.has(s.anchor_id)){const a=pt(e,s.anchor);i.set(s.anchor_id,a)}}),G.jsx("div",{style:{position:"absolute",left:0,top:0,width:n,height:o,overflow:"hidden",pointerEvents:"none",zIndex:bu.dimensionOverlay},children:G.jsxs("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none"},width:n,height:o,children:[t.map(s=>{const a=s.anchor,c=s.anchor_id,l=s.target,u=i.get(c),_=pt(e,l),d=l.x-a.x,m=l.y-a.y,h=Math.abs(_.x-u.x),p=Math.abs(_.y-u.y),x=_.y<u.y,f=_.x>u.x,g=x?Ju.LABEL_OFFSET_ABOVE:Ju.LABEL_OFFSET_BELOW,y=f?Ju.LABEL_OFFSET_RIGHT:Ju.LABEL_OFFSET_LEFT,b=h>Ju.MIN_LINE_LENGTH_FOR_LABEL,v=p>Ju.MIN_LINE_LENGTH_FOR_LABEL,S=`${s.display_offset_x??d.toFixed(2)}mm`,M=`${s.display_offset_y??m.toFixed(2)}mm`;return G.jsxs("g",{children:[G.jsx("line",{x1:u.x,y1:u.y,x2:_.x,y2:u.y,stroke:Ky.OFFSET_LINE,strokeWidth:Ju.LINE_STROKE_WIDTH,strokeDasharray:Ju.LINE_DASH_PATTERN}),G.jsx("line",{x1:_.x,y1:u.y,x2:_.x,y2:_.y,stroke:Ky.OFFSET_LINE,strokeWidth:Ju.LINE_STROKE_WIDTH,strokeDasharray:Ju.LINE_DASH_PATTERN}),s.type==="component"||s.type==="board"?G.jsx("circle",{cx:_.x,cy:_.y,r:Ju.COMPONENT_MARKER_RADIUS,fill:Ky.COMPONENT_MARKER_FILL,stroke:Ky.COMPONENT_MARKER_STROKE,strokeWidth:1}):G.jsxs(G.Fragment,{children:[G.jsx("line",{x1:_.x-Ju.ANCHOR_MARKER_SIZE,y1:_.y,x2:_.x+Ju.ANCHOR_MARKER_SIZE,y2:_.y,stroke:Ky.OFFSET_LINE,strokeWidth:Ju.ANCHOR_MARKER_STROKE_WIDTH}),G.jsx("line",{x1:_.x,y1:_.y-Ju.ANCHOR_MARKER_SIZE,x2:_.x,y2:_.y+Ju.ANCHOR_MARKER_SIZE,stroke:Ky.OFFSET_LINE,strokeWidth:Ju.ANCHOR_MARKER_STROKE_WIDTH})]}),b&&G.jsx("foreignObject",{x:Math.min(u.x,_.x),y:u.y+g,width:Math.abs(_.x-u.x),height:20,style:{overflow:"visible"},children:G.jsx("div",{style:{...r,textAlign:"center"},children:S})}),v&&G.jsx("foreignObject",{x:_.x+y,y:Math.min(u.y,_.y),width:Ju.Y_LABEL_MIN_WIDTH,height:Math.abs(_.y-u.y),style:{overflow:"visible"},children:G.jsx("div",{style:{...r,display:"flex",alignItems:"center",justifyContent:f?"flex-start":"flex-end",whiteSpace:"nowrap",padding:"0 4px",height:"100%"},children:M})})]},s.id)}),Array.from(i.entries()).map(([s,a])=>G.jsxs("g",{children:[G.jsx("line",{x1:a.x-Ju.ANCHOR_MARKER_SIZE,y1:a.y,x2:a.x+Ju.ANCHOR_MARKER_SIZE,y2:a.y,stroke:Ky.OFFSET_LINE,strokeWidth:Ju.ANCHOR_MARKER_STROKE_WIDTH}),G.jsx("line",{x1:a.x,y1:a.y-Ju.ANCHOR_MARKER_SIZE,x2:a.x,y2:a.y+Ju.ANCHOR_MARKER_SIZE,stroke:Ky.OFFSET_LINE,strokeWidth:Ju.ANCHOR_MARKER_STROKE_WIDTH})]},`anchor-${s}`))]})})},Q0o=({elements:t,highlightedPrimitives:e,transform:n,containerWidth:o,containerHeight:r})=>{const i=t.filter(f=>PPe(f)),s=t.filter(f=>a8(f)),a=t.filter(f=>tyt(f)),c=e.map(f=>a8(f._parent_pcb_component)?f._parent_pcb_component.pcb_component_id:a8(f._element)?f._element.pcb_component_id:null).filter(f=>!!f),l=new Set;if(c.forEach(f=>{const g=s.find(y=>y.pcb_component_id===f);g?.pcb_group_id&&l.add(g.pcb_group_id)}),!B_(f=>f.is_showing_group_anchor_offsets)&&c.length===0)return null;const _=s.map(f=>{const g=f.positioned_relative_to_pcb_board_id;if(!g)return null;const y=i.find(b=>b.pcb_board_id===g);return y?{component:f,board:y,type:"component"}:null}).filter(f=>!!f),d=a.map(f=>{const g=f.positioned_relative_to_pcb_board_id;if(!g||!f.center)return null;const y=i.find(b=>b.pcb_board_id===g);return y?{group:f,board:y,type:"group"}:null}).filter(f=>!!f),m=[..._,...d];if(m.length===0)return null;const h=c.length===0,p=m.filter(f=>f.type==="component"?h||c.includes(f.component.pcb_component_id):h||l.has(f.group.pcb_group_id));if(p.length===0)return null;const x=p.map(f=>f.type==="component"?{id:`${f.board.pcb_board_id}-${f.component.pcb_component_id}-${f.type}`,anchor:f.board.center,anchor_id:f.board.pcb_board_id,target:f.component.center,type:"component",display_offset_x:f.component.display_offset_x,display_offset_y:f.component.display_offset_y}:{id:`${f.board.pcb_board_id}-${f.group.pcb_group_id}-${f.type}`,anchor:f.board.center,anchor_id:f.board.pcb_board_id,target:{x:f.group.anchor_position?.x??f.group.center.x,y:f.group.anchor_position?.y??f.group.center.y},type:"group",display_offset_x:f.group.display_offset_x,display_offset_y:f.group.display_offset_y}).filter(f=>!!f);return G.jsx(vPe,{targets:x,transform:n,containerWidth:o,containerHeight:r})},Z0o=({elements:t,highlightedPrimitives:e,transform:n,containerWidth:o,containerHeight:r})=>{const i=t.filter(f=>tyt(f)),s=t.filter(f=>a8(f)),a=e.map(f=>a8(f._parent_pcb_component)?f._parent_pcb_component.pcb_component_id:a8(f._element)?f._element.pcb_component_id:null).filter(f=>!!f),c=(f,g)=>{if(g.has(f))return;g.add(f);const y=i.find(b=>b.pcb_group_id===f);y?.position_mode==="relative_to_group_anchor"&&y.positioned_relative_to_pcb_group_id&&c(y.positioned_relative_to_pcb_group_id,g)},l=new Set;if(a.forEach(f=>{const g=s.find(y=>y.pcb_component_id===f);g&&(g.position_mode==="relative_to_group_anchor"&&g.positioned_relative_to_pcb_group_id&&c(g.positioned_relative_to_pcb_group_id,l),g.pcb_group_id&&c(g.pcb_group_id,l))}),!B_(f=>f.is_showing_group_anchor_offsets)&&a.length===0)return null;const _=s.map(f=>{if(f.position_mode==="relative_to_group_anchor"&&f.positioned_relative_to_pcb_group_id){const g=i.find(y=>y.pcb_group_id===f.positioned_relative_to_pcb_group_id);return g&&g.anchor_position?{component:f,parentGroup:g,type:"component"}:null}if(f.pcb_group_id){const g=i.find(y=>y.pcb_group_id===f.pcb_group_id);return g&&g.anchor_position?{component:f,parentGroup:g,type:"component"}:null}return null}).filter(f=>!!f),d=i.map(f=>{if(f.position_mode==="relative_to_group_anchor"&&f.positioned_relative_to_pcb_group_id){const g=i.find(y=>y.pcb_group_id===f.positioned_relative_to_pcb_group_id);if(g&&g.anchor_position&&f.anchor_position)return{group:f,parentGroup:g,type:"group"}}return null}).filter(f=>!!f),m=[..._,...d];if(m.length===0)return null;const h=a.length===0,p=m.filter(f=>f.type==="component"?h||a.includes(f.component.pcb_component_id):h||l.has(f.group.pcb_group_id)||l.has(f.parentGroup.pcb_group_id));if(p.length===0)return null;const x=p.map(f=>{const g=f.parentGroup.anchor_position;return g?f.type==="component"?f.component.center?{id:`${f.parentGroup.pcb_group_id}-${f.component.pcb_component_id}-${f.type}`,anchor:g,anchor_id:f.parentGroup.pcb_group_id,target:f.component.center,type:"component",display_offset_x:f.component.display_offset_x,display_offset_y:f.component.display_offset_y}:null:f.group.anchor_position?{id:`${f.parentGroup.pcb_group_id}-${f.group.pcb_group_id}-${f.type}`,anchor:g,anchor_id:f.parentGroup.pcb_group_id,target:f.group.anchor_position,type:"group",display_offset_x:f.group.display_offset_x,display_offset_y:f.group.display_offset_y}:null:null}).filter(f=>!!f);return G.jsx(vPe,{targets:x,transform:n,containerWidth:o,containerHeight:r})},e_o=(t,e)=>{const n=t.pcb_component_id,o=e.filter(r=>(r.type==="pcb_smtpad"||r.type==="pcb_plated_hole")&&r.pcb_component_id===n||r.type==="pcb_hole"&&r.pcb_component_id===n);return o.length===0?xPe([t]):xPe(o)},t_o=({elements:t,highlightedPrimitives:e,transform:n,containerWidth:o,containerHeight:r})=>{const i=new Map;for(const a of e)a8(a._parent_pcb_component)&&i.set(a._parent_pcb_component.pcb_component_id,a._parent_pcb_component),a8(a._element)&&i.set(a._element.pcb_component_id,a._element);if(i.size===0)return null;const s=[];for(const a of i.values()){const c=e_o(a,t);if(!c)continue;const l=a.positioned_relative_to_pcb_group_id??a.pcb_group_id,u=l?s8(t).pcb_group.get(l):null;s.push({component:a,bbox:c,group:u})}return s.length===0?null:G.jsx("div",{style:{position:"absolute",left:0,top:0,width:o,height:r,overflow:"hidden",pointerEvents:"none",zIndex:bu.dimensionOverlay},children:G.jsx("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none"},width:o,height:r,children:s.map(({component:a,bbox:c,group:l})=>{const u=pt(n,{x:c.minX,y:c.maxY}),_=pt(n,{x:c.maxX,y:c.minY}),d={x:Math.min(u.x,_.x),y:Math.min(u.y,_.y),width:Math.abs(_.x-u.x),height:Math.abs(_.y-u.y)},m=a.center??{x:(c.minX+c.maxX)/2,y:(c.minY+c.maxY)/2},h=pt(n,m);return G.jsxs("g",{children:[G.jsx("rect",{x:d.x,y:d.y,width:d.width,height:d.height,fill:"none",stroke:"white",strokeWidth:1.5,strokeDasharray:"4,4"}),G.jsx("line",{x1:h.x-6,y1:h.y,x2:h.x+6,y2:h.y,stroke:Ky.COMPONENT_MARKER_STROKE,strokeWidth:1.5}),G.jsx("line",{x1:h.x,y1:h.y-6,x2:h.x,y2:h.y+6,stroke:Ky.COMPONENT_MARKER_STROKE,strokeWidth:1.5}),G.jsx("circle",{cx:h.x,cy:h.y,r:Ju.COMPONENT_MARKER_RADIUS,fill:Ky.COMPONENT_MARKER_FILL,stroke:Ky.COMPONENT_MARKER_STROKE,strokeWidth:1})]},a.pcb_component_id)})})})},n_o=({elements:t,highlightedPrimitives:e,transform:n,containerWidth:o,containerHeight:r})=>{const i=t.filter(m=>J0o(m)),s=t.filter(m=>PPe(m)),a=e.map(m=>PPe(m._element)?m._element.pcb_board_id:null).filter(m=>!!m);if(!B_(m=>m.is_showing_group_anchor_offsets)&&a.length===0)return null;const l=s.map(m=>{const h=m.pcb_panel_id,p=m.position_mode;if(!h||p!=="relative_to_panel_anchor")return null;const x=i.find(f=>f.pcb_panel_id===h);return x?{board:m,panel:x,type:"board"}:null}).filter(m=>!!m);if(l.length===0)return null;const u=a.length===0,_=l.filter(m=>u||a.includes(m.board.pcb_board_id));if(_.length===0)return null;const d=_.map(m=>m.board.center?{id:`${m.panel.pcb_panel_id}-${m.board.pcb_board_id}-${m.type}`,anchor:m.panel.center,anchor_id:m.panel.pcb_panel_id,target:m.board.center,type:"board",display_offset_x:m.board.display_offset_x,display_offset_y:m.board.display_offset_y}:null).filter(m=>!!m);return G.jsx(vPe,{targets:d,transform:n,containerWidth:o,containerHeight:r})},iQ=t=>{if(t.length===0)return null;let e=t[0].x,n=t[0].y,o=t[0].x,r=t[0].y;for(const i of t)i.x<e&&(e=i.x),i.y<n&&(n=i.y),i.x>o&&(o=i.x),i.y>r&&(r=i.y);return{center:{x:(e+o)/2,y:(n+r)/2},width:o-e,height:r-n}},nyt=(t,e)=>{if(e.length<3)return!1;let n=!1;for(let o=0,r=e.length-1;o<e.length;r=o++){const i=e[o].x,s=e[o].y,a=e[r].x,c=e[r].y;s>t.y!=c>t.y&&t.x<(a-i)*(t.y-s)/(c-s||Number.EPSILON)+i&&(n=!n)}return n},o_o=(t,e,n)=>{const o=[];for(const r of t){if(!r._element)continue;if("x1"in r&&r._element?.type==="pcb_trace"){const a=vf({x:e.x,y:e.y},{x:r.x1,y:r.y1},{x:r.x2,y:r.y2}),c=r.width||.5,l=Math.max(c*25,2)/n.a;a<l&&o.push(r);continue}if(r.pcb_drawing_type==="polygon"){const a=r.points.map(l=>({x:Ze.parse(l.x),y:Ze.parse(l.y)})),c=iQ(a);if(!c||e.x<c.center.x-c.width/2||e.x>c.center.x+c.width/2||e.y<c.center.y-c.height/2||e.y>c.center.y+c.height/2)continue;nyt(e,a)&&o.push(r);continue}if(r.pcb_drawing_type==="polygon_with_arcs"){const a=r.brep_shape.outer_ring.vertices.map(l=>({x:Ze.parse(l.x),y:Ze.parse(l.y)})),c=iQ(a);if(!c||e.x<c.center.x-c.width/2||e.x>c.center.x+c.width/2||e.y<c.center.y-c.height/2||e.y>c.center.y+c.height/2)continue;nyt(e,a)&&o.push(r);continue}if(!("x"in r&&"y"in r))continue;let i=0,s=0;if("w"in r&&"h"in r)i=r.w,s=r.h;else if("r"in r)i=r.r*2,s=r.r*2;else if("rX"in r&&"rY"in r)i=r.rX*2,s=r.rY*2;else continue;Math.abs(r.x-e.x)<i/2&&Math.abs(r.y-e.y)<s/2&&o.push(r)}return o},r_o=({elements:t,children:e,transform:n,primitives:o,onMouseHoverOverPrimitives:r})=>{const[i,s]=Y.useState([]),[a,c]=Y.useState({x:0,y:0}),[l,{width:u,height:_}]=nF(),d=Y.useMemo(()=>{const h=[];for(const p of i){if(p._element?.type==="pcb_via"||p._element?.type==="pcb_component"||p?.layer==="drill"||p?.is_hoverable===!1)continue;let x=null,f=0,g=0;if(p.pcb_drawing_type==="polygon"){const S=iQ(p.points);if(!S)continue;x=S.center,f=S.width,g=S.height}else if(p.pcb_drawing_type==="polygon_with_arcs"){const S=p.brep_shape.outer_ring.vertices.map(T=>({x:T.x,y:T.y})),M=iQ(S);if(!M)continue;x=M.center,f=M.width,g=M.height}else"x"in p&&"y"in p&&(x={x:p.x,y:p.y},f="w"in p?p.w:"r"in p?p.r*2:"rX"in p&&"rY"in p?p.rX*2:0,g="h"in p?p.h:"r"in p?p.r*2:"rX"in p&&"rY"in p?p.rY*2:0);if(!x)continue;const y=pt(n,x),b={w:f*n.a,h:g*n.a},v=h.filter(S=>y.x===S.screen_x&&y.y===S.screen_y&&b.w===S.screen_w&&b.h===S.screen_h).length;h.push({...p,x:x.x,y:x.y,w:f,h:g,screen_x:y.x,screen_y:y.y,screen_w:b.w,screen_h:b.h,same_space_index:v})}return h},[i,n]),m=(h,p,x,f)=>{c({x:h,y:p});const g=pt(z5(x),{x:h,y:p}),y=o_o(f,g,x);W0o(new Set(y.map(b=>b._pcb_drawing_object_id)),new Set(i.map(b=>b._pcb_drawing_object_id)))||(s(y),r(y))};return G.jsxs("div",{ref:l,style:{position:"relative",width:"100%",height:"100%"},onMouseMove:h=>{if(n){const p=h.currentTarget.getBoundingClientRect(),x=h.clientX-p.left,f=h.clientY-p.top;m(x,f,n,o)}},onTouchStart:h=>{if(n){const p=h.touches[0],x=h.currentTarget.getBoundingClientRect(),f=p.clientX-x.left,g=p.clientY-x.top;m(f,g,n,o)}},children:[e,G.jsx(K0o,{elements:t,mousePos:a,highlightedPrimitives:d}),n&&G.jsxs(G.Fragment,{children:[G.jsx(Q0o,{elements:t,highlightedPrimitives:d,transform:n,containerWidth:u,containerHeight:_}),G.jsx(Z0o,{elements:t,highlightedPrimitives:d,transform:n,containerWidth:u,containerHeight:_}),G.jsx(t_o,{elements:t,highlightedPrimitives:d,transform:n,containerWidth:u,containerHeight:_}),G.jsx(n_o,{elements:t,highlightedPrimitives:d,transform:n,containerWidth:u,containerHeight:_})]})]})},oyt=["rgb(255, 100, 100)","rgb(100, 255, 100)","rgb(100, 100, 255)","rgb(255, 255, 100)","rgb(255, 100, 255)","rgb(100, 255, 255)","rgb(255, 150, 100)","rgb(150, 100, 255)","rgb(100, 255, 150)","rgb(255, 100, 150)"],i_o=({children:t,transform:e=Sl(),elements:n=[],hoveredComponentIds:o=[]})=>{const[r,{width:i,height:s}]=nF(),a=Y.useRef(null),{is_showing_pcb_groups:c,pcb_group_view_mode:l,is_showing_group_anchor_offsets:u}=B_(_=>({is_showing_pcb_groups:_.is_showing_pcb_groups,pcb_group_view_mode:_.pcb_group_view_mode,is_showing_group_anchor_offsets:_.is_showing_group_anchor_offsets}));return Y.useEffect(()=>{const _=a.current;if(!_||!i||!s)return;_.width=i,_.height=s;const d=_.getContext("2d");if(!d||(d.clearRect(0,0,i,s),!c))return;const m=n.filter(S=>S.type==="pcb_group"),h=n.filter(S=>S.type==="pcb_component"),p=n.filter(S=>S.type==="source_group"),x=new Map(p.map(S=>[S.source_group_id,S])),f=m.filter(S=>{if(S.name?.toLowerCase().includes("subpanel"))return!1;if(l==="all")return!0;if(!S.source_group_id)return!1;const M=x.get(S.source_group_id);return M?M.was_automatically_named!==!0:!1}),g=new Map;p.forEach(S=>{const M=S;if(M.parent_source_group_id){const T=g.get(M.parent_source_group_id)||[];T.push(S.source_group_id),g.set(M.parent_source_group_id,T)}});const y=S=>{const M=[],T=g.get(S)||[];for(const D of T)M.push(D),M.push(...y(D));return M},b=S=>{const M=p.find(T=>T.source_group_id===S);return M?.parent_source_group_id?1+b(M.parent_source_group_id):0},v=new Set;if(o.length>0)for(const S of h){if(!o.includes(S.pcb_component_id))continue;const M=S.positioned_relative_to_pcb_group_id??S.pcb_group_id;M&&v.add(M)}f.forEach((S,M)=>{let T=h.filter(Oe=>Oe.pcb_group_id===S.pcb_group_id);if(S.source_group_id){const Oe=y(S.source_group_id),$e=m.filter(Ie=>Ie.source_group_id&&Oe.includes(Ie.source_group_id));for(const Ie of $e){const Te=h.filter(Ae=>Ae.pcb_group_id===Ie.pcb_group_id);T=[...T,...Te]}}let D,A,L,H,F=!1;if(S.center&&S.width&&S.height){F=!0;const Oe=S.width/2,$e=S.height/2;D=S.center.x-Oe,L=S.center.x+Oe,A=S.center.y-$e,H=S.center.y+$e}else if(T.length===0||(D=1/0,A=1/0,L=-1/0,H=-1/0,T.forEach(Oe=>{if(Oe.center&&typeof Oe.width=="number"&&typeof Oe.height=="number"){const $e=Oe.center.x-Oe.width/2,Ie=Oe.center.x+Oe.width/2,Te=Oe.center.y+Oe.height/2,Ae=Oe.center.y-Oe.height/2;D=Math.min(D,$e),L=Math.max(L,Ie),A=Math.min(A,Ae),H=Math.max(H,Te)}}),D===1/0||L===-1/0))return;const B=S.source_group_id?b(S.source_group_id):0,V=S.source_group_id?y(S.source_group_id).length>0:!1;if(!F){const Ie=1+(V?.5:0);D-=Ie,L+=Ie,A-=Ie,H+=Ie}const X=pt(e,{x:D,y:H}),K=pt(e,{x:L,y:H}),J=pt(e,{x:D,y:A}),oe=pt(e,{x:L,y:A}),ue=oyt[M%oyt.length];d.strokeStyle=ue,d.lineWidth=2;const ne=Math.max(4,Math.min(12,8*Math.abs(e.a))),re=Math.max(2,Math.min(6,4*Math.abs(e.a))),se=ne*(V?1.3:1),me=re;d.setLineDash([se,me]),d.beginPath(),d.moveTo(X.x,X.y),d.lineTo(K.x,K.y),d.lineTo(oe.x,oe.y),d.lineTo(J.x,J.y),d.closePath(),d.stroke();const Pe=Math.max(8,Math.min(12,10*Math.abs(e.a))),Me=B==0||B==1?0:B*.11,Ee=Pe*(1-Me),_e=4,Ce=S.name||`Group ${M+1}`;d.font=`${Ee}px sans-serif`,d.setLineDash([]);const Fe=d.measureText(Ce).width+_e*2,Xe=Ee+_e*2,et=X.x-5,ge=X.y-5,Ke=3;if(d.fillStyle="rgba(0, 0, 0, 0.8)",d.beginPath(),d.roundRect(et,ge-Xe,Fe,Xe,Ke),d.fill(),d.fillStyle=ue,d.textAlign="left",d.textBaseline="middle",d.fillText(Ce,et+_e,ge-Xe/2),u&&v.has(S.pcb_group_id)&&!!S.anchor_position&&S.anchor_position){const Oe=Array.isArray(S.anchor_position)?{x:S.anchor_position[0]??0,y:S.anchor_position[1]??0}:{x:S.anchor_position.x,y:S.anchor_position.y},$e=pt(e,Oe);d.strokeStyle="white",d.lineWidth=1.5,d.setLineDash([]);const Ie=Math.max(4,Math.min(8,6*Math.abs(e.a)));d.beginPath(),d.moveTo($e.x-Ie,$e.y),d.lineTo($e.x+Ie,$e.y),d.stroke(),d.beginPath(),d.moveTo($e.x,$e.y-Ie),d.lineTo($e.x,$e.y+Ie),d.stroke()}})},[n,e,i,s,c,l,u,o]),G.jsxs("div",{ref:r,style:{position:"relative",width:"100%",height:"100%"},children:[t,G.jsx("canvas",{ref:a,style:{position:"absolute",top:0,left:0,pointerEvents:"none",zIndex:bu.pcbGroupOverlay,display:c?"block":"none"}})]})},s_o=({transform:t,soup:e,children:n})=>{const o=B_(a=>a.is_showing_rats_nest),{netMap:r,idToNetMap:i}=Y.useMemo(()=>wgt(e||[]),[e]),s=Y.useMemo(()=>{if(!e||!o)return[];const a=d=>{const m=s8(e)[d.replace(/_\d+$/,"")].get(d);return m&&"x"in m&&"y"in m?{x:m.x,y:m.y}:null},c=(d,m)=>{const h=r[m]||[];let p=null,x=1/0;return h.forEach(f=>{const g=a(f);if(g){const y=Math.sqrt((d.x-g.x)**2+(d.y-g.y)**2);y<x&&y>0&&(x=y,p=g)}}),p},l=s8(e).pcb_port.list(),u=s8(e).source_trace.list(),_=[];return l.forEach((d,m)=>{const h=i[d.pcb_port_id];let p=!1;for(const g of u)g.connected_source_port_ids.includes(d.source_port_id)&&g.connected_source_net_ids.length>0&&(p=!0);if(!h)return;const x={x:d.x,y:d.y},f=c(x,h);f&&_.push({key:`${d.pcb_port_id}-${m}`,startPoint:x,endPoint:f,isInNet:p})}),_},[e,r,i,o]);return!e||!o?n:(t||(t=Sl()),G.jsxs("div",{style:{position:"relative"},children:[n,G.jsx("svg",{style:{position:"absolute",left:0,top:0,width:"100%",height:"100%",pointerEvents:"none",opacity:.5,zIndex:bu.ratsNestOverlay},children:s.map(({key:a,startPoint:c,endPoint:l,isInNet:u})=>{const _=pt(t,c),d=pt(t,l);return G.jsx("line",{x1:_.x,y1:_.y,x2:d.x,y2:d.y,stroke:"white",strokeWidth:"1",strokeDasharray:u?"6,6":void 0},a)})})]}))},a_o={version:"1.11.368"},c8=(t,e,n)=>{const o=B_(s=>s.is_mouse_over_container),r=Y.useRef(o),i=Y.useRef(e);Y.useEffect(()=>{r.current=o},[o]),Y.useEffect(()=>{i.current=e},[e]),Y.useEffect(()=>{if(!t)return;const s=a=>{const c=a.target;if(c.tagName==="INPUT"||c.tagName==="TEXTAREA"||c.isContentEditable)return;const l=t.split("+"),u=l.includes("ctrl"),_=l.includes("shift"),d=l.includes("alt"),m=l.includes("meta"),h=l[l.length-1],p=n?.current?n.current.contains(document.activeElement)||document.activeElement===n.current:!1;(r.current||p)&&(!u||a.ctrlKey)&&(!_||a.shiftKey)&&(!d||a.altKey)&&(!m||a.metaKey)&&a.key.toLowerCase()===h.toLowerCase()&&(a.preventDefault(),i.current())};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s)}},[t])},c_o=()=>{const[t,e]=Y.useState(!1);return Y.useEffect(()=>{const n=()=>{e(window.innerWidth<=768)};return n(),window.addEventListener("resize",n),()=>window.removeEventListener("resize",n)},[]),t},rF=(t,e={stopPropagation:!0})=>{const n=Y.useRef(0),o=Y.useCallback(s=>{e.stopPropagation&&s.stopPropagation();const a=Date.now();a-n.current<300||(n.current=a,t?.(s))},[t,e.stopPropagation]),r=Y.useCallback(s=>{s.preventDefault(),o(s)},[o]);return{onClick:o,onTouchEnd:r,style:{touchAction:"manipulation"}}},BM=({children:t,isSmallScreen:e,onClick:n,...o})=>{const{style:r,...i}=rF(n);return G.jsx("div",{...o,...i,style:{backgroundColor:"#1F1F1F",border:"1px solid #666",margin:0,padding:4,paddingLeft:e?8:6,paddingRight:e?8:6,borderRadius:2,color:"#eee",cursor:"pointer",fontSize:12,height:"fit-content",userSelect:"none",whiteSpace:"nowrap",...r,...o.style},children:t})},l_o=t=>{const e=new Map;return t.forEach((n,o)=>{const r=n.error_type||"unknown_error",i=e.get(r)||[];i.push({error:n,index:o,errorId:dk(n,o)}),e.set(r,i)}),Array.from(e.entries()).map(([n,o])=>({errorType:n,errors:o}))},u_o=({onClose:t,setHoveredErrorId:e,setFocusedErrorId:n,highlightDurationMs:o=3e3})=>{const r=Y.useRef(null),i=Y.useRef(null),s=Y.useRef(null),a=Y.useCallback(()=>{r.current!==null&&(window.clearTimeout(r.current),r.current=null),i.current!==null&&(window.cancelAnimationFrame(i.current),i.current=null)},[]);Y.useEffect(()=>a,[a]);const c=Y.useCallback(u=>{a(),s.current=u,e(u),n(null),i.current=window.requestAnimationFrame(()=>{n(u),i.current=null}),t(),r.current=window.setTimeout(()=>{s.current=null,e(null),n(null),r.current=null},o)},[a,o,t,n,e]),l=Y.useCallback(u=>s.current===u,[]);return{handleErrorSelect:c,isSelectedError:l}},__o=({errorId:t,errorMessage:e,copiedErrorId:n,onCopy:o})=>{const{style:r,...i}=rF(()=>o(e,t));return G.jsx("button",{type:"button","aria-label":n===t?"Error message copied":"Copy error message",style:{position:"absolute",top:12,right:16,cursor:"pointer",color:"#888",fontSize:16,background:"none",border:"none",padding:0,display:"flex",alignItems:"center",...r},...i,children:n===t?G.jsx("span",{style:{color:"#4caf50",fontSize:12},children:"Copied!"}):G.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:G.jsx("path",{d:"M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"})})})},d_o=({elements:t,isOpen:e,isSmallScreen:n,onToggle:o,onClose:r,setHoveredErrorId:i,setFocusedErrorId:s})=>{const[a,c]=Y.useState(null),[l,u]=Y.useState(new Set),[_,d]=Y.useState(new Set),[,m]=Klo(),{handleErrorSelect:h,isSelectedError:p}=u_o({onClose:r,setHoveredErrorId:i,setFocusedErrorId:s}),x=Y.useMemo(()=>t?.filter(v=>v.type.includes("error"))??[],[t]),f=x.length,g=Y.useMemo(()=>l_o(x),[x]),y=Y.useCallback(v=>{u(S=>{const M=new Set(S);return M.has(v)?M.delete(v):M.add(v),M})},[]),b=Y.useCallback(v=>{d(S=>{const M=new Set(S);return M.has(v)?M.delete(v):M.add(v),M})},[]);return G.jsxs("div",{style:{position:"relative"},children:[G.jsx(BM,{isSmallScreen:n,style:f>0?{color:"red"}:void 0,onClick:o,children:G.jsxs("div",{children:[f," errors"]})}),e&&f>0&&G.jsx("div",{style:{position:"absolute",top:"100%",left:0,backgroundColor:"#2a2a2a",border:"1px solid #666",borderRadius:4,marginTop:4,zIndex:1e3,minWidth:n?"280px":"400px",maxWidth:n?"90vw":"600px",maxHeight:"400px",overflow:"auto",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.3)"},children:g.map(({errorType:v,errors:S},M)=>{const T=l.has(v);return G.jsxs("div",{style:{borderBottom:M<g.length-1?"1px solid #444":"none"},children:[G.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 16px",cursor:"pointer",backgroundColor:"#232323",transition:"background-color 0.2s ease",touchAction:"manipulation",position:"sticky",top:0,zIndex:1},onMouseEnter:D=>{D.currentTarget.style.backgroundColor="#303030"},onMouseLeave:D=>{D.currentTarget.style.backgroundColor="#232323"},onTouchStart:D=>{D.stopPropagation(),D.currentTarget.style.backgroundColor="#303030"},onTouchEnd:D=>{D.stopPropagation(),D.preventDefault(),D.currentTarget.style.backgroundColor="#232323",y(v)},onClick:D=>{D.stopPropagation(),y(v)},children:[G.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,color:"#ff6b6b"},children:[G.jsx("div",{style:{color:"#888",fontSize:"16px",transform:T?"rotate(90deg)":"rotate(0deg)",transition:"transform 0.2s ease",flexShrink:0},children:"›"}),G.jsx("div",{style:{fontWeight:"bold",fontSize:n?"12px":"13px"},children:v})]}),G.jsx("div",{style:{fontSize:n?"12px":"13px",color:"#aaa",whiteSpace:"nowrap",marginLeft:12},children:S.length})]}),!T&&S.map(({error:D,index:A,errorId:L})=>{const H=_.has(L),F=D.message??"No error message";return G.jsxs("div",{style:{borderTop:"1px solid #3a3a3a"},children:[G.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"12px 16px 12px 24px",cursor:"pointer",backgroundColor:"#2a2a2a",transition:"background-color 0.2s ease",touchAction:"manipulation"},onMouseEnter:B=>{B.currentTarget.style.backgroundColor="#333",i(L)},onMouseLeave:B=>{B.currentTarget.style.backgroundColor="#2a2a2a",p(L)||i(null)},onTouchStart:B=>{B.stopPropagation(),B.currentTarget.style.backgroundColor="#333",i(L)},onTouchEnd:B=>{B.stopPropagation(),B.preventDefault(),B.currentTarget.style.backgroundColor="#2a2a2a",h(L)},onClick:B=>{B.stopPropagation(),h(L)},children:[G.jsx("div",{style:{flex:1,fontSize:n?"12px":"13px",color:"#ddd",lineHeight:1.4,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",userSelect:"text"},children:F}),G.jsx("button",{type:"button","aria-label":H?"Collapse error details":"Expand error details",style:{color:"#888",fontSize:"16px",transform:H?"rotate(0deg)":"rotate(90deg)",transition:"transform 0.2s ease",flexShrink:0,background:"none",border:"none",padding:0,cursor:"pointer"},onMouseDown:B=>B.stopPropagation(),onClick:B=>{B.stopPropagation(),b(L)},onTouchEnd:B=>{B.stopPropagation(),B.preventDefault(),b(L)},children:"›"})]}),H&&G.jsxs("div",{"data-error-id":A,style:{display:"block",padding:"12px 16px 12px 24px",backgroundColor:"#1a1a1a",borderTop:"1px solid #444",position:"relative"},children:[G.jsx("div",{style:{fontSize:n?"11px":"12px",color:"#ccc",lineHeight:1.5,wordWrap:"break-word",overflowWrap:"break-word",hyphens:"auto",userSelect:"text",paddingRight:30},onMouseDown:B=>B.stopPropagation(),onClick:B=>B.stopPropagation(),children:F}),G.jsx(__o,{errorId:L,errorMessage:F,copiedErrorId:a,onCopy:(B,V)=>{m(B),c(V),setTimeout(()=>c(null),2e3)}})]})]},L)})]},v)})})]})},h_o=({name:t,selected:e,onClick:n})=>{const{style:o,...r}=rF(n);return G.jsxs("div",{className:_k`
|
|
5521
5521
|
margin-top: 2px;
|
|
5522
5522
|
padding: 4px;
|
|
5523
5523
|
padding-left: 8px;
|
|
@@ -5734,7 +5734,7 @@ test("${l} should solve problem correctly", () => {
|
|
|
5734
5734
|
// Add more specific assertions based on expected output
|
|
5735
5735
|
// expect(solver.netLabelPlacementSolver!.netLabelPlacements).toMatchInlineSnapshot()
|
|
5736
5736
|
})
|
|
5737
|
-
`,_=new Blob([u],{type:"text/plain"}),d=URL.createObjectURL(_),m=document.createElement("a");m.href=d,m.download=`${l}.test.ts`,m.click(),URL.revokeObjectURL(d)}catch(c){alert(`Error generating test.ts for ${t.constructor.name}: ${c instanceof Error?c.message:String(c)}`)}o(!1)};return G.jsxs("div",{className:`relative ${e}`,ref:r,children:[G.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>o(!n),title:`Download options for ${t.constructor.name}`,children:t.constructor.name}),n&&G.jsxs("div",{className:"absolute top-full left-0 mt-1 bg-white border border-gray-300 rounded shadow-lg z-10 min-w-[150px]",children:[G.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:i,children:"Download JSON"}),G.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),G.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:a,children:"Download test.ts"})]})]})},hyt=t=>t.activeSubSolver?[t,...hyt(t.activeSubSolver)]:[t],Xdo=({solver:t})=>{const e=hyt(t);return G.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:e.map((n,o)=>G.jsxs("div",{className:"flex items-center",children:[o>0&&G.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),G.jsx(Udo,{solver:n})]},n.constructor.name))})},Gdo=({solver:t,triggerRender:e,animationSpeed:n=25,onSolverStarted:o,onSolverCompleted:r})=>{const[i,s]=Y.useReducer(p=>!p,!1),a=Y.useRef(void 0),c=()=>{!t.solved&&!t.failed&&(t.step(),e())},l=()=>{!t.solved&&!t.failed&&(o&&o(t),t.solve(),e(),r&&r(t))},u=()=>{i?(a.current&&(clearInterval(a.current),a.current=void 0),s()):(s(),a.current=setInterval(()=>{if(t.solved||t.failed){a.current&&(clearInterval(a.current),a.current=void 0),s(),e(),r&&t.solved&&r(t);return}t.step(),e()},n))},_=()=>{const p=t;if(p.getCurrentPhase&&!t.solved&&!t.failed){const x=p.getCurrentPhase();for(;p.getCurrentPhase()===x&&!t.solved&&!t.failed;)t.step();e()}},d=()=>{if(t.solved||t.failed||i)return;const p=window.prompt("Step until which iteration?",`${t.iterations}`);if(p===null)return;const x=Number(p);if(!Number.isFinite(x)){window.alert("Please enter a valid number for the iteration");return}for(;t.iterations<x&&!t.solved&&!t.failed;)t.step();e(),t.solved&&r&&r(t)};Y.useEffect(()=>()=>{a.current&&clearInterval(a.current)},[]),Y.useEffect(()=>{(t.solved||t.failed)&&i&&(a.current&&(clearInterval(a.current),a.current=void 0),s())},[t.solved,t.failed,i]);const m=t.getCurrentPhase!==void 0,h=m?t.getCurrentPhase():null;return G.jsxs("div",{className:"space-y-2 p-2 border-b",children:[G.jsx("div",{className:"flex items-center",children:G.jsx(Xdo,{solver:t})}),G.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[G.jsx("button",{onClick:c,disabled:t.solved||t.failed||i,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),G.jsx("button",{onClick:l,disabled:t.solved||t.failed||i,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),G.jsx("button",{onClick:u,disabled:t.solved||t.failed,className:`px-3 py-1 rounded text-white text-sm ${i?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:i?"Stop":"Animate"}),G.jsx("button",{onClick:d,disabled:t.solved||t.failed||i,className:"bg-orange-500 hover:bg-orange-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step Until Iteration"}),m&&G.jsx("button",{onClick:_,disabled:t.solved||t.failed||i,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),G.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&G.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),h&&G.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",G.jsx("span",{className:"font-medium",children:h})]}),t.solved&&G.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&G.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&G.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},Ydo=(t,e,n)=>{const o=t.currentPipelineStepIndex;return e<o?"Completed":e===o&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},qdo=(t,e)=>{const o=t.pipelineDef[e].solverName,r=Ydo(t,e),i=t[o],s=t.firstIterationOfPhase?.[o]??null,a=t.iterations;let c=0;if(r==="Completed"){const d=t.pipelineDef[e+1],m=d?t.firstIterationOfPhase?.[d.solverName]:void 0;m!==void 0&&s!==null?c=m-s:s!==null&&(c=a-s)}else r==="In Progress"&&s!==null&&(c=a-s);const l=t.timeSpentOnPhase?.[o]??0;let u=0;r==="Completed"?u=1:r==="In Progress"&&i&&(u=i.progress??0);const _=i?.stats??null;return{index:e,name:o,status:r,firstIteration:s,iterations:c,progress:u,timeSpent:l,stats:_&&Object.keys(_).length>0?_:null,solverInstance:i??null}},Kdo=({status:t})=>{const e={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return G.jsx("span",{className:`font-medium ${e[t]}`,children:t})},Jdo=({progress:t})=>{if(t===0)return null;const e=Math.round(t*100);return G.jsxs("div",{className:"flex items-center gap-2",children:[G.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:G.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${e}%`}})}),G.jsxs("span",{className:"text-xs text-gray-500",children:[e,"%"]})]})},Qdo=t=>Object.entries(t).map(([e,n])=>`${e}: ${n}`).join(", "),Zdo=({stats:t})=>{if(!t||Object.keys(t).length===0)return G.jsx("span",{children:"-"});const e=Object.entries(t),n=Qdo(t);return G.jsxs("details",{className:"cursor-pointer",children:[G.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:n}),G.jsx("div",{className:"mt-1 text-xs",children:e.map(([o,r])=>G.jsxs("div",{children:[o,": ",String(r)]},o))})]})},APe=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(APe);const e={};for(const[n,o]of Object.entries(t))n.startsWith("_")||(e[n]=APe(o));return e},eho=(t,e)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${e}`);return}const n=APe(t.getConstructorParams()),o=new Blob([JSON.stringify(n,null,2)],{type:"application/json"}),r=URL.createObjectURL(o),i=document.createElement("a");i.href=r,i.download=`${e}_input.json`,i.click(),URL.revokeObjectURL(r)}catch(n){alert(`Error downloading input for ${e}: ${n instanceof Error?n.message:String(n)}`)}},tho=({solver:t,onStepUntilPhase:e,onDownloadInput:n})=>{const o=t.pipelineDef.map((a,c)=>qdo(t,c)),r=a=>{e?.(a)},i=a=>{a.solverInstance&&(n?n(a.solverInstance,a.name):eho(a.solverInstance,a.name))},s=a=>`${(a/1e3).toFixed(2)}s`;return G.jsxs("div",{className:"border-t border-gray-200",children:[G.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:G.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),G.jsx("div",{className:"overflow-x-auto",children:G.jsxs("table",{className:"w-full text-sm",children:[G.jsx("thead",{children:G.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),G.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",G.jsx("sub",{children:"0"})]}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),G.jsx("tbody",{children:o.map(a=>G.jsxs("tr",{className:`border-b border-gray-100 ${a.status==="In Progress"?"bg-yellow-50":""}`,children:[G.jsx("td",{className:"px-4 py-2",children:G.jsxs("div",{className:"flex items-center gap-2",children:[G.jsx("span",{className:"text-gray-400 w-6",children:String(a.index+1).padStart(2,"0")}),G.jsx("button",{onClick:()=>r(a.name),disabled:a.status==="Completed"||t.solved||t.failed,className:"text-blue-500 hover:text-blue-700 disabled:text-gray-300 disabled:cursor-not-allowed",title:`Step until ${a.name} completes`,children:G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:G.jsx("path",{fillRule:"evenodd",d:"M4.5 5.653c0-1.426 1.529-2.33 2.779-1.643l11.54 6.348c1.295.712 1.295 2.573 0 3.285L7.28 19.991c-1.25.687-2.779-.217-2.779-1.643V5.653z",clipRule:"evenodd"})})}),G.jsx("span",{className:"font-medium text-gray-900",children:a.name})]})}),G.jsx("td",{className:"px-4 py-2",children:G.jsx(Kdo,{status:a.status})}),G.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:a.firstIteration!==null?a.firstIteration:""}),G.jsx("td",{className:"px-4 py-2 text-gray-600",children:a.iterations}),G.jsx("td",{className:"px-4 py-2",children:G.jsx(Jdo,{progress:a.progress})}),G.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(a.timeSpent)}),G.jsx("td",{className:"px-4 py-2 text-gray-500",children:G.jsx(Zdo,{stats:a.stats})}),G.jsx("td",{className:"px-4 py-2",children:a.solverInstance?G.jsxs("button",{onClick:()=>i(a),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${a.name}`,children:[G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:G.jsx("path",{fillRule:"evenodd",d:"M12 2.25a.75.75 0 01.75.75v11.69l3.22-3.22a.75.75 0 111.06 1.06l-4.5 4.5a.75.75 0 01-1.06 0l-4.5-4.5a.75.75 0 111.06-1.06l3.22 3.22V3a.75.75 0 01.75-.75zm-9 13.5a.75.75 0 01.75.75v2.25a1.5 1.5 0 001.5 1.5h13.5a1.5 1.5 0 001.5-1.5V16.5a.75.75 0 011.5 0v2.25a3 3 0 01-3 3H5.25a3 3 0 01-3-3V16.5a.75.75 0 01.75-.75z",clipRule:"evenodd"})}),G.jsx("span",{children:"Input"})]}):null})]},a.name))})]})})]})},nho=class extends fr.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t){console.error("InteractiveGraphics render error:",t)}render(){return this.state.hasError?this.props.fallback:this.props.children}};function oho({graphics:t}){const e=t.points??[],n=t.lines??[],o=t.rects??[],r=t.circles??[],i=t.texts??[];let s=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY,l=Number.NEGATIVE_INFINITY;const u=(x,f)=>{typeof x=="number"&&(x<s&&(s=x),x>c&&(c=x)),typeof f=="number"&&(f<a&&(a=f),f>l&&(l=f))};for(const x of e)u(x.x,x.y);for(const x of n){const f=x.points??[];for(const g of f)u(g.x,g.y)}for(const x of o){const f=x.x??0,g=x.y??0,y=x.width??0,b=x.height??0;u(f,g),u(f+y,g+b)}for(const x of r){const f=x.x??0,g=x.y??0,y=x.radius??1;u(f-y,g-y),u(f+y,g+y)}for(const x of i)u(x.x,x.y);(!isFinite(s)||!isFinite(a)||!isFinite(c)||!isFinite(l))&&(s=-20,a=-20,c=20,l=20);const _=10,d=s-_,m=a-_,h=Math.max(1,c-s+2*_),p=Math.max(1,l-a+2*_);return G.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${d} ${m} ${h} ${p}`,role:"img","aria-label":"Graphics fallback",children:[o.map((x,f)=>G.jsx("rect",{x:x.x??0,y:x.y??0,width:x.width??0,height:x.height??0,fill:"none",stroke:x.strokeColor??"black",strokeWidth:x.strokeWidth??1},`rect-${f}`)),n.map((x,f)=>G.jsx("polyline",{fill:"none",stroke:x.strokeColor??"black",strokeWidth:x.strokeWidth??1,points:(x.points??[]).map(g=>`${g.x??0},${g.y??0}`).join(" ")},`line-${f}`)),r.map((x,f)=>G.jsx("circle",{cx:x.x??0,cy:x.y??0,r:x.radius??1.5,fill:x.fillColor??"none",stroke:x.strokeColor??"black",strokeWidth:x.strokeWidth??1},`circle-${f}`)),e.map((x,f)=>G.jsx("circle",{cx:x.x??0,cy:x.y??0,r:x.radius??1.5,fill:x.color??"black"},`point-${f}`)),i.map((x,f)=>G.jsx("text",{x:x.x??0,y:x.y??0,fontSize:x.fontSize??10,fill:x.color??"black",children:x.text??""},`text-${f}`))]})}var rho=({solver:t,animationSpeed:e=25,onSolverStarted:n,onSolverCompleted:o})=>{const[r,i]=Y.useReducer(u=>u+1,0),s=Y.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(u){return console.error("Visualization error:",u),{points:[],lines:[],rects:[],circles:[]}}},[t,r]),a=Y.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);Y.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const u=document.createElement("script");u.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(u)}},[]);const c=t.pipelineDef!==void 0,l=u=>{const _=t;if(!t.solved&&!t.failed){for(;!t.solved&&!t.failed&&_.currentPipelineStepIndex<=_.pipelineDef.findIndex(d=>d.solverName===u);)t.step();i()}};return G.jsxs("div",{children:[G.jsx(Gdo,{solver:t,triggerRender:i,animationSpeed:e,onSolverStarted:n,onSolverCompleted:o}),a?G.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):G.jsx(nho,{fallback:G.jsx(oho,{graphics:s}),children:G.jsx(jdo,{graphics:s})}),c&&G.jsx(tho,{solver:t,onStepUntilPhase:l})]})};const iho=()=>{Y.useEffect(()=>{const t="tailwind-cdn-script";if(document.getElementById(t)||window.tailwind)return;const e=document.createElement("div");e.className="hidden",document.body.appendChild(e);const n=window.getComputedStyle(e).display==="none";if(document.body.removeChild(e),n)return;const o=document.createElement("script");o.id=t,o.src="https://cdn.tailwindcss.com",document.head.appendChild(o)},[])},sho=t=>t.toLowerCase().includes("pack")?GGn:t.toLowerCase().includes("rout")?QGn:RGn,aho=({solverEvents:t=[]})=>{const[e,n]=Y.useState(null);iho();const o=Y.useMemo(()=>{const a=new Map;for(const c of t){const l=`${c.componentName}-${c.solverName}`;a.set(l,c)}return a},[t]),r=Y.useMemo(()=>Array.from(o.keys()),[o]),i=e?o.get(e):null,s=Y.useMemo(()=>{if(!i)return{instance:null,error:null,classFound:!1};const a=p0e[i.solverName];if(!a)return{instance:null,error:`Solver class "${i.solverName}" not found in SOLVERS registry. Available: ${Object.keys(p0e).join(", ")}`,classFound:!1};try{const c=i.solverParams,l=c?.input!==void 0?c.input:c;return{instance:new a(l),error:null,classFound:!0}}catch(c){const l=c instanceof Error?c.message:String(c);return console.error("Failed to reconstruct solver:",c),{instance:null,error:`Failed to instantiate solver: ${l}`,classFound:!0}}},[i]);return t.length===0?G.jsx("div",{className:"rf-p-4",children:G.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:G.jsxs("div",{className:"rf-p-4",children:[G.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),G.jsx("p",{className:"rf-text-sm rf-text-gray-600",children:"Solvers will appear here when the circuit runs. Solvers are used for tasks like component packing and autorouting."})]})})}):G.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[G.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[G.jsxs("div",{className:"rf-text-xs rf-font-semibold rf-text-gray-500 rf-px-3 rf-py-2 rf-bg-gray-50 rf-border-b rf-border-gray-200",children:[r.length," ",r.length===1?"Solver":"Solvers"]}),r.map(a=>{const c=o.get(a),l=e===a;return G.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${l?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>n(a),children:(()=>{const u=sho(c.solverName);return G.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[G.jsx(u,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),G.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[G.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:c.componentName}),G.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:c.solverName})]})]})})()},a)})]}),G.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:i?s.instance?G.jsx(x3,{fallback:G.jsx("div",{className:"rf-p-4",children:G.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[G.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),G.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",i.solverName]})]})}),children:G.jsx(rho,{solver:s.instance})}):G.jsxs("div",{className:"rf-p-4",children:[G.jsxs("div",{className:"rf-mb-4",children:[G.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:i.solverName}),G.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",i.componentName]})]}),s.error&&G.jsx("div",{className:`rf-rounded-md rf-border rf-p-4 rf-mb-4 ${s.classFound?"rf-bg-red-50 rf-border-red-200":"rf-bg-yellow-50 rf-border-yellow-200"}`,children:G.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),G.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[G.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:G.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),G.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:G.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(i.solverParams,null,2)})})]})]}):G.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:G.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},myt=({errorMessage:t,errorStack:e,circuitJsonErrors:n})=>{Y.useEffect(()=>{if(t){const o=new Error(t);e&&(o.stack=e);try{SG.captureException(o)}catch{}}},[t,e]),Y.useEffect(()=>{if(n&&n.length>0)for(const o of n){const r=new Error(o.message||"Circuit JSON Error");o.stack&&(r.stack=o.stack);try{SG.captureException(r,{error_type:o.type})}catch{}}},[n])},pyt="0.0.1943",cho={version:pyt},uQ=yGe()(bGe(t=>({lastRunEvalVersion:void 0,setLastRunEvalVersion:e=>{t({lastRunEvalVersion:e})}}),{name:"runframe-runner-store"})),lho=t=>{const[e,n]=Y.useState([]),[o,r]=Y.useState(null),[i,s]=Y.useState(""),[a,c]=qE("eval-version-selection",null),l=uQ(m=>m.setLastRunEvalVersion),u=uQ(m=>m.lastRunEvalVersion);return Y.useEffect(()=>{t&&fetch("https://data.jsdelivr.com/v1/package/npm/@tscircuit/eval").then(m=>m.json()).then(m=>{if(Array.isArray(m?.versions)){let h=[...m.versions];m.tags?.latest&&(r(m.tags.latest),h=h.filter(p=>p!==m.tags.latest)),n(h)}}).catch(()=>{})},[t]),Y.useEffect(()=>{t&&(a?(window.TSCIRCUIT_LATEST_EVAL_VERSION=a,l(a)):o&&(window.TSCIRCUIT_LATEST_EVAL_VERSION=o,l(o)))},[t,a,o]),{versions:Y.useMemo(()=>e.filter(m=>m.includes(i)).slice(0,50),[e,i]),latestVersion:o,lastRunEvalVersion:u,search:i,setSearch:s,selectVersion:m=>{c(m),s("")}}},uho=({snippetNames:t,onSelect:e,onCancel:n,isOpen:o})=>{const[r,i]=Y.useState(""),[s,a]=Y.useState("");if(!o)return null;const c=t.filter(_=>_.toLowerCase().includes(s.toLowerCase())),l=s&&!t.includes(s),u=_=>{_.key==="Enter"&&(c.length===1?i(c[0]):l&&i(s))};return G.jsx("div",{className:"rf-fixed rf-inset-0 rf-bg-black rf-bg-opacity-50 rf-flex rf-items-center rf-justify-center rf-z-[100]",children:G.jsxs("div",{className:"rf-bg-white rf-rounded-lg rf-p-6 rf-w-96",children:[G.jsx("h2",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Select Snippet"}),G.jsx("input",{type:"text",className:"rf-w-full rf-px-4 rf-py-2 rf-border rf-rounded rf-mb-4",placeholder:"Search snippets or new snippet name...",value:s,onChange:_=>a(_.target.value),onKeyDown:u}),G.jsxs("div",{className:"rf-h-60 rf-overflow-y-auto",children:[c.map(_=>G.jsx("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 ${r===_?"bg-blue-50":""}`,onClick:()=>i(_),children:_},_)),l&&G.jsxs("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 text-blue-500 ${r===s?"bg-blue-50":""}`,onClick:()=>i(s),children:['Create new "',s,'"']})]}),G.jsxs("div",{className:"rf-mt-4 rf-flex rf-justify-end rf-gap-2",children:[G.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-text-gray-600 rf-hover:text-gray-800",onClick:n,children:"Cancel"}),G.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-bg-blue-500 rf-text-white rf-rounded rf-hover:bg-blue-600 rf-disabled:opacity-50",onClick:()=>r&&e(r),disabled:!r,children:r===s?`Create "${r}"`:`Save to ${r}`})]})]})})},_ho=t=>{const e=Y.useRef(null),n=v0(o=>o.recentEvents);Y.useEffect(()=>{if(n.length===0)return;const o=n[0];o.event_id!==e.current&&(t(o),e.current=o.event_id)},[n,t])};function dho(t){const e=hho(t),n=Y.forwardRef((o,r)=>{const{children:i,...s}=o,a=Y.Children.toArray(i),c=a.find(pho);if(c){const l=c.props.children,u=a.map(_=>_===c?Y.Children.count(l)>1?Y.Children.only(null):Y.isValidElement(l)?l.props.children:null:_);return G.jsx(e,{...s,ref:r,children:Y.isValidElement(l)?Y.cloneElement(l,void 0,u):null})}return G.jsx(e,{...s,ref:r,children:i})});return n.displayName=`${t}.Slot`,n}function hho(t){const e=Y.forwardRef((n,o)=>{const{children:r,...i}=n;if(Y.isValidElement(r)){const s=xho(r),a=fho(i,r.props);return r.type!==Y.Fragment&&(a.ref=o?vg(o,s):s),Y.cloneElement(r,a)}return Y.Children.count(r)>1?Y.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var mho=Symbol("radix.slottable");function pho(t){return Y.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===mho}function fho(t,e){const n={...e};for(const o in e){const r=t[o],i=e[o];/^on[A-Z]/.test(o)?r&&i?n[o]=(...a)=>{const c=i(...a);return r(...a),c}:r&&(n[o]=r):o==="style"?n[o]={...r,...i}:o==="className"&&(n[o]=[r,i].filter(Boolean).join(" "))}return{...t,...n}}function xho(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var _Q="Dialog",[fyt,xyt]=_b(_Q),[gho,Ob]=fyt(_Q),gyt=t=>{const{__scopeDialog:e,children:n,open:o,defaultOpen:r,onOpenChange:i,modal:s=!0}=t,a=Y.useRef(null),c=Y.useRef(null),[l,u]=ZS({prop:o,defaultProp:r??!1,onChange:i,caller:_Q});return G.jsx(gho,{scope:e,triggerRef:a,contentRef:c,contentId:Df(),titleId:Df(),descriptionId:Df(),open:l,onOpenChange:u,onOpenToggle:Y.useCallback(()=>u(_=>!_),[u]),modal:s,children:n})};gyt.displayName=_Q;var yyt="DialogTrigger",byt=Y.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,r=Ob(yyt,n),i=S0(e,r.triggerRef);return G.jsx(Uc.button,{type:"button","aria-haspopup":"dialog","aria-expanded":r.open,"aria-controls":r.contentId,"data-state":NPe(r.open),...o,ref:i,onClick:Qr(t.onClick,r.onOpenToggle)})});byt.displayName=yyt;var kPe="DialogPortal",[yho,Pyt]=fyt(kPe,{forceMount:void 0}),vyt=t=>{const{__scopeDialog:e,forceMount:n,children:o,container:r}=t,i=Ob(kPe,e);return G.jsx(yho,{scope:e,forceMount:n,children:Y.Children.map(o,s=>G.jsx(Ey,{present:n||i.open,children:G.jsx(RK,{asChild:!0,container:r,children:s})}))})};vyt.displayName=kPe;var dQ="DialogOverlay",Syt=Y.forwardRef((t,e)=>{const n=Pyt(dQ,t.__scopeDialog),{forceMount:o=n.forceMount,...r}=t,i=Ob(dQ,t.__scopeDialog);return i.modal?G.jsx(Ey,{present:o||i.open,children:G.jsx(Pho,{...r,ref:e})}):null});Syt.displayName=dQ;var bho=dho("DialogOverlay.RemoveScroll"),Pho=Y.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,r=Ob(dQ,n);return G.jsx(zK,{as:bho,allowPinchZoom:!0,shards:[r.contentRef],children:G.jsx(Uc.div,{"data-state":NPe(r.open),...o,ref:e,style:{pointerEvents:"auto",...o.style}})})}),$M="DialogContent",Cyt=Y.forwardRef((t,e)=>{const n=Pyt($M,t.__scopeDialog),{forceMount:o=n.forceMount,...r}=t,i=Ob($M,t.__scopeDialog);return G.jsx(Ey,{present:o||i.open,children:i.modal?G.jsx(vho,{...r,ref:e}):G.jsx(Sho,{...r,ref:e})})});Cyt.displayName=$M;var vho=Y.forwardRef((t,e)=>{const n=Ob($M,t.__scopeDialog),o=Y.useRef(null),r=S0(e,n.contentRef,o);return Y.useEffect(()=>{const i=o.current;if(i)return Mbe(i)},[]),G.jsx(Myt,{...t,ref:r,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Qr(t.onCloseAutoFocus,i=>{i.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:Qr(t.onPointerDownOutside,i=>{const s=i.detail.originalEvent,a=s.button===0&&s.ctrlKey===!0;(s.button===2||a)&&i.preventDefault()}),onFocusOutside:Qr(t.onFocusOutside,i=>i.preventDefault())})}),Sho=Y.forwardRef((t,e)=>{const n=Ob($M,t.__scopeDialog),o=Y.useRef(!1),r=Y.useRef(!1);return G.jsx(Myt,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{t.onCloseAutoFocus?.(i),i.defaultPrevented||(o.current||n.triggerRef.current?.focus(),i.preventDefault()),o.current=!1,r.current=!1},onInteractOutside:i=>{t.onInteractOutside?.(i),i.defaultPrevented||(o.current=!0,i.detail.originalEvent.type==="pointerdown"&&(r.current=!0));const s=i.target;n.triggerRef.current?.contains(s)&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&r.current&&i.preventDefault()}})}),Myt=Y.forwardRef((t,e)=>{const{__scopeDialog:n,trapFocus:o,onOpenAutoFocus:r,onCloseAutoFocus:i,...s}=t,a=Ob($M,n),c=Y.useRef(null),l=S0(e,c);return sbe(),G.jsxs(G.Fragment,{children:[G.jsx(yK,{asChild:!0,loop:!0,trapped:o,onMountAutoFocus:r,onUnmountAutoFocus:i,children:G.jsx(tO,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":NPe(a.open),...s,ref:l,onDismiss:()=>a.onOpenChange(!1)})}),G.jsxs(G.Fragment,{children:[G.jsx(Mho,{titleId:a.titleId}),G.jsx(who,{contentRef:c,descriptionId:a.descriptionId})]})]})}),RPe="DialogTitle",Tyt=Y.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,r=Ob(RPe,n);return G.jsx(Uc.h2,{id:r.titleId,...o,ref:e})});Tyt.displayName=RPe;var wyt="DialogDescription",Eyt=Y.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,r=Ob(wyt,n);return G.jsx(Uc.p,{id:r.descriptionId,...o,ref:e})});Eyt.displayName=wyt;var Dyt="DialogClose",Ayt=Y.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,r=Ob(Dyt,n);return G.jsx(Uc.button,{type:"button",...o,ref:e,onClick:Qr(t.onClick,()=>r.onOpenChange(!1))})});Ayt.displayName=Dyt;function NPe(t){return t?"open":"closed"}var kyt="DialogTitleWarning",[Cho,Ryt]=Tfn(kyt,{contentName:$M,titleName:RPe,docsSlug:"dialog"}),Mho=({titleId:t})=>{const e=Ryt(kyt),n=`\`${e.contentName}\` requires a \`${e.titleName}\` for the component to be accessible for screen reader users.
|
|
5737
|
+
`,_=new Blob([u],{type:"text/plain"}),d=URL.createObjectURL(_),m=document.createElement("a");m.href=d,m.download=`${l}.test.ts`,m.click(),URL.revokeObjectURL(d)}catch(c){alert(`Error generating test.ts for ${t.constructor.name}: ${c instanceof Error?c.message:String(c)}`)}o(!1)};return G.jsxs("div",{className:`relative ${e}`,ref:r,children:[G.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>o(!n),title:`Download options for ${t.constructor.name}`,children:t.constructor.name}),n&&G.jsxs("div",{className:"absolute top-full left-0 mt-1 bg-white border border-gray-300 rounded shadow-lg z-10 min-w-[150px]",children:[G.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:i,children:"Download JSON"}),G.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),G.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:a,children:"Download test.ts"})]})]})},hyt=t=>t.activeSubSolver?[t,...hyt(t.activeSubSolver)]:[t],Xdo=({solver:t})=>{const e=hyt(t);return G.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:e.map((n,o)=>G.jsxs("div",{className:"flex items-center",children:[o>0&&G.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),G.jsx(Udo,{solver:n})]},n.constructor.name))})},Gdo=({solver:t,triggerRender:e,animationSpeed:n=25,onSolverStarted:o,onSolverCompleted:r})=>{const[i,s]=Y.useReducer(p=>!p,!1),a=Y.useRef(void 0),c=()=>{!t.solved&&!t.failed&&(t.step(),e())},l=()=>{!t.solved&&!t.failed&&(o&&o(t),t.solve(),e(),r&&r(t))},u=()=>{i?(a.current&&(clearInterval(a.current),a.current=void 0),s()):(s(),a.current=setInterval(()=>{if(t.solved||t.failed){a.current&&(clearInterval(a.current),a.current=void 0),s(),e(),r&&t.solved&&r(t);return}t.step(),e()},n))},_=()=>{const p=t;if(p.getCurrentPhase&&!t.solved&&!t.failed){const x=p.getCurrentPhase();for(;p.getCurrentPhase()===x&&!t.solved&&!t.failed;)t.step();e()}},d=()=>{if(t.solved||t.failed||i)return;const p=window.prompt("Step until which iteration?",`${t.iterations}`);if(p===null)return;const x=Number(p);if(!Number.isFinite(x)){window.alert("Please enter a valid number for the iteration");return}for(;t.iterations<x&&!t.solved&&!t.failed;)t.step();e(),t.solved&&r&&r(t)};Y.useEffect(()=>()=>{a.current&&clearInterval(a.current)},[]),Y.useEffect(()=>{(t.solved||t.failed)&&i&&(a.current&&(clearInterval(a.current),a.current=void 0),s())},[t.solved,t.failed,i]);const m=t.getCurrentPhase!==void 0,h=m?t.getCurrentPhase():null;return G.jsxs("div",{className:"space-y-2 p-2 border-b",children:[G.jsx("div",{className:"flex items-center",children:G.jsx(Xdo,{solver:t})}),G.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[G.jsx("button",{onClick:c,disabled:t.solved||t.failed||i,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),G.jsx("button",{onClick:l,disabled:t.solved||t.failed||i,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),G.jsx("button",{onClick:u,disabled:t.solved||t.failed,className:`px-3 py-1 rounded text-white text-sm ${i?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:i?"Stop":"Animate"}),G.jsx("button",{onClick:d,disabled:t.solved||t.failed||i,className:"bg-orange-500 hover:bg-orange-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step Until Iteration"}),m&&G.jsx("button",{onClick:_,disabled:t.solved||t.failed||i,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),G.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&G.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),h&&G.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",G.jsx("span",{className:"font-medium",children:h})]}),t.solved&&G.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&G.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&G.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},Ydo=(t,e,n)=>{const o=t.currentPipelineStepIndex;return e<o?"Completed":e===o&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},qdo=(t,e)=>{const o=t.pipelineDef[e].solverName,r=Ydo(t,e),i=t[o],s=t.firstIterationOfPhase?.[o]??null,a=t.iterations;let c=0;if(r==="Completed"){const d=t.pipelineDef[e+1],m=d?t.firstIterationOfPhase?.[d.solverName]:void 0;m!==void 0&&s!==null?c=m-s:s!==null&&(c=a-s)}else r==="In Progress"&&s!==null&&(c=a-s);const l=t.timeSpentOnPhase?.[o]??0;let u=0;r==="Completed"?u=1:r==="In Progress"&&i&&(u=i.progress??0);const _=i?.stats??null;return{index:e,name:o,status:r,firstIteration:s,iterations:c,progress:u,timeSpent:l,stats:_&&Object.keys(_).length>0?_:null,solverInstance:i??null}},Kdo=({status:t})=>{const e={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return G.jsx("span",{className:`font-medium ${e[t]}`,children:t})},Jdo=({progress:t})=>{if(t===0)return null;const e=Math.round(t*100);return G.jsxs("div",{className:"flex items-center gap-2",children:[G.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:G.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${e}%`}})}),G.jsxs("span",{className:"text-xs text-gray-500",children:[e,"%"]})]})},Qdo=t=>Object.entries(t).map(([e,n])=>`${e}: ${n}`).join(", "),Zdo=({stats:t})=>{if(!t||Object.keys(t).length===0)return G.jsx("span",{children:"-"});const e=Object.entries(t),n=Qdo(t);return G.jsxs("details",{className:"cursor-pointer",children:[G.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:n}),G.jsx("div",{className:"mt-1 text-xs",children:e.map(([o,r])=>G.jsxs("div",{children:[o,": ",String(r)]},o))})]})},APe=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(APe);const e={};for(const[n,o]of Object.entries(t))n.startsWith("_")||(e[n]=APe(o));return e},eho=(t,e)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${e}`);return}const n=APe(t.getConstructorParams()),o=new Blob([JSON.stringify(n,null,2)],{type:"application/json"}),r=URL.createObjectURL(o),i=document.createElement("a");i.href=r,i.download=`${e}_input.json`,i.click(),URL.revokeObjectURL(r)}catch(n){alert(`Error downloading input for ${e}: ${n instanceof Error?n.message:String(n)}`)}},tho=({solver:t,onStepUntilPhase:e,onDownloadInput:n})=>{const o=t.pipelineDef.map((a,c)=>qdo(t,c)),r=a=>{e?.(a)},i=a=>{a.solverInstance&&(n?n(a.solverInstance,a.name):eho(a.solverInstance,a.name))},s=a=>`${(a/1e3).toFixed(2)}s`;return G.jsxs("div",{className:"border-t border-gray-200",children:[G.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:G.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),G.jsx("div",{className:"overflow-x-auto",children:G.jsxs("table",{className:"w-full text-sm",children:[G.jsx("thead",{children:G.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),G.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",G.jsx("sub",{children:"0"})]}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),G.jsx("tbody",{children:o.map(a=>G.jsxs("tr",{className:`border-b border-gray-100 ${a.status==="In Progress"?"bg-yellow-50":""}`,children:[G.jsx("td",{className:"px-4 py-2",children:G.jsxs("div",{className:"flex items-center gap-2",children:[G.jsx("span",{className:"text-gray-400 w-6",children:String(a.index+1).padStart(2,"0")}),G.jsx("button",{onClick:()=>r(a.name),disabled:a.status==="Completed"||t.solved||t.failed,className:"text-blue-500 hover:text-blue-700 disabled:text-gray-300 disabled:cursor-not-allowed",title:`Step until ${a.name} completes`,children:G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:G.jsx("path",{fillRule:"evenodd",d:"M4.5 5.653c0-1.426 1.529-2.33 2.779-1.643l11.54 6.348c1.295.712 1.295 2.573 0 3.285L7.28 19.991c-1.25.687-2.779-.217-2.779-1.643V5.653z",clipRule:"evenodd"})})}),G.jsx("span",{className:"font-medium text-gray-900",children:a.name})]})}),G.jsx("td",{className:"px-4 py-2",children:G.jsx(Kdo,{status:a.status})}),G.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:a.firstIteration!==null?a.firstIteration:""}),G.jsx("td",{className:"px-4 py-2 text-gray-600",children:a.iterations}),G.jsx("td",{className:"px-4 py-2",children:G.jsx(Jdo,{progress:a.progress})}),G.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(a.timeSpent)}),G.jsx("td",{className:"px-4 py-2 text-gray-500",children:G.jsx(Zdo,{stats:a.stats})}),G.jsx("td",{className:"px-4 py-2",children:a.solverInstance?G.jsxs("button",{onClick:()=>i(a),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${a.name}`,children:[G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:G.jsx("path",{fillRule:"evenodd",d:"M12 2.25a.75.75 0 01.75.75v11.69l3.22-3.22a.75.75 0 111.06 1.06l-4.5 4.5a.75.75 0 01-1.06 0l-4.5-4.5a.75.75 0 111.06-1.06l3.22 3.22V3a.75.75 0 01.75-.75zm-9 13.5a.75.75 0 01.75.75v2.25a1.5 1.5 0 001.5 1.5h13.5a1.5 1.5 0 001.5-1.5V16.5a.75.75 0 011.5 0v2.25a3 3 0 01-3 3H5.25a3 3 0 01-3-3V16.5a.75.75 0 01.75-.75z",clipRule:"evenodd"})}),G.jsx("span",{children:"Input"})]}):null})]},a.name))})]})})]})},nho=class extends fr.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t){console.error("InteractiveGraphics render error:",t)}render(){return this.state.hasError?this.props.fallback:this.props.children}};function oho({graphics:t}){const e=t.points??[],n=t.lines??[],o=t.rects??[],r=t.circles??[],i=t.texts??[];let s=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY,l=Number.NEGATIVE_INFINITY;const u=(x,f)=>{typeof x=="number"&&(x<s&&(s=x),x>c&&(c=x)),typeof f=="number"&&(f<a&&(a=f),f>l&&(l=f))};for(const x of e)u(x.x,x.y);for(const x of n){const f=x.points??[];for(const g of f)u(g.x,g.y)}for(const x of o){const f=x.x??0,g=x.y??0,y=x.width??0,b=x.height??0;u(f,g),u(f+y,g+b)}for(const x of r){const f=x.x??0,g=x.y??0,y=x.radius??1;u(f-y,g-y),u(f+y,g+y)}for(const x of i)u(x.x,x.y);(!isFinite(s)||!isFinite(a)||!isFinite(c)||!isFinite(l))&&(s=-20,a=-20,c=20,l=20);const _=10,d=s-_,m=a-_,h=Math.max(1,c-s+2*_),p=Math.max(1,l-a+2*_);return G.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${d} ${m} ${h} ${p}`,role:"img","aria-label":"Graphics fallback",children:[o.map((x,f)=>G.jsx("rect",{x:x.x??0,y:x.y??0,width:x.width??0,height:x.height??0,fill:"none",stroke:x.strokeColor??"black",strokeWidth:x.strokeWidth??1},`rect-${f}`)),n.map((x,f)=>G.jsx("polyline",{fill:"none",stroke:x.strokeColor??"black",strokeWidth:x.strokeWidth??1,points:(x.points??[]).map(g=>`${g.x??0},${g.y??0}`).join(" ")},`line-${f}`)),r.map((x,f)=>G.jsx("circle",{cx:x.x??0,cy:x.y??0,r:x.radius??1.5,fill:x.fillColor??"none",stroke:x.strokeColor??"black",strokeWidth:x.strokeWidth??1},`circle-${f}`)),e.map((x,f)=>G.jsx("circle",{cx:x.x??0,cy:x.y??0,r:x.radius??1.5,fill:x.color??"black"},`point-${f}`)),i.map((x,f)=>G.jsx("text",{x:x.x??0,y:x.y??0,fontSize:x.fontSize??10,fill:x.color??"black",children:x.text??""},`text-${f}`))]})}var rho=({solver:t,animationSpeed:e=25,onSolverStarted:n,onSolverCompleted:o})=>{const[r,i]=Y.useReducer(u=>u+1,0),s=Y.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(u){return console.error("Visualization error:",u),{points:[],lines:[],rects:[],circles:[]}}},[t,r]),a=Y.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);Y.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const u=document.createElement("script");u.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(u)}},[]);const c=t.pipelineDef!==void 0,l=u=>{const _=t;if(!t.solved&&!t.failed){for(;!t.solved&&!t.failed&&_.currentPipelineStepIndex<=_.pipelineDef.findIndex(d=>d.solverName===u);)t.step();i()}};return G.jsxs("div",{children:[G.jsx(Gdo,{solver:t,triggerRender:i,animationSpeed:e,onSolverStarted:n,onSolverCompleted:o}),a?G.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):G.jsx(nho,{fallback:G.jsx(oho,{graphics:s}),children:G.jsx(jdo,{graphics:s})}),c&&G.jsx(tho,{solver:t,onStepUntilPhase:l})]})};const iho=()=>{Y.useEffect(()=>{const t="tailwind-cdn-script";if(document.getElementById(t)||window.tailwind)return;const e=document.createElement("div");e.className="hidden",document.body.appendChild(e);const n=window.getComputedStyle(e).display==="none";if(document.body.removeChild(e),n)return;const o=document.createElement("script");o.id=t,o.src="https://cdn.tailwindcss.com",document.head.appendChild(o)},[])},sho=t=>t.toLowerCase().includes("pack")?GGn:t.toLowerCase().includes("rout")?QGn:RGn,aho=({solverEvents:t=[]})=>{const[e,n]=Y.useState(null);iho();const o=Y.useMemo(()=>{const a=new Map;for(const c of t){const l=`${c.componentName}-${c.solverName}`;a.set(l,c)}return a},[t]),r=Y.useMemo(()=>Array.from(o.keys()),[o]),i=e?o.get(e):null,s=Y.useMemo(()=>{if(!i)return{instance:null,error:null,classFound:!1};const a=p0e[i.solverName];if(!a)return{instance:null,error:`Solver class "${i.solverName}" not found in SOLVERS registry. Available: ${Object.keys(p0e).join(", ")}`,classFound:!1};try{const c=i.solverParams,l=c?.input!==void 0?c.input:c;return{instance:new a(l),error:null,classFound:!0}}catch(c){const l=c instanceof Error?c.message:String(c);return console.error("Failed to reconstruct solver:",c),{instance:null,error:`Failed to instantiate solver: ${l}`,classFound:!0}}},[i]);return t.length===0?G.jsx("div",{className:"rf-p-4",children:G.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:G.jsxs("div",{className:"rf-p-4",children:[G.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),G.jsx("p",{className:"rf-text-sm rf-text-gray-600",children:"Solvers will appear here when the circuit runs. Solvers are used for tasks like component packing and autorouting."})]})})}):G.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[G.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[G.jsxs("div",{className:"rf-text-xs rf-font-semibold rf-text-gray-500 rf-px-3 rf-py-2 rf-bg-gray-50 rf-border-b rf-border-gray-200",children:[r.length," ",r.length===1?"Solver":"Solvers"]}),r.map(a=>{const c=o.get(a),l=e===a;return G.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${l?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>n(a),children:(()=>{const u=sho(c.solverName);return G.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[G.jsx(u,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),G.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[G.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:c.componentName}),G.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:c.solverName})]})]})})()},a)})]}),G.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:i?s.instance?G.jsx(x3,{fallback:G.jsx("div",{className:"rf-p-4",children:G.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[G.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),G.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",i.solverName]})]})}),children:G.jsx(rho,{solver:s.instance})}):G.jsxs("div",{className:"rf-p-4",children:[G.jsxs("div",{className:"rf-mb-4",children:[G.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:i.solverName}),G.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",i.componentName]})]}),s.error&&G.jsx("div",{className:`rf-rounded-md rf-border rf-p-4 rf-mb-4 ${s.classFound?"rf-bg-red-50 rf-border-red-200":"rf-bg-yellow-50 rf-border-yellow-200"}`,children:G.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),G.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[G.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:G.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),G.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:G.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(i.solverParams,null,2)})})]})]}):G.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:G.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},myt=({errorMessage:t,errorStack:e,circuitJsonErrors:n})=>{Y.useEffect(()=>{if(t){const o=new Error(t);e&&(o.stack=e);try{SG.captureException(o)}catch{}}},[t,e]),Y.useEffect(()=>{if(n&&n.length>0)for(const o of n){const r=new Error(o.message||"Circuit JSON Error");o.stack&&(r.stack=o.stack);try{SG.captureException(r,{error_type:o.type})}catch{}}},[n])},pyt="0.0.1945",cho={version:pyt},uQ=yGe()(bGe(t=>({lastRunEvalVersion:void 0,setLastRunEvalVersion:e=>{t({lastRunEvalVersion:e})}}),{name:"runframe-runner-store"})),lho=t=>{const[e,n]=Y.useState([]),[o,r]=Y.useState(null),[i,s]=Y.useState(""),[a,c]=qE("eval-version-selection",null),l=uQ(m=>m.setLastRunEvalVersion),u=uQ(m=>m.lastRunEvalVersion);return Y.useEffect(()=>{t&&fetch("https://data.jsdelivr.com/v1/package/npm/@tscircuit/eval").then(m=>m.json()).then(m=>{if(Array.isArray(m?.versions)){let h=[...m.versions];m.tags?.latest&&(r(m.tags.latest),h=h.filter(p=>p!==m.tags.latest)),n(h)}}).catch(()=>{})},[t]),Y.useEffect(()=>{t&&(a?(window.TSCIRCUIT_LATEST_EVAL_VERSION=a,l(a)):o&&(window.TSCIRCUIT_LATEST_EVAL_VERSION=o,l(o)))},[t,a,o]),{versions:Y.useMemo(()=>e.filter(m=>m.includes(i)).slice(0,50),[e,i]),latestVersion:o,lastRunEvalVersion:u,search:i,setSearch:s,selectVersion:m=>{c(m),s("")}}},uho=({snippetNames:t,onSelect:e,onCancel:n,isOpen:o})=>{const[r,i]=Y.useState(""),[s,a]=Y.useState("");if(!o)return null;const c=t.filter(_=>_.toLowerCase().includes(s.toLowerCase())),l=s&&!t.includes(s),u=_=>{_.key==="Enter"&&(c.length===1?i(c[0]):l&&i(s))};return G.jsx("div",{className:"rf-fixed rf-inset-0 rf-bg-black rf-bg-opacity-50 rf-flex rf-items-center rf-justify-center rf-z-[100]",children:G.jsxs("div",{className:"rf-bg-white rf-rounded-lg rf-p-6 rf-w-96",children:[G.jsx("h2",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Select Snippet"}),G.jsx("input",{type:"text",className:"rf-w-full rf-px-4 rf-py-2 rf-border rf-rounded rf-mb-4",placeholder:"Search snippets or new snippet name...",value:s,onChange:_=>a(_.target.value),onKeyDown:u}),G.jsxs("div",{className:"rf-h-60 rf-overflow-y-auto",children:[c.map(_=>G.jsx("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 ${r===_?"bg-blue-50":""}`,onClick:()=>i(_),children:_},_)),l&&G.jsxs("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 text-blue-500 ${r===s?"bg-blue-50":""}`,onClick:()=>i(s),children:['Create new "',s,'"']})]}),G.jsxs("div",{className:"rf-mt-4 rf-flex rf-justify-end rf-gap-2",children:[G.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-text-gray-600 rf-hover:text-gray-800",onClick:n,children:"Cancel"}),G.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-bg-blue-500 rf-text-white rf-rounded rf-hover:bg-blue-600 rf-disabled:opacity-50",onClick:()=>r&&e(r),disabled:!r,children:r===s?`Create "${r}"`:`Save to ${r}`})]})]})})},_ho=t=>{const e=Y.useRef(null),n=v0(o=>o.recentEvents);Y.useEffect(()=>{if(n.length===0)return;const o=n[0];o.event_id!==e.current&&(t(o),e.current=o.event_id)},[n,t])};function dho(t){const e=hho(t),n=Y.forwardRef((o,r)=>{const{children:i,...s}=o,a=Y.Children.toArray(i),c=a.find(pho);if(c){const l=c.props.children,u=a.map(_=>_===c?Y.Children.count(l)>1?Y.Children.only(null):Y.isValidElement(l)?l.props.children:null:_);return G.jsx(e,{...s,ref:r,children:Y.isValidElement(l)?Y.cloneElement(l,void 0,u):null})}return G.jsx(e,{...s,ref:r,children:i})});return n.displayName=`${t}.Slot`,n}function hho(t){const e=Y.forwardRef((n,o)=>{const{children:r,...i}=n;if(Y.isValidElement(r)){const s=xho(r),a=fho(i,r.props);return r.type!==Y.Fragment&&(a.ref=o?vg(o,s):s),Y.cloneElement(r,a)}return Y.Children.count(r)>1?Y.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var mho=Symbol("radix.slottable");function pho(t){return Y.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===mho}function fho(t,e){const n={...e};for(const o in e){const r=t[o],i=e[o];/^on[A-Z]/.test(o)?r&&i?n[o]=(...a)=>{const c=i(...a);return r(...a),c}:r&&(n[o]=r):o==="style"?n[o]={...r,...i}:o==="className"&&(n[o]=[r,i].filter(Boolean).join(" "))}return{...t,...n}}function xho(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var _Q="Dialog",[fyt,xyt]=_b(_Q),[gho,Ob]=fyt(_Q),gyt=t=>{const{__scopeDialog:e,children:n,open:o,defaultOpen:r,onOpenChange:i,modal:s=!0}=t,a=Y.useRef(null),c=Y.useRef(null),[l,u]=ZS({prop:o,defaultProp:r??!1,onChange:i,caller:_Q});return G.jsx(gho,{scope:e,triggerRef:a,contentRef:c,contentId:Df(),titleId:Df(),descriptionId:Df(),open:l,onOpenChange:u,onOpenToggle:Y.useCallback(()=>u(_=>!_),[u]),modal:s,children:n})};gyt.displayName=_Q;var yyt="DialogTrigger",byt=Y.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,r=Ob(yyt,n),i=S0(e,r.triggerRef);return G.jsx(Uc.button,{type:"button","aria-haspopup":"dialog","aria-expanded":r.open,"aria-controls":r.contentId,"data-state":NPe(r.open),...o,ref:i,onClick:Qr(t.onClick,r.onOpenToggle)})});byt.displayName=yyt;var kPe="DialogPortal",[yho,Pyt]=fyt(kPe,{forceMount:void 0}),vyt=t=>{const{__scopeDialog:e,forceMount:n,children:o,container:r}=t,i=Ob(kPe,e);return G.jsx(yho,{scope:e,forceMount:n,children:Y.Children.map(o,s=>G.jsx(Ey,{present:n||i.open,children:G.jsx(RK,{asChild:!0,container:r,children:s})}))})};vyt.displayName=kPe;var dQ="DialogOverlay",Syt=Y.forwardRef((t,e)=>{const n=Pyt(dQ,t.__scopeDialog),{forceMount:o=n.forceMount,...r}=t,i=Ob(dQ,t.__scopeDialog);return i.modal?G.jsx(Ey,{present:o||i.open,children:G.jsx(Pho,{...r,ref:e})}):null});Syt.displayName=dQ;var bho=dho("DialogOverlay.RemoveScroll"),Pho=Y.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,r=Ob(dQ,n);return G.jsx(zK,{as:bho,allowPinchZoom:!0,shards:[r.contentRef],children:G.jsx(Uc.div,{"data-state":NPe(r.open),...o,ref:e,style:{pointerEvents:"auto",...o.style}})})}),$M="DialogContent",Cyt=Y.forwardRef((t,e)=>{const n=Pyt($M,t.__scopeDialog),{forceMount:o=n.forceMount,...r}=t,i=Ob($M,t.__scopeDialog);return G.jsx(Ey,{present:o||i.open,children:i.modal?G.jsx(vho,{...r,ref:e}):G.jsx(Sho,{...r,ref:e})})});Cyt.displayName=$M;var vho=Y.forwardRef((t,e)=>{const n=Ob($M,t.__scopeDialog),o=Y.useRef(null),r=S0(e,n.contentRef,o);return Y.useEffect(()=>{const i=o.current;if(i)return Mbe(i)},[]),G.jsx(Myt,{...t,ref:r,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Qr(t.onCloseAutoFocus,i=>{i.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:Qr(t.onPointerDownOutside,i=>{const s=i.detail.originalEvent,a=s.button===0&&s.ctrlKey===!0;(s.button===2||a)&&i.preventDefault()}),onFocusOutside:Qr(t.onFocusOutside,i=>i.preventDefault())})}),Sho=Y.forwardRef((t,e)=>{const n=Ob($M,t.__scopeDialog),o=Y.useRef(!1),r=Y.useRef(!1);return G.jsx(Myt,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{t.onCloseAutoFocus?.(i),i.defaultPrevented||(o.current||n.triggerRef.current?.focus(),i.preventDefault()),o.current=!1,r.current=!1},onInteractOutside:i=>{t.onInteractOutside?.(i),i.defaultPrevented||(o.current=!0,i.detail.originalEvent.type==="pointerdown"&&(r.current=!0));const s=i.target;n.triggerRef.current?.contains(s)&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&r.current&&i.preventDefault()}})}),Myt=Y.forwardRef((t,e)=>{const{__scopeDialog:n,trapFocus:o,onOpenAutoFocus:r,onCloseAutoFocus:i,...s}=t,a=Ob($M,n),c=Y.useRef(null),l=S0(e,c);return sbe(),G.jsxs(G.Fragment,{children:[G.jsx(yK,{asChild:!0,loop:!0,trapped:o,onMountAutoFocus:r,onUnmountAutoFocus:i,children:G.jsx(tO,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":NPe(a.open),...s,ref:l,onDismiss:()=>a.onOpenChange(!1)})}),G.jsxs(G.Fragment,{children:[G.jsx(Mho,{titleId:a.titleId}),G.jsx(who,{contentRef:c,descriptionId:a.descriptionId})]})]})}),RPe="DialogTitle",Tyt=Y.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,r=Ob(RPe,n);return G.jsx(Uc.h2,{id:r.titleId,...o,ref:e})});Tyt.displayName=RPe;var wyt="DialogDescription",Eyt=Y.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,r=Ob(wyt,n);return G.jsx(Uc.p,{id:r.descriptionId,...o,ref:e})});Eyt.displayName=wyt;var Dyt="DialogClose",Ayt=Y.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,r=Ob(Dyt,n);return G.jsx(Uc.button,{type:"button",...o,ref:e,onClick:Qr(t.onClick,()=>r.onOpenChange(!1))})});Ayt.displayName=Dyt;function NPe(t){return t?"open":"closed"}var kyt="DialogTitleWarning",[Cho,Ryt]=Tfn(kyt,{contentName:$M,titleName:RPe,docsSlug:"dialog"}),Mho=({titleId:t})=>{const e=Ryt(kyt),n=`\`${e.contentName}\` requires a \`${e.titleName}\` for the component to be accessible for screen reader users.
|
|
5738
5738
|
|
|
5739
5739
|
If you want to hide the \`${e.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
5740
5740
|
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@tscircuit/runframe",
|
|
3
3
|
"main": "dist/preview.js",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "0.0.
|
|
5
|
+
"version": "0.0.1946",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": "./dist/preview.js",
|
|
8
8
|
"./preview": "./dist/preview.js",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"@tscircuit/fake-snippets": "^0.0.163",
|
|
53
53
|
"@tscircuit/file-server": "^0.0.32",
|
|
54
54
|
"@tscircuit/internal-dynamic-import": "^0.0.0",
|
|
55
|
-
"@tscircuit/pcb-viewer": "1.11.
|
|
55
|
+
"@tscircuit/pcb-viewer": "1.11.369",
|
|
56
56
|
"@tscircuit/schematic-viewer": "^2.0.61",
|
|
57
57
|
"@types/bun": "latest",
|
|
58
58
|
"@types/debug": "^4.1.12",
|
|
@@ -113,7 +113,7 @@
|
|
|
113
113
|
"yargs": "^17.7.2"
|
|
114
114
|
},
|
|
115
115
|
"dependencies": {
|
|
116
|
-
"@tscircuit/eval": "^0.0.
|
|
116
|
+
"@tscircuit/eval": "^0.0.837",
|
|
117
117
|
"@tscircuit/solver-utils": "^0.0.7"
|
|
118
118
|
}
|
|
119
119
|
}
|