@tscircuit/runframe 0.0.1971 → 0.0.1973

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.
@@ -1821,7 +1821,7 @@ var useErrorTelemetry = ({
1821
1821
  };
1822
1822
 
1823
1823
  // package.json
1824
- var version = "0.0.1970";
1824
+ var version = "0.0.1972";
1825
1825
  var package_default = {
1826
1826
  name: "@tscircuit/runframe",
1827
1827
  main: "dist/preview.js",
@@ -1887,7 +1887,7 @@ var package_default = {
1887
1887
  autoprefixer: "^10.4.20",
1888
1888
  "chokidar-cli": "^3.0.0",
1889
1889
  "circuit-json-to-bom-csv": "^0.0.8",
1890
- "circuit-json-to-gerber": "^0.0.56",
1890
+ "circuit-json-to-gerber": "^0.0.57",
1891
1891
  "circuit-json-to-kicad": "^0.0.137",
1892
1892
  "circuit-json-to-lbrn": "^0.0.74",
1893
1893
  "circuit-json-to-pnp-csv": "^0.0.7",
@@ -5798,6 +5798,8 @@ var CircuitJsonPreview = ({
5798
5798
  isWebEmbedded,
5799
5799
  circuitJson,
5800
5800
  projectName,
5801
+ autoroutingLog,
5802
+ onReportAutoroutingLog,
5801
5803
  showSchematicDebugGrid,
5802
5804
  onChangeShowSchematicDebugGrid: setShowSchematicDebugGrid,
5803
5805
  showSchematicPorts,
package/dist/preview.js CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  SchematicViewer,
8
8
  useOrderDialog,
9
9
  useOrderDialogCli
10
- } from "./chunk-ZJARL7JF.js";
10
+ } from "./chunk-5I3Y7YU5.js";
11
11
  export {
12
12
  BomTable,
13
13
  CadViewer,
package/dist/runner.js CHANGED
@@ -33,7 +33,7 @@ import {
33
33
  useRunFrameStore,
34
34
  useRunnerStore,
35
35
  useStyles
36
- } from "./chunk-ZJARL7JF.js";
36
+ } from "./chunk-5I3Y7YU5.js";
37
37
 
38
38
  // lib/components/RunFrame/RunFrame.tsx
39
39
  import { createCircuitWebWorker } from "@tscircuit/eval/worker";
@@ -5730,7 +5730,7 @@ test("${l} should solve problem correctly", () => {
5730
5730
  // Add more specific assertions based on expected output
5731
5731
  // expect(solver.netLabelPlacementSolver!.netLabelPlacements).toMatchInlineSnapshot()
5732
5732
  })
5733
- `,_=new Blob([u],{type:"text/plain"}),d=URL.createObjectURL(_),m=document.createElement("a");m.href=d,m.download=`${l}.test.ts`,m.click(),URL.revokeObjectURL(d)}catch(c){alert(`Error generating test.ts for ${t.constructor.name}: ${c instanceof Error?c.message:String(c)}`)}o(!1)};return G.jsxs("div",{className:`relative ${e}`,ref:r,children:[G.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>o(!n),title:`Download options for ${t.constructor.name}`,children:t.constructor.name}),n&&G.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:[G.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:i,children:"Download JSON"}),G.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),G.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:a,children:"Download test.ts"})]})]})},Yxt=t=>t.activeSubSolver?[t,...Yxt(t.activeSubSolver)]:[t],Quo=({solver:t})=>{const e=Yxt(t);return G.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:e.map((n,o)=>G.jsxs("div",{className:"flex items-center",children:[o>0&&G.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),G.jsx(Juo,{solver:n})]},n.constructor.name))})},Zuo=({solver:t,triggerRender:e,animationSpeed:n=25,onSolverStarted:o,onSolverCompleted:r})=>{const[i,s]=te.useReducer(p=>!p,!1),a=te.useRef(void 0),c=()=>{!t.solved&&!t.failed&&(t.step(),e())},l=()=>{!t.solved&&!t.failed&&(o&&o(t),t.solve(),e(),r&&r(t))},u=()=>{i?(a.current&&(clearInterval(a.current),a.current=void 0),s()):(s(),a.current=setInterval(()=>{if(t.solved||t.failed){a.current&&(clearInterval(a.current),a.current=void 0),s(),e(),r&&t.solved&&r(t);return}t.step(),e()},n))},_=()=>{const p=t;if(p.getCurrentPhase&&!t.solved&&!t.failed){const x=p.getCurrentPhase();for(;p.getCurrentPhase()===x&&!t.solved&&!t.failed;)t.step();e()}},d=()=>{if(t.solved||t.failed||i)return;const p=window.prompt("Step until which iteration?",`${t.iterations}`);if(p===null)return;const x=Number(p);if(!Number.isFinite(x)){window.alert("Please enter a valid number for the iteration");return}for(;t.iterations<x&&!t.solved&&!t.failed;)t.step();e(),t.solved&&r&&r(t)};te.useEffect(()=>()=>{a.current&&clearInterval(a.current)},[]),te.useEffect(()=>{(t.solved||t.failed)&&i&&(a.current&&(clearInterval(a.current),a.current=void 0),s())},[t.solved,t.failed,i]);const m=t.getCurrentPhase!==void 0,h=m?t.getCurrentPhase():null;return G.jsxs("div",{className:"space-y-2 p-2 border-b",children:[G.jsx("div",{className:"flex items-center",children:G.jsx(Quo,{solver:t})}),G.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[G.jsx("button",{onClick:c,disabled:t.solved||t.failed||i,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),G.jsx("button",{onClick:l,disabled:t.solved||t.failed||i,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),G.jsx("button",{onClick:u,disabled:t.solved||t.failed,className:`px-3 py-1 rounded text-white text-sm ${i?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:i?"Stop":"Animate"}),G.jsx("button",{onClick:d,disabled:t.solved||t.failed||i,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"}),m&&G.jsx("button",{onClick:_,disabled:t.solved||t.failed||i,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),G.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&G.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),h&&G.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",G.jsx("span",{className:"font-medium",children:h})]}),t.solved&&G.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&G.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&G.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},e0o=(t,e,n)=>{const o=t.currentPipelineStepIndex;return e<o?"Completed":e===o&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},t0o=(t,e)=>{const o=t.pipelineDef[e].solverName,r=e0o(t,e),i=t[o],s=t.firstIterationOfPhase?.[o]??null,a=t.iterations;let c=0;if(r==="Completed"){const d=t.pipelineDef[e+1],m=d?t.firstIterationOfPhase?.[d.solverName]:void 0;m!==void 0&&s!==null?c=m-s:s!==null&&(c=a-s)}else r==="In Progress"&&s!==null&&(c=a-s);const l=t.timeSpentOnPhase?.[o]??0;let u=0;r==="Completed"?u=1:r==="In Progress"&&i&&(u=i.progress??0);const _=i?.stats??null;return{index:e,name:o,status:r,firstIteration:s,iterations:c,progress:u,timeSpent:l,stats:_&&Object.keys(_).length>0?_:null,solverInstance:i??null}},n0o=({status:t})=>{const e={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return G.jsx("span",{className:`font-medium ${e[t]}`,children:t})},o0o=({progress:t})=>{if(t===0)return null;const e=Math.round(t*100);return G.jsxs("div",{className:"flex items-center gap-2",children:[G.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:G.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${e}%`}})}),G.jsxs("span",{className:"text-xs text-gray-500",children:[e,"%"]})]})},r0o=t=>Object.entries(t).map(([e,n])=>`${e}: ${n}`).join(", "),i0o=({stats:t})=>{if(!t||Object.keys(t).length===0)return G.jsx("span",{children:"-"});const e=Object.entries(t),n=r0o(t);return G.jsxs("details",{className:"cursor-pointer",children:[G.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:n}),G.jsx("div",{className:"mt-1 text-xs",children:e.map(([o,r])=>G.jsxs("div",{children:[o,": ",String(r)]},o))})]})},M4e=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(M4e);const e={};for(const[n,o]of Object.entries(t))n.startsWith("_")||(e[n]=M4e(o));return e},s0o=(t,e)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${e}`);return}const n=M4e(t.getConstructorParams()),o=new Blob([JSON.stringify(n,null,2)],{type:"application/json"}),r=URL.createObjectURL(o),i=document.createElement("a");i.href=r,i.download=`${e}_input.json`,i.click(),URL.revokeObjectURL(r)}catch(n){alert(`Error downloading input for ${e}: ${n instanceof Error?n.message:String(n)}`)}},a0o=({solver:t,onStepUntilPhase:e,onDownloadInput:n})=>{const o=t.pipelineDef.map((a,c)=>t0o(t,c)),r=a=>{e?.(a)},i=a=>{a.solverInstance&&(n?n(a.solverInstance,a.name):s0o(a.solverInstance,a.name))},s=a=>`${(a/1e3).toFixed(2)}s`;return G.jsxs("div",{className:"border-t border-gray-200",children:[G.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:G.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),G.jsx("div",{className:"overflow-x-auto",children:G.jsxs("table",{className:"w-full text-sm",children:[G.jsx("thead",{children:G.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),G.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",G.jsx("sub",{children:"0"})]}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),G.jsx("tbody",{children:o.map(a=>G.jsxs("tr",{className:`border-b border-gray-100 ${a.status==="In Progress"?"bg-yellow-50":""}`,children:[G.jsx("td",{className:"px-4 py-2",children:G.jsxs("div",{className:"flex items-center gap-2",children:[G.jsx("span",{className:"text-gray-400 w-6",children:String(a.index+1).padStart(2,"0")}),G.jsx("button",{onClick:()=>r(a.name),disabled:a.status==="Completed"||t.solved||t.failed,className:"text-blue-500 hover:text-blue-700 disabled:text-gray-300 disabled:cursor-not-allowed",title:`Step until ${a.name} completes`,children:G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:G.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"})})}),G.jsx("span",{className:"font-medium text-gray-900",children:a.name})]})}),G.jsx("td",{className:"px-4 py-2",children:G.jsx(n0o,{status:a.status})}),G.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:a.firstIteration!==null?a.firstIteration:""}),G.jsx("td",{className:"px-4 py-2 text-gray-600",children:a.iterations}),G.jsx("td",{className:"px-4 py-2",children:G.jsx(o0o,{progress:a.progress})}),G.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(a.timeSpent)}),G.jsx("td",{className:"px-4 py-2 text-gray-500",children:G.jsx(i0o,{stats:a.stats})}),G.jsx("td",{className:"px-4 py-2",children:a.solverInstance?G.jsxs("button",{onClick:()=>i(a),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${a.name}`,children:[G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:G.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"})}),G.jsx("span",{children:"Input"})]}):null})]},a.name))})]})})]})},c0o=class extends pr.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 l0o({graphics:t}){const e=t.points??[],n=t.lines??[],o=t.rects??[],r=t.circles??[],i=t.texts??[];let s=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY,l=Number.NEGATIVE_INFINITY;const u=(x,f)=>{typeof x=="number"&&(x<s&&(s=x),x>c&&(c=x)),typeof f=="number"&&(f<a&&(a=f),f>l&&(l=f))};for(const x of e)u(x.x,x.y);for(const x of n){const f=x.points??[];for(const g of f)u(g.x,g.y)}for(const x of o){const f=x.x??0,g=x.y??0,y=x.width??0,b=x.height??0;u(f,g),u(f+y,g+b)}for(const x of r){const f=x.x??0,g=x.y??0,y=x.radius??1;u(f-y,g-y),u(f+y,g+y)}for(const x of i)u(x.x,x.y);(!isFinite(s)||!isFinite(a)||!isFinite(c)||!isFinite(l))&&(s=-20,a=-20,c=20,l=20);const _=10,d=s-_,m=a-_,h=Math.max(1,c-s+2*_),p=Math.max(1,l-a+2*_);return G.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${d} ${m} ${h} ${p}`,role:"img","aria-label":"Graphics fallback",children:[o.map((x,f)=>G.jsx("rect",{x:x.x??0,y:x.y??0,width:x.width??0,height:x.height??0,fill:"none",stroke:x.strokeColor??"black",strokeWidth:x.strokeWidth??1},`rect-${f}`)),n.map((x,f)=>G.jsx("polyline",{fill:"none",stroke:x.strokeColor??"black",strokeWidth:x.strokeWidth??1,points:(x.points??[]).map(g=>`${g.x??0},${g.y??0}`).join(" ")},`line-${f}`)),r.map((x,f)=>G.jsx("circle",{cx:x.x??0,cy:x.y??0,r:x.radius??1.5,fill:x.fillColor??"none",stroke:x.strokeColor??"black",strokeWidth:x.strokeWidth??1},`circle-${f}`)),e.map((x,f)=>G.jsx("circle",{cx:x.x??0,cy:x.y??0,r:x.radius??1.5,fill:x.color??"black"},`point-${f}`)),i.map((x,f)=>G.jsx("text",{x:x.x??0,y:x.y??0,fontSize:x.fontSize??10,fill:x.color??"black",children:x.text??""},`text-${f}`))]})}var u0o=({solver:t,animationSpeed:e=25,onSolverStarted:n,onSolverCompleted:o})=>{const[r,i]=te.useReducer(u=>u+1,0),s=te.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(u){return console.error("Visualization error:",u),{points:[],lines:[],rects:[],circles:[]}}},[t,r]),a=te.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);te.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const u=document.createElement("script");u.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(u)}},[]);const c=t.pipelineDef!==void 0,l=u=>{const _=t;if(!t.solved&&!t.failed){for(;!t.solved&&!t.failed&&_.currentPipelineStepIndex<=_.pipelineDef.findIndex(d=>d.solverName===u);)t.step();i()}};return G.jsxs("div",{children:[G.jsx(Zuo,{solver:t,triggerRender:i,animationSpeed:e,onSolverStarted:n,onSolverCompleted:o}),a?G.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):G.jsx(c0o,{fallback:G.jsx(l0o,{graphics:s}),children:G.jsx(Kuo,{graphics:s})}),c&&G.jsx(a0o,{solver:t,onStepUntilPhase:l})]})};const _0o=()=>{te.useEffect(()=>{const t="tailwind-cdn-script";if(document.getElementById(t)||window.tailwind)return;const e=document.createElement("div");e.className="hidden",document.body.appendChild(e);const n=window.getComputedStyle(e).display==="none";if(document.body.removeChild(e),n)return;const o=document.createElement("script");o.id=t,o.src="https://cdn.tailwindcss.com",document.head.appendChild(o)},[])},d0o=t=>t.toLowerCase().includes("pack")?zUn:t.toLowerCase().includes("rout")?jUn:kUn,h0o=({solverEvents:t=[]})=>{const[e,n]=te.useState(null);_0o();const o=te.useMemo(()=>{const a=new Map;for(const c of t){const l=`${c.componentName}-${c.solverName}`;a.set(l,c)}return a},[t]),r=te.useMemo(()=>Array.from(o.keys()),[o]),i=e?o.get(e):null,s=te.useMemo(()=>{if(!i)return{instance:null,error:null,classFound:!1};const a=gde[i.solverName];if(!a)return{instance:null,error:`Solver class "${i.solverName}" not found in SOLVERS registry. Available: ${Object.keys(gde).join(", ")}`,classFound:!1};try{const c=i.solverParams,l=c?.input!==void 0?c.input:c;return{instance:new a(l),error:null,classFound:!0}}catch(c){const l=c instanceof Error?c.message:String(c);return console.error("Failed to reconstruct solver:",c),{instance:null,error:`Failed to instantiate solver: ${l}`,classFound:!0}}},[i]);return t.length===0?G.jsx("div",{className:"rf-p-4",children:G.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:G.jsxs("div",{className:"rf-p-4",children:[G.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),G.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."})]})})}):G.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[G.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[G.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:[r.length," ",r.length===1?"Solver":"Solvers"]}),r.map(a=>{const c=o.get(a),l=e===a;return G.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${l?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>n(a),children:(()=>{const u=d0o(c.solverName);return G.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[G.jsx(u,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),G.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[G.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:c.componentName}),G.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:c.solverName})]})]})})()},a)})]}),G.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:i?s.instance?G.jsx(Q4,{fallback:G.jsx("div",{className:"rf-p-4",children:G.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[G.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),G.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",i.solverName]})]})}),children:G.jsx(u0o,{solver:s.instance})}):G.jsxs("div",{className:"rf-p-4",children:[G.jsxs("div",{className:"rf-mb-4",children:[G.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:i.solverName}),G.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",i.componentName]})]}),s.error&&G.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:G.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),G.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[G.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:G.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),G.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:G.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(i.solverParams,null,2)})})]})]}):G.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:G.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},qxt=({errorMessage:t,errorStack:e,circuitJsonErrors:n})=>{te.useEffect(()=>{if(t){const o=new Error(t);e&&(o.stack=e);try{vB.captureException(o)}catch{}}},[t,e]),te.useEffect(()=>{if(n&&n.length>0)for(const o of n){const r=new Error(o.message||"Circuit JSON Error");o.stack&&(r.stack=o.stack);try{vB.captureException(r,{error_type:o.type})}catch{}}},[n])},Kxt="0.0.1970",m0o={version:Kxt},T4e={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},w4e=new Map,SJ=t=>{const e=w4e.get(t);return e?Object.fromEntries(Object.entries(e.stores).map(([n,o])=>[n,o.getState()])):{}},p0o=(t,e,n)=>{if(t===void 0)return{type:"untracked",connection:e.connect(n)};const o=w4e.get(n.name);if(o)return{type:"tracked",store:t,...o};const r={connection:e.connect(n),stores:{}};return w4e.set(n.name,r),{type:"tracked",store:t,...r}},Jxt=(t,e={})=>(n,o,r)=>{const{enabled:i,anonymousActionType:s,store:a,...c}=e;let l;try{l=(i??(T4e?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!l)return(T4e?"production":void 0)!=="production"&&i&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),t(n,o,r);const{connection:u,..._}=p0o(a,l,c);let d=!0;r.setState=(p,x,f)=>{const g=n(p,x);if(!d)return g;const y=f===void 0?{type:s||"anonymous"}:typeof f=="string"?{type:f}:f;return a===void 0?(u?.send(y,o()),g):(u?.send({...y,type:`${a}/${y.type}`},{...SJ(c.name),[a]:r.getState()}),g)};const m=(...p)=>{const x=d;d=!1,n(...p),d=x},h=t(r.setState,o,r);if(_.type==="untracked"?u?.init(h):(_.stores[_.store]=r,u?.init(Object.fromEntries(Object.entries(_.stores).map(([p,x])=>[p,p===_.store?h:x.getState()])))),r.dispatchFromDevtools&&typeof r.dispatch=="function"){let p=!1;const x=r.dispatch;r.dispatch=(...f)=>{(T4e?"production":void 0)!=="production"&&f[0].type==="__setState"&&!p&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),p=!0),x(...f)}}return u.subscribe(p=>{var x;switch(p.type){case"ACTION":if(typeof p.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return E4e(p.payload,f=>{if(f.type==="__setState"){if(a===void 0){m(f.state);return}Object.keys(f.state).length!==1&&console.error(`
5733
+ `,_=new Blob([u],{type:"text/plain"}),d=URL.createObjectURL(_),m=document.createElement("a");m.href=d,m.download=`${l}.test.ts`,m.click(),URL.revokeObjectURL(d)}catch(c){alert(`Error generating test.ts for ${t.constructor.name}: ${c instanceof Error?c.message:String(c)}`)}o(!1)};return G.jsxs("div",{className:`relative ${e}`,ref:r,children:[G.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>o(!n),title:`Download options for ${t.constructor.name}`,children:t.constructor.name}),n&&G.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:[G.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:i,children:"Download JSON"}),G.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),G.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:a,children:"Download test.ts"})]})]})},Yxt=t=>t.activeSubSolver?[t,...Yxt(t.activeSubSolver)]:[t],Quo=({solver:t})=>{const e=Yxt(t);return G.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:e.map((n,o)=>G.jsxs("div",{className:"flex items-center",children:[o>0&&G.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),G.jsx(Juo,{solver:n})]},n.constructor.name))})},Zuo=({solver:t,triggerRender:e,animationSpeed:n=25,onSolverStarted:o,onSolverCompleted:r})=>{const[i,s]=te.useReducer(p=>!p,!1),a=te.useRef(void 0),c=()=>{!t.solved&&!t.failed&&(t.step(),e())},l=()=>{!t.solved&&!t.failed&&(o&&o(t),t.solve(),e(),r&&r(t))},u=()=>{i?(a.current&&(clearInterval(a.current),a.current=void 0),s()):(s(),a.current=setInterval(()=>{if(t.solved||t.failed){a.current&&(clearInterval(a.current),a.current=void 0),s(),e(),r&&t.solved&&r(t);return}t.step(),e()},n))},_=()=>{const p=t;if(p.getCurrentPhase&&!t.solved&&!t.failed){const x=p.getCurrentPhase();for(;p.getCurrentPhase()===x&&!t.solved&&!t.failed;)t.step();e()}},d=()=>{if(t.solved||t.failed||i)return;const p=window.prompt("Step until which iteration?",`${t.iterations}`);if(p===null)return;const x=Number(p);if(!Number.isFinite(x)){window.alert("Please enter a valid number for the iteration");return}for(;t.iterations<x&&!t.solved&&!t.failed;)t.step();e(),t.solved&&r&&r(t)};te.useEffect(()=>()=>{a.current&&clearInterval(a.current)},[]),te.useEffect(()=>{(t.solved||t.failed)&&i&&(a.current&&(clearInterval(a.current),a.current=void 0),s())},[t.solved,t.failed,i]);const m=t.getCurrentPhase!==void 0,h=m?t.getCurrentPhase():null;return G.jsxs("div",{className:"space-y-2 p-2 border-b",children:[G.jsx("div",{className:"flex items-center",children:G.jsx(Quo,{solver:t})}),G.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[G.jsx("button",{onClick:c,disabled:t.solved||t.failed||i,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),G.jsx("button",{onClick:l,disabled:t.solved||t.failed||i,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),G.jsx("button",{onClick:u,disabled:t.solved||t.failed,className:`px-3 py-1 rounded text-white text-sm ${i?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:i?"Stop":"Animate"}),G.jsx("button",{onClick:d,disabled:t.solved||t.failed||i,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"}),m&&G.jsx("button",{onClick:_,disabled:t.solved||t.failed||i,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),G.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&G.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),h&&G.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",G.jsx("span",{className:"font-medium",children:h})]}),t.solved&&G.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&G.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&G.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},e0o=(t,e,n)=>{const o=t.currentPipelineStepIndex;return e<o?"Completed":e===o&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},t0o=(t,e)=>{const o=t.pipelineDef[e].solverName,r=e0o(t,e),i=t[o],s=t.firstIterationOfPhase?.[o]??null,a=t.iterations;let c=0;if(r==="Completed"){const d=t.pipelineDef[e+1],m=d?t.firstIterationOfPhase?.[d.solverName]:void 0;m!==void 0&&s!==null?c=m-s:s!==null&&(c=a-s)}else r==="In Progress"&&s!==null&&(c=a-s);const l=t.timeSpentOnPhase?.[o]??0;let u=0;r==="Completed"?u=1:r==="In Progress"&&i&&(u=i.progress??0);const _=i?.stats??null;return{index:e,name:o,status:r,firstIteration:s,iterations:c,progress:u,timeSpent:l,stats:_&&Object.keys(_).length>0?_:null,solverInstance:i??null}},n0o=({status:t})=>{const e={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return G.jsx("span",{className:`font-medium ${e[t]}`,children:t})},o0o=({progress:t})=>{if(t===0)return null;const e=Math.round(t*100);return G.jsxs("div",{className:"flex items-center gap-2",children:[G.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:G.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${e}%`}})}),G.jsxs("span",{className:"text-xs text-gray-500",children:[e,"%"]})]})},r0o=t=>Object.entries(t).map(([e,n])=>`${e}: ${n}`).join(", "),i0o=({stats:t})=>{if(!t||Object.keys(t).length===0)return G.jsx("span",{children:"-"});const e=Object.entries(t),n=r0o(t);return G.jsxs("details",{className:"cursor-pointer",children:[G.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:n}),G.jsx("div",{className:"mt-1 text-xs",children:e.map(([o,r])=>G.jsxs("div",{children:[o,": ",String(r)]},o))})]})},M4e=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(M4e);const e={};for(const[n,o]of Object.entries(t))n.startsWith("_")||(e[n]=M4e(o));return e},s0o=(t,e)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${e}`);return}const n=M4e(t.getConstructorParams()),o=new Blob([JSON.stringify(n,null,2)],{type:"application/json"}),r=URL.createObjectURL(o),i=document.createElement("a");i.href=r,i.download=`${e}_input.json`,i.click(),URL.revokeObjectURL(r)}catch(n){alert(`Error downloading input for ${e}: ${n instanceof Error?n.message:String(n)}`)}},a0o=({solver:t,onStepUntilPhase:e,onDownloadInput:n})=>{const o=t.pipelineDef.map((a,c)=>t0o(t,c)),r=a=>{e?.(a)},i=a=>{a.solverInstance&&(n?n(a.solverInstance,a.name):s0o(a.solverInstance,a.name))},s=a=>`${(a/1e3).toFixed(2)}s`;return G.jsxs("div",{className:"border-t border-gray-200",children:[G.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:G.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),G.jsx("div",{className:"overflow-x-auto",children:G.jsxs("table",{className:"w-full text-sm",children:[G.jsx("thead",{children:G.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),G.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",G.jsx("sub",{children:"0"})]}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),G.jsx("tbody",{children:o.map(a=>G.jsxs("tr",{className:`border-b border-gray-100 ${a.status==="In Progress"?"bg-yellow-50":""}`,children:[G.jsx("td",{className:"px-4 py-2",children:G.jsxs("div",{className:"flex items-center gap-2",children:[G.jsx("span",{className:"text-gray-400 w-6",children:String(a.index+1).padStart(2,"0")}),G.jsx("button",{onClick:()=>r(a.name),disabled:a.status==="Completed"||t.solved||t.failed,className:"text-blue-500 hover:text-blue-700 disabled:text-gray-300 disabled:cursor-not-allowed",title:`Step until ${a.name} completes`,children:G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:G.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"})})}),G.jsx("span",{className:"font-medium text-gray-900",children:a.name})]})}),G.jsx("td",{className:"px-4 py-2",children:G.jsx(n0o,{status:a.status})}),G.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:a.firstIteration!==null?a.firstIteration:""}),G.jsx("td",{className:"px-4 py-2 text-gray-600",children:a.iterations}),G.jsx("td",{className:"px-4 py-2",children:G.jsx(o0o,{progress:a.progress})}),G.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(a.timeSpent)}),G.jsx("td",{className:"px-4 py-2 text-gray-500",children:G.jsx(i0o,{stats:a.stats})}),G.jsx("td",{className:"px-4 py-2",children:a.solverInstance?G.jsxs("button",{onClick:()=>i(a),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${a.name}`,children:[G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:G.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"})}),G.jsx("span",{children:"Input"})]}):null})]},a.name))})]})})]})},c0o=class extends pr.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 l0o({graphics:t}){const e=t.points??[],n=t.lines??[],o=t.rects??[],r=t.circles??[],i=t.texts??[];let s=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY,l=Number.NEGATIVE_INFINITY;const u=(x,f)=>{typeof x=="number"&&(x<s&&(s=x),x>c&&(c=x)),typeof f=="number"&&(f<a&&(a=f),f>l&&(l=f))};for(const x of e)u(x.x,x.y);for(const x of n){const f=x.points??[];for(const g of f)u(g.x,g.y)}for(const x of o){const f=x.x??0,g=x.y??0,y=x.width??0,b=x.height??0;u(f,g),u(f+y,g+b)}for(const x of r){const f=x.x??0,g=x.y??0,y=x.radius??1;u(f-y,g-y),u(f+y,g+y)}for(const x of i)u(x.x,x.y);(!isFinite(s)||!isFinite(a)||!isFinite(c)||!isFinite(l))&&(s=-20,a=-20,c=20,l=20);const _=10,d=s-_,m=a-_,h=Math.max(1,c-s+2*_),p=Math.max(1,l-a+2*_);return G.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${d} ${m} ${h} ${p}`,role:"img","aria-label":"Graphics fallback",children:[o.map((x,f)=>G.jsx("rect",{x:x.x??0,y:x.y??0,width:x.width??0,height:x.height??0,fill:"none",stroke:x.strokeColor??"black",strokeWidth:x.strokeWidth??1},`rect-${f}`)),n.map((x,f)=>G.jsx("polyline",{fill:"none",stroke:x.strokeColor??"black",strokeWidth:x.strokeWidth??1,points:(x.points??[]).map(g=>`${g.x??0},${g.y??0}`).join(" ")},`line-${f}`)),r.map((x,f)=>G.jsx("circle",{cx:x.x??0,cy:x.y??0,r:x.radius??1.5,fill:x.fillColor??"none",stroke:x.strokeColor??"black",strokeWidth:x.strokeWidth??1},`circle-${f}`)),e.map((x,f)=>G.jsx("circle",{cx:x.x??0,cy:x.y??0,r:x.radius??1.5,fill:x.color??"black"},`point-${f}`)),i.map((x,f)=>G.jsx("text",{x:x.x??0,y:x.y??0,fontSize:x.fontSize??10,fill:x.color??"black",children:x.text??""},`text-${f}`))]})}var u0o=({solver:t,animationSpeed:e=25,onSolverStarted:n,onSolverCompleted:o})=>{const[r,i]=te.useReducer(u=>u+1,0),s=te.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(u){return console.error("Visualization error:",u),{points:[],lines:[],rects:[],circles:[]}}},[t,r]),a=te.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);te.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const u=document.createElement("script");u.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(u)}},[]);const c=t.pipelineDef!==void 0,l=u=>{const _=t;if(!t.solved&&!t.failed){for(;!t.solved&&!t.failed&&_.currentPipelineStepIndex<=_.pipelineDef.findIndex(d=>d.solverName===u);)t.step();i()}};return G.jsxs("div",{children:[G.jsx(Zuo,{solver:t,triggerRender:i,animationSpeed:e,onSolverStarted:n,onSolverCompleted:o}),a?G.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):G.jsx(c0o,{fallback:G.jsx(l0o,{graphics:s}),children:G.jsx(Kuo,{graphics:s})}),c&&G.jsx(a0o,{solver:t,onStepUntilPhase:l})]})};const _0o=()=>{te.useEffect(()=>{const t="tailwind-cdn-script";if(document.getElementById(t)||window.tailwind)return;const e=document.createElement("div");e.className="hidden",document.body.appendChild(e);const n=window.getComputedStyle(e).display==="none";if(document.body.removeChild(e),n)return;const o=document.createElement("script");o.id=t,o.src="https://cdn.tailwindcss.com",document.head.appendChild(o)},[])},d0o=t=>t.toLowerCase().includes("pack")?zUn:t.toLowerCase().includes("rout")?jUn:kUn,h0o=({solverEvents:t=[]})=>{const[e,n]=te.useState(null);_0o();const o=te.useMemo(()=>{const a=new Map;for(const c of t){const l=`${c.componentName}-${c.solverName}`;a.set(l,c)}return a},[t]),r=te.useMemo(()=>Array.from(o.keys()),[o]),i=e?o.get(e):null,s=te.useMemo(()=>{if(!i)return{instance:null,error:null,classFound:!1};const a=gde[i.solverName];if(!a)return{instance:null,error:`Solver class "${i.solverName}" not found in SOLVERS registry. Available: ${Object.keys(gde).join(", ")}`,classFound:!1};try{const c=i.solverParams,l=c?.input!==void 0?c.input:c;return{instance:new a(l),error:null,classFound:!0}}catch(c){const l=c instanceof Error?c.message:String(c);return console.error("Failed to reconstruct solver:",c),{instance:null,error:`Failed to instantiate solver: ${l}`,classFound:!0}}},[i]);return t.length===0?G.jsx("div",{className:"rf-p-4",children:G.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:G.jsxs("div",{className:"rf-p-4",children:[G.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),G.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."})]})})}):G.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[G.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[G.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:[r.length," ",r.length===1?"Solver":"Solvers"]}),r.map(a=>{const c=o.get(a),l=e===a;return G.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${l?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>n(a),children:(()=>{const u=d0o(c.solverName);return G.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[G.jsx(u,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),G.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[G.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:c.componentName}),G.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:c.solverName})]})]})})()},a)})]}),G.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:i?s.instance?G.jsx(Q4,{fallback:G.jsx("div",{className:"rf-p-4",children:G.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[G.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),G.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",i.solverName]})]})}),children:G.jsx(u0o,{solver:s.instance})}):G.jsxs("div",{className:"rf-p-4",children:[G.jsxs("div",{className:"rf-mb-4",children:[G.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:i.solverName}),G.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",i.componentName]})]}),s.error&&G.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:G.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),G.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[G.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:G.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),G.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:G.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(i.solverParams,null,2)})})]})]}):G.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:G.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},qxt=({errorMessage:t,errorStack:e,circuitJsonErrors:n})=>{te.useEffect(()=>{if(t){const o=new Error(t);e&&(o.stack=e);try{vB.captureException(o)}catch{}}},[t,e]),te.useEffect(()=>{if(n&&n.length>0)for(const o of n){const r=new Error(o.message||"Circuit JSON Error");o.stack&&(r.stack=o.stack);try{vB.captureException(r,{error_type:o.type})}catch{}}},[n])},Kxt="0.0.1972",m0o={version:Kxt},T4e={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},w4e=new Map,SJ=t=>{const e=w4e.get(t);return e?Object.fromEntries(Object.entries(e.stores).map(([n,o])=>[n,o.getState()])):{}},p0o=(t,e,n)=>{if(t===void 0)return{type:"untracked",connection:e.connect(n)};const o=w4e.get(n.name);if(o)return{type:"tracked",store:t,...o};const r={connection:e.connect(n),stores:{}};return w4e.set(n.name,r),{type:"tracked",store:t,...r}},Jxt=(t,e={})=>(n,o,r)=>{const{enabled:i,anonymousActionType:s,store:a,...c}=e;let l;try{l=(i??(T4e?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!l)return(T4e?"production":void 0)!=="production"&&i&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),t(n,o,r);const{connection:u,..._}=p0o(a,l,c);let d=!0;r.setState=(p,x,f)=>{const g=n(p,x);if(!d)return g;const y=f===void 0?{type:s||"anonymous"}:typeof f=="string"?{type:f}:f;return a===void 0?(u?.send(y,o()),g):(u?.send({...y,type:`${a}/${y.type}`},{...SJ(c.name),[a]:r.getState()}),g)};const m=(...p)=>{const x=d;d=!1,n(...p),d=x},h=t(r.setState,o,r);if(_.type==="untracked"?u?.init(h):(_.stores[_.store]=r,u?.init(Object.fromEntries(Object.entries(_.stores).map(([p,x])=>[p,p===_.store?h:x.getState()])))),r.dispatchFromDevtools&&typeof r.dispatch=="function"){let p=!1;const x=r.dispatch;r.dispatch=(...f)=>{(T4e?"production":void 0)!=="production"&&f[0].type==="__setState"&&!p&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),p=!0),x(...f)}}return u.subscribe(p=>{var x;switch(p.type){case"ACTION":if(typeof p.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return E4e(p.payload,f=>{if(f.type==="__setState"){if(a===void 0){m(f.state);return}Object.keys(f.state).length!==1&&console.error(`
5734
5734
  [zustand devtools middleware] Unsupported __setState action format.
5735
5735
  When using 'store' option in devtools(), the 'state' should have only one key, which is a value of 'store' that was passed in devtools(),
5736
5736
  and value of this only key should be a state object. Example: { "type": "__setState", "state": { "abc123Store": { "foo": "bar" } } }
@@ -5821,4 +5821,4 @@ Please report this to https://github.com/markedjs/marked.`,t){const o="<p>An err
5821
5821
  rf-max-h-[90vh] rf-overflow-y-auto
5822
5822
  `,children:G.jsx("div",{className:"rf-relative rf-w-full",children:n==="initial"&&G.jsx(wmo,{onCancel:e,packageReleaseId:i??"",signIn:s??(()=>{}),isLoggedIn:a})})})})}),Nmo=({isOpen:t,onClose:e,stage:n,setStage:o,signIn:r,isLoggedIn:i})=>{const s=xP(a=>a.circuitJson);return G.jsx(Rmo,{signIn:r,isOpen:t,onClose:e,stage:n,setStage:o,circuitJson:s,isLoggedIn:i??!1})},Imo=()=>{const[t,e]=te.useState(!1),[n,o]=te.useState("initial");return{isOpen:t,stage:n,open:()=>e(!0),close:()=>{e(!1),o("initial")},setStage:o,OrderDialog:Nmo}};async function r5t(){const t=await fetch(`${Z6}/files/list`),{file_list:e}=await t.json(),n=new Map;for(const o of e){const i=await(await fetch(`${Z6}/files/get?file_path=${encodeURIComponent(o.file_path)}`)).json();(i.file?.text_content||i.file?.binary_content_b64)&&n.set(o.file_path,{text_content:i.file.text_content,binary_content_b64:i.file.binary_content_b64})}return n}const Hmo="https://api.tscircuit.com/bug_reports/view?bug_report_id=",Lmo=t=>`${Hmo}${t}`,Omo=t=>{const[e,n]=te.useState(!1),[o,r]=te.useState(!1),[i,s]=te.useState(null),[a,c]=te.useState(null),[l,u]=te.useState([]),_=te.useRef(null),[d,m]=te.useState(null),[h,p]=te.useState(0),x=t?.onLoginRequired,f=te.useMemo(()=>IJ()?!0:typeof document>"u"?!1:document.cookie.split(";").some(S=>S.trim().startsWith("session=")),[e]);te.useEffect(()=>{if(e&&!d&&_.current){const S=typeof window<"u"?window.__TSCIRCUIT_LAST_EXECUTION_ERROR:void 0;S&&(_.current.value=`I'm getting this execution error:
5823
5823
 
5824
- ${S}`)}},[e,d]),te.useEffect(()=>{e&&!d&&r5t().then(S=>{p(S.size)}).catch(S=>{console.error("Failed to fetch file count",S),p(0)})},[e,d]);const g=te.useCallback(()=>{s(null),m(null),c(null),u([]),_.current&&(_.current.value=""),n(!0)},[]),y=te.useCallback(()=>{n(!1)},[]),b=te.useCallback(async()=>{r(!0),s(null),c(null),u([]);const S=IM(),C=_.current?.value||"";try{const w=await r5t();if(w.size===0){zs.error("No project files available to include in the bug report"),r(!1);return}const D=new Date(Date.now()+1440*60*1e3).toISOString(),L=(await S.post("bug_reports/create",{json:{text:C.trim()||void 0,is_auto_deleted:!0,delete_at:D}}).json()).bug_report.bug_report_id,H=Array.from(w.entries()),F=[];for(let V=0;V<H.length;V++){const[j,K]=H[V];c({current:V+1,total:H.length,currentFile:j});try{const J={bug_report_id:L,file_path:j};K.text_content&&(J.content_text=K.text_content),K.binary_content_b64&&(J.content_base64=K.binary_content_b64),await S.post("bug_reports/upload_file",{json:J})}catch(J){const oe=J instanceof RM?`HTTP ${J.response.status}`:J instanceof Error?J.message:"Upload failed";F.push({filePath:j,message:oe}),u([...F])}}c(null);const z=Lmo(L);m({bugReportUrl:z})}catch(w){if(console.error("Failed to submit bug report",w),w instanceof RM)if(w.response.status===401)if(f){const D="Your session has expired. Please sign in again to continue.";s(D),zs.error(D),x&&(y(),x())}else{const D="You must be logged in to report a bug. Please sign in via cli and try again.";s(D),zs.error(D),setTimeout(()=>{x&&(y(),x())},1e3)}else{const D=`Failed to submit bug report (${w.response.status})`;s(D),zs.error(D)}else if(w instanceof Error)s(w.message),zs.error(w.message);else{const D="Failed to submit bug report";s(D),zs.error(D)}}finally{r(!1)}},[f,x]);return{BugReportDialog:te.useMemo(()=>{const S=a?Math.round(a.current/a.total*100):0;return G.jsx(Fgt,{open:e,onOpenChange:C=>{C?(s(null),m(null),c(null),u([]),n(!0)):o||y()},children:G.jsxs(F4e,{children:[G.jsxs(B4e,{children:[G.jsx(V4e,{children:d?"Bug Report Created":"Report Bug"}),G.jsx($4e,{asChild:!0,children:d?G.jsxs("div",{className:"rf-text-left rf-space-y-3 rf-text-sm",children:[G.jsx("p",{children:"Bug report created successfully."}),l.length>0&&G.jsxs("div",{className:"rf-bg-red-50 rf-border rf-border-red-200 rf-rounded rf-p-2 rf-max-h-28 rf-overflow-y-auto rf-overflow-x-hidden",children:[G.jsxs("p",{className:"rf-text-red-700 rf-font-medium rf-text-xs rf-mb-1",children:[l.length," file(s) failed:"]}),l.map((C,w)=>G.jsxs("div",{className:"rf-text-red-600 rf-text-xs rf-mb-0.5",title:`${C.filePath}: ${C.message}`,children:[G.jsx("span",{className:"rf-font-medium rf-break-all",children:C.filePath.split("/").pop()}),G.jsx("span",{className:"rf-text-red-500 rf-block rf-truncate",children:C.message})]},w))]}),G.jsx("div",{children:G.jsx("a",{className:"rf-text-blue-600 hover:rf-underline",href:d.bugReportUrl,target:"_blank",rel:"noreferrer",children:"View bug report"})}),G.jsxs("p",{children:["Please share this link privately with tscircuit staff so we can help debug. Join the",G.jsx("a",{className:"rf-ml-1 rf-text-blue-600 hover:rf-underline",href:"https://tscircuit.com/join",target:"_blank",rel:"noreferrer",children:"tscircuit Discord"}),"."]})]}):G.jsx("div",{className:"rf-text-left rf-space-y-3 rf-text-sm",children:a?G.jsxs("div",{className:"rf-space-y-2 rf-overflow-hidden",children:[G.jsxs("div",{className:"rf-flex rf-justify-between rf-text-xs",children:[G.jsx("span",{children:"Uploading files..."}),G.jsxs("span",{children:[a.current,"/",a.total]})]}),G.jsx("div",{className:"rf-w-full rf-h-2 rf-bg-gray-200 rf-rounded-full rf-overflow-hidden",children:G.jsx("div",{className:"rf-h-full rf-bg-blue-500 rf-transition-all rf-duration-150",style:{width:`${S}%`}})}),G.jsx("p",{className:"rf-text-xs rf-text-gray-500 rf-break-all rf-truncate rf-w-full rf-max-w-full",children:`${a.currentFile.slice(0,60)}${a.currentFile.length>60?"...":""}`}),l.length>0&&G.jsx("div",{className:"rf-bg-red-50 rf-border rf-border-red-200 rf-rounded rf-p-2 rf-max-h-20 rf-overflow-y-auto rf-overflow-x-hidden",children:l.map((C,w)=>G.jsxs("div",{className:"rf-text-red-600 rf-text-xs rf-mb-0.5",title:`${C.filePath}: ${C.message}`,children:[G.jsx("span",{className:"rf-font-medium rf-break-all",children:C.filePath.split("/").pop()}),G.jsx("span",{className:"rf-text-red-500 rf-block rf-truncate",children:C.message})]},w))})]}):G.jsxs(G.Fragment,{children:[G.jsxs("p",{children:["Reporting a bug will upload your entire project",h>0?` (${h} file${h===1?"":"s"})`:""," ","to tscircuit support."]}),G.jsxs("div",{className:"rf-space-y-2",children:[G.jsx("label",{htmlFor:"bug-description",className:"rf-block rf-font-medium",children:"Description (optional)"}),G.jsx("textarea",{ref:_,id:"bug-description",className:"rf-w-full rf-min-h-[100px] rf-px-3 rf-py-2 rf-text-sm rf-border rf-border-gray-300 rf-rounded-md focus:rf-outline-none focus:rf-ring-2 focus:rf-ring-blue-500",placeholder:"Describe the issue you're experiencing...",disabled:o})]}),G.jsxs("p",{children:["Share the generated bug report link privately with tscircuit staff so we can help debug your issue. You can also reach out on our",G.jsx("a",{className:"rf-ml-1 rf-text-blue-600 hover:rf-underline",href:"https://tscircuit.com/join",target:"_blank",rel:"noreferrer",children:"Discord community"}),"."]}),!f&&G.jsx("p",{className:"rf-text-red-600",children:"You appear to be logged out. Please log in before reporting a bug or the upload will fail."}),i&&G.jsx("p",{className:"rf-text-red-600",children:i})]})})})]}),G.jsx(z4e,{children:d?G.jsx("button",{type:"button",className:yA(),onClick:()=>{y()},children:"Close"}):G.jsxs(G.Fragment,{children:[G.jsx(W4e,{disabled:o,onClick:()=>{o||y()},children:"Cancel"}),!f&&x?G.jsx("button",{type:"button",className:yA(),onClick:C=>{C.preventDefault(),y(),x()},children:"Sign In"}):G.jsx("button",{type:"button",className:L3(yA(),o&&"rf-opacity-70 rf-cursor-not-allowed"),disabled:o,onClick:C=>{C.preventDefault(),b()},children:o?"Reporting...":"Upload & Report"})]})})]})},"bug-report-dialog")},[e,o,y,i,d,h,f,b,x,a,l]),openBugReportDialog:g}};function Fmo({open:t,onOpenChange:e,onExport:n}){const[o,r]=te.useState(!1),i=()=>{n({includeSilkscreen:o}),e(!1)},s=()=>{e(!1)};return G.jsx(UO,{open:t,onOpenChange:e,children:G.jsxs(QA,{children:[G.jsxs(ZA,{children:[G.jsx(ek,{children:"LightBurn Export Options"}),G.jsx(jO,{children:"Configure export settings for PCB laser ablation with LightBurn"})]}),G.jsx("div",{className:"rf-flex rf-flex-col rf-gap-4 rf-py-4",children:G.jsxs("div",{className:"rf-flex rf-items-center rf-space-x-2",children:[G.jsx(WO,{id:"includeSilkscreen",checked:o,onCheckedChange:a=>r(a===!0)}),G.jsx("label",{htmlFor:"includeSilkscreen",className:"rf-text-xs rf-font-medium rf-leading-none peer-disabled:rf-cursor-not-allowed peer-disabled:rf-opacity-70",children:"Include silkscreen layer"})]})}),G.jsxs(XO,{children:[G.jsx(Yu,{variant:"outline",onClick:s,children:"Cancel"}),G.jsx(Yu,{onClick:i,children:"Export"})]})]})})}const Bmo=/#(\d+)/,zmo=t=>{const e=t.match(Bmo);if(!e)return null;const n=Number.parseInt(e[1],10);return Number.isFinite(n)?n:null},Vmo=t=>{if(typeof t=="number")return Number.isFinite(t)?t:null;if(typeof t=="string"){const e=new Date(t).getTime();return Number.isFinite(e)?e:null}return null},$mo=t=>{if(!t)return null;let e=null,n=-1,o=-1;for(const[r,i]of Object.entries(t)){const s=zmo(r),a=Vmo(i.createdAt);if(s!==null){s>n&&(n=s,e={key:r,value:i});continue}if(n===-1){if(a!==null&&a>o){o=a,e={key:r,value:i};continue}e||(e={key:r,value:i})}}return e},Wmo=t=>{const e=D4e(De=>De.lastRunEvalVersion),n=xP(De=>De.currentMainComponentPath),[o,r]=te.useState(null),[i,s]=te.useState(!1),[a,c]=te.useState(!0),[l,u]=te.useState(!1),[_,d]=te.useState(null),[m,h]=te.useState(null),[p,x]=te.useState(!1),[f,g]=te.useState(null),[y,b]=te.useState(null),[v,S]=te.useState(!1),[C,w]=te.useState(!1),[D,A]=te.useState(!1),[L,H]=te.useState(null),F=Imo(),z=xP(De=>De.pushEvent),V=xP(De=>De.recentEvents),j=te.useMemo(()=>Date.now(),[]);v0o(De=>{if(!(new Date(De.created_at).valueOf()<j+500)){if(De.event_type==="FILE_UPDATED"){s(!0);return}if(De.event_type==="SNIPPET_SAVED"){s(!1),c(!1),g("Snippet saved successfully."),S(!1);return}De.event_type==="REQUEST_EXPORT"&&(w(!0),g("Export processing..."),S(!1)),De.event_type==="EXPORT_CREATED"&&(g(`Export created: ${De.exportFilePath}`),S(!1),w(!1))}}),te.useEffect(()=>{if(!l||_===null)return;const De=V.filter(xe=>new Date(xe.created_at).valueOf()>_),pe=De.find(xe=>xe.event_type==="FAILED_TO_SAVE_SNIPPET"),Ce=De.find(xe=>xe.event_type==="SNIPPET_SAVED");pe&&(u(!1),d(null),b(pe.message??"Failed to save snippet. See console for error."),console.error(pe.message),S(!0),pe.error_code==="SNIPPET_UNSET"&&pe.available_snippet_names&&(h(pe.available_snippet_names),x(!0))),Ce&&(u(!1),d(null),g("Snippet saved successfully."),S(!1))},[V,l]);const K=async()=>{u(!0),d(Date.now()),g(null),S(!1),await z({event_type:"REQUEST_TO_SAVE_SNIPPET",snippet_name:o})},oe=xP(De=>De.circuitJson)??t.circuitJson,[ue,ne]=te.useState(!1),[se,ae]=te.useState(!1),{BugReportDialog:ce,openBugReportDialog:fe}=Omo({onLoginRequired:t.onLoginRequired}),Se=async De=>{L&&(await hyt({circuitJson:L.circuitJson,projectName:L.projectName,options:De}),H(null))},we=te.useMemo(()=>$mo(t.autoroutingLog),[t.autoroutingLog]);return G.jsxs(G.Fragment,{children:[G.jsxs("div",{className:"rf-flex rf-items-center rf-gap-1 rf-flex-shrink-0",children:[G.jsxs(oK,{children:[G.jsx(rK,{asChild:!0,children:G.jsx("div",{className:"rf-whitespace-nowrap rf-text-xs font-medium rf-p-2 rf-mx-1 rf-cursor-pointer rf-relative",children:"File"})}),G.jsxs(XL,{className:"rf-z-[101]",children:[!t.isWebEmbedded&&G.jsxs(G.Fragment,{children:[G.jsx(Jd,{className:"rf-text-xs",onSelect:K,disabled:l,children:l?"Saving...":"Push"}),parseInt(window.location.port)>5e3&&G.jsx(Jd,{className:"rf-text-xs",onSelect:()=>{F.open()},children:"Order"}),G.jsx(Jd,{className:"rf-text-xs",onSelect:()=>ne(!0),disabled:l,children:"Import"}),G.jsx(Jd,{className:"rf-text-xs",onSelect:()=>{if(!IJ()){zs.error("Requires tscircuit token");return}ae(!0)},children:"AI Review"})]}),!t.isWebEmbedded&&t.onLoginRequired&&G.jsx(Jd,{className:"rf-text-xs",onSelect:()=>{t.onLoginRequired?.()},children:"Sign In"}),!t.isWebEmbedded&&G.jsxs(UL,{children:[G.jsx(EA,{className:"rf-text-xs",children:"Report Bug"}),G.jsx(WL,{children:G.jsxs(DA,{children:[G.jsx(Jd,{className:"rf-text-xs",onSelect:()=>{fe()},children:"Report Entire Circuit"}),G.jsx(Jd,{className:"rf-text-xs",disabled:!we||!t.onReportAutoroutingLog,onSelect:()=>{!we||!t.onReportAutoroutingLog||t.onReportAutoroutingLog(we.key,{simpleRouteJson:we.value.simpleRouteJson})},children:"Report Autorouter Bug"})]})})]}),G.jsxs(UL,{children:[G.jsx(EA,{className:"rf-text-xs",disabled:C,children:C?"Exporting...":"Export"}),G.jsx(WL,{children:G.jsx(DA,{children:Hdo.map((De,pe)=>G.jsx(Jd,{onSelect:()=>{if(!oe){zs.error("No Circuit JSON to export");return}let Ce="Untitled";if(n){const ze=n.split("/").pop();ze&&(Ce=ze.replace(/\.[^.]+$/,""))}const xe=t.projectName??o??Ce;if(De.name==="LightBurn"){H({circuitJson:oe,projectName:xe}),A(!0);return}Ldo({exportName:De.name,circuitJson:oe,projectName:xe?.replace(/\.(board|circuit)$/,"")})},disabled:C,children:G.jsx("span",{className:"rf-text-xs",children:De.name})},pe))})})]}),!t.isWebEmbedded&&G.jsxs(UL,{children:[G.jsx(EA,{className:"rf-text-xs",children:"Advanced"}),G.jsx(WL,{children:G.jsxs(DA,{children:[G.jsx(Jd,{className:"rf-flex rf-items-center rf-gap-2",children:G.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[G.jsx(WO,{id:"load-latest-eval",checked:t.shouldLoadLatestEval,onCheckedChange:De=>{t.onChangeShouldLoadLatestEval?.(De===!0)}}),G.jsx("label",{htmlFor:"load-latest-eval",className:"rf-text-xs rf-cursor-pointer",children:"Force Latest @tscircuit/eval"})]})}),e&&G.jsx(Jd,{className:"rf-flex rf-items-center rf-gap-2",children:G.jsx("div",{className:"rf-flex rf-items-center rf-gap-2",children:G.jsxs("span",{className:"rf-text-xs",children:["@tscircuit/eval@",e]})})}),G.jsx(Jd,{className:"rf-flex rf-items-center rf-gap-2",children:G.jsx("div",{className:"rf-flex rf-items-center rf-gap-2",children:G.jsxs("span",{className:"rf-text-xs",children:["@tscircuit/runframe@",m0o.version]})})}),G.jsx(Jd,{className:"rf-flex rf-items-center rf-gap-2",onClick:()=>{window.open("/api/admin","_blank")},children:G.jsx("div",{className:"rf-flex rf-items-center rf-gap-2",children:G.jsx("span",{className:"rf-text-xs",children:"CLI Admin Panel"})})})]})})]})]}),G.jsx(Fgt,{open:v,onOpenChange:S,children:G.jsxs(F4e,{children:[G.jsxs(B4e,{children:[G.jsx(V4e,{children:"Error Saving Snippet"}),G.jsx($4e,{children:y})]}),G.jsx(z4e,{children:G.jsx(W4e,{onClick:()=>S(!1),children:"Dismiss"})})]})}),G.jsx(P0o,{snippetNames:m??[],onSelect:async De=>{u(!0),d(Date.now()),r(De),await z({event_type:"REQUEST_TO_SAVE_SNIPPET",snippet_name:De}),x(!1)},onCancel:()=>x(!1),isOpen:p})]}),G.jsxs(oK,{children:[G.jsx(rK,{asChild:!0,children:G.jsx("div",{className:"rf-whitespace-nowrap rf-text-xs font-medium rf-p-2 rf-mx-1 rf-cursor-pointer rf-relative",children:"View"})}),G.jsx(XL,{className:"rf-z-[104]",children:G.jsxs(UL,{children:[G.jsx(EA,{className:"rf-text-xs",children:"Schematic"}),G.jsx(WL,{children:G.jsxs(DA,{children:[G.jsx(Jd,{className:"rf-flex rf-items-center rf-gap-2",onSelect:De=>De.preventDefault(),children:G.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[G.jsx(WO,{id:"show-schematic-ports",checked:t.showSchematicPorts,onCheckedChange:De=>{t.onChangeShowSchematicPorts?.(De===!0)}}),G.jsx("label",{htmlFor:"show-schematic-ports",className:"rf-text-xs rf-cursor-pointer",children:"Show Schematic Ports"})]})}),G.jsx(Jd,{className:"rf-flex rf-items-center rf-gap-2",onSelect:De=>De.preventDefault(),children:G.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[G.jsx(WO,{id:"show-schematic-grid",checked:t.showSchematicDebugGrid,onCheckedChange:De=>{t.onChangeShowSchematicDebugGrid?.(De===!0)}}),G.jsx("label",{htmlFor:"show-schematic-grid",className:"rf-text-xs rf-cursor-pointer",children:"Show Schematic Grid"})]})})]})})]})})]})]}),ce,G.jsx(Fmo,{open:D,onOpenChange:A,onExport:Se}),G.jsx(uyt,{isOpen:ue,onClose:()=>ne(!1)}),G.jsx(Uho,{isOpen:se,onClose:()=>ae(!1),packageName:o}),G.jsx(rct,{position:"top-center",reverseOrder:!1,containerStyle:{zIndex:1e5},toastOptions:{className:"rf-break-all",style:{zIndex:1e5}}}),G.jsx(F.OrderDialog,{isOpen:F.isOpen,onClose:F.close,stage:F.stage,setStage:F.setStage})]})},Umo=["assembly","pinout","analog_simulation","bom","circuit_json","errors","render_log","solvers"],Xmo=({code:t,fsMap:e,onRunClicked:n=void 0,errorMessage:o,errorStack:r,circuitJson:i,autoroutingGraphics:s,showRightHeaderContent:a=!0,showCodeTab:c=!1,codeTabContent:l,showJsonTab:u=!0,showRenderLogTab:_=!0,onActiveTabChange:d,renderLog:m,showImportAndFormatButtons:h=!0,className:p,headerClassName:x,leftHeaderContent:f,readOnly:g,isStreaming:y,autoroutingLog:b,onReportAutoroutingLog:v,isRunningCode:S,hasCodeChangedSinceLastRun:C,onEditEvent:w,editEvents:D,defaultActiveTab:A,defaultTab:L,availableTabs:H,autoRotate3dViewerDisabled:F,showSchematicDebugGrid:z=!1,showSchematicPorts:V=!1,onChangeShowSchematicDebugGrid:j,onChangeShowSchematicPorts:K,showToggleFullScreen:J=!0,defaultToFullScreen:oe=!1,activeEffectName:ue,allowSelectingVersion:ne=!0,showFileMenu:se=!1,isWebEmbedded:ae=!1,projectName:ce,onRerunWithDebug:fe,solverEvents:Se,onPcbBoundsSelected:we})=>{Fxt();const{versions:De,latestVersion:pe,lastRunEvalVersion:Ce,search:xe,setSearch:ze,selectVersion:We}=f0o(ne),Ye=te.useMemo(()=>i?i.filter(kt=>kt&&"error_type"in kt||kt.type.includes("error")):null,[i]),ye=te.useMemo(()=>i?i.filter(kt=>kt&&"warning_type"in kt||kt.type.includes("warning")):null,[i]),Je=te.useMemo(()=>i?i.some(kt=>kt.type==="schematic_group"):!0,[i]),Be=te.useMemo(()=>i?.some(kt=>kt.type==="pcb_panel"),[i]);qxt({errorMessage:o,errorStack:r,circuitJsonErrors:Ye});const ke=L??H?.[0]??"pcb",[Ve,He]=Bxt("runframe-active-tab",A??ke,A),[Te,Ae]=te.useState(null),[Ee,$e]=te.useState(oe),[Ue,nt]=te.useState(z),[rt,st]=te.useState(V),ut=j?z:Ue,xt=K?V:rt,Et=j??nt,Bt=K??st;Dlo(Ee);const Gt=te.useCallback(kt=>{He(kt),d?.(kt)},[d,He]),Ft=()=>{$e(!Ee)};te.useEffect(()=>{o&&(Ve!=="errors"&&Ae(Ve),Gt("errors"))},[o]),te.useEffect(()=>{(Ve==="code"||Ve==="errors")&&i&&!o&&Gt(Te??A??L??H?.[0]??"pcb")},[i]);const ln=te.useCallback(kt=>{window.TSCIRCUIT_3D_OBJECT_REF=kt===null?void 0:kt},[]);return G.jsx("div",{className:Ei("flex flex-col relative rf-overflow-x-hidden rf-h-full",p),children:G.jsx("div",{className:Ei("rf-md:sticky rf-md:top-2 rf-h-full",Ee&&"rf-fixed rf-top-0 rf-left-0 rf-w-full rf-h-full rf-bg-white rf-overflow-hidden"),children:G.jsxs(oee,{value:Ve,onValueChange:Gt,className:"rf-flex-grow rf-flex rf-flex-col rf-h-full",children:[G.jsxs("div",{className:Ei("rf-flex rf-items-center rf-gap-2 rf-p-2 rf-pb-0",x),children:[f,se&&!f&&G.jsx(Wmo,{isWebEmbedded:ae,circuitJson:i,projectName:ce,showSchematicDebugGrid:ut,onChangeShowSchematicDebugGrid:Et,showSchematicPorts:xt,onChangeShowSchematicPorts:Bt}),(f||se)&&G.jsx("div",{className:"rf-flex-grow"}),!f&&!se&&S&&G.jsx(H9,{className:"rf-w-4 rf-h-4 rf-animate-spin"}),!f&&!se&&G.jsx("div",{className:"rf-flex-grow"}),m&&m.progress!==1&&!o&&G.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2 rf-min-w-0 rf-max-w-xs",children:[ue?G.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate rf-min-w-0",title:ue,children:ue}):m.lastRenderEvent&&G.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate rf-min-w-0",title:m.lastRenderEvent?.phase??"",children:m.lastRenderEvent?.phase??""}),G.jsx("div",{className:"rf-w-4 rf-h-4 rf-bg-blue-500 rf-opacity-50 rf-rounded-full rf-text-white rf-flex-shrink-0",children:G.jsx(H9,{className:"rf-w-4 rf-h-4 rf-animate-spin"})}),G.jsxs("div",{className:"rf-text-xs rf-font-bold rf-text-gray-700 rf-tabular-nums rf-flex-shrink-0",children:[((m.progress??0)*100).toFixed(1),"%"]})]}),a&&G.jsxs(CB,{children:[c&&G.jsx(Yb,{value:"code",children:"Code"}),!H||H.includes("pcb")?G.jsxs(Yb,{value:"pcb",className:"rf-whitespace-nowrap",children:[i&&G.jsx("span",{className:Ei("rf-inline-flex rf-items-center rf-justify-center rf-w-2 rf-h-2 rf-mr-1 rf-text-xs rf-font-bold rf-text-white rf-rounded-full",C?"rf-bg-gray-500":"rf-bg-blue-500")}),"PCB"]}):null,!H||H.includes("schematic")?G.jsxs(Yb,{value:"schematic",className:Ei("rf-whitespace-nowrap",i&&!Je&&"rf-opacity-50"),disabled:i?!Je||Be:!1,children:[i&&G.jsx("span",{className:Ei("rf-inline-flex rf-items-center rf-justify-center rf-w-2 rf-h-2 rf-mr-1 rf-text-xs rf-font-bold rf-text-white rf-rounded-full",C?"rf-bg-gray-500":"rf-bg-blue-500")}),"Schematic"]}):null,!H||H.includes("cad")?G.jsxs(Yb,{value:"cad",children:[i&&G.jsx("span",{className:Ei("inline-flex items-center justify-center w-2 h-2 mr-1 text-xs font-bold text-white rounded-full",C?"rf-bg-gray-500":"rf-bg-blue-500")}),"3D"]}):null,!["pcb","cad","schematic"].includes(Ve)&&G.jsx(Yb,{value:Ve,children:F9e(Ve)}),G.jsxs(oK,{children:[G.jsx(rK,{asChild:!0,children:G.jsxs("div",{className:"rf-whitespace-nowrap rf-p-2 rf-mr-1 rf-cursor-pointer rf-relative",children:[G.jsx(OUn,{className:"rf-w-4 rf-h-4"}),(Ye&&Ye.length>0||o)&&G.jsx("span",{className:"rf-inline-flex rf-absolute rf-top-[6px] rf-right-[4px] rf-items-center rf-justify-center rf-w-1 rf-h-1 rf-ml-2 rf-text-[8px] rf-font-bold rf-text-white rf-bg-red-500 rf-rounded-full"})]})}),G.jsxs(XL,{className:"rf-*:text-xs rf-z-[101]",children:[Umo.filter(kt=>!H||H.includes(kt)).map(kt=>G.jsxs(Jd,{onSelect:()=>Gt(kt),children:[Ve!==kt&&G.jsx(udt,{className:"rf-w-3 rf-h-3 rf-opacity-30"}),Ve===kt&&G.jsx(Y5e,{className:"rf-w-3 rf-h-3"}),G.jsx("div",{className:"rf-pr-2",children:F9e(kt)}),kt==="errors"&&(Ye&&Ye.length>0||o)&&G.jsx("span",{className:"rf-inline-flex rf-items-center rf-justify-center rf-w-3 rf-h-3 rf-ml-2 rf-text-[8px] rf-font-bold rf-text-white rf-bg-red-500 rf-rounded-full",children:o?1:Ye?.length}),kt==="solvers"&&Se&&Se.length>0&&G.jsx("span",{className:"rf-inline-flex rf-items-center rf-justify-center rf-min-w-[12px] rf-h-3 rf-px-1 rf-ml-2 rf-text-[8px] rf-font-bold rf-text-white rf-bg-blue-500 rf-rounded-full",children:Se.length})]},kt)),G.jsx(Jd,{disabled:!0,className:"rf-opacity-60 rf-cursor-default rf-select-none",children:G.jsxs("div",{className:"rf-pr-2 rf-text-xs rf-text-gray-500",children:["@tscircuit/runframe@",Kxt.split(".").map((kt,bn)=>bn===2?parseInt(kt)+1:kt).join(".")]})}),ne?G.jsxs(UL,{onOpenChange:kt=>!kt&&ze(""),children:[G.jsx(EA,{className:"rf-text-xs rf-opacity-60",children:G.jsxs("div",{className:"rf-pr-2 rf-text-xs rf-text-gray-500",children:["@tscircuit/eval@",Ce??pe??"latest"]})}),G.jsx(WL,{children:G.jsxs(DA,{className:"rf-*:text-xs rf-w-40 rf-max-h-[200px] rf-overflow-y-auto",children:[G.jsx("div",{className:"rf-p-1",children:G.jsx(Dbe,{value:xe,onChange:kt=>ze(kt.target.value),placeholder:"Search...",className:"rf-h-7 rf-text-xs"})}),G.jsx(pmt,{}),G.jsx(Jd,{onSelect:()=>We(null),children:pe?`${pe} (latest)`:"latest"}),De.map(kt=>G.jsx(Jd,{onSelect:()=>We(kt),children:kt},kt))]})})]}):Ce&&G.jsx(Jd,{disabled:!0,className:"rf-opacity-60 rf-cursor-default rf-select-none",children:G.jsxs("div",{className:"rf-pr-2 rf-text-xs rf-text-gray-500",children:["@tscircuit/eval@",Ce]})})]})]})]}),J&&G.jsx(Yu,{onClick:Ft,variant:"ghost",children:Ee?G.jsx(WUn,{size:16}):G.jsx(BUn,{size:16})})]}),c&&G.jsx(k1,{value:"code",className:"rf-flex-grow rf-overflow-hidden",children:G.jsx("div",{className:"rf-h-full",children:l})}),(!H||H.includes("pcb"))&&G.jsx(k1,{value:"pcb",children:G.jsx("div",{className:Ei("rf-overflow-hidden",Ee?"rf-h-[calc(100vh-52px)]":"rf-h-full"),children:G.jsx(Q4,{fallbackRender:({error:kt})=>G.jsx("div",{className:"rf-mt-4 rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200",children:G.jsxs("div",{className:"rf-p-4",children:[G.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-3",children:"Error loading PCB viewer"}),G.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-red-600 rf-mt-2",children:kt?.message||"An unknown error occurred"})]})}),children:i?G.jsx(wlo,{focusOnHover:!1,circuitJson:i,debugGraphics:s,onBoundsSelected:we,containerClassName:Ei("rf-h-full rf-w-full",Ee?"rf-min-h-[calc(100vh-240px)]":"rf-min-h-[620px]"),onEditEventsChanged:kt=>{if(w)for(const bn of kt)w(bn)}}):G.jsx(J6,{onRunClicked:n})})})}),(!H||H.includes("assembly"))&&G.jsx(k1,{value:"assembly",children:G.jsx("div",{className:Ei("rf-overflow-auto",Ee?"rf-h-[calc(100vh-60px)]":"rf-h-full rf-min-h-[620px]"),children:G.jsx(Q4,{fallback:G.jsx("div",{children:"Error loading Assembly"}),children:i?G.jsx(Jno,{circuitJson:i,containerStyle:{height:"100%"},editingEnabled:!0,debugGrid:!0}):G.jsx(J6,{onRunClicked:n})})})}),(!H||H.includes("pinout"))&&G.jsx(k1,{value:"pinout",children:G.jsx("div",{className:Ei("rf-overflow-auto",Ee?"rf-h-[calc(100vh-60px)]":"rf-h-full rf-min-h-[620px]"),children:G.jsx(Q4,{fallback:G.jsx("div",{children:"Error loading Pinout Viewer"}),children:i?G.jsx(Qno,{circuitJson:i,containerStyle:{height:"100%"}}):G.jsx(J6,{onRunClicked:n})})})}),(!H||H.includes("schematic"))&&G.jsx(k1,{value:"schematic",children:G.jsx("div",{className:Ei("rf-overflow-auto rf-bg-white",Ee?"rf-h-[calc(100vh-60px)]":"rf-h-full rf-min-h-[620px]"),children:G.jsx(Q4,{fallbackRender:({error:kt})=>G.jsx("div",{className:"rf-mt-4 rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200",children:G.jsxs("div",{className:"rf-p-4",children:[G.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-3",children:"Error loading Schematic"}),G.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-red-600 rf-mt-2",children:kt?.message||"An unknown error occurred"})]})}),children:i?G.jsx(qno,{spiceSimulationEnabled:!0,circuitJson:i,containerStyle:{height:"100%"},editingEnabled:!0,onEditEvent:kt=>{w?.(kt)},debugGrid:ut,showSchematicPorts:xt}):G.jsx(J6,{onRunClicked:n})})})}),(!H||H.includes("cad"))&&G.jsx(k1,{value:"cad",children:G.jsx("div",{className:Ei("rf-overflow-auto",Ee?"rf-h-[calc(100vh-60px)]":"rf-h-full rf-min-h-[620px]"),children:G.jsx(Q4,{fallbackRender:({error:kt,resetErrorBoundary:bn})=>G.jsx(vUn,{error:kt,resetErrorBoundary:bn}),children:i?G.jsx(_Un,{ref:ln,circuitJson:i,autoRotateDisabled:F},`cad-${Ee}`):G.jsx(J6,{onRunClicked:n})})})}),(!H||H.includes("analog_simulation"))&&G.jsx(k1,{value:"analog_simulation",children:G.jsx("div",{className:Ei("rf-overflow-auto",Ee?"rf-h-[calc(100vh-60px)]":"rf-h-full rf-min-h-[620px]"),children:G.jsx(Q4,{fallback:G.jsx("div",{children:"Error loading Analog Simulation"}),children:i?G.jsx(Kno,{circuitJson:i,containerStyle:{height:"100%"}}):G.jsx(J6,{onRunClicked:n})})})}),(!H||H.includes("bom"))&&G.jsx(k1,{value:"bom",children:G.jsx("div",{className:Ei("rf-overflow-auto",Ee?"rf-h-[calc(100vh-60px)]":"rf-h-full rf-min-h-[620px]"),children:G.jsx(Q4,{fallbackRender:({error:kt})=>G.jsx("div",{className:"rf-mt-4 rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200",children:G.jsxs("div",{className:"rf-p-4",children:[G.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-3",children:"Error loading Bill of Materials"}),G.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-red-600 rf-mt-2",children:kt?.message||"An unknown error occurred"})]})}),children:i?G.jsx(moo,{circuitJson:i}):G.jsx(J6,{onRunClicked:n})})})}),(!H||H.includes("circuit_json"))&&G.jsx(k1,{value:"circuit_json",children:G.jsx("div",{className:Ei("rf-overflow-auto",Ee?"rf-h-[calc(100vh-60px)]":"rf-h-full rf-min-h-[620px]"),children:G.jsx(Q4,{fallback:G.jsx("div",{children:"Error loading JSON viewer"}),children:i?G.jsx(too,{elements:i}):G.jsx(J6,{onRunClicked:n})})})}),(!H||H.includes("errors"))&&G.jsx(k1,{value:"errors",className:"rf-h-full",children:G.jsx("div",{className:Ei("rf-overflow-hidden",Ee?"rf-h-[calc(100vh-60px)]":"rf-h-full rf-min-h-[620px]"),children:o||Ye&&Ye.length>0||i?G.jsx(VYn,{code:t,fsMap:e,circuitJsonErrors:Ye,circuitJsonWarnings:ye,errorMessage:o,errorStack:r,circuitJson:i,evalVersion:Ce,autoroutingLog:b,onReportAutoroutingLog:v}):G.jsx(J6,{onRunClicked:n})})}),_&&(!H||H.includes("render_log"))&&G.jsx(k1,{value:"render_log",children:G.jsx(Rlo,{renderLog:m,onRerunWithDebug:fe})}),(!H||H.includes("solvers"))&&G.jsx(k1,{value:"solvers",children:G.jsx("div",{className:Ei("rf-overflow-hidden",Ee?"rf-h-[calc(100vh-60px)]":"rf-h-full rf-min-h-[620px]"),children:G.jsx(Q4,{fallback:G.jsx("div",{children:"Error loading Solvers view"}),children:G.jsx(h0o,{solverEvents:Se})})})})]})})})};ubt.createRoot(document.getElementById("root")).render(G.jsx("div",{style:{height:"100vh"},children:G.jsx(Xmo,{defaultActiveTab:"cad",autoRotate3dViewerDisabled:!0,showRightHeaderContent:!1,circuitJson:window.CIRCUIT_JSON||{},...window.CIRCUIT_JSON_PREVIEW_PROPS||{}})}))}));
5824
+ ${S}`)}},[e,d]),te.useEffect(()=>{e&&!d&&r5t().then(S=>{p(S.size)}).catch(S=>{console.error("Failed to fetch file count",S),p(0)})},[e,d]);const g=te.useCallback(()=>{s(null),m(null),c(null),u([]),_.current&&(_.current.value=""),n(!0)},[]),y=te.useCallback(()=>{n(!1)},[]),b=te.useCallback(async()=>{r(!0),s(null),c(null),u([]);const S=IM(),C=_.current?.value||"";try{const w=await r5t();if(w.size===0){zs.error("No project files available to include in the bug report"),r(!1);return}const D=new Date(Date.now()+1440*60*1e3).toISOString(),L=(await S.post("bug_reports/create",{json:{text:C.trim()||void 0,is_auto_deleted:!0,delete_at:D}}).json()).bug_report.bug_report_id,H=Array.from(w.entries()),F=[];for(let V=0;V<H.length;V++){const[j,K]=H[V];c({current:V+1,total:H.length,currentFile:j});try{const J={bug_report_id:L,file_path:j};K.text_content&&(J.content_text=K.text_content),K.binary_content_b64&&(J.content_base64=K.binary_content_b64),await S.post("bug_reports/upload_file",{json:J})}catch(J){const oe=J instanceof RM?`HTTP ${J.response.status}`:J instanceof Error?J.message:"Upload failed";F.push({filePath:j,message:oe}),u([...F])}}c(null);const z=Lmo(L);m({bugReportUrl:z})}catch(w){if(console.error("Failed to submit bug report",w),w instanceof RM)if(w.response.status===401)if(f){const D="Your session has expired. Please sign in again to continue.";s(D),zs.error(D),x&&(y(),x())}else{const D="You must be logged in to report a bug. Please sign in via cli and try again.";s(D),zs.error(D),setTimeout(()=>{x&&(y(),x())},1e3)}else{const D=`Failed to submit bug report (${w.response.status})`;s(D),zs.error(D)}else if(w instanceof Error)s(w.message),zs.error(w.message);else{const D="Failed to submit bug report";s(D),zs.error(D)}}finally{r(!1)}},[f,x]);return{BugReportDialog:te.useMemo(()=>{const S=a?Math.round(a.current/a.total*100):0;return G.jsx(Fgt,{open:e,onOpenChange:C=>{C?(s(null),m(null),c(null),u([]),n(!0)):o||y()},children:G.jsxs(F4e,{children:[G.jsxs(B4e,{children:[G.jsx(V4e,{children:d?"Bug Report Created":"Report Bug"}),G.jsx($4e,{asChild:!0,children:d?G.jsxs("div",{className:"rf-text-left rf-space-y-3 rf-text-sm",children:[G.jsx("p",{children:"Bug report created successfully."}),l.length>0&&G.jsxs("div",{className:"rf-bg-red-50 rf-border rf-border-red-200 rf-rounded rf-p-2 rf-max-h-28 rf-overflow-y-auto rf-overflow-x-hidden",children:[G.jsxs("p",{className:"rf-text-red-700 rf-font-medium rf-text-xs rf-mb-1",children:[l.length," file(s) failed:"]}),l.map((C,w)=>G.jsxs("div",{className:"rf-text-red-600 rf-text-xs rf-mb-0.5",title:`${C.filePath}: ${C.message}`,children:[G.jsx("span",{className:"rf-font-medium rf-break-all",children:C.filePath.split("/").pop()}),G.jsx("span",{className:"rf-text-red-500 rf-block rf-truncate",children:C.message})]},w))]}),G.jsx("div",{children:G.jsx("a",{className:"rf-text-blue-600 hover:rf-underline",href:d.bugReportUrl,target:"_blank",rel:"noreferrer",children:"View bug report"})}),G.jsxs("p",{children:["Please share this link privately with tscircuit staff so we can help debug. Join the",G.jsx("a",{className:"rf-ml-1 rf-text-blue-600 hover:rf-underline",href:"https://tscircuit.com/join",target:"_blank",rel:"noreferrer",children:"tscircuit Discord"}),"."]})]}):G.jsx("div",{className:"rf-text-left rf-space-y-3 rf-text-sm",children:a?G.jsxs("div",{className:"rf-space-y-2 rf-overflow-hidden",children:[G.jsxs("div",{className:"rf-flex rf-justify-between rf-text-xs",children:[G.jsx("span",{children:"Uploading files..."}),G.jsxs("span",{children:[a.current,"/",a.total]})]}),G.jsx("div",{className:"rf-w-full rf-h-2 rf-bg-gray-200 rf-rounded-full rf-overflow-hidden",children:G.jsx("div",{className:"rf-h-full rf-bg-blue-500 rf-transition-all rf-duration-150",style:{width:`${S}%`}})}),G.jsx("p",{className:"rf-text-xs rf-text-gray-500 rf-break-all rf-truncate rf-w-full rf-max-w-full",children:`${a.currentFile.slice(0,60)}${a.currentFile.length>60?"...":""}`}),l.length>0&&G.jsx("div",{className:"rf-bg-red-50 rf-border rf-border-red-200 rf-rounded rf-p-2 rf-max-h-20 rf-overflow-y-auto rf-overflow-x-hidden",children:l.map((C,w)=>G.jsxs("div",{className:"rf-text-red-600 rf-text-xs rf-mb-0.5",title:`${C.filePath}: ${C.message}`,children:[G.jsx("span",{className:"rf-font-medium rf-break-all",children:C.filePath.split("/").pop()}),G.jsx("span",{className:"rf-text-red-500 rf-block rf-truncate",children:C.message})]},w))})]}):G.jsxs(G.Fragment,{children:[G.jsxs("p",{children:["Reporting a bug will upload your entire project",h>0?` (${h} file${h===1?"":"s"})`:""," ","to tscircuit support."]}),G.jsxs("div",{className:"rf-space-y-2",children:[G.jsx("label",{htmlFor:"bug-description",className:"rf-block rf-font-medium",children:"Description (optional)"}),G.jsx("textarea",{ref:_,id:"bug-description",className:"rf-w-full rf-min-h-[100px] rf-px-3 rf-py-2 rf-text-sm rf-border rf-border-gray-300 rf-rounded-md focus:rf-outline-none focus:rf-ring-2 focus:rf-ring-blue-500",placeholder:"Describe the issue you're experiencing...",disabled:o})]}),G.jsxs("p",{children:["Share the generated bug report link privately with tscircuit staff so we can help debug your issue. You can also reach out on our",G.jsx("a",{className:"rf-ml-1 rf-text-blue-600 hover:rf-underline",href:"https://tscircuit.com/join",target:"_blank",rel:"noreferrer",children:"Discord community"}),"."]}),!f&&G.jsx("p",{className:"rf-text-red-600",children:"You appear to be logged out. Please log in before reporting a bug or the upload will fail."}),i&&G.jsx("p",{className:"rf-text-red-600",children:i})]})})})]}),G.jsx(z4e,{children:d?G.jsx("button",{type:"button",className:yA(),onClick:()=>{y()},children:"Close"}):G.jsxs(G.Fragment,{children:[G.jsx(W4e,{disabled:o,onClick:()=>{o||y()},children:"Cancel"}),!f&&x?G.jsx("button",{type:"button",className:yA(),onClick:C=>{C.preventDefault(),y(),x()},children:"Sign In"}):G.jsx("button",{type:"button",className:L3(yA(),o&&"rf-opacity-70 rf-cursor-not-allowed"),disabled:o,onClick:C=>{C.preventDefault(),b()},children:o?"Reporting...":"Upload & Report"})]})})]})},"bug-report-dialog")},[e,o,y,i,d,h,f,b,x,a,l]),openBugReportDialog:g}};function Fmo({open:t,onOpenChange:e,onExport:n}){const[o,r]=te.useState(!1),i=()=>{n({includeSilkscreen:o}),e(!1)},s=()=>{e(!1)};return G.jsx(UO,{open:t,onOpenChange:e,children:G.jsxs(QA,{children:[G.jsxs(ZA,{children:[G.jsx(ek,{children:"LightBurn Export Options"}),G.jsx(jO,{children:"Configure export settings for PCB laser ablation with LightBurn"})]}),G.jsx("div",{className:"rf-flex rf-flex-col rf-gap-4 rf-py-4",children:G.jsxs("div",{className:"rf-flex rf-items-center rf-space-x-2",children:[G.jsx(WO,{id:"includeSilkscreen",checked:o,onCheckedChange:a=>r(a===!0)}),G.jsx("label",{htmlFor:"includeSilkscreen",className:"rf-text-xs rf-font-medium rf-leading-none peer-disabled:rf-cursor-not-allowed peer-disabled:rf-opacity-70",children:"Include silkscreen layer"})]})}),G.jsxs(XO,{children:[G.jsx(Yu,{variant:"outline",onClick:s,children:"Cancel"}),G.jsx(Yu,{onClick:i,children:"Export"})]})]})})}const Bmo=/#(\d+)/,zmo=t=>{const e=t.match(Bmo);if(!e)return null;const n=Number.parseInt(e[1],10);return Number.isFinite(n)?n:null},Vmo=t=>{if(typeof t=="number")return Number.isFinite(t)?t:null;if(typeof t=="string"){const e=new Date(t).getTime();return Number.isFinite(e)?e:null}return null},$mo=t=>{if(!t)return null;let e=null,n=-1,o=-1;for(const[r,i]of Object.entries(t)){const s=zmo(r),a=Vmo(i.createdAt);if(s!==null){s>n&&(n=s,e={key:r,value:i});continue}if(n===-1){if(a!==null&&a>o){o=a,e={key:r,value:i};continue}e||(e={key:r,value:i})}}return e},Wmo=t=>{const e=D4e(De=>De.lastRunEvalVersion),n=xP(De=>De.currentMainComponentPath),[o,r]=te.useState(null),[i,s]=te.useState(!1),[a,c]=te.useState(!0),[l,u]=te.useState(!1),[_,d]=te.useState(null),[m,h]=te.useState(null),[p,x]=te.useState(!1),[f,g]=te.useState(null),[y,b]=te.useState(null),[v,S]=te.useState(!1),[C,w]=te.useState(!1),[D,A]=te.useState(!1),[L,H]=te.useState(null),F=Imo(),z=xP(De=>De.pushEvent),V=xP(De=>De.recentEvents),j=te.useMemo(()=>Date.now(),[]);v0o(De=>{if(!(new Date(De.created_at).valueOf()<j+500)){if(De.event_type==="FILE_UPDATED"){s(!0);return}if(De.event_type==="SNIPPET_SAVED"){s(!1),c(!1),g("Snippet saved successfully."),S(!1);return}De.event_type==="REQUEST_EXPORT"&&(w(!0),g("Export processing..."),S(!1)),De.event_type==="EXPORT_CREATED"&&(g(`Export created: ${De.exportFilePath}`),S(!1),w(!1))}}),te.useEffect(()=>{if(!l||_===null)return;const De=V.filter(xe=>new Date(xe.created_at).valueOf()>_),pe=De.find(xe=>xe.event_type==="FAILED_TO_SAVE_SNIPPET"),Ce=De.find(xe=>xe.event_type==="SNIPPET_SAVED");pe&&(u(!1),d(null),b(pe.message??"Failed to save snippet. See console for error."),console.error(pe.message),S(!0),pe.error_code==="SNIPPET_UNSET"&&pe.available_snippet_names&&(h(pe.available_snippet_names),x(!0))),Ce&&(u(!1),d(null),g("Snippet saved successfully."),S(!1))},[V,l]);const K=async()=>{u(!0),d(Date.now()),g(null),S(!1),await z({event_type:"REQUEST_TO_SAVE_SNIPPET",snippet_name:o})},oe=xP(De=>De.circuitJson)??t.circuitJson,[ue,ne]=te.useState(!1),[se,ae]=te.useState(!1),{BugReportDialog:ce,openBugReportDialog:fe}=Omo({onLoginRequired:t.onLoginRequired}),Se=async De=>{L&&(await hyt({circuitJson:L.circuitJson,projectName:L.projectName,options:De}),H(null))},we=te.useMemo(()=>$mo(t.autoroutingLog),[t.autoroutingLog]);return G.jsxs(G.Fragment,{children:[G.jsxs("div",{className:"rf-flex rf-items-center rf-gap-1 rf-flex-shrink-0",children:[G.jsxs(oK,{children:[G.jsx(rK,{asChild:!0,children:G.jsx("div",{className:"rf-whitespace-nowrap rf-text-xs font-medium rf-p-2 rf-mx-1 rf-cursor-pointer rf-relative",children:"File"})}),G.jsxs(XL,{className:"rf-z-[101]",children:[!t.isWebEmbedded&&G.jsxs(G.Fragment,{children:[G.jsx(Jd,{className:"rf-text-xs",onSelect:K,disabled:l,children:l?"Saving...":"Push"}),parseInt(window.location.port)>5e3&&G.jsx(Jd,{className:"rf-text-xs",onSelect:()=>{F.open()},children:"Order"}),G.jsx(Jd,{className:"rf-text-xs",onSelect:()=>ne(!0),disabled:l,children:"Import"}),G.jsx(Jd,{className:"rf-text-xs",onSelect:()=>{if(!IJ()){zs.error("Requires tscircuit token");return}ae(!0)},children:"AI Review"})]}),!t.isWebEmbedded&&t.onLoginRequired&&G.jsx(Jd,{className:"rf-text-xs",onSelect:()=>{t.onLoginRequired?.()},children:"Sign In"}),!t.isWebEmbedded&&G.jsxs(UL,{children:[G.jsx(EA,{className:"rf-text-xs",children:"Report Bug"}),G.jsx(WL,{children:G.jsxs(DA,{children:[G.jsx(Jd,{className:"rf-text-xs",onSelect:()=>{fe()},children:"Report Entire Circuit"}),G.jsx(Jd,{className:"rf-text-xs",disabled:!we||!t.onReportAutoroutingLog,onSelect:()=>{!we||!t.onReportAutoroutingLog||t.onReportAutoroutingLog(we.key,{simpleRouteJson:we.value.simpleRouteJson})},children:"Report Autorouter Bug"})]})})]}),G.jsxs(UL,{children:[G.jsx(EA,{className:"rf-text-xs",disabled:C,children:C?"Exporting...":"Export"}),G.jsx(WL,{children:G.jsx(DA,{children:Hdo.map((De,pe)=>G.jsx(Jd,{onSelect:()=>{if(!oe){zs.error("No Circuit JSON to export");return}let Ce="Untitled";if(n){const ze=n.split("/").pop();ze&&(Ce=ze.replace(/\.[^.]+$/,""))}const xe=t.projectName??o??Ce;if(De.name==="LightBurn"){H({circuitJson:oe,projectName:xe}),A(!0);return}Ldo({exportName:De.name,circuitJson:oe,projectName:xe?.replace(/\.(board|circuit)$/,"")})},disabled:C,children:G.jsx("span",{className:"rf-text-xs",children:De.name})},pe))})})]}),!t.isWebEmbedded&&G.jsxs(UL,{children:[G.jsx(EA,{className:"rf-text-xs",children:"Advanced"}),G.jsx(WL,{children:G.jsxs(DA,{children:[G.jsx(Jd,{className:"rf-flex rf-items-center rf-gap-2",children:G.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[G.jsx(WO,{id:"load-latest-eval",checked:t.shouldLoadLatestEval,onCheckedChange:De=>{t.onChangeShouldLoadLatestEval?.(De===!0)}}),G.jsx("label",{htmlFor:"load-latest-eval",className:"rf-text-xs rf-cursor-pointer",children:"Force Latest @tscircuit/eval"})]})}),e&&G.jsx(Jd,{className:"rf-flex rf-items-center rf-gap-2",children:G.jsx("div",{className:"rf-flex rf-items-center rf-gap-2",children:G.jsxs("span",{className:"rf-text-xs",children:["@tscircuit/eval@",e]})})}),G.jsx(Jd,{className:"rf-flex rf-items-center rf-gap-2",children:G.jsx("div",{className:"rf-flex rf-items-center rf-gap-2",children:G.jsxs("span",{className:"rf-text-xs",children:["@tscircuit/runframe@",m0o.version]})})}),G.jsx(Jd,{className:"rf-flex rf-items-center rf-gap-2",onClick:()=>{window.open("/api/admin","_blank")},children:G.jsx("div",{className:"rf-flex rf-items-center rf-gap-2",children:G.jsx("span",{className:"rf-text-xs",children:"CLI Admin Panel"})})})]})})]})]}),G.jsx(Fgt,{open:v,onOpenChange:S,children:G.jsxs(F4e,{children:[G.jsxs(B4e,{children:[G.jsx(V4e,{children:"Error Saving Snippet"}),G.jsx($4e,{children:y})]}),G.jsx(z4e,{children:G.jsx(W4e,{onClick:()=>S(!1),children:"Dismiss"})})]})}),G.jsx(P0o,{snippetNames:m??[],onSelect:async De=>{u(!0),d(Date.now()),r(De),await z({event_type:"REQUEST_TO_SAVE_SNIPPET",snippet_name:De}),x(!1)},onCancel:()=>x(!1),isOpen:p})]}),G.jsxs(oK,{children:[G.jsx(rK,{asChild:!0,children:G.jsx("div",{className:"rf-whitespace-nowrap rf-text-xs font-medium rf-p-2 rf-mx-1 rf-cursor-pointer rf-relative",children:"View"})}),G.jsx(XL,{className:"rf-z-[104]",children:G.jsxs(UL,{children:[G.jsx(EA,{className:"rf-text-xs",children:"Schematic"}),G.jsx(WL,{children:G.jsxs(DA,{children:[G.jsx(Jd,{className:"rf-flex rf-items-center rf-gap-2",onSelect:De=>De.preventDefault(),children:G.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[G.jsx(WO,{id:"show-schematic-ports",checked:t.showSchematicPorts,onCheckedChange:De=>{t.onChangeShowSchematicPorts?.(De===!0)}}),G.jsx("label",{htmlFor:"show-schematic-ports",className:"rf-text-xs rf-cursor-pointer",children:"Show Schematic Ports"})]})}),G.jsx(Jd,{className:"rf-flex rf-items-center rf-gap-2",onSelect:De=>De.preventDefault(),children:G.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[G.jsx(WO,{id:"show-schematic-grid",checked:t.showSchematicDebugGrid,onCheckedChange:De=>{t.onChangeShowSchematicDebugGrid?.(De===!0)}}),G.jsx("label",{htmlFor:"show-schematic-grid",className:"rf-text-xs rf-cursor-pointer",children:"Show Schematic Grid"})]})})]})})]})})]})]}),ce,G.jsx(Fmo,{open:D,onOpenChange:A,onExport:Se}),G.jsx(uyt,{isOpen:ue,onClose:()=>ne(!1)}),G.jsx(Uho,{isOpen:se,onClose:()=>ae(!1),packageName:o}),G.jsx(rct,{position:"top-center",reverseOrder:!1,containerStyle:{zIndex:1e5},toastOptions:{className:"rf-break-all",style:{zIndex:1e5}}}),G.jsx(F.OrderDialog,{isOpen:F.isOpen,onClose:F.close,stage:F.stage,setStage:F.setStage})]})},Umo=["assembly","pinout","analog_simulation","bom","circuit_json","errors","render_log","solvers"],Xmo=({code:t,fsMap:e,onRunClicked:n=void 0,errorMessage:o,errorStack:r,circuitJson:i,autoroutingGraphics:s,showRightHeaderContent:a=!0,showCodeTab:c=!1,codeTabContent:l,showJsonTab:u=!0,showRenderLogTab:_=!0,onActiveTabChange:d,renderLog:m,showImportAndFormatButtons:h=!0,className:p,headerClassName:x,leftHeaderContent:f,readOnly:g,isStreaming:y,autoroutingLog:b,onReportAutoroutingLog:v,isRunningCode:S,hasCodeChangedSinceLastRun:C,onEditEvent:w,editEvents:D,defaultActiveTab:A,defaultTab:L,availableTabs:H,autoRotate3dViewerDisabled:F,showSchematicDebugGrid:z=!1,showSchematicPorts:V=!1,onChangeShowSchematicDebugGrid:j,onChangeShowSchematicPorts:K,showToggleFullScreen:J=!0,defaultToFullScreen:oe=!1,activeEffectName:ue,allowSelectingVersion:ne=!0,showFileMenu:se=!1,isWebEmbedded:ae=!1,projectName:ce,onRerunWithDebug:fe,solverEvents:Se,onPcbBoundsSelected:we})=>{Fxt();const{versions:De,latestVersion:pe,lastRunEvalVersion:Ce,search:xe,setSearch:ze,selectVersion:We}=f0o(ne),Ye=te.useMemo(()=>i?i.filter(kt=>kt&&"error_type"in kt||kt.type.includes("error")):null,[i]),ye=te.useMemo(()=>i?i.filter(kt=>kt&&"warning_type"in kt||kt.type.includes("warning")):null,[i]),Je=te.useMemo(()=>i?i.some(kt=>kt.type==="schematic_group"):!0,[i]),Be=te.useMemo(()=>i?.some(kt=>kt.type==="pcb_panel"),[i]);qxt({errorMessage:o,errorStack:r,circuitJsonErrors:Ye});const ke=L??H?.[0]??"pcb",[Ve,He]=Bxt("runframe-active-tab",A??ke,A),[Te,Ae]=te.useState(null),[Ee,$e]=te.useState(oe),[Ue,nt]=te.useState(z),[rt,st]=te.useState(V),ut=j?z:Ue,xt=K?V:rt,Et=j??nt,Bt=K??st;Dlo(Ee);const Gt=te.useCallback(kt=>{He(kt),d?.(kt)},[d,He]),Ft=()=>{$e(!Ee)};te.useEffect(()=>{o&&(Ve!=="errors"&&Ae(Ve),Gt("errors"))},[o]),te.useEffect(()=>{(Ve==="code"||Ve==="errors")&&i&&!o&&Gt(Te??A??L??H?.[0]??"pcb")},[i]);const ln=te.useCallback(kt=>{window.TSCIRCUIT_3D_OBJECT_REF=kt===null?void 0:kt},[]);return G.jsx("div",{className:Ei("flex flex-col relative rf-overflow-x-hidden rf-h-full",p),children:G.jsx("div",{className:Ei("rf-md:sticky rf-md:top-2 rf-h-full",Ee&&"rf-fixed rf-top-0 rf-left-0 rf-w-full rf-h-full rf-bg-white rf-overflow-hidden"),children:G.jsxs(oee,{value:Ve,onValueChange:Gt,className:"rf-flex-grow rf-flex rf-flex-col rf-h-full",children:[G.jsxs("div",{className:Ei("rf-flex rf-items-center rf-gap-2 rf-p-2 rf-pb-0",x),children:[f,se&&!f&&G.jsx(Wmo,{isWebEmbedded:ae,circuitJson:i,projectName:ce,autoroutingLog:b,onReportAutoroutingLog:v,showSchematicDebugGrid:ut,onChangeShowSchematicDebugGrid:Et,showSchematicPorts:xt,onChangeShowSchematicPorts:Bt}),(f||se)&&G.jsx("div",{className:"rf-flex-grow"}),!f&&!se&&S&&G.jsx(H9,{className:"rf-w-4 rf-h-4 rf-animate-spin"}),!f&&!se&&G.jsx("div",{className:"rf-flex-grow"}),m&&m.progress!==1&&!o&&G.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2 rf-min-w-0 rf-max-w-xs",children:[ue?G.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate rf-min-w-0",title:ue,children:ue}):m.lastRenderEvent&&G.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate rf-min-w-0",title:m.lastRenderEvent?.phase??"",children:m.lastRenderEvent?.phase??""}),G.jsx("div",{className:"rf-w-4 rf-h-4 rf-bg-blue-500 rf-opacity-50 rf-rounded-full rf-text-white rf-flex-shrink-0",children:G.jsx(H9,{className:"rf-w-4 rf-h-4 rf-animate-spin"})}),G.jsxs("div",{className:"rf-text-xs rf-font-bold rf-text-gray-700 rf-tabular-nums rf-flex-shrink-0",children:[((m.progress??0)*100).toFixed(1),"%"]})]}),a&&G.jsxs(CB,{children:[c&&G.jsx(Yb,{value:"code",children:"Code"}),!H||H.includes("pcb")?G.jsxs(Yb,{value:"pcb",className:"rf-whitespace-nowrap",children:[i&&G.jsx("span",{className:Ei("rf-inline-flex rf-items-center rf-justify-center rf-w-2 rf-h-2 rf-mr-1 rf-text-xs rf-font-bold rf-text-white rf-rounded-full",C?"rf-bg-gray-500":"rf-bg-blue-500")}),"PCB"]}):null,!H||H.includes("schematic")?G.jsxs(Yb,{value:"schematic",className:Ei("rf-whitespace-nowrap",i&&!Je&&"rf-opacity-50"),disabled:i?!Je||Be:!1,children:[i&&G.jsx("span",{className:Ei("rf-inline-flex rf-items-center rf-justify-center rf-w-2 rf-h-2 rf-mr-1 rf-text-xs rf-font-bold rf-text-white rf-rounded-full",C?"rf-bg-gray-500":"rf-bg-blue-500")}),"Schematic"]}):null,!H||H.includes("cad")?G.jsxs(Yb,{value:"cad",children:[i&&G.jsx("span",{className:Ei("inline-flex items-center justify-center w-2 h-2 mr-1 text-xs font-bold text-white rounded-full",C?"rf-bg-gray-500":"rf-bg-blue-500")}),"3D"]}):null,!["pcb","cad","schematic"].includes(Ve)&&G.jsx(Yb,{value:Ve,children:F9e(Ve)}),G.jsxs(oK,{children:[G.jsx(rK,{asChild:!0,children:G.jsxs("div",{className:"rf-whitespace-nowrap rf-p-2 rf-mr-1 rf-cursor-pointer rf-relative",children:[G.jsx(OUn,{className:"rf-w-4 rf-h-4"}),(Ye&&Ye.length>0||o)&&G.jsx("span",{className:"rf-inline-flex rf-absolute rf-top-[6px] rf-right-[4px] rf-items-center rf-justify-center rf-w-1 rf-h-1 rf-ml-2 rf-text-[8px] rf-font-bold rf-text-white rf-bg-red-500 rf-rounded-full"})]})}),G.jsxs(XL,{className:"rf-*:text-xs rf-z-[101]",children:[Umo.filter(kt=>!H||H.includes(kt)).map(kt=>G.jsxs(Jd,{onSelect:()=>Gt(kt),children:[Ve!==kt&&G.jsx(udt,{className:"rf-w-3 rf-h-3 rf-opacity-30"}),Ve===kt&&G.jsx(Y5e,{className:"rf-w-3 rf-h-3"}),G.jsx("div",{className:"rf-pr-2",children:F9e(kt)}),kt==="errors"&&(Ye&&Ye.length>0||o)&&G.jsx("span",{className:"rf-inline-flex rf-items-center rf-justify-center rf-w-3 rf-h-3 rf-ml-2 rf-text-[8px] rf-font-bold rf-text-white rf-bg-red-500 rf-rounded-full",children:o?1:Ye?.length}),kt==="solvers"&&Se&&Se.length>0&&G.jsx("span",{className:"rf-inline-flex rf-items-center rf-justify-center rf-min-w-[12px] rf-h-3 rf-px-1 rf-ml-2 rf-text-[8px] rf-font-bold rf-text-white rf-bg-blue-500 rf-rounded-full",children:Se.length})]},kt)),G.jsx(Jd,{disabled:!0,className:"rf-opacity-60 rf-cursor-default rf-select-none",children:G.jsxs("div",{className:"rf-pr-2 rf-text-xs rf-text-gray-500",children:["@tscircuit/runframe@",Kxt.split(".").map((kt,bn)=>bn===2?parseInt(kt)+1:kt).join(".")]})}),ne?G.jsxs(UL,{onOpenChange:kt=>!kt&&ze(""),children:[G.jsx(EA,{className:"rf-text-xs rf-opacity-60",children:G.jsxs("div",{className:"rf-pr-2 rf-text-xs rf-text-gray-500",children:["@tscircuit/eval@",Ce??pe??"latest"]})}),G.jsx(WL,{children:G.jsxs(DA,{className:"rf-*:text-xs rf-w-40 rf-max-h-[200px] rf-overflow-y-auto",children:[G.jsx("div",{className:"rf-p-1",children:G.jsx(Dbe,{value:xe,onChange:kt=>ze(kt.target.value),placeholder:"Search...",className:"rf-h-7 rf-text-xs"})}),G.jsx(pmt,{}),G.jsx(Jd,{onSelect:()=>We(null),children:pe?`${pe} (latest)`:"latest"}),De.map(kt=>G.jsx(Jd,{onSelect:()=>We(kt),children:kt},kt))]})})]}):Ce&&G.jsx(Jd,{disabled:!0,className:"rf-opacity-60 rf-cursor-default rf-select-none",children:G.jsxs("div",{className:"rf-pr-2 rf-text-xs rf-text-gray-500",children:["@tscircuit/eval@",Ce]})})]})]})]}),J&&G.jsx(Yu,{onClick:Ft,variant:"ghost",children:Ee?G.jsx(WUn,{size:16}):G.jsx(BUn,{size:16})})]}),c&&G.jsx(k1,{value:"code",className:"rf-flex-grow rf-overflow-hidden",children:G.jsx("div",{className:"rf-h-full",children:l})}),(!H||H.includes("pcb"))&&G.jsx(k1,{value:"pcb",children:G.jsx("div",{className:Ei("rf-overflow-hidden",Ee?"rf-h-[calc(100vh-52px)]":"rf-h-full"),children:G.jsx(Q4,{fallbackRender:({error:kt})=>G.jsx("div",{className:"rf-mt-4 rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200",children:G.jsxs("div",{className:"rf-p-4",children:[G.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-3",children:"Error loading PCB viewer"}),G.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-red-600 rf-mt-2",children:kt?.message||"An unknown error occurred"})]})}),children:i?G.jsx(wlo,{focusOnHover:!1,circuitJson:i,debugGraphics:s,onBoundsSelected:we,containerClassName:Ei("rf-h-full rf-w-full",Ee?"rf-min-h-[calc(100vh-240px)]":"rf-min-h-[620px]"),onEditEventsChanged:kt=>{if(w)for(const bn of kt)w(bn)}}):G.jsx(J6,{onRunClicked:n})})})}),(!H||H.includes("assembly"))&&G.jsx(k1,{value:"assembly",children:G.jsx("div",{className:Ei("rf-overflow-auto",Ee?"rf-h-[calc(100vh-60px)]":"rf-h-full rf-min-h-[620px]"),children:G.jsx(Q4,{fallback:G.jsx("div",{children:"Error loading Assembly"}),children:i?G.jsx(Jno,{circuitJson:i,containerStyle:{height:"100%"},editingEnabled:!0,debugGrid:!0}):G.jsx(J6,{onRunClicked:n})})})}),(!H||H.includes("pinout"))&&G.jsx(k1,{value:"pinout",children:G.jsx("div",{className:Ei("rf-overflow-auto",Ee?"rf-h-[calc(100vh-60px)]":"rf-h-full rf-min-h-[620px]"),children:G.jsx(Q4,{fallback:G.jsx("div",{children:"Error loading Pinout Viewer"}),children:i?G.jsx(Qno,{circuitJson:i,containerStyle:{height:"100%"}}):G.jsx(J6,{onRunClicked:n})})})}),(!H||H.includes("schematic"))&&G.jsx(k1,{value:"schematic",children:G.jsx("div",{className:Ei("rf-overflow-auto rf-bg-white",Ee?"rf-h-[calc(100vh-60px)]":"rf-h-full rf-min-h-[620px]"),children:G.jsx(Q4,{fallbackRender:({error:kt})=>G.jsx("div",{className:"rf-mt-4 rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200",children:G.jsxs("div",{className:"rf-p-4",children:[G.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-3",children:"Error loading Schematic"}),G.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-red-600 rf-mt-2",children:kt?.message||"An unknown error occurred"})]})}),children:i?G.jsx(qno,{spiceSimulationEnabled:!0,circuitJson:i,containerStyle:{height:"100%"},editingEnabled:!0,onEditEvent:kt=>{w?.(kt)},debugGrid:ut,showSchematicPorts:xt}):G.jsx(J6,{onRunClicked:n})})})}),(!H||H.includes("cad"))&&G.jsx(k1,{value:"cad",children:G.jsx("div",{className:Ei("rf-overflow-auto",Ee?"rf-h-[calc(100vh-60px)]":"rf-h-full rf-min-h-[620px]"),children:G.jsx(Q4,{fallbackRender:({error:kt,resetErrorBoundary:bn})=>G.jsx(vUn,{error:kt,resetErrorBoundary:bn}),children:i?G.jsx(_Un,{ref:ln,circuitJson:i,autoRotateDisabled:F},`cad-${Ee}`):G.jsx(J6,{onRunClicked:n})})})}),(!H||H.includes("analog_simulation"))&&G.jsx(k1,{value:"analog_simulation",children:G.jsx("div",{className:Ei("rf-overflow-auto",Ee?"rf-h-[calc(100vh-60px)]":"rf-h-full rf-min-h-[620px]"),children:G.jsx(Q4,{fallback:G.jsx("div",{children:"Error loading Analog Simulation"}),children:i?G.jsx(Kno,{circuitJson:i,containerStyle:{height:"100%"}}):G.jsx(J6,{onRunClicked:n})})})}),(!H||H.includes("bom"))&&G.jsx(k1,{value:"bom",children:G.jsx("div",{className:Ei("rf-overflow-auto",Ee?"rf-h-[calc(100vh-60px)]":"rf-h-full rf-min-h-[620px]"),children:G.jsx(Q4,{fallbackRender:({error:kt})=>G.jsx("div",{className:"rf-mt-4 rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200",children:G.jsxs("div",{className:"rf-p-4",children:[G.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-3",children:"Error loading Bill of Materials"}),G.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-red-600 rf-mt-2",children:kt?.message||"An unknown error occurred"})]})}),children:i?G.jsx(moo,{circuitJson:i}):G.jsx(J6,{onRunClicked:n})})})}),(!H||H.includes("circuit_json"))&&G.jsx(k1,{value:"circuit_json",children:G.jsx("div",{className:Ei("rf-overflow-auto",Ee?"rf-h-[calc(100vh-60px)]":"rf-h-full rf-min-h-[620px]"),children:G.jsx(Q4,{fallback:G.jsx("div",{children:"Error loading JSON viewer"}),children:i?G.jsx(too,{elements:i}):G.jsx(J6,{onRunClicked:n})})})}),(!H||H.includes("errors"))&&G.jsx(k1,{value:"errors",className:"rf-h-full",children:G.jsx("div",{className:Ei("rf-overflow-hidden",Ee?"rf-h-[calc(100vh-60px)]":"rf-h-full rf-min-h-[620px]"),children:o||Ye&&Ye.length>0||i?G.jsx(VYn,{code:t,fsMap:e,circuitJsonErrors:Ye,circuitJsonWarnings:ye,errorMessage:o,errorStack:r,circuitJson:i,evalVersion:Ce,autoroutingLog:b,onReportAutoroutingLog:v}):G.jsx(J6,{onRunClicked:n})})}),_&&(!H||H.includes("render_log"))&&G.jsx(k1,{value:"render_log",children:G.jsx(Rlo,{renderLog:m,onRerunWithDebug:fe})}),(!H||H.includes("solvers"))&&G.jsx(k1,{value:"solvers",children:G.jsx("div",{className:Ei("rf-overflow-hidden",Ee?"rf-h-[calc(100vh-60px)]":"rf-h-full rf-min-h-[620px]"),children:G.jsx(Q4,{fallback:G.jsx("div",{children:"Error loading Solvers view"}),children:G.jsx(h0o,{solverEvents:Se})})})})]})})})};ubt.createRoot(document.getElementById("root")).render(G.jsx("div",{style:{height:"100vh"},children:G.jsx(Xmo,{defaultActiveTab:"cad",autoRotate3dViewerDisabled:!0,showRightHeaderContent:!1,circuitJson:window.CIRCUIT_JSON||{},...window.CIRCUIT_JSON_PREVIEW_PROPS||{}})}))}));