@tscircuit/runframe 0.0.2432 → 0.0.2433
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.
- package/dist/{chunk-A6GEADL4.js → chunk-A2GTHBKR.js} +1 -1
- package/dist/preview.js +1 -1
- package/dist/runner.d.ts +4 -0
- package/dist/runner.js +12 -18
- package/dist/standalone-preview.min.js +1 -1
- package/dist/standalone.min.js +205 -205
- package/package.json +1 -1
package/dist/preview.js
CHANGED
package/dist/runner.d.ts
CHANGED
|
@@ -129,6 +129,8 @@ interface RunFrameProps {
|
|
|
129
129
|
evalWebWorkerBlobUrl?: string;
|
|
130
130
|
evalVersion?: string;
|
|
131
131
|
forceLatestEvalVersion?: boolean;
|
|
132
|
+
shouldLoadLatestEval?: boolean;
|
|
133
|
+
onChangeShouldLoadLatestEval?: (shouldLoadLatestEval: boolean) => void;
|
|
132
134
|
/**
|
|
133
135
|
* Optional project URL whose pathname will be used when
|
|
134
136
|
* reporting autorouting bugs
|
|
@@ -187,6 +189,8 @@ interface RunFrameWithApiProps {
|
|
|
187
189
|
forceLatestEvalVersion?: boolean;
|
|
188
190
|
debug?: boolean;
|
|
189
191
|
leftHeaderContent?: React.ReactNode;
|
|
192
|
+
shouldLoadLatestEval?: boolean;
|
|
193
|
+
onChangeShouldLoadLatestEval?: (shouldLoadLatestEval: boolean) => void;
|
|
190
194
|
defaultToFullScreen?: boolean;
|
|
191
195
|
showToggleFullScreen?: boolean;
|
|
192
196
|
showFilesSwitch?: boolean;
|
package/dist/runner.js
CHANGED
|
@@ -39,7 +39,7 @@ import {
|
|
|
39
39
|
useRunFrameStore,
|
|
40
40
|
useRunnerStore,
|
|
41
41
|
useStyles
|
|
42
|
-
} from "./chunk-
|
|
42
|
+
} from "./chunk-A2GTHBKR.js";
|
|
43
43
|
|
|
44
44
|
// lib/components/RunFrame/RunFrame.tsx
|
|
45
45
|
import { createCircuitWebWorker } from "@tscircuit/eval/worker";
|
|
@@ -863,7 +863,9 @@ var RunFrame = (props) => {
|
|
|
863
863
|
showSchematicPorts,
|
|
864
864
|
onChangeShowSchematicPorts: setShowSchematicPorts,
|
|
865
865
|
autoroutingLog,
|
|
866
|
-
onReportAutoroutingLog: props.onReportAutoroutingLog || handleReportAutoroutingLog
|
|
866
|
+
onReportAutoroutingLog: props.onReportAutoroutingLog || handleReportAutoroutingLog,
|
|
867
|
+
shouldLoadLatestEval: props.shouldLoadLatestEval,
|
|
868
|
+
onChangeShouldLoadLatestEval: props.onChangeShouldLoadLatestEval
|
|
867
869
|
}
|
|
868
870
|
),
|
|
869
871
|
props.leftHeaderContent
|
|
@@ -1956,6 +1958,8 @@ var RunFrameWithApi = (props) => {
|
|
|
1956
1958
|
{
|
|
1957
1959
|
fsMap,
|
|
1958
1960
|
showFileMenu: props.showFileMenu,
|
|
1961
|
+
shouldLoadLatestEval: props.shouldLoadLatestEval,
|
|
1962
|
+
onChangeShouldLoadLatestEval: props.onChangeShouldLoadLatestEval,
|
|
1959
1963
|
isCli: props.isCli,
|
|
1960
1964
|
schematicSvgOptions: props.schematicSvgOptions,
|
|
1961
1965
|
isLoadingFiles,
|
|
@@ -2301,26 +2305,16 @@ var RunFrameForCli = (props) => {
|
|
|
2301
2305
|
platformConfig,
|
|
2302
2306
|
isCli: true,
|
|
2303
2307
|
showFilesSwitch: true,
|
|
2304
|
-
showFileMenu: false,
|
|
2305
2308
|
enableFetchProxy: props.enableFetchProxy,
|
|
2306
2309
|
initialMainComponentPath,
|
|
2307
2310
|
onLoginRequired: openLoginDialog,
|
|
2308
2311
|
onMainComponentPathChange: updateMainComponentHash,
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
onChangeShouldLoadLatestEval: (newShouldLoadLatestEval) => {
|
|
2316
|
-
setLoadLatestEval(newShouldLoadLatestEval);
|
|
2317
|
-
globalThis.runFrameWorker = null;
|
|
2318
|
-
},
|
|
2319
|
-
onLoginRequired: openLoginDialog
|
|
2320
|
-
}
|
|
2321
|
-
),
|
|
2322
|
-
props.scenarioSelectorContent
|
|
2323
|
-
] })
|
|
2312
|
+
shouldLoadLatestEval: !evalWebWorkerBlobUrl && shouldLoadLatestEval,
|
|
2313
|
+
onChangeShouldLoadLatestEval: (newShouldLoadLatestEval) => {
|
|
2314
|
+
setLoadLatestEval(newShouldLoadLatestEval);
|
|
2315
|
+
globalThis.runFrameWorker = null;
|
|
2316
|
+
},
|
|
2317
|
+
leftHeaderContent: /* @__PURE__ */ jsx9("div", { className: "rf-flex rf-items-center rf-justify-between", children: props.scenarioSelectorContent })
|
|
2324
2318
|
}
|
|
2325
2319
|
)
|
|
2326
2320
|
] });
|
|
@@ -5793,7 +5793,7 @@ test("${c} should solve problem correctly", () => {
|
|
|
5793
5793
|
// Add more specific assertions based on expected output
|
|
5794
5794
|
// expect(solver.netLabelPlacementSolver!.netLabelPlacements).toMatchInlineSnapshot()
|
|
5795
5795
|
})
|
|
5796
|
-
`,g=new Blob([l],{type:"text/plain"}),u=URL.createObjectURL(g),d=document.createElement("a");d.href=u,d.download=`${c}.test.ts`,d.click(),URL.revokeObjectURL(u)}catch(A){alert(`Error generating test.ts for ${t.constructor.name}: ${A instanceof Error?A.message:String(A)}`)}o(!1)};return j.jsxs("div",{className:`relative ${e}`,ref:i,children:[j.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&&j.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:[j.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download JSON"}),j.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),j.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:a,children:"Download test.ts"})]})]})},YHt=t=>t.activeSubSolver?[t,...YHt(t.activeSubSolver)]:[t],Sqo=({solver:t})=>{const e=YHt(t);return j.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:e.map((n,o)=>j.jsxs("div",{className:"flex items-center",children:[o>0&&j.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),j.jsx(Qqo,{solver:n})]},n.constructor.name))})},bqo=({solver:t,triggerRender:e,animationSpeed:n=25,onSolverStarted:o,onSolverCompleted:i})=>{const[r,s]=ne.useReducer(_=>!_,!1),a=ne.useRef(void 0),A=()=>{!t.solved&&!t.failed&&(t.step(),e())},c=()=>{!t.solved&&!t.failed&&(o&&o(t),t.solve(),e(),i&&i(t))},l=()=>{r?(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(),i&&t.solved&&i(t);return}t.step(),e()},n))},g=()=>{const _=t;if(_.getCurrentPhase&&!t.solved&&!t.failed){const m=_.getCurrentPhase();for(;_.getCurrentPhase()===m&&!t.solved&&!t.failed;)t.step();e()}},u=()=>{if(t.solved||t.failed||r)return;const _=window.prompt("Step until which iteration?",`${t.iterations}`);if(_===null)return;const m=Number(_);if(!Number.isFinite(m)){window.alert("Please enter a valid number for the iteration");return}for(;t.iterations<m&&!t.solved&&!t.failed;)t.step();e(),t.solved&&i&&i(t)};ne.useEffect(()=>()=>{a.current&&clearInterval(a.current)},[]),ne.useEffect(()=>{(t.solved||t.failed)&&r&&(a.current&&(clearInterval(a.current),a.current=void 0),s())},[t.solved,t.failed,r]);const d=t.getCurrentPhase!==void 0,h=d?t.getCurrentPhase():null;return j.jsxs("div",{className:"space-y-2 p-2 border-b",children:[j.jsx("div",{className:"flex items-center",children:j.jsx(Sqo,{solver:t})}),j.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[j.jsx("button",{onClick:A,disabled:t.solved||t.failed||r,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),j.jsx("button",{onClick:c,disabled:t.solved||t.failed||r,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),j.jsx("button",{onClick:l,disabled:t.solved||t.failed,className:`px-3 py-1 rounded text-white text-sm ${r?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:r?"Stop":"Animate"}),j.jsx("button",{onClick:u,disabled:t.solved||t.failed||r,className:"bg-orange-500 hover:bg-orange-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step Until Iteration"}),d&&j.jsx("button",{onClick:g,disabled:t.solved||t.failed||r,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),j.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&j.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),h&&j.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",j.jsx("span",{className:"font-medium",children:h})]}),t.solved&&j.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&j.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&j.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},Dqo=(t,e,n)=>{const o=t.currentPipelineStepIndex;return e<o?"Completed":e===o&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},Pqo=(t,e)=>{const o=t.pipelineDef[e].solverName,i=Dqo(t,e),r=t[o],s=t.firstIterationOfPhase?.[o]??null,a=t.iterations;let A=0;if(i==="Completed"){const u=t.pipelineDef[e+1],d=u?t.firstIterationOfPhase?.[u.solverName]:void 0;d!==void 0&&s!==null?A=d-s:s!==null&&(A=a-s)}else i==="In Progress"&&s!==null&&(A=a-s);const c=t.timeSpentOnPhase?.[o]??0;let l=0;i==="Completed"?l=1:i==="In Progress"&&r&&(l=r.progress??0);const g=r?.stats??null;return{index:e,name:o,status:i,firstIteration:s,iterations:A,progress:l,timeSpent:c,stats:g&&Object.keys(g).length>0?g:null,solverInstance:r??null}},vqo=({status:t})=>{const e={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return j.jsx("span",{className:`font-medium ${e[t]}`,children:t})},Mqo=({progress:t})=>{if(t===0)return null;const e=Math.round(t*100);return j.jsxs("div",{className:"flex items-center gap-2",children:[j.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:j.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${e}%`}})}),j.jsxs("span",{className:"text-xs text-gray-500",children:[e,"%"]})]})},wqo=t=>Object.entries(t).map(([e,n])=>`${e}: ${n}`).join(", "),Nqo=({stats:t})=>{if(!t||Object.keys(t).length===0)return j.jsx("span",{children:"-"});const e=Object.entries(t),n=wqo(t);return j.jsxs("details",{className:"cursor-pointer",children:[j.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:n}),j.jsx("div",{className:"mt-1 text-xs",children:e.map(([o,i])=>j.jsxs("div",{children:[o,": ",String(i)]},o))})]})},M9e=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(M9e);const e={};for(const[n,o]of Object.entries(t))n.startsWith("_")||(e[n]=M9e(o));return e},Rqo=(t,e)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${e}`);return}const n=M9e(t.getConstructorParams()),o=new Blob([JSON.stringify(n,null,2)],{type:"application/json"}),i=URL.createObjectURL(o),r=document.createElement("a");r.href=i,r.download=`${e}_input.json`,r.click(),URL.revokeObjectURL(i)}catch(n){alert(`Error downloading input for ${e}: ${n instanceof Error?n.message:String(n)}`)}},Tqo=({solver:t,onStepUntilPhase:e,onDownloadInput:n})=>{const o=t.pipelineDef.map((a,A)=>Pqo(t,A)),i=a=>{e?.(a)},r=a=>{a.solverInstance&&(n?n(a.solverInstance,a.name):Rqo(a.solverInstance,a.name))},s=a=>`${(a/1e3).toFixed(2)}s`;return j.jsxs("div",{className:"border-t border-gray-200",children:[j.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:j.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),j.jsx("div",{className:"overflow-x-auto",children:j.jsxs("table",{className:"w-full text-sm",children:[j.jsx("thead",{children:j.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[j.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),j.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),j.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",j.jsx("sub",{children:"0"})]}),j.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),j.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),j.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),j.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),j.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),j.jsx("tbody",{children:o.map(a=>j.jsxs("tr",{className:`border-b border-gray-100 ${a.status==="In Progress"?"bg-yellow-50":""}`,children:[j.jsx("td",{className:"px-4 py-2",children:j.jsxs("div",{className:"flex items-center gap-2",children:[j.jsx("span",{className:"text-gray-400 w-6",children:String(a.index+1).padStart(2,"0")}),j.jsx("button",{onClick:()=>i(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:j.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:j.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"})})}),j.jsx("span",{className:"font-medium text-gray-900",children:a.name})]})}),j.jsx("td",{className:"px-4 py-2",children:j.jsx(vqo,{status:a.status})}),j.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:a.firstIteration!==null?a.firstIteration:""}),j.jsx("td",{className:"px-4 py-2 text-gray-600",children:a.iterations}),j.jsx("td",{className:"px-4 py-2",children:j.jsx(Mqo,{progress:a.progress})}),j.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(a.timeSpent)}),j.jsx("td",{className:"px-4 py-2 text-gray-500",children:j.jsx(Nqo,{stats:a.stats})}),j.jsx("td",{className:"px-4 py-2",children:a.solverInstance?j.jsxs("button",{onClick:()=>r(a),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${a.name}`,children:[j.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:j.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"})}),j.jsx("span",{children:"Input"})]}):null})]},a.name))})]})})]})},kqo=class extends Xr.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t){console.error("InteractiveGraphics render error:",t)}render(){return this.state.hasError?this.props.fallback:this.props.children}};function Fqo({graphics:t}){const e=t.points??[],n=t.lines??[],o=t.rects??[],i=t.circles??[],r=t.texts??[];let s=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,A=Number.NEGATIVE_INFINITY,c=Number.NEGATIVE_INFINITY;const l=(m,p)=>{typeof m=="number"&&(m<s&&(s=m),m>A&&(A=m)),typeof p=="number"&&(p<a&&(a=p),p>c&&(c=p))};for(const m of e)l(m.x,m.y);for(const m of n){const p=m.points??[];for(const I of p)l(I.x,I.y)}for(const m of o){const p=m.x??0,I=m.y??0,f=m.width??0,C=m.height??0;l(p,I),l(p+f,I+C)}for(const m of i){const p=m.x??0,I=m.y??0,f=m.radius??1;l(p-f,I-f),l(p+f,I+f)}for(const m of r)l(m.x,m.y);(!isFinite(s)||!isFinite(a)||!isFinite(A)||!isFinite(c))&&(s=-20,a=-20,A=20,c=20);const g=10,u=s-g,d=a-g,h=Math.max(1,A-s+2*g),_=Math.max(1,c-a+2*g);return j.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${u} ${d} ${h} ${_}`,role:"img","aria-label":"Graphics fallback",children:[o.map((m,p)=>j.jsx("rect",{x:m.x??0,y:m.y??0,width:m.width??0,height:m.height??0,fill:"none",stroke:m.strokeColor??"black",strokeWidth:m.strokeWidth??1},`rect-${p}`)),n.map((m,p)=>j.jsx("polyline",{fill:"none",stroke:m.strokeColor??"black",strokeWidth:m.strokeWidth??1,points:(m.points??[]).map(I=>`${I.x??0},${I.y??0}`).join(" ")},`line-${p}`)),i.map((m,p)=>j.jsx("circle",{cx:m.x??0,cy:m.y??0,r:m.radius??1.5,fill:m.fillColor??"none",stroke:m.strokeColor??"black",strokeWidth:m.strokeWidth??1},`circle-${p}`)),e.map((m,p)=>j.jsx("circle",{cx:m.x??0,cy:m.y??0,r:m.radius??1.5,fill:m.color??"black"},`point-${p}`)),r.map((m,p)=>j.jsx("text",{x:m.x??0,y:m.y??0,fontSize:m.fontSize??10,fill:m.color??"black",children:m.text??""},`text-${p}`))]})}var Lqo=({solver:t,animationSpeed:e=25,onSolverStarted:n,onSolverCompleted:o})=>{const[i,r]=ne.useReducer(l=>l+1,0),s=ne.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(l){return console.error("Visualization error:",l),{points:[],lines:[],rects:[],circles:[]}}},[t,i]),a=ne.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);ne.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const l=document.createElement("script");l.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(l)}},[]);const A=t.pipelineDef!==void 0,c=l=>{const g=t;if(!t.solved&&!t.failed){for(;!t.solved&&!t.failed&&g.currentPipelineStepIndex<=g.pipelineDef.findIndex(u=>u.solverName===l);)t.step();r()}};return j.jsxs("div",{children:[j.jsx(bqo,{solver:t,triggerRender:r,animationSpeed:e,onSolverStarted:n,onSolverCompleted:o}),a?j.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):j.jsx(kqo,{fallback:j.jsx(Fqo,{graphics:s}),children:j.jsx(Bqo,{graphics:s})}),A&&j.jsx(Tqo,{solver:t,onStepUntilPhase:c})]})};const Hqo=()=>{ne.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)},[])},Gqo=1e3,ub=(t,e)=>{const{fileName:n,mimeType:o="text/plain"}=e,i=t instanceof Blob?t:new Blob([t],{type:o}),r=URL.createObjectURL(i),s=document.createElement("a");s.href=r,s.download=n,s.target="_blank",s.rel="noopener noreferrer",s.style.display="none",document.body.appendChild(s),s.click(),document.body.removeChild(s),setTimeout(()=>{URL.revokeObjectURL(r)},Gqo)},zHt=t=>{let e=t.trim().replace(/[\\/:*?"<>|]/g,"_").replace(/[\x00-\x1f]/g,"").replace(/^\.+/,"").replace(/\.+$/,"").replace(/\s+/g," ").replace(/_+/g,"_");return/^(con|prn|aux|nul|com[0-9]|lpt[0-9])$/i.test(e)&&(e=`_${e}`),e=e.slice(0,200),e||"untitled"},hb="https://github.com/tscircuit/tscircuit-autorouter/issues/new",VHt="https://github.com/tscircuit/copper-pour-solver/issues/new",JHt="https://github.com/tscircuit/calculate-packing/issues/new",Oqo="https://github.com/tscircuit/matchpack/issues/new",qHt="https://github.com/tscircuit/schematic-trace-solver/issues/new?template=json-bug-report.yml",Kqo={PackSolver2:JHt,LayoutPipelineSolver:Oqo,AutoroutingPipelineSolver:hb,AssignableAutoroutingPipeline2:hb,AssignableAutoroutingPipeline3:hb,AutoroutingPipeline1_OriginalUnravel:hb,AutoroutingPipelineSolver3_HgPortPointPathing:hb,AutoroutingPipelineSolver4:hb,AutoroutingPipelineSolver5:hb,AutoroutingPipelineSolver7_MultiGraph:hb,AutoroutingPipelineSolver8:hb,CopperPourPipelineSolver:VHt,SchematicTracePipelineSolver:qHt},Uqo=t=>t.toLowerCase().includes("pack")?hTo:t.toLowerCase().includes("rout")?CTo:sTo,WHt=t=>{const e=Kqo[t];if(e)return e;const n=t.toLowerCase();return n.includes("autorout")?hb:n.includes("schematic")&&n.includes("trace")?qHt:n.includes("copperpour")?VHt:n.includes("pack")?JHt:null},Yqo=t=>`${zHt(`${t.componentName}-${t.solverName}`)}-solver-input.json`,jHt=t=>{ub(JSON.stringify(t.solverParams,null,2),{fileName:Yqo(t),mimeType:"application/json"})},zqo=({solverEvent:t})=>{const e=WHt(t.solverName);return j.jsxs("div",{className:"rf-flex rf-items-center rf-justify-end rf-gap-2 rf-border-b rf-border-gray-200 rf-bg-gray-50 rf-px-4 rf-py-2",children:[j.jsxs(Sc,{type:"button",variant:"outline",size:"sm",onClick:()=>jHt(t),children:[j.jsx(c6e,{className:"rf-w-4 rf-h-4"}),"Download"]}),e?j.jsx(Sc,{asChild:!0,variant:"outline",size:"sm",children:j.jsxs("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:[j.jsx(Pre,{className:"rf-w-4 rf-h-4"}),"Report"]})}):j.jsxs(Sc,{type:"button",variant:"outline",size:"sm",disabled:!0,title:"No report link configured for this solver",children:[j.jsx(Pre,{className:"rf-w-4 rf-h-4"}),"Report"]})]})},Vqo=({solverEvent:t})=>{const e=WHt(t.solverName);return e?j.jsx(Sc,{asChild:!0,variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8",children:j.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",title:"Report solver bug","aria-label":"Report solver bug",children:j.jsx(Pre,{className:"rf-w-4 rf-h-4"})})}):j.jsx(Sc,{type:"button",variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8",disabled:!0,title:"No report link configured for this solver","aria-label":"Report solver bug",children:j.jsx(Pre,{className:"rf-w-4 rf-h-4"})})},Jqo=({solverEvents:t=[]})=>{const[e,n]=ne.useState(null);Hqo();const o=ne.useMemo(()=>{const a=new Map;for(const A of t){const c=`${A.componentName}-${A.solverName}`;a.set(c,A)}return a},[t]),i=ne.useMemo(()=>Array.from(o.keys()),[o]),r=e?o.get(e):null,s=ne.useMemo(()=>{if(!r)return{instance:null,error:null,classFound:!1};const a=RBe[r.solverName];if(!a)return{instance:null,error:`Solver class "${r.solverName}" not found in SOLVERS registry. Available: ${Object.keys(RBe).join(", ")}`,classFound:!1};try{const A=r.solverParams,c=A?.input!==void 0?A.input:A;return{instance:new a(c),error:null,classFound:!0}}catch(A){const c=A instanceof Error?A.message:String(A);return console.error("Failed to reconstruct solver:",A),{instance:null,error:`Failed to instantiate solver: ${c}`,classFound:!0}}},[r]);return t.length===0?j.jsx("div",{className:"rf-p-4",children:j.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:j.jsxs("div",{className:"rf-p-4",children:[j.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),j.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."})]})})}):j.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[j.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[j.jsxs("div",{className:"rf-text-xs rf-font-semibold rf-text-gray-500 rf-px-3 rf-py-2 rf-bg-gray-50 rf-border-b rf-border-gray-200",children:[i.length," ",i.length===1?"Solver":"Solvers"]}),i.map(a=>{const A=o.get(a),c=e===a;return j.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${c?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>n(a),children:(()=>{const l=Uqo(A.solverName);return j.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[j.jsx(l,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),j.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[j.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:A.componentName}),j.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:A.solverName})]})]})})()},a)})]}),j.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:r?s.instance?j.jsxs("div",{className:"rf-flex rf-h-full rf-flex-col rf-overflow-y-auto",children:[j.jsx(zqo,{solverEvent:r}),j.jsx("div",{className:"rf-min-h-0 rf-flex-1",children:j.jsx(tb,{fallback:j.jsx("div",{className:"rf-p-4",children:j.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[j.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),j.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",r.solverName]})]})}),children:j.jsx(Lqo,{solver:s.instance})})})]}):j.jsxs("div",{className:"rf-p-4",children:[j.jsxs("div",{className:"rf-mb-4",children:[j.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:r.solverName}),j.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",r.componentName]})]}),s.error&&j.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:j.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),j.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[j.jsxs("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50 rf-flex rf-items-center rf-justify-between rf-gap-2",children:[j.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"}),j.jsxs("div",{className:"rf-flex rf-items-center rf-gap-1",children:[j.jsx(Vqo,{solverEvent:r}),j.jsx(Sc,{type:"button",variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8","aria-label":"Download solver input JSON",title:"Download solver input JSON",onClick:()=>jHt(r),children:j.jsx(c6e,{className:"rf-w-4 rf-h-4"})})]})]}),j.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:j.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(r.solverParams,null,2)})})]})]}):j.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:j.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},XHt=({errorMessage:t,errorStack:e,circuitJsonErrors:n})=>{ne.useEffect(()=>{if(t){const o=new Error(t);e&&(o.stack=e);try{z8.captureException(o)}catch{}}},[t,e]),ne.useEffect(()=>{if(n&&n.length>0)for(const o of n){const i=new Error(o.message||"Circuit JSON Error");o.stack&&(i.stack=o.stack);try{z8.captureException(i,{error_type:o.type})}catch{}}},[n])},qqo=t=>{ne.useEffect(()=>{try{IWt(t)}catch{}},[t.source,t.component,t.isWebEmbedded,t.activeTab])},$Ht="0.0.2431",Wqo={version:$Ht},w9e={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},N9e=new Map,jse=t=>{const e=N9e.get(t);return e?Object.fromEntries(Object.entries(e.stores).map(([n,o])=>[n,o.getState()])):{}},jqo=(t,e,n)=>{if(t===void 0)return{type:"untracked",connection:e.connect(n)};const o=N9e.get(n.name);if(o)return{type:"tracked",store:t,...o};const i={connection:e.connect(n),stores:{}};return N9e.set(n.name,i),{type:"tracked",store:t,...i}},ZHt=(t,e={})=>(n,o,i)=>{const{enabled:r,anonymousActionType:s,store:a,...A}=e;let c;try{c=(r??(w9e?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!c)return(w9e?"production":void 0)!=="production"&&r&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),t(n,o,i);const{connection:l,...g}=jqo(a,c,A);let u=!0;i.setState=(_,m,p)=>{const I=n(_,m);if(!u)return I;const f=p===void 0?{type:s||"anonymous"}:typeof p=="string"?{type:p}:p;return a===void 0?(l?.send(f,o()),I):(l?.send({...f,type:`${a}/${f.type}`},{...jse(A.name),[a]:i.getState()}),I)};const d=(..._)=>{const m=u;u=!1,n(..._),u=m},h=t(i.setState,o,i);if(g.type==="untracked"?l?.init(h):(g.stores[g.store]=i,l?.init(Object.fromEntries(Object.entries(g.stores).map(([_,m])=>[_,_===g.store?h:m.getState()])))),i.dispatchFromDevtools&&typeof i.dispatch=="function"){let _=!1;const m=i.dispatch;i.dispatch=(...p)=>{(w9e?"production":void 0)!=="production"&&p[0].type==="__setState"&&!_&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),_=!0),m(...p)}}return l.subscribe(_=>{var m;switch(_.type){case"ACTION":if(typeof _.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return R9e(_.payload,p=>{if(p.type==="__setState"){if(a===void 0){d(p.state);return}Object.keys(p.state).length!==1&&console.error(`
|
|
5796
|
+
`,g=new Blob([l],{type:"text/plain"}),u=URL.createObjectURL(g),d=document.createElement("a");d.href=u,d.download=`${c}.test.ts`,d.click(),URL.revokeObjectURL(u)}catch(A){alert(`Error generating test.ts for ${t.constructor.name}: ${A instanceof Error?A.message:String(A)}`)}o(!1)};return j.jsxs("div",{className:`relative ${e}`,ref:i,children:[j.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&&j.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:[j.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download JSON"}),j.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),j.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:a,children:"Download test.ts"})]})]})},YHt=t=>t.activeSubSolver?[t,...YHt(t.activeSubSolver)]:[t],Sqo=({solver:t})=>{const e=YHt(t);return j.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:e.map((n,o)=>j.jsxs("div",{className:"flex items-center",children:[o>0&&j.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),j.jsx(Qqo,{solver:n})]},n.constructor.name))})},bqo=({solver:t,triggerRender:e,animationSpeed:n=25,onSolverStarted:o,onSolverCompleted:i})=>{const[r,s]=ne.useReducer(_=>!_,!1),a=ne.useRef(void 0),A=()=>{!t.solved&&!t.failed&&(t.step(),e())},c=()=>{!t.solved&&!t.failed&&(o&&o(t),t.solve(),e(),i&&i(t))},l=()=>{r?(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(),i&&t.solved&&i(t);return}t.step(),e()},n))},g=()=>{const _=t;if(_.getCurrentPhase&&!t.solved&&!t.failed){const m=_.getCurrentPhase();for(;_.getCurrentPhase()===m&&!t.solved&&!t.failed;)t.step();e()}},u=()=>{if(t.solved||t.failed||r)return;const _=window.prompt("Step until which iteration?",`${t.iterations}`);if(_===null)return;const m=Number(_);if(!Number.isFinite(m)){window.alert("Please enter a valid number for the iteration");return}for(;t.iterations<m&&!t.solved&&!t.failed;)t.step();e(),t.solved&&i&&i(t)};ne.useEffect(()=>()=>{a.current&&clearInterval(a.current)},[]),ne.useEffect(()=>{(t.solved||t.failed)&&r&&(a.current&&(clearInterval(a.current),a.current=void 0),s())},[t.solved,t.failed,r]);const d=t.getCurrentPhase!==void 0,h=d?t.getCurrentPhase():null;return j.jsxs("div",{className:"space-y-2 p-2 border-b",children:[j.jsx("div",{className:"flex items-center",children:j.jsx(Sqo,{solver:t})}),j.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[j.jsx("button",{onClick:A,disabled:t.solved||t.failed||r,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),j.jsx("button",{onClick:c,disabled:t.solved||t.failed||r,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),j.jsx("button",{onClick:l,disabled:t.solved||t.failed,className:`px-3 py-1 rounded text-white text-sm ${r?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:r?"Stop":"Animate"}),j.jsx("button",{onClick:u,disabled:t.solved||t.failed||r,className:"bg-orange-500 hover:bg-orange-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step Until Iteration"}),d&&j.jsx("button",{onClick:g,disabled:t.solved||t.failed||r,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),j.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&j.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),h&&j.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",j.jsx("span",{className:"font-medium",children:h})]}),t.solved&&j.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&j.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&j.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},Dqo=(t,e,n)=>{const o=t.currentPipelineStepIndex;return e<o?"Completed":e===o&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},Pqo=(t,e)=>{const o=t.pipelineDef[e].solverName,i=Dqo(t,e),r=t[o],s=t.firstIterationOfPhase?.[o]??null,a=t.iterations;let A=0;if(i==="Completed"){const u=t.pipelineDef[e+1],d=u?t.firstIterationOfPhase?.[u.solverName]:void 0;d!==void 0&&s!==null?A=d-s:s!==null&&(A=a-s)}else i==="In Progress"&&s!==null&&(A=a-s);const c=t.timeSpentOnPhase?.[o]??0;let l=0;i==="Completed"?l=1:i==="In Progress"&&r&&(l=r.progress??0);const g=r?.stats??null;return{index:e,name:o,status:i,firstIteration:s,iterations:A,progress:l,timeSpent:c,stats:g&&Object.keys(g).length>0?g:null,solverInstance:r??null}},vqo=({status:t})=>{const e={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return j.jsx("span",{className:`font-medium ${e[t]}`,children:t})},Mqo=({progress:t})=>{if(t===0)return null;const e=Math.round(t*100);return j.jsxs("div",{className:"flex items-center gap-2",children:[j.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:j.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${e}%`}})}),j.jsxs("span",{className:"text-xs text-gray-500",children:[e,"%"]})]})},wqo=t=>Object.entries(t).map(([e,n])=>`${e}: ${n}`).join(", "),Nqo=({stats:t})=>{if(!t||Object.keys(t).length===0)return j.jsx("span",{children:"-"});const e=Object.entries(t),n=wqo(t);return j.jsxs("details",{className:"cursor-pointer",children:[j.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:n}),j.jsx("div",{className:"mt-1 text-xs",children:e.map(([o,i])=>j.jsxs("div",{children:[o,": ",String(i)]},o))})]})},M9e=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(M9e);const e={};for(const[n,o]of Object.entries(t))n.startsWith("_")||(e[n]=M9e(o));return e},Rqo=(t,e)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${e}`);return}const n=M9e(t.getConstructorParams()),o=new Blob([JSON.stringify(n,null,2)],{type:"application/json"}),i=URL.createObjectURL(o),r=document.createElement("a");r.href=i,r.download=`${e}_input.json`,r.click(),URL.revokeObjectURL(i)}catch(n){alert(`Error downloading input for ${e}: ${n instanceof Error?n.message:String(n)}`)}},Tqo=({solver:t,onStepUntilPhase:e,onDownloadInput:n})=>{const o=t.pipelineDef.map((a,A)=>Pqo(t,A)),i=a=>{e?.(a)},r=a=>{a.solverInstance&&(n?n(a.solverInstance,a.name):Rqo(a.solverInstance,a.name))},s=a=>`${(a/1e3).toFixed(2)}s`;return j.jsxs("div",{className:"border-t border-gray-200",children:[j.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:j.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),j.jsx("div",{className:"overflow-x-auto",children:j.jsxs("table",{className:"w-full text-sm",children:[j.jsx("thead",{children:j.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[j.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),j.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),j.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",j.jsx("sub",{children:"0"})]}),j.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),j.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),j.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),j.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),j.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),j.jsx("tbody",{children:o.map(a=>j.jsxs("tr",{className:`border-b border-gray-100 ${a.status==="In Progress"?"bg-yellow-50":""}`,children:[j.jsx("td",{className:"px-4 py-2",children:j.jsxs("div",{className:"flex items-center gap-2",children:[j.jsx("span",{className:"text-gray-400 w-6",children:String(a.index+1).padStart(2,"0")}),j.jsx("button",{onClick:()=>i(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:j.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:j.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"})})}),j.jsx("span",{className:"font-medium text-gray-900",children:a.name})]})}),j.jsx("td",{className:"px-4 py-2",children:j.jsx(vqo,{status:a.status})}),j.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:a.firstIteration!==null?a.firstIteration:""}),j.jsx("td",{className:"px-4 py-2 text-gray-600",children:a.iterations}),j.jsx("td",{className:"px-4 py-2",children:j.jsx(Mqo,{progress:a.progress})}),j.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(a.timeSpent)}),j.jsx("td",{className:"px-4 py-2 text-gray-500",children:j.jsx(Nqo,{stats:a.stats})}),j.jsx("td",{className:"px-4 py-2",children:a.solverInstance?j.jsxs("button",{onClick:()=>r(a),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${a.name}`,children:[j.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:j.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"})}),j.jsx("span",{children:"Input"})]}):null})]},a.name))})]})})]})},kqo=class extends Xr.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t){console.error("InteractiveGraphics render error:",t)}render(){return this.state.hasError?this.props.fallback:this.props.children}};function Fqo({graphics:t}){const e=t.points??[],n=t.lines??[],o=t.rects??[],i=t.circles??[],r=t.texts??[];let s=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,A=Number.NEGATIVE_INFINITY,c=Number.NEGATIVE_INFINITY;const l=(m,p)=>{typeof m=="number"&&(m<s&&(s=m),m>A&&(A=m)),typeof p=="number"&&(p<a&&(a=p),p>c&&(c=p))};for(const m of e)l(m.x,m.y);for(const m of n){const p=m.points??[];for(const I of p)l(I.x,I.y)}for(const m of o){const p=m.x??0,I=m.y??0,f=m.width??0,C=m.height??0;l(p,I),l(p+f,I+C)}for(const m of i){const p=m.x??0,I=m.y??0,f=m.radius??1;l(p-f,I-f),l(p+f,I+f)}for(const m of r)l(m.x,m.y);(!isFinite(s)||!isFinite(a)||!isFinite(A)||!isFinite(c))&&(s=-20,a=-20,A=20,c=20);const g=10,u=s-g,d=a-g,h=Math.max(1,A-s+2*g),_=Math.max(1,c-a+2*g);return j.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${u} ${d} ${h} ${_}`,role:"img","aria-label":"Graphics fallback",children:[o.map((m,p)=>j.jsx("rect",{x:m.x??0,y:m.y??0,width:m.width??0,height:m.height??0,fill:"none",stroke:m.strokeColor??"black",strokeWidth:m.strokeWidth??1},`rect-${p}`)),n.map((m,p)=>j.jsx("polyline",{fill:"none",stroke:m.strokeColor??"black",strokeWidth:m.strokeWidth??1,points:(m.points??[]).map(I=>`${I.x??0},${I.y??0}`).join(" ")},`line-${p}`)),i.map((m,p)=>j.jsx("circle",{cx:m.x??0,cy:m.y??0,r:m.radius??1.5,fill:m.fillColor??"none",stroke:m.strokeColor??"black",strokeWidth:m.strokeWidth??1},`circle-${p}`)),e.map((m,p)=>j.jsx("circle",{cx:m.x??0,cy:m.y??0,r:m.radius??1.5,fill:m.color??"black"},`point-${p}`)),r.map((m,p)=>j.jsx("text",{x:m.x??0,y:m.y??0,fontSize:m.fontSize??10,fill:m.color??"black",children:m.text??""},`text-${p}`))]})}var Lqo=({solver:t,animationSpeed:e=25,onSolverStarted:n,onSolverCompleted:o})=>{const[i,r]=ne.useReducer(l=>l+1,0),s=ne.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(l){return console.error("Visualization error:",l),{points:[],lines:[],rects:[],circles:[]}}},[t,i]),a=ne.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);ne.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const l=document.createElement("script");l.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(l)}},[]);const A=t.pipelineDef!==void 0,c=l=>{const g=t;if(!t.solved&&!t.failed){for(;!t.solved&&!t.failed&&g.currentPipelineStepIndex<=g.pipelineDef.findIndex(u=>u.solverName===l);)t.step();r()}};return j.jsxs("div",{children:[j.jsx(bqo,{solver:t,triggerRender:r,animationSpeed:e,onSolverStarted:n,onSolverCompleted:o}),a?j.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):j.jsx(kqo,{fallback:j.jsx(Fqo,{graphics:s}),children:j.jsx(Bqo,{graphics:s})}),A&&j.jsx(Tqo,{solver:t,onStepUntilPhase:c})]})};const Hqo=()=>{ne.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)},[])},Gqo=1e3,ub=(t,e)=>{const{fileName:n,mimeType:o="text/plain"}=e,i=t instanceof Blob?t:new Blob([t],{type:o}),r=URL.createObjectURL(i),s=document.createElement("a");s.href=r,s.download=n,s.target="_blank",s.rel="noopener noreferrer",s.style.display="none",document.body.appendChild(s),s.click(),document.body.removeChild(s),setTimeout(()=>{URL.revokeObjectURL(r)},Gqo)},zHt=t=>{let e=t.trim().replace(/[\\/:*?"<>|]/g,"_").replace(/[\x00-\x1f]/g,"").replace(/^\.+/,"").replace(/\.+$/,"").replace(/\s+/g," ").replace(/_+/g,"_");return/^(con|prn|aux|nul|com[0-9]|lpt[0-9])$/i.test(e)&&(e=`_${e}`),e=e.slice(0,200),e||"untitled"},hb="https://github.com/tscircuit/tscircuit-autorouter/issues/new",VHt="https://github.com/tscircuit/copper-pour-solver/issues/new",JHt="https://github.com/tscircuit/calculate-packing/issues/new",Oqo="https://github.com/tscircuit/matchpack/issues/new",qHt="https://github.com/tscircuit/schematic-trace-solver/issues/new?template=json-bug-report.yml",Kqo={PackSolver2:JHt,LayoutPipelineSolver:Oqo,AutoroutingPipelineSolver:hb,AssignableAutoroutingPipeline2:hb,AssignableAutoroutingPipeline3:hb,AutoroutingPipeline1_OriginalUnravel:hb,AutoroutingPipelineSolver3_HgPortPointPathing:hb,AutoroutingPipelineSolver4:hb,AutoroutingPipelineSolver5:hb,AutoroutingPipelineSolver7_MultiGraph:hb,AutoroutingPipelineSolver8:hb,CopperPourPipelineSolver:VHt,SchematicTracePipelineSolver:qHt},Uqo=t=>t.toLowerCase().includes("pack")?hTo:t.toLowerCase().includes("rout")?CTo:sTo,WHt=t=>{const e=Kqo[t];if(e)return e;const n=t.toLowerCase();return n.includes("autorout")?hb:n.includes("schematic")&&n.includes("trace")?qHt:n.includes("copperpour")?VHt:n.includes("pack")?JHt:null},Yqo=t=>`${zHt(`${t.componentName}-${t.solverName}`)}-solver-input.json`,jHt=t=>{ub(JSON.stringify(t.solverParams,null,2),{fileName:Yqo(t),mimeType:"application/json"})},zqo=({solverEvent:t})=>{const e=WHt(t.solverName);return j.jsxs("div",{className:"rf-flex rf-items-center rf-justify-end rf-gap-2 rf-border-b rf-border-gray-200 rf-bg-gray-50 rf-px-4 rf-py-2",children:[j.jsxs(Sc,{type:"button",variant:"outline",size:"sm",onClick:()=>jHt(t),children:[j.jsx(c6e,{className:"rf-w-4 rf-h-4"}),"Download"]}),e?j.jsx(Sc,{asChild:!0,variant:"outline",size:"sm",children:j.jsxs("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:[j.jsx(Pre,{className:"rf-w-4 rf-h-4"}),"Report"]})}):j.jsxs(Sc,{type:"button",variant:"outline",size:"sm",disabled:!0,title:"No report link configured for this solver",children:[j.jsx(Pre,{className:"rf-w-4 rf-h-4"}),"Report"]})]})},Vqo=({solverEvent:t})=>{const e=WHt(t.solverName);return e?j.jsx(Sc,{asChild:!0,variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8",children:j.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",title:"Report solver bug","aria-label":"Report solver bug",children:j.jsx(Pre,{className:"rf-w-4 rf-h-4"})})}):j.jsx(Sc,{type:"button",variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8",disabled:!0,title:"No report link configured for this solver","aria-label":"Report solver bug",children:j.jsx(Pre,{className:"rf-w-4 rf-h-4"})})},Jqo=({solverEvents:t=[]})=>{const[e,n]=ne.useState(null);Hqo();const o=ne.useMemo(()=>{const a=new Map;for(const A of t){const c=`${A.componentName}-${A.solverName}`;a.set(c,A)}return a},[t]),i=ne.useMemo(()=>Array.from(o.keys()),[o]),r=e?o.get(e):null,s=ne.useMemo(()=>{if(!r)return{instance:null,error:null,classFound:!1};const a=RBe[r.solverName];if(!a)return{instance:null,error:`Solver class "${r.solverName}" not found in SOLVERS registry. Available: ${Object.keys(RBe).join(", ")}`,classFound:!1};try{const A=r.solverParams,c=A?.input!==void 0?A.input:A;return{instance:new a(c),error:null,classFound:!0}}catch(A){const c=A instanceof Error?A.message:String(A);return console.error("Failed to reconstruct solver:",A),{instance:null,error:`Failed to instantiate solver: ${c}`,classFound:!0}}},[r]);return t.length===0?j.jsx("div",{className:"rf-p-4",children:j.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:j.jsxs("div",{className:"rf-p-4",children:[j.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),j.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."})]})})}):j.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[j.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[j.jsxs("div",{className:"rf-text-xs rf-font-semibold rf-text-gray-500 rf-px-3 rf-py-2 rf-bg-gray-50 rf-border-b rf-border-gray-200",children:[i.length," ",i.length===1?"Solver":"Solvers"]}),i.map(a=>{const A=o.get(a),c=e===a;return j.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${c?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>n(a),children:(()=>{const l=Uqo(A.solverName);return j.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[j.jsx(l,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),j.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[j.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:A.componentName}),j.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:A.solverName})]})]})})()},a)})]}),j.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:r?s.instance?j.jsxs("div",{className:"rf-flex rf-h-full rf-flex-col rf-overflow-y-auto",children:[j.jsx(zqo,{solverEvent:r}),j.jsx("div",{className:"rf-min-h-0 rf-flex-1",children:j.jsx(tb,{fallback:j.jsx("div",{className:"rf-p-4",children:j.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[j.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),j.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",r.solverName]})]})}),children:j.jsx(Lqo,{solver:s.instance})})})]}):j.jsxs("div",{className:"rf-p-4",children:[j.jsxs("div",{className:"rf-mb-4",children:[j.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:r.solverName}),j.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",r.componentName]})]}),s.error&&j.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:j.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),j.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[j.jsxs("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50 rf-flex rf-items-center rf-justify-between rf-gap-2",children:[j.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"}),j.jsxs("div",{className:"rf-flex rf-items-center rf-gap-1",children:[j.jsx(Vqo,{solverEvent:r}),j.jsx(Sc,{type:"button",variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8","aria-label":"Download solver input JSON",title:"Download solver input JSON",onClick:()=>jHt(r),children:j.jsx(c6e,{className:"rf-w-4 rf-h-4"})})]})]}),j.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:j.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(r.solverParams,null,2)})})]})]}):j.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:j.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},XHt=({errorMessage:t,errorStack:e,circuitJsonErrors:n})=>{ne.useEffect(()=>{if(t){const o=new Error(t);e&&(o.stack=e);try{z8.captureException(o)}catch{}}},[t,e]),ne.useEffect(()=>{if(n&&n.length>0)for(const o of n){const i=new Error(o.message||"Circuit JSON Error");o.stack&&(i.stack=o.stack);try{z8.captureException(i,{error_type:o.type})}catch{}}},[n])},qqo=t=>{ne.useEffect(()=>{try{IWt(t)}catch{}},[t.source,t.component,t.isWebEmbedded,t.activeTab])},$Ht="0.0.2432",Wqo={version:$Ht},w9e={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},N9e=new Map,jse=t=>{const e=N9e.get(t);return e?Object.fromEntries(Object.entries(e.stores).map(([n,o])=>[n,o.getState()])):{}},jqo=(t,e,n)=>{if(t===void 0)return{type:"untracked",connection:e.connect(n)};const o=N9e.get(n.name);if(o)return{type:"tracked",store:t,...o};const i={connection:e.connect(n),stores:{}};return N9e.set(n.name,i),{type:"tracked",store:t,...i}},ZHt=(t,e={})=>(n,o,i)=>{const{enabled:r,anonymousActionType:s,store:a,...A}=e;let c;try{c=(r??(w9e?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!c)return(w9e?"production":void 0)!=="production"&&r&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),t(n,o,i);const{connection:l,...g}=jqo(a,c,A);let u=!0;i.setState=(_,m,p)=>{const I=n(_,m);if(!u)return I;const f=p===void 0?{type:s||"anonymous"}:typeof p=="string"?{type:p}:p;return a===void 0?(l?.send(f,o()),I):(l?.send({...f,type:`${a}/${f.type}`},{...jse(A.name),[a]:i.getState()}),I)};const d=(..._)=>{const m=u;u=!1,n(..._),u=m},h=t(i.setState,o,i);if(g.type==="untracked"?l?.init(h):(g.stores[g.store]=i,l?.init(Object.fromEntries(Object.entries(g.stores).map(([_,m])=>[_,_===g.store?h:m.getState()])))),i.dispatchFromDevtools&&typeof i.dispatch=="function"){let _=!1;const m=i.dispatch;i.dispatch=(...p)=>{(w9e?"production":void 0)!=="production"&&p[0].type==="__setState"&&!_&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),_=!0),m(...p)}}return l.subscribe(_=>{var m;switch(_.type){case"ACTION":if(typeof _.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return R9e(_.payload,p=>{if(p.type==="__setState"){if(a===void 0){d(p.state);return}Object.keys(p.state).length!==1&&console.error(`
|
|
5797
5797
|
[zustand devtools middleware] Unsupported __setState action format.
|
|
5798
5798
|
When using 'store' option in devtools(), the 'state' should have only one key, which is a value of 'store' that was passed in devtools(),
|
|
5799
5799
|
and value of this only key should be a state object. Example: { "type": "__setState", "state": { "abc123Store": { "foo": "bar" } } }
|