@tscircuit/runframe 0.0.1424 → 0.0.1425

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.
@@ -1716,7 +1716,7 @@ var useErrorTelemetry = ({
1716
1716
  };
1717
1717
 
1718
1718
  // package.json
1719
- var version = "0.0.1423";
1719
+ var version = "0.0.1424";
1720
1720
  var package_default = {
1721
1721
  name: "@tscircuit/runframe",
1722
1722
  main: "dist/preview.js",
@@ -1774,7 +1774,7 @@ var package_default = {
1774
1774
  "@tscircuit/pcb-viewer": "1.11.290",
1775
1775
  "@tscircuit/props": "^0.0.429",
1776
1776
  "@tscircuit/schematic-trace-solver": "^0.0.40",
1777
- "@tscircuit/schematic-viewer": "2.0.50",
1777
+ "@tscircuit/schematic-viewer": "^2.0.50",
1778
1778
  "@types/bun": "latest",
1779
1779
  "@types/debug": "^4.1.12",
1780
1780
  "@types/react": "^19.1.10",
package/dist/preview.js CHANGED
@@ -8,7 +8,7 @@ import {
8
8
  linkify,
9
9
  useOrderDialog,
10
10
  useOrderDialogCli
11
- } from "./chunk-5SANIX45.js";
11
+ } from "./chunk-5CA4F566.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-5SANIX45.js";
37
+ } from "./chunk-5CA4F566.js";
38
38
 
39
39
  // lib/components/RunFrame/RunFrame.tsx
40
40
  import { createCircuitWebWorker } from "@tscircuit/eval/worker";
@@ -5598,7 +5598,7 @@ test("${g} should solve problem correctly", () => {
5598
5598
  // Add more specific assertions based on expected output
5599
5599
  // expect(solver.netLabelPlacementSolver!.netLabelPlacements).toMatchInlineSnapshot()
5600
5600
  })
5601
- `,c=new Blob([I],{type:"text/plain"}),B=URL.createObjectURL(c),C=document.createElement("a");C.href=B,C.download=`${g}.test.ts`,C.click(),URL.revokeObjectURL(B)}catch(a){alert(`Error generating test.ts for ${t.constructor.name}: ${a instanceof Error?a.message:String(a)}`)}i(!1)};return V.jsxs("div",{className:`relative ${A}`,ref:o,children:[V.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>i(!e),title:`Download options for ${t.constructor.name}`,children:t.constructor.name}),e&&V.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:[V.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:n,children:"Download JSON"}),V.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),V.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download test.ts"})]})]})},mie=t=>t.activeSubSolver?[t,...mie(t.activeSubSolver)]:[t],CHt=({solver:t})=>{const A=mie(t);return V.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:A.map((e,i)=>V.jsxs("div",{className:"flex items-center",children:[i>0&&V.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),V.jsx(BHt,{solver:e})]},e.constructor.name))})},lHt=({solver:t,triggerRender:A,animationSpeed:e=25,onSolverStarted:i,onSolverCompleted:o})=>{const[n,s]=AA.useReducer(Q=>!Q,!1),r=AA.useRef(void 0),a=()=>{!t.solved&&!t.failed&&(t.step(),A())},g=()=>{!t.solved&&!t.failed&&(i&&i(t),t.solve(),A(),o&&o(t))},I=()=>{n?(r.current&&(clearInterval(r.current),r.current=void 0),s()):(s(),r.current=setInterval(()=>{if(t.solved||t.failed){r.current&&(clearInterval(r.current),r.current=void 0),s(),A(),o&&t.solved&&o(t);return}t.step(),A()},e))},c=()=>{const Q=t;if(Q.getCurrentPhase&&!t.solved&&!t.failed){const E=Q.getCurrentPhase();for(;Q.getCurrentPhase()===E&&!t.solved&&!t.failed;)t.step();A()}},B=()=>{if(t.solved||t.failed||n)return;const Q=window.prompt("Step until which iteration?",`${t.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(;t.iterations<E&&!t.solved&&!t.failed;)t.step();A(),t.solved&&o&&o(t)};AA.useEffect(()=>()=>{r.current&&clearInterval(r.current)},[]),AA.useEffect(()=>{(t.solved||t.failed)&&n&&(r.current&&(clearInterval(r.current),r.current=void 0),s())},[t.solved,t.failed,n]);const C=t.getCurrentPhase!==void 0,l=C?t.getCurrentPhase():null;return V.jsxs("div",{className:"space-y-2 p-2 border-b",children:[V.jsx("div",{className:"flex items-center",children:V.jsx(CHt,{solver:t})}),V.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[V.jsx("button",{onClick:a,disabled:t.solved||t.failed||n,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),V.jsx("button",{onClick:g,disabled:t.solved||t.failed||n,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),V.jsx("button",{onClick:I,disabled:t.solved||t.failed,className:`px-3 py-1 rounded text-white text-sm ${n?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:n?"Stop":"Animate"}),V.jsx("button",{onClick:B,disabled:t.solved||t.failed||n,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"}),C&&V.jsx("button",{onClick:c,disabled:t.solved||t.failed||n,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),V.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&V.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),l&&V.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",V.jsx("span",{className:"font-medium",children:l})]}),t.solved&&V.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&V.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&V.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},QHt=(t,A,e)=>{const i=t.currentPipelineStepIndex;return A<i?"Completed":A===i&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},EHt=(t,A)=>{const i=t.pipelineDef[A].solverName,o=QHt(t,A),n=t[i],s=t.firstIterationOfPhase?.[i]??null,r=t.iterations;let a=0;if(o==="Completed"){const B=t.pipelineDef[A+1],C=B?t.firstIterationOfPhase?.[B.solverName]:void 0;C!==void 0&&s!==null?a=C-s:s!==null&&(a=r-s)}else o==="In Progress"&&s!==null&&(a=r-s);const g=t.timeSpentOnPhase?.[i]??0;let I=0;o==="Completed"?I=1:o==="In Progress"&&n&&(I=n.progress??0);const c=n?.stats??null;return{index:A,name:i,status:o,firstIteration:s,iterations:a,progress:I,timeSpent:g,stats:c&&Object.keys(c).length>0?c:null,solverInstance:n??null}},hHt=({status:t})=>{const A={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return V.jsx("span",{className:`font-medium ${A[t]}`,children:t})},uHt=({progress:t})=>{if(t===0)return null;const A=Math.round(t*100);return V.jsxs("div",{className:"flex items-center gap-2",children:[V.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:V.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${A}%`}})}),V.jsxs("span",{className:"text-xs text-gray-500",children:[A,"%"]})]})},dHt=t=>Object.entries(t).map(([A,e])=>`${A}: ${e}`).join(", "),pHt=({stats:t})=>{if(!t||Object.keys(t).length===0)return V.jsx("span",{children:"-"});const A=Object.entries(t),e=dHt(t);return V.jsxs("details",{className:"cursor-pointer",children:[V.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:e}),V.jsx("div",{className:"mt-1 text-xs",children:A.map(([i,o])=>V.jsxs("div",{children:[i,": ",String(o)]},i))})]})},xEA=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(xEA);const A={};for(const[e,i]of Object.entries(t))e.startsWith("_")||(A[e]=xEA(i));return A},fHt=(t,A)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${A}`);return}const e=xEA(t.getConstructorParams()),i=new Blob([JSON.stringify(e,null,2)],{type:"application/json"}),o=URL.createObjectURL(i),n=document.createElement("a");n.href=o,n.download=`${A}_input.json`,n.click(),URL.revokeObjectURL(o)}catch(e){alert(`Error downloading input for ${A}: ${e instanceof Error?e.message:String(e)}`)}},yHt=({solver:t,onStepUntilPhase:A,onDownloadInput:e})=>{const i=t.pipelineDef.map((r,a)=>EHt(t,a)),o=r=>{A?.(r)},n=r=>{r.solverInstance&&(e?e(r.solverInstance,r.name):fHt(r.solverInstance,r.name))},s=r=>`${(r/1e3).toFixed(2)}s`;return V.jsxs("div",{className:"border-t border-gray-200",children:[V.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:V.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),V.jsx("div",{className:"overflow-x-auto",children:V.jsxs("table",{className:"w-full text-sm",children:[V.jsx("thead",{children:V.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),V.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",V.jsx("sub",{children:"0"})]}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),V.jsx("tbody",{children:i.map(r=>V.jsxs("tr",{className:`border-b border-gray-100 ${r.status==="In Progress"?"bg-yellow-50":""}`,children:[V.jsx("td",{className:"px-4 py-2",children:V.jsxs("div",{className:"flex items-center gap-2",children:[V.jsx("span",{className:"text-gray-400 w-6",children:String(r.index+1).padStart(2,"0")}),V.jsx("button",{onClick:()=>o(r.name),disabled:r.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 ${r.name} completes`,children:V.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:V.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"})})}),V.jsx("span",{className:"font-medium text-gray-900",children:r.name})]})}),V.jsx("td",{className:"px-4 py-2",children:V.jsx(hHt,{status:r.status})}),V.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:r.firstIteration!==null?r.firstIteration:""}),V.jsx("td",{className:"px-4 py-2 text-gray-600",children:r.iterations}),V.jsx("td",{className:"px-4 py-2",children:V.jsx(uHt,{progress:r.progress})}),V.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(r.timeSpent)}),V.jsx("td",{className:"px-4 py-2 text-gray-500",children:V.jsx(pHt,{stats:r.stats})}),V.jsx("td",{className:"px-4 py-2",children:r.solverInstance?V.jsxs("button",{onClick:()=>n(r),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${r.name}`,children:[V.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:V.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"})}),V.jsx("span",{children:"Input"})]}):null})]},r.name))})]})})]})},mHt=class extends Ao.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 wHt({graphics:t}){const A=t.points??[],e=t.lines??[],i=t.rects??[],o=t.circles??[],n=t.texts??[];let s=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,g=Number.NEGATIVE_INFINITY;const I=(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)I(E.x,E.y);for(const E of e){const h=E.points??[];for(const u of h)I(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;I(h,u),I(h+d,u+f)}for(const E of o){const h=E.x??0,u=E.y??0,d=E.radius??1;I(h-d,u-d),I(h+d,u+d)}for(const E of n)I(E.x,E.y);(!isFinite(s)||!isFinite(r)||!isFinite(a)||!isFinite(g))&&(s=-20,r=-20,a=20,g=20);const c=10,B=s-c,C=r-c,l=Math.max(1,a-s+2*c),Q=Math.max(1,g-r+2*c);return V.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${B} ${C} ${l} ${Q}`,role:"img","aria-label":"Graphics fallback",children:[i.map((E,h)=>V.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}`)),e.map((E,h)=>V.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}`)),o.map((E,h)=>V.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)=>V.jsx("circle",{cx:E.x??0,cy:E.y??0,r:E.radius??1.5,fill:E.color??"black"},`point-${h}`)),n.map((E,h)=>V.jsx("text",{x:E.x??0,y:E.y??0,fontSize:E.fontSize??10,fill:E.color??"black",children:E.text??""},`text-${h}`))]})}var DHt=({solver:t,animationSpeed:A=25,onSolverStarted:e,onSolverCompleted:i})=>{const[o,n]=AA.useReducer(I=>I+1,0),s=AA.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(I){return console.error("Visualization error:",I),{points:[],lines:[],rects:[],circles:[]}}},[t,o]),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 I=document.createElement("script");I.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(I)}},[]);const a=t.pipelineDef!==void 0,g=I=>{const c=t;if(!t.solved&&!t.failed){for(;!t.solved&&!t.failed&&c.currentPipelineStepIndex<=c.pipelineDef.findIndex(B=>B.solverName===I);)t.step();n()}};return V.jsxs("div",{children:[V.jsx(lHt,{solver:t,triggerRender:n,animationSpeed:A,onSolverStarted:e,onSolverCompleted:i}),r?V.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):V.jsx(mHt,{fallback:V.jsx(wHt,{graphics:s}),children:V.jsx(cHt,{graphics:s})}),a&&V.jsx(yHt,{solver:t,onStepUntilPhase:g})]})};const SHt=()=>{AA.useEffect(()=>{const t="tailwind-cdn-script";if(document.getElementById(t)||window.tailwind)return;const A=document.createElement("div");A.className="hidden",document.body.appendChild(A);const e=window.getComputedStyle(A).display==="none";if(document.body.removeChild(A),e)return;const i=document.createElement("script");i.id=t,i.src="https://cdn.tailwindcss.com",document.head.appendChild(i)},[])},bHt=t=>t.toLowerCase().includes("pack")?_mt:t.toLowerCase().includes("rout")?Lmt:mmt,xHt=({solverEvents:t=[]})=>{const[A,e]=AA.useState(null);SHt();const i=AA.useMemo(()=>{const r=new Map;for(const a of t){const g=`${a.componentName}-${a.solverName}`;r.set(g,a)}return r},[t]),o=AA.useMemo(()=>Array.from(i.keys()),[i]),n=A?i.get(A):null,s=AA.useMemo(()=>{if(!n)return{instance:null,error:null,classFound:!1};const r=WHA[n.solverName];if(!r)return{instance:null,error:`Solver class "${n.solverName}" not found in SOLVERS registry. Available: ${Object.keys(WHA).join(", ")}`,classFound:!1};try{const a=n.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}}},[n]);return t.length===0?V.jsx("div",{className:"rf-p-4",children:V.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:V.jsxs("div",{className:"rf-p-4",children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),V.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."})]})})}):V.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[V.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[V.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:[o.length," ",o.length===1?"Solver":"Solvers"]}),o.map(r=>{const a=i.get(r),g=A===r;return V.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:()=>e(r),children:(()=>{const I=bHt(a.solverName);return V.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[V.jsx(I,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),V.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[V.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:a.componentName}),V.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:a.solverName})]})]})})()},r)})]}),V.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:n?s.instance?V.jsx(Rw,{fallback:V.jsx("div",{className:"rf-p-4",children:V.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),V.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",n.solverName]})]})}),children:V.jsx(DHt,{solver:s.instance})}):V.jsxs("div",{className:"rf-p-4",children:[V.jsxs("div",{className:"rf-mb-4",children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:n.solverName}),V.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",n.componentName]})]}),s.error&&V.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:V.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),V.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[V.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:V.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),V.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:V.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(n.solverParams,null,2)})})]})]}):V.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:V.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},wie=({errorMessage:t,errorStack:A,circuitJsonErrors:e})=>{AA.useEffect(()=>{if(t){const i=new Error(t);A&&(i.stack=A);try{ZJ.captureException(i)}catch{}}},[t,A]),AA.useEffect(()=>{if(e&&e.length>0)for(const i of e){const o=new Error(i.message||"Circuit JSON Error");i.stack&&(o.stack=i.stack);try{ZJ.captureException(o,{error_type:i.type})}catch{}}},[e])},Die="0.0.1423",kHt={version:Die},kEA={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},GEA=new Map,lW=t=>{const A=GEA.get(t);return A?Object.fromEntries(Object.entries(A.stores).map(([e,i])=>[e,i.getState()])):{}},GHt=(t,A,e)=>{if(t===void 0)return{type:"untracked",connection:A.connect(e)};const i=GEA.get(e.name);if(i)return{type:"tracked",store:t,...i};const o={connection:A.connect(e),stores:{}};return GEA.set(e.name,o),{type:"tracked",store:t,...o}},Sie=(t,A={})=>(e,i,o)=>{const{enabled:n,anonymousActionType:s,store:r,...a}=A;let g;try{g=(n??(kEA?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!g)return(kEA?"production":void 0)!=="production"&&n&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),t(e,i,o);const{connection:I,...c}=GHt(r,g,a);let B=!0;o.setState=(Q,E,h)=>{const u=e(Q,E);if(!B)return u;const d=h===void 0?{type:s||"anonymous"}:typeof h=="string"?{type:h}:h;return r===void 0?(I?.send(d,i()),u):(I?.send({...d,type:`${r}/${d.type}`},{...lW(a.name),[r]:o.getState()}),u)};const C=(...Q)=>{const E=B;B=!1,e(...Q),B=E},l=t(o.setState,i,o);if(c.type==="untracked"?I?.init(l):(c.stores[c.store]=o,I?.init(Object.fromEntries(Object.entries(c.stores).map(([Q,E])=>[Q,Q===c.store?l:E.getState()])))),o.dispatchFromDevtools&&typeof o.dispatch=="function"){let Q=!1;const E=o.dispatch;o.dispatch=(...h)=>{(kEA?"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 I.subscribe(Q=>{var E;switch(Q.type){case"ACTION":if(typeof Q.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return FEA(Q.payload,h=>{if(h.type==="__setState"){if(r===void 0){C(h.state);return}Object.keys(h.state).length!==1&&console.error(`
5601
+ `,c=new Blob([I],{type:"text/plain"}),B=URL.createObjectURL(c),C=document.createElement("a");C.href=B,C.download=`${g}.test.ts`,C.click(),URL.revokeObjectURL(B)}catch(a){alert(`Error generating test.ts for ${t.constructor.name}: ${a instanceof Error?a.message:String(a)}`)}i(!1)};return V.jsxs("div",{className:`relative ${A}`,ref:o,children:[V.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>i(!e),title:`Download options for ${t.constructor.name}`,children:t.constructor.name}),e&&V.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:[V.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:n,children:"Download JSON"}),V.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),V.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download test.ts"})]})]})},mie=t=>t.activeSubSolver?[t,...mie(t.activeSubSolver)]:[t],CHt=({solver:t})=>{const A=mie(t);return V.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:A.map((e,i)=>V.jsxs("div",{className:"flex items-center",children:[i>0&&V.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),V.jsx(BHt,{solver:e})]},e.constructor.name))})},lHt=({solver:t,triggerRender:A,animationSpeed:e=25,onSolverStarted:i,onSolverCompleted:o})=>{const[n,s]=AA.useReducer(Q=>!Q,!1),r=AA.useRef(void 0),a=()=>{!t.solved&&!t.failed&&(t.step(),A())},g=()=>{!t.solved&&!t.failed&&(i&&i(t),t.solve(),A(),o&&o(t))},I=()=>{n?(r.current&&(clearInterval(r.current),r.current=void 0),s()):(s(),r.current=setInterval(()=>{if(t.solved||t.failed){r.current&&(clearInterval(r.current),r.current=void 0),s(),A(),o&&t.solved&&o(t);return}t.step(),A()},e))},c=()=>{const Q=t;if(Q.getCurrentPhase&&!t.solved&&!t.failed){const E=Q.getCurrentPhase();for(;Q.getCurrentPhase()===E&&!t.solved&&!t.failed;)t.step();A()}},B=()=>{if(t.solved||t.failed||n)return;const Q=window.prompt("Step until which iteration?",`${t.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(;t.iterations<E&&!t.solved&&!t.failed;)t.step();A(),t.solved&&o&&o(t)};AA.useEffect(()=>()=>{r.current&&clearInterval(r.current)},[]),AA.useEffect(()=>{(t.solved||t.failed)&&n&&(r.current&&(clearInterval(r.current),r.current=void 0),s())},[t.solved,t.failed,n]);const C=t.getCurrentPhase!==void 0,l=C?t.getCurrentPhase():null;return V.jsxs("div",{className:"space-y-2 p-2 border-b",children:[V.jsx("div",{className:"flex items-center",children:V.jsx(CHt,{solver:t})}),V.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[V.jsx("button",{onClick:a,disabled:t.solved||t.failed||n,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),V.jsx("button",{onClick:g,disabled:t.solved||t.failed||n,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),V.jsx("button",{onClick:I,disabled:t.solved||t.failed,className:`px-3 py-1 rounded text-white text-sm ${n?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:n?"Stop":"Animate"}),V.jsx("button",{onClick:B,disabled:t.solved||t.failed||n,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"}),C&&V.jsx("button",{onClick:c,disabled:t.solved||t.failed||n,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),V.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&V.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),l&&V.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",V.jsx("span",{className:"font-medium",children:l})]}),t.solved&&V.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&V.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&V.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},QHt=(t,A,e)=>{const i=t.currentPipelineStepIndex;return A<i?"Completed":A===i&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},EHt=(t,A)=>{const i=t.pipelineDef[A].solverName,o=QHt(t,A),n=t[i],s=t.firstIterationOfPhase?.[i]??null,r=t.iterations;let a=0;if(o==="Completed"){const B=t.pipelineDef[A+1],C=B?t.firstIterationOfPhase?.[B.solverName]:void 0;C!==void 0&&s!==null?a=C-s:s!==null&&(a=r-s)}else o==="In Progress"&&s!==null&&(a=r-s);const g=t.timeSpentOnPhase?.[i]??0;let I=0;o==="Completed"?I=1:o==="In Progress"&&n&&(I=n.progress??0);const c=n?.stats??null;return{index:A,name:i,status:o,firstIteration:s,iterations:a,progress:I,timeSpent:g,stats:c&&Object.keys(c).length>0?c:null,solverInstance:n??null}},hHt=({status:t})=>{const A={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return V.jsx("span",{className:`font-medium ${A[t]}`,children:t})},uHt=({progress:t})=>{if(t===0)return null;const A=Math.round(t*100);return V.jsxs("div",{className:"flex items-center gap-2",children:[V.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:V.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${A}%`}})}),V.jsxs("span",{className:"text-xs text-gray-500",children:[A,"%"]})]})},dHt=t=>Object.entries(t).map(([A,e])=>`${A}: ${e}`).join(", "),pHt=({stats:t})=>{if(!t||Object.keys(t).length===0)return V.jsx("span",{children:"-"});const A=Object.entries(t),e=dHt(t);return V.jsxs("details",{className:"cursor-pointer",children:[V.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:e}),V.jsx("div",{className:"mt-1 text-xs",children:A.map(([i,o])=>V.jsxs("div",{children:[i,": ",String(o)]},i))})]})},xEA=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(xEA);const A={};for(const[e,i]of Object.entries(t))e.startsWith("_")||(A[e]=xEA(i));return A},fHt=(t,A)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${A}`);return}const e=xEA(t.getConstructorParams()),i=new Blob([JSON.stringify(e,null,2)],{type:"application/json"}),o=URL.createObjectURL(i),n=document.createElement("a");n.href=o,n.download=`${A}_input.json`,n.click(),URL.revokeObjectURL(o)}catch(e){alert(`Error downloading input for ${A}: ${e instanceof Error?e.message:String(e)}`)}},yHt=({solver:t,onStepUntilPhase:A,onDownloadInput:e})=>{const i=t.pipelineDef.map((r,a)=>EHt(t,a)),o=r=>{A?.(r)},n=r=>{r.solverInstance&&(e?e(r.solverInstance,r.name):fHt(r.solverInstance,r.name))},s=r=>`${(r/1e3).toFixed(2)}s`;return V.jsxs("div",{className:"border-t border-gray-200",children:[V.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:V.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),V.jsx("div",{className:"overflow-x-auto",children:V.jsxs("table",{className:"w-full text-sm",children:[V.jsx("thead",{children:V.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),V.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",V.jsx("sub",{children:"0"})]}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),V.jsx("tbody",{children:i.map(r=>V.jsxs("tr",{className:`border-b border-gray-100 ${r.status==="In Progress"?"bg-yellow-50":""}`,children:[V.jsx("td",{className:"px-4 py-2",children:V.jsxs("div",{className:"flex items-center gap-2",children:[V.jsx("span",{className:"text-gray-400 w-6",children:String(r.index+1).padStart(2,"0")}),V.jsx("button",{onClick:()=>o(r.name),disabled:r.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 ${r.name} completes`,children:V.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:V.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"})})}),V.jsx("span",{className:"font-medium text-gray-900",children:r.name})]})}),V.jsx("td",{className:"px-4 py-2",children:V.jsx(hHt,{status:r.status})}),V.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:r.firstIteration!==null?r.firstIteration:""}),V.jsx("td",{className:"px-4 py-2 text-gray-600",children:r.iterations}),V.jsx("td",{className:"px-4 py-2",children:V.jsx(uHt,{progress:r.progress})}),V.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(r.timeSpent)}),V.jsx("td",{className:"px-4 py-2 text-gray-500",children:V.jsx(pHt,{stats:r.stats})}),V.jsx("td",{className:"px-4 py-2",children:r.solverInstance?V.jsxs("button",{onClick:()=>n(r),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${r.name}`,children:[V.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:V.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"})}),V.jsx("span",{children:"Input"})]}):null})]},r.name))})]})})]})},mHt=class extends Ao.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 wHt({graphics:t}){const A=t.points??[],e=t.lines??[],i=t.rects??[],o=t.circles??[],n=t.texts??[];let s=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,g=Number.NEGATIVE_INFINITY;const I=(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)I(E.x,E.y);for(const E of e){const h=E.points??[];for(const u of h)I(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;I(h,u),I(h+d,u+f)}for(const E of o){const h=E.x??0,u=E.y??0,d=E.radius??1;I(h-d,u-d),I(h+d,u+d)}for(const E of n)I(E.x,E.y);(!isFinite(s)||!isFinite(r)||!isFinite(a)||!isFinite(g))&&(s=-20,r=-20,a=20,g=20);const c=10,B=s-c,C=r-c,l=Math.max(1,a-s+2*c),Q=Math.max(1,g-r+2*c);return V.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${B} ${C} ${l} ${Q}`,role:"img","aria-label":"Graphics fallback",children:[i.map((E,h)=>V.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}`)),e.map((E,h)=>V.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}`)),o.map((E,h)=>V.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)=>V.jsx("circle",{cx:E.x??0,cy:E.y??0,r:E.radius??1.5,fill:E.color??"black"},`point-${h}`)),n.map((E,h)=>V.jsx("text",{x:E.x??0,y:E.y??0,fontSize:E.fontSize??10,fill:E.color??"black",children:E.text??""},`text-${h}`))]})}var DHt=({solver:t,animationSpeed:A=25,onSolverStarted:e,onSolverCompleted:i})=>{const[o,n]=AA.useReducer(I=>I+1,0),s=AA.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(I){return console.error("Visualization error:",I),{points:[],lines:[],rects:[],circles:[]}}},[t,o]),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 I=document.createElement("script");I.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(I)}},[]);const a=t.pipelineDef!==void 0,g=I=>{const c=t;if(!t.solved&&!t.failed){for(;!t.solved&&!t.failed&&c.currentPipelineStepIndex<=c.pipelineDef.findIndex(B=>B.solverName===I);)t.step();n()}};return V.jsxs("div",{children:[V.jsx(lHt,{solver:t,triggerRender:n,animationSpeed:A,onSolverStarted:e,onSolverCompleted:i}),r?V.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):V.jsx(mHt,{fallback:V.jsx(wHt,{graphics:s}),children:V.jsx(cHt,{graphics:s})}),a&&V.jsx(yHt,{solver:t,onStepUntilPhase:g})]})};const SHt=()=>{AA.useEffect(()=>{const t="tailwind-cdn-script";if(document.getElementById(t)||window.tailwind)return;const A=document.createElement("div");A.className="hidden",document.body.appendChild(A);const e=window.getComputedStyle(A).display==="none";if(document.body.removeChild(A),e)return;const i=document.createElement("script");i.id=t,i.src="https://cdn.tailwindcss.com",document.head.appendChild(i)},[])},bHt=t=>t.toLowerCase().includes("pack")?_mt:t.toLowerCase().includes("rout")?Lmt:mmt,xHt=({solverEvents:t=[]})=>{const[A,e]=AA.useState(null);SHt();const i=AA.useMemo(()=>{const r=new Map;for(const a of t){const g=`${a.componentName}-${a.solverName}`;r.set(g,a)}return r},[t]),o=AA.useMemo(()=>Array.from(i.keys()),[i]),n=A?i.get(A):null,s=AA.useMemo(()=>{if(!n)return{instance:null,error:null,classFound:!1};const r=WHA[n.solverName];if(!r)return{instance:null,error:`Solver class "${n.solverName}" not found in SOLVERS registry. Available: ${Object.keys(WHA).join(", ")}`,classFound:!1};try{const a=n.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}}},[n]);return t.length===0?V.jsx("div",{className:"rf-p-4",children:V.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:V.jsxs("div",{className:"rf-p-4",children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),V.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."})]})})}):V.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[V.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[V.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:[o.length," ",o.length===1?"Solver":"Solvers"]}),o.map(r=>{const a=i.get(r),g=A===r;return V.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:()=>e(r),children:(()=>{const I=bHt(a.solverName);return V.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[V.jsx(I,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),V.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[V.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:a.componentName}),V.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:a.solverName})]})]})})()},r)})]}),V.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:n?s.instance?V.jsx(Rw,{fallback:V.jsx("div",{className:"rf-p-4",children:V.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),V.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",n.solverName]})]})}),children:V.jsx(DHt,{solver:s.instance})}):V.jsxs("div",{className:"rf-p-4",children:[V.jsxs("div",{className:"rf-mb-4",children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:n.solverName}),V.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",n.componentName]})]}),s.error&&V.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:V.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),V.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[V.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:V.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),V.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:V.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(n.solverParams,null,2)})})]})]}):V.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:V.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},wie=({errorMessage:t,errorStack:A,circuitJsonErrors:e})=>{AA.useEffect(()=>{if(t){const i=new Error(t);A&&(i.stack=A);try{ZJ.captureException(i)}catch{}}},[t,A]),AA.useEffect(()=>{if(e&&e.length>0)for(const i of e){const o=new Error(i.message||"Circuit JSON Error");i.stack&&(o.stack=i.stack);try{ZJ.captureException(o,{error_type:i.type})}catch{}}},[e])},Die="0.0.1424",kHt={version:Die},kEA={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},GEA=new Map,lW=t=>{const A=GEA.get(t);return A?Object.fromEntries(Object.entries(A.stores).map(([e,i])=>[e,i.getState()])):{}},GHt=(t,A,e)=>{if(t===void 0)return{type:"untracked",connection:A.connect(e)};const i=GEA.get(e.name);if(i)return{type:"tracked",store:t,...i};const o={connection:A.connect(e),stores:{}};return GEA.set(e.name,o),{type:"tracked",store:t,...o}},Sie=(t,A={})=>(e,i,o)=>{const{enabled:n,anonymousActionType:s,store:r,...a}=A;let g;try{g=(n??(kEA?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!g)return(kEA?"production":void 0)!=="production"&&n&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),t(e,i,o);const{connection:I,...c}=GHt(r,g,a);let B=!0;o.setState=(Q,E,h)=>{const u=e(Q,E);if(!B)return u;const d=h===void 0?{type:s||"anonymous"}:typeof h=="string"?{type:h}:h;return r===void 0?(I?.send(d,i()),u):(I?.send({...d,type:`${r}/${d.type}`},{...lW(a.name),[r]:o.getState()}),u)};const C=(...Q)=>{const E=B;B=!1,e(...Q),B=E},l=t(o.setState,i,o);if(c.type==="untracked"?I?.init(l):(c.stores[c.store]=o,I?.init(Object.fromEntries(Object.entries(c.stores).map(([Q,E])=>[Q,Q===c.store?l:E.getState()])))),o.dispatchFromDevtools&&typeof o.dispatch=="function"){let Q=!1;const E=o.dispatch;o.dispatch=(...h)=>{(kEA?"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 I.subscribe(Q=>{var E;switch(Q.type){case"ACTION":if(typeof Q.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return FEA(Q.payload,h=>{if(h.type==="__setState"){if(r===void 0){C(h.state);return}Object.keys(h.state).length!==1&&console.error(`
5602
5602
  [zustand devtools middleware] Unsupported __setState action format.
