@tscircuit/runframe 0.0.2351 → 0.0.2352

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.
@@ -2181,7 +2181,7 @@ var usePostHogActivity = (properties) => {
2181
2181
  };
2182
2182
 
2183
2183
  // package.json
2184
- var version = "0.0.2349";
2184
+ var version = "0.0.2351";
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-CBTV7MXK.js";
10
+ } from "./chunk-6DCKAWL6.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-CBTV7MXK.js";
42
+ } from "./chunk-6DCKAWL6.js";
43
43
 
44
44
  // lib/components/RunFrame/RunFrame.tsx
45
45
  import { createCircuitWebWorker } from "@tscircuit/eval/worker";
@@ -54,7 +54,8 @@ import { AlertTriangle } from "lucide-react";
54
54
  import { jsx, jsxs } from "react/jsx-runtime";
55
55
  var RunFrameErrorFallback = ({
56
56
  error,
57
- resetErrorBoundary
57
+ resetErrorBoundary,
58
+ componentStack
58
59
  }) => {
59
60
  const resolvedError = error instanceof Error ? error : new Error(String(error));
60
61
  return /* @__PURE__ */ jsx("section", { className: "rf-h-full rf-w-full rf-grid rf-place-items-center", children: /* @__PURE__ */ jsx("div", { className: "rf-min-h-full rf-flex rf-items-center rf-justify-center rf-px-4", children: /* @__PURE__ */ jsxs("div", { className: "rf-max-w-lg rf-w-full rf-text-center", children: [
@@ -66,6 +67,10 @@ var RunFrameErrorFallback = ({
66
67
  resolvedError.stack && /* @__PURE__ */ jsxs("details", { className: "rf-text-center rf-mb-6", children: [
67
68
  /* @__PURE__ */ jsx("summary", { className: "rf-text-xs rf-text-gray-500 rf-cursor-pointer hover:rf-text-gray-700", children: "View stack trace" }),
68
69
  /* @__PURE__ */ jsx("pre", { className: "rf-text-xs rf-font-mono no-scrollbar rf-whitespace-pre-wrap rf-text-gray-500 rf-bg-gray-100 rf-p-3 rf-rounded-lg rf-mt-2 rf-overflow-auto rf-text-left rf-max-h-[150px]", children: resolvedError.stack })
70
+ ] }),
71
+ componentStack && /* @__PURE__ */ jsxs("details", { className: "rf-text-center rf-mb-6", children: [
72
+ /* @__PURE__ */ jsx("summary", { className: "rf-text-xs rf-text-gray-500 rf-cursor-pointer hover:rf-text-gray-700", children: "View component stack" }),
73
+ /* @__PURE__ */ jsx("pre", { className: "rf-text-xs rf-font-mono no-scrollbar rf-whitespace-pre-wrap rf-text-gray-500 rf-bg-gray-100 rf-p-3 rf-rounded-lg rf-mt-2 rf-overflow-auto rf-text-left rf-max-h-[150px]", children: componentStack })
69
74
  ] })
70
75
  ] }),
71
76
  /* @__PURE__ */ jsxs("div", { className: "rf-flex rf-flex-col rf-gap-2 rf-justify-center", children: [
@@ -323,6 +328,7 @@ var RunFrame = (props) => {
323
328
  const circuitJson = useRunFrameStore((s) => s.circuitJson);
324
329
  const setCircuitJson = useRunFrameStore((s) => s.setCircuitJson);
325
330
  const [error, setError] = useState(null);
331
+ const [componentStack, setComponentStack] = useState(null);
326
332
  const cancelExecutionRef = useRef2(null);
327
333
  const [autoroutingGraphics, setAutoroutingGraphics] = useState(null);
328
334
  const [runCountTrigger, incRunCountTrigger] = useReducer(
@@ -740,122 +746,138 @@ var RunFrame = (props) => {
740
746
  if (props.isLoadingFiles) {
741
747
  return /* @__PURE__ */ jsx3(LoadingSkeleton, {});
742
748
  }
743
- return /* @__PURE__ */ jsx3(ErrorBoundary, { FallbackComponent: RunFrameErrorFallback, children: /* @__PURE__ */ jsx3(
744
- CircuitJsonPreview,
749
+ return /* @__PURE__ */ jsx3(
750
+ ErrorBoundary,
745
751
  {
746
- code: fsMap.get(props.entrypoint ?? props.mainComponentPath),
747
- fsMap,
748
- defaultActiveTab: props.defaultActiveTab ?? props.defaultTab,
749
- defaultTab: props.defaultTab,
750
- availableTabs: props.availableTabs,
751
- schematicSvgOptions: props.schematicSvgOptions,
752
- showToggleFullScreen: props.showToggleFullScreen,
753
- autoroutingGraphics,
754
- autoroutingLog,
755
- onReportAutoroutingLog: props.onReportAutoroutingLog || handleReportAutoroutingLog,
756
- leftHeaderContent: /* @__PURE__ */ jsxs3(Fragment, { children: [
757
- props.showRunButton && /* @__PURE__ */ jsx3(TooltipProvider, { children: /* @__PURE__ */ jsxs3(Tooltip, { children: [
758
- /* @__PURE__ */ jsx3(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxs3("div", { className: "rf-relative rf-inline-flex", children: [
759
- /* @__PURE__ */ jsxs3(
760
- "button",
761
- {
762
- type: "button",
763
- onClick: () => {
764
- incRunCountTrigger(1);
765
- },
766
- className: "rf-flex rf-items-center rf-gap-2 rf-px-4 rf-py-2 rf-bg-blue-600 hover:rf-bg-blue-700 rf-text-white rf-rounded-md disabled:rf-opacity-50 transition-colors duration-200",
767
- disabled: isRunning || !dependenciesLoaded,
768
- children: [
769
- "Run",
770
- " ",
771
- isRunning || !dependenciesLoaded ? /* @__PURE__ */ jsx3(Loader2, { className: "rf-w-3 rf-h-3 rf-animate-spin" }) : /* @__PURE__ */ jsx3(Play, { className: "rf-w-3 rf-h-3" })
772
- ]
773
- }
774
- ),
775
- isRunning && /* @__PURE__ */ jsx3("div", { className: "rf-flex rf-items-center rf-ml-1", children: /* @__PURE__ */ jsx3(
776
- Button,
777
- {
778
- onClick: (e) => {
779
- e.stopPropagation();
780
- setIsRunning(false);
781
- setRenderLog(null);
782
- setError(null);
783
- if (cancelExecutionRef.current) {
784
- cancelExecutionRef.current();
785
- cancelExecutionRef.current = null;
786
- }
787
- runMutex.cancel();
788
- setActiveAsyncEffects({});
789
- if (globalThis.runFrameWorker) {
790
- globalThis.runFrameWorker.kill();
791
- globalThis.runFrameWorker = null;
752
+ onError: (_error, info) => {
753
+ setComponentStack(info.componentStack ?? null);
754
+ },
755
+ onReset: () => setComponentStack(null),
756
+ fallbackRender: (fallbackProps) => /* @__PURE__ */ jsx3(
757
+ RunFrameErrorFallback,
758
+ {
759
+ ...fallbackProps,
760
+ componentStack
761
+ }
762
+ ),
763
+ children: /* @__PURE__ */ jsx3(
764
+ CircuitJsonPreview,
765
+ {
766
+ code: fsMap.get(props.entrypoint ?? props.mainComponentPath),
767
+ fsMap,
768
+ defaultActiveTab: props.defaultActiveTab ?? props.defaultTab,
769
+ defaultTab: props.defaultTab,
770
+ availableTabs: props.availableTabs,
771
+ schematicSvgOptions: props.schematicSvgOptions,
772
+ showToggleFullScreen: props.showToggleFullScreen,
773
+ autoroutingGraphics,
774
+ autoroutingLog,
775
+ onReportAutoroutingLog: props.onReportAutoroutingLog || handleReportAutoroutingLog,
776
+ leftHeaderContent: /* @__PURE__ */ jsxs3(Fragment, { children: [
777
+ props.showRunButton && /* @__PURE__ */ jsx3(TooltipProvider, { children: /* @__PURE__ */ jsxs3(Tooltip, { children: [
778
+ /* @__PURE__ */ jsx3(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxs3("div", { className: "rf-relative rf-inline-flex", children: [
779
+ /* @__PURE__ */ jsxs3(
780
+ "button",
781
+ {
782
+ type: "button",
783
+ onClick: () => {
784
+ incRunCountTrigger(1);
785
+ },
786
+ className: "rf-flex rf-items-center rf-gap-2 rf-px-4 rf-py-2 rf-bg-blue-600 hover:rf-bg-blue-700 rf-text-white rf-rounded-md disabled:rf-opacity-50 transition-colors duration-200",
787
+ disabled: isRunning || !dependenciesLoaded,
788
+ children: [
789
+ "Run",
790
+ " ",
791
+ isRunning || !dependenciesLoaded ? /* @__PURE__ */ jsx3(Loader2, { className: "rf-w-3 rf-h-3 rf-animate-spin" }) : /* @__PURE__ */ jsx3(Play, { className: "rf-w-3 rf-h-3" })
792
+ ]
792
793
  }
793
- },
794
- variant: "ghost",
795
- size: "icon",
796
- className: "rf-text-red-300 hover:rf-text-red-400 hover:!rf-bg-transparent [&>svg]:rf-text-red-300 [&>svg]:hover:rf-text-red-400 rf-flex rf-items-center rf-justify-center",
797
- children: /* @__PURE__ */ jsx3(
798
- Square,
794
+ ),
795
+ isRunning && /* @__PURE__ */ jsx3("div", { className: "rf-flex rf-items-center rf-ml-1", children: /* @__PURE__ */ jsx3(
796
+ Button,
799
797
  {
800
- className: "!rf-h-2.5 !rf-w-2.5",
801
- fill: "currentColor",
802
- stroke: "currentColor"
798
+ onClick: (e) => {
799
+ e.stopPropagation();
800
+ setIsRunning(false);
801
+ setRenderLog(null);
802
+ setError(null);
803
+ if (cancelExecutionRef.current) {
804
+ cancelExecutionRef.current();
805
+ cancelExecutionRef.current = null;
806
+ }
807
+ runMutex.cancel();
808
+ setActiveAsyncEffects({});
809
+ if (globalThis.runFrameWorker) {
810
+ globalThis.runFrameWorker.kill();
811
+ globalThis.runFrameWorker = null;
812
+ }
813
+ },
814
+ variant: "ghost",
815
+ size: "icon",
816
+ className: "rf-text-red-300 hover:rf-text-red-400 hover:!rf-bg-transparent [&>svg]:rf-text-red-300 [&>svg]:hover:rf-text-red-400 rf-flex rf-items-center rf-justify-center",
817
+ children: /* @__PURE__ */ jsx3(
818
+ Square,
819
+ {
820
+ className: "!rf-h-2.5 !rf-w-2.5",
821
+ fill: "currentColor",
822
+ stroke: "currentColor"
823
+ }
824
+ )
803
825
  }
804
- )
826
+ ) })
827
+ ] }) }),
828
+ /* @__PURE__ */ jsx3(
829
+ TooltipContent,
830
+ {
831
+ sideOffset: 8,
832
+ className: "rf-p-0 rf-bg-transparent rf-border-none rf-shadow-none rf-pointer-events-none",
833
+ children: /* @__PURE__ */ jsxs3("div", { className: "rf-flex rf-items-center rf-gap-2 rf-px-2.5 rf-py-1.5 rf-bg-slate-900 rf-rounded-md rf-shadow-xl rf-border rf-border-slate-800/60", children: [
834
+ /* @__PURE__ */ jsx3("kbd", { className: "rf-bg-slate-800 rf-px-1.5 rf-py-0.5 rf-rounded rf-text-[10px] rf-font-sans rf-font-medium rf-border rf-border-slate-700 rf-text-slate-200 rf-leading-none", children: "Ctrl" }),
835
+ /* @__PURE__ */ jsx3("span", { className: "rf-text-slate-500 rf-text-[11px] rf-font-medium rf-leading-none", children: "+" }),
836
+ /* @__PURE__ */ jsx3("kbd", { className: "rf-bg-slate-800 rf-px-1.5 rf-py-0.5 rf-rounded rf-text-[10px] rf-font-sans rf-font-medium rf-border rf-border-slate-700 rf-text-slate-200 rf-leading-none", children: "Enter" })
837
+ ] })
838
+ }
839
+ )
840
+ ] }) }),
841
+ props.showFileMenu !== false && /* @__PURE__ */ jsx3(
842
+ FileMenuLeftHeader,
843
+ {
844
+ isWebEmbedded: props.isWebEmbedded,
845
+ onLoginRequired: props.onLoginRequired,
846
+ showSchematicDebugGrid,
847
+ onChangeShowSchematicDebugGrid: setShowSchematicDebugGrid,
848
+ showSchematicPorts,
849
+ onChangeShowSchematicPorts: setShowSchematicPorts,
850
+ autoroutingLog,
851
+ onReportAutoroutingLog: props.onReportAutoroutingLog || handleReportAutoroutingLog
805
852
  }
806
- ) })
807
- ] }) }),
808
- /* @__PURE__ */ jsx3(
809
- TooltipContent,
810
- {
811
- sideOffset: 8,
812
- className: "rf-p-0 rf-bg-transparent rf-border-none rf-shadow-none rf-pointer-events-none",
813
- children: /* @__PURE__ */ jsxs3("div", { className: "rf-flex rf-items-center rf-gap-2 rf-px-2.5 rf-py-1.5 rf-bg-slate-900 rf-rounded-md rf-shadow-xl rf-border rf-border-slate-800/60", children: [
814
- /* @__PURE__ */ jsx3("kbd", { className: "rf-bg-slate-800 rf-px-1.5 rf-py-0.5 rf-rounded rf-text-[10px] rf-font-sans rf-font-medium rf-border rf-border-slate-700 rf-text-slate-200 rf-leading-none", children: "Ctrl" }),
815
- /* @__PURE__ */ jsx3("span", { className: "rf-text-slate-500 rf-text-[11px] rf-font-medium rf-leading-none", children: "+" }),
816
- /* @__PURE__ */ jsx3("kbd", { className: "rf-bg-slate-800 rf-px-1.5 rf-py-0.5 rf-rounded rf-text-[10px] rf-font-sans rf-font-medium rf-border rf-border-slate-700 rf-text-slate-200 rf-leading-none", children: "Enter" })
817
- ] })
818
- }
819
- )
820
- ] }) }),
821
- props.showFileMenu !== false && /* @__PURE__ */ jsx3(
822
- FileMenuLeftHeader,
823
- {
824
- isWebEmbedded: props.isWebEmbedded,
825
- onLoginRequired: props.onLoginRequired,
826
- showSchematicDebugGrid,
827
- onChangeShowSchematicDebugGrid: setShowSchematicDebugGrid,
828
- showSchematicPorts,
829
- onChangeShowSchematicPorts: setShowSchematicPorts,
830
- autoroutingLog,
831
- onReportAutoroutingLog: props.onReportAutoroutingLog || handleReportAutoroutingLog
832
- }
833
- ),
834
- props.leftHeaderContent
835
- ] }),
836
- onActiveTabChange: setActiveTab,
837
- circuitJson,
838
- renderLog,
839
- activeEffectName,
840
- isRunningCode: isRunning,
841
- errorMessage: error?.error,
842
- errorStack: error?.stack,
843
- onEditEvent: handleEditEvent,
844
- editEvents: props.editEvents,
845
- onPcbBoundsSelected: props.onPcbBoundsSelected,
846
- defaultToFullScreen: props.defaultToFullScreen,
847
- onRerunWithDebug: (debugOption) => {
848
- setCurrentDebugOption(debugOption || "");
849
- incRunCountTrigger(1);
850
- },
851
- solverEvents,
852
- isCli: props.isCli,
853
- showSchematicDebugGrid,
854
- showSchematicPorts,
855
- onChangeShowSchematicDebugGrid: setShowSchematicDebugGrid,
856
- onChangeShowSchematicPorts: setShowSchematicPorts
853
+ ),
854
+ props.leftHeaderContent
855
+ ] }),
856
+ onActiveTabChange: setActiveTab,
857
+ circuitJson,
858
+ renderLog,
859
+ activeEffectName,
860
+ isRunningCode: isRunning,
861
+ errorMessage: error?.error,
862
+ errorStack: error?.stack,
863
+ onEditEvent: handleEditEvent,
864
+ editEvents: props.editEvents,
865
+ onPcbBoundsSelected: props.onPcbBoundsSelected,
866
+ defaultToFullScreen: props.defaultToFullScreen,
867
+ onRerunWithDebug: (debugOption) => {
868
+ setCurrentDebugOption(debugOption || "");
869
+ incRunCountTrigger(1);
870
+ },
871
+ solverEvents,
872
+ isCli: props.isCli,
873
+ showSchematicDebugGrid,
874
+ showSchematicPorts,
875
+ onChangeShowSchematicDebugGrid: setShowSchematicDebugGrid,
876
+ onChangeShowSchematicPorts: setShowSchematicPorts
877
+ }
878
+ )
857
879
  }
858
- ) });
880
+ );
859
881
  };
860
882
 
861
883
  // lib/components/RunFrameWithApi/RunFrameWithApi.tsx
@@ -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],qko=({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(Jko,{solver:n})]},n.constructor.name))})},Wko=({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(qko,{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]})]})},jko=(t,e,n)=>{const o=t.currentPipelineStepIndex;return e<o?"Completed":e===o&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},Xko=(t,e)=>{const o=t.pipelineDef[e].solverName,i=jko(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}},$ko=({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})},Zko=({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,"%"]})]})},eFo=t=>Object.entries(t).map(([e,n])=>`${e}: ${n}`).join(", "),tFo=({stats:t})=>{if(!t||Object.keys(t).length===0)return q.jsx("span",{children:"-"});const e=Object.entries(t),n=eFo(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},nFo=(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)}`)}},oFo=({solver:t,onStepUntilPhase:e,onDownloadInput:n})=>{const o=t.pipelineDef.map((s,a)=>Xko(t,a)),i=s=>{e?.(s)},r=s=>{s.solverInstance&&(n?n(s.solverInstance,s.name):nFo(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($ko,{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(Zko,{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(tFo,{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))})]})})]})},iFo=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 rFo({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 AFo=({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(Wko,{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(iFo,{fallback:q.jsx(rFo,{graphics:A}),children:q.jsx(Vko,{graphics:A})}),a&&q.jsx(oFo,{solver:t,onStepUntilPhase:c})]})};const sFo=()=>{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)},[])},aFo=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)},aFo)},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",cFo={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},lFo=t=>t.toLowerCase().includes("pack")?ODo:t.toLowerCase().includes("rout")?qDo:RDo,j7t=t=>{const e=cFo[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},gFo=t=>`${V7t(`${t.componentName}-${t.solverName}`)}-solver-input.json`,X7t=t=>{IS(JSON.stringify(t.solverParams,null,2),{fileName:gFo(t),mimeType:"application/json"})},uFo=({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"]})]})},dFo=({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"})})},hFo=({solverEvents:t=[]})=>{const[e,n]=ee.useState(null);sFo();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=lFo(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(uFo,{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(AFo,{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(dFo,{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])},_Fo=t=>{ee.useEffect(()=>{try{cKt(t)}catch{}},[t.source,t.component,t.isWebEmbedded,t.activeTab])},Z7t="0.0.2349",mFo={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()])):{}},pFo=(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}=pFo(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],qko=({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(Jko,{solver:n})]},n.constructor.name))})},Wko=({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(qko,{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]})]})},jko=(t,e,n)=>{const o=t.currentPipelineStepIndex;return e<o?"Completed":e===o&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},Xko=(t,e)=>{const o=t.pipelineDef[e].solverName,i=jko(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}},$ko=({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})},Zko=({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,"%"]})]})},eFo=t=>Object.entries(t).map(([e,n])=>`${e}: ${n}`).join(", "),tFo=({stats:t})=>{if(!t||Object.keys(t).length===0)return q.jsx("span",{children:"-"});const e=Object.entries(t),n=eFo(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},nFo=(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)}`)}},oFo=({solver:t,onStepUntilPhase:e,onDownloadInput:n})=>{const o=t.pipelineDef.map((s,a)=>Xko(t,a)),i=s=>{e?.(s)},r=s=>{s.solverInstance&&(n?n(s.solverInstance,s.name):nFo(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($ko,{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(Zko,{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(tFo,{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))})]})})]})},iFo=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 rFo({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 AFo=({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(Wko,{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(iFo,{fallback:q.jsx(rFo,{graphics:A}),children:q.jsx(Vko,{graphics:A})}),a&&q.jsx(oFo,{solver:t,onStepUntilPhase:c})]})};const sFo=()=>{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)},[])},aFo=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)},aFo)},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",cFo={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},lFo=t=>t.toLowerCase().includes("pack")?ODo:t.toLowerCase().includes("rout")?qDo:RDo,j7t=t=>{const e=cFo[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},gFo=t=>`${V7t(`${t.componentName}-${t.solverName}`)}-solver-input.json`,X7t=t=>{IS(JSON.stringify(t.solverParams,null,2),{fileName:gFo(t),mimeType:"application/json"})},uFo=({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"]})]})},dFo=({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"})})},hFo=({solverEvents:t=[]})=>{const[e,n]=ee.useState(null);sFo();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=lFo(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(uFo,{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(AFo,{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(dFo,{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])},_Fo=t=>{ee.useEffect(()=>{try{cKt(t)}catch{}},[t.source,t.component,t.isWebEmbedded,t.activeTab])},Z7t="0.0.2351",mFo={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()])):{}},pFo=(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}=pFo(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" } } }