@tscircuit/runframe 0.0.1659 → 0.0.1661

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.
@@ -1730,7 +1730,7 @@ var useErrorTelemetry = ({
1730
1730
  };
1731
1731
 
1732
1732
  // package.json
1733
- var version = "0.0.1658";
1733
+ var version = "0.0.1660";
1734
1734
  var package_default = {
1735
1735
  name: "@tscircuit/runframe",
1736
1736
  main: "dist/preview.js",
@@ -1782,7 +1782,7 @@ var package_default = {
1782
1782
  "@tscircuit/3d-viewer": "^0.0.526",
1783
1783
  "@tscircuit/assembly-viewer": "^0.0.5",
1784
1784
  "@tscircuit/create-snippet-url": "^0.0.9",
1785
- "@tscircuit/eval": "^0.0.664",
1785
+ "@tscircuit/eval": "^0.0.665",
1786
1786
  "@tscircuit/circuit-json-util": "^0.0.75",
1787
1787
  "@tscircuit/fake-snippets": "^0.0.163",
1788
1788
  "@tscircuit/file-server": "^0.0.32",
package/dist/preview.js CHANGED
@@ -8,7 +8,7 @@ import {
8
8
  linkify,
9
9
  useOrderDialog,
10
10
  useOrderDialogCli
11
- } from "./chunk-JAAAFOND.js";
11
+ } from "./chunk-U7RXHO6B.js";
12
12
  export {
13
13
  BomTable,
14
14
  CadViewer,
package/dist/runner.js CHANGED
@@ -34,7 +34,7 @@ import {
34
34
  useRunFrameStore,
35
35
  useRunnerStore,
36
36
  useStyles
37
- } from "./chunk-JAAAFOND.js";
37
+ } from "./chunk-U7RXHO6B.js";
38
38
 
39
39
  // lib/components/RunFrame/RunFrame.tsx
40
40
  import { createCircuitWebWorker } from "@tscircuit/eval/worker";
@@ -193,6 +193,17 @@ var LoadingSkeleton = ({
193
193
  ] });
194
194
  };
195
195
 
196
+ // lib/utils/file-filters.ts
197
+ var isCircuitJsonFile = (filename) => {
198
+ const normalizedFilename = filename.toLowerCase();
199
+ const basename = normalizedFilename.split("/").pop();
200
+ return normalizedFilename.endsWith(".circuit.json") || basename === "circuit.json";
201
+ };
202
+ var getUiFileFilter = () => (filename) => {
203
+ return filename.endsWith(".tsx") || isCircuitJsonFile(filename) || filename.endsWith(".jsx");
204
+ };
205
+ var DEFAULT_UI_FILE_FILTER = getUiFileFilter();
206
+
196
207
  // lib/hooks/use-circuit-json-file.ts
197
208
  import { useMemo } from "react";
