tscircuit 0.0.1918 → 0.0.1919
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.min.js +3 -3
- package/package.json +3 -3
package/dist/browser.min.js
CHANGED
|
@@ -5661,7 +5661,7 @@ You passed in: '`+this.raw_options[r]+"'");return c},n.prototype._is_valid_selec
|
|
|
5661
5661
|
`+k)}B&&(E?E=B+E+`
|
|
5662
5662
|
`+M:E=B+M),f.print_newline(!1),E&&(y.text=E,y.whitespace_before="",y.newlines=0,f.add_raw_token(y),f.print_newline(!0))}},h.prototype._handle_tag_open=function(f,y,C,I,E){var b=this._get_tag_open_token(y);if((C.is_unformatted||C.is_content_unformatted)&&!C.is_empty_element&&y.type===r.TAG_OPEN&&!b.is_start_tag?(f.add_raw_token(y),b.start_tag_token=this._tag_stack.try_pop(b.tag_name)):(f.traverse_whitespace(y),this._set_tag_position(f,y,b,C,I),b.is_inline_element||f.set_wrap_point(),f.print_token(y)),b.is_start_tag&&this._is_wrap_attributes_force){var P=0,B;do B=E.peek(P),B.type===r.ATTRIBUTE&&(b.attr_count+=1),P+=1;while(B.type!==r.EOF&&B.type!==r.TAG_CLOSE)}return(this._is_wrap_attributes_force_aligned||this._is_wrap_attributes_aligned_multiple||this._is_wrap_attributes_preserve_aligned)&&(b.alignment_size=y.text.length+1),!b.tag_complete&&!b.is_unformatted&&(f.alignment_size=b.alignment_size),b};var m=function(f,y,C){if(this.parent=y||null,this.text="",this.type="TK_TAG_OPEN",this.tag_name="",this.is_inline_element=!1,this.is_unformatted=!1,this.is_content_unformatted=!1,this.is_empty_element=!1,this.is_start_tag=!1,this.is_end_tag=!1,this.indent_content=!1,this.multiline_content=!1,this.custom_beautifier_name=null,this.start_tag_token=null,this.attr_count=0,this.has_wrapped_attrs=!1,this.alignment_size=0,this.tag_complete=!1,this.tag_start_char="",this.tag_check="",!C)this.tag_complete=!0;else{var I;this.tag_start_char=C.text[0],this.text=C.text,this.tag_start_char==="<"?(I=C.text.match(/^<([^\s>]*)/),this.tag_check=I?I[1]:""):(I=C.text.match(/^{{~?(?:[\^]|#\*?)?([^\s}]+)/),this.tag_check=I?I[1]:"",(C.text.startsWith("{{#>")||C.text.startsWith("{{~#>"))&&this.tag_check[0]===">"&&(this.tag_check===">"&&C.next!==null?this.tag_check=C.next.text.split(" ")[0]:this.tag_check=C.text.split(">")[1])),this.tag_check=this.tag_check.toLowerCase(),C.type===r.COMMENT&&(this.tag_complete=!0),this.is_start_tag=this.tag_check.charAt(0)!=="/",this.tag_name=this.is_start_tag?this.tag_check:this.tag_check.substr(1),this.is_end_tag=!this.is_start_tag||C.closed&&C.closed.text==="/>";var E=2;this.tag_start_char==="{"&&this.text.length>=3&&this.text.charAt(2)==="~"&&(E=3),this.is_end_tag=this.is_end_tag||this.tag_start_char==="{"&&(!f.indent_handlebars||this.text.length<3||/[^#\^]/.test(this.text.charAt(E)))}};h.prototype._get_tag_open_token=function(f){var y=new m(this._options,this._tag_stack.get_parser_token(),f);return y.alignment_size=this._options.wrap_attributes_indent_size,y.is_end_tag=y.is_end_tag||u(y.tag_check,this._options.void_elements),y.is_empty_element=y.tag_complete||y.is_start_tag&&y.is_end_tag,y.is_unformatted=!y.tag_complete&&u(y.tag_check,this._options.unformatted),y.is_content_unformatted=!y.is_empty_element&&u(y.tag_check,this._options.content_unformatted),y.is_inline_element=u(y.tag_name,this._options.inline)||this._options.inline_custom_elements&&y.tag_name.includes("-")||y.tag_start_char==="{",y},h.prototype._set_tag_position=function(f,y,C,I,E){if(C.is_empty_element||(C.is_end_tag?C.start_tag_token=this._tag_stack.try_pop(C.tag_name):(this._do_optional_end_element(C)&&(C.is_inline_element||f.print_newline(!1)),this._tag_stack.record_tag(C),(C.tag_name==="script"||C.tag_name==="style")&&!(C.is_unformatted||C.is_content_unformatted)&&(C.custom_beautifier_name=A(C.tag_check,y)))),u(C.tag_check,this._options.extra_liners)&&(f.print_newline(!1),f._output.just_added_blankline()||f.print_newline(!0)),C.is_empty_element){if(C.tag_start_char==="{"&&C.tag_check==="else"){this._tag_stack.indent_to_tag(["if","unless","each"]),C.indent_content=!0;var b=f.current_line_has_match(/{{#if/);b||f.print_newline(!1)}C.tag_name==="!--"&&E.type===r.TAG_CLOSE&&I.is_end_tag&&C.text.indexOf(`
|
|
5663
5663
|
`)===-1||(C.is_inline_element||C.is_unformatted||f.print_newline(!1),this._calcluate_parent_multiline(f,C))}else if(C.is_end_tag){var P=!1;P=C.start_tag_token&&C.start_tag_token.multiline_content,P=P||!C.is_inline_element&&!(I.is_inline_element||I.is_unformatted)&&!(E.type===r.TAG_CLOSE&&C.start_tag_token===I)&&E.type!=="TK_CONTENT",(C.is_content_unformatted||C.is_unformatted)&&(P=!1),P&&f.print_newline(!1)}else C.indent_content=!C.custom_beautifier_name,C.tag_start_char==="<"&&(C.tag_name==="html"?C.indent_content=this._options.indent_inner_html:C.tag_name==="head"?C.indent_content=this._options.indent_head_inner_html:C.tag_name==="body"&&(C.indent_content=this._options.indent_body_inner_html)),!(C.is_inline_element||C.is_unformatted)&&(E.type!=="TK_CONTENT"||C.is_content_unformatted)&&f.print_newline(!1),this._calcluate_parent_multiline(f,C)},h.prototype._calcluate_parent_multiline=function(f,y){y.parent&&f._output.just_added_newline()&&!((y.is_inline_element||y.is_unformatted)&&y.parent.is_inline_element)&&(y.parent.multiline_content=!0)};var p=["address","article","aside","blockquote","details","div","dl","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hr","main","menu","nav","ol","p","pre","section","table","ul"],g=["a","audio","del","ins","map","noscript","video"];h.prototype._do_optional_end_element=function(f){var y=null;if(!(f.is_empty_element||!f.is_start_tag||!f.parent)){if(f.tag_name==="body")y=y||this._tag_stack.try_pop("head");else if(f.tag_name==="li")y=y||this._tag_stack.try_pop("li",["ol","ul","menu"]);else if(f.tag_name==="dd"||f.tag_name==="dt")y=y||this._tag_stack.try_pop("dt",["dl"]),y=y||this._tag_stack.try_pop("dd",["dl"]);else if(f.parent.tag_name==="p"&&p.indexOf(f.tag_name)!==-1){var C=f.parent.parent;(!C||g.indexOf(C.tag_name)===-1)&&(y=y||this._tag_stack.try_pop("p"))}else f.tag_name==="rp"||f.tag_name==="rt"?(y=y||this._tag_stack.try_pop("rt",["ruby","rtc"]),y=y||this._tag_stack.try_pop("rp",["ruby","rtc"])):f.tag_name==="optgroup"?y=y||this._tag_stack.try_pop("optgroup",["select"]):f.tag_name==="option"?y=y||this._tag_stack.try_pop("option",["select","datalist","optgroup"]):f.tag_name==="colgroup"?y=y||this._tag_stack.try_pop("caption",["table"]):f.tag_name==="thead"?(y=y||this._tag_stack.try_pop("caption",["table"]),y=y||this._tag_stack.try_pop("colgroup",["table"])):f.tag_name==="tbody"||f.tag_name==="tfoot"?(y=y||this._tag_stack.try_pop("caption",["table"]),y=y||this._tag_stack.try_pop("colgroup",["table"]),y=y||this._tag_stack.try_pop("thead",["table"]),y=y||this._tag_stack.try_pop("tbody",["table"])):f.tag_name==="tr"?(y=y||this._tag_stack.try_pop("caption",["table"]),y=y||this._tag_stack.try_pop("colgroup",["table"]),y=y||this._tag_stack.try_pop("tr",["table","thead","tbody","tfoot"])):(f.tag_name==="th"||f.tag_name==="td")&&(y=y||this._tag_stack.try_pop("td",["table","thead","tbody","tfoot","tr"]),y=y||this._tag_stack.try_pop("th",["table","thead","tbody","tfoot","tr"]));return f.parent=this._tag_stack.get_parser_token(),y}},e.exports.Beautifier=h}}),Hxo=Wc({"node_modules/js-beautify/js/src/html/index.js"(t,e){var n=kxo().Beautifier,o=aSt().Options;function i(r,s,a,c){var l=new n(r,s,a,c);return l.beautify()}e.exports=i,e.exports.defaultOptions=function(){return new o}}}),Lxo=Wc({"node_modules/js-beautify/js/src/index.js"(t,e){var n=Txo(),o=Nxo(),i=Hxo();function r(s,a,c,l){return c=c||n,l=l||o,i(s,a,c,l)}r.defaultOptions=i.defaultOptions,e.exports.js=n,e.exports.css=o,e.exports.html=r}}),Fxo=Wc({"node_modules/js-beautify/js/index.js"(t,e){function n(o,i,r){var s=function(a,c){return o.js_beautify(a,c)};return s.js=o.js_beautify,s.css=i.css_beautify,s.html=r.html_beautify,s.js_beautify=o.js_beautify,s.css_beautify=i.css_beautify,s.html_beautify=r.html_beautify,s}typeof define=="function"&&define.amd?define(["./lib/beautify","./lib/beautify-css","./lib/beautify-html"],function(o,i,r){return n(o,i,r)}):(function(o){var i=Lxo();i.js_beautify=i.js,i.css_beautify=i.css,i.html_beautify=i.html,o.exports=n(i,i,i)})(e)}}),Oxo=Wc({"node_modules/is-whitespace/index.js"(t,e){var n;e.exports=function(r){return typeof r=="string"&&o().test(r)};function o(){return n||(n=new RegExp(`^[\\s
|
|
5664
|
-
\v\f\r \u2028\u2029\uFEFF"]+$`))}}}),Gxo=Wc({"node_modules/is-extendable/index.js"(t,e){e.exports=function(o){return typeof o<"u"&&o!==null&&(typeof o=="object"||typeof o=="function")}}}),lSt=Wc({"node_modules/extend-shallow/index.js"(t,e){var n=Gxo();e.exports=function(s){n(s)||(s={});for(var a=arguments.length,c=1;c<a;c++){var l=arguments[c];n(l)&&o(s,l)}return s};function o(r,s){for(var a in s)i(s,a)&&(r[a]=s[a])}function i(r,s){return Object.prototype.hasOwnProperty.call(r,s)}}}),Uxo=Wc({"node_modules/is-buffer/index.js"(t,e){e.exports=function(i){return i!=null&&(n(i)||o(i)||!!i._isBuffer)};function n(i){return!!i.constructor&&typeof i.constructor.isBuffer=="function"&&i.constructor.isBuffer(i)}function o(i){return typeof i.readFloatLE=="function"&&typeof i.slice=="function"&&n(i.slice(0,0))}}}),zxo=Wc({"node_modules/kind-of/index.js"(t,e){var n=Uxo(),o=Object.prototype.toString;e.exports=function(r){if(typeof r>"u")return"undefined";if(r===null)return"null";if(r===!0||r===!1||r instanceof Boolean)return"boolean";if(typeof r=="string"||r instanceof String)return"string";if(typeof r=="number"||r instanceof Number)return"number";if(typeof r=="function"||r instanceof Function)return"function";if(typeof Array.isArray<"u"&&Array.isArray(r))return"array";if(r instanceof RegExp)return"regexp";if(r instanceof Date)return"date";var s=o.call(r);return s==="[object RegExp]"?"regexp":s==="[object Date]"?"date":s==="[object Arguments]"?"arguments":s==="[object Error]"?"error":n(r)?"buffer":s==="[object Set]"?"set":s==="[object WeakSet]"?"weakset":s==="[object Map]"?"map":s==="[object WeakMap]"?"weakmap":s==="[object Symbol]"?"symbol":s==="[object Int8Array]"?"int8array":s==="[object Uint8Array]"?"uint8array":s==="[object Uint8ClampedArray]"?"uint8clampedarray":s==="[object Int16Array]"?"int16array":s==="[object Uint16Array]"?"uint16array":s==="[object Int32Array]"?"int32array":s==="[object Uint32Array]"?"uint32array":s==="[object Float32Array]"?"float32array":s==="[object Float64Array]"?"float64array":"object"}}}),Vxo=Wc({"node_modules/condense-newlines/index.js"(t,e){var n=Oxo(),o=lSt(),i=zxo();e.exports=function(s,a){var c=o({},a),l=c.sep||`
|
|
5664
|
+
\v\f\r \u2028\u2029\uFEFF"]+$`))}}}),Gxo=Wc({"node_modules/is-extendable/index.js"(t,e){e.exports=function(o){return typeof o<"u"&&o!==null&&(typeof o=="object"||typeof o=="function")}}}),lSt=Wc({"node_modules/extend-shallow/index.js"(t,e){var n=Gxo();e.exports=function(s){n(s)||(s={});for(var a=arguments.length,c=1;c<a;c++){var l=arguments[c];n(l)&&o(s,l)}return s};function o(r,s){for(var a in s)i(s,a)&&(r[a]=s[a])}function i(r,s){return Object.prototype.hasOwnProperty.call(r,s)}}}),Uxo=Wc({"node_modules/is-buffer/index.js"(t,e){e.exports=function(i){return i!=null&&(n(i)||o(i)||!!i._isBuffer)};function n(i){return!!i.constructor&&typeof i.constructor.isBuffer=="function"&&i.constructor.isBuffer(i)}function o(i){return typeof i.readFloatLE=="function"&&typeof i.slice=="function"&&n(i.slice(0,0))}}}),zxo=Wc({"node_modules/condense-newlines/node_modules/kind-of/index.js"(t,e){var n=Uxo(),o=Object.prototype.toString;e.exports=function(r){if(typeof r>"u")return"undefined";if(r===null)return"null";if(r===!0||r===!1||r instanceof Boolean)return"boolean";if(typeof r=="string"||r instanceof String)return"string";if(typeof r=="number"||r instanceof Number)return"number";if(typeof r=="function"||r instanceof Function)return"function";if(typeof Array.isArray<"u"&&Array.isArray(r))return"array";if(r instanceof RegExp)return"regexp";if(r instanceof Date)return"date";var s=o.call(r);return s==="[object RegExp]"?"regexp":s==="[object Date]"?"date":s==="[object Arguments]"?"arguments":s==="[object Error]"?"error":n(r)?"buffer":s==="[object Set]"?"set":s==="[object WeakSet]"?"weakset":s==="[object Map]"?"map":s==="[object WeakMap]"?"weakmap":s==="[object Symbol]"?"symbol":s==="[object Int8Array]"?"int8array":s==="[object Uint8Array]"?"uint8array":s==="[object Uint8ClampedArray]"?"uint8clampedarray":s==="[object Int16Array]"?"int16array":s==="[object Uint16Array]"?"uint16array":s==="[object Int32Array]"?"int32array":s==="[object Uint32Array]"?"uint32array":s==="[object Float32Array]"?"float32array":s==="[object Float64Array]"?"float64array":"object"}}}),Vxo=Wc({"node_modules/condense-newlines/index.js"(t,e){var n=Oxo(),o=lSt(),i=zxo();e.exports=function(s,a){var c=o({},a),l=c.sep||`
|
|
5665
5665
|
|
|
5666
5666
|
`,A=c.min,u;return typeof A=="number"&&A!==2&&(u=new RegExp("(\\r\\n|\\n|\\u2424) {"+A+",}")),typeof u>"u"&&(u=c.regex||/(\r\n|\n|\u2424){2,}/g),c.keepWhitespace!==!0&&(s=s.split(`
|
|
5667
5667
|
`).map(function(d){return n(d)?d.trim():d}).join(`
|
|
@@ -5708,7 +5708,7 @@ $1`).replace(/>(\s*)(?=<!--\s*\/)/g,"> ")}}});function ASt(t,e,n){if(!e||!n)retu
|
|
|
5708
5708
|
transition: opacity 0.2s;
|
|
5709
5709
|
margin-bottom: 10px;
|
|
5710
5710
|
color: red;
|
|
5711
|
-
`,i5o=({children:t,transform:e=dA(),elements:n})=>{const o=J.useRef(null),{isShowingDRCErrors:i,hoveredErrorId:r,focusedErrorId:s}=Ld(m=>({isShowingDRCErrors:m.is_showing_drc_errors,hoveredErrorId:m.hovered_error_id,focusedErrorId:m.focused_error_id})),a=s??r;if(!n)return K.jsx("div",{style:{position:"relative"},ref:o,children:t});const c=n.filter(m=>m.type==="pcb_trace_error"&&!m.message?.includes("Multiple components found with name")),l=n.filter(m=>m.type==="pcb_via_clearance_error"),A=n.filter(m=>m.type==="pcb_trace_error"&&m.message?.includes("Multiple components found with name")),u=CSt(n),d=ySt(n,a),_=m=>{const p=S2o({error:m,indexes:u});if(!p||typeof p.x!="number"||typeof p.y!="number")return null;const g=ht(e,p);return Number.isNaN(g.x)||Number.isNaN(g.y)?null:g};let h=null;return d&&(h=_(d)),K.jsxs("div",{style:{position:"relative"},ref:o,children:[t,c.map((m,p)=>{const g=JQ(m,p),f=a===g;if(!f&&!i)return null;const y=_(m);if(!y)return null;const C=XPe(y,o);return K.jsxs(J.Fragment,{children:[K.jsx(YSt,{errorCenter:y,isHighlighted:f}),K.jsx("div",{style:{position:"absolute",left:y.x-15,top:y.y-15,width:30,height:30,zIndex:bA.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:I=>{const E=I.currentTarget.nextElementSibling;if(E){const b=E.querySelector(".error-message");b&&(b.style.opacity="1")}},onMouseLeave:I=>{if(!f){const E=I.currentTarget.nextElementSibling;if(E){const b=E.querySelector(".error-message");b&&(b.style.opacity="0")}}}}),K.jsx("div",{style:{position:"absolute",zIndex:f?200:100,left:C.left,top:C.top,color:f?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:i||f?"flex":"none",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:C.transform},children:K.jsx("div",{className:`error-message ${JPe}`,style:{opacity:f?1:0,border:`1px solid ${f?"#ff4444":"red"}`},children:m.message})})]},g)}),l.map((m,p)=>{const g=JQ(m,p),f=a===g;if(!f&&!i)return null;const y=_(m);if(!y)return null;const C=XPe({x:y.x,y:y.y},o);return K.jsxs(J.Fragment,{children:[K.jsx(YSt,{errorCenter:y,isHighlighted:f}),K.jsx("div",{style:{position:"absolute",left:y.x-15,top:y.y-15,width:30,height:30,zIndex:bA.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:I=>{const E=I.currentTarget.nextElementSibling;if(E){const b=E.querySelector(".error-message");b&&(b.style.opacity="1")}},onMouseLeave:I=>{if(!f){const E=I.currentTarget.nextElementSibling;if(E){const b=E.querySelector(".error-message");b&&(b.style.opacity="0")}}}}),K.jsx("div",{style:{position:"absolute",zIndex:f?bA.errorOverlay+10:bA.errorOverlay+1,left:C.left,top:C.top,color:f?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:"flex",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:C.transform},children:K.jsx("div",{className:`error-message ${JPe}`,style:{opacity:f?1:0,border:`1px solid ${f?"#ff4444":"red"}`},children:m.message})})]},g)}),A.map((m,p)=>{const g=m.component_name||m.message?.match(/name "([^"]+)"/)?.[1];if(!g)return null;const f=n?.filter(I=>I.type==="source_component"&&I.name===g||I.type==="pcb_component"&&n?.find(E=>E.type==="source_component"&&E.source_component_id===I.source_component_id&&E.name===g))||[],y=JQ(m,p),C=a===y;return!C&&!i?null:f.map((I,E)=>{let b={x:0,y:0};if(I.type==="pcb_component")b=I.center||{x:0,y:0};else if(I.type==="source_component"){const G=n?.find(W=>W.type==="pcb_component"&&W.source_component_id===I.source_component_id);G&&G.type==="pcb_component"&&(b=G.center||{x:0,y:0})}const P=ht(e,b);if(Number.isNaN(P.x)||Number.isNaN(P.y))return null;const B=Math.abs(e.a),L=Math.max(8,Math.min(30,.5*B)),F=XPe(P,o);return K.jsxs(J.Fragment,{children:[K.jsx("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none",mixBlendMode:"difference",zIndex:bA.errorOverlay},width:"100%",height:"100%",children:C?K.jsx("polygon",{points:`${P.x},${P.y-L*1.25} ${P.x+L},${P.y} ${P.x},${P.y+L*1.25} ${P.x-L},${P.y}`,fill:"#ff4444"}):K.jsx("circle",{cx:P.x,cy:P.y,r:L,fill:"none",stroke:C?"#ff4444":"red",strokeWidth:C?Math.max(2,L*.15):Math.max(1,L*.1),opacity:1})}),K.jsx("div",{style:{position:"absolute",left:P.x-(L+10),top:P.y-(L+10),width:(L+10)*2,height:(L+10)*2,zIndex:bA.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:G=>{const W=G.currentTarget.nextElementSibling;if(W){const j=W.querySelector(".error-message");j&&(j.style.opacity="1")}},onMouseLeave:G=>{if(!C){const W=G.currentTarget.nextElementSibling;if(W){const j=W.querySelector(".error-message");j&&(j.style.opacity="0")}}}}),K.jsx("div",{style:{position:"absolute",zIndex:C?bA.errorOverlay+20:bA.errorOverlay+10,left:F.left,top:F.top,color:C?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:i||C?"flex":"none",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:F.transform},children:K.jsx("div",{className:`error-message ${JPe}`,style:{opacity:C?1:0,border:`1px solid ${C?"#ff4444":"red"}`},children:m.message})})]},`${y}_${E}`)})}),h&&K.jsx(o5o,{center:h})]})};function r5o(t,e){return t.size!==e.size?!1:Array.from(t).every(n=>e.has(n))}function s5o({primitiveElement:t,elements:e}){let n=t.trace_length?`${t.trace_length.toFixed(3)}`:"";const o=uv(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 i=t.trace_length&&o?.max_length&&t.trace_length>o.max_length;return{text:n,isOverLength:i}}function a5o(t){const{primitives:e,is_showing_multiple_traces_length:n,elements:o}=t,i=e.filter(c=>c._element.type==="pcb_trace"),r=o.filter(c=>c.type==="source_trace"),s=e.filter(c=>c._element.type!=="pcb_trace"),a=i.filter(c=>r.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(i.length>1){const c=i.reduce((l,A)=>{const u=l._element.trace_length;return A._element.trace_length<u?A:l},i[0]);return[...s,c]}return e}var c5o={position:"absolute",left:0,top:0,pointerEvents:"none",color:"red",fontFamily:"sans-serif",fontSize:12,textShadow:"0 0 2px black"},l5o=t=>{const{_element:e,_parent_pcb_component:n,_parent_source_component:o,_source_port:i}=t;switch(e.type){case"pcb_trace":return e.trace_length?`${e.trace_length.toFixed(3)}`:"";case"pcb_smtpad":case"pcb_plated_hole":{const r=[],s=Array.from(new Set((e.port_hints??[]).concat(i?.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?r.push(...s.map(c=>`${a}.${c}`)):r.push(...s):a&&r.push(a),r.join(", ")}default:return""}},A5o={top:"red",bottom:"aqua"},u5o=({primitive:t,mousePos:e,elements:n})=>{const[o,i]=J.useState(!1),r=t._element;J.useEffect(()=>{setTimeout(()=>{i(!0)},100)},[]);const[s,a,c,l]=[t.screen_x,t.screen_y,t.screen_w,t.screen_h],A=t.same_space_index??0,u=26,d=A5o[t?._element?.layer]??"red";let _=0;if(r.type==="pcb_smtpad"&&r?.shape==="rotated_rect"?_=r?.ccw_rotation??0:(r.type==="pcb_smtpad"&&(r?.shape==="pill"||r?.shape==="rotated_pill")&&"ccw_rotation"in t||r.type==="pcb_plated_hole"&&(r?.shape==="pill"||r?.shape==="oval")&&"ccw_rotation"in t)&&(_=r.ccw_rotation??0),r.type==="pcb_trace"){const p=s5o({primitiveElement:r,elements:n});if(!p)return null;const g=e.y-35;return K.jsx("div",{style:{zIndex:bA.elementOverlay,position:"absolute",left:e.x,top:g,color:d,pointerEvents:"none",transform:"translateX(-50%)"},children:K.jsx("div",{style:{backgroundColor:"#f2efcc",color:p.isOverLength?"red":"black",textShadow:"none",WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale",padding:"6px 6px",borderRadius:"6px",fontSize:"14px",minWidth:"45px",textAlign:"center",whiteSpace:"nowrap"},children:p.text})})}const h=l5o(t);return h.trim().length===0?null:K.jsx("div",{style:{zIndex:bA.elementOverlay,position:"absolute",left:s-c/2-8,top:a-l/2-8,width:c+16,height:l+16,color:d,transform:`rotate(${-_}deg)`,transformOrigin:"center center"},children:K.jsx("div",{style:{width:o?`calc(100% + ${u*2*A}px)`:"100%",height:o?`calc(100% + ${u*2*A}px)`:"100%",marginLeft:o?`${-u*A}px`:0,marginTop:o?`${-u*A}px`:0,border:`1px solid ${d}`,opacity:o||A===0?1:0,transition:"width 0.2s, height 0.2s, margin-left 0.2s, margin-top 0.2s, opacity 0.2s"},children:K.jsx("div",{style:{position:"absolute",bottom:l+20+u*A,marginRight:o?`${-u*A}px`:0,marginBottom:o?0:-u*A,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(${_}deg)`,minWidth:"45px",textAlign:"center"},children:h})})})},d5o=({highlightedPrimitives:t,mousePos:e,elements:n})=>{const[o,i]=Ld(a=>[a.is_moving_component,a.is_showing_multiple_traces_length]),r=t.some(a=>a._element.type==="pcb_smtpad")&&t.some(a=>a._element.type==="pcb_trace");let s=t;return r&&(s=s.filter(a=>a._element.type==="pcb_smtpad")),s=a5o({primitives:s,is_showing_multiple_traces_length:i,elements:n}),K.jsx("div",{style:c5o,children:!o&&s.map((a,c)=>K.jsx(u5o,{primitive:a,mousePos:e,elements:n},c))})},dv=t=>t?.type==="pcb_component",KSt=t=>t?.type==="pcb_group",h5o=t=>t?.type==="pcb_panel",qPe=t=>t?.type==="pcb_board",zu={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},Rx={OFFSET_LINE:"white",COMPONENT_MARKER_FILL:"#66ccff",COMPONENT_MARKER_STROKE:"white",LABEL_TEXT:"white"},$Pe=({targets:t,transform:e,containerWidth:n,containerHeight:o})=>{if(t.length===0)return null;const i={color:Rx.LABEL_TEXT,mixBlendMode:"difference",pointerEvents:"none",fontSize:zu.LABEL_FONT_SIZE,fontFamily:"monospace",fontWeight:"bold"},r=new Map;return t.forEach(s=>{if(!r.has(s.anchor_id)){const a=ht(e,s.anchor);r.set(s.anchor_id,a)}}),K.jsx("div",{style:{position:"absolute",left:0,top:0,width:n,height:o,overflow:"hidden",pointerEvents:"none",zIndex:bA.dimensionOverlay},children:K.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,A=r.get(c),u=ht(e,l),d=l.x-a.x,_=l.y-a.y,h=Math.abs(u.x-A.x),m=Math.abs(u.y-A.y),p=u.y<A.y,g=u.x>A.x,f=p?zu.LABEL_OFFSET_ABOVE:zu.LABEL_OFFSET_BELOW,y=g?zu.LABEL_OFFSET_RIGHT:zu.LABEL_OFFSET_LEFT,C=h>zu.MIN_LINE_LENGTH_FOR_LABEL,I=m>zu.MIN_LINE_LENGTH_FOR_LABEL,E=`${s.display_offset_x??d.toFixed(2)}mm`,b=`${s.display_offset_y??_.toFixed(2)}mm`;return K.jsxs("g",{children:[K.jsx("line",{x1:A.x,y1:A.y,x2:u.x,y2:A.y,stroke:Rx.OFFSET_LINE,strokeWidth:zu.LINE_STROKE_WIDTH,strokeDasharray:zu.LINE_DASH_PATTERN}),K.jsx("line",{x1:u.x,y1:A.y,x2:u.x,y2:u.y,stroke:Rx.OFFSET_LINE,strokeWidth:zu.LINE_STROKE_WIDTH,strokeDasharray:zu.LINE_DASH_PATTERN}),s.type==="component"||s.type==="board"?K.jsx("circle",{cx:u.x,cy:u.y,r:zu.COMPONENT_MARKER_RADIUS,fill:Rx.COMPONENT_MARKER_FILL,stroke:Rx.COMPONENT_MARKER_STROKE,strokeWidth:1}):K.jsxs(K.Fragment,{children:[K.jsx("line",{x1:u.x-zu.ANCHOR_MARKER_SIZE,y1:u.y,x2:u.x+zu.ANCHOR_MARKER_SIZE,y2:u.y,stroke:Rx.OFFSET_LINE,strokeWidth:zu.ANCHOR_MARKER_STROKE_WIDTH}),K.jsx("line",{x1:u.x,y1:u.y-zu.ANCHOR_MARKER_SIZE,x2:u.x,y2:u.y+zu.ANCHOR_MARKER_SIZE,stroke:Rx.OFFSET_LINE,strokeWidth:zu.ANCHOR_MARKER_STROKE_WIDTH})]}),C&&K.jsx("foreignObject",{x:Math.min(A.x,u.x),y:A.y+f,width:Math.abs(u.x-A.x),height:20,style:{overflow:"visible"},children:K.jsx("div",{style:{...i,textAlign:"center"},children:E})}),I&&K.jsx("foreignObject",{x:u.x+y,y:Math.min(A.y,u.y),width:zu.Y_LABEL_MIN_WIDTH,height:Math.abs(u.y-A.y),style:{overflow:"visible"},children:K.jsx("div",{style:{...i,display:"flex",alignItems:"center",justifyContent:g?"flex-start":"flex-end",whiteSpace:"nowrap",padding:"0 4px",height:"100%"},children:b})})]},s.id)}),Array.from(r.entries()).map(([s,a])=>K.jsxs("g",{children:[K.jsx("line",{x1:a.x-zu.ANCHOR_MARKER_SIZE,y1:a.y,x2:a.x+zu.ANCHOR_MARKER_SIZE,y2:a.y,stroke:Rx.OFFSET_LINE,strokeWidth:zu.ANCHOR_MARKER_STROKE_WIDTH}),K.jsx("line",{x1:a.x,y1:a.y-zu.ANCHOR_MARKER_SIZE,x2:a.x,y2:a.y+zu.ANCHOR_MARKER_SIZE,stroke:Rx.OFFSET_LINE,strokeWidth:zu.ANCHOR_MARKER_STROKE_WIDTH})]},`anchor-${s}`))]})})},_5o=({elements:t,highlightedPrimitives:e,transform:n,containerWidth:o,containerHeight:i})=>{const r=t.filter(g=>qPe(g)),s=t.filter(g=>dv(g)),a=t.filter(g=>KSt(g)),c=e.map(g=>dv(g._parent_pcb_component)?g._parent_pcb_component.pcb_component_id:dv(g._element)?g._element.pcb_component_id:null).filter(g=>!!g),l=new Set;if(c.forEach(g=>{const f=s.find(y=>y.pcb_component_id===g);f?.pcb_group_id&&l.add(f.pcb_group_id)}),!Ld(g=>g.is_showing_group_anchor_offsets)&&c.length===0)return null;const u=s.map(g=>{const f=g.positioned_relative_to_pcb_board_id;if(!f)return null;const y=r.find(C=>C.pcb_board_id===f);return y?{component:g,board:y,type:"component"}:null}).filter(g=>!!g),d=a.map(g=>{const f=g.positioned_relative_to_pcb_board_id;if(!f||!g.center)return null;const y=r.find(C=>C.pcb_board_id===f);return y?{group:g,board:y,type:"group"}:null}).filter(g=>!!g),_=[...u,...d];if(_.length===0)return null;const h=c.length===0,m=_.filter(g=>g.type==="component"?h||c.includes(g.component.pcb_component_id):h||l.has(g.group.pcb_group_id));if(m.length===0)return null;const p=m.map(g=>g.type==="component"?{id:`${g.board.pcb_board_id}-${g.component.pcb_component_id}-${g.type}`,anchor:g.board.center,anchor_id:g.board.pcb_board_id,target:g.component.center,type:"component",display_offset_x:g.component.display_offset_x,display_offset_y:g.component.display_offset_y}:{id:`${g.board.pcb_board_id}-${g.group.pcb_group_id}-${g.type}`,anchor:g.board.center,anchor_id:g.board.pcb_board_id,target:{x:g.group.anchor_position?.x??g.group.center.x,y:g.group.anchor_position?.y??g.group.center.y},type:"group",display_offset_x:g.group.display_offset_x,display_offset_y:g.group.display_offset_y}).filter(g=>!!g);return K.jsx($Pe,{targets:p,transform:n,containerWidth:o,containerHeight:i})},m5o=({elements:t,highlightedPrimitives:e,transform:n,containerWidth:o,containerHeight:i})=>{const r=t.filter(g=>KSt(g)),s=t.filter(g=>dv(g)),a=e.map(g=>dv(g._parent_pcb_component)?g._parent_pcb_component.pcb_component_id:dv(g._element)?g._element.pcb_component_id:null).filter(g=>!!g),c=(g,f)=>{if(f.has(g))return;f.add(g);const y=r.find(C=>C.pcb_group_id===g);y?.position_mode==="relative_to_group_anchor"&&y.positioned_relative_to_pcb_group_id&&c(y.positioned_relative_to_pcb_group_id,f)},l=new Set;if(a.forEach(g=>{const f=s.find(y=>y.pcb_component_id===g);f&&(f.position_mode==="relative_to_group_anchor"&&f.positioned_relative_to_pcb_group_id&&c(f.positioned_relative_to_pcb_group_id,l),f.pcb_group_id&&c(f.pcb_group_id,l))}),!Ld(g=>g.is_showing_group_anchor_offsets)&&a.length===0)return null;const u=s.map(g=>{if(g.position_mode==="relative_to_group_anchor"&&g.positioned_relative_to_pcb_group_id){const f=r.find(y=>y.pcb_group_id===g.positioned_relative_to_pcb_group_id);return f&&f.anchor_position?{component:g,parentGroup:f,type:"component"}:null}if(g.pcb_group_id){const f=r.find(y=>y.pcb_group_id===g.pcb_group_id);return f&&f.anchor_position?{component:g,parentGroup:f,type:"component"}:null}return null}).filter(g=>!!g),d=r.map(g=>{if(g.position_mode==="relative_to_group_anchor"&&g.positioned_relative_to_pcb_group_id){const f=r.find(y=>y.pcb_group_id===g.positioned_relative_to_pcb_group_id);if(f&&f.anchor_position&&g.anchor_position)return{group:g,parentGroup:f,type:"group"}}return null}).filter(g=>!!g),_=[...u,...d];if(_.length===0)return null;const h=a.length===0,m=_.filter(g=>g.type==="component"?h||a.includes(g.component.pcb_component_id):h||l.has(g.group.pcb_group_id)||l.has(g.parentGroup.pcb_group_id));if(m.length===0)return null;const p=m.map(g=>{const f=g.parentGroup.anchor_position;return f?g.type==="component"?g.component.center?{id:`${g.parentGroup.pcb_group_id}-${g.component.pcb_component_id}-${g.type}`,anchor:f,anchor_id:g.parentGroup.pcb_group_id,target:g.component.center,type:"component",display_offset_x:g.component.display_offset_x,display_offset_y:g.component.display_offset_y}:null:g.group.anchor_position?{id:`${g.parentGroup.pcb_group_id}-${g.group.pcb_group_id}-${g.type}`,anchor:f,anchor_id:g.parentGroup.pcb_group_id,target:g.group.anchor_position,type:"group",display_offset_x:g.group.display_offset_x,display_offset_y:g.group.display_offset_y}:null:null}).filter(g=>!!g);return K.jsx($Pe,{targets:p,transform:n,containerWidth:o,containerHeight:i})},g5o=(t,e)=>{const n=t.pcb_component_id,o=e.filter(i=>(i.type==="pcb_smtpad"||i.type==="pcb_plated_hole")&&i.pcb_component_id===n||i.type==="pcb_hole"&&i.pcb_component_id===n);return o.length===0?WPe([t]):WPe(o)},p5o=({elements:t,highlightedPrimitives:e,transform:n,containerWidth:o,containerHeight:i})=>{const r=new Map;for(const a of e)dv(a._parent_pcb_component)&&r.set(a._parent_pcb_component.pcb_component_id,a._parent_pcb_component),dv(a._element)&&r.set(a._element.pcb_component_id,a._element);if(r.size===0)return null;const s=[];for(const a of r.values()){const c=g5o(a,t);if(!c)continue;const l=a.positioned_relative_to_pcb_group_id??a.pcb_group_id,A=l?uv(t).pcb_group.get(l):null;s.push({component:a,bbox:c,group:A})}return s.length===0?null:K.jsx("div",{style:{position:"absolute",left:0,top:0,width:o,height:i,overflow:"hidden",pointerEvents:"none",zIndex:bA.dimensionOverlay},children:K.jsx("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none"},width:o,height:i,children:s.map(({component:a,bbox:c,group:l})=>{const A=ht(n,{x:c.minX,y:c.maxY}),u=ht(n,{x:c.maxX,y:c.minY}),d={x:Math.min(A.x,u.x),y:Math.min(A.y,u.y),width:Math.abs(u.x-A.x),height:Math.abs(u.y-A.y)},_=a.center??{x:(c.minX+c.maxX)/2,y:(c.minY+c.maxY)/2},h=ht(n,_);return K.jsxs("g",{children:[K.jsx("rect",{x:d.x,y:d.y,width:d.width,height:d.height,fill:"none",stroke:"white",strokeWidth:1.5,strokeDasharray:"4,4"}),K.jsx("line",{x1:h.x-6,y1:h.y,x2:h.x+6,y2:h.y,stroke:Rx.COMPONENT_MARKER_STROKE,strokeWidth:1.5}),K.jsx("line",{x1:h.x,y1:h.y-6,x2:h.x,y2:h.y+6,stroke:Rx.COMPONENT_MARKER_STROKE,strokeWidth:1.5}),K.jsx("circle",{cx:h.x,cy:h.y,r:zu.COMPONENT_MARKER_RADIUS,fill:Rx.COMPONENT_MARKER_FILL,stroke:Rx.COMPONENT_MARKER_STROKE,strokeWidth:1})]},a.pcb_component_id)})})})},f5o=({elements:t,highlightedPrimitives:e,transform:n,containerWidth:o,containerHeight:i})=>{const r=t.filter(_=>h5o(_)),s=t.filter(_=>qPe(_)),a=e.map(_=>qPe(_._element)?_._element.pcb_board_id:null).filter(_=>!!_);if(!Ld(_=>_.is_showing_group_anchor_offsets)&&a.length===0)return null;const l=s.map(_=>{const h=_.pcb_panel_id,m=_.position_mode;if(!h||m!=="relative_to_panel_anchor")return null;const p=r.find(g=>g.pcb_panel_id===h);return p?{board:_,panel:p,type:"board"}:null}).filter(_=>!!_);if(l.length===0)return null;const A=a.length===0,u=l.filter(_=>A||a.includes(_.board.pcb_board_id));if(u.length===0)return null;const d=u.map(_=>_.board.center?{id:`${_.panel.pcb_panel_id}-${_.board.pcb_board_id}-${_.type}`,anchor:_.panel.center,anchor_id:_.panel.pcb_panel_id,target:_.board.center,type:"board",display_offset_x:_.board.display_offset_x,display_offset_y:_.board.display_offset_y}:null).filter(_=>!!_);return K.jsx($Pe,{targets:d,transform:n,containerWidth:o,containerHeight:i})},rte=t=>{if(t.length===0)return null;let e=t[0].x,n=t[0].y,o=t[0].x,i=t[0].y;for(const r of t)r.x<e&&(e=r.x),r.y<n&&(n=r.y),r.x>o&&(o=r.x),r.y>i&&(i=r.y);return{center:{x:(e+o)/2,y:(n+i)/2},width:o-e,height:i-n}},WSt=(t,e)=>{if(e.length<3)return!1;let n=!1;for(let o=0,i=e.length-1;o<e.length;i=o++){const r=e[o].x,s=e[o].y,a=e[i].x,c=e[i].y;s>t.y!=c>t.y&&t.x<(a-r)*(t.y-s)/(c-s||Number.EPSILON)+r&&(n=!n)}return n},y5o=(t,e,n)=>{const o=[];for(const i of t){if(!i._element)continue;if("x1"in i&&i._element?.type==="pcb_trace"){const a=hg({x:e.x,y:e.y},{x:i.x1,y:i.y1},{x:i.x2,y:i.y2}),c=i.width||.5,l=Math.max(c*25,2)/n.a;a<l&&o.push(i);continue}if(i.pcb_drawing_type==="polygon"){const a=i.points.map(l=>({x:tt.parse(l.x),y:tt.parse(l.y)})),c=rte(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;WSt(e,a)&&o.push(i);continue}if(i.pcb_drawing_type==="polygon_with_arcs"){const a=i.brep_shape.outer_ring.vertices.map(l=>({x:tt.parse(l.x),y:tt.parse(l.y)})),c=rte(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;WSt(e,a)&&o.push(i);continue}if(!("x"in i&&"y"in i))continue;let r=0,s=0;if("w"in i&&"h"in i)r=i.w,s=i.h;else if("r"in i)r=i.r*2,s=i.r*2;else if("rX"in i&&"rY"in i)r=i.rX*2,s=i.rY*2;else continue;Math.abs(i.x-e.x)<r/2&&Math.abs(i.y-e.y)<s/2&&o.push(i)}return o},C5o=({elements:t,children:e,transform:n,primitives:o,onMouseHoverOverPrimitives:i})=>{const[r,s]=J.useState([]),[a,c]=J.useState({x:0,y:0}),[l,{width:A,height:u}]=yO(),d=J.useMemo(()=>{const h=[];for(const m of r){if(m._element?.type==="pcb_via"||m._element?.type==="pcb_component"||m?.layer==="drill"||m?.is_hoverable===!1)continue;let p=null,g=0,f=0;if(m.pcb_drawing_type==="polygon"){const E=rte(m.points);if(!E)continue;p=E.center,g=E.width,f=E.height}else if(m.pcb_drawing_type==="polygon_with_arcs"){const E=m.brep_shape.outer_ring.vertices.map(P=>({x:P.x,y:P.y})),b=rte(E);if(!b)continue;p=b.center,g=b.width,f=b.height}else"x"in m&&"y"in m&&(p={x:m.x,y:m.y},g="w"in m?m.w:"r"in m?m.r*2:"rX"in m&&"rY"in m?m.rX*2:0,f="h"in m?m.h:"r"in m?m.r*2:"rX"in m&&"rY"in m?m.rY*2:0);if(!p)continue;const y=ht(n,p),C={w:g*n.a,h:f*n.a},I=h.filter(E=>y.x===E.screen_x&&y.y===E.screen_y&&C.w===E.screen_w&&C.h===E.screen_h).length;h.push({...m,x:p.x,y:p.y,w:g,h:f,screen_x:y.x,screen_y:y.y,screen_w:C.w,screen_h:C.h,same_space_index:I})}return h},[r,n]),_=(h,m,p,g)=>{c({x:h,y:m});const f=ht(qC(p),{x:h,y:m}),y=y5o(g,f,p);r5o(new Set(y.map(C=>C._pcb_drawing_object_id)),new Set(r.map(C=>C._pcb_drawing_object_id)))||(s(y),i(y))};return K.jsxs("div",{ref:l,style:{position:"relative",width:"100%",height:"100%"},onMouseMove:h=>{if(n){const m=h.currentTarget.getBoundingClientRect(),p=h.clientX-m.left,g=h.clientY-m.top;_(p,g,n,o)}},onTouchStart:h=>{if(n){const m=h.touches[0],p=h.currentTarget.getBoundingClientRect(),g=m.clientX-p.left,f=m.clientY-p.top;_(g,f,n,o)}},children:[e,K.jsx(d5o,{elements:t,mousePos:a,highlightedPrimitives:d}),n&&K.jsxs(K.Fragment,{children:[K.jsx(_5o,{elements:t,highlightedPrimitives:d,transform:n,containerWidth:A,containerHeight:u}),K.jsx(m5o,{elements:t,highlightedPrimitives:d,transform:n,containerWidth:A,containerHeight:u}),K.jsx(p5o,{elements:t,highlightedPrimitives:d,transform:n,containerWidth:A,containerHeight:u}),K.jsx(f5o,{elements:t,highlightedPrimitives:d,transform:n,containerWidth:A,containerHeight:u})]})]})},jSt=["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)"],x5o=({children:t,transform:e=dA(),elements:n=[],hoveredComponentIds:o=[]})=>{const[i,{width:r,height:s}]=yO(),a=J.useRef(null),{is_showing_pcb_groups:c,pcb_group_view_mode:l,is_showing_group_anchor_offsets:A}=Ld(u=>({is_showing_pcb_groups:u.is_showing_pcb_groups,pcb_group_view_mode:u.pcb_group_view_mode,is_showing_group_anchor_offsets:u.is_showing_group_anchor_offsets}));return J.useEffect(()=>{const u=a.current;if(!u||!r||!s)return;u.width=r,u.height=s;const d=u.getContext("2d");if(!d||(d.clearRect(0,0,r,s),!c))return;const _=n.filter(E=>E.type==="pcb_group"),h=n.filter(E=>E.type==="pcb_component"),m=n.filter(E=>E.type==="source_group"),p=new Map(m.map(E=>[E.source_group_id,E])),g=_.filter(E=>{if(E.name?.toLowerCase().includes("subpanel"))return!1;if(l==="all")return!0;if(!E.source_group_id)return!1;const b=p.get(E.source_group_id);return b?b.was_automatically_named!==!0:!1}),f=new Map;m.forEach(E=>{const b=E;if(b.parent_source_group_id){const P=f.get(b.parent_source_group_id)||[];P.push(E.source_group_id),f.set(b.parent_source_group_id,P)}});const y=E=>{const b=[],P=f.get(E)||[];for(const B of P)b.push(B),b.push(...y(B));return b},C=E=>{const b=m.find(P=>P.source_group_id===E);return b?.parent_source_group_id?1+C(b.parent_source_group_id):0},I=new Set;if(o.length>0)for(const E of h){if(!o.includes(E.pcb_component_id))continue;const b=E.positioned_relative_to_pcb_group_id??E.pcb_group_id;b&&I.add(b)}g.forEach((E,b)=>{let P=h.filter(we=>we.pcb_group_id===E.pcb_group_id);if(E.source_group_id){const we=y(E.source_group_id),Ue=_.filter(De=>De.source_group_id&&we.includes(De.source_group_id));for(const De of Ue){const Ee=h.filter(Le=>Le.pcb_group_id===De.pcb_group_id);P=[...P,...Ee]}}let B,M,k,N,L=!1;if(E.center&&E.width&&E.height){L=!0;const we=E.width/2,Ue=E.height/2;B=E.center.x-we,k=E.center.x+we,M=E.center.y-Ue,N=E.center.y+Ue}else if(P.length===0||(B=1/0,M=1/0,k=-1/0,N=-1/0,P.forEach(we=>{if(we.center&&typeof we.width=="number"&&typeof we.height=="number"){const Ue=we.center.x-we.width/2,De=we.center.x+we.width/2,Ee=we.center.y+we.height/2,Le=we.center.y-we.height/2;B=Math.min(B,Ue),k=Math.max(k,De),M=Math.min(M,Le),N=Math.max(N,Ee)}}),B===1/0||k===-1/0))return;const F=E.source_group_id?C(E.source_group_id):0,G=E.source_group_id?y(E.source_group_id).length>0:!1;if(!L){const De=1+(G?.5:0);B-=De,k+=De,M-=De,N+=De}const W=ht(e,{x:B,y:N}),j=ht(e,{x:k,y:N}),$=ht(e,{x:B,y:M}),oe=ht(e,{x:k,y:M}),le=jSt[b%jSt.length];d.strokeStyle=le,d.lineWidth=2;const ee=Math.max(4,Math.min(12,8*Math.abs(e.a))),ie=Math.max(2,Math.min(6,4*Math.abs(e.a))),re=ee*(G?1.3:1),ue=ie;d.setLineDash([re,ue]),d.beginPath(),d.moveTo(W.x,W.y),d.lineTo(j.x,j.y),d.lineTo(oe.x,oe.y),d.lineTo($.x,$.y),d.closePath(),d.stroke();const ye=Math.max(8,Math.min(12,10*Math.abs(e.a))),be=F==0||F==1?0:F*.11,ve=ye*(1-be),he=4,Pe=E.name||`Group ${b+1}`;d.font=`${ve}px sans-serif`,d.setLineDash([]);const Te=d.measureText(Pe).width+he*2,Ge=ve+he*2,Ye=W.x-5,fe=W.y-5,Xe=3;if(d.fillStyle="rgba(0, 0, 0, 0.8)",d.beginPath(),d.roundRect(Ye,fe-Ge,Te,Ge,Xe),d.fill(),d.fillStyle=le,d.textAlign="left",d.textBaseline="middle",d.fillText(Pe,Ye+he,fe-Ge/2),A&&I.has(E.pcb_group_id)&&!!E.anchor_position&&E.anchor_position){const we=Array.isArray(E.anchor_position)?{x:E.anchor_position[0]??0,y:E.anchor_position[1]??0}:{x:E.anchor_position.x,y:E.anchor_position.y},Ue=ht(e,we);d.strokeStyle="white",d.lineWidth=1.5,d.setLineDash([]);const De=Math.max(4,Math.min(8,6*Math.abs(e.a)));d.beginPath(),d.moveTo(Ue.x-De,Ue.y),d.lineTo(Ue.x+De,Ue.y),d.stroke(),d.beginPath(),d.moveTo(Ue.x,Ue.y-De),d.lineTo(Ue.x,Ue.y+De),d.stroke()}})},[n,e,r,s,c,l,A,o]),K.jsxs("div",{ref:i,style:{position:"relative",width:"100%",height:"100%"},children:[t,K.jsx("canvas",{ref:a,style:{position:"absolute",top:0,left:0,pointerEvents:"none",zIndex:bA.pcbGroupOverlay,display:c?"block":"none"}})]})},I5o=({transform:t,soup:e,children:n})=>{const o=Ld(a=>a.is_showing_rats_nest),{netMap:i,idToNetMap:r}=J.useMemo(()=>fSt(e||[]),[e]),s=J.useMemo(()=>{if(!e||!o)return[];const a=d=>{const _=uv(e)[d.replace(/_\d+$/,"")].get(d);return _&&"x"in _&&"y"in _?{x:_.x,y:_.y}:null},c=(d,_)=>{const h=i[_]||[];let m=null,p=1/0;return h.forEach(g=>{const f=a(g);if(f){const y=Math.sqrt((d.x-f.x)**2+(d.y-f.y)**2);y<p&&y>0&&(p=y,m=f)}}),m},l=uv(e).pcb_port.list(),A=uv(e).source_trace.list(),u=[];return l.forEach((d,_)=>{const h=r[d.pcb_port_id];let m=!1;for(const f of A)f.connected_source_port_ids.includes(d.source_port_id)&&f.connected_source_net_ids.length>0&&(m=!0);if(!h)return;const p={x:d.x,y:d.y},g=c(p,h);g&&u.push({key:`${d.pcb_port_id}-${_}`,startPoint:p,endPoint:g,isInNet:m})}),u},[e,i,r,o]);return!e||!o?n:(t||(t=dA()),K.jsxs("div",{style:{position:"relative"},children:[n,K.jsx("svg",{style:{position:"absolute",left:0,top:0,width:"100%",height:"100%",pointerEvents:"none",opacity:.5,zIndex:bA.ratsNestOverlay},children:s.map(({key:a,startPoint:c,endPoint:l,isInNet:A})=>{const u=ht(t,c),d=ht(t,l);return K.jsx("line",{x1:u.x,y1:u.y,x2:d.x,y2:d.y,stroke:"white",strokeWidth:"1",strokeDasharray:A?"6,6":void 0},a)})})]}))},E5o={version:"1.11.371"},hv=(t,e,n)=>{const o=Ld(s=>s.is_mouse_over_container),i=J.useRef(o),r=J.useRef(e);J.useEffect(()=>{i.current=o},[o]),J.useEffect(()=>{r.current=e},[e]),J.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("+"),A=l.includes("ctrl"),u=l.includes("shift"),d=l.includes("alt"),_=l.includes("meta"),h=l[l.length-1],m=n?.current?n.current.contains(document.activeElement)||document.activeElement===n.current:!1;(i.current||m)&&(!A||a.ctrlKey)&&(!u||a.shiftKey)&&(!d||a.altKey)&&(!_||a.metaKey)&&a.key.toLowerCase()===h.toLowerCase()&&(a.preventDefault(),r.current())};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s)}},[t])},b5o=()=>{const[t,e]=J.useState(!1);return J.useEffect(()=>{const n=()=>{e(window.innerWidth<=768)};return n(),window.addEventListener("resize",n),()=>window.removeEventListener("resize",n)},[]),t},xO=(t,e={stopPropagation:!0})=>{const n=J.useRef(0),o=J.useCallback(s=>{e.stopPropagation&&s.stopPropagation();const a=Date.now();a-n.current<300||(n.current=a,t?.(s))},[t,e.stopPropagation]),i=J.useCallback(s=>{s.preventDefault(),o(s)},[o]);return{onClick:o,onTouchEnd:i,style:{touchAction:"manipulation"}}},_v=({children:t,isSmallScreen:e,onClick:n,...o})=>{const{style:i,...r}=xO(n);return K.jsx("div",{...o,...r,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",...i,...o.style},children:t})},S5o=t=>{const e=new Map;return t.forEach((n,o)=>{const i=n.error_type||"unknown_error",r=e.get(i)||[];r.push({error:n,index:o,errorId:JQ(n,o)}),e.set(i,r)}),Array.from(e.entries()).map(([n,o])=>({errorType:n,errors:o}))},P5o=({onClose:t,setHoveredErrorId:e,setFocusedErrorId:n,highlightDurationMs:o=3e3})=>{const i=J.useRef(null),r=J.useRef(null),s=J.useRef(null),a=J.useCallback(()=>{i.current!==null&&(window.clearTimeout(i.current),i.current=null),r.current!==null&&(window.cancelAnimationFrame(r.current),r.current=null)},[]);J.useEffect(()=>a,[a]);const c=J.useCallback(A=>{a(),s.current=A,e(A),n(null),r.current=window.requestAnimationFrame(()=>{n(A),r.current=null}),t(),i.current=window.setTimeout(()=>{s.current=null,e(null),n(null),i.current=null},o)},[a,o,t,n,e]),l=J.useCallback(A=>s.current===A,[]);return{handleErrorSelect:c,isSelectedError:l}},v5o=({errorId:t,errorMessage:e,copiedErrorId:n,onCopy:o})=>{const{style:i,...r}=xO(()=>o(e,t));return K.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",...i},...r,children:n===t?K.jsx("span",{style:{color:"#4caf50",fontSize:12},children:"Copied!"}):K.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:K.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"})})})},B5o=({elements:t,isOpen:e,isSmallScreen:n,onToggle:o,onClose:i,setHoveredErrorId:r,setFocusedErrorId:s})=>{const[a,c]=J.useState(null),[l,A]=J.useState(new Set),[u,d]=J.useState(new Set),[,_]=d2o(),{handleErrorSelect:h,isSelectedError:m}=P5o({onClose:i,setHoveredErrorId:r,setFocusedErrorId:s}),p=J.useMemo(()=>t?.filter(I=>I.type.includes("error"))??[],[t]),g=p.length,f=J.useMemo(()=>S5o(p),[p]),y=J.useCallback(I=>{A(E=>{const b=new Set(E);return b.has(I)?b.delete(I):b.add(I),b})},[]),C=J.useCallback(I=>{d(E=>{const b=new Set(E);return b.has(I)?b.delete(I):b.add(I),b})},[]);return K.jsxs("div",{style:{position:"relative"},children:[K.jsx(_v,{isSmallScreen:n,style:g>0?{color:"red"}:void 0,onClick:o,children:K.jsxs("div",{children:[g," errors"]})}),e&&g>0&&K.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:f.map(({errorType:I,errors:E},b)=>{const P=l.has(I);return K.jsxs("div",{style:{borderBottom:b<f.length-1?"1px solid #444":"none"},children:[K.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:B=>{B.currentTarget.style.backgroundColor="#303030"},onMouseLeave:B=>{B.currentTarget.style.backgroundColor="#232323"},onTouchStart:B=>{B.stopPropagation(),B.currentTarget.style.backgroundColor="#303030"},onTouchEnd:B=>{B.stopPropagation(),B.preventDefault(),B.currentTarget.style.backgroundColor="#232323",y(I)},onClick:B=>{B.stopPropagation(),y(I)},children:[K.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,color:"#ff6b6b"},children:[K.jsx("div",{style:{color:"#888",fontSize:"16px",transform:P?"rotate(90deg)":"rotate(0deg)",transition:"transform 0.2s ease",flexShrink:0},children:"›"}),K.jsx("div",{style:{fontWeight:"bold",fontSize:n?"12px":"13px"},children:I})]}),K.jsx("div",{style:{fontSize:n?"12px":"13px",color:"#aaa",whiteSpace:"nowrap",marginLeft:12},children:E.length})]}),!P&&E.map(({error:B,index:M,errorId:k})=>{const N=u.has(k),L=B.message??"No error message";return K.jsxs("div",{style:{borderTop:"1px solid #3a3a3a"},children:[K.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:F=>{F.currentTarget.style.backgroundColor="#333",r(k)},onMouseLeave:F=>{F.currentTarget.style.backgroundColor="#2a2a2a",m(k)||r(null)},onTouchStart:F=>{F.stopPropagation(),F.currentTarget.style.backgroundColor="#333",r(k)},onTouchEnd:F=>{F.stopPropagation(),F.preventDefault(),F.currentTarget.style.backgroundColor="#2a2a2a",h(k)},onClick:F=>{F.stopPropagation(),h(k)},children:[K.jsx("div",{style:{flex:1,fontSize:n?"12px":"13px",color:"#ddd",lineHeight:1.4,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",userSelect:"text"},children:L}),K.jsx("button",{type:"button","aria-label":N?"Collapse error details":"Expand error details",style:{color:"#888",fontSize:"16px",transform:N?"rotate(0deg)":"rotate(90deg)",transition:"transform 0.2s ease",flexShrink:0,background:"none",border:"none",padding:0,cursor:"pointer"},onMouseDown:F=>F.stopPropagation(),onClick:F=>{F.stopPropagation(),C(k)},onTouchEnd:F=>{F.stopPropagation(),F.preventDefault(),C(k)},children:"›"})]}),N&&K.jsxs("div",{"data-error-id":M,style:{display:"block",padding:"12px 16px 12px 24px",backgroundColor:"#1a1a1a",borderTop:"1px solid #444",position:"relative"},children:[K.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:F=>F.stopPropagation(),onClick:F=>F.stopPropagation(),children:L}),K.jsx(v5o,{errorId:k,errorMessage:L,copiedErrorId:a,onCopy:(F,G)=>{_(F),c(G),setTimeout(()=>c(null),2e3)}})]})]},k)})]},I)})})]})},M5o=({name:t,selected:e,onClick:n})=>{const{style:o,...i}=xO(n);return K.jsxs("div",{className:XQ`
|
|
5711
|
+
`,i5o=({children:t,transform:e=dA(),elements:n})=>{const o=J.useRef(null),{isShowingDRCErrors:i,hoveredErrorId:r,focusedErrorId:s}=Ld(m=>({isShowingDRCErrors:m.is_showing_drc_errors,hoveredErrorId:m.hovered_error_id,focusedErrorId:m.focused_error_id})),a=s??r;if(!n)return K.jsx("div",{style:{position:"relative"},ref:o,children:t});const c=n.filter(m=>m.type==="pcb_trace_error"&&!m.message?.includes("Multiple components found with name")),l=n.filter(m=>m.type==="pcb_via_clearance_error"),A=n.filter(m=>m.type==="pcb_trace_error"&&m.message?.includes("Multiple components found with name")),u=CSt(n),d=ySt(n,a),_=m=>{const p=S2o({error:m,indexes:u});if(!p||typeof p.x!="number"||typeof p.y!="number")return null;const g=ht(e,p);return Number.isNaN(g.x)||Number.isNaN(g.y)?null:g};let h=null;return d&&(h=_(d)),K.jsxs("div",{style:{position:"relative"},ref:o,children:[t,c.map((m,p)=>{const g=JQ(m,p),f=a===g;if(!f&&!i)return null;const y=_(m);if(!y)return null;const C=XPe(y,o);return K.jsxs(J.Fragment,{children:[K.jsx(YSt,{errorCenter:y,isHighlighted:f}),K.jsx("div",{style:{position:"absolute",left:y.x-15,top:y.y-15,width:30,height:30,zIndex:bA.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:I=>{const E=I.currentTarget.nextElementSibling;if(E){const b=E.querySelector(".error-message");b&&(b.style.opacity="1")}},onMouseLeave:I=>{if(!f){const E=I.currentTarget.nextElementSibling;if(E){const b=E.querySelector(".error-message");b&&(b.style.opacity="0")}}}}),K.jsx("div",{style:{position:"absolute",zIndex:f?200:100,left:C.left,top:C.top,color:f?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:i||f?"flex":"none",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:C.transform},children:K.jsx("div",{className:`error-message ${JPe}`,style:{opacity:f?1:0,border:`1px solid ${f?"#ff4444":"red"}`},children:m.message})})]},g)}),l.map((m,p)=>{const g=JQ(m,p),f=a===g;if(!f&&!i)return null;const y=_(m);if(!y)return null;const C=XPe({x:y.x,y:y.y},o);return K.jsxs(J.Fragment,{children:[K.jsx(YSt,{errorCenter:y,isHighlighted:f}),K.jsx("div",{style:{position:"absolute",left:y.x-15,top:y.y-15,width:30,height:30,zIndex:bA.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:I=>{const E=I.currentTarget.nextElementSibling;if(E){const b=E.querySelector(".error-message");b&&(b.style.opacity="1")}},onMouseLeave:I=>{if(!f){const E=I.currentTarget.nextElementSibling;if(E){const b=E.querySelector(".error-message");b&&(b.style.opacity="0")}}}}),K.jsx("div",{style:{position:"absolute",zIndex:f?bA.errorOverlay+10:bA.errorOverlay+1,left:C.left,top:C.top,color:f?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:"flex",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:C.transform},children:K.jsx("div",{className:`error-message ${JPe}`,style:{opacity:f?1:0,border:`1px solid ${f?"#ff4444":"red"}`},children:m.message})})]},g)}),A.map((m,p)=>{const g=m.component_name||m.message?.match(/name "([^"]+)"/)?.[1];if(!g)return null;const f=n?.filter(I=>I.type==="source_component"&&I.name===g||I.type==="pcb_component"&&n?.find(E=>E.type==="source_component"&&E.source_component_id===I.source_component_id&&E.name===g))||[],y=JQ(m,p),C=a===y;return!C&&!i?null:f.map((I,E)=>{let b={x:0,y:0};if(I.type==="pcb_component")b=I.center||{x:0,y:0};else if(I.type==="source_component"){const G=n?.find(W=>W.type==="pcb_component"&&W.source_component_id===I.source_component_id);G&&G.type==="pcb_component"&&(b=G.center||{x:0,y:0})}const P=ht(e,b);if(Number.isNaN(P.x)||Number.isNaN(P.y))return null;const B=Math.abs(e.a),L=Math.max(8,Math.min(30,.5*B)),F=XPe(P,o);return K.jsxs(J.Fragment,{children:[K.jsx("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none",mixBlendMode:"difference",zIndex:bA.errorOverlay},width:"100%",height:"100%",children:C?K.jsx("polygon",{points:`${P.x},${P.y-L*1.25} ${P.x+L},${P.y} ${P.x},${P.y+L*1.25} ${P.x-L},${P.y}`,fill:"#ff4444"}):K.jsx("circle",{cx:P.x,cy:P.y,r:L,fill:"none",stroke:C?"#ff4444":"red",strokeWidth:C?Math.max(2,L*.15):Math.max(1,L*.1),opacity:1})}),K.jsx("div",{style:{position:"absolute",left:P.x-(L+10),top:P.y-(L+10),width:(L+10)*2,height:(L+10)*2,zIndex:bA.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:G=>{const W=G.currentTarget.nextElementSibling;if(W){const j=W.querySelector(".error-message");j&&(j.style.opacity="1")}},onMouseLeave:G=>{if(!C){const W=G.currentTarget.nextElementSibling;if(W){const j=W.querySelector(".error-message");j&&(j.style.opacity="0")}}}}),K.jsx("div",{style:{position:"absolute",zIndex:C?bA.errorOverlay+20:bA.errorOverlay+10,left:F.left,top:F.top,color:C?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:i||C?"flex":"none",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:F.transform},children:K.jsx("div",{className:`error-message ${JPe}`,style:{opacity:C?1:0,border:`1px solid ${C?"#ff4444":"red"}`},children:m.message})})]},`${y}_${E}`)})}),h&&K.jsx(o5o,{center:h})]})};function r5o(t,e){return t.size!==e.size?!1:Array.from(t).every(n=>e.has(n))}function s5o({primitiveElement:t,elements:e}){let n=t.trace_length?`${t.trace_length.toFixed(3)}`:"";const o=uv(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 i=t.trace_length&&o?.max_length&&t.trace_length>o.max_length;return{text:n,isOverLength:i}}function a5o(t){const{primitives:e,is_showing_multiple_traces_length:n,elements:o}=t,i=e.filter(c=>c._element.type==="pcb_trace"),r=o.filter(c=>c.type==="source_trace"),s=e.filter(c=>c._element.type!=="pcb_trace"),a=i.filter(c=>r.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(i.length>1){const c=i.reduce((l,A)=>{const u=l._element.trace_length;return A._element.trace_length<u?A:l},i[0]);return[...s,c]}return e}var c5o={position:"absolute",left:0,top:0,pointerEvents:"none",color:"red",fontFamily:"sans-serif",fontSize:12,textShadow:"0 0 2px black"},l5o=t=>{const{_element:e,_parent_pcb_component:n,_parent_source_component:o,_source_port:i}=t;switch(e.type){case"pcb_trace":return e.trace_length?`${e.trace_length.toFixed(3)}`:"";case"pcb_smtpad":case"pcb_plated_hole":{const r=[],s=Array.from(new Set((e.port_hints??[]).concat(i?.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?r.push(...s.map(c=>`${a}.${c}`)):r.push(...s):a&&r.push(a),r.join(", ")}default:return""}},A5o={top:"red",bottom:"aqua"},u5o=({primitive:t,mousePos:e,elements:n})=>{const[o,i]=J.useState(!1),r=t._element;J.useEffect(()=>{setTimeout(()=>{i(!0)},100)},[]);const[s,a,c,l]=[t.screen_x,t.screen_y,t.screen_w,t.screen_h],A=t.same_space_index??0,u=26,d=A5o[t?._element?.layer]??"red";let _=0;if(r.type==="pcb_smtpad"&&r?.shape==="rotated_rect"?_=r?.ccw_rotation??0:(r.type==="pcb_smtpad"&&(r?.shape==="pill"||r?.shape==="rotated_pill")&&"ccw_rotation"in t||r.type==="pcb_plated_hole"&&(r?.shape==="pill"||r?.shape==="oval")&&"ccw_rotation"in t)&&(_=r.ccw_rotation??0),r.type==="pcb_trace"){const p=s5o({primitiveElement:r,elements:n});if(!p)return null;const g=e.y-35;return K.jsx("div",{style:{zIndex:bA.elementOverlay,position:"absolute",left:e.x,top:g,color:d,pointerEvents:"none",transform:"translateX(-50%)"},children:K.jsx("div",{style:{backgroundColor:"#f2efcc",color:p.isOverLength?"red":"black",textShadow:"none",WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale",padding:"6px 6px",borderRadius:"6px",fontSize:"14px",minWidth:"45px",textAlign:"center",whiteSpace:"nowrap"},children:p.text})})}const h=l5o(t);return h.trim().length===0?null:K.jsx("div",{style:{zIndex:bA.elementOverlay,position:"absolute",left:s-c/2-8,top:a-l/2-8,width:c+16,height:l+16,color:d,transform:`rotate(${-_}deg)`,transformOrigin:"center center"},children:K.jsx("div",{style:{width:o?`calc(100% + ${u*2*A}px)`:"100%",height:o?`calc(100% + ${u*2*A}px)`:"100%",marginLeft:o?`${-u*A}px`:0,marginTop:o?`${-u*A}px`:0,border:`1px solid ${d}`,opacity:o||A===0?1:0,transition:"width 0.2s, height 0.2s, margin-left 0.2s, margin-top 0.2s, opacity 0.2s"},children:K.jsx("div",{style:{position:"absolute",bottom:l+20+u*A,marginRight:o?`${-u*A}px`:0,marginBottom:o?0:-u*A,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(${_}deg)`,minWidth:"45px",textAlign:"center"},children:h})})})},d5o=({highlightedPrimitives:t,mousePos:e,elements:n})=>{const[o,i]=Ld(a=>[a.is_moving_component,a.is_showing_multiple_traces_length]),r=t.some(a=>a._element.type==="pcb_smtpad")&&t.some(a=>a._element.type==="pcb_trace");let s=t;return r&&(s=s.filter(a=>a._element.type==="pcb_smtpad")),s=a5o({primitives:s,is_showing_multiple_traces_length:i,elements:n}),K.jsx("div",{style:c5o,children:!o&&s.map((a,c)=>K.jsx(u5o,{primitive:a,mousePos:e,elements:n},c))})},dv=t=>t?.type==="pcb_component",KSt=t=>t?.type==="pcb_group",h5o=t=>t?.type==="pcb_panel",qPe=t=>t?.type==="pcb_board",zu={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},Rx={OFFSET_LINE:"white",COMPONENT_MARKER_FILL:"#66ccff",COMPONENT_MARKER_STROKE:"white",LABEL_TEXT:"white"},$Pe=({targets:t,transform:e,containerWidth:n,containerHeight:o})=>{if(t.length===0)return null;const i={color:Rx.LABEL_TEXT,mixBlendMode:"difference",pointerEvents:"none",fontSize:zu.LABEL_FONT_SIZE,fontFamily:"monospace",fontWeight:"bold"},r=new Map;return t.forEach(s=>{if(!r.has(s.anchor_id)){const a=ht(e,s.anchor);r.set(s.anchor_id,a)}}),K.jsx("div",{style:{position:"absolute",left:0,top:0,width:n,height:o,overflow:"hidden",pointerEvents:"none",zIndex:bA.dimensionOverlay},children:K.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,A=r.get(c),u=ht(e,l),d=l.x-a.x,_=l.y-a.y,h=Math.abs(u.x-A.x),m=Math.abs(u.y-A.y),p=u.y<A.y,g=u.x>A.x,f=p?zu.LABEL_OFFSET_ABOVE:zu.LABEL_OFFSET_BELOW,y=g?zu.LABEL_OFFSET_RIGHT:zu.LABEL_OFFSET_LEFT,C=h>zu.MIN_LINE_LENGTH_FOR_LABEL,I=m>zu.MIN_LINE_LENGTH_FOR_LABEL,E=`${s.display_offset_x??d.toFixed(2)}mm`,b=`${s.display_offset_y??_.toFixed(2)}mm`;return K.jsxs("g",{children:[K.jsx("line",{x1:A.x,y1:A.y,x2:u.x,y2:A.y,stroke:Rx.OFFSET_LINE,strokeWidth:zu.LINE_STROKE_WIDTH,strokeDasharray:zu.LINE_DASH_PATTERN}),K.jsx("line",{x1:u.x,y1:A.y,x2:u.x,y2:u.y,stroke:Rx.OFFSET_LINE,strokeWidth:zu.LINE_STROKE_WIDTH,strokeDasharray:zu.LINE_DASH_PATTERN}),s.type==="component"||s.type==="board"?K.jsx("circle",{cx:u.x,cy:u.y,r:zu.COMPONENT_MARKER_RADIUS,fill:Rx.COMPONENT_MARKER_FILL,stroke:Rx.COMPONENT_MARKER_STROKE,strokeWidth:1}):K.jsxs(K.Fragment,{children:[K.jsx("line",{x1:u.x-zu.ANCHOR_MARKER_SIZE,y1:u.y,x2:u.x+zu.ANCHOR_MARKER_SIZE,y2:u.y,stroke:Rx.OFFSET_LINE,strokeWidth:zu.ANCHOR_MARKER_STROKE_WIDTH}),K.jsx("line",{x1:u.x,y1:u.y-zu.ANCHOR_MARKER_SIZE,x2:u.x,y2:u.y+zu.ANCHOR_MARKER_SIZE,stroke:Rx.OFFSET_LINE,strokeWidth:zu.ANCHOR_MARKER_STROKE_WIDTH})]}),C&&K.jsx("foreignObject",{x:Math.min(A.x,u.x),y:A.y+f,width:Math.abs(u.x-A.x),height:20,style:{overflow:"visible"},children:K.jsx("div",{style:{...i,textAlign:"center"},children:E})}),I&&K.jsx("foreignObject",{x:u.x+y,y:Math.min(A.y,u.y),width:zu.Y_LABEL_MIN_WIDTH,height:Math.abs(u.y-A.y),style:{overflow:"visible"},children:K.jsx("div",{style:{...i,display:"flex",alignItems:"center",justifyContent:g?"flex-start":"flex-end",whiteSpace:"nowrap",padding:"0 4px",height:"100%"},children:b})})]},s.id)}),Array.from(r.entries()).map(([s,a])=>K.jsxs("g",{children:[K.jsx("line",{x1:a.x-zu.ANCHOR_MARKER_SIZE,y1:a.y,x2:a.x+zu.ANCHOR_MARKER_SIZE,y2:a.y,stroke:Rx.OFFSET_LINE,strokeWidth:zu.ANCHOR_MARKER_STROKE_WIDTH}),K.jsx("line",{x1:a.x,y1:a.y-zu.ANCHOR_MARKER_SIZE,x2:a.x,y2:a.y+zu.ANCHOR_MARKER_SIZE,stroke:Rx.OFFSET_LINE,strokeWidth:zu.ANCHOR_MARKER_STROKE_WIDTH})]},`anchor-${s}`))]})})},_5o=({elements:t,highlightedPrimitives:e,transform:n,containerWidth:o,containerHeight:i})=>{const r=t.filter(g=>qPe(g)),s=t.filter(g=>dv(g)),a=t.filter(g=>KSt(g)),c=e.map(g=>dv(g._parent_pcb_component)?g._parent_pcb_component.pcb_component_id:dv(g._element)?g._element.pcb_component_id:null).filter(g=>!!g),l=new Set;if(c.forEach(g=>{const f=s.find(y=>y.pcb_component_id===g);f?.pcb_group_id&&l.add(f.pcb_group_id)}),!Ld(g=>g.is_showing_group_anchor_offsets)&&c.length===0)return null;const u=s.map(g=>{const f=g.positioned_relative_to_pcb_board_id;if(!f)return null;const y=r.find(C=>C.pcb_board_id===f);return y?{component:g,board:y,type:"component"}:null}).filter(g=>!!g),d=a.map(g=>{const f=g.positioned_relative_to_pcb_board_id;if(!f||!g.center)return null;const y=r.find(C=>C.pcb_board_id===f);return y?{group:g,board:y,type:"group"}:null}).filter(g=>!!g),_=[...u,...d];if(_.length===0)return null;const h=c.length===0,m=_.filter(g=>g.type==="component"?h||c.includes(g.component.pcb_component_id):h||l.has(g.group.pcb_group_id));if(m.length===0)return null;const p=m.map(g=>g.type==="component"?{id:`${g.board.pcb_board_id}-${g.component.pcb_component_id}-${g.type}`,anchor:g.board.center,anchor_id:g.board.pcb_board_id,target:g.component.center,type:"component",display_offset_x:g.component.display_offset_x,display_offset_y:g.component.display_offset_y}:{id:`${g.board.pcb_board_id}-${g.group.pcb_group_id}-${g.type}`,anchor:g.board.center,anchor_id:g.board.pcb_board_id,target:{x:g.group.anchor_position?.x??g.group.center.x,y:g.group.anchor_position?.y??g.group.center.y},type:"group",display_offset_x:g.group.display_offset_x,display_offset_y:g.group.display_offset_y}).filter(g=>!!g);return K.jsx($Pe,{targets:p,transform:n,containerWidth:o,containerHeight:i})},m5o=({elements:t,highlightedPrimitives:e,transform:n,containerWidth:o,containerHeight:i})=>{const r=t.filter(g=>KSt(g)),s=t.filter(g=>dv(g)),a=e.map(g=>dv(g._parent_pcb_component)?g._parent_pcb_component.pcb_component_id:dv(g._element)?g._element.pcb_component_id:null).filter(g=>!!g),c=(g,f)=>{if(f.has(g))return;f.add(g);const y=r.find(C=>C.pcb_group_id===g);y?.position_mode==="relative_to_group_anchor"&&y.positioned_relative_to_pcb_group_id&&c(y.positioned_relative_to_pcb_group_id,f)},l=new Set;if(a.forEach(g=>{const f=s.find(y=>y.pcb_component_id===g);f&&(f.position_mode==="relative_to_group_anchor"&&f.positioned_relative_to_pcb_group_id&&c(f.positioned_relative_to_pcb_group_id,l),f.pcb_group_id&&c(f.pcb_group_id,l))}),!Ld(g=>g.is_showing_group_anchor_offsets)&&a.length===0)return null;const u=s.map(g=>{if(g.position_mode==="relative_to_group_anchor"&&g.positioned_relative_to_pcb_group_id){const f=r.find(y=>y.pcb_group_id===g.positioned_relative_to_pcb_group_id);return f&&f.anchor_position?{component:g,parentGroup:f,type:"component"}:null}if(g.pcb_group_id){const f=r.find(y=>y.pcb_group_id===g.pcb_group_id);return f&&f.anchor_position?{component:g,parentGroup:f,type:"component"}:null}return null}).filter(g=>!!g),d=r.map(g=>{if(g.position_mode==="relative_to_group_anchor"&&g.positioned_relative_to_pcb_group_id){const f=r.find(y=>y.pcb_group_id===g.positioned_relative_to_pcb_group_id);if(f&&f.anchor_position&&g.anchor_position)return{group:g,parentGroup:f,type:"group"}}return null}).filter(g=>!!g),_=[...u,...d];if(_.length===0)return null;const h=a.length===0,m=_.filter(g=>g.type==="component"?h||a.includes(g.component.pcb_component_id):h||l.has(g.group.pcb_group_id)||l.has(g.parentGroup.pcb_group_id));if(m.length===0)return null;const p=m.map(g=>{const f=g.parentGroup.anchor_position;return f?g.type==="component"?g.component.center?{id:`${g.parentGroup.pcb_group_id}-${g.component.pcb_component_id}-${g.type}`,anchor:f,anchor_id:g.parentGroup.pcb_group_id,target:g.component.center,type:"component",display_offset_x:g.component.display_offset_x,display_offset_y:g.component.display_offset_y}:null:g.group.anchor_position?{id:`${g.parentGroup.pcb_group_id}-${g.group.pcb_group_id}-${g.type}`,anchor:f,anchor_id:g.parentGroup.pcb_group_id,target:g.group.anchor_position,type:"group",display_offset_x:g.group.display_offset_x,display_offset_y:g.group.display_offset_y}:null:null}).filter(g=>!!g);return K.jsx($Pe,{targets:p,transform:n,containerWidth:o,containerHeight:i})},g5o=(t,e)=>{const n=t.pcb_component_id,o=e.filter(i=>(i.type==="pcb_smtpad"||i.type==="pcb_plated_hole")&&i.pcb_component_id===n||i.type==="pcb_hole"&&i.pcb_component_id===n);return o.length===0?WPe([t]):WPe(o)},p5o=({elements:t,highlightedPrimitives:e,transform:n,containerWidth:o,containerHeight:i})=>{const r=new Map;for(const a of e)dv(a._parent_pcb_component)&&r.set(a._parent_pcb_component.pcb_component_id,a._parent_pcb_component),dv(a._element)&&r.set(a._element.pcb_component_id,a._element);if(r.size===0)return null;const s=[];for(const a of r.values()){const c=g5o(a,t);if(!c)continue;const l=a.positioned_relative_to_pcb_group_id??a.pcb_group_id,A=l?uv(t).pcb_group.get(l):null;s.push({component:a,bbox:c,group:A})}return s.length===0?null:K.jsx("div",{style:{position:"absolute",left:0,top:0,width:o,height:i,overflow:"hidden",pointerEvents:"none",zIndex:bA.dimensionOverlay},children:K.jsx("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none"},width:o,height:i,children:s.map(({component:a,bbox:c,group:l})=>{const A=ht(n,{x:c.minX,y:c.maxY}),u=ht(n,{x:c.maxX,y:c.minY}),d={x:Math.min(A.x,u.x),y:Math.min(A.y,u.y),width:Math.abs(u.x-A.x),height:Math.abs(u.y-A.y)},_=a.center??{x:(c.minX+c.maxX)/2,y:(c.minY+c.maxY)/2},h=ht(n,_);return K.jsxs("g",{children:[K.jsx("rect",{x:d.x,y:d.y,width:d.width,height:d.height,fill:"none",stroke:"white",strokeWidth:1.5,strokeDasharray:"4,4"}),K.jsx("line",{x1:h.x-6,y1:h.y,x2:h.x+6,y2:h.y,stroke:Rx.COMPONENT_MARKER_STROKE,strokeWidth:1.5}),K.jsx("line",{x1:h.x,y1:h.y-6,x2:h.x,y2:h.y+6,stroke:Rx.COMPONENT_MARKER_STROKE,strokeWidth:1.5}),K.jsx("circle",{cx:h.x,cy:h.y,r:zu.COMPONENT_MARKER_RADIUS,fill:Rx.COMPONENT_MARKER_FILL,stroke:Rx.COMPONENT_MARKER_STROKE,strokeWidth:1})]},a.pcb_component_id)})})})},f5o=({elements:t,highlightedPrimitives:e,transform:n,containerWidth:o,containerHeight:i})=>{const r=t.filter(_=>h5o(_)),s=t.filter(_=>qPe(_)),a=e.map(_=>qPe(_._element)?_._element.pcb_board_id:null).filter(_=>!!_);if(!Ld(_=>_.is_showing_group_anchor_offsets)&&a.length===0)return null;const l=s.map(_=>{const h=_.pcb_panel_id,m=_.position_mode;if(!h||m!=="relative_to_panel_anchor")return null;const p=r.find(g=>g.pcb_panel_id===h);return p?{board:_,panel:p,type:"board"}:null}).filter(_=>!!_);if(l.length===0)return null;const A=a.length===0,u=l.filter(_=>A||a.includes(_.board.pcb_board_id));if(u.length===0)return null;const d=u.map(_=>_.board.center?{id:`${_.panel.pcb_panel_id}-${_.board.pcb_board_id}-${_.type}`,anchor:_.panel.center,anchor_id:_.panel.pcb_panel_id,target:_.board.center,type:"board",display_offset_x:_.board.display_offset_x,display_offset_y:_.board.display_offset_y}:null).filter(_=>!!_);return K.jsx($Pe,{targets:d,transform:n,containerWidth:o,containerHeight:i})},rte=t=>{if(t.length===0)return null;let e=t[0].x,n=t[0].y,o=t[0].x,i=t[0].y;for(const r of t)r.x<e&&(e=r.x),r.y<n&&(n=r.y),r.x>o&&(o=r.x),r.y>i&&(i=r.y);return{center:{x:(e+o)/2,y:(n+i)/2},width:o-e,height:i-n}},WSt=(t,e)=>{if(e.length<3)return!1;let n=!1;for(let o=0,i=e.length-1;o<e.length;i=o++){const r=e[o].x,s=e[o].y,a=e[i].x,c=e[i].y;s>t.y!=c>t.y&&t.x<(a-r)*(t.y-s)/(c-s||Number.EPSILON)+r&&(n=!n)}return n},y5o=(t,e,n)=>{const o=[];for(const i of t){if(!i._element)continue;if("x1"in i&&i._element?.type==="pcb_trace"){const a=hg({x:e.x,y:e.y},{x:i.x1,y:i.y1},{x:i.x2,y:i.y2}),c=i.width||.5,l=Math.max(c*25,2)/n.a;a<l&&o.push(i);continue}if(i.pcb_drawing_type==="polygon"){const a=i.points.map(l=>({x:tt.parse(l.x),y:tt.parse(l.y)})),c=rte(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;WSt(e,a)&&o.push(i);continue}if(i.pcb_drawing_type==="polygon_with_arcs"){const a=i.brep_shape.outer_ring.vertices.map(l=>({x:tt.parse(l.x),y:tt.parse(l.y)})),c=rte(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;WSt(e,a)&&o.push(i);continue}if(!("x"in i&&"y"in i))continue;let r=0,s=0;if("w"in i&&"h"in i)r=i.w,s=i.h;else if("r"in i)r=i.r*2,s=i.r*2;else if("rX"in i&&"rY"in i)r=i.rX*2,s=i.rY*2;else continue;Math.abs(i.x-e.x)<r/2&&Math.abs(i.y-e.y)<s/2&&o.push(i)}return o},C5o=({elements:t,children:e,transform:n,primitives:o,onMouseHoverOverPrimitives:i})=>{const[r,s]=J.useState([]),[a,c]=J.useState({x:0,y:0}),[l,{width:A,height:u}]=yO(),d=J.useMemo(()=>{const h=[];for(const m of r){if(m._element?.type==="pcb_via"||m._element?.type==="pcb_component"||m?.layer==="drill"||m?.is_hoverable===!1)continue;let p=null,g=0,f=0;if(m.pcb_drawing_type==="polygon"){const E=rte(m.points);if(!E)continue;p=E.center,g=E.width,f=E.height}else if(m.pcb_drawing_type==="polygon_with_arcs"){const E=m.brep_shape.outer_ring.vertices.map(P=>({x:P.x,y:P.y})),b=rte(E);if(!b)continue;p=b.center,g=b.width,f=b.height}else"x"in m&&"y"in m&&(p={x:m.x,y:m.y},g="w"in m?m.w:"r"in m?m.r*2:"rX"in m&&"rY"in m?m.rX*2:0,f="h"in m?m.h:"r"in m?m.r*2:"rX"in m&&"rY"in m?m.rY*2:0);if(!p)continue;const y=ht(n,p),C={w:g*n.a,h:f*n.a},I=h.filter(E=>y.x===E.screen_x&&y.y===E.screen_y&&C.w===E.screen_w&&C.h===E.screen_h).length;h.push({...m,x:p.x,y:p.y,w:g,h:f,screen_x:y.x,screen_y:y.y,screen_w:C.w,screen_h:C.h,same_space_index:I})}return h},[r,n]),_=(h,m,p,g)=>{c({x:h,y:m});const f=ht(qC(p),{x:h,y:m}),y=y5o(g,f,p);r5o(new Set(y.map(C=>C._pcb_drawing_object_id)),new Set(r.map(C=>C._pcb_drawing_object_id)))||(s(y),i(y))};return K.jsxs("div",{ref:l,style:{position:"relative",width:"100%",height:"100%"},onMouseMove:h=>{if(n){const m=h.currentTarget.getBoundingClientRect(),p=h.clientX-m.left,g=h.clientY-m.top;_(p,g,n,o)}},onTouchStart:h=>{if(n){const m=h.touches[0],p=h.currentTarget.getBoundingClientRect(),g=m.clientX-p.left,f=m.clientY-p.top;_(g,f,n,o)}},children:[e,K.jsx(d5o,{elements:t,mousePos:a,highlightedPrimitives:d}),n&&K.jsxs(K.Fragment,{children:[K.jsx(_5o,{elements:t,highlightedPrimitives:d,transform:n,containerWidth:A,containerHeight:u}),K.jsx(m5o,{elements:t,highlightedPrimitives:d,transform:n,containerWidth:A,containerHeight:u}),K.jsx(p5o,{elements:t,highlightedPrimitives:d,transform:n,containerWidth:A,containerHeight:u}),K.jsx(f5o,{elements:t,highlightedPrimitives:d,transform:n,containerWidth:A,containerHeight:u})]})]})},jSt=["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)"],x5o=({children:t,transform:e=dA(),elements:n=[],hoveredComponentIds:o=[]})=>{const[i,{width:r,height:s}]=yO(),a=J.useRef(null),{is_showing_pcb_groups:c,pcb_group_view_mode:l,is_showing_group_anchor_offsets:A}=Ld(u=>({is_showing_pcb_groups:u.is_showing_pcb_groups,pcb_group_view_mode:u.pcb_group_view_mode,is_showing_group_anchor_offsets:u.is_showing_group_anchor_offsets}));return J.useEffect(()=>{const u=a.current;if(!u||!r||!s)return;u.width=r,u.height=s;const d=u.getContext("2d");if(!d||(d.clearRect(0,0,r,s),!c))return;const _=n.filter(E=>E.type==="pcb_group"),h=n.filter(E=>E.type==="pcb_component"),m=n.filter(E=>E.type==="source_group"),p=new Map(m.map(E=>[E.source_group_id,E])),g=_.filter(E=>{if(E.name?.toLowerCase().includes("subpanel"))return!1;if(l==="all")return!0;if(!E.source_group_id)return!1;const b=p.get(E.source_group_id);return b?b.was_automatically_named!==!0:!1}),f=new Map;m.forEach(E=>{const b=E;if(b.parent_source_group_id){const P=f.get(b.parent_source_group_id)||[];P.push(E.source_group_id),f.set(b.parent_source_group_id,P)}});const y=E=>{const b=[],P=f.get(E)||[];for(const B of P)b.push(B),b.push(...y(B));return b},C=E=>{const b=m.find(P=>P.source_group_id===E);return b?.parent_source_group_id?1+C(b.parent_source_group_id):0},I=new Set;if(o.length>0)for(const E of h){if(!o.includes(E.pcb_component_id))continue;const b=E.positioned_relative_to_pcb_group_id??E.pcb_group_id;b&&I.add(b)}g.forEach((E,b)=>{let P=h.filter(we=>we.pcb_group_id===E.pcb_group_id);if(E.source_group_id){const we=y(E.source_group_id),Ue=_.filter(De=>De.source_group_id&&we.includes(De.source_group_id));for(const De of Ue){const Ee=h.filter(Le=>Le.pcb_group_id===De.pcb_group_id);P=[...P,...Ee]}}let B,M,k,N,L=!1;if(E.center&&E.width&&E.height){L=!0;const we=E.width/2,Ue=E.height/2;B=E.center.x-we,k=E.center.x+we,M=E.center.y-Ue,N=E.center.y+Ue}else if(P.length===0||(B=1/0,M=1/0,k=-1/0,N=-1/0,P.forEach(we=>{if(we.center&&typeof we.width=="number"&&typeof we.height=="number"){const Ue=we.center.x-we.width/2,De=we.center.x+we.width/2,Ee=we.center.y+we.height/2,Le=we.center.y-we.height/2;B=Math.min(B,Ue),k=Math.max(k,De),M=Math.min(M,Le),N=Math.max(N,Ee)}}),B===1/0||k===-1/0))return;const F=E.source_group_id?C(E.source_group_id):0,G=E.source_group_id?y(E.source_group_id).length>0:!1;if(!L){const De=1+(G?.5:0);B-=De,k+=De,M-=De,N+=De}const W=ht(e,{x:B,y:N}),j=ht(e,{x:k,y:N}),$=ht(e,{x:B,y:M}),oe=ht(e,{x:k,y:M}),le=jSt[b%jSt.length];d.strokeStyle=le,d.lineWidth=2;const ee=Math.max(4,Math.min(12,8*Math.abs(e.a))),ie=Math.max(2,Math.min(6,4*Math.abs(e.a))),re=ee*(G?1.3:1),ue=ie;d.setLineDash([re,ue]),d.beginPath(),d.moveTo(W.x,W.y),d.lineTo(j.x,j.y),d.lineTo(oe.x,oe.y),d.lineTo($.x,$.y),d.closePath(),d.stroke();const ye=Math.max(8,Math.min(12,10*Math.abs(e.a))),be=F==0||F==1?0:F*.11,ve=ye*(1-be),he=4,Pe=E.name||`Group ${b+1}`;d.font=`${ve}px sans-serif`,d.setLineDash([]);const Te=d.measureText(Pe).width+he*2,Ge=ve+he*2,Ye=W.x-5,fe=W.y-5,Xe=3;if(d.fillStyle="rgba(0, 0, 0, 0.8)",d.beginPath(),d.roundRect(Ye,fe-Ge,Te,Ge,Xe),d.fill(),d.fillStyle=le,d.textAlign="left",d.textBaseline="middle",d.fillText(Pe,Ye+he,fe-Ge/2),A&&I.has(E.pcb_group_id)&&!!E.anchor_position&&E.anchor_position){const we=Array.isArray(E.anchor_position)?{x:E.anchor_position[0]??0,y:E.anchor_position[1]??0}:{x:E.anchor_position.x,y:E.anchor_position.y},Ue=ht(e,we);d.strokeStyle="white",d.lineWidth=1.5,d.setLineDash([]);const De=Math.max(4,Math.min(8,6*Math.abs(e.a)));d.beginPath(),d.moveTo(Ue.x-De,Ue.y),d.lineTo(Ue.x+De,Ue.y),d.stroke(),d.beginPath(),d.moveTo(Ue.x,Ue.y-De),d.lineTo(Ue.x,Ue.y+De),d.stroke()}})},[n,e,r,s,c,l,A,o]),K.jsxs("div",{ref:i,style:{position:"relative",width:"100%",height:"100%"},children:[t,K.jsx("canvas",{ref:a,style:{position:"absolute",top:0,left:0,pointerEvents:"none",zIndex:bA.pcbGroupOverlay,display:c?"block":"none"}})]})},I5o=({transform:t,soup:e,children:n})=>{const o=Ld(a=>a.is_showing_rats_nest),{netMap:i,idToNetMap:r}=J.useMemo(()=>fSt(e||[]),[e]),s=J.useMemo(()=>{if(!e||!o)return[];const a=d=>{const _=uv(e)[d.replace(/_\d+$/,"")].get(d);return _&&"x"in _&&"y"in _?{x:_.x,y:_.y}:null},c=(d,_)=>{const h=i[_]||[];let m=null,p=1/0;return h.forEach(g=>{const f=a(g);if(f){const y=Math.sqrt((d.x-f.x)**2+(d.y-f.y)**2);y<p&&y>0&&(p=y,m=f)}}),m},l=uv(e).pcb_port.list(),A=uv(e).source_trace.list(),u=[];return l.forEach((d,_)=>{const h=r[d.pcb_port_id];let m=!1;for(const f of A)f.connected_source_port_ids.includes(d.source_port_id)&&f.connected_source_net_ids.length>0&&(m=!0);if(!h)return;const p={x:d.x,y:d.y},g=c(p,h);g&&u.push({key:`${d.pcb_port_id}-${_}`,startPoint:p,endPoint:g,isInNet:m})}),u},[e,i,r,o]);return!e||!o?n:(t||(t=dA()),K.jsxs("div",{style:{position:"relative"},children:[n,K.jsx("svg",{style:{position:"absolute",left:0,top:0,width:"100%",height:"100%",pointerEvents:"none",opacity:.5,zIndex:bA.ratsNestOverlay},children:s.map(({key:a,startPoint:c,endPoint:l,isInNet:A})=>{const u=ht(t,c),d=ht(t,l);return K.jsx("line",{x1:u.x,y1:u.y,x2:d.x,y2:d.y,stroke:"white",strokeWidth:"1",strokeDasharray:A?"6,6":void 0},a)})})]}))},E5o={version:"1.11.372"},hv=(t,e,n)=>{const o=Ld(s=>s.is_mouse_over_container),i=J.useRef(o),r=J.useRef(e);J.useEffect(()=>{i.current=o},[o]),J.useEffect(()=>{r.current=e},[e]),J.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("+"),A=l.includes("ctrl"),u=l.includes("shift"),d=l.includes("alt"),_=l.includes("meta"),h=l[l.length-1],m=n?.current?n.current.contains(document.activeElement)||document.activeElement===n.current:!1;(i.current||m)&&(!A||a.ctrlKey)&&(!u||a.shiftKey)&&(!d||a.altKey)&&(!_||a.metaKey)&&a.key.toLowerCase()===h.toLowerCase()&&(a.preventDefault(),r.current())};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s)}},[t])},b5o=()=>{const[t,e]=J.useState(!1);return J.useEffect(()=>{const n=()=>{e(window.innerWidth<=768)};return n(),window.addEventListener("resize",n),()=>window.removeEventListener("resize",n)},[]),t},xO=(t,e={stopPropagation:!0})=>{const n=J.useRef(0),o=J.useCallback(s=>{e.stopPropagation&&s.stopPropagation();const a=Date.now();a-n.current<300||(n.current=a,t?.(s))},[t,e.stopPropagation]),i=J.useCallback(s=>{s.preventDefault(),o(s)},[o]);return{onClick:o,onTouchEnd:i,style:{touchAction:"manipulation"}}},_v=({children:t,isSmallScreen:e,onClick:n,...o})=>{const{style:i,...r}=xO(n);return K.jsx("div",{...o,...r,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",...i,...o.style},children:t})},S5o=t=>{const e=new Map;return t.forEach((n,o)=>{const i=n.error_type||"unknown_error",r=e.get(i)||[];r.push({error:n,index:o,errorId:JQ(n,o)}),e.set(i,r)}),Array.from(e.entries()).map(([n,o])=>({errorType:n,errors:o}))},P5o=({onClose:t,setHoveredErrorId:e,setFocusedErrorId:n,highlightDurationMs:o=3e3})=>{const i=J.useRef(null),r=J.useRef(null),s=J.useRef(null),a=J.useCallback(()=>{i.current!==null&&(window.clearTimeout(i.current),i.current=null),r.current!==null&&(window.cancelAnimationFrame(r.current),r.current=null)},[]);J.useEffect(()=>a,[a]);const c=J.useCallback(A=>{a(),s.current=A,e(A),n(null),r.current=window.requestAnimationFrame(()=>{n(A),r.current=null}),t(),i.current=window.setTimeout(()=>{s.current=null,e(null),n(null),i.current=null},o)},[a,o,t,n,e]),l=J.useCallback(A=>s.current===A,[]);return{handleErrorSelect:c,isSelectedError:l}},v5o=({errorId:t,errorMessage:e,copiedErrorId:n,onCopy:o})=>{const{style:i,...r}=xO(()=>o(e,t));return K.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",...i},...r,children:n===t?K.jsx("span",{style:{color:"#4caf50",fontSize:12},children:"Copied!"}):K.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:K.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"})})})},B5o=({elements:t,isOpen:e,isSmallScreen:n,onToggle:o,onClose:i,setHoveredErrorId:r,setFocusedErrorId:s})=>{const[a,c]=J.useState(null),[l,A]=J.useState(new Set),[u,d]=J.useState(new Set),[,_]=d2o(),{handleErrorSelect:h,isSelectedError:m}=P5o({onClose:i,setHoveredErrorId:r,setFocusedErrorId:s}),p=J.useMemo(()=>t?.filter(I=>I.type.includes("error"))??[],[t]),g=p.length,f=J.useMemo(()=>S5o(p),[p]),y=J.useCallback(I=>{A(E=>{const b=new Set(E);return b.has(I)?b.delete(I):b.add(I),b})},[]),C=J.useCallback(I=>{d(E=>{const b=new Set(E);return b.has(I)?b.delete(I):b.add(I),b})},[]);return K.jsxs("div",{style:{position:"relative"},children:[K.jsx(_v,{isSmallScreen:n,style:g>0?{color:"red"}:void 0,onClick:o,children:K.jsxs("div",{children:[g," errors"]})}),e&&g>0&&K.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:f.map(({errorType:I,errors:E},b)=>{const P=l.has(I);return K.jsxs("div",{style:{borderBottom:b<f.length-1?"1px solid #444":"none"},children:[K.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:B=>{B.currentTarget.style.backgroundColor="#303030"},onMouseLeave:B=>{B.currentTarget.style.backgroundColor="#232323"},onTouchStart:B=>{B.stopPropagation(),B.currentTarget.style.backgroundColor="#303030"},onTouchEnd:B=>{B.stopPropagation(),B.preventDefault(),B.currentTarget.style.backgroundColor="#232323",y(I)},onClick:B=>{B.stopPropagation(),y(I)},children:[K.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,color:"#ff6b6b"},children:[K.jsx("div",{style:{color:"#888",fontSize:"16px",transform:P?"rotate(90deg)":"rotate(0deg)",transition:"transform 0.2s ease",flexShrink:0},children:"›"}),K.jsx("div",{style:{fontWeight:"bold",fontSize:n?"12px":"13px"},children:I})]}),K.jsx("div",{style:{fontSize:n?"12px":"13px",color:"#aaa",whiteSpace:"nowrap",marginLeft:12},children:E.length})]}),!P&&E.map(({error:B,index:M,errorId:k})=>{const N=u.has(k),L=B.message??"No error message";return K.jsxs("div",{style:{borderTop:"1px solid #3a3a3a"},children:[K.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:F=>{F.currentTarget.style.backgroundColor="#333",r(k)},onMouseLeave:F=>{F.currentTarget.style.backgroundColor="#2a2a2a",m(k)||r(null)},onTouchStart:F=>{F.stopPropagation(),F.currentTarget.style.backgroundColor="#333",r(k)},onTouchEnd:F=>{F.stopPropagation(),F.preventDefault(),F.currentTarget.style.backgroundColor="#2a2a2a",h(k)},onClick:F=>{F.stopPropagation(),h(k)},children:[K.jsx("div",{style:{flex:1,fontSize:n?"12px":"13px",color:"#ddd",lineHeight:1.4,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",userSelect:"text"},children:L}),K.jsx("button",{type:"button","aria-label":N?"Collapse error details":"Expand error details",style:{color:"#888",fontSize:"16px",transform:N?"rotate(0deg)":"rotate(90deg)",transition:"transform 0.2s ease",flexShrink:0,background:"none",border:"none",padding:0,cursor:"pointer"},onMouseDown:F=>F.stopPropagation(),onClick:F=>{F.stopPropagation(),C(k)},onTouchEnd:F=>{F.stopPropagation(),F.preventDefault(),C(k)},children:"›"})]}),N&&K.jsxs("div",{"data-error-id":M,style:{display:"block",padding:"12px 16px 12px 24px",backgroundColor:"#1a1a1a",borderTop:"1px solid #444",position:"relative"},children:[K.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:F=>F.stopPropagation(),onClick:F=>F.stopPropagation(),children:L}),K.jsx(v5o,{errorId:k,errorMessage:L,copiedErrorId:a,onCopy:(F,G)=>{_(F),c(G),setTimeout(()=>c(null),2e3)}})]})]},k)})]},I)})})]})},M5o=({name:t,selected:e,onClick:n})=>{const{style:o,...i}=xO(n);return K.jsxs("div",{className:XQ`
|
|
5712
5712
|
margin-top: 2px;
|
|
5713
5713
|
padding: 4px;
|
|
5714
5714
|
padding-left: 8px;
|
|
@@ -5779,7 +5779,7 @@ test("${l} should solve problem correctly", () => {
|
|
|
5779
5779
|
// Add more specific assertions based on expected output
|
|
5780
5780
|
// expect(solver.netLabelPlacementSolver!.netLabelPlacements).toMatchInlineSnapshot()
|
|
5781
5781
|
})
|
|
5782
|
-
`,u=new Blob([A],{type:"text/plain"}),d=URL.createObjectURL(u),_=document.createElement("a");_.href=d,_.download=`${l}.test.ts`,_.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 K.jsxs("div",{className:`relative ${e}`,ref:i,children:[K.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&&K.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:[K.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download JSON"}),K.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),K.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:a,children:"Download test.ts"})]})]})},$St=t=>t.activeSubSolver?[t,...$St(t.activeSubSolver)]:[t],S4o=({solver:t})=>{const e=$St(t);return K.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:e.map((n,o)=>K.jsxs("div",{className:"flex items-center",children:[o>0&&K.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),K.jsx(b4o,{solver:n})]},n.constructor.name))})},P4o=({solver:t,triggerRender:e,animationSpeed:n=25,onSolverStarted:o,onSolverCompleted:i})=>{const[r,s]=J.useReducer(m=>!m,!1),a=J.useRef(void 0),c=()=>{!t.solved&&!t.failed&&(t.step(),e())},l=()=>{!t.solved&&!t.failed&&(o&&o(t),t.solve(),e(),i&&i(t))},A=()=>{r?(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(),i&&t.solved&&i(t);return}t.step(),e()},n))},u=()=>{const m=t;if(m.getCurrentPhase&&!t.solved&&!t.failed){const p=m.getCurrentPhase();for(;m.getCurrentPhase()===p&&!t.solved&&!t.failed;)t.step();e()}},d=()=>{if(t.solved||t.failed||r)return;const m=window.prompt("Step until which iteration?",`${t.iterations}`);if(m===null)return;const p=Number(m);if(!Number.isFinite(p)){window.alert("Please enter a valid number for the iteration");return}for(;t.iterations<p&&!t.solved&&!t.failed;)t.step();e(),t.solved&&i&&i(t)};J.useEffect(()=>()=>{a.current&&clearInterval(a.current)},[]),J.useEffect(()=>{(t.solved||t.failed)&&r&&(a.current&&(clearInterval(a.current),a.current=void 0),s())},[t.solved,t.failed,r]);const _=t.getCurrentPhase!==void 0,h=_?t.getCurrentPhase():null;return K.jsxs("div",{className:"space-y-2 p-2 border-b",children:[K.jsx("div",{className:"flex items-center",children:K.jsx(S4o,{solver:t})}),K.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[K.jsx("button",{onClick:c,disabled:t.solved||t.failed||r,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),K.jsx("button",{onClick:l,disabled:t.solved||t.failed||r,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),K.jsx("button",{onClick:A,disabled:t.solved||t.failed,className:`px-3 py-1 rounded text-white text-sm ${r?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:r?"Stop":"Animate"}),K.jsx("button",{onClick:d,disabled:t.solved||t.failed||r,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"}),_&&K.jsx("button",{onClick:u,disabled:t.solved||t.failed||r,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),K.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&K.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),h&&K.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",K.jsx("span",{className:"font-medium",children:h})]}),t.solved&&K.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&K.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&K.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},v4o=(t,e,n)=>{const o=t.currentPipelineStepIndex;return e<o?"Completed":e===o&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},B4o=(t,e)=>{const o=t.pipelineDef[e].solverName,i=v4o(t,e),r=t[o],s=t.firstIterationOfPhase?.[o]??null,a=t.iterations;let c=0;if(i==="Completed"){const d=t.pipelineDef[e+1],_=d?t.firstIterationOfPhase?.[d.solverName]:void 0;_!==void 0&&s!==null?c=_-s:s!==null&&(c=a-s)}else i==="In Progress"&&s!==null&&(c=a-s);const l=t.timeSpentOnPhase?.[o]??0;let A=0;i==="Completed"?A=1:i==="In Progress"&&r&&(A=r.progress??0);const u=r?.stats??null;return{index:e,name:o,status:i,firstIteration:s,iterations:c,progress:A,timeSpent:l,stats:u&&Object.keys(u).length>0?u:null,solverInstance:r??null}},M4o=({status:t})=>{const e={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return K.jsx("span",{className:`font-medium ${e[t]}`,children:t})},w4o=({progress:t})=>{if(t===0)return null;const e=Math.round(t*100);return K.jsxs("div",{className:"flex items-center gap-2",children:[K.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:K.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${e}%`}})}),K.jsxs("span",{className:"text-xs text-gray-500",children:[e,"%"]})]})},D4o=t=>Object.entries(t).map(([e,n])=>`${e}: ${n}`).join(", "),Q4o=({stats:t})=>{if(!t||Object.keys(t).length===0)return K.jsx("span",{children:"-"});const e=Object.entries(t),n=D4o(t);return K.jsxs("details",{className:"cursor-pointer",children:[K.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:n}),K.jsx("div",{className:"mt-1 text-xs",children:e.map(([o,i])=>K.jsxs("div",{children:[o,": ",String(i)]},o))})]})},eve=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(eve);const e={};for(const[n,o]of Object.entries(t))n.startsWith("_")||(e[n]=eve(o));return e},T4o=(t,e)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${e}`);return}const n=eve(t.getConstructorParams()),o=new Blob([JSON.stringify(n,null,2)],{type:"application/json"}),i=URL.createObjectURL(o),r=document.createElement("a");r.href=i,r.download=`${e}_input.json`,r.click(),URL.revokeObjectURL(i)}catch(n){alert(`Error downloading input for ${e}: ${n instanceof Error?n.message:String(n)}`)}},R4o=({solver:t,onStepUntilPhase:e,onDownloadInput:n})=>{const o=t.pipelineDef.map((a,c)=>B4o(t,c)),i=a=>{e?.(a)},r=a=>{a.solverInstance&&(n?n(a.solverInstance,a.name):T4o(a.solverInstance,a.name))},s=a=>`${(a/1e3).toFixed(2)}s`;return K.jsxs("div",{className:"border-t border-gray-200",children:[K.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:K.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),K.jsx("div",{className:"overflow-x-auto",children:K.jsxs("table",{className:"w-full text-sm",children:[K.jsx("thead",{children:K.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[K.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),K.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),K.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",K.jsx("sub",{children:"0"})]}),K.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),K.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),K.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),K.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),K.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),K.jsx("tbody",{children:o.map(a=>K.jsxs("tr",{className:`border-b border-gray-100 ${a.status==="In Progress"?"bg-yellow-50":""}`,children:[K.jsx("td",{className:"px-4 py-2",children:K.jsxs("div",{className:"flex items-center gap-2",children:[K.jsx("span",{className:"text-gray-400 w-6",children:String(a.index+1).padStart(2,"0")}),K.jsx("button",{onClick:()=>i(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:K.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:K.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"})})}),K.jsx("span",{className:"font-medium text-gray-900",children:a.name})]})}),K.jsx("td",{className:"px-4 py-2",children:K.jsx(M4o,{status:a.status})}),K.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:a.firstIteration!==null?a.firstIteration:""}),K.jsx("td",{className:"px-4 py-2 text-gray-600",children:a.iterations}),K.jsx("td",{className:"px-4 py-2",children:K.jsx(w4o,{progress:a.progress})}),K.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(a.timeSpent)}),K.jsx("td",{className:"px-4 py-2 text-gray-500",children:K.jsx(Q4o,{stats:a.stats})}),K.jsx("td",{className:"px-4 py-2",children:a.solverInstance?K.jsxs("button",{onClick:()=>r(a),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${a.name}`,children:[K.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:K.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"})}),K.jsx("span",{children:"Input"})]}):null})]},a.name))})]})})]})},N4o=class extends lr.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 k4o({graphics:t}){const e=t.points??[],n=t.lines??[],o=t.rects??[],i=t.circles??[],r=t.texts??[];let s=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY,l=Number.NEGATIVE_INFINITY;const A=(p,g)=>{typeof p=="number"&&(p<s&&(s=p),p>c&&(c=p)),typeof g=="number"&&(g<a&&(a=g),g>l&&(l=g))};for(const p of e)A(p.x,p.y);for(const p of n){const g=p.points??[];for(const f of g)A(f.x,f.y)}for(const p of o){const g=p.x??0,f=p.y??0,y=p.width??0,C=p.height??0;A(g,f),A(g+y,f+C)}for(const p of i){const g=p.x??0,f=p.y??0,y=p.radius??1;A(g-y,f-y),A(g+y,f+y)}for(const p of r)A(p.x,p.y);(!isFinite(s)||!isFinite(a)||!isFinite(c)||!isFinite(l))&&(s=-20,a=-20,c=20,l=20);const u=10,d=s-u,_=a-u,h=Math.max(1,c-s+2*u),m=Math.max(1,l-a+2*u);return K.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${d} ${_} ${h} ${m}`,role:"img","aria-label":"Graphics fallback",children:[o.map((p,g)=>K.jsx("rect",{x:p.x??0,y:p.y??0,width:p.width??0,height:p.height??0,fill:"none",stroke:p.strokeColor??"black",strokeWidth:p.strokeWidth??1},`rect-${g}`)),n.map((p,g)=>K.jsx("polyline",{fill:"none",stroke:p.strokeColor??"black",strokeWidth:p.strokeWidth??1,points:(p.points??[]).map(f=>`${f.x??0},${f.y??0}`).join(" ")},`line-${g}`)),i.map((p,g)=>K.jsx("circle",{cx:p.x??0,cy:p.y??0,r:p.radius??1.5,fill:p.fillColor??"none",stroke:p.strokeColor??"black",strokeWidth:p.strokeWidth??1},`circle-${g}`)),e.map((p,g)=>K.jsx("circle",{cx:p.x??0,cy:p.y??0,r:p.radius??1.5,fill:p.color??"black"},`point-${g}`)),r.map((p,g)=>K.jsx("text",{x:p.x??0,y:p.y??0,fontSize:p.fontSize??10,fill:p.color??"black",children:p.text??""},`text-${g}`))]})}var H4o=({solver:t,animationSpeed:e=25,onSolverStarted:n,onSolverCompleted:o})=>{const[i,r]=J.useReducer(A=>A+1,0),s=J.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(A){return console.error("Visualization error:",A),{points:[],lines:[],rects:[],circles:[]}}},[t,i]),a=J.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);J.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const A=document.createElement("script");A.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(A)}},[]);const c=t.pipelineDef!==void 0,l=A=>{const u=t;if(!t.solved&&!t.failed){for(;!t.solved&&!t.failed&&u.currentPipelineStepIndex<=u.pipelineDef.findIndex(d=>d.solverName===A);)t.step();r()}};return K.jsxs("div",{children:[K.jsx(P4o,{solver:t,triggerRender:r,animationSpeed:e,onSolverStarted:n,onSolverCompleted:o}),a?K.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):K.jsx(N4o,{fallback:K.jsx(k4o,{graphics:s}),children:K.jsx(E4o,{graphics:s})}),c&&K.jsx(R4o,{solver:t,onStepUntilPhase:l})]})};const L4o=()=>{J.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)},[])},F4o=t=>t.toLowerCase().includes("pack")?oco:t.toLowerCase().includes("rout")?cco:Uao,O4o=({solverEvents:t=[]})=>{const[e,n]=J.useState(null);L4o();const o=J.useMemo(()=>{const a=new Map;for(const c of t){const l=`${c.componentName}-${c.solverName}`;a.set(l,c)}return a},[t]),i=J.useMemo(()=>Array.from(o.keys()),[o]),r=e?o.get(e):null,s=J.useMemo(()=>{if(!r)return{instance:null,error:null,classFound:!1};const a=ome[r.solverName];if(!a)return{instance:null,error:`Solver class "${r.solverName}" not found in SOLVERS registry. Available: ${Object.keys(ome).join(", ")}`,classFound:!1};try{const c=r.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}}},[r]);return t.length===0?K.jsx("div",{className:"rf-p-4",children:K.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:K.jsxs("div",{className:"rf-p-4",children:[K.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),K.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."})]})})}):K.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[K.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[K.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:[i.length," ",i.length===1?"Solver":"Solvers"]}),i.map(a=>{const c=o.get(a),l=e===a;return K.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 A=F4o(c.solverName);return K.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[K.jsx(A,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),K.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[K.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:c.componentName}),K.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:c.solverName})]})]})})()},a)})]}),K.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:r?s.instance?K.jsx(J2,{fallback:K.jsx("div",{className:"rf-p-4",children:K.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[K.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),K.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",r.solverName]})]})}),children:K.jsx(H4o,{solver:s.instance})}):K.jsxs("div",{className:"rf-p-4",children:[K.jsxs("div",{className:"rf-mb-4",children:[K.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:r.solverName}),K.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",r.componentName]})]}),s.error&&K.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:K.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),K.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[K.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:K.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),K.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:K.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(r.solverParams,null,2)})})]})]}):K.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:K.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},ZSt=({errorMessage:t,errorStack:e,circuitJsonErrors:n})=>{J.useEffect(()=>{if(t){const o=new Error(t);e&&(o.stack=e);try{Ww.captureException(o)}catch{}}},[t,e]),J.useEffect(()=>{if(n&&n.length>0)for(const o of n){const i=new Error(o.message||"Circuit JSON Error");o.stack&&(i.stack=o.stack);try{Ww.captureException(i,{error_type:o.type})}catch{}}},[n])},e3t=t=>{J.useEffect(()=>{try{EBn(t)}catch{}},[t.source,t.component,t.isWebEmbedded,t.activeTab])},t3t="0.0.2100",G4o={version:t3t},cte=Ktt()(Wtt(t=>({lastRunEvalVersion:void 0,setLastRunEvalVersion:e=>{t({lastRunEvalVersion:e})}}),{name:"runframe-runner-store"})),U4o=t=>{const[e,n]=J.useState([]),[o,i]=J.useState(null),[r,s]=J.useState(""),[a,c]=bw("eval-version-selection",null),l=cte(_=>_.setLastRunEvalVersion),A=cte(_=>_.lastRunEvalVersion);return J.useEffect(()=>{t&&fetch("https://data.jsdelivr.com/v1/package/npm/@tscircuit/eval").then(_=>_.json()).then(_=>{if(Array.isArray(_?.versions)){let h=[..._.versions];_.tags?.latest&&(i(_.tags.latest),h=h.filter(m=>m!==_.tags.latest)),n(h)}}).catch(()=>{})},[t]),J.useEffect(()=>{t&&(a?(window.TSCIRCUIT_LATEST_EVAL_VERSION=a,l(a)):o&&(window.TSCIRCUIT_LATEST_EVAL_VERSION=o,l(o)))},[t,a,o]),{versions:J.useMemo(()=>e.filter(_=>_.includes(r)).slice(0,50),[e,r]),latestVersion:o,lastRunEvalVersion:A,search:r,setSearch:s,selectVersion:_=>{c(_),s("")}}},z4o=({snippetNames:t,onSelect:e,onCancel:n,isOpen:o})=>{const[i,r]=J.useState(""),[s,a]=J.useState("");if(!o)return null;const c=t.filter(u=>u.toLowerCase().includes(s.toLowerCase())),l=s&&!t.includes(s),A=u=>{u.key==="Enter"&&(c.length===1?r(c[0]):l&&r(s))};return K.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:K.jsxs("div",{className:"rf-bg-white rf-rounded-lg rf-p-6 rf-w-96",children:[K.jsx("h2",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Select Snippet"}),K.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:u=>a(u.target.value),onKeyDown:A}),K.jsxs("div",{className:"rf-h-60 rf-overflow-y-auto",children:[c.map(u=>K.jsx("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 ${i===u?"bg-blue-50":""}`,onClick:()=>r(u),children:u},u)),l&&K.jsxs("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 text-blue-500 ${i===s?"bg-blue-50":""}`,onClick:()=>r(s),children:['Create new "',s,'"']})]}),K.jsxs("div",{className:"rf-mt-4 rf-flex rf-justify-end rf-gap-2",children:[K.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-text-gray-600 rf-hover:text-gray-800",onClick:n,children:"Cancel"}),K.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:()=>i&&e(i),disabled:!i,children:i===s?`Create "${i}"`:`Save to ${i}`})]})]})})},V4o=t=>{const e=J.useRef(null),n=p0(o=>o.recentEvents);J.useEffect(()=>{if(n.length===0)return;const o=n[0];o.event_id!==e.current&&(t(o),e.current=o.event_id)},[n,t])};var lte="Dialog",[n3t,o3t]=zI(lte),[Y4o,g5]=n3t(lte),i3t=t=>{const{__scopeDialog:e,children:n,open:o,defaultOpen:i,onOpenChange:r,modal:s=!0}=t,a=J.useRef(null),c=J.useRef(null),[l,A]=rP({prop:o,defaultProp:i??!1,onChange:r,caller:lte});return K.jsx(Y4o,{scope:e,triggerRef:a,contentRef:c,contentId:hp(),titleId:hp(),descriptionId:hp(),open:l,onOpenChange:A,onOpenToggle:J.useCallback(()=>A(u=>!u),[A]),modal:s,children:n})};i3t.displayName=lte;var r3t="DialogTrigger",s3t=J.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,i=g5(r3t,n),r=f0(e,i.triggerRef);return K.jsx(ka.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":ove(i.open),...o,ref:r,onClick:Sr(t.onClick,i.onOpenToggle)})});s3t.displayName=r3t;var tve="DialogPortal",[K4o,a3t]=n3t(tve,{forceMount:void 0}),c3t=t=>{const{__scopeDialog:e,forceMount:n,children:o,container:i}=t,r=g5(tve,e);return K.jsx(K4o,{scope:e,forceMount:n,children:J.Children.map(o,s=>K.jsx(ux,{present:n||r.open,children:K.jsx(MZ,{asChild:!0,container:i,children:s})}))})};c3t.displayName=tve;var Ate="DialogOverlay",l3t=J.forwardRef((t,e)=>{const n=a3t(Ate,t.__scopeDialog),{forceMount:o=n.forceMount,...i}=t,r=g5(Ate,t.__scopeDialog);return r.modal?K.jsx(ux,{present:o||r.open,children:K.jsx(j4o,{...i,ref:e})}):null});l3t.displayName=Ate;var W4o=MB("DialogOverlay.RemoveScroll"),j4o=J.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,i=g5(Ate,n);return K.jsx(HZ,{as:W4o,allowPinchZoom:!0,shards:[i.contentRef],children:K.jsx(ka.div,{"data-state":ove(i.open),...o,ref:e,style:{pointerEvents:"auto",...o.style}})})}),q8="DialogContent",A3t=J.forwardRef((t,e)=>{const n=a3t(q8,t.__scopeDialog),{forceMount:o=n.forceMount,...i}=t,r=g5(q8,t.__scopeDialog);return K.jsx(ux,{present:o||r.open,children:r.modal?K.jsx(X4o,{...i,ref:e}):K.jsx(J4o,{...i,ref:e})})});A3t.displayName=q8;var X4o=J.forwardRef((t,e)=>{const n=g5(q8,t.__scopeDialog),o=J.useRef(null),i=f0(e,n.contentRef,o);return J.useEffect(()=>{const r=o.current;if(r)return e3e(r)},[]),K.jsx(u3t,{...t,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:Sr(t.onCloseAutoFocus,r=>{r.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:Sr(t.onPointerDownOutside,r=>{const s=r.detail.originalEvent,a=s.button===0&&s.ctrlKey===!0;(s.button===2||a)&&r.preventDefault()}),onFocusOutside:Sr(t.onFocusOutside,r=>r.preventDefault())})}),J4o=J.forwardRef((t,e)=>{const n=g5(q8,t.__scopeDialog),o=J.useRef(!1),i=J.useRef(!1);return K.jsx(u3t,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:r=>{t.onCloseAutoFocus?.(r),r.defaultPrevented||(o.current||n.triggerRef.current?.focus(),r.preventDefault()),o.current=!1,i.current=!1},onInteractOutside:r=>{t.onInteractOutside?.(r),r.defaultPrevented||(o.current=!0,r.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const s=r.target;n.triggerRef.current?.contains(s)&&r.preventDefault(),r.detail.originalEvent.type==="focusin"&&i.current&&r.preventDefault()}})}),u3t=J.forwardRef((t,e)=>{const{__scopeDialog:n,trapFocus:o,onOpenAutoFocus:i,onCloseAutoFocus:r,...s}=t,a=g5(q8,n),c=J.useRef(null),l=f0(e,c);return TSe(),K.jsxs(K.Fragment,{children:[K.jsx(gZ,{asChild:!0,loop:!0,trapped:o,onMountAutoFocus:i,onUnmountAutoFocus:r,children:K.jsx(pF,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":ove(a.open),...s,ref:l,onDismiss:()=>a.onOpenChange(!1)})}),K.jsxs(K.Fragment,{children:[K.jsx($4o,{titleId:a.titleId}),K.jsx(eEo,{contentRef:c,descriptionId:a.descriptionId})]})]})}),nve="DialogTitle",d3t=J.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,i=g5(nve,n);return K.jsx(ka.h2,{id:i.titleId,...o,ref:e})});d3t.displayName=nve;var h3t="DialogDescription",_3t=J.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,i=g5(h3t,n);return K.jsx(ka.p,{id:i.descriptionId,...o,ref:e})});_3t.displayName=h3t;var m3t="DialogClose",g3t=J.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,i=g5(m3t,n);return K.jsx(ka.button,{type:"button",...o,ref:e,onClick:Sr(t.onClick,()=>i.onOpenChange(!1))})});g3t.displayName=m3t;function ove(t){return t?"open":"closed"}var p3t="DialogTitleWarning",[q4o,f3t]=I3n(p3t,{contentName:q8,titleName:nve,docsSlug:"dialog"}),$4o=({titleId:t})=>{const e=f3t(p3t),n=`\`${e.contentName}\` requires a \`${e.titleName}\` for the component to be accessible for screen reader users.
|
|
5782
|
+
`,u=new Blob([A],{type:"text/plain"}),d=URL.createObjectURL(u),_=document.createElement("a");_.href=d,_.download=`${l}.test.ts`,_.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 K.jsxs("div",{className:`relative ${e}`,ref:i,children:[K.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&&K.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:[K.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download JSON"}),K.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),K.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:a,children:"Download test.ts"})]})]})},$St=t=>t.activeSubSolver?[t,...$St(t.activeSubSolver)]:[t],S4o=({solver:t})=>{const e=$St(t);return K.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:e.map((n,o)=>K.jsxs("div",{className:"flex items-center",children:[o>0&&K.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),K.jsx(b4o,{solver:n})]},n.constructor.name))})},P4o=({solver:t,triggerRender:e,animationSpeed:n=25,onSolverStarted:o,onSolverCompleted:i})=>{const[r,s]=J.useReducer(m=>!m,!1),a=J.useRef(void 0),c=()=>{!t.solved&&!t.failed&&(t.step(),e())},l=()=>{!t.solved&&!t.failed&&(o&&o(t),t.solve(),e(),i&&i(t))},A=()=>{r?(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(),i&&t.solved&&i(t);return}t.step(),e()},n))},u=()=>{const m=t;if(m.getCurrentPhase&&!t.solved&&!t.failed){const p=m.getCurrentPhase();for(;m.getCurrentPhase()===p&&!t.solved&&!t.failed;)t.step();e()}},d=()=>{if(t.solved||t.failed||r)return;const m=window.prompt("Step until which iteration?",`${t.iterations}`);if(m===null)return;const p=Number(m);if(!Number.isFinite(p)){window.alert("Please enter a valid number for the iteration");return}for(;t.iterations<p&&!t.solved&&!t.failed;)t.step();e(),t.solved&&i&&i(t)};J.useEffect(()=>()=>{a.current&&clearInterval(a.current)},[]),J.useEffect(()=>{(t.solved||t.failed)&&r&&(a.current&&(clearInterval(a.current),a.current=void 0),s())},[t.solved,t.failed,r]);const _=t.getCurrentPhase!==void 0,h=_?t.getCurrentPhase():null;return K.jsxs("div",{className:"space-y-2 p-2 border-b",children:[K.jsx("div",{className:"flex items-center",children:K.jsx(S4o,{solver:t})}),K.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[K.jsx("button",{onClick:c,disabled:t.solved||t.failed||r,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),K.jsx("button",{onClick:l,disabled:t.solved||t.failed||r,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),K.jsx("button",{onClick:A,disabled:t.solved||t.failed,className:`px-3 py-1 rounded text-white text-sm ${r?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:r?"Stop":"Animate"}),K.jsx("button",{onClick:d,disabled:t.solved||t.failed||r,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"}),_&&K.jsx("button",{onClick:u,disabled:t.solved||t.failed||r,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),K.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&K.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),h&&K.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",K.jsx("span",{className:"font-medium",children:h})]}),t.solved&&K.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&K.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&K.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},v4o=(t,e,n)=>{const o=t.currentPipelineStepIndex;return e<o?"Completed":e===o&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},B4o=(t,e)=>{const o=t.pipelineDef[e].solverName,i=v4o(t,e),r=t[o],s=t.firstIterationOfPhase?.[o]??null,a=t.iterations;let c=0;if(i==="Completed"){const d=t.pipelineDef[e+1],_=d?t.firstIterationOfPhase?.[d.solverName]:void 0;_!==void 0&&s!==null?c=_-s:s!==null&&(c=a-s)}else i==="In Progress"&&s!==null&&(c=a-s);const l=t.timeSpentOnPhase?.[o]??0;let A=0;i==="Completed"?A=1:i==="In Progress"&&r&&(A=r.progress??0);const u=r?.stats??null;return{index:e,name:o,status:i,firstIteration:s,iterations:c,progress:A,timeSpent:l,stats:u&&Object.keys(u).length>0?u:null,solverInstance:r??null}},M4o=({status:t})=>{const e={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return K.jsx("span",{className:`font-medium ${e[t]}`,children:t})},w4o=({progress:t})=>{if(t===0)return null;const e=Math.round(t*100);return K.jsxs("div",{className:"flex items-center gap-2",children:[K.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:K.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${e}%`}})}),K.jsxs("span",{className:"text-xs text-gray-500",children:[e,"%"]})]})},D4o=t=>Object.entries(t).map(([e,n])=>`${e}: ${n}`).join(", "),Q4o=({stats:t})=>{if(!t||Object.keys(t).length===0)return K.jsx("span",{children:"-"});const e=Object.entries(t),n=D4o(t);return K.jsxs("details",{className:"cursor-pointer",children:[K.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:n}),K.jsx("div",{className:"mt-1 text-xs",children:e.map(([o,i])=>K.jsxs("div",{children:[o,": ",String(i)]},o))})]})},eve=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(eve);const e={};for(const[n,o]of Object.entries(t))n.startsWith("_")||(e[n]=eve(o));return e},T4o=(t,e)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${e}`);return}const n=eve(t.getConstructorParams()),o=new Blob([JSON.stringify(n,null,2)],{type:"application/json"}),i=URL.createObjectURL(o),r=document.createElement("a");r.href=i,r.download=`${e}_input.json`,r.click(),URL.revokeObjectURL(i)}catch(n){alert(`Error downloading input for ${e}: ${n instanceof Error?n.message:String(n)}`)}},R4o=({solver:t,onStepUntilPhase:e,onDownloadInput:n})=>{const o=t.pipelineDef.map((a,c)=>B4o(t,c)),i=a=>{e?.(a)},r=a=>{a.solverInstance&&(n?n(a.solverInstance,a.name):T4o(a.solverInstance,a.name))},s=a=>`${(a/1e3).toFixed(2)}s`;return K.jsxs("div",{className:"border-t border-gray-200",children:[K.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:K.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),K.jsx("div",{className:"overflow-x-auto",children:K.jsxs("table",{className:"w-full text-sm",children:[K.jsx("thead",{children:K.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[K.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),K.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),K.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",K.jsx("sub",{children:"0"})]}),K.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),K.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),K.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),K.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),K.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),K.jsx("tbody",{children:o.map(a=>K.jsxs("tr",{className:`border-b border-gray-100 ${a.status==="In Progress"?"bg-yellow-50":""}`,children:[K.jsx("td",{className:"px-4 py-2",children:K.jsxs("div",{className:"flex items-center gap-2",children:[K.jsx("span",{className:"text-gray-400 w-6",children:String(a.index+1).padStart(2,"0")}),K.jsx("button",{onClick:()=>i(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:K.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:K.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"})})}),K.jsx("span",{className:"font-medium text-gray-900",children:a.name})]})}),K.jsx("td",{className:"px-4 py-2",children:K.jsx(M4o,{status:a.status})}),K.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:a.firstIteration!==null?a.firstIteration:""}),K.jsx("td",{className:"px-4 py-2 text-gray-600",children:a.iterations}),K.jsx("td",{className:"px-4 py-2",children:K.jsx(w4o,{progress:a.progress})}),K.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(a.timeSpent)}),K.jsx("td",{className:"px-4 py-2 text-gray-500",children:K.jsx(Q4o,{stats:a.stats})}),K.jsx("td",{className:"px-4 py-2",children:a.solverInstance?K.jsxs("button",{onClick:()=>r(a),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${a.name}`,children:[K.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:K.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"})}),K.jsx("span",{children:"Input"})]}):null})]},a.name))})]})})]})},N4o=class extends lr.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 k4o({graphics:t}){const e=t.points??[],n=t.lines??[],o=t.rects??[],i=t.circles??[],r=t.texts??[];let s=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY,l=Number.NEGATIVE_INFINITY;const A=(p,g)=>{typeof p=="number"&&(p<s&&(s=p),p>c&&(c=p)),typeof g=="number"&&(g<a&&(a=g),g>l&&(l=g))};for(const p of e)A(p.x,p.y);for(const p of n){const g=p.points??[];for(const f of g)A(f.x,f.y)}for(const p of o){const g=p.x??0,f=p.y??0,y=p.width??0,C=p.height??0;A(g,f),A(g+y,f+C)}for(const p of i){const g=p.x??0,f=p.y??0,y=p.radius??1;A(g-y,f-y),A(g+y,f+y)}for(const p of r)A(p.x,p.y);(!isFinite(s)||!isFinite(a)||!isFinite(c)||!isFinite(l))&&(s=-20,a=-20,c=20,l=20);const u=10,d=s-u,_=a-u,h=Math.max(1,c-s+2*u),m=Math.max(1,l-a+2*u);return K.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${d} ${_} ${h} ${m}`,role:"img","aria-label":"Graphics fallback",children:[o.map((p,g)=>K.jsx("rect",{x:p.x??0,y:p.y??0,width:p.width??0,height:p.height??0,fill:"none",stroke:p.strokeColor??"black",strokeWidth:p.strokeWidth??1},`rect-${g}`)),n.map((p,g)=>K.jsx("polyline",{fill:"none",stroke:p.strokeColor??"black",strokeWidth:p.strokeWidth??1,points:(p.points??[]).map(f=>`${f.x??0},${f.y??0}`).join(" ")},`line-${g}`)),i.map((p,g)=>K.jsx("circle",{cx:p.x??0,cy:p.y??0,r:p.radius??1.5,fill:p.fillColor??"none",stroke:p.strokeColor??"black",strokeWidth:p.strokeWidth??1},`circle-${g}`)),e.map((p,g)=>K.jsx("circle",{cx:p.x??0,cy:p.y??0,r:p.radius??1.5,fill:p.color??"black"},`point-${g}`)),r.map((p,g)=>K.jsx("text",{x:p.x??0,y:p.y??0,fontSize:p.fontSize??10,fill:p.color??"black",children:p.text??""},`text-${g}`))]})}var H4o=({solver:t,animationSpeed:e=25,onSolverStarted:n,onSolverCompleted:o})=>{const[i,r]=J.useReducer(A=>A+1,0),s=J.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(A){return console.error("Visualization error:",A),{points:[],lines:[],rects:[],circles:[]}}},[t,i]),a=J.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);J.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const A=document.createElement("script");A.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(A)}},[]);const c=t.pipelineDef!==void 0,l=A=>{const u=t;if(!t.solved&&!t.failed){for(;!t.solved&&!t.failed&&u.currentPipelineStepIndex<=u.pipelineDef.findIndex(d=>d.solverName===A);)t.step();r()}};return K.jsxs("div",{children:[K.jsx(P4o,{solver:t,triggerRender:r,animationSpeed:e,onSolverStarted:n,onSolverCompleted:o}),a?K.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):K.jsx(N4o,{fallback:K.jsx(k4o,{graphics:s}),children:K.jsx(E4o,{graphics:s})}),c&&K.jsx(R4o,{solver:t,onStepUntilPhase:l})]})};const L4o=()=>{J.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)},[])},F4o=t=>t.toLowerCase().includes("pack")?oco:t.toLowerCase().includes("rout")?cco:Uao,O4o=({solverEvents:t=[]})=>{const[e,n]=J.useState(null);L4o();const o=J.useMemo(()=>{const a=new Map;for(const c of t){const l=`${c.componentName}-${c.solverName}`;a.set(l,c)}return a},[t]),i=J.useMemo(()=>Array.from(o.keys()),[o]),r=e?o.get(e):null,s=J.useMemo(()=>{if(!r)return{instance:null,error:null,classFound:!1};const a=ome[r.solverName];if(!a)return{instance:null,error:`Solver class "${r.solverName}" not found in SOLVERS registry. Available: ${Object.keys(ome).join(", ")}`,classFound:!1};try{const c=r.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}}},[r]);return t.length===0?K.jsx("div",{className:"rf-p-4",children:K.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:K.jsxs("div",{className:"rf-p-4",children:[K.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),K.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."})]})})}):K.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[K.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[K.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:[i.length," ",i.length===1?"Solver":"Solvers"]}),i.map(a=>{const c=o.get(a),l=e===a;return K.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 A=F4o(c.solverName);return K.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[K.jsx(A,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),K.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[K.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:c.componentName}),K.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:c.solverName})]})]})})()},a)})]}),K.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:r?s.instance?K.jsx(J2,{fallback:K.jsx("div",{className:"rf-p-4",children:K.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[K.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),K.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",r.solverName]})]})}),children:K.jsx(H4o,{solver:s.instance})}):K.jsxs("div",{className:"rf-p-4",children:[K.jsxs("div",{className:"rf-mb-4",children:[K.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:r.solverName}),K.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",r.componentName]})]}),s.error&&K.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:K.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),K.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[K.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:K.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),K.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:K.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(r.solverParams,null,2)})})]})]}):K.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:K.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},ZSt=({errorMessage:t,errorStack:e,circuitJsonErrors:n})=>{J.useEffect(()=>{if(t){const o=new Error(t);e&&(o.stack=e);try{Ww.captureException(o)}catch{}}},[t,e]),J.useEffect(()=>{if(n&&n.length>0)for(const o of n){const i=new Error(o.message||"Circuit JSON Error");o.stack&&(i.stack=o.stack);try{Ww.captureException(i,{error_type:o.type})}catch{}}},[n])},e3t=t=>{J.useEffect(()=>{try{EBn(t)}catch{}},[t.source,t.component,t.isWebEmbedded,t.activeTab])},t3t="0.0.2101",G4o={version:t3t},cte=Ktt()(Wtt(t=>({lastRunEvalVersion:void 0,setLastRunEvalVersion:e=>{t({lastRunEvalVersion:e})}}),{name:"runframe-runner-store"})),U4o=t=>{const[e,n]=J.useState([]),[o,i]=J.useState(null),[r,s]=J.useState(""),[a,c]=bw("eval-version-selection",null),l=cte(_=>_.setLastRunEvalVersion),A=cte(_=>_.lastRunEvalVersion);return J.useEffect(()=>{t&&fetch("https://data.jsdelivr.com/v1/package/npm/@tscircuit/eval").then(_=>_.json()).then(_=>{if(Array.isArray(_?.versions)){let h=[..._.versions];_.tags?.latest&&(i(_.tags.latest),h=h.filter(m=>m!==_.tags.latest)),n(h)}}).catch(()=>{})},[t]),J.useEffect(()=>{t&&(a?(window.TSCIRCUIT_LATEST_EVAL_VERSION=a,l(a)):o&&(window.TSCIRCUIT_LATEST_EVAL_VERSION=o,l(o)))},[t,a,o]),{versions:J.useMemo(()=>e.filter(_=>_.includes(r)).slice(0,50),[e,r]),latestVersion:o,lastRunEvalVersion:A,search:r,setSearch:s,selectVersion:_=>{c(_),s("")}}},z4o=({snippetNames:t,onSelect:e,onCancel:n,isOpen:o})=>{const[i,r]=J.useState(""),[s,a]=J.useState("");if(!o)return null;const c=t.filter(u=>u.toLowerCase().includes(s.toLowerCase())),l=s&&!t.includes(s),A=u=>{u.key==="Enter"&&(c.length===1?r(c[0]):l&&r(s))};return K.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:K.jsxs("div",{className:"rf-bg-white rf-rounded-lg rf-p-6 rf-w-96",children:[K.jsx("h2",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Select Snippet"}),K.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:u=>a(u.target.value),onKeyDown:A}),K.jsxs("div",{className:"rf-h-60 rf-overflow-y-auto",children:[c.map(u=>K.jsx("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 ${i===u?"bg-blue-50":""}`,onClick:()=>r(u),children:u},u)),l&&K.jsxs("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 text-blue-500 ${i===s?"bg-blue-50":""}`,onClick:()=>r(s),children:['Create new "',s,'"']})]}),K.jsxs("div",{className:"rf-mt-4 rf-flex rf-justify-end rf-gap-2",children:[K.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-text-gray-600 rf-hover:text-gray-800",onClick:n,children:"Cancel"}),K.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:()=>i&&e(i),disabled:!i,children:i===s?`Create "${i}"`:`Save to ${i}`})]})]})})},V4o=t=>{const e=J.useRef(null),n=p0(o=>o.recentEvents);J.useEffect(()=>{if(n.length===0)return;const o=n[0];o.event_id!==e.current&&(t(o),e.current=o.event_id)},[n,t])};var lte="Dialog",[n3t,o3t]=zI(lte),[Y4o,g5]=n3t(lte),i3t=t=>{const{__scopeDialog:e,children:n,open:o,defaultOpen:i,onOpenChange:r,modal:s=!0}=t,a=J.useRef(null),c=J.useRef(null),[l,A]=rP({prop:o,defaultProp:i??!1,onChange:r,caller:lte});return K.jsx(Y4o,{scope:e,triggerRef:a,contentRef:c,contentId:hp(),titleId:hp(),descriptionId:hp(),open:l,onOpenChange:A,onOpenToggle:J.useCallback(()=>A(u=>!u),[A]),modal:s,children:n})};i3t.displayName=lte;var r3t="DialogTrigger",s3t=J.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,i=g5(r3t,n),r=f0(e,i.triggerRef);return K.jsx(ka.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":ove(i.open),...o,ref:r,onClick:Sr(t.onClick,i.onOpenToggle)})});s3t.displayName=r3t;var tve="DialogPortal",[K4o,a3t]=n3t(tve,{forceMount:void 0}),c3t=t=>{const{__scopeDialog:e,forceMount:n,children:o,container:i}=t,r=g5(tve,e);return K.jsx(K4o,{scope:e,forceMount:n,children:J.Children.map(o,s=>K.jsx(ux,{present:n||r.open,children:K.jsx(MZ,{asChild:!0,container:i,children:s})}))})};c3t.displayName=tve;var Ate="DialogOverlay",l3t=J.forwardRef((t,e)=>{const n=a3t(Ate,t.__scopeDialog),{forceMount:o=n.forceMount,...i}=t,r=g5(Ate,t.__scopeDialog);return r.modal?K.jsx(ux,{present:o||r.open,children:K.jsx(j4o,{...i,ref:e})}):null});l3t.displayName=Ate;var W4o=MB("DialogOverlay.RemoveScroll"),j4o=J.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,i=g5(Ate,n);return K.jsx(HZ,{as:W4o,allowPinchZoom:!0,shards:[i.contentRef],children:K.jsx(ka.div,{"data-state":ove(i.open),...o,ref:e,style:{pointerEvents:"auto",...o.style}})})}),q8="DialogContent",A3t=J.forwardRef((t,e)=>{const n=a3t(q8,t.__scopeDialog),{forceMount:o=n.forceMount,...i}=t,r=g5(q8,t.__scopeDialog);return K.jsx(ux,{present:o||r.open,children:r.modal?K.jsx(X4o,{...i,ref:e}):K.jsx(J4o,{...i,ref:e})})});A3t.displayName=q8;var X4o=J.forwardRef((t,e)=>{const n=g5(q8,t.__scopeDialog),o=J.useRef(null),i=f0(e,n.contentRef,o);return J.useEffect(()=>{const r=o.current;if(r)return e3e(r)},[]),K.jsx(u3t,{...t,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:Sr(t.onCloseAutoFocus,r=>{r.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:Sr(t.onPointerDownOutside,r=>{const s=r.detail.originalEvent,a=s.button===0&&s.ctrlKey===!0;(s.button===2||a)&&r.preventDefault()}),onFocusOutside:Sr(t.onFocusOutside,r=>r.preventDefault())})}),J4o=J.forwardRef((t,e)=>{const n=g5(q8,t.__scopeDialog),o=J.useRef(!1),i=J.useRef(!1);return K.jsx(u3t,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:r=>{t.onCloseAutoFocus?.(r),r.defaultPrevented||(o.current||n.triggerRef.current?.focus(),r.preventDefault()),o.current=!1,i.current=!1},onInteractOutside:r=>{t.onInteractOutside?.(r),r.defaultPrevented||(o.current=!0,r.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const s=r.target;n.triggerRef.current?.contains(s)&&r.preventDefault(),r.detail.originalEvent.type==="focusin"&&i.current&&r.preventDefault()}})}),u3t=J.forwardRef((t,e)=>{const{__scopeDialog:n,trapFocus:o,onOpenAutoFocus:i,onCloseAutoFocus:r,...s}=t,a=g5(q8,n),c=J.useRef(null),l=f0(e,c);return TSe(),K.jsxs(K.Fragment,{children:[K.jsx(gZ,{asChild:!0,loop:!0,trapped:o,onMountAutoFocus:i,onUnmountAutoFocus:r,children:K.jsx(pF,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":ove(a.open),...s,ref:l,onDismiss:()=>a.onOpenChange(!1)})}),K.jsxs(K.Fragment,{children:[K.jsx($4o,{titleId:a.titleId}),K.jsx(eEo,{contentRef:c,descriptionId:a.descriptionId})]})]})}),nve="DialogTitle",d3t=J.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,i=g5(nve,n);return K.jsx(ka.h2,{id:i.titleId,...o,ref:e})});d3t.displayName=nve;var h3t="DialogDescription",_3t=J.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,i=g5(h3t,n);return K.jsx(ka.p,{id:i.descriptionId,...o,ref:e})});_3t.displayName=h3t;var m3t="DialogClose",g3t=J.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,i=g5(m3t,n);return K.jsx(ka.button,{type:"button",...o,ref:e,onClick:Sr(t.onClick,()=>i.onOpenChange(!1))})});g3t.displayName=m3t;function ove(t){return t?"open":"closed"}var p3t="DialogTitleWarning",[q4o,f3t]=I3n(p3t,{contentName:q8,titleName:nve,docsSlug:"dialog"}),$4o=({titleId:t})=>{const e=f3t(p3t),n=`\`${e.contentName}\` requires a \`${e.titleName}\` for the component to be accessible for screen reader users.
|
|
5783
5783
|
|
|
5784
5784
|
If you want to hide the \`${e.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
5785
5785
|
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"main": "dist/index.js",
|
|
4
4
|
"types": "dist/index.d.ts",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"version": "0.0.
|
|
6
|
+
"version": "0.0.1919",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"@tscircuit/capacity-autorouter": "^0.0.583",
|
|
56
56
|
"@tscircuit/checks": "0.0.138",
|
|
57
57
|
"@tscircuit/circuit-json-util": "^0.0.96",
|
|
58
|
-
"@tscircuit/cli": "^0.1.
|
|
58
|
+
"@tscircuit/cli": "^0.1.1530",
|
|
59
59
|
"@tscircuit/copper-pour-solver": "^0.0.29",
|
|
60
60
|
"@tscircuit/core": "^0.0.1346",
|
|
61
61
|
"@tscircuit/eval": "^0.0.946",
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"@tscircuit/miniflex": "^0.0.4",
|
|
71
71
|
"@tscircuit/ngspice-spice-engine": "^0.0.17",
|
|
72
72
|
"@tscircuit/props": "^0.0.551",
|
|
73
|
-
"@tscircuit/runframe": "^0.0.
|
|
73
|
+
"@tscircuit/runframe": "^0.0.2102",
|
|
74
74
|
"@tscircuit/schematic-match-adapt": "^0.0.18",
|
|
75
75
|
"@tscircuit/schematic-trace-solver": "^0.0.71",
|
|
76
76
|
"@tscircuit/simple-3d-svg": "^0.0.41",
|