5603
5603
  When using 'store' option in devtools(), the 'state' should have only one key, which is a value of 'store' that was passed in devtools(),
5604
5604
  and value of this only key should be a state object. Example: { "type": "__setState", "state": { "abc123Store": { "foo": "bar" } } }
@@ -5602,7 +5602,7 @@ test("${g} should solve problem correctly", () => {
5602
5602
  // Add more specific assertions based on expected output
5603
5603
  // expect(solver.netLabelPlacementSolver!.netLabelPlacements).toMatchInlineSnapshot()
5604
5604
  })
5605
- `,c=new Blob([I],{type:"text/plain"}),B=URL.createObjectURL(c),l=document.createElement("a");l.href=B,l.download=`${g}.test.ts`,l.click(),URL.revokeObjectURL(B)}catch(a){alert(`Error generating test.ts for ${t.constructor.name}: ${a instanceof Error?a.message:String(a)}`)}i(!1)};return O.jsxs("div",{className:`relative ${A}`,ref:o,children:[O.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>i(!e),title:`Download options for ${t.constructor.name}`,children:t.constructor.name}),e&&O.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:[O.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:n,children:"Download JSON"}),O.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),O.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download test.ts"})]})]})},Loe=t=>t.activeSubSolver?[t,...Loe(t.activeSubSolver)]:[t],ZJt=({solver:t})=>{const A=Loe(t);return O.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:A.map((e,i)=>O.jsxs("div",{className:"flex items-center",children:[i>0&&O.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),O.jsx(WJt,{solver:e})]},e.constructor.name))})},VJt=({solver:t,triggerRender:A,animationSpeed:e=25,onSolverStarted:i,onSolverCompleted:o})=>{const[n,s]=z.useReducer(Q=>!Q,!1),r=z.useRef(void 0),a=()=>{!t.solved&&!t.failed&&(t.step(),A())},g=()=>{!t.solved&&!t.failed&&(i&&i(t),t.solve(),A(),o&&o(t))},I=()=>{n?(r.current&&(clearInterval(r.current),r.current=void 0),s()):(s(),r.current=setInterval(()=>{if(t.solved||t.failed){r.current&&(clearInterval(r.current),r.current=void 0),s(),A(),o&&t.solved&&o(t);return}t.step(),A()},e))},c=()=>{const Q=t;if(Q.getCurrentPhase&&!t.solved&&!t.failed){const E=Q.getCurrentPhase();for(;Q.getCurrentPhase()===E&&!t.solved&&!t.failed;)t.step();A()}},B=()=>{if(t.solved||t.failed||n)return;const Q=window.prompt("Step until which iteration?",`${t.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(;t.iterations<E&&!t.solved&&!t.failed;)t.step();A(),t.solved&&o&&o(t)};z.useEffect(()=>()=>{r.current&&clearInterval(r.current)},[]),z.useEffect(()=>{(t.solved||t.failed)&&n&&(r.current&&(clearInterval(r.current),r.current=void 0),s())},[t.solved,t.failed,n]);const l=t.getCurrentPhase!==void 0,C=l?t.getCurrentPhase():null;return O.jsxs("div",{className:"space-y-2 p-2 border-b",children:[O.jsx("div",{className:"flex items-center",children:O.jsx(ZJt,{solver:t})}),O.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[O.jsx("button",{onClick:a,disabled:t.solved||t.failed||n,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),O.jsx("button",{onClick:g,disabled:t.solved||t.failed||n,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),O.jsx("button",{onClick:I,disabled:t.solved||t.failed,className:`px-3 py-1 rounded text-white text-sm ${n?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:n?"Stop":"Animate"}),O.jsx("button",{onClick:B,disabled:t.solved||t.failed||n,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"}),l&&O.jsx("button",{onClick:c,disabled:t.solved||t.failed||n,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),O.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&O.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),C&&O.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",O.jsx("span",{className:"font-medium",children:C})]}),t.solved&&O.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&O.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&O.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},jJt=(t,A,e)=>{const i=t.currentPipelineStepIndex;return A<i?"Completed":A===i&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},zJt=(t,A)=>{const i=t.pipelineDef[A].solverName,o=jJt(t,A),n=t[i],s=t.firstIterationOfPhase?.[i]??null,r=t.iterations;let a=0;if(o==="Completed"){const B=t.pipelineDef[A+1],l=B?t.firstIterationOfPhase?.[B.solverName]:void 0;l!==void 0&&s!==null?a=l-s:s!==null&&(a=r-s)}else o==="In Progress"&&s!==null&&(a=r-s);const g=t.timeSpentOnPhase?.[i]??0;let I=0;o==="Completed"?I=1:o==="In Progress"&&n&&(I=n.progress??0);const c=n?.stats??null;return{index:A,name:i,status:o,firstIteration:s,iterations:a,progress:I,timeSpent:g,stats:c&&Object.keys(c).length>0?c:null,solverInstance:n??null}},XJt=({status:t})=>{const A={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return O.jsx("span",{className:`font-medium ${A[t]}`,children:t})},$Jt=({progress:t})=>{if(t===0)return null;const A=Math.round(t*100);return O.jsxs("div",{className:"flex items-center gap-2",children:[O.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:O.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${A}%`}})}),O.jsxs("span",{className:"text-xs text-gray-500",children:[A,"%"]})]})},ATt=t=>Object.entries(t).map(([A,e])=>`${A}: ${e}`).join(", "),eTt=({stats:t})=>{if(!t||Object.keys(t).length===0)return O.jsx("span",{children:"-"});const A=Object.entries(t),e=ATt(t);return O.jsxs("details",{className:"cursor-pointer",children:[O.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:e}),O.jsx("div",{className:"mt-1 text-xs",children:A.map(([i,o])=>O.jsxs("div",{children:[i,": ",String(o)]},i))})]})},bhA=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(bhA);const A={};for(const[e,i]of Object.entries(t))e.startsWith("_")||(A[e]=bhA(i));return A},tTt=(t,A)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${A}`);return}const e=bhA(t.getConstructorParams()),i=new Blob([JSON.stringify(e,null,2)],{type:"application/json"}),o=URL.createObjectURL(i),n=document.createElement("a");n.href=o,n.download=`${A}_input.json`,n.click(),URL.revokeObjectURL(o)}catch(e){alert(`Error downloading input for ${A}: ${e instanceof Error?e.message:String(e)}`)}},iTt=({solver:t,onStepUntilPhase:A,onDownloadInput:e})=>{const i=t.pipelineDef.map((r,a)=>zJt(t,a)),o=r=>{A?.(r)},n=r=>{r.solverInstance&&(e?e(r.solverInstance,r.name):tTt(r.solverInstance,r.name))},s=r=>`${(r/1e3).toFixed(2)}s`;return O.jsxs("div",{className:"border-t border-gray-200",children:[O.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:O.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),O.jsx("div",{className:"overflow-x-auto",children:O.jsxs("table",{className:"w-full text-sm",children:[O.jsx("thead",{children:O.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[O.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),O.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),O.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",O.jsx("sub",{children:"0"})]}),O.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),O.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),O.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),O.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),O.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),O.jsx("tbody",{children:i.map(r=>O.jsxs("tr",{className:`border-b border-gray-100 ${r.status==="In Progress"?"bg-yellow-50":""}`,children:[O.jsx("td",{className:"px-4 py-2",children:O.jsxs("div",{className:"flex items-center gap-2",children:[O.jsx("span",{className:"text-gray-400 w-6",children:String(r.index+1).padStart(2,"0")}),O.jsx("button",{onClick:()=>o(r.name),disabled:r.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 ${r.name} completes`,children:O.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:O.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"})})}),O.jsx("span",{className:"font-medium text-gray-900",children:r.name})]})}),O.jsx("td",{className:"px-4 py-2",children:O.jsx(XJt,{status:r.status})}),O.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:r.firstIteration!==null?r.firstIteration:""}),O.jsx("td",{className:"px-4 py-2 text-gray-600",children:r.iterations}),O.jsx("td",{className:"px-4 py-2",children:O.jsx($Jt,{progress:r.progress})}),O.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(r.timeSpent)}),O.jsx("td",{className:"px-4 py-2 text-gray-500",children:O.jsx(eTt,{stats:r.stats})}),O.jsx("td",{className:"px-4 py-2",children:r.solverInstance?O.jsxs("button",{onClick:()=>n(r),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${r.name}`,children:[O.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:O.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"})}),O.jsx("span",{children:"Input"})]}):null})]},r.name))})]})})]})},oTt=class extends eo.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 nTt({graphics:t}){const A=t.points??[],e=t.lines??[],i=t.rects??[],o=t.circles??[],n=t.texts??[];let s=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,g=Number.NEGATIVE_INFINITY;const I=(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)I(E.x,E.y);for(const E of e){const h=E.points??[];for(const u of h)I(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;I(h,u),I(h+d,u+f)}for(const E of o){const h=E.x??0,u=E.y??0,d=E.radius??1;I(h-d,u-d),I(h+d,u+d)}for(const E of n)I(E.x,E.y);(!isFinite(s)||!isFinite(r)||!isFinite(a)||!isFinite(g))&&(s=-20,r=-20,a=20,g=20);const c=10,B=s-c,l=r-c,C=Math.max(1,a-s+2*c),Q=Math.max(1,g-r+2*c);return O.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${B} ${l} ${C} ${Q}`,role:"img","aria-label":"Graphics fallback",children:[i.map((E,h)=>O.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}`)),e.map((E,h)=>O.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}`)),o.map((E,h)=>O.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)=>O.jsx("circle",{cx:E.x??0,cy:E.y??0,r:E.radius??1.5,fill:E.color??"black"},`point-${h}`)),n.map((E,h)=>O.jsx("text",{x:E.x??0,y:E.y??0,fontSize:E.fontSize??10,fill:E.color??"black",children:E.text??""},`text-${h}`))]})}var sTt=({solver:t,animationSpeed:A=25,onSolverStarted:e,onSolverCompleted:i})=>{const[o,n]=z.useReducer(I=>I+1,0),s=z.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(I){return console.error("Visualization error:",I),{points:[],lines:[],rects:[],circles:[]}}},[t,o]),r=z.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);z.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const I=document.createElement("script");I.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(I)}},[]);const a=t.pipelineDef!==void 0,g=I=>{const c=t;if(!t.solved&&!t.failed){for(;!t.solved&&!t.failed&&c.currentPipelineStepIndex<=c.pipelineDef.findIndex(B=>B.solverName===I);)t.step();n()}};return O.jsxs("div",{children:[O.jsx(VJt,{solver:t,triggerRender:n,animationSpeed:A,onSolverStarted:e,onSolverCompleted:i}),r?O.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):O.jsx(oTt,{fallback:O.jsx(nTt,{graphics:s}),children:O.jsx(OJt,{graphics:s})}),a&&O.jsx(iTt,{solver:t,onStepUntilPhase:g})]})};const rTt=()=>{z.useEffect(()=>{const t="tailwind-cdn-script";if(document.getElementById(t)||window.tailwind)return;const A=document.createElement("div");A.className="hidden",document.body.appendChild(A);const e=window.getComputedStyle(A).display==="none";if(document.body.removeChild(A),e)return;const i=document.createElement("script");i.id=t,i.src="https://cdn.tailwindcss.com",document.head.appendChild(i)},[])},aTt=t=>t.toLowerCase().includes("pack")?bSt:t.toLowerCase().includes("rout")?_St:ISt,gTt=({solverEvents:t=[]})=>{const[A,e]=z.useState(null);rTt();const i=z.useMemo(()=>{const r=new Map;for(const a of t){const g=`${a.componentName}-${a.solverName}`;r.set(g,a)}return r},[t]),o=z.useMemo(()=>Array.from(i.keys()),[i]),n=A?i.get(A):null,s=z.useMemo(()=>{if(!n)return{instance:null,error:null,classFound:!1};const r=FvA[n.solverName];if(!r)return{instance:null,error:`Solver class "${n.solverName}" not found in SOLVERS registry. Available: ${Object.keys(FvA).join(", ")}`,classFound:!1};try{const a=n.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}}},[n]);return t.length===0?O.jsx("div",{className:"rf-p-4",children:O.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:O.jsxs("div",{className:"rf-p-4",children:[O.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),O.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."})]})})}):O.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[O.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[O.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:[o.length," ",o.length===1?"Solver":"Solvers"]}),o.map(r=>{const a=i.get(r),g=A===r;return O.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:()=>e(r),children:(()=>{const I=aTt(a.solverName);return O.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[O.jsx(I,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),O.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[O.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:a.componentName}),O.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:a.solverName})]})]})})()},r)})]}),O.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:n?s.instance?O.jsx(fy,{fallback:O.jsx("div",{className:"rf-p-4",children:O.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[O.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),O.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",n.solverName]})]})}),children:O.jsx(sTt,{solver:s.instance})}):O.jsxs("div",{className:"rf-p-4",children:[O.jsxs("div",{className:"rf-mb-4",children:[O.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:n.solverName}),O.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",n.componentName]})]}),s.error&&O.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:O.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),O.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[O.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:O.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),O.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:O.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(n.solverParams,null,2)})})]})]}):O.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:O.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},Hoe=({errorMessage:t,errorStack:A,circuitJsonErrors:e})=>{z.useEffect(()=>{if(t){const i=new Error(t);A&&(i.stack=A);try{C3.captureException(i)}catch{}}},[t,A]),z.useEffect(()=>{if(e&&e.length>0)for(const i of e){const o=new Error(i.message||"Circuit JSON Error");i.stack&&(o.stack=i.stack);try{C3.captureException(o,{error_type:i.type})}catch{}}},[e])},Yoe="0.0.1423",ITt={version:Yoe},$W=PvA()(OvA(t=>({lastRunEvalVersion:void 0,setLastRunEvalVersion:A=>{t({lastRunEvalVersion:A})}}),{name:"runframe-runner-store"})),cTt=t=>{const[A,e]=z.useState([]),[i,o]=z.useState(null),[n,s]=z.useState(""),[r,a]=KM("eval-version-selection",null),g=$W(l=>l.setLastRunEvalVersion),I=$W(l=>l.lastRunEvalVersion);return z.useEffect(()=>{t&&fetch("https://data.jsdelivr.com/v1/package/npm/@tscircuit/eval").then(l=>l.json()).then(l=>{if(Array.isArray(l?.versions)){let C=[...l.versions];l.tags?.latest&&(o(l.tags.latest),C=C.filter(Q=>Q!==l.tags.latest)),e(C)}}).catch(()=>{})},[t]),z.useEffect(()=>{t&&(r?(window.TSCIRCUIT_LATEST_EVAL_VERSION=r,g(r)):i&&(window.TSCIRCUIT_LATEST_EVAL_VERSION=i,g(i)))},[t,r,i]),{versions:z.useMemo(()=>A.filter(l=>l.includes(n)).slice(0,50),[A,n]),latestVersion:i,lastRunEvalVersion:I,search:n,setSearch:s,selectVersion:l=>{a(l),s("")}}},BTt=({snippetNames:t,onSelect:A,onCancel:e,isOpen:i})=>{const[o,n]=z.useState(""),[s,r]=z.useState("");if(!i)return null;const a=t.filter(c=>c.toLowerCase().includes(s.toLowerCase())),g=s&&!t.includes(s),I=c=>{c.key==="Enter"&&(a.length===1?n(a[0]):g&&n(s))};return O.jsx("div",{className:"rf-fixed rf-inset-0 rf-bg-black rf-bg-opacity-50 rf-flex rf-items-center rf-justify-center rf-z-[100]",children:O.jsxs("div",{className:"rf-bg-white rf-rounded-lg rf-p-6 rf-w-96",children:[O.jsx("h2",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Select Snippet"}),O.jsx("input",{type:"text",className:"rf-w-full rf-px-4 rf-py-2 rf-border rf-rounded rf-mb-4",placeholder:"Search snippets or new snippet name...",value:s,onChange:c=>r(c.target.value),onKeyDown:I}),O.jsxs("div",{className:"rf-h-60 rf-overflow-y-auto",children:[a.map(c=>O.jsx("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 ${o===c?"bg-blue-50":""}`,onClick:()=>n(c),children:c},c)),g&&O.jsxs("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 text-blue-500 ${o===s?"bg-blue-50":""}`,onClick:()=>n(s),children:['Create new "',s,'"']})]}),O.jsxs("div",{className:"rf-mt-4 rf-flex rf-justify-end rf-gap-2",children:[O.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-text-gray-600 rf-hover:text-gray-800",onClick:e,children:"Cancel"}),O.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-bg-blue-500 rf-text-white rf-rounded rf-hover:bg-blue-600 rf-disabled:opacity-50",onClick:()=>o&&A(o),disabled:!o,children:o===s?`Create "${o}"`:`Save to ${o}`})]})]})})},lTt=t=>{const A=z.useRef(null),e=Jc(i=>i.recentEvents);z.useEffect(()=>{if(e.length===0)return;const i=e[0];i.event_id!==A.current&&(t(i),A.current=i.event_id)},[e,t])};function CTt(t){const A=QTt(t),e=z.forwardRef((i,o)=>{const{children:n,...s}=i,r=z.Children.toArray(n),a=r.find(hTt);if(a){const g=a.props.children,I=r.map(c=>c===a?z.Children.count(g)>1?z.Children.only(null):z.isValidElement(g)?g.props.children:null:c);return O.jsx(A,{...s,ref:o,children:z.isValidElement(g)?z.cloneElement(g,void 0,I):null})}return O.jsx(A,{...s,ref:o,children:n})});return e.displayName=`${t}.Slot`,e}function QTt(t){const A=z.forwardRef((e,i)=>{const{children:o,...n}=e;if(z.isValidElement(o)){const s=dTt(o),r=uTt(n,o.props);return o.type!==z.Fragment&&(r.ref=i?Kp(i,s):s),z.cloneElement(o,r)}return z.Children.count(o)>1?z.Children.only(null):null});return A.displayName=`${t}.SlotClone`,A}var ETt=Symbol("radix.slottable");function hTt(t){return z.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===ETt}function uTt(t,A){const e={...A};for(const i in A){const o=t[i],n=A[i];/^on[A-Z]/.test(i)?o&&n?e[i]=(...r)=>{const a=n(...r);return o(...r),a}:o&&(e[i]=o):i==="style"?e[i]={...o,...n}:i==="className"&&(e[i]=[o,n].filter(Boolean).join(" "))}return{...t,...e}}function dTt(t){let A=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,e=A&&"isReactWarning"in A&&A.isReactWarning;return e?t.ref:(A=Object.getOwnPropertyDescriptor(t,"ref")?.get,e=A&&"isReactWarning"in A&&A.isReactWarning,e?t.props.ref:t.props.ref||t.ref)}var AZ="Dialog",[Joe,Toe]=fw(AZ),[pTt,Lm]=Joe(AZ),Koe=t=>{const{__scopeDialog:A,children:e,open:i,defaultOpen:o,onOpenChange:n,modal:s=!0}=t,r=z.useRef(null),a=z.useRef(null),[g,I]=lG({prop:i,defaultProp:o??!1,onChange:n,caller:AZ});return O.jsx(pTt,{scope:A,triggerRef:r,contentRef:a,contentId:yu(),titleId:yu(),descriptionId:yu(),open:g,onOpenChange:I,onOpenToggle:z.useCallback(()=>I(c=>!c),[I]),modal:s,children:e})};Koe.displayName=AZ;var qoe="DialogTrigger",Poe=z.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,o=Lm(qoe,e),n=mB(A,o.triggerRef);return O.jsx(pg.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":GhA(o.open),...i,ref:n,onClick:Cn(t.onClick,o.onOpenToggle)})});Poe.displayName=qoe;var xhA="DialogPortal",[fTt,Ooe]=Joe(xhA,{forceMount:void 0}),Woe=t=>{const{__scopeDialog:A,forceMount:e,children:i,container:o}=t,n=Lm(xhA,A);return O.jsx(fTt,{scope:A,forceMount:e,children:z.Children.map(i,s=>O.jsx(Iy,{present:e||n.open,children:O.jsx(p8,{asChild:!0,container:o,children:s})}))})};Woe.displayName=xhA;var eZ="DialogOverlay",Zoe=z.forwardRef((t,A)=>{const e=Ooe(eZ,t.__scopeDialog),{forceMount:i=e.forceMount,...o}=t,n=Lm(eZ,t.__scopeDialog);return n.modal?O.jsx(Iy,{present:i||n.open,children:O.jsx(mTt,{...o,ref:A})}):null});Zoe.displayName=eZ;var yTt=CTt("DialogOverlay.RemoveScroll"),mTt=z.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,o=Lm(eZ,e);return O.jsx(x8,{as:yTt,allowPinchZoom:!0,shards:[o.contentRef],children:O.jsx(pg.div,{"data-state":GhA(o.open),...i,ref:A,style:{pointerEvents:"auto",...i.style}})})}),yF="DialogContent",Voe=z.forwardRef((t,A)=>{const e=Ooe(yF,t.__scopeDialog),{forceMount:i=e.forceMount,...o}=t,n=Lm(yF,t.__scopeDialog);return O.jsx(Iy,{present:i||n.open,children:n.modal?O.jsx(wTt,{...o,ref:A}):O.jsx(DTt,{...o,ref:A})})});Voe.displayName=yF;var wTt=z.forwardRef((t,A)=>{const e=Lm(yF,t.__scopeDialog),i=z.useRef(null),o=mB(A,e.contentRef,i);return z.useEffect(()=>{const n=i.current;if(n)return nQA(n)},[]),O.jsx(joe,{...t,ref:o,trapFocus:e.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Cn(t.onCloseAutoFocus,n=>{n.preventDefault(),e.triggerRef.current?.focus()}),onPointerDownOutside:Cn(t.onPointerDownOutside,n=>{const s=n.detail.originalEvent,r=s.button===0&&s.ctrlKey===!0;(s.button===2||r)&&n.preventDefault()}),onFocusOutside:Cn(t.onFocusOutside,n=>n.preventDefault())})}),DTt=z.forwardRef((t,A)=>{const e=Lm(yF,t.__scopeDialog),i=z.useRef(!1),o=z.useRef(!1);return O.jsx(joe,{...t,ref:A,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:n=>{t.onCloseAutoFocus?.(n),n.defaultPrevented||(i.current||e.triggerRef.current?.focus(),n.preventDefault()),i.current=!1,o.current=!1},onInteractOutside:n=>{t.onInteractOutside?.(n),n.defaultPrevented||(i.current=!0,n.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const s=n.target;e.triggerRef.current?.contains(s)&&n.preventDefault(),n.detail.originalEvent.type==="focusin"&&o.current&&n.preventDefault()}})}),joe=z.forwardRef((t,A)=>{const{__scopeDialog:e,trapFocus:i,onOpenAutoFocus:o,onCloseAutoFocus:n,...s}=t,r=Lm(yF,e),a=z.useRef(null),g=mB(A,a);return YCA(),O.jsxs(O.Fragment,{children:[O.jsx(a8,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:o,onUnmountAutoFocus:n,children:O.jsx(r8,{role:"dialog",id:r.contentId,"aria-describedby":r.descriptionId,"aria-labelledby":r.titleId,"data-state":GhA(r.open),...s,ref:g,onDismiss:()=>r.onOpenChange(!1)})}),O.jsxs(O.Fragment,{children:[O.jsx(bTt,{titleId:r.titleId}),O.jsx(kTt,{contentRef:a,descriptionId:r.descriptionId})]})]})}),khA="DialogTitle",zoe=z.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,o=Lm(khA,e);return O.jsx(pg.h2,{id:o.titleId,...i,ref:A})});zoe.displayName=khA;var Xoe="DialogDescription",$oe=z.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,o=Lm(Xoe,e);return O.jsx(pg.p,{id:o.descriptionId,...i,ref:A})});$oe.displayName=Xoe;var Ane="DialogClose",ene=z.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,o=Lm(Ane,e);return O.jsx(pg.button,{type:"button",...i,ref:A,onClick:Cn(t.onClick,()=>o.onOpenChange(!1))})});ene.displayName=Ane;function GhA(t){return t?"open":"closed"}var tne="DialogTitleWarning",[STt,ine]=E5e(tne,{contentName:yF,titleName:khA,docsSlug:"dialog"}),bTt=({titleId:t})=>{const A=ine(tne),e=`\`${A.contentName}\` requires a \`${A.titleName}\` for the component to be accessible for screen reader users.
5605
+ `,c=new Blob([I],{type:"text/plain"}),B=URL.createObjectURL(c),l=document.createElement("a");l.href=B,l.download=`${g}.test.ts`,l.click(),URL.revokeObjectURL(B)}catch(a){alert(`Error generating test.ts for ${t.constructor.name}: ${a instanceof Error?a.message:String(a)}`)}i(!1)};return O.jsxs("div",{className:`relative ${A}`,ref:o,children:[O.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>i(!e),title:`Download options for ${t.constructor.name}`,children:t.constructor.name}),e&&O.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:[O.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:n,children:"Download JSON"}),O.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),O.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download test.ts"})]})]})},Loe=t=>t.activeSubSolver?[t,...Loe(t.activeSubSolver)]:[t],ZJt=({solver:t})=>{const A=Loe(t);return O.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:A.map((e,i)=>O.jsxs("div",{className:"flex items-center",children:[i>0&&O.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),O.jsx(WJt,{solver:e})]},e.constructor.name))})},VJt=({solver:t,triggerRender:A,animationSpeed:e=25,onSolverStarted:i,onSolverCompleted:o})=>{const[n,s]=z.useReducer(Q=>!Q,!1),r=z.useRef(void 0),a=()=>{!t.solved&&!t.failed&&(t.step(),A())},g=()=>{!t.solved&&!t.failed&&(i&&i(t),t.solve(),A(),o&&o(t))},I=()=>{n?(r.current&&(clearInterval(r.current),r.current=void 0),s()):(s(),r.current=setInterval(()=>{if(t.solved||t.failed){r.current&&(clearInterval(r.current),r.current=void 0),s(),A(),o&&t.solved&&o(t);return}t.step(),A()},e))},c=()=>{const Q=t;if(Q.getCurrentPhase&&!t.solved&&!t.failed){const E=Q.getCurrentPhase();for(;Q.getCurrentPhase()===E&&!t.solved&&!t.failed;)t.step();A()}},B=()=>{if(t.solved||t.failed||n)return;const Q=window.prompt("Step until which iteration?",`${t.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(;t.iterations<E&&!t.solved&&!t.failed;)t.step();A(),t.solved&&o&&o(t)};z.useEffect(()=>()=>{r.current&&clearInterval(r.current)},[]),z.useEffect(()=>{(t.solved||t.failed)&&n&&(r.current&&(clearInterval(r.current),r.current=void 0),s())},[t.solved,t.failed,n]);const l=t.getCurrentPhase!==void 0,C=l?t.getCurrentPhase():null;return O.jsxs("div",{className:"space-y-2 p-2 border-b",children:[O.jsx("div",{className:"flex items-center",children:O.jsx(ZJt,{solver:t})}),O.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[O.jsx("button",{onClick:a,disabled:t.solved||t.failed||n,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),O.jsx("button",{onClick:g,disabled:t.solved||t.failed||n,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),O.jsx("button",{onClick:I,disabled:t.solved||t.failed,className:`px-3 py-1 rounded text-white text-sm ${n?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:n?"Stop":"Animate"}),O.jsx("button",{onClick:B,disabled:t.solved||t.failed||n,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"}),l&&O.jsx("button",{onClick:c,disabled:t.solved||t.failed||n,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),O.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&O.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),C&&O.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",O.jsx("span",{className:"font-medium",children:C})]}),t.solved&&O.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&O.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&O.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},jJt=(t,A,e)=>{const i=t.currentPipelineStepIndex;return A<i?"Completed":A===i&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},zJt=(t,A)=>{const i=t.pipelineDef[A].solverName,o=jJt(t,A),n=t[i],s=t.firstIterationOfPhase?.[i]??null,r=t.iterations;let a=0;if(o==="Completed"){const B=t.pipelineDef[A+1],l=B?t.firstIterationOfPhase?.[B.solverName]:void 0;l!==void 0&&s!==null?a=l-s:s!==null&&(a=r-s)}else o==="In Progress"&&s!==null&&(a=r-s);const g=t.timeSpentOnPhase?.[i]??0;let I=0;o==="Completed"?I=1:o==="In Progress"&&n&&(I=n.progress??0);const c=n?.stats??null;return{index:A,name:i,status:o,firstIteration:s,iterations:a,progress:I,timeSpent:g,stats:c&&Object.keys(c).length>0?c:null,solverInstance:n??null}},XJt=({status:t})=>{const A={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return O.jsx("span",{className:`font-medium ${A[t]}`,children:t})},$Jt=({progress:t})=>{if(t===0)return null;const A=Math.round(t*100);return O.jsxs("div",{className:"flex items-center gap-2",children:[O.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:O.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${A}%`}})}),O.jsxs("span",{className:"text-xs text-gray-500",children:[A,"%"]})]})},ATt=t=>Object.entries(t).map(([A,e])=>`${A}: ${e}`).join(", "),eTt=({stats:t})=>{if(!t||Object.keys(t).length===0)return O.jsx("span",{children:"-"});const A=Object.entries(t),e=ATt(t);return O.jsxs("details",{className:"cursor-pointer",children:[O.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:e}),O.jsx("div",{className:"mt-1 text-xs",children:A.map(([i,o])=>O.jsxs("div",{children:[i,": ",String(o)]},i))})]})},bhA=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(bhA);const A={};for(const[e,i]of Object.entries(t))e.startsWith("_")||(A[e]=bhA(i));return A},tTt=(t,A)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${A}`);return}const e=bhA(t.getConstructorParams()),i=new Blob([JSON.stringify(e,null,2)],{type:"application/json"}),o=URL.createObjectURL(i),n=document.createElement("a");n.href=o,n.download=`${A}_input.json`,n.click(),URL.revokeObjectURL(o)}catch(e){alert(`Error downloading input for ${A}: ${e instanceof Error?e.message:String(e)}`)}},iTt=({solver:t,onStepUntilPhase:A,onDownloadInput:e})=>{const i=t.pipelineDef.map((r,a)=>zJt(t,a)),o=r=>{A?.(r)},n=r=>{r.solverInstance&&(e?e(r.solverInstance,r.name):tTt(r.solverInstance,r.name))},s=r=>`${(r/1e3).toFixed(2)}s`;return O.jsxs("div",{className:"border-t border-gray-200",children:[O.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:O.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),O.jsx("div",{className:"overflow-x-auto",children:O.jsxs("table",{className:"w-full text-sm",children:[O.jsx("thead",{children:O.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[O.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),O.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),O.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",O.jsx("sub",{children:"0"})]}),O.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),O.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),O.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),O.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),O.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),O.jsx("tbody",{children:i.map(r=>O.jsxs("tr",{className:`border-b border-gray-100 ${r.status==="In Progress"?"bg-yellow-50":""}`,children:[O.jsx("td",{className:"px-4 py-2",children:O.jsxs("div",{className:"flex items-center gap-2",children:[O.jsx("span",{className:"text-gray-400 w-6",children:String(r.index+1).padStart(2,"0")}),O.jsx("button",{onClick:()=>o(r.name),disabled:r.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 ${r.name} completes`,children:O.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:O.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"})})}),O.jsx("span",{className:"font-medium text-gray-900",children:r.name})]})}),O.jsx("td",{className:"px-4 py-2",children:O.jsx(XJt,{status:r.status})}),O.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:r.firstIteration!==null?r.firstIteration:""}),O.jsx("td",{className:"px-4 py-2 text-gray-600",children:r.iterations}),O.jsx("td",{className:"px-4 py-2",children:O.jsx($Jt,{progress:r.progress})}),O.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(r.timeSpent)}),O.jsx("td",{className:"px-4 py-2 text-gray-500",children:O.jsx(eTt,{stats:r.stats})}),O.jsx("td",{className:"px-4 py-2",children:r.solverInstance?O.jsxs("button",{onClick:()=>n(r),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${r.name}`,children:[O.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:O.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"})}),O.jsx("span",{children:"Input"})]}):null})]},r.name))})]})})]})},oTt=class extends eo.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 nTt({graphics:t}){const A=t.points??[],e=t.lines??[],i=t.rects??[],o=t.circles??[],n=t.texts??[];let s=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,g=Number.NEGATIVE_INFINITY;const I=(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)I(E.x,E.y);for(const E of e){const h=E.points??[];for(const u of h)I(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;I(h,u),I(h+d,u+f)}for(const E of o){const h=E.x??0,u=E.y??0,d=E.radius??1;I(h-d,u-d),I(h+d,u+d)}for(const E of n)I(E.x,E.y);(!isFinite(s)||!isFinite(r)||!isFinite(a)||!isFinite(g))&&(s=-20,r=-20,a=20,g=20);const c=10,B=s-c,l=r-c,C=Math.max(1,a-s+2*c),Q=Math.max(1,g-r+2*c);return O.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${B} ${l} ${C} ${Q}`,role:"img","aria-label":"Graphics fallback",children:[i.map((E,h)=>O.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}`)),e.map((E,h)=>O.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}`)),o.map((E,h)=>O.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)=>O.jsx("circle",{cx:E.x??0,cy:E.y??0,r:E.radius??1.5,fill:E.color??"black"},`point-${h}`)),n.map((E,h)=>O.jsx("text",{x:E.x??0,y:E.y??0,fontSize:E.fontSize??10,fill:E.color??"black",children:E.text??""},`text-${h}`))]})}var sTt=({solver:t,animationSpeed:A=25,onSolverStarted:e,onSolverCompleted:i})=>{const[o,n]=z.useReducer(I=>I+1,0),s=z.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(I){return console.error("Visualization error:",I),{points:[],lines:[],rects:[],circles:[]}}},[t,o]),r=z.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);z.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const I=document.createElement("script");I.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(I)}},[]);const a=t.pipelineDef!==void 0,g=I=>{const c=t;if(!t.solved&&!t.failed){for(;!t.solved&&!t.failed&&c.currentPipelineStepIndex<=c.pipelineDef.findIndex(B=>B.solverName===I);)t.step();n()}};return O.jsxs("div",{children:[O.jsx(VJt,{solver:t,triggerRender:n,animationSpeed:A,onSolverStarted:e,onSolverCompleted:i}),r?O.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):O.jsx(oTt,{fallback:O.jsx(nTt,{graphics:s}),children:O.jsx(OJt,{graphics:s})}),a&&O.jsx(iTt,{solver:t,onStepUntilPhase:g})]})};const rTt=()=>{z.useEffect(()=>{const t="tailwind-cdn-script";if(document.getElementById(t)||window.tailwind)return;const A=document.createElement("div");A.className="hidden",document.body.appendChild(A);const e=window.getComputedStyle(A).display==="none";if(document.body.removeChild(A),e)return;const i=document.createElement("script");i.id=t,i.src="https://cdn.tailwindcss.com",document.head.appendChild(i)},[])},aTt=t=>t.toLowerCase().includes("pack")?bSt:t.toLowerCase().includes("rout")?_St:ISt,gTt=({solverEvents:t=[]})=>{const[A,e]=z.useState(null);rTt();const i=z.useMemo(()=>{const r=new Map;for(const a of t){const g=`${a.componentName}-${a.solverName}`;r.set(g,a)}return r},[t]),o=z.useMemo(()=>Array.from(i.keys()),[i]),n=A?i.get(A):null,s=z.useMemo(()=>{if(!n)return{instance:null,error:null,classFound:!1};const r=FvA[n.solverName];if(!r)return{instance:null,error:`Solver class "${n.solverName}" not found in SOLVERS registry. Available: ${Object.keys(FvA).join(", ")}`,classFound:!1};try{const a=n.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}}},[n]);return t.length===0?O.jsx("div",{className:"rf-p-4",children:O.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:O.jsxs("div",{className:"rf-p-4",children:[O.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),O.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."})]})})}):O.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[O.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[O.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:[o.length," ",o.length===1?"Solver":"Solvers"]}),o.map(r=>{const a=i.get(r),g=A===r;return O.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:()=>e(r),children:(()=>{const I=aTt(a.solverName);return O.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[O.jsx(I,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),O.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[O.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:a.componentName}),O.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:a.solverName})]})]})})()},r)})]}),O.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:n?s.instance?O.jsx(fy,{fallback:O.jsx("div",{className:"rf-p-4",children:O.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[O.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),O.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",n.solverName]})]})}),children:O.jsx(sTt,{solver:s.instance})}):O.jsxs("div",{className:"rf-p-4",children:[O.jsxs("div",{className:"rf-mb-4",children:[O.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:n.solverName}),O.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",n.componentName]})]}),s.error&&O.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:O.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),O.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[O.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:O.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),O.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:O.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(n.solverParams,null,2)})})]})]}):O.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:O.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},Hoe=({errorMessage:t,errorStack:A,circuitJsonErrors:e})=>{z.useEffect(()=>{if(t){const i=new Error(t);A&&(i.stack=A);try{C3.captureException(i)}catch{}}},[t,A]),z.useEffect(()=>{if(e&&e.length>0)for(const i of e){const o=new Error(i.message||"Circuit JSON Error");i.stack&&(o.stack=i.stack);try{C3.captureException(o,{error_type:i.type})}catch{}}},[e])},Yoe="0.0.1424",ITt={version:Yoe},$W=PvA()(OvA(t=>({lastRunEvalVersion:void 0,setLastRunEvalVersion:A=>{t({lastRunEvalVersion:A})}}),{name:"runframe-runner-store"})),cTt=t=>{const[A,e]=z.useState([]),[i,o]=z.useState(null),[n,s]=z.useState(""),[r,a]=KM("eval-version-selection",null),g=$W(l=>l.setLastRunEvalVersion),I=$W(l=>l.lastRunEvalVersion);return z.useEffect(()=>{t&&fetch("https://data.jsdelivr.com/v1/package/npm/@tscircuit/eval").then(l=>l.json()).then(l=>{if(Array.isArray(l?.versions)){let C=[...l.versions];l.tags?.latest&&(o(l.tags.latest),C=C.filter(Q=>Q!==l.tags.latest)),e(C)}}).catch(()=>{})},[t]),z.useEffect(()=>{t&&(r?(window.TSCIRCUIT_LATEST_EVAL_VERSION=r,g(r)):i&&(window.TSCIRCUIT_LATEST_EVAL_VERSION=i,g(i)))},[t,r,i]),{versions:z.useMemo(()=>A.filter(l=>l.includes(n)).slice(0,50),[A,n]),latestVersion:i,lastRunEvalVersion:I,search:n,setSearch:s,selectVersion:l=>{a(l),s("")}}},BTt=({snippetNames:t,onSelect:A,onCancel:e,isOpen:i})=>{const[o,n]=z.useState(""),[s,r]=z.useState("");if(!i)return null;const a=t.filter(c=>c.toLowerCase().includes(s.toLowerCase())),g=s&&!t.includes(s),I=c=>{c.key==="Enter"&&(a.length===1?n(a[0]):g&&n(s))};return O.jsx("div",{className:"rf-fixed rf-inset-0 rf-bg-black rf-bg-opacity-50 rf-flex rf-items-center rf-justify-center rf-z-[100]",children:O.jsxs("div",{className:"rf-bg-white rf-rounded-lg rf-p-6 rf-w-96",children:[O.jsx("h2",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Select Snippet"}),O.jsx("input",{type:"text",className:"rf-w-full rf-px-4 rf-py-2 rf-border rf-rounded rf-mb-4",placeholder:"Search snippets or new snippet name...",value:s,onChange:c=>r(c.target.value),onKeyDown:I}),O.jsxs("div",{className:"rf-h-60 rf-overflow-y-auto",children:[a.map(c=>O.jsx("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 ${o===c?"bg-blue-50":""}`,onClick:()=>n(c),children:c},c)),g&&O.jsxs("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 text-blue-500 ${o===s?"bg-blue-50":""}`,onClick:()=>n(s),children:['Create new "',s,'"']})]}),O.jsxs("div",{className:"rf-mt-4 rf-flex rf-justify-end rf-gap-2",children:[O.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-text-gray-600 rf-hover:text-gray-800",onClick:e,children:"Cancel"}),O.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-bg-blue-500 rf-text-white rf-rounded rf-hover:bg-blue-600 rf-disabled:opacity-50",onClick:()=>o&&A(o),disabled:!o,children:o===s?`Create "${o}"`:`Save to ${o}`})]})]})})},lTt=t=>{const A=z.useRef(null),e=Jc(i=>i.recentEvents);z.useEffect(()=>{if(e.length===0)return;const i=e[0];i.event_id!==A.current&&(t(i),A.current=i.event_id)},[e,t])};function CTt(t){const A=QTt(t),e=z.forwardRef((i,o)=>{const{children:n,...s}=i,r=z.Children.toArray(n),a=r.find(hTt);if(a){const g=a.props.children,I=r.map(c=>c===a?z.Children.count(g)>1?z.Children.only(null):z.isValidElement(g)?g.props.children:null:c);return O.jsx(A,{...s,ref:o,children:z.isValidElement(g)?z.cloneElement(g,void 0,I):null})}return O.jsx(A,{...s,ref:o,children:n})});return e.displayName=`${t}.Slot`,e}function QTt(t){const A=z.forwardRef((e,i)=>{const{children:o,...n}=e;if(z.isValidElement(o)){const s=dTt(o),r=uTt(n,o.props);return o.type!==z.Fragment&&(r.ref=i?Kp(i,s):s),z.cloneElement(o,r)}return z.Children.count(o)>1?z.Children.only(null):null});return A.displayName=`${t}.SlotClone`,A}var ETt=Symbol("radix.slottable");function hTt(t){return z.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===ETt}function uTt(t,A){const e={...A};for(const i in A){const o=t[i],n=A[i];/^on[A-Z]/.test(i)?o&&n?e[i]=(...r)=>{const a=n(...r);return o(...r),a}:o&&(e[i]=o):i==="style"?e[i]={...o,...n}:i==="className"&&(e[i]=[o,n].filter(Boolean).join(" "))}return{...t,...e}}function dTt(t){let A=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,e=A&&"isReactWarning"in A&&A.isReactWarning;return e?t.ref:(A=Object.getOwnPropertyDescriptor(t,"ref")?.get,e=A&&"isReactWarning"in A&&A.isReactWarning,e?t.props.ref:t.props.ref||t.ref)}var AZ="Dialog",[Joe,Toe]=fw(AZ),[pTt,Lm]=Joe(AZ),Koe=t=>{const{__scopeDialog:A,children:e,open:i,defaultOpen:o,onOpenChange:n,modal:s=!0}=t,r=z.useRef(null),a=z.useRef(null),[g,I]=lG({prop:i,defaultProp:o??!1,onChange:n,caller:AZ});return O.jsx(pTt,{scope:A,triggerRef:r,contentRef:a,contentId:yu(),titleId:yu(),descriptionId:yu(),open:g,onOpenChange:I,onOpenToggle:z.useCallback(()=>I(c=>!c),[I]),modal:s,children:e})};Koe.displayName=AZ;var qoe="DialogTrigger",Poe=z.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,o=Lm(qoe,e),n=mB(A,o.triggerRef);return O.jsx(pg.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":GhA(o.open),...i,ref:n,onClick:Cn(t.onClick,o.onOpenToggle)})});Poe.displayName=qoe;var xhA="DialogPortal",[fTt,Ooe]=Joe(xhA,{forceMount:void 0}),Woe=t=>{const{__scopeDialog:A,forceMount:e,children:i,container:o}=t,n=Lm(xhA,A);return O.jsx(fTt,{scope:A,forceMount:e,children:z.Children.map(i,s=>O.jsx(Iy,{present:e||n.open,children:O.jsx(p8,{asChild:!0,container:o,children:s})}))})};Woe.displayName=xhA;var eZ="DialogOverlay",Zoe=z.forwardRef((t,A)=>{const e=Ooe(eZ,t.__scopeDialog),{forceMount:i=e.forceMount,...o}=t,n=Lm(eZ,t.__scopeDialog);return n.modal?O.jsx(Iy,{present:i||n.open,children:O.jsx(mTt,{...o,ref:A})}):null});Zoe.displayName=eZ;var yTt=CTt("DialogOverlay.RemoveScroll"),mTt=z.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,o=Lm(eZ,e);return O.jsx(x8,{as:yTt,allowPinchZoom:!0,shards:[o.contentRef],children:O.jsx(pg.div,{"data-state":GhA(o.open),...i,ref:A,style:{pointerEvents:"auto",...i.style}})})}),yF="DialogContent",Voe=z.forwardRef((t,A)=>{const e=Ooe(yF,t.__scopeDialog),{forceMount:i=e.forceMount,...o}=t,n=Lm(yF,t.__scopeDialog);return O.jsx(Iy,{present:i||n.open,children:n.modal?O.jsx(wTt,{...o,ref:A}):O.jsx(DTt,{...o,ref:A})})});Voe.displayName=yF;var wTt=z.forwardRef((t,A)=>{const e=Lm(yF,t.__scopeDialog),i=z.useRef(null),o=mB(A,e.contentRef,i);return z.useEffect(()=>{const n=i.current;if(n)return nQA(n)},[]),O.jsx(joe,{...t,ref:o,trapFocus:e.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Cn(t.onCloseAutoFocus,n=>{n.preventDefault(),e.triggerRef.current?.focus()}),onPointerDownOutside:Cn(t.onPointerDownOutside,n=>{const s=n.detail.originalEvent,r=s.button===0&&s.ctrlKey===!0;(s.button===2||r)&&n.preventDefault()}),onFocusOutside:Cn(t.onFocusOutside,n=>n.preventDefault())})}),DTt=z.forwardRef((t,A)=>{const e=Lm(yF,t.__scopeDialog),i=z.useRef(!1),o=z.useRef(!1);return O.jsx(joe,{...t,ref:A,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:n=>{t.onCloseAutoFocus?.(n),n.defaultPrevented||(i.current||e.triggerRef.current?.focus(),n.preventDefault()),i.current=!1,o.current=!1},onInteractOutside:n=>{t.onInteractOutside?.(n),n.defaultPrevented||(i.current=!0,n.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const s=n.target;e.triggerRef.current?.contains(s)&&n.preventDefault(),n.detail.originalEvent.type==="focusin"&&o.current&&n.preventDefault()}})}),joe=z.forwardRef((t,A)=>{const{__scopeDialog:e,trapFocus:i,onOpenAutoFocus:o,onCloseAutoFocus:n,...s}=t,r=Lm(yF,e),a=z.useRef(null),g=mB(A,a);return YCA(),O.jsxs(O.Fragment,{children:[O.jsx(a8,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:o,onUnmountAutoFocus:n,children:O.jsx(r8,{role:"dialog",id:r.contentId,"aria-describedby":r.descriptionId,"aria-labelledby":r.titleId,"data-state":GhA(r.open),...s,ref:g,onDismiss:()=>r.onOpenChange(!1)})}),O.jsxs(O.Fragment,{children:[O.jsx(bTt,{titleId:r.titleId}),O.jsx(kTt,{contentRef:a,descriptionId:r.descriptionId})]})]})}),khA="DialogTitle",zoe=z.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,o=Lm(khA,e);return O.jsx(pg.h2,{id:o.titleId,...i,ref:A})});zoe.displayName=khA;var Xoe="DialogDescription",$oe=z.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,o=Lm(Xoe,e);return O.jsx(pg.p,{id:o.descriptionId,...i,ref:A})});$oe.displayName=Xoe;var Ane="DialogClose",ene=z.forwardRef((t,A)=>{const{__scopeDialog:e,...i}=t,o=Lm(Ane,e);return O.jsx(pg.button,{type:"button",...i,ref:A,onClick:Cn(t.onClick,()=>o.onOpenChange(!1))})});ene.displayName=Ane;function GhA(t){return t?"open":"closed"}var tne="DialogTitleWarning",[STt,ine]=E5e(tne,{contentName:yF,titleName:khA,docsSlug:"dialog"}),bTt=({titleId:t})=>{const A=ine(tne),e=`\`${A.contentName}\` requires a \`${A.titleName}\` for the component to be accessible for screen reader users.
5606
5606
 
5607
5607
  If you want to hide the \`${A.titleName}\`, you can wrap it with our VisuallyHidden component.
5608
5608
 
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@tscircuit/runframe",
3
3
  "main": "dist/preview.js",
4
4
  "type": "module",
5
- "version": "0.0.1424",
5
+ "version": "0.0.1425",
6
6
  "exports": {
7
7
  ".": "./dist/preview.js",
8
8
  "./preview": "./dist/preview.js",
@@ -55,7 +55,7 @@
55
55
  "@tscircuit/pcb-viewer": "1.11.290",
56
56
  "@tscircuit/props": "^0.0.429",
57
57
  "@tscircuit/schematic-trace-solver": "^0.0.40",
58
- "@tscircuit/schematic-viewer": "2.0.50",
58
+ "@tscircuit/schematic-viewer": "^2.0.50",
59
59
  "@types/bun": "latest",
60
60
  "@types/debug": "^4.1.12",
61
61
  "@types/react": "^19.1.10",