198
209
  var useCircuitJsonFile = ({
@@ -200,7 +211,7 @@ var useCircuitJsonFile = ({
200
211
  fsMap
201
212
  }) => {
202
213
  return useMemo(() => {
203
- const isStaticCircuitJson = mainComponentPath?.endsWith(".circuit.json") || mainComponentPath?.toLowerCase() === "circuit.json";
214
+ const isStaticCircuitJson = mainComponentPath != null && isCircuitJsonFile(mainComponentPath);
204
215
  if (!isStaticCircuitJson) {
205
216
  return { isStaticCircuitJson: false, circuitJson: null, error: null };
206
217
  }
@@ -843,6 +854,7 @@ var RunFrame = (props) => {
843
854
  };
844
855
 
845
856
  // lib/components/RunFrameWithApi/RunFrameWithApi.tsx
857
+ import { applyEditEventsToManualEditsFile } from "@tscircuit/core";
846
858
  import Debug3 from "debug";
847
859
 
848
860
  // lib/hooks/use-edit-event-controller.ts
@@ -969,58 +981,50 @@ var useSyncPageTitle = () => {
969
981
 
970
982
  // lib/components/RunFrameWithApi/RunFrameWithApi.tsx
971
983
  import { useCallback as useCallback4, useEffect as useEffect7, useMemo as useMemo4, useState as useState6 } from "react";
972
- import { applyEditEventsToManualEditsFile } from "@tscircuit/core";
973
-
974
- // lib/components/RunFrameWithApi/EnhancedFileSelectorCombobox/EnhancedFileSelectorCombobox.tsx
975
- import { useEffect as useEffect6, useState as useState5, useRef as useRef3, useMemo as useMemo3, useCallback as useCallback3 } from "react";
976
984
 
977
- // lib/components/RunFrameWithApi/EnhancedFileSelectorCombobox/useCurrentFolder.ts
978
- import { useState as useState4, useEffect as useEffect5 } from "react";
979
- function getDirectoryPath(filePath) {
980
- const lastSlashIndex = filePath.lastIndexOf("/");
981
- if (lastSlashIndex === -1) return "/";
982
- return filePath.substring(0, lastSlashIndex);
983
- }
984
- function useCurrentFolder({
985
- currentFile,
986
- files
987
- }) {
988
- const [hasManuallyNavigated, setHasManuallyNavigated] = useState4(false);
989
- const [currentFolder, setCurrentFolder] = useState4(() => {
990
- if (typeof window !== "undefined") {
991
- const searchParams = new URLSearchParams(window.location.search);
992
- const hashParams = new URLSearchParams(window.location.hash.slice(1));
993
- const urlFile = searchParams.get("file") ?? hashParams.get("file");
994
- if (urlFile && files.includes(urlFile)) {
995
- const fileDir = getDirectoryPath(urlFile);
996
- return fileDir === "/" ? null : fileDir;
997
- }
998
- }
999
- if (currentFile && files.includes(currentFile)) {
1000
- const fileDir = getDirectoryPath(currentFile);
1001
- return fileDir === "/" ? null : fileDir;
1002
- }
985
+ // lib/utils/get-board-files-from-config.ts
986
+ import { projectConfig } from "@tscircuit/props";
987
+ import { Minimatch } from "minimatch";
988
+ var DEFAULT_BOARD_FILE_FILTER = (filename) => (filename.endsWith(".tsx") || filename.endsWith(".ts") || filename.endsWith(".jsx") || filename.endsWith(".js") || isCircuitJsonFile(filename)) && !filename.endsWith(".d.ts");
989
+ var parseProjectConfig = (configContent) => {
990
+ if (!configContent) return null;
991
+ try {
992
+ const parsedJson = JSON.parse(configContent);
993
+ return projectConfig.parse(parsedJson);
994
+ } catch (error) {
995
+ console.warn("Failed to parse tscircuit.config.json", error);
1003
996
  return null;
1004
- });
1005
- useEffect5(() => {
1006
- if (currentFile && !hasManuallyNavigated && files.includes(currentFile)) {
1007
- const fileDir = getDirectoryPath(currentFile);
1008
- setCurrentFolder(fileDir === "/" ? null : fileDir);
1009
- }
1010
- }, [currentFile, hasManuallyNavigated, files]);
1011
- const navigateToFolder = (folderPath) => {
1012
- setCurrentFolder(folderPath);
1013
- setHasManuallyNavigated(true);
1014
- };
1015
- const resetManualNavigation = () => {
1016
- setHasManuallyNavigated(false);
1017
- };
1018
- return {
1019
- currentFolder,
1020
- navigateToFolder,
1021
- resetManualNavigation
1022
- };
1023
- }
997
+ }
998
+ };
999
+ var getBoardFilesFromConfig = (files, configContent) => {
1000
+ const parsedConfig = parseProjectConfig(configContent);
1001
+ const includeBoardFiles = parsedConfig?.includeBoardFiles?.filter(Boolean);
1002
+ if (includeBoardFiles && includeBoardFiles.length > 0) {
1003
+ const matchers = includeBoardFiles.map(
1004
+ (pattern) => new Minimatch(pattern, { dot: true })
1005
+ );
1006
+ return files.filter(
1007
+ (file) => matchers.some((matcher) => matcher.match(file))
1008
+ );
1009
+ }
1010
+ return files.filter(DEFAULT_BOARD_FILE_FILTER);
1011
+ };
1012
+
1013
+ // lib/components/RunFrameWithApi/EnhancedFileSelectorCombobox/EnhancedFileSelectorCombobox.tsx
1014
+ import {
1015
+ ArrowUp,
1016
+ Check,
1017
+ ChevronDown,
1018
+ ChevronRight,
1019
+ ChevronsUpDown,
1020
+ Clock,
1021
+ Code,
1022
+ File,
1023
+ FileText,
1024
+ Folder,
1025
+ Save
1026
+ } from "lucide-react";
1027
+ import { useCallback as useCallback3, useEffect as useEffect6, useMemo as useMemo3, useRef as useRef3, useState as useState5 } from "react";
1024
1028
 
1025
1029
  // lib/components/ui/command.tsx
1026
1030
  import * as React2 from "react";
@@ -1157,21 +1161,6 @@ var PopoverContent = React3.forwardRef(({ className, align = "center", sideOffse
1157
1161
  ) }));
1158
1162
  PopoverContent.displayName = PopoverPrimitive.Content.displayName;
1159
1163
 
1160
- // lib/components/RunFrameWithApi/EnhancedFileSelectorCombobox/EnhancedFileSelectorCombobox.tsx
1161
- import {
1162
- ChevronsUpDown,
1163
- Check,
1164
- ChevronRight,
1165
- ChevronDown,
1166
- File,
1167
- FileText,
1168
- Code,
1169
- Folder,
1170
- ArrowUp,
1171
- Clock,
1172
- Save
1173
- } from "lucide-react";
1174
-
1175
1164
  // lib/components/RunFrameWithApi/EnhancedFileSelectorCombobox/naturalSort.ts
1176
1165
  function naturalSort(a, b) {
1177
1166
  const extA = a.lastIndexOf(".");
@@ -1246,6 +1235,54 @@ function getCurrentFolderContents(tree, currentFolder) {
1246
1235
  return { files, folders };
1247
1236
  }
1248
1237
 
1238
+ // lib/components/RunFrameWithApi/EnhancedFileSelectorCombobox/useCurrentFolder.ts
1239
+ import { useState as useState4, useEffect as useEffect5 } from "react";
1240
+ function getDirectoryPath(filePath) {
1241
+ const lastSlashIndex = filePath.lastIndexOf("/");
1242
+ if (lastSlashIndex === -1) return "/";
1243
+ return filePath.substring(0, lastSlashIndex);
1244
+ }
1245
+ function useCurrentFolder({
1246
+ currentFile,
1247
+ files
1248
+ }) {
1249
+ const [hasManuallyNavigated, setHasManuallyNavigated] = useState4(false);
1250
+ const [currentFolder, setCurrentFolder] = useState4(() => {
1251
+ if (typeof window !== "undefined") {
1252
+ const searchParams = new URLSearchParams(window.location.search);
1253
+ const hashParams = new URLSearchParams(window.location.hash.slice(1));
1254
+ const urlFile = searchParams.get("file") ?? hashParams.get("file");
1255
+ if (urlFile && files.includes(urlFile)) {
1256
+ const fileDir = getDirectoryPath(urlFile);
1257
+ return fileDir === "/" ? null : fileDir;
1258
+ }
1259
+ }
1260
+ if (currentFile && files.includes(currentFile)) {
1261
+ const fileDir = getDirectoryPath(currentFile);
1262
+ return fileDir === "/" ? null : fileDir;
1263
+ }
1264
+ return null;
1265
+ });
1266
+ useEffect5(() => {
1267
+ if (currentFile && !hasManuallyNavigated && files.includes(currentFile)) {
1268
+ const fileDir = getDirectoryPath(currentFile);
1269
+ setCurrentFolder(fileDir === "/" ? null : fileDir);
1270
+ }
1271
+ }, [currentFile, hasManuallyNavigated, files]);
1272
+ const navigateToFolder = (folderPath) => {
1273
+ setCurrentFolder(folderPath);
1274
+ setHasManuallyNavigated(true);
1275
+ };
1276
+ const resetManualNavigation = () => {
1277
+ setHasManuallyNavigated(false);
1278
+ };
1279
+ return {
1280
+ currentFolder,
1281
+ navigateToFolder,
1282
+ resetManualNavigation
1283
+ };
1284
+ }
1285
+
1249
1286
  // lib/components/RunFrameWithApi/EnhancedFileSelectorCombobox/EnhancedFileSelectorCombobox.tsx
1250
1287
  import { Fragment as Fragment2, jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
1251
1288
  var defaultFileIcon = (fileName) => {
@@ -1258,7 +1295,7 @@ var defaultFileIcon = (fileName) => {
1258
1295
  return /* @__PURE__ */ jsx7(File, { className: "rf-h-4 rf-w-4 rf-text-gray-500" });
1259
1296
  };
1260
1297
  var defaultFileFilter = (filename) => {
1261
- return filename.endsWith(".tsx") || filename.endsWith(".circuit.json") || filename.endsWith(".jsx");
1298
+ return filename.endsWith(".tsx") || isCircuitJsonFile(filename) || filename.endsWith(".jsx");
1262
1299
  };
1263
1300
  var defaultDisplayName = (filename) => {
1264
1301
  return filename.split("/").pop() || "";
@@ -1692,47 +1729,6 @@ var EnhancedFileSelectorCombobox = ({
1692
1729
  ) });
1693
1730
  };
1694
1731
 
1695
- // lib/utils/get-board-files-from-config.ts
1696
- import { projectConfig } from "@tscircuit/props";
1697
- import { Minimatch } from "minimatch";
1698
- var DEFAULT_BOARD_FILE_EXTENSIONS = [
1699
- ".tsx",
1700
- ".ts",
1701
- ".jsx",
1702
- ".js",
1703
- ".circuit.json"
1704
- ];
1705
- var DEFAULT_BOARD_FILE_FILTER = (filename) => DEFAULT_BOARD_FILE_EXTENSIONS.some((ext) => filename.endsWith(ext)) && !filename.endsWith(".d.ts");
1706
- var parseProjectConfig = (configContent) => {
1707
- if (!configContent) return null;
1708
- try {
1709
- const parsedJson = JSON.parse(configContent);
1710
- return projectConfig.parse(parsedJson);
1711
- } catch (error) {
1712
- console.warn("Failed to parse tscircuit.config.json", error);
1713
- return null;
1714
- }
1715
- };
1716
- var getBoardFilesFromConfig = (files, configContent) => {
1717
- const parsedConfig = parseProjectConfig(configContent);
1718
- const includeBoardFiles = parsedConfig?.includeBoardFiles?.filter(Boolean);
1719
- if (includeBoardFiles && includeBoardFiles.length > 0) {
1720
- const matchers = includeBoardFiles.map(
1721
- (pattern) => new Minimatch(pattern, { dot: true })
1722
- );
1723
- return files.filter(
1724
- (file) => matchers.some((matcher) => matcher.match(file))
1725
- );
1726
- }
1727
- return files.filter(DEFAULT_BOARD_FILE_FILTER);
1728
- };
1729
-
1730
- // lib/utils/file-filters.ts
1731
- var getUiFileFilter = () => (filename) => {
1732
- return filename.endsWith(".tsx") || filename.endsWith(".circuit.json") || filename.endsWith(".jsx");
1733
- };
1734
- var DEFAULT_UI_FILE_FILTER = getUiFileFilter();
1735
-
1736
1732
  // lib/components/RunFrameWithApi/RunFrameWithApi.tsx
1737
1733
  import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
1738
1734
  var debug4 = Debug3("run-frame:RunFrameWithApi");
@@ -1787,7 +1783,7 @@ var RunFrameWithApi = (props) => {
1787
1783
  [boardFiles, activeFileFilter]
1788
1784
  );
1789
1785
  useEffect7(() => {
1790
- if (componentPath && visibleBoardFiles.includes(componentPath)) {
1786
+ if (componentPath && (visibleBoardFiles.includes(componentPath) || boardFiles.includes(componentPath))) {
1791
1787
  return;
1792
1788
  }
1793
1789
  if (componentPath) {
@@ -1816,7 +1812,12 @@ var RunFrameWithApi = (props) => {
1816
1812
  if (firstMatch) {
1817
1813
  setComponentPath(firstMatch);
1818
1814
  }
1819
- }, [visibleBoardFiles, props.initialMainComponentPath, componentPath]);
1815
+ }, [
1816
+ visibleBoardFiles,
1817
+ boardFiles,
1818
+ props.initialMainComponentPath,
1819
+ componentPath
1820
+ ]);
1820
1821
  const updateFileHash = useCallback4((filePath) => {
1821
1822
  if (typeof window === "undefined") return;
1822
1823
  const params = new URLSearchParams(window.location.hash.slice(1));
@@ -5679,7 +5679,7 @@ test("${g} should solve problem correctly", () => {
5679
5679
  // Add more specific assertions based on expected output
5680
5680
  // expect(solver.netLabelPlacementSolver!.netLabelPlacements).toMatchInlineSnapshot()
5681
5681
  })
5682
- `,I=new Blob([c],{type:"text/plain"}),l=URL.createObjectURL(I),B=document.createElement("a");B.href=l,B.download=`${g}.test.ts`,B.click(),URL.revokeObjectURL(l)}catch(a){alert(`Error generating test.ts for ${e.constructor.name}: ${a instanceof Error?a.message:String(a)}`)}i(!1)};return Z.jsxs("div",{className:`relative ${A}`,ref:n,children:[Z.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>i(!t),title:`Download options for ${e.constructor.name}`,children:e.constructor.name}),t&&Z.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:[Z.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:o,children:"Download JSON"}),Z.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),Z.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download test.ts"})]})]})},Uct=e=>e.activeSubSolver?[e,...Uct(e.activeSubSolver)]:[e],t9e=({solver:e})=>{const A=Uct(e);return Z.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:A.map((t,i)=>Z.jsxs("div",{className:"flex items-center",children:[i>0&&Z.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),Z.jsx(A9e,{solver:t})]},t.constructor.name))})},e9e=({solver:e,triggerRender:A,animationSpeed:t=25,onSolverStarted:i,onSolverCompleted:n})=>{const[o,s]=AA.useReducer(Q=>!Q,!1),r=AA.useRef(void 0),a=()=>{!e.solved&&!e.failed&&(e.step(),A())},g=()=>{!e.solved&&!e.failed&&(i&&i(e),e.solve(),A(),n&&n(e))},c=()=>{o?(r.current&&(clearInterval(r.current),r.current=void 0),s()):(s(),r.current=setInterval(()=>{if(e.solved||e.failed){r.current&&(clearInterval(r.current),r.current=void 0),s(),A(),n&&e.solved&&n(e);return}e.step(),A()},t))},I=()=>{const Q=e;if(Q.getCurrentPhase&&!e.solved&&!e.failed){const E=Q.getCurrentPhase();for(;Q.getCurrentPhase()===E&&!e.solved&&!e.failed;)e.step();A()}},l=()=>{if(e.solved||e.failed||o)return;const Q=window.prompt("Step until which iteration?",`${e.iterations}`);if(Q===null)return;const E=Number(Q);if(!Number.isFinite(E)){window.alert("Please enter a valid number for the iteration");return}for(;e.iterations<E&&!e.solved&&!e.failed;)e.step();A(),e.solved&&n&&n(e)};AA.useEffect(()=>()=>{r.current&&clearInterval(r.current)},[]),AA.useEffect(()=>{(e.solved||e.failed)&&o&&(r.current&&(clearInterval(r.current),r.current=void 0),s())},[e.solved,e.failed,o]);const B=e.getCurrentPhase!==void 0,C=B?e.getCurrentPhase():null;return Z.jsxs("div",{className:"space-y-2 p-2 border-b",children:[Z.jsx("div",{className:"flex items-center",children:Z.jsx(t9e,{solver:e})}),Z.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[Z.jsx("button",{onClick:a,disabled:e.solved||e.failed||o,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),Z.jsx("button",{onClick:g,disabled:e.solved||e.failed||o,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),Z.jsx("button",{onClick:c,disabled:e.solved||e.failed,className:`px-3 py-1 rounded text-white text-sm ${o?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:o?"Stop":"Animate"}),Z.jsx("button",{onClick:l,disabled:e.solved||e.failed||o,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"}),B&&Z.jsx("button",{onClick:I,disabled:e.solved||e.failed||o,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),Z.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",e.iterations]}),e.timeToSolve!==void 0&&Z.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(e.timeToSolve/1e3).toFixed(3),"s"]}),C&&Z.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",Z.jsx("span",{className:"font-medium",children:C})]}),e.solved&&Z.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),e.failed&&Z.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),e.error&&Z.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",e.error]})]})},i9e=(e,A,t)=>{const i=e.currentPipelineStepIndex;return A<i?"Completed":A===i&&e.activeSubSolver?e.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},n9e=(e,A)=>{const i=e.pipelineDef[A].solverName,n=i9e(e,A),o=e[i],s=e.firstIterationOfPhase?.[i]??null,r=e.iterations;let a=0;if(n==="Completed"){const l=e.pipelineDef[A+1],B=l?e.firstIterationOfPhase?.[l.solverName]:void 0;B!==void 0&&s!==null?a=B-s:s!==null&&(a=r-s)}else n==="In Progress"&&s!==null&&(a=r-s);const g=e.timeSpentOnPhase?.[i]??0;let c=0;n==="Completed"?c=1:n==="In Progress"&&o&&(c=o.progress??0);const I=o?.stats??null;return{index:A,name:i,status:n,firstIteration:s,iterations:a,progress:c,timeSpent:g,stats:I&&Object.keys(I).length>0?I:null,solverInstance:o??null}},o9e=({status:e})=>{const A={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return Z.jsx("span",{className:`font-medium ${A[e]}`,children:e})},s9e=({progress:e})=>{if(e===0)return null;const A=Math.round(e*100);return Z.jsxs("div",{className:"flex items-center gap-2",children:[Z.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:Z.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${A}%`}})}),Z.jsxs("span",{className:"text-xs text-gray-500",children:[A,"%"]})]})},r9e=e=>Object.entries(e).map(([A,t])=>`${A}: ${t}`).join(", "),a9e=({stats:e})=>{if(!e||Object.keys(e).length===0)return Z.jsx("span",{children:"-"});const A=Object.entries(e),t=r9e(e);return Z.jsxs("details",{className:"cursor-pointer",children:[Z.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:t}),Z.jsx("div",{className:"mt-1 text-xs",children:A.map(([i,n])=>Z.jsxs("div",{children:[i,": ",String(n)]},i))})]})},ifA=e=>{if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(ifA);const A={};for(const[t,i]of Object.entries(e))t.startsWith("_")||(A[t]=ifA(i));return A},g9e=(e,A)=>{try{if(typeof e.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${A}`);return}const t=ifA(e.getConstructorParams()),i=new Blob([JSON.stringify(t,null,2)],{type:"application/json"}),n=URL.createObjectURL(i),o=document.createElement("a");o.href=n,o.download=`${A}_input.json`,o.click(),URL.revokeObjectURL(n)}catch(t){alert(`Error downloading input for ${A}: ${t instanceof Error?t.message:String(t)}`)}},c9e=({solver:e,onStepUntilPhase:A,onDownloadInput:t})=>{const i=e.pipelineDef.map((r,a)=>n9e(e,a)),n=r=>{A?.(r)},o=r=>{r.solverInstance&&(t?t(r.solverInstance,r.name):g9e(r.solverInstance,r.name))},s=r=>`${(r/1e3).toFixed(2)}s`;return Z.jsxs("div",{className:"border-t border-gray-200",children:[Z.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:Z.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),Z.jsx("div",{className:"overflow-x-auto",children:Z.jsxs("table",{className:"w-full text-sm",children:[Z.jsx("thead",{children:Z.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),Z.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",Z.jsx("sub",{children:"0"})]}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),Z.jsx("tbody",{children:i.map(r=>Z.jsxs("tr",{className:`border-b border-gray-100 ${r.status==="In Progress"?"bg-yellow-50":""}`,children:[Z.jsx("td",{className:"px-4 py-2",children:Z.jsxs("div",{className:"flex items-center gap-2",children:[Z.jsx("span",{className:"text-gray-400 w-6",children:String(r.index+1).padStart(2,"0")}),Z.jsx("button",{onClick:()=>n(r.name),disabled:r.status==="Completed"||e.solved||e.failed,className:"text-blue-500 hover:text-blue-700 disabled:text-gray-300 disabled:cursor-not-allowed",title:`Step until ${r.name} completes`,children:Z.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:Z.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"})})}),Z.jsx("span",{className:"font-medium text-gray-900",children:r.name})]})}),Z.jsx("td",{className:"px-4 py-2",children:Z.jsx(o9e,{status:r.status})}),Z.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:r.firstIteration!==null?r.firstIteration:""}),Z.jsx("td",{className:"px-4 py-2 text-gray-600",children:r.iterations}),Z.jsx("td",{className:"px-4 py-2",children:Z.jsx(s9e,{progress:r.progress})}),Z.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(r.timeSpent)}),Z.jsx("td",{className:"px-4 py-2 text-gray-500",children:Z.jsx(a9e,{stats:r.stats})}),Z.jsx("td",{className:"px-4 py-2",children:r.solverInstance?Z.jsxs("button",{onClick:()=>o(r),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${r.name}`,children:[Z.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:Z.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"})}),Z.jsx("span",{children:"Input"})]}):null})]},r.name))})]})})]})},I9e=class extends en.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e){console.error("InteractiveGraphics render error:",e)}render(){return this.state.hasError?this.props.fallback:this.props.children}};function l9e({graphics:e}){const A=e.points??[],t=e.lines??[],i=e.rects??[],n=e.circles??[],o=e.texts??[];let s=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,g=Number.NEGATIVE_INFINITY;const c=(E,h)=>{typeof E=="number"&&(E<s&&(s=E),E>a&&(a=E)),typeof h=="number"&&(h<r&&(r=h),h>g&&(g=h))};for(const E of A)c(E.x,E.y);for(const E of t){const h=E.points??[];for(const u of h)c(u.x,u.y)}for(const E of i){const h=E.x??0,u=E.y??0,d=E.width??0,f=E.height??0;c(h,u),c(h+d,u+f)}for(const E of n){const h=E.x??0,u=E.y??0,d=E.radius??1;c(h-d,u-d),c(h+d,u+d)}for(const E of o)c(E.x,E.y);(!isFinite(s)||!isFinite(r)||!isFinite(a)||!isFinite(g))&&(s=-20,r=-20,a=20,g=20);const I=10,l=s-I,B=r-I,C=Math.max(1,a-s+2*I),Q=Math.max(1,g-r+2*I);return Z.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${l} ${B} ${C} ${Q}`,role:"img","aria-label":"Graphics fallback",children:[i.map((E,h)=>Z.jsx("rect",{x:E.x??0,y:E.y??0,width:E.width??0,height:E.height??0,fill:"none",stroke:E.strokeColor??"black",strokeWidth:E.strokeWidth??1},`rect-${h}`)),t.map((E,h)=>Z.jsx("polyline",{fill:"none",stroke:E.strokeColor??"black",strokeWidth:E.strokeWidth??1,points:(E.points??[]).map(u=>`${u.x??0},${u.y??0}`).join(" ")},`line-${h}`)),n.map((E,h)=>Z.jsx("circle",{cx:E.x??0,cy:E.y??0,r:E.radius??1.5,fill:E.fillColor??"none",stroke:E.strokeColor??"black",strokeWidth:E.strokeWidth??1},`circle-${h}`)),A.map((E,h)=>Z.jsx("circle",{cx:E.x??0,cy:E.y??0,r:E.radius??1.5,fill:E.color??"black"},`point-${h}`)),o.map((E,h)=>Z.jsx("text",{x:E.x??0,y:E.y??0,fontSize:E.fontSize??10,fill:E.color??"black",children:E.text??""},`text-${h}`))]})}var B9e=({solver:e,animationSpeed:A=25,onSolverStarted:t,onSolverCompleted:i})=>{const[n,o]=AA.useReducer(c=>c+1,0),s=AA.useMemo(()=>{try{return e.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(c){return console.error("Visualization error:",c),{points:[],lines:[],rects:[],circles:[]}}},[e,n]),r=AA.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);AA.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const c=document.createElement("script");c.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(c)}},[]);const a=e.pipelineDef!==void 0,g=c=>{const I=e;if(!e.solved&&!e.failed){for(;!e.solved&&!e.failed&&I.currentPipelineStepIndex<=I.pipelineDef.findIndex(l=>l.solverName===c);)e.step();o()}};return Z.jsxs("div",{children:[Z.jsx(e9e,{solver:e,triggerRender:o,animationSpeed:A,onSolverStarted:t,onSolverCompleted:i}),r?Z.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):Z.jsx(I9e,{fallback:Z.jsx(l9e,{graphics:s}),children:Z.jsx($Ze,{graphics:s})}),a&&Z.jsx(c9e,{solver:e,onStepUntilPhase:g})]})};const C9e=()=>{AA.useEffect(()=>{const e="tailwind-cdn-script";if(document.getElementById(e)||window.tailwind)return;const A=document.createElement("div");A.className="hidden",document.body.appendChild(A);const t=window.getComputedStyle(A).display==="none";if(document.body.removeChild(A),t)return;const i=document.createElement("script");i.id=e,i.src="https://cdn.tailwindcss.com",document.head.appendChild(i)},[])},Q9e=e=>e.toLowerCase().includes("pack")?eMe:e.toLowerCase().includes("rout")?aMe:WGe,E9e=({solverEvents:e=[]})=>{const[A,t]=AA.useState(null);C9e();const i=AA.useMemo(()=>{const r=new Map;for(const a of e){const g=`${a.componentName}-${a.solverName}`;r.set(g,a)}return r},[e]),n=AA.useMemo(()=>Array.from(i.keys()),[i]),o=A?i.get(A):null,s=AA.useMemo(()=>{if(!o)return{instance:null,error:null,classFound:!1};const r=BrA[o.solverName];if(!r)return{instance:null,error:`Solver class "${o.solverName}" not found in SOLVERS registry. Available: ${Object.keys(BrA).join(", ")}`,classFound:!1};try{const a=o.solverParams,g=a?.input!==void 0?a.input:a;return{instance:new r(g),error:null,classFound:!0}}catch(a){const g=a instanceof Error?a.message:String(a);return console.error("Failed to reconstruct solver:",a),{instance:null,error:`Failed to instantiate solver: ${g}`,classFound:!0}}},[o]);return e.length===0?Z.jsx("div",{className:"rf-p-4",children:Z.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:Z.jsxs("div",{className:"rf-p-4",children:[Z.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),Z.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."})]})})}):Z.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[Z.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[Z.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:[n.length," ",n.length===1?"Solver":"Solvers"]}),n.map(r=>{const a=i.get(r),g=A===r;return Z.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${g?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>t(r),children:(()=>{const c=Q9e(a.solverName);return Z.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[Z.jsx(c,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),Z.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[Z.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:a.componentName}),Z.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:a.solverName})]})]})})()},r)})]}),Z.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:o?s.instance?Z.jsx(yD,{fallback:Z.jsx("div",{className:"rf-p-4",children:Z.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[Z.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),Z.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",o.solverName]})]})}),children:Z.jsx(B9e,{solver:s.instance})}):Z.jsxs("div",{className:"rf-p-4",children:[Z.jsxs("div",{className:"rf-mb-4",children:[Z.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:o.solverName}),Z.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",o.componentName]})]}),s.error&&Z.jsx("div",{className:`rf-rounded-md rf-border rf-p-4 rf-mb-4 ${s.classFound?"rf-bg-red-50 rf-border-red-200":"rf-bg-yellow-50 rf-border-yellow-200"}`,children:Z.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),Z.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[Z.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:Z.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),Z.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:Z.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(o.solverParams,null,2)})})]})]}):Z.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:Z.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},Hct=({errorMessage:e,errorStack:A,circuitJsonErrors:t})=>{AA.useEffect(()=>{if(e){const i=new Error(e);A&&(i.stack=A);try{qK.captureException(i)}catch{}}},[e,A]),AA.useEffect(()=>{if(t&&t.length>0)for(const i of t){const n=new Error(i.message||"Circuit JSON Error");i.stack&&(n.stack=i.stack);try{qK.captureException(n,{error_type:i.type})}catch{}}},[t])},Yct="0.0.1658",h9e={version:Yct},nfA={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},ofA=new Map,pV=e=>{const A=ofA.get(e);return A?Object.fromEntries(Object.entries(A.stores).map(([t,i])=>[t,i.getState()])):{}},u9e=(e,A,t)=>{if(e===void 0)return{type:"untracked",connection:A.connect(t)};const i=ofA.get(t.name);if(i)return{type:"tracked",store:e,...i};const n={connection:A.connect(t),stores:{}};return ofA.set(t.name,n),{type:"tracked",store:e,...n}},Jct=(e,A={})=>(t,i,n)=>{const{enabled:o,anonymousActionType:s,store:r,...a}=A;let g;try{g=(o??(nfA?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!g)return(nfA?"production":void 0)!=="production"&&o&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),e(t,i,n);const{connection:c,...I}=u9e(r,g,a);let l=!0;n.setState=(Q,E,h)=>{const u=t(Q,E);if(!l)return u;const d=h===void 0?{type:s||"anonymous"}:typeof h=="string"?{type:h}:h;return r===void 0?(c?.send(d,i()),u):(c?.send({...d,type:`${r}/${d.type}`},{...pV(a.name),[r]:n.getState()}),u)};const B=(...Q)=>{const E=l;l=!1,t(...Q),l=E},C=e(n.setState,i,n);if(I.type==="untracked"?c?.init(C):(I.stores[I.store]=n,c?.init(Object.fromEntries(Object.entries(I.stores).map(([Q,E])=>[Q,Q===I.store?C:E.getState()])))),n.dispatchFromDevtools&&typeof n.dispatch=="function"){let Q=!1;const E=n.dispatch;n.dispatch=(...h)=>{(nfA?"production":void 0)!=="production"&&h[0].type==="__setState"&&!Q&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),Q=!0),E(...h)}}return c.subscribe(Q=>{var E;switch(Q.type){case"ACTION":if(typeof Q.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return sfA(Q.payload,h=>{if(h.type==="__setState"){if(r===void 0){B(h.state);return}Object.keys(h.state).length!==1&&console.error(`
5682
+ `,I=new Blob([c],{type:"text/plain"}),l=URL.createObjectURL(I),B=document.createElement("a");B.href=l,B.download=`${g}.test.ts`,B.click(),URL.revokeObjectURL(l)}catch(a){alert(`Error generating test.ts for ${e.constructor.name}: ${a instanceof Error?a.message:String(a)}`)}i(!1)};return Z.jsxs("div",{className:`relative ${A}`,ref:n,children:[Z.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>i(!t),title:`Download options for ${e.constructor.name}`,children:e.constructor.name}),t&&Z.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:[Z.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:o,children:"Download JSON"}),Z.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),Z.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download test.ts"})]})]})},Uct=e=>e.activeSubSolver?[e,...Uct(e.activeSubSolver)]:[e],t9e=({solver:e})=>{const A=Uct(e);return Z.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:A.map((t,i)=>Z.jsxs("div",{className:"flex items-center",children:[i>0&&Z.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),Z.jsx(A9e,{solver:t})]},t.constructor.name))})},e9e=({solver:e,triggerRender:A,animationSpeed:t=25,onSolverStarted:i,onSolverCompleted:n})=>{const[o,s]=AA.useReducer(Q=>!Q,!1),r=AA.useRef(void 0),a=()=>{!e.solved&&!e.failed&&(e.step(),A())},g=()=>{!e.solved&&!e.failed&&(i&&i(e),e.solve(),A(),n&&n(e))},c=()=>{o?(r.current&&(clearInterval(r.current),r.current=void 0),s()):(s(),r.current=setInterval(()=>{if(e.solved||e.failed){r.current&&(clearInterval(r.current),r.current=void 0),s(),A(),n&&e.solved&&n(e);return}e.step(),A()},t))},I=()=>{const Q=e;if(Q.getCurrentPhase&&!e.solved&&!e.failed){const E=Q.getCurrentPhase();for(;Q.getCurrentPhase()===E&&!e.solved&&!e.failed;)e.step();A()}},l=()=>{if(e.solved||e.failed||o)return;const Q=window.prompt("Step until which iteration?",`${e.iterations}`);if(Q===null)return;const E=Number(Q);if(!Number.isFinite(E)){window.alert("Please enter a valid number for the iteration");return}for(;e.iterations<E&&!e.solved&&!e.failed;)e.step();A(),e.solved&&n&&n(e)};AA.useEffect(()=>()=>{r.current&&clearInterval(r.current)},[]),AA.useEffect(()=>{(e.solved||e.failed)&&o&&(r.current&&(clearInterval(r.current),r.current=void 0),s())},[e.solved,e.failed,o]);const B=e.getCurrentPhase!==void 0,C=B?e.getCurrentPhase():null;return Z.jsxs("div",{className:"space-y-2 p-2 border-b",children:[Z.jsx("div",{className:"flex items-center",children:Z.jsx(t9e,{solver:e})}),Z.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[Z.jsx("button",{onClick:a,disabled:e.solved||e.failed||o,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),Z.jsx("button",{onClick:g,disabled:e.solved||e.failed||o,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),Z.jsx("button",{onClick:c,disabled:e.solved||e.failed,className:`px-3 py-1 rounded text-white text-sm ${o?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:o?"Stop":"Animate"}),Z.jsx("button",{onClick:l,disabled:e.solved||e.failed||o,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"}),B&&Z.jsx("button",{onClick:I,disabled:e.solved||e.failed||o,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),Z.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",e.iterations]}),e.timeToSolve!==void 0&&Z.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(e.timeToSolve/1e3).toFixed(3),"s"]}),C&&Z.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",Z.jsx("span",{className:"font-medium",children:C})]}),e.solved&&Z.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),e.failed&&Z.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),e.error&&Z.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",e.error]})]})},i9e=(e,A,t)=>{const i=e.currentPipelineStepIndex;return A<i?"Completed":A===i&&e.activeSubSolver?e.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},n9e=(e,A)=>{const i=e.pipelineDef[A].solverName,n=i9e(e,A),o=e[i],s=e.firstIterationOfPhase?.[i]??null,r=e.iterations;let a=0;if(n==="Completed"){const l=e.pipelineDef[A+1],B=l?e.firstIterationOfPhase?.[l.solverName]:void 0;B!==void 0&&s!==null?a=B-s:s!==null&&(a=r-s)}else n==="In Progress"&&s!==null&&(a=r-s);const g=e.timeSpentOnPhase?.[i]??0;let c=0;n==="Completed"?c=1:n==="In Progress"&&o&&(c=o.progress??0);const I=o?.stats??null;return{index:A,name:i,status:n,firstIteration:s,iterations:a,progress:c,timeSpent:g,stats:I&&Object.keys(I).length>0?I:null,solverInstance:o??null}},o9e=({status:e})=>{const A={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return Z.jsx("span",{className:`font-medium ${A[e]}`,children:e})},s9e=({progress:e})=>{if(e===0)return null;const A=Math.round(e*100);return Z.jsxs("div",{className:"flex items-center gap-2",children:[Z.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:Z.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${A}%`}})}),Z.jsxs("span",{className:"text-xs text-gray-500",children:[A,"%"]})]})},r9e=e=>Object.entries(e).map(([A,t])=>`${A}: ${t}`).join(", "),a9e=({stats:e})=>{if(!e||Object.keys(e).length===0)return Z.jsx("span",{children:"-"});const A=Object.entries(e),t=r9e(e);return Z.jsxs("details",{className:"cursor-pointer",children:[Z.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:t}),Z.jsx("div",{className:"mt-1 text-xs",children:A.map(([i,n])=>Z.jsxs("div",{children:[i,": ",String(n)]},i))})]})},ifA=e=>{if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(ifA);const A={};for(const[t,i]of Object.entries(e))t.startsWith("_")||(A[t]=ifA(i));return A},g9e=(e,A)=>{try{if(typeof e.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${A}`);return}const t=ifA(e.getConstructorParams()),i=new Blob([JSON.stringify(t,null,2)],{type:"application/json"}),n=URL.createObjectURL(i),o=document.createElement("a");o.href=n,o.download=`${A}_input.json`,o.click(),URL.revokeObjectURL(n)}catch(t){alert(`Error downloading input for ${A}: ${t instanceof Error?t.message:String(t)}`)}},c9e=({solver:e,onStepUntilPhase:A,onDownloadInput:t})=>{const i=e.pipelineDef.map((r,a)=>n9e(e,a)),n=r=>{A?.(r)},o=r=>{r.solverInstance&&(t?t(r.solverInstance,r.name):g9e(r.solverInstance,r.name))},s=r=>`${(r/1e3).toFixed(2)}s`;return Z.jsxs("div",{className:"border-t border-gray-200",children:[Z.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:Z.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),Z.jsx("div",{className:"overflow-x-auto",children:Z.jsxs("table",{className:"w-full text-sm",children:[Z.jsx("thead",{children:Z.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),Z.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",Z.jsx("sub",{children:"0"})]}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),Z.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),Z.jsx("tbody",{children:i.map(r=>Z.jsxs("tr",{className:`border-b border-gray-100 ${r.status==="In Progress"?"bg-yellow-50":""}`,children:[Z.jsx("td",{className:"px-4 py-2",children:Z.jsxs("div",{className:"flex items-center gap-2",children:[Z.jsx("span",{className:"text-gray-400 w-6",children:String(r.index+1).padStart(2,"0")}),Z.jsx("button",{onClick:()=>n(r.name),disabled:r.status==="Completed"||e.solved||e.failed,className:"text-blue-500 hover:text-blue-700 disabled:text-gray-300 disabled:cursor-not-allowed",title:`Step until ${r.name} completes`,children:Z.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:Z.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"})})}),Z.jsx("span",{className:"font-medium text-gray-900",children:r.name})]})}),Z.jsx("td",{className:"px-4 py-2",children:Z.jsx(o9e,{status:r.status})}),Z.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:r.firstIteration!==null?r.firstIteration:""}),Z.jsx("td",{className:"px-4 py-2 text-gray-600",children:r.iterations}),Z.jsx("td",{className:"px-4 py-2",children:Z.jsx(s9e,{progress:r.progress})}),Z.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(r.timeSpent)}),Z.jsx("td",{className:"px-4 py-2 text-gray-500",children:Z.jsx(a9e,{stats:r.stats})}),Z.jsx("td",{className:"px-4 py-2",children:r.solverInstance?Z.jsxs("button",{onClick:()=>o(r),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${r.name}`,children:[Z.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:Z.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"})}),Z.jsx("span",{children:"Input"})]}):null})]},r.name))})]})})]})},I9e=class extends en.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e){console.error("InteractiveGraphics render error:",e)}render(){return this.state.hasError?this.props.fallback:this.props.children}};function l9e({graphics:e}){const A=e.points??[],t=e.lines??[],i=e.rects??[],n=e.circles??[],o=e.texts??[];let s=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,g=Number.NEGATIVE_INFINITY;const c=(E,h)=>{typeof E=="number"&&(E<s&&(s=E),E>a&&(a=E)),typeof h=="number"&&(h<r&&(r=h),h>g&&(g=h))};for(const E of A)c(E.x,E.y);for(const E of t){const h=E.points??[];for(const u of h)c(u.x,u.y)}for(const E of i){const h=E.x??0,u=E.y??0,d=E.width??0,f=E.height??0;c(h,u),c(h+d,u+f)}for(const E of n){const h=E.x??0,u=E.y??0,d=E.radius??1;c(h-d,u-d),c(h+d,u+d)}for(const E of o)c(E.x,E.y);(!isFinite(s)||!isFinite(r)||!isFinite(a)||!isFinite(g))&&(s=-20,r=-20,a=20,g=20);const I=10,l=s-I,B=r-I,C=Math.max(1,a-s+2*I),Q=Math.max(1,g-r+2*I);return Z.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${l} ${B} ${C} ${Q}`,role:"img","aria-label":"Graphics fallback",children:[i.map((E,h)=>Z.jsx("rect",{x:E.x??0,y:E.y??0,width:E.width??0,height:E.height??0,fill:"none",stroke:E.strokeColor??"black",strokeWidth:E.strokeWidth??1},`rect-${h}`)),t.map((E,h)=>Z.jsx("polyline",{fill:"none",stroke:E.strokeColor??"black",strokeWidth:E.strokeWidth??1,points:(E.points??[]).map(u=>`${u.x??0},${u.y??0}`).join(" ")},`line-${h}`)),n.map((E,h)=>Z.jsx("circle",{cx:E.x??0,cy:E.y??0,r:E.radius??1.5,fill:E.fillColor??"none",stroke:E.strokeColor??"black",strokeWidth:E.strokeWidth??1},`circle-${h}`)),A.map((E,h)=>Z.jsx("circle",{cx:E.x??0,cy:E.y??0,r:E.radius??1.5,fill:E.color??"black"},`point-${h}`)),o.map((E,h)=>Z.jsx("text",{x:E.x??0,y:E.y??0,fontSize:E.fontSize??10,fill:E.color??"black",children:E.text??""},`text-${h}`))]})}var B9e=({solver:e,animationSpeed:A=25,onSolverStarted:t,onSolverCompleted:i})=>{const[n,o]=AA.useReducer(c=>c+1,0),s=AA.useMemo(()=>{try{return e.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(c){return console.error("Visualization error:",c),{points:[],lines:[],rects:[],circles:[]}}},[e,n]),r=AA.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);AA.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const c=document.createElement("script");c.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(c)}},[]);const a=e.pipelineDef!==void 0,g=c=>{const I=e;if(!e.solved&&!e.failed){for(;!e.solved&&!e.failed&&I.currentPipelineStepIndex<=I.pipelineDef.findIndex(l=>l.solverName===c);)e.step();o()}};return Z.jsxs("div",{children:[Z.jsx(e9e,{solver:e,triggerRender:o,animationSpeed:A,onSolverStarted:t,onSolverCompleted:i}),r?Z.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):Z.jsx(I9e,{fallback:Z.jsx(l9e,{graphics:s}),children:Z.jsx($Ze,{graphics:s})}),a&&Z.jsx(c9e,{solver:e,onStepUntilPhase:g})]})};const C9e=()=>{AA.useEffect(()=>{const e="tailwind-cdn-script";if(document.getElementById(e)||window.tailwind)return;const A=document.createElement("div");A.className="hidden",document.body.appendChild(A);const t=window.getComputedStyle(A).display==="none";if(document.body.removeChild(A),t)return;const i=document.createElement("script");i.id=e,i.src="https://cdn.tailwindcss.com",document.head.appendChild(i)},[])},Q9e=e=>e.toLowerCase().includes("pack")?eMe:e.toLowerCase().includes("rout")?aMe:WGe,E9e=({solverEvents:e=[]})=>{const[A,t]=AA.useState(null);C9e();const i=AA.useMemo(()=>{const r=new Map;for(const a of e){const g=`${a.componentName}-${a.solverName}`;r.set(g,a)}return r},[e]),n=AA.useMemo(()=>Array.from(i.keys()),[i]),o=A?i.get(A):null,s=AA.useMemo(()=>{if(!o)return{instance:null,error:null,classFound:!1};const r=BrA[o.solverName];if(!r)return{instance:null,error:`Solver class "${o.solverName}" not found in SOLVERS registry. Available: ${Object.keys(BrA).join(", ")}`,classFound:!1};try{const a=o.solverParams,g=a?.input!==void 0?a.input:a;return{instance:new r(g),error:null,classFound:!0}}catch(a){const g=a instanceof Error?a.message:String(a);return console.error("Failed to reconstruct solver:",a),{instance:null,error:`Failed to instantiate solver: ${g}`,classFound:!0}}},[o]);return e.length===0?Z.jsx("div",{className:"rf-p-4",children:Z.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:Z.jsxs("div",{className:"rf-p-4",children:[Z.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),Z.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."})]})})}):Z.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[Z.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[Z.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:[n.length," ",n.length===1?"Solver":"Solvers"]}),n.map(r=>{const a=i.get(r),g=A===r;return Z.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${g?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>t(r),children:(()=>{const c=Q9e(a.solverName);return Z.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[Z.jsx(c,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),Z.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[Z.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:a.componentName}),Z.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:a.solverName})]})]})})()},r)})]}),Z.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:o?s.instance?Z.jsx(yD,{fallback:Z.jsx("div",{className:"rf-p-4",children:Z.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[Z.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),Z.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",o.solverName]})]})}),children:Z.jsx(B9e,{solver:s.instance})}):Z.jsxs("div",{className:"rf-p-4",children:[Z.jsxs("div",{className:"rf-mb-4",children:[Z.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:o.solverName}),Z.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",o.componentName]})]}),s.error&&Z.jsx("div",{className:`rf-rounded-md rf-border rf-p-4 rf-mb-4 ${s.classFound?"rf-bg-red-50 rf-border-red-200":"rf-bg-yellow-50 rf-border-yellow-200"}`,children:Z.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),Z.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[Z.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:Z.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),Z.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:Z.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(o.solverParams,null,2)})})]})]}):Z.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:Z.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},Hct=({errorMessage:e,errorStack:A,circuitJsonErrors:t})=>{AA.useEffect(()=>{if(e){const i=new Error(e);A&&(i.stack=A);try{qK.captureException(i)}catch{}}},[e,A]),AA.useEffect(()=>{if(t&&t.length>0)for(const i of t){const n=new Error(i.message||"Circuit JSON Error");i.stack&&(n.stack=i.stack);try{qK.captureException(n,{error_type:i.type})}catch{}}},[t])},Yct="0.0.1660",h9e={version:Yct},nfA={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},ofA=new Map,pV=e=>{const A=ofA.get(e);return A?Object.fromEntries(Object.entries(A.stores).map(([t,i])=>[t,i.getState()])):{}},u9e=(e,A,t)=>{if(e===void 0)return{type:"untracked",connection:A.connect(t)};const i=ofA.get(t.name);if(i)return{type:"tracked",store:e,...i};const n={connection:A.connect(t),stores:{}};return ofA.set(t.name,n),{type:"tracked",store:e,...n}},Jct=(e,A={})=>(t,i,n)=>{const{enabled:o,anonymousActionType:s,store:r,...a}=A;let g;try{g=(o??(nfA?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!g)return(nfA?"production":void 0)!=="production"&&o&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),e(t,i,n);const{connection:c,...I}=u9e(r,g,a);let l=!0;n.setState=(Q,E,h)=>{const u=t(Q,E);if(!l)return u;const d=h===void 0?{type:s||"anonymous"}:typeof h=="string"?{type:h}:h;return r===void 0?(c?.send(d,i()),u):(c?.send({...d,type:`${r}/${d.type}`},{...pV(a.name),[r]:n.getState()}),u)};const B=(...Q)=>{const E=l;l=!1,t(...Q),l=E},C=e(n.setState,i,n);if(I.type==="untracked"?c?.init(C):(I.stores[I.store]=n,c?.init(Object.fromEntries(Object.entries(I.stores).map(([Q,E])=>[Q,Q===I.store?C:E.getState()])))),n.dispatchFromDevtools&&typeof n.dispatch=="function"){let Q=!1;const E=n.dispatch;n.dispatch=(...h)=>{(nfA?"production":void 0)!=="production"&&h[0].type==="__setState"&&!Q&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),Q=!0),E(...h)}}return c.subscribe(Q=>{var E;switch(Q.type){case"ACTION":if(typeof Q.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return sfA(Q.payload,h=>{if(h.type==="__setState"){if(r===void 0){B(h.state);return}Object.keys(h.state).length!==1&&console.error(`
5683
5683
  [zustand devtools middleware] Unsupported __setState action format.
5684
5684
  When using 'store' option in devtools(), the 'state' should have only one key, which is a value of 'store' that was passed in devtools(),
5685
5685
  and value of this only key should be a state object. Example: { "type": "__setState", "state": { "abc123Store": { "foo": "bar" } } }