@tscircuit/runframe 0.0.2348 → 0.0.2349

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.
@@ -650,6 +650,31 @@ var ErrorTabContent = ({
650
650
  )}&body=${encodeURIComponent(body)}`;
651
651
  window.open(issueUrl, "_blank");
652
652
  };
653
+ useEffect(() => {
654
+ if (errorMessage) {
655
+ let errorText = errorMessage;
656
+ if (errorStack) {
657
+ errorText += `
658
+
659
+ ${errorStack}`;
660
+ }
661
+ if (typeof window !== "undefined") {
662
+ window.__TSCIRCUIT_LAST_EXECUTION_ERROR = errorText;
663
+ }
664
+ }
665
+ }, [errorMessage, errorStack]);
666
+ const [expandedErrors, setExpandedErrors] = useState(() => {
667
+ const allIndexes = /* @__PURE__ */ new Set();
668
+ unifiedErrors.forEach((_, i) => allIndexes.add(i));
669
+ return allIndexes;
670
+ });
671
+ const [expandedWarnings, setExpandedWarnings] = useState(() => {
672
+ const allIndexes = /* @__PURE__ */ new Set();
673
+ unifiedWarnings.forEach((_, i) => allIndexes.add(i));
674
+ return allIndexes;
675
+ });
676
+ const [errorsCollapsed, setErrorsCollapsed] = useState(false);
677
+ const [warningsCollapsed, setWarningsCollapsed] = useState(false);
653
678
  if (unifiedErrors.length === 0 && unifiedWarnings.length === 0) {
654
679
  return /* @__PURE__ */ jsxs4("div", { className: "px-2", children: [
655
680
  /* @__PURE__ */ jsx6("div", { className: "rf-mt-4 rf-bg-green-50 rf-rounded-md rf-border rf-border-green-200", children: /* @__PURE__ */ jsxs4("div", { className: "rf-p-4", children: [
@@ -682,31 +707,6 @@ var ErrorTabContent = ({
682
707
  ] })
683
708
  ] });
684
709
  }
685
- useEffect(() => {
686
- if (errorMessage) {
687
- let errorText = errorMessage;
688
- if (errorStack) {
689
- errorText += `
690
-
691
- ${errorStack}`;
692
- }
693
- if (typeof window !== "undefined") {
694
- window.__TSCIRCUIT_LAST_EXECUTION_ERROR = errorText;
695
- }
696
- }
697
- }, [errorMessage, errorStack]);
698
- const [expandedErrors, setExpandedErrors] = useState(() => {
699
- const allIndexes = /* @__PURE__ */ new Set();
700
- unifiedErrors.forEach((_, i) => allIndexes.add(i));
701
- return allIndexes;
702
- });
703
- const [expandedWarnings, setExpandedWarnings] = useState(() => {
704
- const allIndexes = /* @__PURE__ */ new Set();
705
- unifiedWarnings.forEach((_, i) => allIndexes.add(i));
706
- return allIndexes;
707
- });
708
- const [errorsCollapsed, setErrorsCollapsed] = useState(false);
709
- const [warningsCollapsed, setWarningsCollapsed] = useState(false);
710
710
  const toggleError = (index) => {
711
711
  setExpandedErrors((prev) => {
712
712
  const next = new Set(prev);
@@ -2181,7 +2181,7 @@ var usePostHogActivity = (properties) => {
2181
2181
  };
2182
2182
 
2183
2183
  // package.json
2184
- var version = "0.0.2347";
2184
+ var version = "0.0.2348";
2185
2185
  var package_default = {
2186
2186
  name: "@tscircuit/runframe",
2187
2187
  main: "dist/preview.js",
package/dist/preview.js CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  SchematicViewer,
8
8
  useOrderDialog,
9
9
  useOrderDialogCli
10
- } from "./chunk-UDVOZEHU.js";
10
+ } from "./chunk-CJ7IQWXR.js";
11
11
  export {
12
12
  BomTable,
13
13
  CadViewer,
package/dist/runner.js CHANGED
@@ -39,7 +39,7 @@ import {
39
39
  useRunFrameStore,
40
40
  useRunnerStore,
41
41
  useStyles
42
- } from "./chunk-UDVOZEHU.js";
42
+ } from "./chunk-CJ7IQWXR.js";
43
43
 
44
44
  // lib/components/RunFrame/RunFrame.tsx
45
45
  import { createCircuitWebWorker } from "@tscircuit/eval/worker";
@@ -5583,9 +5583,9 @@ try {
5583
5583
  `)},ePt=function(){var t=parseInt(document.body.getAttribute(qR)||"0",10);return isFinite(t)?t:0},Wwo=function(){ee.useEffect(function(){return document.body.setAttribute(qR,(ePt()+1).toString()),function(){var t=ePt()-1;t<=0?document.body.removeAttribute(qR):document.body.setAttribute(qR,t.toString())}},[])},jwo=function(t){var e=t.noRelative,n=t.noImportant,o=t.gapMode,i=o===void 0?"margin":o;Wwo();var r=ee.useMemo(function(){return Vwo(i)},[i]);return ee.createElement(Jwo,{styles:qwo(r,!e,i,n?"":"!important")})},Ewe=!1;if(typeof window<"u")try{var One=Object.defineProperty({},"passive",{get:function(){return Ewe=!0,!0}});window.addEventListener("test",One,One),window.removeEventListener("test",One,One)}catch{Ewe=!1}var WR=Ewe?{passive:!1}:!1,Xwo=function(t){return t.tagName==="TEXTAREA"},tPt=function(t,e){if(!(t instanceof Element))return!1;var n=window.getComputedStyle(t);return n[e]!=="hidden"&&!(n.overflowY===n.overflowX&&!Xwo(t)&&n[e]==="visible")},$wo=function(t){return tPt(t,"overflowY")},Zwo=function(t){return tPt(t,"overflowX")},nPt=function(t,e){var n=e.ownerDocument,o=e;do{typeof ShadowRoot<"u"&&o instanceof ShadowRoot&&(o=o.host);var i=oPt(t,o);if(i){var r=iPt(t,o),A=r[1],s=r[2];if(A>s)return!0}o=o.parentNode}while(o&&o!==n.body);return!1},ePo=function(t){var e=t.scrollTop,n=t.scrollHeight,o=t.clientHeight;return[e,n,o]},tPo=function(t){var e=t.scrollLeft,n=t.scrollWidth,o=t.clientWidth;return[e,n,o]},oPt=function(t,e){return t==="v"?$wo(e):Zwo(e)},iPt=function(t,e){return t==="v"?ePo(e):tPo(e)},nPo=function(t,e){return t==="h"&&e==="rtl"?-1:1},oPo=function(t,e,n,o,i){var r=nPo(t,window.getComputedStyle(e).direction),A=r*o,s=n.target,a=e.contains(s),c=!1,l=A>0,g=0,u=0;do{if(!s)break;var h=iPt(t,s),d=h[0],_=h[1],p=h[2],m=_-p-r*d;(d||m)&&oPt(t,s)&&(g+=m,u+=d);var C=s.parentNode;s=C&&C.nodeType===Node.DOCUMENT_FRAGMENT_NODE?C.host:C}while(!a&&s!==document.body||a&&(e.contains(s)||e===s));return(l&&Math.abs(g)<1||!l&&Math.abs(u)<1)&&(c=!0),c},Kne=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},rPt=function(t){return[t.deltaX,t.deltaY]},APt=function(t){return t&&"current"in t?t.current:t},iPo=function(t,e){return t[0]===e[0]&&t[1]===e[1]},rPo=function(t){return`
5584
5584
  .block-interactivity-`.concat(t,` {pointer-events: none;}
5585
5585
  .allow-interactivity-`).concat(t,` {pointer-events: all;}
5586
- `)},APo=0,jR=[];function sPo(t){var e=ee.useRef([]),n=ee.useRef([0,0]),o=ee.useRef(),i=ee.useState(APo++)[0],r=ee.useState(Zwt)[0],A=ee.useRef(t);ee.useEffect(function(){A.current=t},[t]),ee.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(i));var _=Dwo([t.lockRef.current],(t.shards||[]).map(APt),!0).filter(Boolean);return _.forEach(function(p){return p.classList.add("allow-interactivity-".concat(i))}),function(){document.body.classList.remove("block-interactivity-".concat(i)),_.forEach(function(p){return p.classList.remove("allow-interactivity-".concat(i))})}}},[t.inert,t.lockRef.current,t.shards]);var s=ee.useCallback(function(_,p){if("touches"in _&&_.touches.length===2||_.type==="wheel"&&_.ctrlKey)return!A.current.allowPinchZoom;var m=Kne(_),C=n.current,I="deltaX"in _?_.deltaX:C[0]-m[0],f="deltaY"in _?_.deltaY:C[1]-m[1],y,x=_.target,B=Math.abs(I)>Math.abs(f)?"h":"v";if("touches"in _&&B==="h"&&x.type==="range")return!1;var S=window.getSelection(),D=S&&S.anchorNode,w=D?D===x||D.contains(x):!1;if(w)return!1;var F=nPt(B,x);if(!F)return!0;if(F?y=B:(y=B==="v"?"h":"v",F=nPt(B,x)),!F)return!1;if(!o.current&&"changedTouches"in _&&(I||f)&&(o.current=y),!y)return!0;var R=o.current||y;return oPo(R,p,_,R==="h"?I:f)},[]),a=ee.useCallback(function(_){var p=_;if(!(!jR.length||jR[jR.length-1]!==r)){var m="deltaY"in p?rPt(p):Kne(p),C=e.current.filter(function(y){return y.name===p.type&&(y.target===p.target||p.target===y.shadowParent)&&iPo(y.delta,m)})[0];if(C&&C.should){p.cancelable&&p.preventDefault();return}if(!C){var I=(A.current.shards||[]).map(APt).filter(Boolean).filter(function(y){return y.contains(p.target)}),f=I.length>0?s(p,I[0]):!A.current.noIsolation;f&&p.cancelable&&p.preventDefault()}}},[]),c=ee.useCallback(function(_,p,m,C){var I={name:_,delta:p,target:m,should:C,shadowParent:aPo(m)};e.current.push(I),setTimeout(function(){e.current=e.current.filter(function(f){return f!==I})},1)},[]),l=ee.useCallback(function(_){n.current=Kne(_),o.current=void 0},[]),g=ee.useCallback(function(_){c(_.type,rPt(_),_.target,s(_,t.lockRef.current))},[]),u=ee.useCallback(function(_){c(_.type,Kne(_),_.target,s(_,t.lockRef.current))},[]);ee.useEffect(function(){return jR.push(r),t.setCallbacks({onScrollCapture:g,onWheelCapture:g,onTouchMoveCapture:u}),document.addEventListener("wheel",a,WR),document.addEventListener("touchmove",a,WR),document.addEventListener("touchstart",l,WR),function(){jR=jR.filter(function(_){return _!==r}),document.removeEventListener("wheel",a,WR),document.removeEventListener("touchmove",a,WR),document.removeEventListener("touchstart",l,WR)}},[]);var h=t.removeScrollBar,d=t.inert;return ee.createElement(ee.Fragment,null,d?ee.createElement(r,{styles:rPo(i)}):null,h?ee.createElement(jwo,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function aPo(t){for(var e=null;t!==null;)t instanceof ShadowRoot&&(e=t.host,t=t.host),t=t.parentNode;return e}const cPo=Fwo($wt,sPo);var xwe=ee.forwardRef(function(t,e){return ee.createElement(Gne,lS({},t,{ref:e,sideCar:cPo}))});xwe.classNames=Gne.classNames;var lPo=Object.defineProperty,mc=(t,e)=>lPo(t,"name",{value:e,configurable:!0}),Bwe=["Enter"," "],gPo=["ArrowDown","PageUp","Home"],sPt=["ArrowUp","PageDown","End"],uPo=[...gPo,...sPt],dPo={ltr:[...Bwe,"ArrowRight"],rtl:[...Bwe,"ArrowLeft"]},hPo={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Une="Menu",[rK,_Po,mPo]=Are(Une),[Pv,aPt]=pE(Une,[mPo,Rne,KU]),Yne=Rne(),cPt=KU(),[lPt,JM]=Pv(Une),[pPo,AK]=Pv(Une),IPo=mc(t=>{const{__scopeMenu:e,open:n=!1,children:o,dir:i,onOpenChange:r,modal:A=!0}=t,s=Yne(e),[a,c]=ee.useState(null),l=ee.useRef(!1),g=HB(r),u=GU(i);return ee.useEffect(()=>{const h=mc(()=>{l.current=!0,document.addEventListener("pointerdown",d,{capture:!0,once:!0}),document.addEventListener("pointermove",d,{capture:!0,once:!0})},"handleKeyDown"),d=mc(()=>l.current=!1,"handlePointer");return document.addEventListener("keydown",h,{capture:!0}),()=>{document.removeEventListener("keydown",h,{capture:!0}),document.removeEventListener("pointerdown",d,{capture:!0}),document.removeEventListener("pointermove",d,{capture:!0})}},[]),ee.useEffect(()=>{if(!n)return;const h=mc(()=>g(!1),"handleBlur");return window.addEventListener("blur",h),()=>window.removeEventListener("blur",h)},[n,g]),q.jsx(pwe,{...s,children:q.jsx(lPt,{scope:e,open:n,onOpenChange:g,content:a,onContentChange:c,children:q.jsx(pPo,{scope:e,onClose:ee.useCallback(()=>g(!1),[g]),isUsingKeyboardRef:l,dir:u,modal:A,children:o})})})},"Menu"),gPt=ee.forwardRef(mc(function(e,n){const{__scopeMenu:o,...i}=e,r=Yne(o);return q.jsx(Ywt,{...r,...i,ref:n})},"MenuAnchor")),uPt="MenuPortal",[CPo,dPt]=Pv(uPt,{forceMount:void 0}),fPo=mc(t=>{const{__scopeMenu:e,forceMount:n,children:o,container:i}=t,r=JM(uPt,e);return q.jsx(CPo,{scope:e,forceMount:n,children:q.jsx(GB,{present:n||r.open,children:q.jsx(Vwt,{asChild:!0,container:i,children:o})})})},"MenuPortal"),_B="MenuContent",[yPo,Qwe]=Pv(_B),EPo=ee.forwardRef(mc(function(e,n){const o=dPt(_B,e.__scopeMenu),{forceMount:i=o.forceMount,...r}=e,A=JM(_B,e.__scopeMenu),s=AK(_B,e.__scopeMenu);return q.jsx(rK.Provider,{scope:e.__scopeMenu,children:q.jsx(GB,{present:i||A.open,children:q.jsx(rK.Slot,{scope:e.__scopeMenu,children:s.modal?q.jsx(xPo,{...r,ref:n}):q.jsx(BPo,{...r,ref:n})})})})},"MenuContent")),xPo=ee.forwardRef(mc(function(e,n){const o=JM(_B,e.__scopeMenu),i=ee.useRef(null),r=rg(n,i);return ee.useEffect(()=>{const A=i.current;if(A)return qwt(A)},[]),q.jsx(Swe,{...e,ref:r,trapFocus:o.open,disableOutsidePointerEvents:o.open,disableOutsideScroll:!0,onFocusOutside:zr(e.onFocusOutside,A=>A.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>o.onOpenChange(!1)})},"MenuRootContentModal")),BPo=ee.forwardRef(mc(function(e,n){const o=JM(_B,e.__scopeMenu);return q.jsx(Swe,{...e,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>o.onOpenChange(!1)})},"MenuRootContentNonModal")),QPo=kS("MenuContent.ScrollLock"),Swe=ee.forwardRef(mc(function(e,n){const{__scopeMenu:o,loop:i=!1,trapFocus:r,onOpenAutoFocus:A,onCloseAutoFocus:s,disableOutsidePointerEvents:a,onEntryFocus:c,onEscapeKeyDown:l,onPointerDownOutside:g,onFocusOutside:u,onInteractOutside:h,onDismiss:d,disableOutsideScroll:_,...p}=e,m=JM(_B,o),C=AK(_B,o),I=Yne(o),f=cPt(o),y=_Po(o),[x,B]=ee.useState(null),S=ee.useRef(null),D=rg(n,S,m.onContentChange),w=ee.useRef(0),F=ee.useRef(""),R=ee.useRef(0),H=ee.useRef(null),G=ee.useRef("right"),K=ee.useRef(0),J=_?xwe:ee.Fragment,W=_?{as:QPo,allowPinchZoom:!0}:void 0,X=mc(se=>{const Z=F.current+se,ie=y().filter(we=>!we.disabled),ae=document.activeElement,ce=ie.find(we=>we.ref.current===ae)?.textValue,ge=ie.map(we=>we.textValue),xe=EPt(ge,Z,ce),Be=ie.find(we=>we.textValue===xe)?.ref.current;mc((function we(_e){F.current=_e,window.clearTimeout(w.current),_e!==""&&(w.current=window.setTimeout(()=>we(""),1e3))}),"updateSearch")(Z),Be&&setTimeout(()=>Be.focus())},"handleTypeaheadSearch");ee.useEffect(()=>()=>window.clearTimeout(w.current),[]),Ene();const re=ee.useCallback(se=>G.current===H.current?.side&&BPt(se,H.current?.area),[]);return q.jsx(yPo,{scope:o,searchRef:F,onItemEnter:ee.useCallback(se=>{re(se)&&se.preventDefault()},[re]),onItemLeave:ee.useCallback(se=>{re(se)||(S.current?.focus(),B(null))},[re]),onTriggerLeave:ee.useCallback(se=>{re(se)&&se.preventDefault()},[re]),pointerGraceTimerRef:R,onPointerGraceIntentChange:ee.useCallback(se=>{H.current=se},[]),children:q.jsx(J,{...W,children:q.jsx(lwt,{asChild:!0,trapped:r,onMountAutoFocus:zr(A,se=>{se.preventDefault(),S.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:s,children:q.jsx(WMe,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:l,onPointerDownOutside:g,onFocusOutside:u,onInteractOutside:h,onDismiss:d,children:q.jsx(u8e,{asChild:!0,...f,dir:C.dir,orientation:"vertical",loop:i,currentTabStopId:x,onCurrentTabStopIdChange:B,onEntryFocus:zr(c,se=>{C.isUsingKeyboardRef.current||se.preventDefault()}),preventScrollOnEntryFocus:!0,children:q.jsx(zwt,{role:"menu","aria-orientation":"vertical","data-state":Mwe(m.open),"data-radix-menu-content":"",dir:C.dir,...I,...p,ref:D,style:{outline:"none",...p.style},onKeyDown:zr(p.onKeyDown,se=>{const ie=se.target.closest("[data-radix-menu-content]")===se.currentTarget,ae=se.ctrlKey||se.altKey||se.metaKey,ce=se.key.length===1;ie&&(se.key==="Tab"&&se.preventDefault(),!ae&&ce&&X(se.key));const ge=S.current;if(se.target!==ge||!uPo.includes(se.key))return;se.preventDefault();const Be=y().filter(we=>!we.disabled).map(we=>we.ref.current);sPt.includes(se.key)&&Be.reverse(),fPt(Be)}),onBlur:zr(e.onBlur,se=>{se.currentTarget.contains(se.target)||(window.clearTimeout(w.current),F.current="")}),onPointerMove:zr(e.onPointerMove,XR(se=>{const Z=se.target,ie=K.current!==se.clientX;if(se.currentTarget.contains(Z)&&ie){const ae=se.clientX>K.current?"right":"left";G.current=ae,K.current=se.clientX}}))})})})})})})},"MenuContentImpl")),SPo=ee.forwardRef(mc(function(e,n){const{__scopeMenu:o,...i}=e;return q.jsx(o0.div,{...i,ref:n})},"MenuLabel")),bwe="MenuItem",hPt="menu.itemSelect",Dwe=ee.forwardRef(mc(function(e,n){const{disabled:o=!1,onSelect:i,...r}=e,A=ee.useRef(null),s=AK(bwe,e.__scopeMenu),a=Qwe(bwe,e.__scopeMenu),c=rg(n,A),l=ee.useRef(!1),g=mc(()=>{const u=A.current;if(!o&&u){const h=new CustomEvent(hPt,{bubbles:!0,cancelable:!0});u.addEventListener(hPt,d=>i?.(d),{once:!0}),lre(u,h),h.defaultPrevented?l.current=!1:s.onClose()}},"handleSelect");return q.jsx(_Pt,{...r,ref:c,disabled:o,onClick:zr(e.onClick,g),onPointerDown:u=>{e.onPointerDown?.(u),l.current=!0},onPointerUp:zr(e.onPointerUp,u=>{l.current||u.currentTarget?.click()}),onKeyDown:zr(e.onKeyDown,u=>{o||u.target!==u.currentTarget||a.searchRef.current!==""&&u.key===" "||Bwe.includes(u.key)&&(u.currentTarget.click(),u.preventDefault())})})},"MenuItem")),_Pt=ee.forwardRef(mc(function(e,n){const{__scopeMenu:o,disabled:i=!1,textValue:r,...A}=e,s=Qwe(bwe,o),a=cPt(o),c=ee.useRef(null),l=rg(n,c),[g,u]=ee.useState(!1),[h,d]=ee.useState("");return ee.useEffect(()=>{const _=c.current;_&&d((_.textContent??"").trim())},[A.children]),q.jsx(rK.ItemSlot,{scope:o,disabled:i,textValue:r??h,children:q.jsx(d8e,{asChild:!0,...a,focusable:!i,children:q.jsx(o0.div,{role:"menuitem","data-highlighted":g?"":void 0,"aria-disabled":i||void 0,"data-disabled":i?"":void 0,...A,ref:l,onPointerMove:zr(e.onPointerMove,XR(_=>{i?s.onItemLeave(_):(s.onItemEnter(_),_.defaultPrevented||_.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:zr(e.onPointerLeave,XR(_=>s.onItemLeave(_))),onFocus:zr(e.onFocus,()=>u(!0)),onBlur:zr(e.onBlur,()=>u(!1))})})})},"MenuItemImpl")),bPo=ee.forwardRef(mc(function(e,n){const{checked:o=!1,onCheckedChange:i,...r}=e;return q.jsx(pPt,{scope:e.__scopeMenu,checked:o,children:q.jsx(Dwe,{role:"menuitemcheckbox","aria-checked":sK(o)?"mixed":o,...r,ref:n,"data-state":Vne(o),onSelect:zr(r.onSelect,()=>i?.(sK(o)?!0:!o),{checkForDefaultPrevented:!1})})})},"MenuCheckboxItem")),DPo="MenuRadioGroup",[szo,MPo]=Pv(DPo,{value:void 0,onValueChange:mc(()=>{},"onValueChange")}),wPo="MenuRadioItem",PPo=ee.forwardRef(mc(function(e,n){const{value:o,...i}=e,r=MPo(wPo,e.__scopeMenu),A=o===r.value;return q.jsx(pPt,{scope:e.__scopeMenu,checked:A,children:q.jsx(Dwe,{role:"menuitemradio","aria-checked":A,...i,ref:n,"data-state":Vne(A),onSelect:zr(i.onSelect,()=>r.onValueChange?.(o),{checkForDefaultPrevented:!1})})})},"MenuRadioItem")),mPt="MenuItemIndicator",[pPt,vPo]=Pv(mPt,{checked:!1}),NPo=ee.forwardRef(mc(function(e,n){const{__scopeMenu:o,forceMount:i,...r}=e,A=vPo(mPt,o);return q.jsx(GB,{present:i||sK(A.checked)||A.checked===!0,children:q.jsx(o0.span,{...r,ref:n,"data-state":Vne(A.checked)})})},"MenuItemIndicator")),RPo=ee.forwardRef(mc(function(e,n){const{__scopeMenu:o,...i}=e;return q.jsx(o0.div,{role:"separator","aria-orientation":"horizontal",...i,ref:n})},"MenuSeparator")),IPt="MenuSub",[TPo,CPt]=Pv(IPt),kPo=mc(t=>{const{__scopeMenu:e,children:n,open:o=!1,onOpenChange:i}=t,r=JM(IPt,e),A=Yne(e),[s,a]=ee.useState(null),[c,l]=ee.useState(null),g=HB(i);return ee.useEffect(()=>(r.open===!1&&g(!1),()=>g(!1)),[r.open,g]),q.jsx(pwe,{...A,children:q.jsx(lPt,{scope:e,open:o,onOpenChange:g,content:c,onContentChange:l,children:q.jsx(TPo,{scope:e,contentId:Ex(),triggerId:Ex(),trigger:s,onTriggerChange:a,children:n})})})},"MenuSub"),zne="MenuSubTrigger",FPo=ee.forwardRef(mc(function(e,n){const o=JM(zne,e.__scopeMenu),i=AK(zne,e.__scopeMenu),r=CPt(zne,e.__scopeMenu),A=Qwe(zne,e.__scopeMenu),s=ee.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:c}=A,l={__scopeMenu:e.__scopeMenu},g=ee.useCallback(()=>{s.current&&window.clearTimeout(s.current),s.current=null},[]);ee.useEffect(()=>g,[g]),ee.useEffect(()=>{const h=a.current;return()=>{window.clearTimeout(h),c(null)}},[a,c]);const u=rg(n,r.onTriggerChange);return q.jsx(gPt,{asChild:!0,...l,children:q.jsx(_Pt,{id:r.triggerId,"aria-haspopup":"menu","aria-expanded":o.open,"aria-controls":o.open?r.contentId:void 0,"data-state":Mwe(o.open),...e,ref:u,onClick:h=>{e.onClick?.(h),!(e.disabled||h.defaultPrevented)&&(h.currentTarget.focus(),o.open||o.onOpenChange(!0))},onPointerMove:zr(e.onPointerMove,XR(h=>{A.onItemEnter(h),!h.defaultPrevented&&!e.disabled&&!o.open&&!s.current&&(A.onPointerGraceIntentChange(null),s.current=window.setTimeout(()=>{o.onOpenChange(!0),g()},100))})),onPointerLeave:zr(e.onPointerLeave,XR(h=>{g();const d=o.content?.getBoundingClientRect();if(d){const _=o.content?.dataset.side,p=_==="right",m=p?-5:5,C=d[p?"left":"right"],I=d[p?"right":"left"];A.onPointerGraceIntentChange({area:[{x:h.clientX+m,y:h.clientY},{x:C,y:d.top},{x:I,y:d.top},{x:I,y:d.bottom},{x:C,y:d.bottom}],side:_}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>A.onPointerGraceIntentChange(null),300)}else{if(A.onTriggerLeave(h),h.defaultPrevented)return;A.onPointerGraceIntentChange(null)}})),onKeyDown:zr(e.onKeyDown,h=>{e.disabled||h.target!==h.currentTarget||A.searchRef.current!==""&&h.key===" "||dPo[i.dir].includes(h.key)&&(o.onOpenChange(!0),o.content?.focus(),h.preventDefault())})})})},"MenuSubTrigger")),LPo="MenuSubContent",HPo=ee.forwardRef(mc(function(e,n){const o=dPt(_B,e.__scopeMenu),{forceMount:i=o.forceMount,align:r="start",...A}=e,s=JM(_B,e.__scopeMenu),a=AK(_B,e.__scopeMenu),c=CPt(LPo,e.__scopeMenu),l=ee.useRef(null),g=rg(n,l);return q.jsx(rK.Provider,{scope:e.__scopeMenu,children:q.jsx(GB,{present:i||s.open,children:q.jsx(rK.Slot,{scope:e.__scopeMenu,children:q.jsx(Swe,{id:c.contentId,"aria-labelledby":c.triggerId,...A,ref:g,align:r,side:a.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:u=>{a.isUsingKeyboardRef.current&&l.current?.focus(),u.preventDefault()},onCloseAutoFocus:u=>u.preventDefault(),onFocusOutside:zr(e.onFocusOutside,u=>{u.target!==c.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:zr(e.onEscapeKeyDown,u=>{a.onClose(),u.preventDefault()}),onKeyDown:zr(e.onKeyDown,u=>{const h=u.currentTarget.contains(u.target),d=hPo[a.dir].includes(u.key);h&&d&&(s.onOpenChange(!1),c.trigger?.focus(),u.preventDefault())})})})})})},"MenuSubContent"));function Mwe(t){return t?"open":"closed"}mc(Mwe,"getOpenState");function sK(t){return t==="indeterminate"}mc(sK,"isIndeterminate");function Vne(t){return sK(t)?"indeterminate":t?"checked":"unchecked"}mc(Vne,"getCheckedState");function fPt(t){const e=document.activeElement;for(const n of t)if(n===e||(n.focus(),document.activeElement!==e))return}mc(fPt,"focusFirst");function yPt(t,e){return t.map((n,o)=>t[(e+o)%t.length])}mc(yPt,"wrapArray");function EPt(t,e,n){const i=e.length>1&&Array.from(e).every(c=>c===e[0])?e[0]:e,r=n?t.indexOf(n):-1;let A=yPt(t,Math.max(r,0));i.length===1&&(A=A.filter(c=>c!==n));const a=A.find(c=>c.toLowerCase().startsWith(i.toLowerCase()));return a!==n?a:void 0}mc(EPt,"getNextMatch");function xPt(t,e){const{x:n,y:o}=t;let i=!1;for(let r=0,A=e.length-1;r<e.length;A=r++){const s=e[r],a=e[A],c=s.x,l=s.y,g=a.x,u=a.y;l>o!=u>o&&n<(g-c)*(o-l)/(u-l)+c&&(i=!i)}return i}mc(xPt,"isPointInPolygon");function BPt(t,e){if(!e)return!1;const n={x:t.clientX,y:t.clientY};return xPt(n,e)}mc(BPt,"isPointerInGraceArea");function XR(t){return e=>e.pointerType==="mouse"?t(e):void 0}mc(XR,"whenMouse");var GPo=IPo,OPo=gPt,KPo=fPo,UPo=EPo,YPo=SPo,zPo=Dwe,VPo=bPo,JPo=PPo,qPo=NPo,WPo=RPo,jPo=kPo,XPo=FPo,$Po=HPo,ZPo=Object.defineProperty,x2=(t,e)=>ZPo(t,"name",{value:e,configurable:!0}),wwe="DropdownMenu",[e3o,azo]=pE(wwe,[aPt]),B2=aPt(),[t3o,QPt]=e3o(wwe),n3o=x2(t=>{const{__scopeDropdownMenu:e,children:n,dir:o,open:i,defaultOpen:r,onOpenChange:A,modal:s=!0}=t,a=B2(e),c=ee.useRef(null),[l,g]=t4({prop:i,defaultProp:r??!1,onChange:A,caller:wwe});return q.jsx(t3o,{scope:e,triggerId:Ex(),triggerRef:c,contentId:Ex(),open:l,onOpenChange:g,onOpenToggle:ee.useCallback(()=>g(u=>!u),[g]),modal:s,children:q.jsx(GPo,{...a,open:l,onOpenChange:g,dir:o,modal:s,children:n})})},"DropdownMenu"),o3o="DropdownMenuTrigger",i3o=ee.forwardRef(x2(function(e,n){const{__scopeDropdownMenu:o,disabled:i=!1,...r}=e,A=QPt(o3o,o),s=B2(o),a=rg(n,A.triggerRef);return q.jsx(OPo,{asChild:!0,...s,children:q.jsx(o0.button,{type:"button",id:A.triggerId,"aria-haspopup":"menu","aria-expanded":A.open,"aria-controls":A.open?A.contentId:void 0,"data-state":A.open?"open":"closed","data-disabled":i?"":void 0,disabled:i,...r,ref:a,onPointerDown:zr(e.onPointerDown,c=>{!i&&c.button===0&&c.ctrlKey===!1&&(A.onOpenToggle(),A.open||c.preventDefault())}),onKeyDown:zr(e.onKeyDown,c=>{i||(["Enter"," "].includes(c.key)&&A.onOpenToggle(),c.key==="ArrowDown"&&A.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(c.key)&&c.preventDefault())})})})},"DropdownMenuTrigger")),r3o=x2(t=>{const{__scopeDropdownMenu:e,...n}=t,o=B2(e);return q.jsx(KPo,{...o,...n})},"DropdownMenuPortal"),A3o="DropdownMenuContent",s3o=ee.forwardRef(x2(function(e,n){const{__scopeDropdownMenu:o,...i}=e,r=QPt(A3o,o),A=B2(o),s=ee.useRef(!1);return q.jsx(UPo,{id:r.contentId,"aria-labelledby":r.triggerId,...A,...i,ref:n,onCloseAutoFocus:zr(e.onCloseAutoFocus,a=>{s.current||r.triggerRef.current?.focus(),s.current=!1,a.preventDefault()}),onInteractOutside:zr(e.onInteractOutside,a=>{const c=a.detail.originalEvent,l=c.button===0&&c.ctrlKey===!0,g=c.button===2||l;(!r.modal||g)&&(s.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})},"DropdownMenuContent")),a3o=ee.forwardRef(x2(function(e,n){const{__scopeDropdownMenu:o,...i}=e,r=B2(o);return q.jsx(YPo,{...r,...i,ref:n})},"DropdownMenuLabel")),c3o=ee.forwardRef(x2(function(e,n){const{__scopeDropdownMenu:o,...i}=e,r=B2(o);return q.jsx(zPo,{...r,...i,ref:n})},"DropdownMenuItem")),l3o=ee.forwardRef(x2(function(e,n){const{__scopeDropdownMenu:o,...i}=e,r=B2(o);return q.jsx(VPo,{...r,...i,ref:n})},"DropdownMenuCheckboxItem")),g3o=ee.forwardRef(x2(function(e,n){const{__scopeDropdownMenu:o,...i}=e,r=B2(o);return q.jsx(JPo,{...r,...i,ref:n})},"DropdownMenuRadioItem")),u3o=ee.forwardRef(x2(function(e,n){const{__scopeDropdownMenu:o,...i}=e,r=B2(o);return q.jsx(qPo,{...r,...i,ref:n})},"DropdownMenuItemIndicator")),d3o=ee.forwardRef(x2(function(e,n){const{__scopeDropdownMenu:o,...i}=e,r=B2(o);return q.jsx(WPo,{...r,...i,ref:n})},"DropdownMenuSeparator")),h3o=x2(t=>{const{__scopeDropdownMenu:e,children:n,open:o,onOpenChange:i,defaultOpen:r}=t,A=B2(e),[s,a]=t4({prop:o,defaultProp:r??!1,onChange:i,caller:"DropdownMenuSub"});return q.jsx(jPo,{...A,open:s,onOpenChange:a,children:n})},"DropdownMenuSub"),_3o=ee.forwardRef(x2(function(e,n){const{__scopeDropdownMenu:o,...i}=e,r=B2(o);return q.jsx(XPo,{...r,...i,ref:n})},"DropdownMenuSubTrigger")),m3o=ee.forwardRef(x2(function(e,n){const{__scopeDropdownMenu:o,...i}=e,r=B2(o);return q.jsx($Po,{...r,...i,ref:n,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})},"DropdownMenuSubContent")),Jne=n3o,qne=i3o,aK=r3o,cK=s3o,SPt=a3o,$R=c3o,bPt=l3o,DPt=g3o,MPt=u3o,Pwe=d3o,p3o=h3o,wPt=_3o,PPt=m3o;const Wne=Jne,jne=qne,lK=aK,gK=p3o,ZR=ee.forwardRef(({className:t,inset:e,children:n,...o},i)=>q.jsxs(wPt,{ref:i,className:sA("rf-flex rf-cursor-default rf-gap-2 rf-select-none rf-items-center rf-rounded-sm rf-px-2 rf-py-1.5 rf-text-sm rf-outline-none focus:rf-bg-zinc-100 data-[state=open]:rf-bg-zinc-100 [&_svg]:rf-pointer-events-none [&_svg]:rf-size-4 [&_svg]:rf-shrink-0 dark:focus:rf-bg-zinc-800 dark:data-[state=open]:rf-bg-zinc-800",e&&"rf-pl-8",t),...o,children:[n,q.jsx(nK,{className:"rf-ml-auto"})]}));ZR.displayName=wPt.displayName;const eT=ee.forwardRef(({className:t,...e},n)=>q.jsx(PPt,{ref:n,className:sA("rf-z-50 rf-min-w-[8rem] rf-overflow-hidden rf-rounded-md rf-border rf-border-zinc-200 rf-bg-white rf-p-1 rf-text-zinc-950 rf-shadow-lg data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0 data-[state=closed]:rf-zoom-out-95 data-[state=open]:rf-zoom-in-95 data-[side=bottom]:rf-slide-in-from-top-2 data-[side=left]:rf-slide-in-from-right-2 data-[side=right]:rf-slide-in-from-left-2 data-[side=top]:rf-slide-in-from-bottom-2 dark:rf-border-zinc-800 dark:rf-bg-zinc-950 dark:rf-text-zinc-50",t),...e}));eT.displayName=PPt.displayName;const uK=ee.forwardRef(({className:t,sideOffset:e=4,...n},o)=>q.jsx(aK,{children:q.jsx(cK,{ref:o,sideOffset:e,className:sA("rf-z-50 rf-min-w-[8rem] rf-overflow-hidden rf-rounded-md rf-border rf-border-zinc-200 rf-bg-white rf-p-1 rf-text-zinc-950 rf-shadow-md dark:rf-border-zinc-800 dark:rf-bg-zinc-950 dark:rf-text-zinc-50","data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0 data-[state=closed]:rf-zoom-out-95 data-[state=open]:rf-zoom-in-95 data-[side=bottom]:rf-slide-in-from-top-2 data-[side=left]:rf-slide-in-from-right-2 data-[side=right]:rf-slide-in-from-left-2 data-[side=top]:rf-slide-in-from-bottom-2",t),...n})}));uK.displayName=cK.displayName;const Qh=ee.forwardRef(({className:t,inset:e,...n},o)=>q.jsx($R,{ref:o,className:sA("rf-relative rf-flex rf-cursor-default rf-select-none rf-items-center rf-gap-2 rf-rounded-sm rf-px-2 rf-py-1.5 rf-text-sm rf-outline-none rf-transition-colors focus:rf-bg-zinc-100 focus:rf-text-zinc-900 data-[disabled]:rf-pointer-events-none data-[disabled]:rf-opacity-50 [&>svg]:rf-size-4 [&>svg]:rf-shrink-0 dark:focus:rf-bg-zinc-800 dark:focus:rf-text-zinc-50",e&&"rf-pl-8",t),...n}));Qh.displayName=$R.displayName;const I3o=ee.forwardRef(({className:t,children:e,checked:n,...o},i)=>q.jsxs(bPt,{ref:i,className:sA("rf-relative rf-flex rf-cursor-default rf-select-none rf-items-center rf-rounded-sm rf-py-1.5 rf-pl-8 rf-pr-2 rf-text-sm rf-outline-none rf-transition-colors focus:rf-bg-zinc-100 focus:rf-text-zinc-900 data-[disabled]:rf-pointer-events-none data-[disabled]:rf-opacity-50 dark:focus:rf-bg-zinc-800 dark:focus:rf-text-zinc-50",t),checked:n,...o,children:[q.jsx("span",{className:"rf-absolute rf-left-2 rf-flex rf-h-3.5 rf-w-3.5 rf-items-center rf-justify-center",children:q.jsx(MPt,{children:q.jsx(VMe,{className:"rf-h-4 rf-w-4"})})}),e]}));I3o.displayName=bPt.displayName;const C3o=ee.forwardRef(({className:t,children:e,...n},o)=>q.jsxs(DPt,{ref:o,className:sA("rf-relative rf-flex rf-cursor-default rf-select-none rf-items-center rf-rounded-sm rf-py-1.5 rf-pl-8 rf-pr-2 rf-text-sm rf-outline-none rf-transition-colors focus:rf-bg-zinc-100 focus:rf-text-zinc-900 data-[disabled]:rf-pointer-events-none data-[disabled]:rf-opacity-50 dark:focus:rf-bg-zinc-800 dark:focus:rf-text-zinc-50",t),...n,children:[q.jsx("span",{className:"rf-absolute rf-left-2 rf-flex rf-h-3.5 rf-w-3.5 rf-items-center rf-justify-center",children:q.jsx(MPt,{children:q.jsx(nwt,{className:"rf-h-2 rf-w-2 rf-fill-current"})})}),e]}));C3o.displayName=DPt.displayName;const f3o=ee.forwardRef(({className:t,inset:e,...n},o)=>q.jsx(SPt,{ref:o,className:sA("rf-px-2 rf-py-1.5 rf-text-sm rf-font-semibold",e&&"rf-pl-8",t),...n}));f3o.displayName=SPt.displayName;const vPt=ee.forwardRef(({className:t,...e},n)=>q.jsx(Pwe,{ref:n,className:sA("rf--mx-1 rf-my-1 rf-h-px rf-bg-zinc-100 dark:rf-bg-zinc-800",t),...e}));vPt.displayName=Pwe.displayName;const NPt=({autoroutingLog:t,onReportAutoroutingLog:e})=>q.jsx(q.Fragment,{children:Object.keys(t??{}).length>0&&q.jsxs(Wne,{children:[q.jsx(jne,{asChild:!0,children:q.jsxs(_c,{variant:"outline",children:[q.jsx(kDo,{className:"rf-w-4 rf-h-4 rf-mr-2"}),"Open Autorouting Log"]})}),q.jsx(uK,{className:"rf-w-96",children:Object.entries(t??{}).map(([n,{simpleRouteJson:o}])=>q.jsxs(Qh,{className:"rf-flex rf-justify-between rf-items-center",children:[q.jsx("span",{className:"rf-truncate rf-text-xs rf-mr-2",children:n}),q.jsxs("div",{className:"rf-flex rf-gap-2",children:[q.jsxs(_c,{variant:"outline",size:"sm",onClick:i=>{i.stopPropagation();const r=new Blob([JSON.stringify(o,null,2)],{type:"application/json"}),A=URL.createObjectURL(r),s=document.createElement("a");s.href=A,s.download=`${n}-autorouting.json`,s.click(),URL.revokeObjectURL(A)},children:[q.jsx(JMe,{className:"rf-w-3 rf-h-3"}),"Download"]}),e&&q.jsxs(_c,{variant:"outline",size:"sm",onClick:i=>{i.stopPropagation(),e&&e(n,{simpleRouteJson:o})},children:[q.jsx(jDo,{className:"rf-w-3 rf-h-3"}),"Report Bug"]})]})]},n))})]})}),y3o=({code:t,fsMap:e,autoroutingLog:n,circuitJsonErrors:o,circuitJsonWarnings:i,onReportAutoroutingLog:r,errorMessage:A,errorStack:s,circuitJson:a,evalVersion:c})=>{const l=ee.useMemo(()=>{const D=[];if(A&&D.push({type:"Execution Error",message:A,stack:s||void 0,source:"execution"}),o&&o.length>0)for(const w of o)D.push({type:w.type||"Circuit JSON Error",message:w.message||"No error message available",stack:w.stack||"",source:"circuitJson"});return D},[A,s,o]),g=ee.useMemo(()=>!a||!Array.isArray(a)?void 0:a.find(w=>w.type==="source_project_metadata")?.software_used_string,[a]),u=ee.useMemo(()=>{const D=[];if(i&&i.length>0)for(const w of i)D.push({type:w.type||"Circuit JSON Warning",message:w.message||"No warning message available",stack:w.stack||"",source:"circuitJson"});return D},[i]),h=()=>{if(e)try{return DKt(e instanceof Map?Object.fromEntries(e.entries()):e)}catch{}return eMo(t??"")},d=(D,w)=>{const F=`https://github.com/tscircuit/tscircuit.com/issues/new?title=${encodeURIComponent(D)}&body=${encodeURIComponent(w)}`;window.open(F,"_blank")};if(l.length===0&&u.length===0)return q.jsxs("div",{className:"px-2",children:[q.jsx("div",{className:"rf-mt-4 rf-bg-green-50 rf-rounded-md rf-border rf-border-green-200",children:q.jsxs("div",{className:"rf-p-4",children:[q.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-green-800 rf-mb-3",children:"No errors or warnings!"}),q.jsx("p",{className:"rf-text-sm rf-text-green-700",children:"Your code is running without any errors or warnings."})]})}),q.jsxs("div",{className:"rf-flex rf-gap-2 rf-mt-4 rf-justify-end",children:[q.jsx(NPt,{autoroutingLog:n,onReportAutoroutingLog:r}),q.jsxs(_c,{variant:"outline",className:"rf-p-1",onClick:()=>{const D=h();d("Issue Report",`[Package code to reproduce](${D})`)},children:[q.jsx(zMe,{className:"rf-w-4 rf-h-4"}),"Report Issue"]})]})]});ee.useEffect(()=>{if(A){let D=A;s&&(D+=`
5586
+ `)},APo=0,jR=[];function sPo(t){var e=ee.useRef([]),n=ee.useRef([0,0]),o=ee.useRef(),i=ee.useState(APo++)[0],r=ee.useState(Zwt)[0],A=ee.useRef(t);ee.useEffect(function(){A.current=t},[t]),ee.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(i));var _=Dwo([t.lockRef.current],(t.shards||[]).map(APt),!0).filter(Boolean);return _.forEach(function(p){return p.classList.add("allow-interactivity-".concat(i))}),function(){document.body.classList.remove("block-interactivity-".concat(i)),_.forEach(function(p){return p.classList.remove("allow-interactivity-".concat(i))})}}},[t.inert,t.lockRef.current,t.shards]);var s=ee.useCallback(function(_,p){if("touches"in _&&_.touches.length===2||_.type==="wheel"&&_.ctrlKey)return!A.current.allowPinchZoom;var m=Kne(_),C=n.current,I="deltaX"in _?_.deltaX:C[0]-m[0],f="deltaY"in _?_.deltaY:C[1]-m[1],y,x=_.target,B=Math.abs(I)>Math.abs(f)?"h":"v";if("touches"in _&&B==="h"&&x.type==="range")return!1;var S=window.getSelection(),D=S&&S.anchorNode,w=D?D===x||D.contains(x):!1;if(w)return!1;var F=nPt(B,x);if(!F)return!0;if(F?y=B:(y=B==="v"?"h":"v",F=nPt(B,x)),!F)return!1;if(!o.current&&"changedTouches"in _&&(I||f)&&(o.current=y),!y)return!0;var R=o.current||y;return oPo(R,p,_,R==="h"?I:f)},[]),a=ee.useCallback(function(_){var p=_;if(!(!jR.length||jR[jR.length-1]!==r)){var m="deltaY"in p?rPt(p):Kne(p),C=e.current.filter(function(y){return y.name===p.type&&(y.target===p.target||p.target===y.shadowParent)&&iPo(y.delta,m)})[0];if(C&&C.should){p.cancelable&&p.preventDefault();return}if(!C){var I=(A.current.shards||[]).map(APt).filter(Boolean).filter(function(y){return y.contains(p.target)}),f=I.length>0?s(p,I[0]):!A.current.noIsolation;f&&p.cancelable&&p.preventDefault()}}},[]),c=ee.useCallback(function(_,p,m,C){var I={name:_,delta:p,target:m,should:C,shadowParent:aPo(m)};e.current.push(I),setTimeout(function(){e.current=e.current.filter(function(f){return f!==I})},1)},[]),l=ee.useCallback(function(_){n.current=Kne(_),o.current=void 0},[]),g=ee.useCallback(function(_){c(_.type,rPt(_),_.target,s(_,t.lockRef.current))},[]),u=ee.useCallback(function(_){c(_.type,Kne(_),_.target,s(_,t.lockRef.current))},[]);ee.useEffect(function(){return jR.push(r),t.setCallbacks({onScrollCapture:g,onWheelCapture:g,onTouchMoveCapture:u}),document.addEventListener("wheel",a,WR),document.addEventListener("touchmove",a,WR),document.addEventListener("touchstart",l,WR),function(){jR=jR.filter(function(_){return _!==r}),document.removeEventListener("wheel",a,WR),document.removeEventListener("touchmove",a,WR),document.removeEventListener("touchstart",l,WR)}},[]);var h=t.removeScrollBar,d=t.inert;return ee.createElement(ee.Fragment,null,d?ee.createElement(r,{styles:rPo(i)}):null,h?ee.createElement(jwo,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function aPo(t){for(var e=null;t!==null;)t instanceof ShadowRoot&&(e=t.host,t=t.host),t=t.parentNode;return e}const cPo=Fwo($wt,sPo);var xwe=ee.forwardRef(function(t,e){return ee.createElement(Gne,lS({},t,{ref:e,sideCar:cPo}))});xwe.classNames=Gne.classNames;var lPo=Object.defineProperty,mc=(t,e)=>lPo(t,"name",{value:e,configurable:!0}),Bwe=["Enter"," "],gPo=["ArrowDown","PageUp","Home"],sPt=["ArrowUp","PageDown","End"],uPo=[...gPo,...sPt],dPo={ltr:[...Bwe,"ArrowRight"],rtl:[...Bwe,"ArrowLeft"]},hPo={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Une="Menu",[rK,_Po,mPo]=Are(Une),[Pv,aPt]=pE(Une,[mPo,Rne,KU]),Yne=Rne(),cPt=KU(),[lPt,JM]=Pv(Une),[pPo,AK]=Pv(Une),IPo=mc(t=>{const{__scopeMenu:e,open:n=!1,children:o,dir:i,onOpenChange:r,modal:A=!0}=t,s=Yne(e),[a,c]=ee.useState(null),l=ee.useRef(!1),g=HB(r),u=GU(i);return ee.useEffect(()=>{const h=mc(()=>{l.current=!0,document.addEventListener("pointerdown",d,{capture:!0,once:!0}),document.addEventListener("pointermove",d,{capture:!0,once:!0})},"handleKeyDown"),d=mc(()=>l.current=!1,"handlePointer");return document.addEventListener("keydown",h,{capture:!0}),()=>{document.removeEventListener("keydown",h,{capture:!0}),document.removeEventListener("pointerdown",d,{capture:!0}),document.removeEventListener("pointermove",d,{capture:!0})}},[]),ee.useEffect(()=>{if(!n)return;const h=mc(()=>g(!1),"handleBlur");return window.addEventListener("blur",h),()=>window.removeEventListener("blur",h)},[n,g]),q.jsx(pwe,{...s,children:q.jsx(lPt,{scope:e,open:n,onOpenChange:g,content:a,onContentChange:c,children:q.jsx(pPo,{scope:e,onClose:ee.useCallback(()=>g(!1),[g]),isUsingKeyboardRef:l,dir:u,modal:A,children:o})})})},"Menu"),gPt=ee.forwardRef(mc(function(e,n){const{__scopeMenu:o,...i}=e,r=Yne(o);return q.jsx(Ywt,{...r,...i,ref:n})},"MenuAnchor")),uPt="MenuPortal",[CPo,dPt]=Pv(uPt,{forceMount:void 0}),fPo=mc(t=>{const{__scopeMenu:e,forceMount:n,children:o,container:i}=t,r=JM(uPt,e);return q.jsx(CPo,{scope:e,forceMount:n,children:q.jsx(GB,{present:n||r.open,children:q.jsx(Vwt,{asChild:!0,container:i,children:o})})})},"MenuPortal"),_B="MenuContent",[yPo,Qwe]=Pv(_B),EPo=ee.forwardRef(mc(function(e,n){const o=dPt(_B,e.__scopeMenu),{forceMount:i=o.forceMount,...r}=e,A=JM(_B,e.__scopeMenu),s=AK(_B,e.__scopeMenu);return q.jsx(rK.Provider,{scope:e.__scopeMenu,children:q.jsx(GB,{present:i||A.open,children:q.jsx(rK.Slot,{scope:e.__scopeMenu,children:s.modal?q.jsx(xPo,{...r,ref:n}):q.jsx(BPo,{...r,ref:n})})})})},"MenuContent")),xPo=ee.forwardRef(mc(function(e,n){const o=JM(_B,e.__scopeMenu),i=ee.useRef(null),r=rg(n,i);return ee.useEffect(()=>{const A=i.current;if(A)return qwt(A)},[]),q.jsx(Swe,{...e,ref:r,trapFocus:o.open,disableOutsidePointerEvents:o.open,disableOutsideScroll:!0,onFocusOutside:zr(e.onFocusOutside,A=>A.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>o.onOpenChange(!1)})},"MenuRootContentModal")),BPo=ee.forwardRef(mc(function(e,n){const o=JM(_B,e.__scopeMenu);return q.jsx(Swe,{...e,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>o.onOpenChange(!1)})},"MenuRootContentNonModal")),QPo=kS("MenuContent.ScrollLock"),Swe=ee.forwardRef(mc(function(e,n){const{__scopeMenu:o,loop:i=!1,trapFocus:r,onOpenAutoFocus:A,onCloseAutoFocus:s,disableOutsidePointerEvents:a,onEntryFocus:c,onEscapeKeyDown:l,onPointerDownOutside:g,onFocusOutside:u,onInteractOutside:h,onDismiss:d,disableOutsideScroll:_,...p}=e,m=JM(_B,o),C=AK(_B,o),I=Yne(o),f=cPt(o),y=_Po(o),[x,B]=ee.useState(null),S=ee.useRef(null),D=rg(n,S,m.onContentChange),w=ee.useRef(0),F=ee.useRef(""),R=ee.useRef(0),H=ee.useRef(null),G=ee.useRef("right"),K=ee.useRef(0),J=_?xwe:ee.Fragment,W=_?{as:QPo,allowPinchZoom:!0}:void 0,X=mc(se=>{const Z=F.current+se,ie=y().filter(we=>!we.disabled),ae=document.activeElement,ce=ie.find(we=>we.ref.current===ae)?.textValue,ge=ie.map(we=>we.textValue),xe=EPt(ge,Z,ce),Be=ie.find(we=>we.textValue===xe)?.ref.current;mc((function we(_e){F.current=_e,window.clearTimeout(w.current),_e!==""&&(w.current=window.setTimeout(()=>we(""),1e3))}),"updateSearch")(Z),Be&&setTimeout(()=>Be.focus())},"handleTypeaheadSearch");ee.useEffect(()=>()=>window.clearTimeout(w.current),[]),Ene();const re=ee.useCallback(se=>G.current===H.current?.side&&BPt(se,H.current?.area),[]);return q.jsx(yPo,{scope:o,searchRef:F,onItemEnter:ee.useCallback(se=>{re(se)&&se.preventDefault()},[re]),onItemLeave:ee.useCallback(se=>{re(se)||(S.current?.focus(),B(null))},[re]),onTriggerLeave:ee.useCallback(se=>{re(se)&&se.preventDefault()},[re]),pointerGraceTimerRef:R,onPointerGraceIntentChange:ee.useCallback(se=>{H.current=se},[]),children:q.jsx(J,{...W,children:q.jsx(lwt,{asChild:!0,trapped:r,onMountAutoFocus:zr(A,se=>{se.preventDefault(),S.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:s,children:q.jsx(WMe,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:l,onPointerDownOutside:g,onFocusOutside:u,onInteractOutside:h,onDismiss:d,children:q.jsx(u8e,{asChild:!0,...f,dir:C.dir,orientation:"vertical",loop:i,currentTabStopId:x,onCurrentTabStopIdChange:B,onEntryFocus:zr(c,se=>{C.isUsingKeyboardRef.current||se.preventDefault()}),preventScrollOnEntryFocus:!0,children:q.jsx(zwt,{role:"menu","aria-orientation":"vertical","data-state":Mwe(m.open),"data-radix-menu-content":"",dir:C.dir,...I,...p,ref:D,style:{outline:"none",...p.style},onKeyDown:zr(p.onKeyDown,se=>{const ie=se.target.closest("[data-radix-menu-content]")===se.currentTarget,ae=se.ctrlKey||se.altKey||se.metaKey,ce=se.key.length===1;ie&&(se.key==="Tab"&&se.preventDefault(),!ae&&ce&&X(se.key));const ge=S.current;if(se.target!==ge||!uPo.includes(se.key))return;se.preventDefault();const Be=y().filter(we=>!we.disabled).map(we=>we.ref.current);sPt.includes(se.key)&&Be.reverse(),fPt(Be)}),onBlur:zr(e.onBlur,se=>{se.currentTarget.contains(se.target)||(window.clearTimeout(w.current),F.current="")}),onPointerMove:zr(e.onPointerMove,XR(se=>{const Z=se.target,ie=K.current!==se.clientX;if(se.currentTarget.contains(Z)&&ie){const ae=se.clientX>K.current?"right":"left";G.current=ae,K.current=se.clientX}}))})})})})})})},"MenuContentImpl")),SPo=ee.forwardRef(mc(function(e,n){const{__scopeMenu:o,...i}=e;return q.jsx(o0.div,{...i,ref:n})},"MenuLabel")),bwe="MenuItem",hPt="menu.itemSelect",Dwe=ee.forwardRef(mc(function(e,n){const{disabled:o=!1,onSelect:i,...r}=e,A=ee.useRef(null),s=AK(bwe,e.__scopeMenu),a=Qwe(bwe,e.__scopeMenu),c=rg(n,A),l=ee.useRef(!1),g=mc(()=>{const u=A.current;if(!o&&u){const h=new CustomEvent(hPt,{bubbles:!0,cancelable:!0});u.addEventListener(hPt,d=>i?.(d),{once:!0}),lre(u,h),h.defaultPrevented?l.current=!1:s.onClose()}},"handleSelect");return q.jsx(_Pt,{...r,ref:c,disabled:o,onClick:zr(e.onClick,g),onPointerDown:u=>{e.onPointerDown?.(u),l.current=!0},onPointerUp:zr(e.onPointerUp,u=>{l.current||u.currentTarget?.click()}),onKeyDown:zr(e.onKeyDown,u=>{o||u.target!==u.currentTarget||a.searchRef.current!==""&&u.key===" "||Bwe.includes(u.key)&&(u.currentTarget.click(),u.preventDefault())})})},"MenuItem")),_Pt=ee.forwardRef(mc(function(e,n){const{__scopeMenu:o,disabled:i=!1,textValue:r,...A}=e,s=Qwe(bwe,o),a=cPt(o),c=ee.useRef(null),l=rg(n,c),[g,u]=ee.useState(!1),[h,d]=ee.useState("");return ee.useEffect(()=>{const _=c.current;_&&d((_.textContent??"").trim())},[A.children]),q.jsx(rK.ItemSlot,{scope:o,disabled:i,textValue:r??h,children:q.jsx(d8e,{asChild:!0,...a,focusable:!i,children:q.jsx(o0.div,{role:"menuitem","data-highlighted":g?"":void 0,"aria-disabled":i||void 0,"data-disabled":i?"":void 0,...A,ref:l,onPointerMove:zr(e.onPointerMove,XR(_=>{i?s.onItemLeave(_):(s.onItemEnter(_),_.defaultPrevented||_.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:zr(e.onPointerLeave,XR(_=>s.onItemLeave(_))),onFocus:zr(e.onFocus,()=>u(!0)),onBlur:zr(e.onBlur,()=>u(!1))})})})},"MenuItemImpl")),bPo=ee.forwardRef(mc(function(e,n){const{checked:o=!1,onCheckedChange:i,...r}=e;return q.jsx(pPt,{scope:e.__scopeMenu,checked:o,children:q.jsx(Dwe,{role:"menuitemcheckbox","aria-checked":sK(o)?"mixed":o,...r,ref:n,"data-state":Vne(o),onSelect:zr(r.onSelect,()=>i?.(sK(o)?!0:!o),{checkForDefaultPrevented:!1})})})},"MenuCheckboxItem")),DPo="MenuRadioGroup",[szo,MPo]=Pv(DPo,{value:void 0,onValueChange:mc(()=>{},"onValueChange")}),wPo="MenuRadioItem",PPo=ee.forwardRef(mc(function(e,n){const{value:o,...i}=e,r=MPo(wPo,e.__scopeMenu),A=o===r.value;return q.jsx(pPt,{scope:e.__scopeMenu,checked:A,children:q.jsx(Dwe,{role:"menuitemradio","aria-checked":A,...i,ref:n,"data-state":Vne(A),onSelect:zr(i.onSelect,()=>r.onValueChange?.(o),{checkForDefaultPrevented:!1})})})},"MenuRadioItem")),mPt="MenuItemIndicator",[pPt,vPo]=Pv(mPt,{checked:!1}),NPo=ee.forwardRef(mc(function(e,n){const{__scopeMenu:o,forceMount:i,...r}=e,A=vPo(mPt,o);return q.jsx(GB,{present:i||sK(A.checked)||A.checked===!0,children:q.jsx(o0.span,{...r,ref:n,"data-state":Vne(A.checked)})})},"MenuItemIndicator")),RPo=ee.forwardRef(mc(function(e,n){const{__scopeMenu:o,...i}=e;return q.jsx(o0.div,{role:"separator","aria-orientation":"horizontal",...i,ref:n})},"MenuSeparator")),IPt="MenuSub",[TPo,CPt]=Pv(IPt),kPo=mc(t=>{const{__scopeMenu:e,children:n,open:o=!1,onOpenChange:i}=t,r=JM(IPt,e),A=Yne(e),[s,a]=ee.useState(null),[c,l]=ee.useState(null),g=HB(i);return ee.useEffect(()=>(r.open===!1&&g(!1),()=>g(!1)),[r.open,g]),q.jsx(pwe,{...A,children:q.jsx(lPt,{scope:e,open:o,onOpenChange:g,content:c,onContentChange:l,children:q.jsx(TPo,{scope:e,contentId:Ex(),triggerId:Ex(),trigger:s,onTriggerChange:a,children:n})})})},"MenuSub"),zne="MenuSubTrigger",FPo=ee.forwardRef(mc(function(e,n){const o=JM(zne,e.__scopeMenu),i=AK(zne,e.__scopeMenu),r=CPt(zne,e.__scopeMenu),A=Qwe(zne,e.__scopeMenu),s=ee.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:c}=A,l={__scopeMenu:e.__scopeMenu},g=ee.useCallback(()=>{s.current&&window.clearTimeout(s.current),s.current=null},[]);ee.useEffect(()=>g,[g]),ee.useEffect(()=>{const h=a.current;return()=>{window.clearTimeout(h),c(null)}},[a,c]);const u=rg(n,r.onTriggerChange);return q.jsx(gPt,{asChild:!0,...l,children:q.jsx(_Pt,{id:r.triggerId,"aria-haspopup":"menu","aria-expanded":o.open,"aria-controls":o.open?r.contentId:void 0,"data-state":Mwe(o.open),...e,ref:u,onClick:h=>{e.onClick?.(h),!(e.disabled||h.defaultPrevented)&&(h.currentTarget.focus(),o.open||o.onOpenChange(!0))},onPointerMove:zr(e.onPointerMove,XR(h=>{A.onItemEnter(h),!h.defaultPrevented&&!e.disabled&&!o.open&&!s.current&&(A.onPointerGraceIntentChange(null),s.current=window.setTimeout(()=>{o.onOpenChange(!0),g()},100))})),onPointerLeave:zr(e.onPointerLeave,XR(h=>{g();const d=o.content?.getBoundingClientRect();if(d){const _=o.content?.dataset.side,p=_==="right",m=p?-5:5,C=d[p?"left":"right"],I=d[p?"right":"left"];A.onPointerGraceIntentChange({area:[{x:h.clientX+m,y:h.clientY},{x:C,y:d.top},{x:I,y:d.top},{x:I,y:d.bottom},{x:C,y:d.bottom}],side:_}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>A.onPointerGraceIntentChange(null),300)}else{if(A.onTriggerLeave(h),h.defaultPrevented)return;A.onPointerGraceIntentChange(null)}})),onKeyDown:zr(e.onKeyDown,h=>{e.disabled||h.target!==h.currentTarget||A.searchRef.current!==""&&h.key===" "||dPo[i.dir].includes(h.key)&&(o.onOpenChange(!0),o.content?.focus(),h.preventDefault())})})})},"MenuSubTrigger")),LPo="MenuSubContent",HPo=ee.forwardRef(mc(function(e,n){const o=dPt(_B,e.__scopeMenu),{forceMount:i=o.forceMount,align:r="start",...A}=e,s=JM(_B,e.__scopeMenu),a=AK(_B,e.__scopeMenu),c=CPt(LPo,e.__scopeMenu),l=ee.useRef(null),g=rg(n,l);return q.jsx(rK.Provider,{scope:e.__scopeMenu,children:q.jsx(GB,{present:i||s.open,children:q.jsx(rK.Slot,{scope:e.__scopeMenu,children:q.jsx(Swe,{id:c.contentId,"aria-labelledby":c.triggerId,...A,ref:g,align:r,side:a.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:u=>{a.isUsingKeyboardRef.current&&l.current?.focus(),u.preventDefault()},onCloseAutoFocus:u=>u.preventDefault(),onFocusOutside:zr(e.onFocusOutside,u=>{u.target!==c.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:zr(e.onEscapeKeyDown,u=>{a.onClose(),u.preventDefault()}),onKeyDown:zr(e.onKeyDown,u=>{const h=u.currentTarget.contains(u.target),d=hPo[a.dir].includes(u.key);h&&d&&(s.onOpenChange(!1),c.trigger?.focus(),u.preventDefault())})})})})})},"MenuSubContent"));function Mwe(t){return t?"open":"closed"}mc(Mwe,"getOpenState");function sK(t){return t==="indeterminate"}mc(sK,"isIndeterminate");function Vne(t){return sK(t)?"indeterminate":t?"checked":"unchecked"}mc(Vne,"getCheckedState");function fPt(t){const e=document.activeElement;for(const n of t)if(n===e||(n.focus(),document.activeElement!==e))return}mc(fPt,"focusFirst");function yPt(t,e){return t.map((n,o)=>t[(e+o)%t.length])}mc(yPt,"wrapArray");function EPt(t,e,n){const i=e.length>1&&Array.from(e).every(c=>c===e[0])?e[0]:e,r=n?t.indexOf(n):-1;let A=yPt(t,Math.max(r,0));i.length===1&&(A=A.filter(c=>c!==n));const a=A.find(c=>c.toLowerCase().startsWith(i.toLowerCase()));return a!==n?a:void 0}mc(EPt,"getNextMatch");function xPt(t,e){const{x:n,y:o}=t;let i=!1;for(let r=0,A=e.length-1;r<e.length;A=r++){const s=e[r],a=e[A],c=s.x,l=s.y,g=a.x,u=a.y;l>o!=u>o&&n<(g-c)*(o-l)/(u-l)+c&&(i=!i)}return i}mc(xPt,"isPointInPolygon");function BPt(t,e){if(!e)return!1;const n={x:t.clientX,y:t.clientY};return xPt(n,e)}mc(BPt,"isPointerInGraceArea");function XR(t){return e=>e.pointerType==="mouse"?t(e):void 0}mc(XR,"whenMouse");var GPo=IPo,OPo=gPt,KPo=fPo,UPo=EPo,YPo=SPo,zPo=Dwe,VPo=bPo,JPo=PPo,qPo=NPo,WPo=RPo,jPo=kPo,XPo=FPo,$Po=HPo,ZPo=Object.defineProperty,x2=(t,e)=>ZPo(t,"name",{value:e,configurable:!0}),wwe="DropdownMenu",[e3o,azo]=pE(wwe,[aPt]),B2=aPt(),[t3o,QPt]=e3o(wwe),n3o=x2(t=>{const{__scopeDropdownMenu:e,children:n,dir:o,open:i,defaultOpen:r,onOpenChange:A,modal:s=!0}=t,a=B2(e),c=ee.useRef(null),[l,g]=t4({prop:i,defaultProp:r??!1,onChange:A,caller:wwe});return q.jsx(t3o,{scope:e,triggerId:Ex(),triggerRef:c,contentId:Ex(),open:l,onOpenChange:g,onOpenToggle:ee.useCallback(()=>g(u=>!u),[g]),modal:s,children:q.jsx(GPo,{...a,open:l,onOpenChange:g,dir:o,modal:s,children:n})})},"DropdownMenu"),o3o="DropdownMenuTrigger",i3o=ee.forwardRef(x2(function(e,n){const{__scopeDropdownMenu:o,disabled:i=!1,...r}=e,A=QPt(o3o,o),s=B2(o),a=rg(n,A.triggerRef);return q.jsx(OPo,{asChild:!0,...s,children:q.jsx(o0.button,{type:"button",id:A.triggerId,"aria-haspopup":"menu","aria-expanded":A.open,"aria-controls":A.open?A.contentId:void 0,"data-state":A.open?"open":"closed","data-disabled":i?"":void 0,disabled:i,...r,ref:a,onPointerDown:zr(e.onPointerDown,c=>{!i&&c.button===0&&c.ctrlKey===!1&&(A.onOpenToggle(),A.open||c.preventDefault())}),onKeyDown:zr(e.onKeyDown,c=>{i||(["Enter"," "].includes(c.key)&&A.onOpenToggle(),c.key==="ArrowDown"&&A.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(c.key)&&c.preventDefault())})})})},"DropdownMenuTrigger")),r3o=x2(t=>{const{__scopeDropdownMenu:e,...n}=t,o=B2(e);return q.jsx(KPo,{...o,...n})},"DropdownMenuPortal"),A3o="DropdownMenuContent",s3o=ee.forwardRef(x2(function(e,n){const{__scopeDropdownMenu:o,...i}=e,r=QPt(A3o,o),A=B2(o),s=ee.useRef(!1);return q.jsx(UPo,{id:r.contentId,"aria-labelledby":r.triggerId,...A,...i,ref:n,onCloseAutoFocus:zr(e.onCloseAutoFocus,a=>{s.current||r.triggerRef.current?.focus(),s.current=!1,a.preventDefault()}),onInteractOutside:zr(e.onInteractOutside,a=>{const c=a.detail.originalEvent,l=c.button===0&&c.ctrlKey===!0,g=c.button===2||l;(!r.modal||g)&&(s.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})},"DropdownMenuContent")),a3o=ee.forwardRef(x2(function(e,n){const{__scopeDropdownMenu:o,...i}=e,r=B2(o);return q.jsx(YPo,{...r,...i,ref:n})},"DropdownMenuLabel")),c3o=ee.forwardRef(x2(function(e,n){const{__scopeDropdownMenu:o,...i}=e,r=B2(o);return q.jsx(zPo,{...r,...i,ref:n})},"DropdownMenuItem")),l3o=ee.forwardRef(x2(function(e,n){const{__scopeDropdownMenu:o,...i}=e,r=B2(o);return q.jsx(VPo,{...r,...i,ref:n})},"DropdownMenuCheckboxItem")),g3o=ee.forwardRef(x2(function(e,n){const{__scopeDropdownMenu:o,...i}=e,r=B2(o);return q.jsx(JPo,{...r,...i,ref:n})},"DropdownMenuRadioItem")),u3o=ee.forwardRef(x2(function(e,n){const{__scopeDropdownMenu:o,...i}=e,r=B2(o);return q.jsx(qPo,{...r,...i,ref:n})},"DropdownMenuItemIndicator")),d3o=ee.forwardRef(x2(function(e,n){const{__scopeDropdownMenu:o,...i}=e,r=B2(o);return q.jsx(WPo,{...r,...i,ref:n})},"DropdownMenuSeparator")),h3o=x2(t=>{const{__scopeDropdownMenu:e,children:n,open:o,onOpenChange:i,defaultOpen:r}=t,A=B2(e),[s,a]=t4({prop:o,defaultProp:r??!1,onChange:i,caller:"DropdownMenuSub"});return q.jsx(jPo,{...A,open:s,onOpenChange:a,children:n})},"DropdownMenuSub"),_3o=ee.forwardRef(x2(function(e,n){const{__scopeDropdownMenu:o,...i}=e,r=B2(o);return q.jsx(XPo,{...r,...i,ref:n})},"DropdownMenuSubTrigger")),m3o=ee.forwardRef(x2(function(e,n){const{__scopeDropdownMenu:o,...i}=e,r=B2(o);return q.jsx($Po,{...r,...i,ref:n,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})},"DropdownMenuSubContent")),Jne=n3o,qne=i3o,aK=r3o,cK=s3o,SPt=a3o,$R=c3o,bPt=l3o,DPt=g3o,MPt=u3o,Pwe=d3o,p3o=h3o,wPt=_3o,PPt=m3o;const Wne=Jne,jne=qne,lK=aK,gK=p3o,ZR=ee.forwardRef(({className:t,inset:e,children:n,...o},i)=>q.jsxs(wPt,{ref:i,className:sA("rf-flex rf-cursor-default rf-gap-2 rf-select-none rf-items-center rf-rounded-sm rf-px-2 rf-py-1.5 rf-text-sm rf-outline-none focus:rf-bg-zinc-100 data-[state=open]:rf-bg-zinc-100 [&_svg]:rf-pointer-events-none [&_svg]:rf-size-4 [&_svg]:rf-shrink-0 dark:focus:rf-bg-zinc-800 dark:data-[state=open]:rf-bg-zinc-800",e&&"rf-pl-8",t),...o,children:[n,q.jsx(nK,{className:"rf-ml-auto"})]}));ZR.displayName=wPt.displayName;const eT=ee.forwardRef(({className:t,...e},n)=>q.jsx(PPt,{ref:n,className:sA("rf-z-50 rf-min-w-[8rem] rf-overflow-hidden rf-rounded-md rf-border rf-border-zinc-200 rf-bg-white rf-p-1 rf-text-zinc-950 rf-shadow-lg data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0 data-[state=closed]:rf-zoom-out-95 data-[state=open]:rf-zoom-in-95 data-[side=bottom]:rf-slide-in-from-top-2 data-[side=left]:rf-slide-in-from-right-2 data-[side=right]:rf-slide-in-from-left-2 data-[side=top]:rf-slide-in-from-bottom-2 dark:rf-border-zinc-800 dark:rf-bg-zinc-950 dark:rf-text-zinc-50",t),...e}));eT.displayName=PPt.displayName;const uK=ee.forwardRef(({className:t,sideOffset:e=4,...n},o)=>q.jsx(aK,{children:q.jsx(cK,{ref:o,sideOffset:e,className:sA("rf-z-50 rf-min-w-[8rem] rf-overflow-hidden rf-rounded-md rf-border rf-border-zinc-200 rf-bg-white rf-p-1 rf-text-zinc-950 rf-shadow-md dark:rf-border-zinc-800 dark:rf-bg-zinc-950 dark:rf-text-zinc-50","data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0 data-[state=closed]:rf-zoom-out-95 data-[state=open]:rf-zoom-in-95 data-[side=bottom]:rf-slide-in-from-top-2 data-[side=left]:rf-slide-in-from-right-2 data-[side=right]:rf-slide-in-from-left-2 data-[side=top]:rf-slide-in-from-bottom-2",t),...n})}));uK.displayName=cK.displayName;const Qh=ee.forwardRef(({className:t,inset:e,...n},o)=>q.jsx($R,{ref:o,className:sA("rf-relative rf-flex rf-cursor-default rf-select-none rf-items-center rf-gap-2 rf-rounded-sm rf-px-2 rf-py-1.5 rf-text-sm rf-outline-none rf-transition-colors focus:rf-bg-zinc-100 focus:rf-text-zinc-900 data-[disabled]:rf-pointer-events-none data-[disabled]:rf-opacity-50 [&>svg]:rf-size-4 [&>svg]:rf-shrink-0 dark:focus:rf-bg-zinc-800 dark:focus:rf-text-zinc-50",e&&"rf-pl-8",t),...n}));Qh.displayName=$R.displayName;const I3o=ee.forwardRef(({className:t,children:e,checked:n,...o},i)=>q.jsxs(bPt,{ref:i,className:sA("rf-relative rf-flex rf-cursor-default rf-select-none rf-items-center rf-rounded-sm rf-py-1.5 rf-pl-8 rf-pr-2 rf-text-sm rf-outline-none rf-transition-colors focus:rf-bg-zinc-100 focus:rf-text-zinc-900 data-[disabled]:rf-pointer-events-none data-[disabled]:rf-opacity-50 dark:focus:rf-bg-zinc-800 dark:focus:rf-text-zinc-50",t),checked:n,...o,children:[q.jsx("span",{className:"rf-absolute rf-left-2 rf-flex rf-h-3.5 rf-w-3.5 rf-items-center rf-justify-center",children:q.jsx(MPt,{children:q.jsx(VMe,{className:"rf-h-4 rf-w-4"})})}),e]}));I3o.displayName=bPt.displayName;const C3o=ee.forwardRef(({className:t,children:e,...n},o)=>q.jsxs(DPt,{ref:o,className:sA("rf-relative rf-flex rf-cursor-default rf-select-none rf-items-center rf-rounded-sm rf-py-1.5 rf-pl-8 rf-pr-2 rf-text-sm rf-outline-none rf-transition-colors focus:rf-bg-zinc-100 focus:rf-text-zinc-900 data-[disabled]:rf-pointer-events-none data-[disabled]:rf-opacity-50 dark:focus:rf-bg-zinc-800 dark:focus:rf-text-zinc-50",t),...n,children:[q.jsx("span",{className:"rf-absolute rf-left-2 rf-flex rf-h-3.5 rf-w-3.5 rf-items-center rf-justify-center",children:q.jsx(MPt,{children:q.jsx(nwt,{className:"rf-h-2 rf-w-2 rf-fill-current"})})}),e]}));C3o.displayName=DPt.displayName;const f3o=ee.forwardRef(({className:t,inset:e,...n},o)=>q.jsx(SPt,{ref:o,className:sA("rf-px-2 rf-py-1.5 rf-text-sm rf-font-semibold",e&&"rf-pl-8",t),...n}));f3o.displayName=SPt.displayName;const vPt=ee.forwardRef(({className:t,...e},n)=>q.jsx(Pwe,{ref:n,className:sA("rf--mx-1 rf-my-1 rf-h-px rf-bg-zinc-100 dark:rf-bg-zinc-800",t),...e}));vPt.displayName=Pwe.displayName;const NPt=({autoroutingLog:t,onReportAutoroutingLog:e})=>q.jsx(q.Fragment,{children:Object.keys(t??{}).length>0&&q.jsxs(Wne,{children:[q.jsx(jne,{asChild:!0,children:q.jsxs(_c,{variant:"outline",children:[q.jsx(kDo,{className:"rf-w-4 rf-h-4 rf-mr-2"}),"Open Autorouting Log"]})}),q.jsx(uK,{className:"rf-w-96",children:Object.entries(t??{}).map(([n,{simpleRouteJson:o}])=>q.jsxs(Qh,{className:"rf-flex rf-justify-between rf-items-center",children:[q.jsx("span",{className:"rf-truncate rf-text-xs rf-mr-2",children:n}),q.jsxs("div",{className:"rf-flex rf-gap-2",children:[q.jsxs(_c,{variant:"outline",size:"sm",onClick:i=>{i.stopPropagation();const r=new Blob([JSON.stringify(o,null,2)],{type:"application/json"}),A=URL.createObjectURL(r),s=document.createElement("a");s.href=A,s.download=`${n}-autorouting.json`,s.click(),URL.revokeObjectURL(A)},children:[q.jsx(JMe,{className:"rf-w-3 rf-h-3"}),"Download"]}),e&&q.jsxs(_c,{variant:"outline",size:"sm",onClick:i=>{i.stopPropagation(),e&&e(n,{simpleRouteJson:o})},children:[q.jsx(jDo,{className:"rf-w-3 rf-h-3"}),"Report Bug"]})]})]},n))})]})}),y3o=({code:t,fsMap:e,autoroutingLog:n,circuitJsonErrors:o,circuitJsonWarnings:i,onReportAutoroutingLog:r,errorMessage:A,errorStack:s,circuitJson:a,evalVersion:c})=>{const l=ee.useMemo(()=>{const D=[];if(A&&D.push({type:"Execution Error",message:A,stack:s||void 0,source:"execution"}),o&&o.length>0)for(const w of o)D.push({type:w.type||"Circuit JSON Error",message:w.message||"No error message available",stack:w.stack||"",source:"circuitJson"});return D},[A,s,o]),g=ee.useMemo(()=>!a||!Array.isArray(a)?void 0:a.find(w=>w.type==="source_project_metadata")?.software_used_string,[a]),u=ee.useMemo(()=>{const D=[];if(i&&i.length>0)for(const w of i)D.push({type:w.type||"Circuit JSON Warning",message:w.message||"No warning message available",stack:w.stack||"",source:"circuitJson"});return D},[i]),h=()=>{if(e)try{return DKt(e instanceof Map?Object.fromEntries(e.entries()):e)}catch{}return eMo(t??"")},d=(D,w)=>{const F=`https://github.com/tscircuit/tscircuit.com/issues/new?title=${encodeURIComponent(D)}&body=${encodeURIComponent(w)}`;window.open(F,"_blank")};ee.useEffect(()=>{if(A){let D=A;s&&(D+=`
5587
5587
 
5588
- ${s}`),typeof window<"u"&&(window.__TSCIRCUIT_LAST_EXECUTION_ERROR=D)}},[A,s]);const[_,p]=ee.useState(()=>{const D=new Set;return l.forEach((w,F)=>D.add(F)),D}),[m,C]=ee.useState(()=>{const D=new Set;return u.forEach((w,F)=>D.add(F)),D}),[I,f]=ee.useState(!1),[y,x]=ee.useState(!1),B=D=>{p(w=>{const F=new Set(w);return F.has(D)?F.delete(D):F.add(D),F})},S=D=>{C(w=>{const F=new Set(w);return F.has(D)?F.delete(D):F.add(D),F})};return q.jsx(q.Fragment,{children:q.jsxs("div",{className:"rf-w-full rf-flex rf-flex-col rf-h-full",children:[q.jsxs("div",{className:"rf-overflow-y-auto rf-min-h-0",children:[l.length>0&&q.jsxs("div",{className:"rf-mt-2",children:[q.jsxs("div",{className:"rf-text-xs rf-text-red-700 rf-font-semibold rf-px-2 rf-py-1 rf-bg-red-50 rf-border-b rf-border-red-200 rf-flex rf-items-center rf-gap-2 rf-cursor-pointer hover:rf-bg-red-100",onClick:()=>f(!I),children:[I?q.jsx(nK,{className:"rf-h-3 rf-w-3 rf-text-red-700"}):q.jsx(ewt,{className:"rf-h-3 rf-w-3 rf-text-red-700"}),q.jsxs("span",{children:[l.length," ",l.length===1?"error":"errors"]})]}),!I&&l.map((D,w)=>{const F=_.has(w);D.message;const R=D.stack||c||g;return q.jsxs("div",{className:"rf-bg-white hover:rf-bg-red-100",children:[q.jsxs("div",{className:"rf-flex rf-items-start rf-gap-1 rf-px-2 rf-pt-1 rf-pb-1 rf-cursor-pointer rf-bg-red-50/50",onClick:()=>R&&B(w),children:[q.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",style:{marginTop:"2px"},children:[q.jsx(TDo,{className:"rf-h-4 rf-w-4 rf-text-red-500 rf-flex-shrink-0"}),R&&q.jsx(nK,{className:`rf-h-3 rf-w-3 rf-text-red-500 rf-flex-shrink-0 rf-transition-transform ${F?"rf-rotate-90":""}`})]}),q.jsxs("div",{className:"rf-flex-1 rf-min-w-0 rf-leading-[1rem]",children:[q.jsxs("span",{className:"rf-text-xs rf-font-mono rf-text-red-700 rf-leading-[0.95rem]",children:[D.type,":"]}),q.jsx("span",{className:"rf-text-xs rf-font-mono rf-text-red-600 rf-ml-1 rf-leading-[0.95rem]",children:D.message})]})]}),F&&R&&q.jsxs("div",{className:"rf-bg-red-50/50 rf-pl-12",children:[D.stack?.split(`
5588
+ ${s}`),typeof window<"u"&&(window.__TSCIRCUIT_LAST_EXECUTION_ERROR=D)}},[A,s]);const[_,p]=ee.useState(()=>{const D=new Set;return l.forEach((w,F)=>D.add(F)),D}),[m,C]=ee.useState(()=>{const D=new Set;return u.forEach((w,F)=>D.add(F)),D}),[I,f]=ee.useState(!1),[y,x]=ee.useState(!1);if(l.length===0&&u.length===0)return q.jsxs("div",{className:"px-2",children:[q.jsx("div",{className:"rf-mt-4 rf-bg-green-50 rf-rounded-md rf-border rf-border-green-200",children:q.jsxs("div",{className:"rf-p-4",children:[q.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-green-800 rf-mb-3",children:"No errors or warnings!"}),q.jsx("p",{className:"rf-text-sm rf-text-green-700",children:"Your code is running without any errors or warnings."})]})}),q.jsxs("div",{className:"rf-flex rf-gap-2 rf-mt-4 rf-justify-end",children:[q.jsx(NPt,{autoroutingLog:n,onReportAutoroutingLog:r}),q.jsxs(_c,{variant:"outline",className:"rf-p-1",onClick:()=>{const D=h();d("Issue Report",`[Package code to reproduce](${D})`)},children:[q.jsx(zMe,{className:"rf-w-4 rf-h-4"}),"Report Issue"]})]})]});const B=D=>{p(w=>{const F=new Set(w);return F.has(D)?F.delete(D):F.add(D),F})},S=D=>{C(w=>{const F=new Set(w);return F.has(D)?F.delete(D):F.add(D),F})};return q.jsx(q.Fragment,{children:q.jsxs("div",{className:"rf-w-full rf-flex rf-flex-col rf-h-full",children:[q.jsxs("div",{className:"rf-overflow-y-auto rf-min-h-0",children:[l.length>0&&q.jsxs("div",{className:"rf-mt-2",children:[q.jsxs("div",{className:"rf-text-xs rf-text-red-700 rf-font-semibold rf-px-2 rf-py-1 rf-bg-red-50 rf-border-b rf-border-red-200 rf-flex rf-items-center rf-gap-2 rf-cursor-pointer hover:rf-bg-red-100",onClick:()=>f(!I),children:[I?q.jsx(nK,{className:"rf-h-3 rf-w-3 rf-text-red-700"}):q.jsx(ewt,{className:"rf-h-3 rf-w-3 rf-text-red-700"}),q.jsxs("span",{children:[l.length," ",l.length===1?"error":"errors"]})]}),!I&&l.map((D,w)=>{const F=_.has(w);D.message;const R=D.stack||c||g;return q.jsxs("div",{className:"rf-bg-white hover:rf-bg-red-100",children:[q.jsxs("div",{className:"rf-flex rf-items-start rf-gap-1 rf-px-2 rf-pt-1 rf-pb-1 rf-cursor-pointer rf-bg-red-50/50",onClick:()=>R&&B(w),children:[q.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",style:{marginTop:"2px"},children:[q.jsx(TDo,{className:"rf-h-4 rf-w-4 rf-text-red-500 rf-flex-shrink-0"}),R&&q.jsx(nK,{className:`rf-h-3 rf-w-3 rf-text-red-500 rf-flex-shrink-0 rf-transition-transform ${F?"rf-rotate-90":""}`})]}),q.jsxs("div",{className:"rf-flex-1 rf-min-w-0 rf-leading-[1rem]",children:[q.jsxs("span",{className:"rf-text-xs rf-font-mono rf-text-red-700 rf-leading-[0.95rem]",children:[D.type,":"]}),q.jsx("span",{className:"rf-text-xs rf-font-mono rf-text-red-600 rf-ml-1 rf-leading-[0.95rem]",children:D.message})]})]}),F&&R&&q.jsxs("div",{className:"rf-bg-red-50/50 rf-pl-12",children:[D.stack?.split(`
5589
5589
  `).filter(H=>H.trim()).slice(1).map((H,G)=>q.jsx("div",{className:"rf-px-2 rf-leading-tight",children:q.jsx("span",{className:"rf-text-xs rf-font-mono rf-text-red-500",children:H})},G)),(c||g)&&q.jsx("div",{className:"rf-px-2",children:q.jsxs("span",{className:"rf-text-xs rf-font-mono rf-text-red-400",children:[c&&`@tscircuit/eval@${c}`,c&&g&&" • ",g]})})]})]},w)})]}),u.length>0&&q.jsxs("div",{className:"rf-mt-2",children:[q.jsxs("div",{className:"rf-text-xs rf-text-orange-700 rf-font-semibold rf-px-2 rf-py-1 rf-bg-orange-50 rf-border-b rf-border-orange-200 rf-flex rf-items-center rf-gap-2 rf-cursor-pointer hover:rf-bg-orange-100",onClick:()=>x(!y),children:[y?q.jsx(nK,{className:"rf-h-3 rf-w-3 rf-text-orange-700"}):q.jsx(ewt,{className:"rf-h-3 rf-w-3 rf-text-orange-700"}),q.jsxs("span",{children:[u.length," ",u.length===1?"warning":"warnings"]})]}),!y&&u.map((D,w)=>{const F=m.has(w);D.message;const R=!!D.stack;return q.jsxs("div",{className:"rf-bg-white hover:rf-bg-orange-100",children:[q.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2 rf-px-2 rf-py-1 rf-cursor-pointer rf-bg-orange-50/50",onClick:()=>R&&S(w),children:[q.jsx(twt,{className:"rf-h-4 rf-w-4 rf-text-orange-500 rf-flex-shrink-0"}),R&&q.jsx(nK,{className:`rf-h-3 rf-w-3 rf-text-orange-500 rf-flex-shrink-0 rf-transition-transform ${F?"rf-rotate-90":""}`}),q.jsxs("div",{className:"rf-flex-1 rf-min-w-0 rf-flex rf-items-center rf-flex-wrap",children:[q.jsxs("span",{className:"rf-text-xs rf-font-mono rf-text-orange-700 rf-break-words",children:[D.type,":"]}),q.jsx("span",{className:"rf-text-xs rf-font-mono rf-text-orange-600 rf-ml-1 rf-break-words",children:D.message})]})]}),F&&R&&q.jsx("div",{className:"rf-bg-orange-50/50 rf-pl-12",children:D.stack?.split(`
5590
5590
  `).filter(H=>H.trim()).slice(1).map((H,G)=>q.jsx("div",{className:"rf-px-2 rf-leading-tight",children:q.jsx("span",{className:"rf-text-xs rf-font-mono rf-text-orange-500",children:H})},G))})]},w)})]})]}),q.jsxs("div",{className:"rf-flex rf-gap-2 rf-mt-4 rf-justify-end rf-flex-shrink-0",children:[q.jsx(NPt,{autoroutingLog:n,onReportAutoroutingLog:r}),q.jsxs(_c,{variant:"outline",className:"rf-p-1",onClick:()=>{const D=l[0]??u[0]??{type:"General Issue",message:"No error or warning details provided."};let w=`${D.type}: ${D.message}`;c&&(w+=`
5591
5591
  @tscircuit/eval@${c}`),g&&(w+=`
@@ -5786,7 +5786,7 @@ test("${c} should solve problem correctly", () => {
5786
5786
  // Add more specific assertions based on expected output
5787
5787
  // expect(solver.netLabelPlacementSolver!.netLabelPlacements).toMatchInlineSnapshot()
5788
5788
  })
5789
- `,g=new Blob([l],{type:"text/plain"}),u=URL.createObjectURL(g),h=document.createElement("a");h.href=u,h.download=`${c}.test.ts`,h.click(),URL.revokeObjectURL(u)}catch(a){alert(`Error generating test.ts for ${t.constructor.name}: ${a instanceof Error?a.message:String(a)}`)}o(!1)};return q.jsxs("div",{className:`relative ${e}`,ref:i,children:[q.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&&q.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:[q.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download JSON"}),q.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:A,children:"Download page.tsx"}),q.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download test.ts"})]})]})},z7t=t=>t.activeSubSolver?[t,...z7t(t.activeSubSolver)]:[t],Jko=({solver:t})=>{const e=z7t(t);return q.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:e.map((n,o)=>q.jsxs("div",{className:"flex items-center",children:[o>0&&q.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),q.jsx(Vko,{solver:n})]},n.constructor.name))})},qko=({solver:t,triggerRender:e,animationSpeed:n=25,onSolverStarted:o,onSolverCompleted:i})=>{const[r,A]=ee.useReducer(_=>!_,!1),s=ee.useRef(void 0),a=()=>{!t.solved&&!t.failed&&(t.step(),e())},c=()=>{!t.solved&&!t.failed&&(o&&o(t),t.solve(),e(),i&&i(t))},l=()=>{r?(s.current&&(clearInterval(s.current),s.current=void 0),A()):(A(),s.current=setInterval(()=>{if(t.solved||t.failed){s.current&&(clearInterval(s.current),s.current=void 0),A(),e(),i&&t.solved&&i(t);return}t.step(),e()},n))},g=()=>{const _=t;if(_.getCurrentPhase&&!t.solved&&!t.failed){const p=_.getCurrentPhase();for(;_.getCurrentPhase()===p&&!t.solved&&!t.failed;)t.step();e()}},u=()=>{if(t.solved||t.failed||r)return;const _=window.prompt("Step until which iteration?",`${t.iterations}`);if(_===null)return;const p=Number(_);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)};ee.useEffect(()=>()=>{s.current&&clearInterval(s.current)},[]),ee.useEffect(()=>{(t.solved||t.failed)&&r&&(s.current&&(clearInterval(s.current),s.current=void 0),A())},[t.solved,t.failed,r]);const h=t.getCurrentPhase!==void 0,d=h?t.getCurrentPhase():null;return q.jsxs("div",{className:"space-y-2 p-2 border-b",children:[q.jsx("div",{className:"flex items-center",children:q.jsx(Jko,{solver:t})}),q.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[q.jsx("button",{onClick:a,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"}),q.jsx("button",{onClick:c,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"}),q.jsx("button",{onClick:l,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"}),q.jsx("button",{onClick:u,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"}),h&&q.jsx("button",{onClick:g,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"}),q.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&q.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),d&&q.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",q.jsx("span",{className:"font-medium",children:d})]}),t.solved&&q.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&q.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&q.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},Wko=(t,e,n)=>{const o=t.currentPipelineStepIndex;return e<o?"Completed":e===o&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},jko=(t,e)=>{const o=t.pipelineDef[e].solverName,i=Wko(t,e),r=t[o],A=t.firstIterationOfPhase?.[o]??null,s=t.iterations;let a=0;if(i==="Completed"){const u=t.pipelineDef[e+1],h=u?t.firstIterationOfPhase?.[u.solverName]:void 0;h!==void 0&&A!==null?a=h-A:A!==null&&(a=s-A)}else i==="In Progress"&&A!==null&&(a=s-A);const c=t.timeSpentOnPhase?.[o]??0;let l=0;i==="Completed"?l=1:i==="In Progress"&&r&&(l=r.progress??0);const g=r?.stats??null;return{index:e,name:o,status:i,firstIteration:A,iterations:a,progress:l,timeSpent:c,stats:g&&Object.keys(g).length>0?g:null,solverInstance:r??null}},Xko=({status:t})=>{const e={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return q.jsx("span",{className:`font-medium ${e[t]}`,children:t})},$ko=({progress:t})=>{if(t===0)return null;const e=Math.round(t*100);return q.jsxs("div",{className:"flex items-center gap-2",children:[q.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:q.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${e}%`}})}),q.jsxs("span",{className:"text-xs text-gray-500",children:[e,"%"]})]})},Zko=t=>Object.entries(t).map(([e,n])=>`${e}: ${n}`).join(", "),eFo=({stats:t})=>{if(!t||Object.keys(t).length===0)return q.jsx("span",{children:"-"});const e=Object.entries(t),n=Zko(t);return q.jsxs("details",{className:"cursor-pointer",children:[q.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:n}),q.jsx("div",{className:"mt-1 text-xs",children:e.map(([o,i])=>q.jsxs("div",{children:[o,": ",String(i)]},o))})]})},u3e=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(u3e);const e={};for(const[n,o]of Object.entries(t))n.startsWith("_")||(e[n]=u3e(o));return e},tFo=(t,e)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${e}`);return}const n=u3e(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)}`)}},nFo=({solver:t,onStepUntilPhase:e,onDownloadInput:n})=>{const o=t.pipelineDef.map((s,a)=>jko(t,a)),i=s=>{e?.(s)},r=s=>{s.solverInstance&&(n?n(s.solverInstance,s.name):tFo(s.solverInstance,s.name))},A=s=>`${(s/1e3).toFixed(2)}s`;return q.jsxs("div",{className:"border-t border-gray-200",children:[q.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:q.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),q.jsx("div",{className:"overflow-x-auto",children:q.jsxs("table",{className:"w-full text-sm",children:[q.jsx("thead",{children:q.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[q.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),q.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),q.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",q.jsx("sub",{children:"0"})]}),q.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),q.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),q.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),q.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),q.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),q.jsx("tbody",{children:o.map(s=>q.jsxs("tr",{className:`border-b border-gray-100 ${s.status==="In Progress"?"bg-yellow-50":""}`,children:[q.jsx("td",{className:"px-4 py-2",children:q.jsxs("div",{className:"flex items-center gap-2",children:[q.jsx("span",{className:"text-gray-400 w-6",children:String(s.index+1).padStart(2,"0")}),q.jsx("button",{onClick:()=>i(s.name),disabled:s.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 ${s.name} completes`,children:q.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:q.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"})})}),q.jsx("span",{className:"font-medium text-gray-900",children:s.name})]})}),q.jsx("td",{className:"px-4 py-2",children:q.jsx(Xko,{status:s.status})}),q.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:s.firstIteration!==null?s.firstIteration:""}),q.jsx("td",{className:"px-4 py-2 text-gray-600",children:s.iterations}),q.jsx("td",{className:"px-4 py-2",children:q.jsx($ko,{progress:s.progress})}),q.jsx("td",{className:"px-4 py-2 text-gray-600",children:A(s.timeSpent)}),q.jsx("td",{className:"px-4 py-2 text-gray-500",children:q.jsx(eFo,{stats:s.stats})}),q.jsx("td",{className:"px-4 py-2",children:s.solverInstance?q.jsxs("button",{onClick:()=>r(s),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${s.name}`,children:[q.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:q.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"})}),q.jsx("span",{children:"Input"})]}):null})]},s.name))})]})})]})},oFo=class extends Xr.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 iFo({graphics:t}){const e=t.points??[],n=t.lines??[],o=t.rects??[],i=t.circles??[],r=t.texts??[];let A=Number.POSITIVE_INFINITY,s=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,c=Number.NEGATIVE_INFINITY;const l=(p,m)=>{typeof p=="number"&&(p<A&&(A=p),p>a&&(a=p)),typeof m=="number"&&(m<s&&(s=m),m>c&&(c=m))};for(const p of e)l(p.x,p.y);for(const p of n){const m=p.points??[];for(const C of m)l(C.x,C.y)}for(const p of o){const m=p.x??0,C=p.y??0,I=p.width??0,f=p.height??0;l(m,C),l(m+I,C+f)}for(const p of i){const m=p.x??0,C=p.y??0,I=p.radius??1;l(m-I,C-I),l(m+I,C+I)}for(const p of r)l(p.x,p.y);(!isFinite(A)||!isFinite(s)||!isFinite(a)||!isFinite(c))&&(A=-20,s=-20,a=20,c=20);const g=10,u=A-g,h=s-g,d=Math.max(1,a-A+2*g),_=Math.max(1,c-s+2*g);return q.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${u} ${h} ${d} ${_}`,role:"img","aria-label":"Graphics fallback",children:[o.map((p,m)=>q.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-${m}`)),n.map((p,m)=>q.jsx("polyline",{fill:"none",stroke:p.strokeColor??"black",strokeWidth:p.strokeWidth??1,points:(p.points??[]).map(C=>`${C.x??0},${C.y??0}`).join(" ")},`line-${m}`)),i.map((p,m)=>q.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-${m}`)),e.map((p,m)=>q.jsx("circle",{cx:p.x??0,cy:p.y??0,r:p.radius??1.5,fill:p.color??"black"},`point-${m}`)),r.map((p,m)=>q.jsx("text",{x:p.x??0,y:p.y??0,fontSize:p.fontSize??10,fill:p.color??"black",children:p.text??""},`text-${m}`))]})}var rFo=({solver:t,animationSpeed:e=25,onSolverStarted:n,onSolverCompleted:o})=>{const[i,r]=ee.useReducer(l=>l+1,0),A=ee.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(l){return console.error("Visualization error:",l),{points:[],lines:[],rects:[],circles:[]}}},[t,i]),s=ee.useMemo(()=>(A.rects?.length||0)===0&&(A.lines?.length||0)===0&&(A.points?.length||0)===0&&(A.circles?.length||0)===0,[A]);ee.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const l=document.createElement("script");l.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(l)}},[]);const a=t.pipelineDef!==void 0,c=l=>{const g=t;if(!t.solved&&!t.failed){for(;!t.solved&&!t.failed&&g.currentPipelineStepIndex<=g.pipelineDef.findIndex(u=>u.solverName===l);)t.step();r()}};return q.jsxs("div",{children:[q.jsx(qko,{solver:t,triggerRender:r,animationSpeed:e,onSolverStarted:n,onSolverCompleted:o}),s?q.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):q.jsx(oFo,{fallback:q.jsx(iFo,{graphics:A}),children:q.jsx(zko,{graphics:A})}),a&&q.jsx(nFo,{solver:t,onStepUntilPhase:c})]})};const AFo=()=>{ee.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)},[])},sFo=1e3,IS=(t,e)=>{const{fileName:n,mimeType:o="text/plain"}=e,i=t instanceof Blob?t:new Blob([t],{type:o}),r=URL.createObjectURL(i),A=document.createElement("a");A.href=r,A.download=n,A.target="_blank",A.rel="noopener noreferrer",A.style.display="none",document.body.appendChild(A),A.click(),document.body.removeChild(A),setTimeout(()=>{URL.revokeObjectURL(r)},sFo)},V7t=t=>{let e=t.trim().replace(/[\\/:*?"<>|]/g,"_").replace(/[\x00-\x1f]/g,"").replace(/^\.+/,"").replace(/\.+$/,"").replace(/\s+/g," ").replace(/_+/g,"_");return/^(con|prn|aux|nul|com[0-9]|lpt[0-9])$/i.test(e)&&(e=`_${e}`),e=e.slice(0,200),e||"untitled"},CS="https://github.com/tscircuit/tscircuit-autorouter/issues/new",J7t="https://github.com/tscircuit/copper-pour-solver/issues/new",q7t="https://github.com/tscircuit/calculate-packing/issues/new",W7t="https://github.com/tscircuit/schematic-trace-solver/issues/new?template=json-bug-report.yml",aFo={PackSolver2:q7t,AutoroutingPipelineSolver:CS,AssignableAutoroutingPipeline2:CS,AssignableAutoroutingPipeline3:CS,AutoroutingPipeline1_OriginalUnravel:CS,AutoroutingPipelineSolver3_HgPortPointPathing:CS,AutoroutingPipelineSolver4:CS,AutoroutingPipelineSolver5:CS,AutoroutingPipelineSolver7_MultiGraph:CS,AutoroutingPipelineSolver8:CS,CopperPourPipelineSolver:J7t,SchematicTracePipelineSolver:W7t},cFo=t=>t.toLowerCase().includes("pack")?ODo:t.toLowerCase().includes("rout")?qDo:RDo,j7t=t=>{const e=aFo[t];if(e)return e;const n=t.toLowerCase();return n.includes("autorout")?CS:n.includes("schematic")&&n.includes("trace")?W7t:n.includes("copperpour")?J7t:n.includes("pack")?q7t:null},lFo=t=>`${V7t(`${t.componentName}-${t.solverName}`)}-solver-input.json`,X7t=t=>{IS(JSON.stringify(t.solverParams,null,2),{fileName:lFo(t),mimeType:"application/json"})},gFo=({solverEvent:t})=>{const e=j7t(t.solverName);return q.jsxs("div",{className:"rf-flex rf-items-center rf-justify-end rf-gap-2 rf-border-b rf-border-gray-200 rf-bg-gray-50 rf-px-4 rf-py-2",children:[q.jsxs(_c,{type:"button",variant:"outline",size:"sm",onClick:()=>X7t(t),children:[q.jsx(JMe,{className:"rf-w-4 rf-h-4"}),"Download"]}),e?q.jsx(_c,{asChild:!0,variant:"outline",size:"sm",children:q.jsxs("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:[q.jsx(fne,{className:"rf-w-4 rf-h-4"}),"Report"]})}):q.jsxs(_c,{type:"button",variant:"outline",size:"sm",disabled:!0,title:"No report link configured for this solver",children:[q.jsx(fne,{className:"rf-w-4 rf-h-4"}),"Report"]})]})},uFo=({solverEvent:t})=>{const e=j7t(t.solverName);return e?q.jsx(_c,{asChild:!0,variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8",children:q.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",title:"Report solver bug","aria-label":"Report solver bug",children:q.jsx(fne,{className:"rf-w-4 rf-h-4"})})}):q.jsx(_c,{type:"button",variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8",disabled:!0,title:"No report link configured for this solver","aria-label":"Report solver bug",children:q.jsx(fne,{className:"rf-w-4 rf-h-4"})})},dFo=({solverEvents:t=[]})=>{const[e,n]=ee.useState(null);AFo();const o=ee.useMemo(()=>{const s=new Map;for(const a of t){const c=`${a.componentName}-${a.solverName}`;s.set(c,a)}return s},[t]),i=ee.useMemo(()=>Array.from(o.keys()),[o]),r=e?o.get(e):null,A=ee.useMemo(()=>{if(!r)return{instance:null,error:null,classFound:!1};const s=kye[r.solverName];if(!s)return{instance:null,error:`Solver class "${r.solverName}" not found in SOLVERS registry. Available: ${Object.keys(kye).join(", ")}`,classFound:!1};try{const a=r.solverParams,c=a?.input!==void 0?a.input:a;return{instance:new s(c),error:null,classFound:!0}}catch(a){const c=a instanceof Error?a.message:String(a);return console.error("Failed to reconstruct solver:",a),{instance:null,error:`Failed to instantiate solver: ${c}`,classFound:!0}}},[r]);return t.length===0?q.jsx("div",{className:"rf-p-4",children:q.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:q.jsxs("div",{className:"rf-p-4",children:[q.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),q.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."})]})})}):q.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[q.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[q.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(s=>{const a=o.get(s),c=e===s;return q.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${c?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>n(s),children:(()=>{const l=cFo(a.solverName);return q.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[q.jsx(l,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),q.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[q.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:a.componentName}),q.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:a.solverName})]})]})})()},s)})]}),q.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:r?A.instance?q.jsxs("div",{className:"rf-flex rf-h-full rf-flex-col rf-overflow-y-auto",children:[q.jsx(gFo,{solverEvent:r}),q.jsx("div",{className:"rf-min-h-0 rf-flex-1",children:q.jsx(rS,{fallback:q.jsx("div",{className:"rf-p-4",children:q.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[q.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),q.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",r.solverName]})]})}),children:q.jsx(rFo,{solver:A.instance})})})]}):q.jsxs("div",{className:"rf-p-4",children:[q.jsxs("div",{className:"rf-mb-4",children:[q.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:r.solverName}),q.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",r.componentName]})]}),A.error&&q.jsx("div",{className:`rf-rounded-md rf-border rf-p-4 rf-mb-4 ${A.classFound?"rf-bg-red-50 rf-border-red-200":"rf-bg-yellow-50 rf-border-yellow-200"}`,children:q.jsx("p",{className:`rf-text-sm ${A.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:A.error})}),q.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[q.jsxs("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50 rf-flex rf-items-center rf-justify-between rf-gap-2",children:[q.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"}),q.jsxs("div",{className:"rf-flex rf-items-center rf-gap-1",children:[q.jsx(uFo,{solverEvent:r}),q.jsx(_c,{type:"button",variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8","aria-label":"Download solver input JSON",title:"Download solver input JSON",onClick:()=>X7t(r),children:q.jsx(JMe,{className:"rf-w-4 rf-h-4"})})]})]}),q.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:q.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)})})]})]}):q.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:q.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},$7t=({errorMessage:t,errorStack:e,circuitJsonErrors:n})=>{ee.useEffect(()=>{if(t){const o=new Error(t);e&&(o.stack=e);try{k6.captureException(o)}catch{}}},[t,e]),ee.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{k6.captureException(i,{error_type:o.type})}catch{}}},[n])},hFo=t=>{ee.useEffect(()=>{try{cKt(t)}catch{}},[t.source,t.component,t.isWebEmbedded,t.activeTab])},Z7t="0.0.2347",_Fo={version:Z7t},d3e={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},h3e=new Map,Ooe=t=>{const e=h3e.get(t);return e?Object.fromEntries(Object.entries(e.stores).map(([n,o])=>[n,o.getState()])):{}},mFo=(t,e,n)=>{if(t===void 0)return{type:"untracked",connection:e.connect(n)};const o=h3e.get(n.name);if(o)return{type:"tracked",store:t,...o};const i={connection:e.connect(n),stores:{}};return h3e.set(n.name,i),{type:"tracked",store:t,...i}},eNt=(t,e={})=>(n,o,i)=>{const{enabled:r,anonymousActionType:A,store:s,...a}=e;let c;try{c=(r??(d3e?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!c)return(d3e?"production":void 0)!=="production"&&r&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),t(n,o,i);const{connection:l,...g}=mFo(s,c,a);let u=!0;i.setState=(_,p,m)=>{const C=n(_,p);if(!u)return C;const I=m===void 0?{type:A||"anonymous"}:typeof m=="string"?{type:m}:m;return s===void 0?(l?.send(I,o()),C):(l?.send({...I,type:`${s}/${I.type}`},{...Ooe(a.name),[s]:i.getState()}),C)};const h=(..._)=>{const p=u;u=!1,n(..._),u=p},d=t(i.setState,o,i);if(g.type==="untracked"?l?.init(d):(g.stores[g.store]=i,l?.init(Object.fromEntries(Object.entries(g.stores).map(([_,p])=>[_,_===g.store?d:p.getState()])))),i.dispatchFromDevtools&&typeof i.dispatch=="function"){let _=!1;const p=i.dispatch;i.dispatch=(...m)=>{(d3e?"production":void 0)!=="production"&&m[0].type==="__setState"&&!_&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),_=!0),p(...m)}}return l.subscribe(_=>{var p;switch(_.type){case"ACTION":if(typeof _.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return _3e(_.payload,m=>{if(m.type==="__setState"){if(s===void 0){h(m.state);return}Object.keys(m.state).length!==1&&console.error(`
5789
+ `,g=new Blob([l],{type:"text/plain"}),u=URL.createObjectURL(g),h=document.createElement("a");h.href=u,h.download=`${c}.test.ts`,h.click(),URL.revokeObjectURL(u)}catch(a){alert(`Error generating test.ts for ${t.constructor.name}: ${a instanceof Error?a.message:String(a)}`)}o(!1)};return q.jsxs("div",{className:`relative ${e}`,ref:i,children:[q.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&&q.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:[q.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download JSON"}),q.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:A,children:"Download page.tsx"}),q.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download test.ts"})]})]})},z7t=t=>t.activeSubSolver?[t,...z7t(t.activeSubSolver)]:[t],Jko=({solver:t})=>{const e=z7t(t);return q.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:e.map((n,o)=>q.jsxs("div",{className:"flex items-center",children:[o>0&&q.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),q.jsx(Vko,{solver:n})]},n.constructor.name))})},qko=({solver:t,triggerRender:e,animationSpeed:n=25,onSolverStarted:o,onSolverCompleted:i})=>{const[r,A]=ee.useReducer(_=>!_,!1),s=ee.useRef(void 0),a=()=>{!t.solved&&!t.failed&&(t.step(),e())},c=()=>{!t.solved&&!t.failed&&(o&&o(t),t.solve(),e(),i&&i(t))},l=()=>{r?(s.current&&(clearInterval(s.current),s.current=void 0),A()):(A(),s.current=setInterval(()=>{if(t.solved||t.failed){s.current&&(clearInterval(s.current),s.current=void 0),A(),e(),i&&t.solved&&i(t);return}t.step(),e()},n))},g=()=>{const _=t;if(_.getCurrentPhase&&!t.solved&&!t.failed){const p=_.getCurrentPhase();for(;_.getCurrentPhase()===p&&!t.solved&&!t.failed;)t.step();e()}},u=()=>{if(t.solved||t.failed||r)return;const _=window.prompt("Step until which iteration?",`${t.iterations}`);if(_===null)return;const p=Number(_);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)};ee.useEffect(()=>()=>{s.current&&clearInterval(s.current)},[]),ee.useEffect(()=>{(t.solved||t.failed)&&r&&(s.current&&(clearInterval(s.current),s.current=void 0),A())},[t.solved,t.failed,r]);const h=t.getCurrentPhase!==void 0,d=h?t.getCurrentPhase():null;return q.jsxs("div",{className:"space-y-2 p-2 border-b",children:[q.jsx("div",{className:"flex items-center",children:q.jsx(Jko,{solver:t})}),q.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[q.jsx("button",{onClick:a,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"}),q.jsx("button",{onClick:c,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"}),q.jsx("button",{onClick:l,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"}),q.jsx("button",{onClick:u,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"}),h&&q.jsx("button",{onClick:g,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"}),q.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&q.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),d&&q.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",q.jsx("span",{className:"font-medium",children:d})]}),t.solved&&q.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&q.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&q.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},Wko=(t,e,n)=>{const o=t.currentPipelineStepIndex;return e<o?"Completed":e===o&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},jko=(t,e)=>{const o=t.pipelineDef[e].solverName,i=Wko(t,e),r=t[o],A=t.firstIterationOfPhase?.[o]??null,s=t.iterations;let a=0;if(i==="Completed"){const u=t.pipelineDef[e+1],h=u?t.firstIterationOfPhase?.[u.solverName]:void 0;h!==void 0&&A!==null?a=h-A:A!==null&&(a=s-A)}else i==="In Progress"&&A!==null&&(a=s-A);const c=t.timeSpentOnPhase?.[o]??0;let l=0;i==="Completed"?l=1:i==="In Progress"&&r&&(l=r.progress??0);const g=r?.stats??null;return{index:e,name:o,status:i,firstIteration:A,iterations:a,progress:l,timeSpent:c,stats:g&&Object.keys(g).length>0?g:null,solverInstance:r??null}},Xko=({status:t})=>{const e={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return q.jsx("span",{className:`font-medium ${e[t]}`,children:t})},$ko=({progress:t})=>{if(t===0)return null;const e=Math.round(t*100);return q.jsxs("div",{className:"flex items-center gap-2",children:[q.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:q.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${e}%`}})}),q.jsxs("span",{className:"text-xs text-gray-500",children:[e,"%"]})]})},Zko=t=>Object.entries(t).map(([e,n])=>`${e}: ${n}`).join(", "),eFo=({stats:t})=>{if(!t||Object.keys(t).length===0)return q.jsx("span",{children:"-"});const e=Object.entries(t),n=Zko(t);return q.jsxs("details",{className:"cursor-pointer",children:[q.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:n}),q.jsx("div",{className:"mt-1 text-xs",children:e.map(([o,i])=>q.jsxs("div",{children:[o,": ",String(i)]},o))})]})},u3e=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(u3e);const e={};for(const[n,o]of Object.entries(t))n.startsWith("_")||(e[n]=u3e(o));return e},tFo=(t,e)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${e}`);return}const n=u3e(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)}`)}},nFo=({solver:t,onStepUntilPhase:e,onDownloadInput:n})=>{const o=t.pipelineDef.map((s,a)=>jko(t,a)),i=s=>{e?.(s)},r=s=>{s.solverInstance&&(n?n(s.solverInstance,s.name):tFo(s.solverInstance,s.name))},A=s=>`${(s/1e3).toFixed(2)}s`;return q.jsxs("div",{className:"border-t border-gray-200",children:[q.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:q.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),q.jsx("div",{className:"overflow-x-auto",children:q.jsxs("table",{className:"w-full text-sm",children:[q.jsx("thead",{children:q.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[q.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),q.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),q.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",q.jsx("sub",{children:"0"})]}),q.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),q.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),q.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),q.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),q.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),q.jsx("tbody",{children:o.map(s=>q.jsxs("tr",{className:`border-b border-gray-100 ${s.status==="In Progress"?"bg-yellow-50":""}`,children:[q.jsx("td",{className:"px-4 py-2",children:q.jsxs("div",{className:"flex items-center gap-2",children:[q.jsx("span",{className:"text-gray-400 w-6",children:String(s.index+1).padStart(2,"0")}),q.jsx("button",{onClick:()=>i(s.name),disabled:s.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 ${s.name} completes`,children:q.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:q.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"})})}),q.jsx("span",{className:"font-medium text-gray-900",children:s.name})]})}),q.jsx("td",{className:"px-4 py-2",children:q.jsx(Xko,{status:s.status})}),q.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:s.firstIteration!==null?s.firstIteration:""}),q.jsx("td",{className:"px-4 py-2 text-gray-600",children:s.iterations}),q.jsx("td",{className:"px-4 py-2",children:q.jsx($ko,{progress:s.progress})}),q.jsx("td",{className:"px-4 py-2 text-gray-600",children:A(s.timeSpent)}),q.jsx("td",{className:"px-4 py-2 text-gray-500",children:q.jsx(eFo,{stats:s.stats})}),q.jsx("td",{className:"px-4 py-2",children:s.solverInstance?q.jsxs("button",{onClick:()=>r(s),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${s.name}`,children:[q.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:q.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"})}),q.jsx("span",{children:"Input"})]}):null})]},s.name))})]})})]})},oFo=class extends Xr.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 iFo({graphics:t}){const e=t.points??[],n=t.lines??[],o=t.rects??[],i=t.circles??[],r=t.texts??[];let A=Number.POSITIVE_INFINITY,s=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,c=Number.NEGATIVE_INFINITY;const l=(p,m)=>{typeof p=="number"&&(p<A&&(A=p),p>a&&(a=p)),typeof m=="number"&&(m<s&&(s=m),m>c&&(c=m))};for(const p of e)l(p.x,p.y);for(const p of n){const m=p.points??[];for(const C of m)l(C.x,C.y)}for(const p of o){const m=p.x??0,C=p.y??0,I=p.width??0,f=p.height??0;l(m,C),l(m+I,C+f)}for(const p of i){const m=p.x??0,C=p.y??0,I=p.radius??1;l(m-I,C-I),l(m+I,C+I)}for(const p of r)l(p.x,p.y);(!isFinite(A)||!isFinite(s)||!isFinite(a)||!isFinite(c))&&(A=-20,s=-20,a=20,c=20);const g=10,u=A-g,h=s-g,d=Math.max(1,a-A+2*g),_=Math.max(1,c-s+2*g);return q.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${u} ${h} ${d} ${_}`,role:"img","aria-label":"Graphics fallback",children:[o.map((p,m)=>q.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-${m}`)),n.map((p,m)=>q.jsx("polyline",{fill:"none",stroke:p.strokeColor??"black",strokeWidth:p.strokeWidth??1,points:(p.points??[]).map(C=>`${C.x??0},${C.y??0}`).join(" ")},`line-${m}`)),i.map((p,m)=>q.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-${m}`)),e.map((p,m)=>q.jsx("circle",{cx:p.x??0,cy:p.y??0,r:p.radius??1.5,fill:p.color??"black"},`point-${m}`)),r.map((p,m)=>q.jsx("text",{x:p.x??0,y:p.y??0,fontSize:p.fontSize??10,fill:p.color??"black",children:p.text??""},`text-${m}`))]})}var rFo=({solver:t,animationSpeed:e=25,onSolverStarted:n,onSolverCompleted:o})=>{const[i,r]=ee.useReducer(l=>l+1,0),A=ee.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(l){return console.error("Visualization error:",l),{points:[],lines:[],rects:[],circles:[]}}},[t,i]),s=ee.useMemo(()=>(A.rects?.length||0)===0&&(A.lines?.length||0)===0&&(A.points?.length||0)===0&&(A.circles?.length||0)===0,[A]);ee.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const l=document.createElement("script");l.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(l)}},[]);const a=t.pipelineDef!==void 0,c=l=>{const g=t;if(!t.solved&&!t.failed){for(;!t.solved&&!t.failed&&g.currentPipelineStepIndex<=g.pipelineDef.findIndex(u=>u.solverName===l);)t.step();r()}};return q.jsxs("div",{children:[q.jsx(qko,{solver:t,triggerRender:r,animationSpeed:e,onSolverStarted:n,onSolverCompleted:o}),s?q.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):q.jsx(oFo,{fallback:q.jsx(iFo,{graphics:A}),children:q.jsx(zko,{graphics:A})}),a&&q.jsx(nFo,{solver:t,onStepUntilPhase:c})]})};const AFo=()=>{ee.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)},[])},sFo=1e3,IS=(t,e)=>{const{fileName:n,mimeType:o="text/plain"}=e,i=t instanceof Blob?t:new Blob([t],{type:o}),r=URL.createObjectURL(i),A=document.createElement("a");A.href=r,A.download=n,A.target="_blank",A.rel="noopener noreferrer",A.style.display="none",document.body.appendChild(A),A.click(),document.body.removeChild(A),setTimeout(()=>{URL.revokeObjectURL(r)},sFo)},V7t=t=>{let e=t.trim().replace(/[\\/:*?"<>|]/g,"_").replace(/[\x00-\x1f]/g,"").replace(/^\.+/,"").replace(/\.+$/,"").replace(/\s+/g," ").replace(/_+/g,"_");return/^(con|prn|aux|nul|com[0-9]|lpt[0-9])$/i.test(e)&&(e=`_${e}`),e=e.slice(0,200),e||"untitled"},CS="https://github.com/tscircuit/tscircuit-autorouter/issues/new",J7t="https://github.com/tscircuit/copper-pour-solver/issues/new",q7t="https://github.com/tscircuit/calculate-packing/issues/new",W7t="https://github.com/tscircuit/schematic-trace-solver/issues/new?template=json-bug-report.yml",aFo={PackSolver2:q7t,AutoroutingPipelineSolver:CS,AssignableAutoroutingPipeline2:CS,AssignableAutoroutingPipeline3:CS,AutoroutingPipeline1_OriginalUnravel:CS,AutoroutingPipelineSolver3_HgPortPointPathing:CS,AutoroutingPipelineSolver4:CS,AutoroutingPipelineSolver5:CS,AutoroutingPipelineSolver7_MultiGraph:CS,AutoroutingPipelineSolver8:CS,CopperPourPipelineSolver:J7t,SchematicTracePipelineSolver:W7t},cFo=t=>t.toLowerCase().includes("pack")?ODo:t.toLowerCase().includes("rout")?qDo:RDo,j7t=t=>{const e=aFo[t];if(e)return e;const n=t.toLowerCase();return n.includes("autorout")?CS:n.includes("schematic")&&n.includes("trace")?W7t:n.includes("copperpour")?J7t:n.includes("pack")?q7t:null},lFo=t=>`${V7t(`${t.componentName}-${t.solverName}`)}-solver-input.json`,X7t=t=>{IS(JSON.stringify(t.solverParams,null,2),{fileName:lFo(t),mimeType:"application/json"})},gFo=({solverEvent:t})=>{const e=j7t(t.solverName);return q.jsxs("div",{className:"rf-flex rf-items-center rf-justify-end rf-gap-2 rf-border-b rf-border-gray-200 rf-bg-gray-50 rf-px-4 rf-py-2",children:[q.jsxs(_c,{type:"button",variant:"outline",size:"sm",onClick:()=>X7t(t),children:[q.jsx(JMe,{className:"rf-w-4 rf-h-4"}),"Download"]}),e?q.jsx(_c,{asChild:!0,variant:"outline",size:"sm",children:q.jsxs("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:[q.jsx(fne,{className:"rf-w-4 rf-h-4"}),"Report"]})}):q.jsxs(_c,{type:"button",variant:"outline",size:"sm",disabled:!0,title:"No report link configured for this solver",children:[q.jsx(fne,{className:"rf-w-4 rf-h-4"}),"Report"]})]})},uFo=({solverEvent:t})=>{const e=j7t(t.solverName);return e?q.jsx(_c,{asChild:!0,variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8",children:q.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",title:"Report solver bug","aria-label":"Report solver bug",children:q.jsx(fne,{className:"rf-w-4 rf-h-4"})})}):q.jsx(_c,{type:"button",variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8",disabled:!0,title:"No report link configured for this solver","aria-label":"Report solver bug",children:q.jsx(fne,{className:"rf-w-4 rf-h-4"})})},dFo=({solverEvents:t=[]})=>{const[e,n]=ee.useState(null);AFo();const o=ee.useMemo(()=>{const s=new Map;for(const a of t){const c=`${a.componentName}-${a.solverName}`;s.set(c,a)}return s},[t]),i=ee.useMemo(()=>Array.from(o.keys()),[o]),r=e?o.get(e):null,A=ee.useMemo(()=>{if(!r)return{instance:null,error:null,classFound:!1};const s=kye[r.solverName];if(!s)return{instance:null,error:`Solver class "${r.solverName}" not found in SOLVERS registry. Available: ${Object.keys(kye).join(", ")}`,classFound:!1};try{const a=r.solverParams,c=a?.input!==void 0?a.input:a;return{instance:new s(c),error:null,classFound:!0}}catch(a){const c=a instanceof Error?a.message:String(a);return console.error("Failed to reconstruct solver:",a),{instance:null,error:`Failed to instantiate solver: ${c}`,classFound:!0}}},[r]);return t.length===0?q.jsx("div",{className:"rf-p-4",children:q.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:q.jsxs("div",{className:"rf-p-4",children:[q.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),q.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."})]})})}):q.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[q.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[q.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(s=>{const a=o.get(s),c=e===s;return q.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${c?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>n(s),children:(()=>{const l=cFo(a.solverName);return q.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[q.jsx(l,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),q.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[q.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:a.componentName}),q.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:a.solverName})]})]})})()},s)})]}),q.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:r?A.instance?q.jsxs("div",{className:"rf-flex rf-h-full rf-flex-col rf-overflow-y-auto",children:[q.jsx(gFo,{solverEvent:r}),q.jsx("div",{className:"rf-min-h-0 rf-flex-1",children:q.jsx(rS,{fallback:q.jsx("div",{className:"rf-p-4",children:q.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[q.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),q.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",r.solverName]})]})}),children:q.jsx(rFo,{solver:A.instance})})})]}):q.jsxs("div",{className:"rf-p-4",children:[q.jsxs("div",{className:"rf-mb-4",children:[q.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:r.solverName}),q.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",r.componentName]})]}),A.error&&q.jsx("div",{className:`rf-rounded-md rf-border rf-p-4 rf-mb-4 ${A.classFound?"rf-bg-red-50 rf-border-red-200":"rf-bg-yellow-50 rf-border-yellow-200"}`,children:q.jsx("p",{className:`rf-text-sm ${A.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:A.error})}),q.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[q.jsxs("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50 rf-flex rf-items-center rf-justify-between rf-gap-2",children:[q.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"}),q.jsxs("div",{className:"rf-flex rf-items-center rf-gap-1",children:[q.jsx(uFo,{solverEvent:r}),q.jsx(_c,{type:"button",variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8","aria-label":"Download solver input JSON",title:"Download solver input JSON",onClick:()=>X7t(r),children:q.jsx(JMe,{className:"rf-w-4 rf-h-4"})})]})]}),q.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:q.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)})})]})]}):q.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:q.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},$7t=({errorMessage:t,errorStack:e,circuitJsonErrors:n})=>{ee.useEffect(()=>{if(t){const o=new Error(t);e&&(o.stack=e);try{k6.captureException(o)}catch{}}},[t,e]),ee.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{k6.captureException(i,{error_type:o.type})}catch{}}},[n])},hFo=t=>{ee.useEffect(()=>{try{cKt(t)}catch{}},[t.source,t.component,t.isWebEmbedded,t.activeTab])},Z7t="0.0.2348",_Fo={version:Z7t},d3e={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},h3e=new Map,Ooe=t=>{const e=h3e.get(t);return e?Object.fromEntries(Object.entries(e.stores).map(([n,o])=>[n,o.getState()])):{}},mFo=(t,e,n)=>{if(t===void 0)return{type:"untracked",connection:e.connect(n)};const o=h3e.get(n.name);if(o)return{type:"tracked",store:t,...o};const i={connection:e.connect(n),stores:{}};return h3e.set(n.name,i),{type:"tracked",store:t,...i}},eNt=(t,e={})=>(n,o,i)=>{const{enabled:r,anonymousActionType:A,store:s,...a}=e;let c;try{c=(r??(d3e?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!c)return(d3e?"production":void 0)!=="production"&&r&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),t(n,o,i);const{connection:l,...g}=mFo(s,c,a);let u=!0;i.setState=(_,p,m)=>{const C=n(_,p);if(!u)return C;const I=m===void 0?{type:A||"anonymous"}:typeof m=="string"?{type:m}:m;return s===void 0?(l?.send(I,o()),C):(l?.send({...I,type:`${s}/${I.type}`},{...Ooe(a.name),[s]:i.getState()}),C)};const h=(..._)=>{const p=u;u=!1,n(..._),u=p},d=t(i.setState,o,i);if(g.type==="untracked"?l?.init(d):(g.stores[g.store]=i,l?.init(Object.fromEntries(Object.entries(g.stores).map(([_,p])=>[_,_===g.store?d:p.getState()])))),i.dispatchFromDevtools&&typeof i.dispatch=="function"){let _=!1;const p=i.dispatch;i.dispatch=(...m)=>{(d3e?"production":void 0)!=="production"&&m[0].type==="__setState"&&!_&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),_=!0),p(...m)}}return l.subscribe(_=>{var p;switch(_.type){case"ACTION":if(typeof _.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return _3e(_.payload,m=>{if(m.type==="__setState"){if(s===void 0){h(m.state);return}Object.keys(m.state).length!==1&&console.error(`
5790
5790
  [zustand devtools middleware] Unsupported __setState action format.
5791
5791
  When using 'store' option in devtools(), the 'state' should have only one key, which is a value of 'store' that was passed in devtools(),
5792
5792
  and value of this only key should be a state object. Example: { "type": "__setState", "state": { "abc123Store": { "foo": "bar" } } }