@tscircuit/runframe 0.0.2156 → 0.0.2157
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.
|
@@ -2012,7 +2012,7 @@ var usePostHogActivity = (properties) => {
|
|
|
2012
2012
|
};
|
|
2013
2013
|
|
|
2014
2014
|
// package.json
|
|
2015
|
-
var version = "0.0.
|
|
2015
|
+
var version = "0.0.2156";
|
|
2016
2016
|
var package_default = {
|
|
2017
2017
|
name: "@tscircuit/runframe",
|
|
2018
2018
|
main: "dist/preview.js",
|
|
@@ -6056,10 +6056,9 @@ var shouldShowCrispFeedbackButton = ({
|
|
|
6056
6056
|
isCli,
|
|
6057
6057
|
hostname = typeof window !== "undefined" ? window.location.hostname : void 0
|
|
6058
6058
|
} = {}) => {
|
|
6059
|
+
if (hostname?.toLowerCase() === TSCIRCUIT_HOSTNAME) return false;
|
|
6059
6060
|
if (isCli) return true;
|
|
6060
|
-
|
|
6061
|
-
const normalizedHostname = hostname.toLowerCase();
|
|
6062
|
-
return normalizedHostname === TSCIRCUIT_HOSTNAME;
|
|
6061
|
+
return false;
|
|
6063
6062
|
};
|
|
6064
6063
|
var CrispFeedbackButton = () => {
|
|
6065
6064
|
return /* @__PURE__ */ jsx41(TooltipProvider, { children: /* @__PURE__ */ jsxs29(Tooltip, { children: [
|
|
@@ -6069,13 +6068,13 @@ var CrispFeedbackButton = () => {
|
|
|
6069
6068
|
type: "button",
|
|
6070
6069
|
variant: "ghost",
|
|
6071
6070
|
size: "icon",
|
|
6072
|
-
"aria-label": "Give
|
|
6071
|
+
"aria-label": "Get Support or Give Feedback",
|
|
6073
6072
|
onClick: openCrispChat,
|
|
6074
6073
|
className: "rf-h-8 rf-w-8",
|
|
6075
6074
|
children: /* @__PURE__ */ jsx41(MessageCircleQuestion, { className: "rf-h-4 rf-w-4 rf-text-gray-500" })
|
|
6076
6075
|
}
|
|
6077
6076
|
) }),
|
|
6078
|
-
/* @__PURE__ */ jsx41(TooltipContent, { side: "bottom", children: "Give
|
|
6077
|
+
/* @__PURE__ */ jsx41(TooltipContent, { side: "bottom", children: "Get Support or Give Feedback" })
|
|
6079
6078
|
] }) });
|
|
6080
6079
|
};
|
|
6081
6080
|
|
package/dist/preview.js
CHANGED
package/dist/runner.js
CHANGED
|
@@ -5790,7 +5790,7 @@ test("${l} should solve problem correctly", () => {
|
|
|
5790
5790
|
// Add more specific assertions based on expected output
|
|
5791
5791
|
// expect(solver.netLabelPlacementSolver!.netLabelPlacements).toMatchInlineSnapshot()
|
|
5792
5792
|
})
|
|
5793
|
-
`,u=new Blob([A],{type:"text/plain"}),d=URL.createObjectURL(u),_=document.createElement("a");_.href=d,_.download=`${l}.test.ts`,_.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 W.jsxs("div",{className:`relative ${e}`,ref:i,children:[W.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&&W.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:[W.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download JSON"}),W.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),W.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:a,children:"Download test.ts"})]})]})},S3t=t=>t.activeSubSolver?[t,...S3t(t.activeSubSolver)]:[t],eSo=({solver:t})=>{const e=S3t(t);return W.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:e.map((n,o)=>W.jsxs("div",{className:"flex items-center",children:[o>0&&W.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),W.jsx(Zbo,{solver:n})]},n.constructor.name))})},tSo=({solver:t,triggerRender:e,animationSpeed:n=25,onSolverStarted:o,onSolverCompleted:i})=>{const[r,s]=Z.useReducer(m=>!m,!1),a=Z.useRef(void 0),c=()=>{!t.solved&&!t.failed&&(t.step(),e())},l=()=>{!t.solved&&!t.failed&&(o&&o(t),t.solve(),e(),i&&i(t))},A=()=>{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))},u=()=>{const m=t;if(m.getCurrentPhase&&!t.solved&&!t.failed){const p=m.getCurrentPhase();for(;m.getCurrentPhase()===p&&!t.solved&&!t.failed;)t.step();e()}},d=()=>{if(t.solved||t.failed||r)return;const m=window.prompt("Step until which iteration?",`${t.iterations}`);if(m===null)return;const p=Number(m);if(!Number.isFinite(p)){window.alert("Please enter a valid number for the iteration");return}for(;t.iterations<p&&!t.solved&&!t.failed;)t.step();e(),t.solved&&i&&i(t)};Z.useEffect(()=>()=>{a.current&&clearInterval(a.current)},[]),Z.useEffect(()=>{(t.solved||t.failed)&&r&&(a.current&&(clearInterval(a.current),a.current=void 0),s())},[t.solved,t.failed,r]);const _=t.getCurrentPhase!==void 0,h=_?t.getCurrentPhase():null;return W.jsxs("div",{className:"space-y-2 p-2 border-b",children:[W.jsx("div",{className:"flex items-center",children:W.jsx(eSo,{solver:t})}),W.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[W.jsx("button",{onClick:c,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"}),W.jsx("button",{onClick:l,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"}),W.jsx("button",{onClick:A,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"}),W.jsx("button",{onClick:d,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"}),_&&W.jsx("button",{onClick:u,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"}),W.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&W.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),h&&W.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",W.jsx("span",{className:"font-medium",children:h})]}),t.solved&&W.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&W.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&W.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},nSo=(t,e,n)=>{const o=t.currentPipelineStepIndex;return e<o?"Completed":e===o&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},oSo=(t,e)=>{const o=t.pipelineDef[e].solverName,i=nSo(t,e),r=t[o],s=t.firstIterationOfPhase?.[o]??null,a=t.iterations;let c=0;if(i==="Completed"){const d=t.pipelineDef[e+1],_=d?t.firstIterationOfPhase?.[d.solverName]:void 0;_!==void 0&&s!==null?c=_-s:s!==null&&(c=a-s)}else i==="In Progress"&&s!==null&&(c=a-s);const l=t.timeSpentOnPhase?.[o]??0;let A=0;i==="Completed"?A=1:i==="In Progress"&&r&&(A=r.progress??0);const u=r?.stats??null;return{index:e,name:o,status:i,firstIteration:s,iterations:c,progress:A,timeSpent:l,stats:u&&Object.keys(u).length>0?u:null,solverInstance:r??null}},iSo=({status:t})=>{const e={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return W.jsx("span",{className:`font-medium ${e[t]}`,children:t})},rSo=({progress:t})=>{if(t===0)return null;const e=Math.round(t*100);return W.jsxs("div",{className:"flex items-center gap-2",children:[W.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:W.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${e}%`}})}),W.jsxs("span",{className:"text-xs text-gray-500",children:[e,"%"]})]})},sSo=t=>Object.entries(t).map(([e,n])=>`${e}: ${n}`).join(", "),aSo=({stats:t})=>{if(!t||Object.keys(t).length===0)return W.jsx("span",{children:"-"});const e=Object.entries(t),n=sSo(t);return W.jsxs("details",{className:"cursor-pointer",children:[W.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:n}),W.jsx("div",{className:"mt-1 text-xs",children:e.map(([o,i])=>W.jsxs("div",{children:[o,": ",String(i)]},o))})]})},pve=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(pve);const e={};for(const[n,o]of Object.entries(t))n.startsWith("_")||(e[n]=pve(o));return e},cSo=(t,e)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${e}`);return}const n=pve(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)}`)}},lSo=({solver:t,onStepUntilPhase:e,onDownloadInput:n})=>{const o=t.pipelineDef.map((a,c)=>oSo(t,c)),i=a=>{e?.(a)},r=a=>{a.solverInstance&&(n?n(a.solverInstance,a.name):cSo(a.solverInstance,a.name))},s=a=>`${(a/1e3).toFixed(2)}s`;return W.jsxs("div",{className:"border-t border-gray-200",children:[W.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:W.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),W.jsx("div",{className:"overflow-x-auto",children:W.jsxs("table",{className:"w-full text-sm",children:[W.jsx("thead",{children:W.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),W.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",W.jsx("sub",{children:"0"})]}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),W.jsx("tbody",{children:o.map(a=>W.jsxs("tr",{className:`border-b border-gray-100 ${a.status==="In Progress"?"bg-yellow-50":""}`,children:[W.jsx("td",{className:"px-4 py-2",children:W.jsxs("div",{className:"flex items-center gap-2",children:[W.jsx("span",{className:"text-gray-400 w-6",children:String(a.index+1).padStart(2,"0")}),W.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:W.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:W.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"})})}),W.jsx("span",{className:"font-medium text-gray-900",children:a.name})]})}),W.jsx("td",{className:"px-4 py-2",children:W.jsx(iSo,{status:a.status})}),W.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:a.firstIteration!==null?a.firstIteration:""}),W.jsx("td",{className:"px-4 py-2 text-gray-600",children:a.iterations}),W.jsx("td",{className:"px-4 py-2",children:W.jsx(rSo,{progress:a.progress})}),W.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(a.timeSpent)}),W.jsx("td",{className:"px-4 py-2 text-gray-500",children:W.jsx(aSo,{stats:a.stats})}),W.jsx("td",{className:"px-4 py-2",children:a.solverInstance?W.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:[W.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:W.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"})}),W.jsx("span",{children:"Input"})]}):null})]},a.name))})]})})]})},ASo=class extends Or.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 uSo({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,c=Number.NEGATIVE_INFINITY,l=Number.NEGATIVE_INFINITY;const A=(p,g)=>{typeof p=="number"&&(p<s&&(s=p),p>c&&(c=p)),typeof g=="number"&&(g<a&&(a=g),g>l&&(l=g))};for(const p of e)A(p.x,p.y);for(const p of n){const g=p.points??[];for(const f of g)A(f.x,f.y)}for(const p of o){const g=p.x??0,f=p.y??0,y=p.width??0,C=p.height??0;A(g,f),A(g+y,f+C)}for(const p of i){const g=p.x??0,f=p.y??0,y=p.radius??1;A(g-y,f-y),A(g+y,f+y)}for(const p of r)A(p.x,p.y);(!isFinite(s)||!isFinite(a)||!isFinite(c)||!isFinite(l))&&(s=-20,a=-20,c=20,l=20);const u=10,d=s-u,_=a-u,h=Math.max(1,c-s+2*u),m=Math.max(1,l-a+2*u);return W.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${d} ${_} ${h} ${m}`,role:"img","aria-label":"Graphics fallback",children:[o.map((p,g)=>W.jsx("rect",{x:p.x??0,y:p.y??0,width:p.width??0,height:p.height??0,fill:"none",stroke:p.strokeColor??"black",strokeWidth:p.strokeWidth??1},`rect-${g}`)),n.map((p,g)=>W.jsx("polyline",{fill:"none",stroke:p.strokeColor??"black",strokeWidth:p.strokeWidth??1,points:(p.points??[]).map(f=>`${f.x??0},${f.y??0}`).join(" ")},`line-${g}`)),i.map((p,g)=>W.jsx("circle",{cx:p.x??0,cy:p.y??0,r:p.radius??1.5,fill:p.fillColor??"none",stroke:p.strokeColor??"black",strokeWidth:p.strokeWidth??1},`circle-${g}`)),e.map((p,g)=>W.jsx("circle",{cx:p.x??0,cy:p.y??0,r:p.radius??1.5,fill:p.color??"black"},`point-${g}`)),r.map((p,g)=>W.jsx("text",{x:p.x??0,y:p.y??0,fontSize:p.fontSize??10,fill:p.color??"black",children:p.text??""},`text-${g}`))]})}var dSo=({solver:t,animationSpeed:e=25,onSolverStarted:n,onSolverCompleted:o})=>{const[i,r]=Z.useReducer(A=>A+1,0),s=Z.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(A){return console.error("Visualization error:",A),{points:[],lines:[],rects:[],circles:[]}}},[t,i]),a=Z.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);Z.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const A=document.createElement("script");A.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(A)}},[]);const c=t.pipelineDef!==void 0,l=A=>{const u=t;if(!t.solved&&!t.failed){for(;!t.solved&&!t.failed&&u.currentPipelineStepIndex<=u.pipelineDef.findIndex(d=>d.solverName===A);)t.step();r()}};return W.jsxs("div",{children:[W.jsx(tSo,{solver:t,triggerRender:r,animationSpeed:e,onSolverStarted:n,onSolverCompleted:o}),a?W.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):W.jsx(ASo,{fallback:W.jsx(uSo,{graphics:s}),children:W.jsx($bo,{graphics:s})}),c&&W.jsx(lSo,{solver:t,onStepUntilPhase:l})]})};const hSo=()=>{Z.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)},[])},_So=t=>t.toLowerCase().includes("pack")?Auo:t.toLowerCase().includes("rout")?puo:nuo,mSo=({solverEvents:t=[]})=>{const[e,n]=Z.useState(null);hSo();const o=Z.useMemo(()=>{const a=new Map;for(const c of t){const l=`${c.componentName}-${c.solverName}`;a.set(l,c)}return a},[t]),i=Z.useMemo(()=>Array.from(o.keys()),[o]),r=e?o.get(e):null,s=Z.useMemo(()=>{if(!r)return{instance:null,error:null,classFound:!1};const a=Wfe[r.solverName];if(!a)return{instance:null,error:`Solver class "${r.solverName}" not found in SOLVERS registry. Available: ${Object.keys(Wfe).join(", ")}`,classFound:!1};try{const c=r.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}}},[r]);return t.length===0?W.jsx("div",{className:"rf-p-4",children:W.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:W.jsxs("div",{className:"rf-p-4",children:[W.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),W.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."})]})})}):W.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[W.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[W.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 c=o.get(a),l=e===a;return W.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 A=_So(c.solverName);return W.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[W.jsx(A,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),W.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[W.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:c.componentName}),W.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:c.solverName})]})]})})()},a)})]}),W.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:r?s.instance?W.jsx($4,{fallback:W.jsx("div",{className:"rf-p-4",children:W.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[W.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),W.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",r.solverName]})]})}),children:W.jsx(dSo,{solver:s.instance})}):W.jsxs("div",{className:"rf-p-4",children:[W.jsxs("div",{className:"rf-mb-4",children:[W.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:r.solverName}),W.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",r.componentName]})]}),s.error&&W.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:W.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),W.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[W.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:W.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),W.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:W.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)})})]})]}):W.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:W.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},P3t=({errorMessage:t,errorStack:e,circuitJsonErrors:n})=>{Z.useEffect(()=>{if(t){const o=new Error(t);e&&(o.stack=e);try{t9.captureException(o)}catch{}}},[t,e]),Z.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{t9.captureException(i,{error_type:o.type})}catch{}}},[n])},gSo=t=>{Z.useEffect(()=>{try{BDt(t)}catch{}},[t.source,t.component,t.isWebEmbedded,t.activeTab])},v3t="0.0.2155",pSo={version:v3t},fve={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},yve=new Map,Qte=t=>{const e=yve.get(t);return e?Object.fromEntries(Object.entries(e.stores).map(([n,o])=>[n,o.getState()])):{}},fSo=(t,e,n)=>{if(t===void 0)return{type:"untracked",connection:e.connect(n)};const o=yve.get(n.name);if(o)return{type:"tracked",store:t,...o};const i={connection:e.connect(n),stores:{}};return yve.set(n.name,i),{type:"tracked",store:t,...i}},B3t=(t,e={})=>(n,o,i)=>{const{enabled:r,anonymousActionType:s,store:a,...c}=e;let l;try{l=(r??(fve?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!l)return(fve?"production":void 0)!=="production"&&r&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),t(n,o,i);const{connection:A,...u}=fSo(a,l,c);let d=!0;i.setState=(m,p,g)=>{const f=n(m,p);if(!d)return f;const y=g===void 0?{type:s||"anonymous"}:typeof g=="string"?{type:g}:g;return a===void 0?(A?.send(y,o()),f):(A?.send({...y,type:`${a}/${y.type}`},{...Qte(c.name),[a]:i.getState()}),f)};const _=(...m)=>{const p=d;d=!1,n(...m),d=p},h=t(i.setState,o,i);if(u.type==="untracked"?A?.init(h):(u.stores[u.store]=i,A?.init(Object.fromEntries(Object.entries(u.stores).map(([m,p])=>[m,m===u.store?h:p.getState()])))),i.dispatchFromDevtools&&typeof i.dispatch=="function"){let m=!1;const p=i.dispatch;i.dispatch=(...g)=>{(fve?"production":void 0)!=="production"&&g[0].type==="__setState"&&!m&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),m=!0),p(...g)}}return A.subscribe(m=>{var p;switch(m.type){case"ACTION":if(typeof m.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return Cve(m.payload,g=>{if(g.type==="__setState"){if(a===void 0){_(g.state);return}Object.keys(g.state).length!==1&&console.error(`
|
|
5793
|
+
`,u=new Blob([A],{type:"text/plain"}),d=URL.createObjectURL(u),_=document.createElement("a");_.href=d,_.download=`${l}.test.ts`,_.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 W.jsxs("div",{className:`relative ${e}`,ref:i,children:[W.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&&W.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:[W.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download JSON"}),W.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),W.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:a,children:"Download test.ts"})]})]})},S3t=t=>t.activeSubSolver?[t,...S3t(t.activeSubSolver)]:[t],eSo=({solver:t})=>{const e=S3t(t);return W.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:e.map((n,o)=>W.jsxs("div",{className:"flex items-center",children:[o>0&&W.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),W.jsx(Zbo,{solver:n})]},n.constructor.name))})},tSo=({solver:t,triggerRender:e,animationSpeed:n=25,onSolverStarted:o,onSolverCompleted:i})=>{const[r,s]=Z.useReducer(m=>!m,!1),a=Z.useRef(void 0),c=()=>{!t.solved&&!t.failed&&(t.step(),e())},l=()=>{!t.solved&&!t.failed&&(o&&o(t),t.solve(),e(),i&&i(t))},A=()=>{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))},u=()=>{const m=t;if(m.getCurrentPhase&&!t.solved&&!t.failed){const p=m.getCurrentPhase();for(;m.getCurrentPhase()===p&&!t.solved&&!t.failed;)t.step();e()}},d=()=>{if(t.solved||t.failed||r)return;const m=window.prompt("Step until which iteration?",`${t.iterations}`);if(m===null)return;const p=Number(m);if(!Number.isFinite(p)){window.alert("Please enter a valid number for the iteration");return}for(;t.iterations<p&&!t.solved&&!t.failed;)t.step();e(),t.solved&&i&&i(t)};Z.useEffect(()=>()=>{a.current&&clearInterval(a.current)},[]),Z.useEffect(()=>{(t.solved||t.failed)&&r&&(a.current&&(clearInterval(a.current),a.current=void 0),s())},[t.solved,t.failed,r]);const _=t.getCurrentPhase!==void 0,h=_?t.getCurrentPhase():null;return W.jsxs("div",{className:"space-y-2 p-2 border-b",children:[W.jsx("div",{className:"flex items-center",children:W.jsx(eSo,{solver:t})}),W.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[W.jsx("button",{onClick:c,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"}),W.jsx("button",{onClick:l,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"}),W.jsx("button",{onClick:A,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"}),W.jsx("button",{onClick:d,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"}),_&&W.jsx("button",{onClick:u,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"}),W.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&W.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),h&&W.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",W.jsx("span",{className:"font-medium",children:h})]}),t.solved&&W.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&W.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&W.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},nSo=(t,e,n)=>{const o=t.currentPipelineStepIndex;return e<o?"Completed":e===o&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},oSo=(t,e)=>{const o=t.pipelineDef[e].solverName,i=nSo(t,e),r=t[o],s=t.firstIterationOfPhase?.[o]??null,a=t.iterations;let c=0;if(i==="Completed"){const d=t.pipelineDef[e+1],_=d?t.firstIterationOfPhase?.[d.solverName]:void 0;_!==void 0&&s!==null?c=_-s:s!==null&&(c=a-s)}else i==="In Progress"&&s!==null&&(c=a-s);const l=t.timeSpentOnPhase?.[o]??0;let A=0;i==="Completed"?A=1:i==="In Progress"&&r&&(A=r.progress??0);const u=r?.stats??null;return{index:e,name:o,status:i,firstIteration:s,iterations:c,progress:A,timeSpent:l,stats:u&&Object.keys(u).length>0?u:null,solverInstance:r??null}},iSo=({status:t})=>{const e={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return W.jsx("span",{className:`font-medium ${e[t]}`,children:t})},rSo=({progress:t})=>{if(t===0)return null;const e=Math.round(t*100);return W.jsxs("div",{className:"flex items-center gap-2",children:[W.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:W.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${e}%`}})}),W.jsxs("span",{className:"text-xs text-gray-500",children:[e,"%"]})]})},sSo=t=>Object.entries(t).map(([e,n])=>`${e}: ${n}`).join(", "),aSo=({stats:t})=>{if(!t||Object.keys(t).length===0)return W.jsx("span",{children:"-"});const e=Object.entries(t),n=sSo(t);return W.jsxs("details",{className:"cursor-pointer",children:[W.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:n}),W.jsx("div",{className:"mt-1 text-xs",children:e.map(([o,i])=>W.jsxs("div",{children:[o,": ",String(i)]},o))})]})},pve=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(pve);const e={};for(const[n,o]of Object.entries(t))n.startsWith("_")||(e[n]=pve(o));return e},cSo=(t,e)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${e}`);return}const n=pve(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)}`)}},lSo=({solver:t,onStepUntilPhase:e,onDownloadInput:n})=>{const o=t.pipelineDef.map((a,c)=>oSo(t,c)),i=a=>{e?.(a)},r=a=>{a.solverInstance&&(n?n(a.solverInstance,a.name):cSo(a.solverInstance,a.name))},s=a=>`${(a/1e3).toFixed(2)}s`;return W.jsxs("div",{className:"border-t border-gray-200",children:[W.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:W.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),W.jsx("div",{className:"overflow-x-auto",children:W.jsxs("table",{className:"w-full text-sm",children:[W.jsx("thead",{children:W.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),W.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",W.jsx("sub",{children:"0"})]}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),W.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),W.jsx("tbody",{children:o.map(a=>W.jsxs("tr",{className:`border-b border-gray-100 ${a.status==="In Progress"?"bg-yellow-50":""}`,children:[W.jsx("td",{className:"px-4 py-2",children:W.jsxs("div",{className:"flex items-center gap-2",children:[W.jsx("span",{className:"text-gray-400 w-6",children:String(a.index+1).padStart(2,"0")}),W.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:W.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:W.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"})})}),W.jsx("span",{className:"font-medium text-gray-900",children:a.name})]})}),W.jsx("td",{className:"px-4 py-2",children:W.jsx(iSo,{status:a.status})}),W.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:a.firstIteration!==null?a.firstIteration:""}),W.jsx("td",{className:"px-4 py-2 text-gray-600",children:a.iterations}),W.jsx("td",{className:"px-4 py-2",children:W.jsx(rSo,{progress:a.progress})}),W.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(a.timeSpent)}),W.jsx("td",{className:"px-4 py-2 text-gray-500",children:W.jsx(aSo,{stats:a.stats})}),W.jsx("td",{className:"px-4 py-2",children:a.solverInstance?W.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:[W.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:W.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"})}),W.jsx("span",{children:"Input"})]}):null})]},a.name))})]})})]})},ASo=class extends Or.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 uSo({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,c=Number.NEGATIVE_INFINITY,l=Number.NEGATIVE_INFINITY;const A=(p,g)=>{typeof p=="number"&&(p<s&&(s=p),p>c&&(c=p)),typeof g=="number"&&(g<a&&(a=g),g>l&&(l=g))};for(const p of e)A(p.x,p.y);for(const p of n){const g=p.points??[];for(const f of g)A(f.x,f.y)}for(const p of o){const g=p.x??0,f=p.y??0,y=p.width??0,C=p.height??0;A(g,f),A(g+y,f+C)}for(const p of i){const g=p.x??0,f=p.y??0,y=p.radius??1;A(g-y,f-y),A(g+y,f+y)}for(const p of r)A(p.x,p.y);(!isFinite(s)||!isFinite(a)||!isFinite(c)||!isFinite(l))&&(s=-20,a=-20,c=20,l=20);const u=10,d=s-u,_=a-u,h=Math.max(1,c-s+2*u),m=Math.max(1,l-a+2*u);return W.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${d} ${_} ${h} ${m}`,role:"img","aria-label":"Graphics fallback",children:[o.map((p,g)=>W.jsx("rect",{x:p.x??0,y:p.y??0,width:p.width??0,height:p.height??0,fill:"none",stroke:p.strokeColor??"black",strokeWidth:p.strokeWidth??1},`rect-${g}`)),n.map((p,g)=>W.jsx("polyline",{fill:"none",stroke:p.strokeColor??"black",strokeWidth:p.strokeWidth??1,points:(p.points??[]).map(f=>`${f.x??0},${f.y??0}`).join(" ")},`line-${g}`)),i.map((p,g)=>W.jsx("circle",{cx:p.x??0,cy:p.y??0,r:p.radius??1.5,fill:p.fillColor??"none",stroke:p.strokeColor??"black",strokeWidth:p.strokeWidth??1},`circle-${g}`)),e.map((p,g)=>W.jsx("circle",{cx:p.x??0,cy:p.y??0,r:p.radius??1.5,fill:p.color??"black"},`point-${g}`)),r.map((p,g)=>W.jsx("text",{x:p.x??0,y:p.y??0,fontSize:p.fontSize??10,fill:p.color??"black",children:p.text??""},`text-${g}`))]})}var dSo=({solver:t,animationSpeed:e=25,onSolverStarted:n,onSolverCompleted:o})=>{const[i,r]=Z.useReducer(A=>A+1,0),s=Z.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(A){return console.error("Visualization error:",A),{points:[],lines:[],rects:[],circles:[]}}},[t,i]),a=Z.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);Z.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const A=document.createElement("script");A.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(A)}},[]);const c=t.pipelineDef!==void 0,l=A=>{const u=t;if(!t.solved&&!t.failed){for(;!t.solved&&!t.failed&&u.currentPipelineStepIndex<=u.pipelineDef.findIndex(d=>d.solverName===A);)t.step();r()}};return W.jsxs("div",{children:[W.jsx(tSo,{solver:t,triggerRender:r,animationSpeed:e,onSolverStarted:n,onSolverCompleted:o}),a?W.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):W.jsx(ASo,{fallback:W.jsx(uSo,{graphics:s}),children:W.jsx($bo,{graphics:s})}),c&&W.jsx(lSo,{solver:t,onStepUntilPhase:l})]})};const hSo=()=>{Z.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)},[])},_So=t=>t.toLowerCase().includes("pack")?Auo:t.toLowerCase().includes("rout")?puo:nuo,mSo=({solverEvents:t=[]})=>{const[e,n]=Z.useState(null);hSo();const o=Z.useMemo(()=>{const a=new Map;for(const c of t){const l=`${c.componentName}-${c.solverName}`;a.set(l,c)}return a},[t]),i=Z.useMemo(()=>Array.from(o.keys()),[o]),r=e?o.get(e):null,s=Z.useMemo(()=>{if(!r)return{instance:null,error:null,classFound:!1};const a=Wfe[r.solverName];if(!a)return{instance:null,error:`Solver class "${r.solverName}" not found in SOLVERS registry. Available: ${Object.keys(Wfe).join(", ")}`,classFound:!1};try{const c=r.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}}},[r]);return t.length===0?W.jsx("div",{className:"rf-p-4",children:W.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:W.jsxs("div",{className:"rf-p-4",children:[W.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),W.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."})]})})}):W.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[W.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[W.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 c=o.get(a),l=e===a;return W.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 A=_So(c.solverName);return W.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[W.jsx(A,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),W.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[W.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:c.componentName}),W.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:c.solverName})]})]})})()},a)})]}),W.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:r?s.instance?W.jsx($4,{fallback:W.jsx("div",{className:"rf-p-4",children:W.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[W.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),W.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",r.solverName]})]})}),children:W.jsx(dSo,{solver:s.instance})}):W.jsxs("div",{className:"rf-p-4",children:[W.jsxs("div",{className:"rf-mb-4",children:[W.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:r.solverName}),W.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",r.componentName]})]}),s.error&&W.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:W.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),W.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[W.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:W.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),W.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:W.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)})})]})]}):W.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:W.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},P3t=({errorMessage:t,errorStack:e,circuitJsonErrors:n})=>{Z.useEffect(()=>{if(t){const o=new Error(t);e&&(o.stack=e);try{t9.captureException(o)}catch{}}},[t,e]),Z.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{t9.captureException(i,{error_type:o.type})}catch{}}},[n])},gSo=t=>{Z.useEffect(()=>{try{BDt(t)}catch{}},[t.source,t.component,t.isWebEmbedded,t.activeTab])},v3t="0.0.2156",pSo={version:v3t},fve={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},yve=new Map,Qte=t=>{const e=yve.get(t);return e?Object.fromEntries(Object.entries(e.stores).map(([n,o])=>[n,o.getState()])):{}},fSo=(t,e,n)=>{if(t===void 0)return{type:"untracked",connection:e.connect(n)};const o=yve.get(n.name);if(o)return{type:"tracked",store:t,...o};const i={connection:e.connect(n),stores:{}};return yve.set(n.name,i),{type:"tracked",store:t,...i}},B3t=(t,e={})=>(n,o,i)=>{const{enabled:r,anonymousActionType:s,store:a,...c}=e;let l;try{l=(r??(fve?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!l)return(fve?"production":void 0)!=="production"&&r&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),t(n,o,i);const{connection:A,...u}=fSo(a,l,c);let d=!0;i.setState=(m,p,g)=>{const f=n(m,p);if(!d)return f;const y=g===void 0?{type:s||"anonymous"}:typeof g=="string"?{type:g}:g;return a===void 0?(A?.send(y,o()),f):(A?.send({...y,type:`${a}/${y.type}`},{...Qte(c.name),[a]:i.getState()}),f)};const _=(...m)=>{const p=d;d=!1,n(...m),d=p},h=t(i.setState,o,i);if(u.type==="untracked"?A?.init(h):(u.stores[u.store]=i,A?.init(Object.fromEntries(Object.entries(u.stores).map(([m,p])=>[m,m===u.store?h:p.getState()])))),i.dispatchFromDevtools&&typeof i.dispatch=="function"){let m=!1;const p=i.dispatch;i.dispatch=(...g)=>{(fve?"production":void 0)!=="production"&&g[0].type==="__setState"&&!m&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),m=!0),p(...g)}}return A.subscribe(m=>{var p;switch(m.type){case"ACTION":if(typeof m.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return Cve(m.payload,g=>{if(g.type==="__setState"){if(a===void 0){_(g.state);return}Object.keys(g.state).length!==1&&console.error(`
|
|
5794
5794
|
[zustand devtools middleware] Unsupported __setState action format.
|
|
5795
5795
|
When using 'store' option in devtools(), the 'state' should have only one key, which is a value of 'store' that was passed in devtools(),
|
|
5796
5796
|
and value of this only key should be a state object. Example: { "type": "__setState", "state": { "abc123Store": { "foo": "bar" } } }
|
|
@@ -5871,4 +5871,4 @@ Please report this to https://github.com/markedjs/marked.`,t){const o="<p>An err
|
|
|
5871
5871
|
rf-max-h-[90vh] rf-overflow-y-auto
|
|
5872
5872
|
`,children:W.jsx("div",{className:"rf-relative rf-w-full",children:n==="initial"&&W.jsx(Xvo,{onCancel:e,packageReleaseId:r??"",signIn:s??(()=>{}),isLoggedIn:a})})})})}),tBo=({isOpen:t,onClose:e,stage:n,setStage:o,signIn:i,isLoggedIn:r})=>{const s=dE(a=>a.circuitJson);return W.jsx(eBo,{signIn:i,isOpen:t,onClose:e,stage:n,setStage:o,circuitJson:s,isLoggedIn:r??!1})},nBo=()=>{const[t,e]=Z.useState(!1),[n,o]=Z.useState("initial");return{isOpen:t,stage:n,open:()=>e(!0),close:()=>{e(!1),o("initial")},setStage:o,OrderDialog:tBo}};async function hBt(){const t=await fetch(`${tS}/files/list`),{file_list:e}=await t.json(),n=new Map;for(const o of e){const r=await(await fetch(`${tS}/files/get?file_path=${encodeURIComponent(o.file_path)}`)).json();(r.file?.text_content||r.file?.binary_content_b64)&&n.set(o.file_path,{text_content:r.file.text_content,binary_content_b64:r.file.binary_content_b64})}return n}const oBo="https://api.tscircuit.com/bug_reports/view?bug_report_id=",iBo=t=>`${oBo}${t}`,rBo=t=>{const[e,n]=Z.useState(!1),[o,i]=Z.useState(!1),[r,s]=Z.useState(null),[a,c]=Z.useState(null),[l,A]=Z.useState([]),u=Z.useRef(null),[d,_]=Z.useState(null),[h,m]=Z.useState(0),p=t?.onLoginRequired,g=Z.useMemo(()=>HU()?!0:typeof document>"u"?!1:document.cookie.split(";").some(E=>E.trim().startsWith("session=")),[e]);Z.useEffect(()=>{if(e&&!d&&u.current){const E=typeof window<"u"?window.__TSCIRCUIT_LAST_EXECUTION_ERROR:void 0;E&&(u.current.value=`I'm getting this execution error:
|
|
5873
5873
|
|
|
5874
|
-
${E}`)}},[e,d]),Z.useEffect(()=>{e&&!d&&hBt().then(E=>{m(E.size)}).catch(E=>{console.error("Failed to fetch file count",E),m(0)})},[e,d]);const f=Z.useCallback(()=>{s(null),_(null),c(null),A([]),u.current&&(u.current.value=""),n(!0)},[]),y=Z.useCallback(()=>{n(!1)},[]),C=Z.useCallback(async()=>{i(!0),s(null),c(null),A([]);const E=IB(),b=u.current?.value||"";try{const P=await hBt();if(P.size===0){Js.error("No project files available to include in the bug report"),i(!1);return}const w=new Date(Date.now()+1440*60*1e3).toISOString(),k=(await E.post("bug_reports/create",{json:{text:b.trim()||void 0,is_auto_deleted:!0,delete_at:w}}).json()).bug_report.bug_report_id,R=Array.from(P.entries()),O=[];for(let U=0;U<R.length;U++){const[K,X]=R[U];c({current:U+1,total:R.length,currentFile:K});try{const $={bug_report_id:k,file_path:K};X.text_content&&($.content_text=X.text_content),X.binary_content_b64&&($.content_base64=X.binary_content_b64),await E.post("bug_reports/upload_file",{json:$})}catch($){const oe=$ instanceof CB?`HTTP ${$.response.status}`:$ instanceof Error?$.message:"Upload failed";O.push({filePath:K,message:oe}),A([...O])}}c(null);const F=iBo(k);_({bugReportUrl:F})}catch(P){if(console.error("Failed to submit bug report",P),P instanceof CB)if(P.response.status===401)if(g){const w="Your session has expired. Please sign in again to continue.";s(w),Js.error(w),p&&(y(),p())}else{const w="You must be logged in to report a bug. Please sign in via cli and try again.";s(w),Js.error(w),setTimeout(()=>{p&&(y(),p())},1e3)}else{const w=`Failed to submit bug report (${P.response.status})`;s(w),Js.error(w)}else if(P instanceof Error)s(P.message),Js.error(P.message);else{const w="Failed to submit bug report";s(w),Js.error(w)}}finally{i(!1)}},[g,p]);return{BugReportDialog:Z.useMemo(()=>{const E=a?Math.round(a.current/a.total*100):0;return W.jsx(nvt,{open:e,onOpenChange:b=>{b?(s(null),_(null),c(null),A([]),n(!0)):o||y()},children:W.jsxs(Mve,{children:[W.jsxs(wve,{children:[W.jsx(Qve,{children:d?"Bug Report Created":"Report Bug"}),W.jsx(Tve,{asChild:!0,children:d?W.jsxs("div",{className:"rf-text-left rf-space-y-3 rf-text-sm",children:[W.jsx("p",{children:"Bug report created successfully."}),l.length>0&&W.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:[W.jsxs("p",{className:"rf-text-red-700 rf-font-medium rf-text-xs rf-mb-1",children:[l.length," file(s) failed:"]}),l.map((b,P)=>W.jsxs("div",{className:"rf-text-red-600 rf-text-xs rf-mb-0.5",title:`${b.filePath}: ${b.message}`,children:[W.jsx("span",{className:"rf-font-medium rf-break-all",children:b.filePath.split("/").pop()}),W.jsx("span",{className:"rf-text-red-500 rf-block rf-truncate",children:b.message})]},P))]}),W.jsx("div",{children:W.jsx("a",{className:"rf-text-blue-600 hover:rf-underline",href:d.bugReportUrl,target:"_blank",rel:"noreferrer",children:"View bug report"})}),W.jsxs("p",{children:["Please share this link privately with tscircuit staff so we can help debug. Join the",W.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"}),"."]})]}):W.jsx("div",{className:"rf-text-left rf-space-y-3 rf-text-sm",children:a?W.jsxs("div",{className:"rf-space-y-2 rf-overflow-hidden",children:[W.jsxs("div",{className:"rf-flex rf-justify-between rf-text-xs",children:[W.jsx("span",{children:"Uploading files..."}),W.jsxs("span",{children:[a.current,"/",a.total]})]}),W.jsx("div",{className:"rf-w-full rf-h-2 rf-bg-gray-200 rf-rounded-full rf-overflow-hidden",children:W.jsx("div",{className:"rf-h-full rf-bg-blue-500 rf-transition-all rf-duration-150",style:{width:`${E}%`}})}),W.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&&W.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((b,P)=>W.jsxs("div",{className:"rf-text-red-600 rf-text-xs rf-mb-0.5",title:`${b.filePath}: ${b.message}`,children:[W.jsx("span",{className:"rf-font-medium rf-break-all",children:b.filePath.split("/").pop()}),W.jsx("span",{className:"rf-text-red-500 rf-block rf-truncate",children:b.message})]},P))})]}):W.jsxs(W.Fragment,{children:[W.jsxs("p",{children:["Reporting a bug will upload your entire project",h>0?` (${h} file${h===1?"":"s"})`:""," ","to tscircuit support."]}),W.jsxs("div",{className:"rf-space-y-2",children:[W.jsx("label",{htmlFor:"bug-description",className:"rf-block rf-font-medium",children:"Description (optional)"}),W.jsx("textarea",{ref:u,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})]}),W.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",W.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"}),"."]}),!g&&W.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."}),r&&W.jsx("p",{className:"rf-text-red-600",children:r})]})})})]}),W.jsx(Dve,{children:d?W.jsx("button",{type:"button",className:DQ(),onClick:()=>{y()},children:"Close"}):W.jsxs(W.Fragment,{children:[W.jsx(Nve,{disabled:o,onClick:()=>{o||y()},children:"Cancel"}),!g&&p?W.jsx("button",{type:"button",className:DQ(),onClick:b=>{b.preventDefault(),y(),p()},children:"Sign In"}):W.jsx("button",{type:"button",className:EI(DQ(),o&&"rf-opacity-70 rf-cursor-not-allowed"),disabled:o,onClick:b=>{b.preventDefault(),C()},children:o?"Reporting...":"Upload & Report"})]})})]})},"bug-report-dialog")},[e,o,y,r,d,h,g,C,p,a,l]),openBugReportDialog:f}};function sBo({open:t,onOpenChange:e,onExport:n}){const[o,i]=Z.useState(!1),r=()=>{n({includeSilkscreen:o}),e(!1)},s=()=>{e(!1)};return W.jsx(OO,{open:t,onOpenChange:e,children:W.jsxs(uT,{children:[W.jsxs(dT,{children:[W.jsx(hT,{children:"LightBurn Export Options"}),W.jsx(UO,{children:"Configure export settings for PCB laser ablation with LightBurn"})]}),W.jsx("div",{className:"rf-flex rf-flex-col rf-gap-4 rf-py-4",children:W.jsxs("div",{className:"rf-flex rf-items-center rf-space-x-2",children:[W.jsx(FO,{id:"includeSilkscreen",checked:o,onCheckedChange:a=>i(a===!0)}),W.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"})]})}),W.jsxs(GO,{children:[W.jsx(du,{variant:"outline",onClick:s,children:"Cancel"}),W.jsx(du,{onClick:r,children:"Export"})]})]})})}const aBo=/#(\d+)/,cBo=t=>{const e=t.match(aBo);if(!e)return null;const n=Number.parseInt(e[1],10);return Number.isFinite(n)?n:null},lBo=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},ABo=t=>{if(!t)return null;let e=null,n=-1,o=-1;for(const[i,r]of Object.entries(t)){const s=cBo(i),a=lBo(r.createdAt);if(s!==null){s>n&&(n=s,e={key:i,value:r});continue}if(n===-1){if(a!==null&&a>o){o=a,e={key:i,value:r};continue}e||(e={key:i,value:r})}}return e},uBo=t=>{const e=xve(Be=>Be.lastRunEvalVersion),n=dE(Be=>Be.currentMainComponentPath),[o,i]=Z.useState(null),[r,s]=Z.useState(!1),[a,c]=Z.useState(!0),[l,A]=Z.useState(!1),[u,d]=Z.useState(null),[_,h]=Z.useState(null),[m,p]=Z.useState(!1),[g,f]=Z.useState(null),[y,C]=Z.useState(null),[I,E]=Z.useState(!1),[b,P]=Z.useState(!1),[w,M]=Z.useState(!1),[k,R]=Z.useState(null),O=nBo(),F=dE(Be=>Be.pushEvent),U=dE(Be=>Be.recentEvents),K=Z.useMemo(()=>Date.now(),[]);PSo(Be=>{if(!(new Date(Be.created_at).valueOf()<K+500)){if(Be.event_type==="FILE_UPDATED"){s(!0);return}if(Be.event_type==="SNIPPET_SAVED"){s(!1),c(!1),f("Snippet saved successfully."),E(!1);return}Be.event_type==="REQUEST_EXPORT"&&(P(!0),f("Export processing..."),E(!1)),Be.event_type==="EXPORT_CREATED"&&(f(`Export created: ${Be.exportFilePath}`),E(!1),P(!1))}}),Z.useEffect(()=>{if(!l||u===null)return;const Be=U.filter(pe=>new Date(pe.created_at).valueOf()>u),ge=Be.find(pe=>pe.event_type==="FAILED_TO_SAVE_SNIPPET"),Pe=Be.find(pe=>pe.event_type==="SNIPPET_SAVED");ge&&(A(!1),d(null),C(ge.message??"Failed to save snippet. See console for error."),console.error(ge.message),E(!0),ge.error_code==="SNIPPET_UNSET"&&ge.available_snippet_names&&(h(ge.available_snippet_names),p(!0))),Pe&&(A(!1),d(null),f("Snippet saved successfully."),E(!1))},[U,l]);const X=async()=>{A(!0),d(Date.now()),f(null),E(!1),await F({event_type:"REQUEST_TO_SAVE_SNIPPET",snippet_name:o})},oe=dE(Be=>Be.circuitJson)??t.circuitJson,[Ae,ne]=Z.useState(!1),[re,ce]=Z.useState(!1),{BugReportDialog:ae,openBugReportDialog:_e}=rBo({onLoginRequired:t.onLoginRequired}),ye=async Be=>{k&&(await Qvt({circuitJson:k.circuitJson,projectName:k.projectName,options:Be}),R(null))},ve=Z.useMemo(()=>ABo(t.autoroutingLog),[t.autoroutingLog]);return W.jsxs(W.Fragment,{children:[W.jsxs("div",{className:"rf-flex rf-items-center rf-gap-1 rf-flex-shrink-0",children:[W.jsxs(lee,{children:[W.jsx(Aee,{asChild:!0,children:W.jsx("div",{className:"rf-whitespace-nowrap rf-text-xs font-medium rf-p-2 rf-mx-1 rf-cursor-pointer rf-relative",children:"File"})}),W.jsxs(zF,{className:"rf-z-[101]",children:[!t.isWebEmbedded&&W.jsxs(W.Fragment,{children:[W.jsx(n_,{className:"rf-text-xs",onSelect:X,disabled:l,children:l?"Saving...":"Push"}),parseInt(window.location.port)>5e3&&W.jsx(n_,{className:"rf-text-xs",onSelect:()=>{O.open()},children:"Order"}),W.jsx(n_,{className:"rf-text-xs",onSelect:()=>ne(!0),disabled:l,children:"Import"}),W.jsx(n_,{className:"rf-text-xs",onSelect:()=>{if(!HU()){Js.error("Requires tscircuit token");return}ce(!0)},children:"AI Review"})]}),!t.isWebEmbedded&&t.onLoginRequired&&W.jsx(n_,{className:"rf-text-xs",onSelect:()=>{t.onLoginRequired?.()},children:"Sign In"}),!t.isWebEmbedded&&W.jsxs(UF,{children:[W.jsx(GQ,{className:"rf-text-xs",children:"Report Bug"}),W.jsx(GF,{children:W.jsxs(UQ,{children:[W.jsx(n_,{className:"rf-text-xs",onSelect:()=>{_e()},children:"Report Entire Circuit"}),W.jsx(n_,{className:"rf-text-xs",disabled:!ve||!t.onReportAutoroutingLog,onSelect:()=>{!ve||!t.onReportAutoroutingLog||t.onReportAutoroutingLog(ve.key,{simpleRouteJson:ve.value.simpleRouteJson})},children:"Report Autorouter Bug"})]})})]}),W.jsxs(UF,{children:[W.jsx(GQ,{className:"rf-text-xs",disabled:b,children:b?"Exporting...":"Export"}),W.jsx(GF,{children:W.jsx(UQ,{children:P3o.map((Be,ge)=>W.jsx(n_,{onSelect:()=>{if(!oe){Js.error("No Circuit JSON to export");return}let Pe="Untitled";if(n){const ke=n.split("/").pop();ke&&(Pe=ke.replace(/\.[^.]+$/,""))}const pe=t.projectName??o??Pe,Ge=ve?.value.simpleRouteJson;if(Be.name==="LightBurn"){R({circuitJson:oe,projectName:pe}),M(!0);return}v3o({exportName:Be.name,circuitJson:oe,simpleRouteJson:Ge,projectName:pe?.replace(/\.(board|circuit)$/,"")})},disabled:b||Be.name==="Simple Route JSON"&&!ve,children:W.jsx("span",{className:"rf-text-xs",children:Be.name})},ge))})})]}),!t.isWebEmbedded&&W.jsxs(UF,{children:[W.jsx(GQ,{className:"rf-text-xs",children:"Advanced"}),W.jsx(GF,{children:W.jsxs(UQ,{children:[W.jsx(n_,{className:"rf-flex rf-items-center rf-gap-2",children:W.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[W.jsx(FO,{id:"load-latest-eval",checked:t.shouldLoadLatestEval,onCheckedChange:Be=>{t.onChangeShouldLoadLatestEval?.(Be===!0)}}),W.jsx("label",{htmlFor:"load-latest-eval",className:"rf-text-xs rf-cursor-pointer",children:"Force Latest @tscircuit/eval"})]})}),e&&W.jsx(n_,{className:"rf-flex rf-items-center rf-gap-2",children:W.jsx("div",{className:"rf-flex rf-items-center rf-gap-2",children:W.jsxs("span",{className:"rf-text-xs",children:["@tscircuit/eval@",e]})})}),W.jsx(n_,{className:"rf-flex rf-items-center rf-gap-2",children:W.jsx("div",{className:"rf-flex rf-items-center rf-gap-2",children:W.jsxs("span",{className:"rf-text-xs",children:["@tscircuit/runframe@",pSo.version]})})}),W.jsx(n_,{className:"rf-flex rf-items-center rf-gap-2",onClick:()=>{window.open("/api/admin","_blank")},children:W.jsx("div",{className:"rf-flex rf-items-center rf-gap-2",children:W.jsx("span",{className:"rf-text-xs",children:"CLI Admin Panel"})})})]})})]})]}),W.jsx(nvt,{open:I,onOpenChange:E,children:W.jsxs(Mve,{children:[W.jsxs(wve,{children:[W.jsx(Qve,{children:"Error Saving Snippet"}),W.jsx(Tve,{children:y})]}),W.jsx(Dve,{children:W.jsx(Nve,{onClick:()=>E(!1),children:"Dismiss"})})]})}),W.jsx(SSo,{snippetNames:_??[],onSelect:async Be=>{A(!0),d(Date.now()),i(Be),await F({event_type:"REQUEST_TO_SAVE_SNIPPET",snippet_name:Be}),p(!1)},onCancel:()=>p(!1),isOpen:m})]}),W.jsxs(lee,{children:[W.jsx(Aee,{asChild:!0,children:W.jsx("div",{className:"rf-whitespace-nowrap rf-text-xs font-medium rf-p-2 rf-mx-1 rf-cursor-pointer rf-relative",children:"View"})}),W.jsx(zF,{className:"rf-z-[104]",children:W.jsxs(UF,{children:[W.jsx(GQ,{className:"rf-text-xs",children:"Schematic"}),W.jsx(GF,{children:W.jsxs(UQ,{children:[W.jsx(n_,{className:"rf-flex rf-items-center rf-gap-2",onSelect:Be=>Be.preventDefault(),children:W.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[W.jsx(FO,{id:"show-schematic-ports",checked:t.showSchematicPorts,onCheckedChange:Be=>{t.onChangeShowSchematicPorts?.(Be===!0)}}),W.jsx("label",{htmlFor:"show-schematic-ports",className:"rf-text-xs rf-cursor-pointer",children:"Show Schematic Ports"})]})}),W.jsx(n_,{className:"rf-flex rf-items-center rf-gap-2",onSelect:Be=>Be.preventDefault(),children:W.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[W.jsx(FO,{id:"show-schematic-grid",checked:t.showSchematicDebugGrid,onCheckedChange:Be=>{t.onChangeShowSchematicDebugGrid?.(Be===!0)}}),W.jsx("label",{htmlFor:"show-schematic-grid",className:"rf-text-xs rf-cursor-pointer",children:"Show Schematic Grid"})]})})]})})]})})]})]}),ae,W.jsx(sBo,{open:w,onOpenChange:M,onExport:ye}),W.jsx(wvt,{isOpen:Ae,onClose:()=>ne(!1)}),W.jsx(dvo,{isOpen:re,onClose:()=>ce(!1),packageName:o}),W.jsx(Lft,{position:"top-center",reverseOrder:!1,containerStyle:{zIndex:1e5},toastOptions:{className:"rf-break-all",style:{zIndex:1e5}}}),W.jsx(O.OrderDialog,{isOpen:O.isOpen,onClose:O.close,stage:O.stage,setStage:O.setStage})]})};var dBo=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),hBo="VisuallyHidden",_Bt=Z.forwardRef((t,e)=>W.jsx(lA.span,{...t,ref:e,style:{...dBo,...t.style}}));_Bt.displayName=hBo;var _Bo=_Bt,[cne]=F5("Tooltip",[XZ]),lne=XZ(),mBt="TooltipProvider",mBo=700,fBe="tooltip.open",[gBo,yBe]=cne(mBt),gBt=t=>{const{__scopeTooltip:e,delayDuration:n=mBo,skipDelayDuration:o=300,disableHoverableContent:i=!1,children:r}=t,s=Z.useRef(!0),a=Z.useRef(!1),c=Z.useRef(0);return Z.useEffect(()=>{const l=c.current;return()=>window.clearTimeout(l)},[]),W.jsx(gBo,{scope:e,isOpenDelayedRef:s,delayDuration:n,onOpen:Z.useCallback(()=>{o<=0||(window.clearTimeout(c.current),s.current=!1)},[o]),onClose:Z.useCallback(()=>{o<=0||(window.clearTimeout(c.current),c.current=window.setTimeout(()=>s.current=!0,o))},[o]),isPointerInTransitRef:a,onPointerInTransitChange:Z.useCallback(l=>{a.current=l},[]),disableHoverableContent:i,children:r})};gBt.displayName=mBt;var qO="Tooltip",[pBo,Ane]=cne(qO),pBt=t=>{const{__scopeTooltip:e,children:n,open:o,defaultOpen:i,onOpenChange:r,disableHoverableContent:s,delayDuration:a}=t,c=yBe(qO,t.__scopeTooltip),l=lne(e),[A,u]=Z.useState(null),d=G5(),_=Z.useRef(0),h=s??c.disableHoverableContent,m=a??c.delayDuration,p=Z.useRef(!1),[g,f]=aB({prop:o,defaultProp:i??!1,onChange:b=>{b?(c.onOpen(),document.dispatchEvent(new CustomEvent(fBe))):c.onClose(),r?.(b)},caller:qO}),y=Z.useMemo(()=>g?p.current?"delayed-open":"instant-open":"closed",[g]),C=Z.useCallback(()=>{window.clearTimeout(_.current),_.current=0,p.current=!1,f(!0)},[f]),I=Z.useCallback(()=>{window.clearTimeout(_.current),_.current=0,f(!1)},[f]),E=Z.useCallback(()=>{window.clearTimeout(_.current),_.current=window.setTimeout(()=>{p.current=!0,f(!0),_.current=0},m)},[m,f]);return Z.useEffect(()=>()=>{_.current&&(window.clearTimeout(_.current),_.current=0)},[]),W.jsx(iPe,{...l,children:W.jsx(pBo,{scope:e,contentId:d,open:g,stateAttribute:y,trigger:A,onTriggerChange:u,onTriggerEnter:Z.useCallback(()=>{c.isOpenDelayedRef.current?E():C()},[c.isOpenDelayedRef,E,C]),onTriggerLeave:Z.useCallback(()=>{h?I():(window.clearTimeout(_.current),_.current=0)},[I,h]),onOpen:C,onClose:I,disableHoverableContent:h,children:n})})};pBt.displayName=qO;var CBe="TooltipTrigger",fBt=Z.forwardRef((t,e)=>{const{__scopeTooltip:n,...o}=t,i=Ane(CBe,n),r=yBe(CBe,n),s=lne(n),a=Z.useRef(null),c=d0(e,a,i.onTriggerChange),l=Z.useRef(!1),A=Z.useRef(!1),u=Z.useCallback(()=>l.current=!1,[]);return Z.useEffect(()=>()=>document.removeEventListener("pointerup",u),[u]),W.jsx(GIt,{asChild:!0,...s,children:W.jsx(lA.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...o,ref:c,onPointerMove:Kr(t.onPointerMove,d=>{d.pointerType!=="touch"&&!A.current&&!r.isPointerInTransitRef.current&&(i.onTriggerEnter(),A.current=!0)}),onPointerLeave:Kr(t.onPointerLeave,()=>{i.onTriggerLeave(),A.current=!1}),onPointerDown:Kr(t.onPointerDown,()=>{i.open&&i.onClose(),l.current=!0,document.addEventListener("pointerup",u,{once:!0})}),onFocus:Kr(t.onFocus,()=>{l.current||i.onOpen()}),onBlur:Kr(t.onBlur,i.onClose),onClick:Kr(t.onClick,i.onClose)})})});fBt.displayName=CBe;var fBo="TooltipPortal",[YMo,yBo]=cne(fBo,{forceMount:void 0}),mT="TooltipContent",yBt=Z.forwardRef((t,e)=>{const n=yBo(mT,t.__scopeTooltip),{forceMount:o=n.forceMount,side:i="top",...r}=t,s=Ane(mT,t.__scopeTooltip);return W.jsx(II,{present:o||s.open,children:s.disableHoverableContent?W.jsx(CBt,{side:i,...r,ref:e}):W.jsx(CBo,{side:i,...r,ref:e})})}),CBo=Z.forwardRef((t,e)=>{const n=Ane(mT,t.__scopeTooltip),o=yBe(mT,t.__scopeTooltip),i=Z.useRef(null),r=d0(e,i),[s,a]=Z.useState(null),{trigger:c,onClose:l}=n,A=i.current,{onPointerInTransitChange:u}=o,d=Z.useCallback(()=>{a(null),u(!1)},[u]),_=Z.useCallback((h,m)=>{const p=h.currentTarget,g={x:h.clientX,y:h.clientY},f=SBo(g,p.getBoundingClientRect()),y=PBo(g,f),C=vBo(m.getBoundingClientRect()),I=MBo([...y,...C]);a(I),u(!0)},[u]);return Z.useEffect(()=>()=>d(),[d]),Z.useEffect(()=>{if(c&&A){const h=p=>_(p,A),m=p=>_(p,c);return c.addEventListener("pointerleave",h),A.addEventListener("pointerleave",m),()=>{c.removeEventListener("pointerleave",h),A.removeEventListener("pointerleave",m)}}},[c,A,_,d]),Z.useEffect(()=>{if(s){const h=m=>{const p=m.target,g={x:m.clientX,y:m.clientY},f=c?.contains(p)||A?.contains(p),y=!BBo(g,s);f?d():y&&(d(),l())};return document.addEventListener("pointermove",h),()=>document.removeEventListener("pointermove",h)}},[c,A,s,l,d]),W.jsx(CBt,{...t,ref:r})}),[xBo,IBo]=cne(qO,{isInside:!1}),EBo=xMt("TooltipContent"),CBt=Z.forwardRef((t,e)=>{const{__scopeTooltip:n,children:o,"aria-label":i,onEscapeKeyDown:r,onPointerDownOutside:s,...a}=t,c=Ane(mT,n),l=lne(n),{onClose:A}=c;return Z.useEffect(()=>(document.addEventListener(fBe,A),()=>document.removeEventListener(fBe,A)),[A]),Z.useEffect(()=>{if(c.trigger){const u=d=>{d.target instanceof Node&&d.target.contains(c.trigger)&&A()};return window.addEventListener("scroll",u,{capture:!0}),()=>window.removeEventListener("scroll",u,{capture:!0})}},[c.trigger,A]),W.jsx(HZ,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:r,onPointerDownOutside:s,onFocusOutside:u=>u.preventDefault(),onDismiss:A,children:W.jsxs(UIt,{"data-state":c.stateAttribute,...l,...a,ref:e,style:{...a.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[W.jsx(EBo,{children:o}),W.jsx(xBo,{scope:n,isInside:!0,children:W.jsx(_Bo,{id:c.contentId,role:"tooltip",children:i||o})})]})})});yBt.displayName=mT;var xBt="TooltipArrow",bBo=Z.forwardRef((t,e)=>{const{__scopeTooltip:n,...o}=t,i=lne(n);return IBo(xBt,n).isInside?null:W.jsx(zIt,{...i,...o,ref:e})});bBo.displayName=xBt;function SBo(t,e){const n=Math.abs(e.top-t.y),o=Math.abs(e.bottom-t.y),i=Math.abs(e.right-t.x),r=Math.abs(e.left-t.x);switch(Math.min(n,o,i,r)){case r:return"left";case i:return"right";case n:return"top";case o:return"bottom";default:throw new Error("unreachable")}}function PBo(t,e,n=5){const o=[];switch(e){case"top":o.push({x:t.x-n,y:t.y+n},{x:t.x+n,y:t.y+n});break;case"bottom":o.push({x:t.x-n,y:t.y-n},{x:t.x+n,y:t.y-n});break;case"left":o.push({x:t.x+n,y:t.y-n},{x:t.x+n,y:t.y+n});break;case"right":o.push({x:t.x-n,y:t.y-n},{x:t.x-n,y:t.y+n});break}return o}function vBo(t){const{top:e,right:n,bottom:o,left:i}=t;return[{x:i,y:e},{x:n,y:e},{x:n,y:o},{x:i,y:o}]}function BBo(t,e){const{x:n,y:o}=t;let i=!1;for(let r=0,s=e.length-1;r<e.length;s=r++){const a=e[r],c=e[s],l=a.x,A=a.y,u=c.x,d=c.y;A>o!=d>o&&n<(u-l)*(o-A)/(d-A)+l&&(i=!i)}return i}function MBo(t){const e=t.slice();return e.sort((n,o)=>n.x<o.x?-1:n.x>o.x?1:n.y<o.y?-1:n.y>o.y?1:0),wBo(e)}function wBo(t){if(t.length<=1)return t.slice();const e=[];for(let o=0;o<t.length;o++){const i=t[o];for(;e.length>=2;){const r=e[e.length-1],s=e[e.length-2];if((r.x-s.x)*(i.y-s.y)>=(r.y-s.y)*(i.x-s.x))e.pop();else break}e.push(i)}e.pop();const n=[];for(let o=t.length-1;o>=0;o--){const i=t[o];for(;n.length>=2;){const r=n[n.length-1],s=n[n.length-2];if((r.x-s.x)*(i.y-s.y)>=(r.y-s.y)*(i.x-s.x))n.pop();else break}n.push(i)}return n.pop(),e.length===1&&n.length===1&&e[0].x===n[0].x&&e[0].y===n[0].y?e:e.concat(n)}var DBo=gBt,QBo=pBt,TBo=fBt,IBt=yBt;const NBo=DBo,RBo=QBo,kBo=TBo,EBt=Z.forwardRef(({className:t,sideOffset:e=4,...n},o)=>W.jsx(IBt,{ref:o,sideOffset:e,className:qr("z-50 overflow-hidden rounded-md bg-slate-900 px-3 py-1.5 text-xs text-slate-50 animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 dark:bg-slate-50 dark:text-slate-900",t),...n}));EBt.displayName=IBt.displayName;const HBo="24b58135-86c7-4e4b-bf6e-cca862bc4b26",bBt="runframe-crisp-chat-script",LBo="tscircuit.com",$O=t=>{window.$crisp=window.$crisp||[],window.$crisp.push(t)},FBo=()=>{if(window.$crisp=window.$crisp||[],window.CRISP_WEBSITE_ID=HBo,window.__RUNFRAME_CRISP_CONFIGURED__||(window.__RUNFRAME_CRISP_CONFIGURED__=!0,$O(["do","chat:hide"]),$O(["on","chat:closed",()=>$O(["do","chat:hide"])])),!document.getElementById(bBt)){const t=document.createElement("script");t.id=bBt,t.src="https://client.crisp.chat/l.js",t.async=!0,document.head.appendChild(t)}},OBo=()=>{FBo(),$O(["do","chat:show"]),$O(["do","chat:open"])},GBo=({isCli:t,hostname:e=typeof window<"u"?window.location.hostname:void 0}={})=>t?!0:e?e.toLowerCase()===LBo:!1,UBo=()=>W.jsx(NBo,{children:W.jsxs(RBo,{children:[W.jsx(kBo,{asChild:!0,children:W.jsx(du,{type:"button",variant:"ghost",size:"icon","aria-label":"Give feeback",onClick:OBo,className:"rf-h-8 rf-w-8",children:W.jsx(huo,{className:"rf-h-4 rf-w-4 rf-text-gray-500"})})}),W.jsx(EBt,{side:"bottom",children:"Give feeback"})]})}),zBo=["assembly","pinout","analog_simulation","bom","circuit_json","errors","render_log","solvers"],xBe=t=>t instanceof Error?t.message:"An unknown error occurred",VBo=({code:t,fsMap:e,onRunClicked:n=void 0,errorMessage:o,errorStack:i,circuitJson:r,autoroutingGraphics:s,showRightHeaderContent:a=!0,showCodeTab:c=!1,codeTabContent:l,showJsonTab:A=!0,showRenderLogTab:u=!0,onActiveTabChange:d,renderLog:_,showImportAndFormatButtons:h=!0,className:m,headerClassName:p,leftHeaderContent:g,readOnly:f,isStreaming:y,autoroutingLog:C,onReportAutoroutingLog:I,isRunningCode:E,hasCodeChangedSinceLastRun:b,onEditEvent:P,editEvents:w,defaultActiveTab:M,defaultTab:k,availableTabs:R,autoRotate3dViewerDisabled:O,showSchematicDebugGrid:F=!1,showSchematicPorts:U=!1,onChangeShowSchematicDebugGrid:K,onChangeShowSchematicPorts:X,showToggleFullScreen:$=!0,defaultToFullScreen:oe=!1,activeEffectName:Ae,allowSelectingVersion:ne=!0,showFileMenu:re=!1,isWebEmbedded:ce=!1,isCli:ae=!1,projectName:_e,schematicSvgOptions:ye,onRerunWithDebug:ve,solverEvents:Be,onPcbBoundsSelected:ge})=>{x3t();const{versions:Pe,latestVersion:pe,lastRunEvalVersion:Ge,search:ke,setSearch:We,selectVersion:fe}=ySo(ne),qe=Z.useMemo(()=>r?r.filter(it=>it&&"error_type"in it||it.type.includes("error")):null,[r]),Oe=Z.useMemo(()=>r?r.filter(it=>it&&"warning_type"in it||it.type.includes("warning")):null,[r]),Qe=Z.useMemo(()=>r?r.some(it=>it.type==="schematic_group"):!0,[r]),Ue=Z.useMemo(()=>r?.some(it=>it.type==="pcb_panel"),[r]),Ne=Z.useMemo(()=>{if(!r||!E||qe?.length)return!1;const it=r.some(kt=>kt.type==="simulation_experiment"),xt=r.some(kt=>kt.type==="simulation_transient_voltage_graph");return it&&!xt},[r,qe,E]),be=Z.useMemo(()=>qe?.find(it=>it.type.startsWith("simulation_")),[qe]);P3t({errorMessage:o,errorStack:i,circuitJsonErrors:qe});const Fe=k??R?.[0]??"pcb",[Me,Ke]=I3t("runframe-active-tab",M??Fe,M);gSo({source:"runframe",component:"CircuitJsonPreview",isWebEmbedded:ce,activeTab:Me});const[Xe,st]=Z.useState(null),[at,ut]=Z.useState(oe),[ct,yt]=Z.useState(F),[vt,pt]=Z.useState(U),Qt=K?F:ct,Ht=X?U:vt,un=K??yt,An=X??pt;_bo(at);const Bn=Z.useCallback(it=>{Ke(it),d?.(it)},[d,Ke]),xe=()=>{ut(!at)};Z.useEffect(()=>{o&&(Me!=="errors"&&st(Me),Bn("errors"))},[o]),Z.useEffect(()=>{(Me==="code"||Me==="errors")&&r&&!o&&Bn(Xe??M??k??R?.[0]??"pcb")},[r]);const ot=Z.useCallback(it=>{window.TSCIRCUIT_3D_OBJECT_REF=it===null?void 0:it},[]);return W.jsx("div",{className:qr("flex flex-col relative rf-overflow-x-hidden rf-h-full",m),children:W.jsx("div",{className:qr("rf-md:sticky rf-md:top-2 rf-h-full",at&&"rf-fixed rf-top-0 rf-left-0 rf-w-full rf-h-full rf-bg-white rf-overflow-hidden"),children:W.jsxs(Jie,{value:Me,onValueChange:Bn,className:"rf-flex-grow rf-flex rf-flex-col rf-h-full",children:[W.jsxs("div",{className:qr("rf-flex rf-items-center rf-gap-2 rf-p-2 rf-pb-0",p),children:[g,re&&!g&&W.jsx(uBo,{isWebEmbedded:ce,circuitJson:r,projectName:_e,autoroutingLog:C,onReportAutoroutingLog:I,showSchematicDebugGrid:Qt,onChangeShowSchematicDebugGrid:un,showSchematicPorts:Ht,onChangeShowSchematicPorts:An}),(g||re)&&W.jsx("div",{className:"rf-flex-grow"}),!g&&!re&&E&&W.jsx(Z4,{className:"rf-w-4 rf-h-4 rf-animate-spin"}),!g&&!re&&W.jsx("div",{className:"rf-flex-grow"}),_&&_.progress!==1&&!o&&W.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2 rf-min-w-0 rf-max-w-xs",children:[Ae?W.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate rf-min-w-0",title:Ae,children:Ae}):_.lastRenderEvent&&W.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate rf-min-w-0",title:_.lastRenderEvent?.phase??"",children:_.lastRenderEvent?.phase??""}),W.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:W.jsx(Z4,{className:"rf-w-4 rf-h-4 rf-animate-spin"})}),W.jsxs("div",{className:"rf-text-xs rf-font-bold rf-text-gray-700 rf-tabular-nums rf-flex-shrink-0",children:[((_.progress??0)*100).toFixed(1),"%"]})]}),a&&GBo({isCli:ae})&&W.jsx(UBo,{}),a&&W.jsxs(GU,{children:[c&&W.jsx(X5,{value:"code",children:"Code"}),!R||R.includes("pcb")?W.jsxs(X5,{value:"pcb",className:"rf-whitespace-nowrap",children:[r&&W.jsx("span",{className:qr("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",b?"rf-bg-gray-500":"rf-bg-blue-500")}),"PCB"]}):null,!R||R.includes("schematic")?W.jsxs(X5,{value:"schematic",className:qr("rf-whitespace-nowrap",r&&!Qe&&"rf-opacity-50"),disabled:r?!Qe||Ue:!1,children:[r&&W.jsx("span",{className:qr("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",b?"rf-bg-gray-500":"rf-bg-blue-500")}),"Schematic"]}):null,!R||R.includes("cad")?W.jsxs(X5,{value:"cad",children:[r&&W.jsx("span",{className:qr("inline-flex items-center justify-center w-2 h-2 mr-1 text-xs font-bold text-white rounded-full",b?"rf-bg-gray-500":"rf-bg-blue-500")}),"3D"]}):null,!["pcb","cad","schematic"].includes(Me)&&W.jsx(X5,{value:Me,children:v7e(Me)}),W.jsxs(lee,{children:[W.jsx(Aee,{asChild:!0,children:W.jsxs("div",{className:"rf-whitespace-nowrap rf-p-2 rf-mr-1 rf-cursor-pointer rf-relative",children:[W.jsx(auo,{className:"rf-w-4 rf-h-4"}),(qe&&qe.length>0||o)&&W.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"})]})}),W.jsxs(zF,{className:"rf-*:text-xs rf-z-[101]",children:[zBo.filter(it=>!R||R.includes(it)).map(it=>W.jsxs(n_,{onSelect:()=>Bn(it),children:[Me!==it&&W.jsx(qxt,{className:"rf-w-3 rf-h-3 rf-opacity-30"}),Me===it&&W.jsx(HSe,{className:"rf-w-3 rf-h-3"}),W.jsx("div",{className:"rf-pr-2",children:v7e(it)}),it==="errors"&&(qe&&qe.length>0||o)&&W.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:qe?.length}),it==="solvers"&&Be&&Be.length>0&&W.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:Be.length})]},it)),W.jsx(n_,{disabled:!0,className:"rf-opacity-60 rf-cursor-default rf-select-none",children:W.jsxs("div",{className:"rf-pr-2 rf-text-xs rf-text-gray-500",children:["@tscircuit/runframe@",v3t.split(".").map((it,xt)=>xt===2?parseInt(it)+1:it).join(".")]})}),ne?W.jsxs(UF,{onOpenChange:it=>!it&&We(""),children:[W.jsx(GQ,{className:"rf-text-xs rf-opacity-60",children:W.jsxs("div",{className:"rf-pr-2 rf-text-xs rf-text-gray-500",children:["@tscircuit/eval@",Ge??pe??"latest"]})}),W.jsx(GF,{children:W.jsxs(UQ,{className:"rf-*:text-xs rf-w-40 rf-max-h-[200px] rf-overflow-y-auto",children:[W.jsx("div",{className:"rf-p-1",children:W.jsx(N3e,{value:ke,onChange:it=>We(it.target.value),placeholder:"Search...",className:"rf-h-7 rf-text-xs"})}),W.jsx(q5t,{}),W.jsx(n_,{onSelect:()=>fe(null),children:pe?`${pe} (latest)`:"latest"}),Pe.map(it=>W.jsx(n_,{onSelect:()=>fe(it),children:it},it))]})})]}):Ge&&W.jsx(n_,{disabled:!0,className:"rf-opacity-60 rf-cursor-default rf-select-none",children:W.jsxs("div",{className:"rf-pr-2 rf-text-xs rf-text-gray-500",children:["@tscircuit/eval@",Ge]})})]})]})]}),$&&W.jsx(du,{onClick:xe,variant:"ghost",children:at?W.jsx(_uo,{size:16}):W.jsx(luo,{size:16})})]}),c&&W.jsx(ff,{value:"code",className:"rf-flex-grow rf-overflow-hidden",children:W.jsx("div",{className:"rf-h-full",children:l})}),(!R||R.includes("pcb"))&&W.jsx(ff,{value:"pcb",children:W.jsx("div",{className:qr("rf-overflow-hidden",at?"rf-h-[calc(100vh-52px)]":"rf-h-full"),children:W.jsx($4,{fallbackRender:({error:it})=>W.jsx("div",{className:"rf-mt-4 rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200",children:W.jsxs("div",{className:"rf-p-4",children:[W.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-3",children:"Error loading PCB viewer"}),W.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-red-600 rf-mt-2",children:xBe(it)})]})}),children:r?W.jsx(dbo,{focusOnHover:!1,circuitJson:r,debugGraphics:s,onBoundsSelected:ge,containerClassName:qr("rf-h-full rf-w-full",at?"rf-min-h-[calc(100vh-240px)]":"rf-min-h-[620px]"),onEditEventsChanged:it=>{if(P)for(const xt of it)P(xt)}}):W.jsx(eS,{onRunClicked:n})})})}),(!R||R.includes("assembly"))&&W.jsx(ff,{value:"assembly",children:W.jsx("div",{className:qr("rf-overflow-auto",at?"rf-h-[calc(100vh-60px)]":"rf-h-full rf-min-h-[620px]"),children:W.jsx($4,{fallback:W.jsx("div",{children:"Error loading Assembly"}),children:r?W.jsx(_xo,{circuitJson:r,containerStyle:{height:"100%"},editingEnabled:!0,debugGrid:!0}):W.jsx(eS,{onRunClicked:n})})})}),(!R||R.includes("pinout"))&&W.jsx(ff,{value:"pinout",children:W.jsx("div",{className:qr("rf-overflow-auto",at?"rf-h-[calc(100vh-60px)]":"rf-h-full rf-min-h-[620px]"),children:W.jsx($4,{fallback:W.jsx("div",{children:"Error loading Pinout Viewer"}),children:r?W.jsx(mxo,{circuitJson:r,containerStyle:{height:"100%"}}):W.jsx(eS,{onRunClicked:n})})})}),(!R||R.includes("schematic"))&&W.jsx(ff,{value:"schematic",children:W.jsx("div",{className:qr("rf-overflow-auto rf-bg-white",at?"rf-h-[calc(100vh-60px)]":"rf-h-full rf-min-h-[620px]"),children:W.jsx($4,{fallbackRender:({error:it})=>W.jsx("div",{className:"rf-mt-4 rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200",children:W.jsxs("div",{className:"rf-p-4",children:[W.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-3",children:"Error loading Schematic"}),W.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-red-600 rf-mt-2",children:xBe(it)})]})}),children:r?W.jsx(Axo,{spiceSimulationEnabled:!0,circuitJson:r,containerStyle:{height:"100%"},editingEnabled:!0,onEditEvent:it=>{P?.(it)},debugGrid:Qt,showSchematicPorts:Ht,css:ye?.css,className:ye?.className}):W.jsx(eS,{onRunClicked:n})})})}),(!R||R.includes("cad"))&&W.jsx(ff,{value:"cad",children:W.jsx("div",{className:qr("rf-overflow-auto",at?"rf-h-[calc(100vh-60px)]":"rf-h-full rf-min-h-[620px]"),children:W.jsx($4,{fallbackRender:({error:it,resetErrorBoundary:xt})=>W.jsx(WAo,{error:it,resetErrorBoundary:xt}),children:r?W.jsx(YAo,{ref:ot,circuitJson:r,autoRotateDisabled:O},`cad-${at}`):W.jsx(eS,{onRunClicked:n})})})}),(!R||R.includes("analog_simulation"))&&W.jsx(ff,{value:"analog_simulation",children:W.jsx("div",{className:qr("rf-overflow-auto",at?"rf-h-[calc(100vh-60px)]":"rf-h-full rf-min-h-[620px]"),children:W.jsx($4,{fallback:W.jsx("div",{children:"Error loading Analog Simulation"}),children:r?be?W.jsx("div",{className:"rf-mt-4 rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200",children:W.jsxs("div",{className:"rf-p-4",children:[W.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-3",children:"Error running analog simulation"}),W.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-red-600 rf-mt-2",children:be.message})]})}):Ne?W.jsx("div",{className:"rf-flex rf-h-full rf-min-h-[300px] rf-items-center rf-justify-center rf-bg-slate-50",children:W.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2 rf-text-sm rf-text-slate-600",children:[W.jsx(Z4,{className:"rf-h-4 rf-w-4 rf-animate-spin"}),"Running analog simulation..."]})}):W.jsx(hxo,{circuitJson:r,containerStyle:{height:"100%"}}):W.jsx(eS,{onRunClicked:n})})})}),(!R||R.includes("bom"))&&W.jsx(ff,{value:"bom",children:W.jsx("div",{className:qr("rf-overflow-auto",at?"rf-h-[calc(100vh-60px)]":"rf-h-full rf-min-h-[620px]"),children:W.jsx($4,{fallbackRender:({error:it})=>W.jsx("div",{className:"rf-mt-4 rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200",children:W.jsxs("div",{className:"rf-p-4",children:[W.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-3",children:"Error loading Bill of Materials"}),W.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-red-600 rf-mt-2",children:xBe(it)})]})}),children:r?W.jsx(Dxo,{circuitJson:r}):W.jsx(eS,{onRunClicked:n})})})}),(!R||R.includes("circuit_json"))&&W.jsx(ff,{value:"circuit_json",children:W.jsx("div",{className:qr("rf-overflow-auto",at?"rf-h-[calc(100vh-60px)]":"rf-h-full rf-min-h-[620px]"),children:W.jsx($4,{fallback:W.jsx("div",{children:"Error loading JSON viewer"}),children:r?W.jsx(fxo,{elements:r}):W.jsx(eS,{onRunClicked:n})})})}),(!R||R.includes("errors"))&&W.jsx(ff,{value:"errors",className:"rf-h-full",children:W.jsx("div",{className:qr("rf-overflow-hidden",at?"rf-h-[calc(100vh-60px)]":"rf-h-full rf-min-h-[620px]"),children:o||qe&&qe.length>0||r?W.jsx(jho,{code:t,fsMap:e,circuitJsonErrors:qe,circuitJsonWarnings:Oe,errorMessage:o,errorStack:i,circuitJson:r,evalVersion:Ge,autoroutingLog:C,onReportAutoroutingLog:I}):W.jsx(eS,{onRunClicked:n})})}),u&&(!R||R.includes("render_log"))&&W.jsx(ff,{value:"render_log",children:W.jsx(pbo,{renderLog:_,onRerunWithDebug:ve})}),(!R||R.includes("solvers"))&&W.jsx(ff,{value:"solvers",children:W.jsx("div",{className:qr("rf-overflow-hidden",at?"rf-h-[calc(100vh-60px)]":"rf-h-full rf-min-h-[620px]"),children:W.jsx($4,{fallback:W.jsx("div",{children:"Error loading Solvers view"}),children:W.jsx(mSo,{solverEvents:Be})})})})]})})})};pMt.createRoot(document.getElementById("root")).render(W.jsx("div",{style:{height:"100vh"},children:W.jsx(VBo,{defaultActiveTab:"cad",autoRotate3dViewerDisabled:!0,showRightHeaderContent:!1,circuitJson:window.CIRCUIT_JSON||{},...window.CIRCUIT_JSON_PREVIEW_PROPS||{}})}));const YBo=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}))}));
|
|
5874
|
+
${E}`)}},[e,d]),Z.useEffect(()=>{e&&!d&&hBt().then(E=>{m(E.size)}).catch(E=>{console.error("Failed to fetch file count",E),m(0)})},[e,d]);const f=Z.useCallback(()=>{s(null),_(null),c(null),A([]),u.current&&(u.current.value=""),n(!0)},[]),y=Z.useCallback(()=>{n(!1)},[]),C=Z.useCallback(async()=>{i(!0),s(null),c(null),A([]);const E=IB(),b=u.current?.value||"";try{const P=await hBt();if(P.size===0){Js.error("No project files available to include in the bug report"),i(!1);return}const w=new Date(Date.now()+1440*60*1e3).toISOString(),k=(await E.post("bug_reports/create",{json:{text:b.trim()||void 0,is_auto_deleted:!0,delete_at:w}}).json()).bug_report.bug_report_id,R=Array.from(P.entries()),O=[];for(let U=0;U<R.length;U++){const[K,X]=R[U];c({current:U+1,total:R.length,currentFile:K});try{const $={bug_report_id:k,file_path:K};X.text_content&&($.content_text=X.text_content),X.binary_content_b64&&($.content_base64=X.binary_content_b64),await E.post("bug_reports/upload_file",{json:$})}catch($){const oe=$ instanceof CB?`HTTP ${$.response.status}`:$ instanceof Error?$.message:"Upload failed";O.push({filePath:K,message:oe}),A([...O])}}c(null);const F=iBo(k);_({bugReportUrl:F})}catch(P){if(console.error("Failed to submit bug report",P),P instanceof CB)if(P.response.status===401)if(g){const w="Your session has expired. Please sign in again to continue.";s(w),Js.error(w),p&&(y(),p())}else{const w="You must be logged in to report a bug. Please sign in via cli and try again.";s(w),Js.error(w),setTimeout(()=>{p&&(y(),p())},1e3)}else{const w=`Failed to submit bug report (${P.response.status})`;s(w),Js.error(w)}else if(P instanceof Error)s(P.message),Js.error(P.message);else{const w="Failed to submit bug report";s(w),Js.error(w)}}finally{i(!1)}},[g,p]);return{BugReportDialog:Z.useMemo(()=>{const E=a?Math.round(a.current/a.total*100):0;return W.jsx(nvt,{open:e,onOpenChange:b=>{b?(s(null),_(null),c(null),A([]),n(!0)):o||y()},children:W.jsxs(Mve,{children:[W.jsxs(wve,{children:[W.jsx(Qve,{children:d?"Bug Report Created":"Report Bug"}),W.jsx(Tve,{asChild:!0,children:d?W.jsxs("div",{className:"rf-text-left rf-space-y-3 rf-text-sm",children:[W.jsx("p",{children:"Bug report created successfully."}),l.length>0&&W.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:[W.jsxs("p",{className:"rf-text-red-700 rf-font-medium rf-text-xs rf-mb-1",children:[l.length," file(s) failed:"]}),l.map((b,P)=>W.jsxs("div",{className:"rf-text-red-600 rf-text-xs rf-mb-0.5",title:`${b.filePath}: ${b.message}`,children:[W.jsx("span",{className:"rf-font-medium rf-break-all",children:b.filePath.split("/").pop()}),W.jsx("span",{className:"rf-text-red-500 rf-block rf-truncate",children:b.message})]},P))]}),W.jsx("div",{children:W.jsx("a",{className:"rf-text-blue-600 hover:rf-underline",href:d.bugReportUrl,target:"_blank",rel:"noreferrer",children:"View bug report"})}),W.jsxs("p",{children:["Please share this link privately with tscircuit staff so we can help debug. Join the",W.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"}),"."]})]}):W.jsx("div",{className:"rf-text-left rf-space-y-3 rf-text-sm",children:a?W.jsxs("div",{className:"rf-space-y-2 rf-overflow-hidden",children:[W.jsxs("div",{className:"rf-flex rf-justify-between rf-text-xs",children:[W.jsx("span",{children:"Uploading files..."}),W.jsxs("span",{children:[a.current,"/",a.total]})]}),W.jsx("div",{className:"rf-w-full rf-h-2 rf-bg-gray-200 rf-rounded-full rf-overflow-hidden",children:W.jsx("div",{className:"rf-h-full rf-bg-blue-500 rf-transition-all rf-duration-150",style:{width:`${E}%`}})}),W.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&&W.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((b,P)=>W.jsxs("div",{className:"rf-text-red-600 rf-text-xs rf-mb-0.5",title:`${b.filePath}: ${b.message}`,children:[W.jsx("span",{className:"rf-font-medium rf-break-all",children:b.filePath.split("/").pop()}),W.jsx("span",{className:"rf-text-red-500 rf-block rf-truncate",children:b.message})]},P))})]}):W.jsxs(W.Fragment,{children:[W.jsxs("p",{children:["Reporting a bug will upload your entire project",h>0?` (${h} file${h===1?"":"s"})`:""," ","to tscircuit support."]}),W.jsxs("div",{className:"rf-space-y-2",children:[W.jsx("label",{htmlFor:"bug-description",className:"rf-block rf-font-medium",children:"Description (optional)"}),W.jsx("textarea",{ref:u,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})]}),W.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",W.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"}),"."]}),!g&&W.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."}),r&&W.jsx("p",{className:"rf-text-red-600",children:r})]})})})]}),W.jsx(Dve,{children:d?W.jsx("button",{type:"button",className:DQ(),onClick:()=>{y()},children:"Close"}):W.jsxs(W.Fragment,{children:[W.jsx(Nve,{disabled:o,onClick:()=>{o||y()},children:"Cancel"}),!g&&p?W.jsx("button",{type:"button",className:DQ(),onClick:b=>{b.preventDefault(),y(),p()},children:"Sign In"}):W.jsx("button",{type:"button",className:EI(DQ(),o&&"rf-opacity-70 rf-cursor-not-allowed"),disabled:o,onClick:b=>{b.preventDefault(),C()},children:o?"Reporting...":"Upload & Report"})]})})]})},"bug-report-dialog")},[e,o,y,r,d,h,g,C,p,a,l]),openBugReportDialog:f}};function sBo({open:t,onOpenChange:e,onExport:n}){const[o,i]=Z.useState(!1),r=()=>{n({includeSilkscreen:o}),e(!1)},s=()=>{e(!1)};return W.jsx(OO,{open:t,onOpenChange:e,children:W.jsxs(uT,{children:[W.jsxs(dT,{children:[W.jsx(hT,{children:"LightBurn Export Options"}),W.jsx(UO,{children:"Configure export settings for PCB laser ablation with LightBurn"})]}),W.jsx("div",{className:"rf-flex rf-flex-col rf-gap-4 rf-py-4",children:W.jsxs("div",{className:"rf-flex rf-items-center rf-space-x-2",children:[W.jsx(FO,{id:"includeSilkscreen",checked:o,onCheckedChange:a=>i(a===!0)}),W.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"})]})}),W.jsxs(GO,{children:[W.jsx(du,{variant:"outline",onClick:s,children:"Cancel"}),W.jsx(du,{onClick:r,children:"Export"})]})]})})}const aBo=/#(\d+)/,cBo=t=>{const e=t.match(aBo);if(!e)return null;const n=Number.parseInt(e[1],10);return Number.isFinite(n)?n:null},lBo=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},ABo=t=>{if(!t)return null;let e=null,n=-1,o=-1;for(const[i,r]of Object.entries(t)){const s=cBo(i),a=lBo(r.createdAt);if(s!==null){s>n&&(n=s,e={key:i,value:r});continue}if(n===-1){if(a!==null&&a>o){o=a,e={key:i,value:r};continue}e||(e={key:i,value:r})}}return e},uBo=t=>{const e=xve(Be=>Be.lastRunEvalVersion),n=dE(Be=>Be.currentMainComponentPath),[o,i]=Z.useState(null),[r,s]=Z.useState(!1),[a,c]=Z.useState(!0),[l,A]=Z.useState(!1),[u,d]=Z.useState(null),[_,h]=Z.useState(null),[m,p]=Z.useState(!1),[g,f]=Z.useState(null),[y,C]=Z.useState(null),[I,E]=Z.useState(!1),[b,P]=Z.useState(!1),[w,M]=Z.useState(!1),[k,R]=Z.useState(null),O=nBo(),F=dE(Be=>Be.pushEvent),U=dE(Be=>Be.recentEvents),K=Z.useMemo(()=>Date.now(),[]);PSo(Be=>{if(!(new Date(Be.created_at).valueOf()<K+500)){if(Be.event_type==="FILE_UPDATED"){s(!0);return}if(Be.event_type==="SNIPPET_SAVED"){s(!1),c(!1),f("Snippet saved successfully."),E(!1);return}Be.event_type==="REQUEST_EXPORT"&&(P(!0),f("Export processing..."),E(!1)),Be.event_type==="EXPORT_CREATED"&&(f(`Export created: ${Be.exportFilePath}`),E(!1),P(!1))}}),Z.useEffect(()=>{if(!l||u===null)return;const Be=U.filter(pe=>new Date(pe.created_at).valueOf()>u),ge=Be.find(pe=>pe.event_type==="FAILED_TO_SAVE_SNIPPET"),Pe=Be.find(pe=>pe.event_type==="SNIPPET_SAVED");ge&&(A(!1),d(null),C(ge.message??"Failed to save snippet. See console for error."),console.error(ge.message),E(!0),ge.error_code==="SNIPPET_UNSET"&&ge.available_snippet_names&&(h(ge.available_snippet_names),p(!0))),Pe&&(A(!1),d(null),f("Snippet saved successfully."),E(!1))},[U,l]);const X=async()=>{A(!0),d(Date.now()),f(null),E(!1),await F({event_type:"REQUEST_TO_SAVE_SNIPPET",snippet_name:o})},oe=dE(Be=>Be.circuitJson)??t.circuitJson,[Ae,ne]=Z.useState(!1),[re,ce]=Z.useState(!1),{BugReportDialog:ae,openBugReportDialog:_e}=rBo({onLoginRequired:t.onLoginRequired}),ye=async Be=>{k&&(await Qvt({circuitJson:k.circuitJson,projectName:k.projectName,options:Be}),R(null))},ve=Z.useMemo(()=>ABo(t.autoroutingLog),[t.autoroutingLog]);return W.jsxs(W.Fragment,{children:[W.jsxs("div",{className:"rf-flex rf-items-center rf-gap-1 rf-flex-shrink-0",children:[W.jsxs(lee,{children:[W.jsx(Aee,{asChild:!0,children:W.jsx("div",{className:"rf-whitespace-nowrap rf-text-xs font-medium rf-p-2 rf-mx-1 rf-cursor-pointer rf-relative",children:"File"})}),W.jsxs(zF,{className:"rf-z-[101]",children:[!t.isWebEmbedded&&W.jsxs(W.Fragment,{children:[W.jsx(n_,{className:"rf-text-xs",onSelect:X,disabled:l,children:l?"Saving...":"Push"}),parseInt(window.location.port)>5e3&&W.jsx(n_,{className:"rf-text-xs",onSelect:()=>{O.open()},children:"Order"}),W.jsx(n_,{className:"rf-text-xs",onSelect:()=>ne(!0),disabled:l,children:"Import"}),W.jsx(n_,{className:"rf-text-xs",onSelect:()=>{if(!HU()){Js.error("Requires tscircuit token");return}ce(!0)},children:"AI Review"})]}),!t.isWebEmbedded&&t.onLoginRequired&&W.jsx(n_,{className:"rf-text-xs",onSelect:()=>{t.onLoginRequired?.()},children:"Sign In"}),!t.isWebEmbedded&&W.jsxs(UF,{children:[W.jsx(GQ,{className:"rf-text-xs",children:"Report Bug"}),W.jsx(GF,{children:W.jsxs(UQ,{children:[W.jsx(n_,{className:"rf-text-xs",onSelect:()=>{_e()},children:"Report Entire Circuit"}),W.jsx(n_,{className:"rf-text-xs",disabled:!ve||!t.onReportAutoroutingLog,onSelect:()=>{!ve||!t.onReportAutoroutingLog||t.onReportAutoroutingLog(ve.key,{simpleRouteJson:ve.value.simpleRouteJson})},children:"Report Autorouter Bug"})]})})]}),W.jsxs(UF,{children:[W.jsx(GQ,{className:"rf-text-xs",disabled:b,children:b?"Exporting...":"Export"}),W.jsx(GF,{children:W.jsx(UQ,{children:P3o.map((Be,ge)=>W.jsx(n_,{onSelect:()=>{if(!oe){Js.error("No Circuit JSON to export");return}let Pe="Untitled";if(n){const ke=n.split("/").pop();ke&&(Pe=ke.replace(/\.[^.]+$/,""))}const pe=t.projectName??o??Pe,Ge=ve?.value.simpleRouteJson;if(Be.name==="LightBurn"){R({circuitJson:oe,projectName:pe}),M(!0);return}v3o({exportName:Be.name,circuitJson:oe,simpleRouteJson:Ge,projectName:pe?.replace(/\.(board|circuit)$/,"")})},disabled:b||Be.name==="Simple Route JSON"&&!ve,children:W.jsx("span",{className:"rf-text-xs",children:Be.name})},ge))})})]}),!t.isWebEmbedded&&W.jsxs(UF,{children:[W.jsx(GQ,{className:"rf-text-xs",children:"Advanced"}),W.jsx(GF,{children:W.jsxs(UQ,{children:[W.jsx(n_,{className:"rf-flex rf-items-center rf-gap-2",children:W.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[W.jsx(FO,{id:"load-latest-eval",checked:t.shouldLoadLatestEval,onCheckedChange:Be=>{t.onChangeShouldLoadLatestEval?.(Be===!0)}}),W.jsx("label",{htmlFor:"load-latest-eval",className:"rf-text-xs rf-cursor-pointer",children:"Force Latest @tscircuit/eval"})]})}),e&&W.jsx(n_,{className:"rf-flex rf-items-center rf-gap-2",children:W.jsx("div",{className:"rf-flex rf-items-center rf-gap-2",children:W.jsxs("span",{className:"rf-text-xs",children:["@tscircuit/eval@",e]})})}),W.jsx(n_,{className:"rf-flex rf-items-center rf-gap-2",children:W.jsx("div",{className:"rf-flex rf-items-center rf-gap-2",children:W.jsxs("span",{className:"rf-text-xs",children:["@tscircuit/runframe@",pSo.version]})})}),W.jsx(n_,{className:"rf-flex rf-items-center rf-gap-2",onClick:()=>{window.open("/api/admin","_blank")},children:W.jsx("div",{className:"rf-flex rf-items-center rf-gap-2",children:W.jsx("span",{className:"rf-text-xs",children:"CLI Admin Panel"})})})]})})]})]}),W.jsx(nvt,{open:I,onOpenChange:E,children:W.jsxs(Mve,{children:[W.jsxs(wve,{children:[W.jsx(Qve,{children:"Error Saving Snippet"}),W.jsx(Tve,{children:y})]}),W.jsx(Dve,{children:W.jsx(Nve,{onClick:()=>E(!1),children:"Dismiss"})})]})}),W.jsx(SSo,{snippetNames:_??[],onSelect:async Be=>{A(!0),d(Date.now()),i(Be),await F({event_type:"REQUEST_TO_SAVE_SNIPPET",snippet_name:Be}),p(!1)},onCancel:()=>p(!1),isOpen:m})]}),W.jsxs(lee,{children:[W.jsx(Aee,{asChild:!0,children:W.jsx("div",{className:"rf-whitespace-nowrap rf-text-xs font-medium rf-p-2 rf-mx-1 rf-cursor-pointer rf-relative",children:"View"})}),W.jsx(zF,{className:"rf-z-[104]",children:W.jsxs(UF,{children:[W.jsx(GQ,{className:"rf-text-xs",children:"Schematic"}),W.jsx(GF,{children:W.jsxs(UQ,{children:[W.jsx(n_,{className:"rf-flex rf-items-center rf-gap-2",onSelect:Be=>Be.preventDefault(),children:W.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[W.jsx(FO,{id:"show-schematic-ports",checked:t.showSchematicPorts,onCheckedChange:Be=>{t.onChangeShowSchematicPorts?.(Be===!0)}}),W.jsx("label",{htmlFor:"show-schematic-ports",className:"rf-text-xs rf-cursor-pointer",children:"Show Schematic Ports"})]})}),W.jsx(n_,{className:"rf-flex rf-items-center rf-gap-2",onSelect:Be=>Be.preventDefault(),children:W.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[W.jsx(FO,{id:"show-schematic-grid",checked:t.showSchematicDebugGrid,onCheckedChange:Be=>{t.onChangeShowSchematicDebugGrid?.(Be===!0)}}),W.jsx("label",{htmlFor:"show-schematic-grid",className:"rf-text-xs rf-cursor-pointer",children:"Show Schematic Grid"})]})})]})})]})})]})]}),ae,W.jsx(sBo,{open:w,onOpenChange:M,onExport:ye}),W.jsx(wvt,{isOpen:Ae,onClose:()=>ne(!1)}),W.jsx(dvo,{isOpen:re,onClose:()=>ce(!1),packageName:o}),W.jsx(Lft,{position:"top-center",reverseOrder:!1,containerStyle:{zIndex:1e5},toastOptions:{className:"rf-break-all",style:{zIndex:1e5}}}),W.jsx(O.OrderDialog,{isOpen:O.isOpen,onClose:O.close,stage:O.stage,setStage:O.setStage})]})};var dBo=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),hBo="VisuallyHidden",_Bt=Z.forwardRef((t,e)=>W.jsx(lA.span,{...t,ref:e,style:{...dBo,...t.style}}));_Bt.displayName=hBo;var _Bo=_Bt,[cne]=F5("Tooltip",[XZ]),lne=XZ(),mBt="TooltipProvider",mBo=700,fBe="tooltip.open",[gBo,yBe]=cne(mBt),gBt=t=>{const{__scopeTooltip:e,delayDuration:n=mBo,skipDelayDuration:o=300,disableHoverableContent:i=!1,children:r}=t,s=Z.useRef(!0),a=Z.useRef(!1),c=Z.useRef(0);return Z.useEffect(()=>{const l=c.current;return()=>window.clearTimeout(l)},[]),W.jsx(gBo,{scope:e,isOpenDelayedRef:s,delayDuration:n,onOpen:Z.useCallback(()=>{o<=0||(window.clearTimeout(c.current),s.current=!1)},[o]),onClose:Z.useCallback(()=>{o<=0||(window.clearTimeout(c.current),c.current=window.setTimeout(()=>s.current=!0,o))},[o]),isPointerInTransitRef:a,onPointerInTransitChange:Z.useCallback(l=>{a.current=l},[]),disableHoverableContent:i,children:r})};gBt.displayName=mBt;var qO="Tooltip",[pBo,Ane]=cne(qO),pBt=t=>{const{__scopeTooltip:e,children:n,open:o,defaultOpen:i,onOpenChange:r,disableHoverableContent:s,delayDuration:a}=t,c=yBe(qO,t.__scopeTooltip),l=lne(e),[A,u]=Z.useState(null),d=G5(),_=Z.useRef(0),h=s??c.disableHoverableContent,m=a??c.delayDuration,p=Z.useRef(!1),[g,f]=aB({prop:o,defaultProp:i??!1,onChange:b=>{b?(c.onOpen(),document.dispatchEvent(new CustomEvent(fBe))):c.onClose(),r?.(b)},caller:qO}),y=Z.useMemo(()=>g?p.current?"delayed-open":"instant-open":"closed",[g]),C=Z.useCallback(()=>{window.clearTimeout(_.current),_.current=0,p.current=!1,f(!0)},[f]),I=Z.useCallback(()=>{window.clearTimeout(_.current),_.current=0,f(!1)},[f]),E=Z.useCallback(()=>{window.clearTimeout(_.current),_.current=window.setTimeout(()=>{p.current=!0,f(!0),_.current=0},m)},[m,f]);return Z.useEffect(()=>()=>{_.current&&(window.clearTimeout(_.current),_.current=0)},[]),W.jsx(iPe,{...l,children:W.jsx(pBo,{scope:e,contentId:d,open:g,stateAttribute:y,trigger:A,onTriggerChange:u,onTriggerEnter:Z.useCallback(()=>{c.isOpenDelayedRef.current?E():C()},[c.isOpenDelayedRef,E,C]),onTriggerLeave:Z.useCallback(()=>{h?I():(window.clearTimeout(_.current),_.current=0)},[I,h]),onOpen:C,onClose:I,disableHoverableContent:h,children:n})})};pBt.displayName=qO;var CBe="TooltipTrigger",fBt=Z.forwardRef((t,e)=>{const{__scopeTooltip:n,...o}=t,i=Ane(CBe,n),r=yBe(CBe,n),s=lne(n),a=Z.useRef(null),c=d0(e,a,i.onTriggerChange),l=Z.useRef(!1),A=Z.useRef(!1),u=Z.useCallback(()=>l.current=!1,[]);return Z.useEffect(()=>()=>document.removeEventListener("pointerup",u),[u]),W.jsx(GIt,{asChild:!0,...s,children:W.jsx(lA.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...o,ref:c,onPointerMove:Kr(t.onPointerMove,d=>{d.pointerType!=="touch"&&!A.current&&!r.isPointerInTransitRef.current&&(i.onTriggerEnter(),A.current=!0)}),onPointerLeave:Kr(t.onPointerLeave,()=>{i.onTriggerLeave(),A.current=!1}),onPointerDown:Kr(t.onPointerDown,()=>{i.open&&i.onClose(),l.current=!0,document.addEventListener("pointerup",u,{once:!0})}),onFocus:Kr(t.onFocus,()=>{l.current||i.onOpen()}),onBlur:Kr(t.onBlur,i.onClose),onClick:Kr(t.onClick,i.onClose)})})});fBt.displayName=CBe;var fBo="TooltipPortal",[YMo,yBo]=cne(fBo,{forceMount:void 0}),mT="TooltipContent",yBt=Z.forwardRef((t,e)=>{const n=yBo(mT,t.__scopeTooltip),{forceMount:o=n.forceMount,side:i="top",...r}=t,s=Ane(mT,t.__scopeTooltip);return W.jsx(II,{present:o||s.open,children:s.disableHoverableContent?W.jsx(CBt,{side:i,...r,ref:e}):W.jsx(CBo,{side:i,...r,ref:e})})}),CBo=Z.forwardRef((t,e)=>{const n=Ane(mT,t.__scopeTooltip),o=yBe(mT,t.__scopeTooltip),i=Z.useRef(null),r=d0(e,i),[s,a]=Z.useState(null),{trigger:c,onClose:l}=n,A=i.current,{onPointerInTransitChange:u}=o,d=Z.useCallback(()=>{a(null),u(!1)},[u]),_=Z.useCallback((h,m)=>{const p=h.currentTarget,g={x:h.clientX,y:h.clientY},f=SBo(g,p.getBoundingClientRect()),y=PBo(g,f),C=vBo(m.getBoundingClientRect()),I=MBo([...y,...C]);a(I),u(!0)},[u]);return Z.useEffect(()=>()=>d(),[d]),Z.useEffect(()=>{if(c&&A){const h=p=>_(p,A),m=p=>_(p,c);return c.addEventListener("pointerleave",h),A.addEventListener("pointerleave",m),()=>{c.removeEventListener("pointerleave",h),A.removeEventListener("pointerleave",m)}}},[c,A,_,d]),Z.useEffect(()=>{if(s){const h=m=>{const p=m.target,g={x:m.clientX,y:m.clientY},f=c?.contains(p)||A?.contains(p),y=!BBo(g,s);f?d():y&&(d(),l())};return document.addEventListener("pointermove",h),()=>document.removeEventListener("pointermove",h)}},[c,A,s,l,d]),W.jsx(CBt,{...t,ref:r})}),[xBo,IBo]=cne(qO,{isInside:!1}),EBo=xMt("TooltipContent"),CBt=Z.forwardRef((t,e)=>{const{__scopeTooltip:n,children:o,"aria-label":i,onEscapeKeyDown:r,onPointerDownOutside:s,...a}=t,c=Ane(mT,n),l=lne(n),{onClose:A}=c;return Z.useEffect(()=>(document.addEventListener(fBe,A),()=>document.removeEventListener(fBe,A)),[A]),Z.useEffect(()=>{if(c.trigger){const u=d=>{d.target instanceof Node&&d.target.contains(c.trigger)&&A()};return window.addEventListener("scroll",u,{capture:!0}),()=>window.removeEventListener("scroll",u,{capture:!0})}},[c.trigger,A]),W.jsx(HZ,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:r,onPointerDownOutside:s,onFocusOutside:u=>u.preventDefault(),onDismiss:A,children:W.jsxs(UIt,{"data-state":c.stateAttribute,...l,...a,ref:e,style:{...a.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[W.jsx(EBo,{children:o}),W.jsx(xBo,{scope:n,isInside:!0,children:W.jsx(_Bo,{id:c.contentId,role:"tooltip",children:i||o})})]})})});yBt.displayName=mT;var xBt="TooltipArrow",bBo=Z.forwardRef((t,e)=>{const{__scopeTooltip:n,...o}=t,i=lne(n);return IBo(xBt,n).isInside?null:W.jsx(zIt,{...i,...o,ref:e})});bBo.displayName=xBt;function SBo(t,e){const n=Math.abs(e.top-t.y),o=Math.abs(e.bottom-t.y),i=Math.abs(e.right-t.x),r=Math.abs(e.left-t.x);switch(Math.min(n,o,i,r)){case r:return"left";case i:return"right";case n:return"top";case o:return"bottom";default:throw new Error("unreachable")}}function PBo(t,e,n=5){const o=[];switch(e){case"top":o.push({x:t.x-n,y:t.y+n},{x:t.x+n,y:t.y+n});break;case"bottom":o.push({x:t.x-n,y:t.y-n},{x:t.x+n,y:t.y-n});break;case"left":o.push({x:t.x+n,y:t.y-n},{x:t.x+n,y:t.y+n});break;case"right":o.push({x:t.x-n,y:t.y-n},{x:t.x-n,y:t.y+n});break}return o}function vBo(t){const{top:e,right:n,bottom:o,left:i}=t;return[{x:i,y:e},{x:n,y:e},{x:n,y:o},{x:i,y:o}]}function BBo(t,e){const{x:n,y:o}=t;let i=!1;for(let r=0,s=e.length-1;r<e.length;s=r++){const a=e[r],c=e[s],l=a.x,A=a.y,u=c.x,d=c.y;A>o!=d>o&&n<(u-l)*(o-A)/(d-A)+l&&(i=!i)}return i}function MBo(t){const e=t.slice();return e.sort((n,o)=>n.x<o.x?-1:n.x>o.x?1:n.y<o.y?-1:n.y>o.y?1:0),wBo(e)}function wBo(t){if(t.length<=1)return t.slice();const e=[];for(let o=0;o<t.length;o++){const i=t[o];for(;e.length>=2;){const r=e[e.length-1],s=e[e.length-2];if((r.x-s.x)*(i.y-s.y)>=(r.y-s.y)*(i.x-s.x))e.pop();else break}e.push(i)}e.pop();const n=[];for(let o=t.length-1;o>=0;o--){const i=t[o];for(;n.length>=2;){const r=n[n.length-1],s=n[n.length-2];if((r.x-s.x)*(i.y-s.y)>=(r.y-s.y)*(i.x-s.x))n.pop();else break}n.push(i)}return n.pop(),e.length===1&&n.length===1&&e[0].x===n[0].x&&e[0].y===n[0].y?e:e.concat(n)}var DBo=gBt,QBo=pBt,TBo=fBt,IBt=yBt;const NBo=DBo,RBo=QBo,kBo=TBo,EBt=Z.forwardRef(({className:t,sideOffset:e=4,...n},o)=>W.jsx(IBt,{ref:o,sideOffset:e,className:qr("z-50 overflow-hidden rounded-md bg-slate-900 px-3 py-1.5 text-xs text-slate-50 animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 dark:bg-slate-50 dark:text-slate-900",t),...n}));EBt.displayName=IBt.displayName;const HBo="24b58135-86c7-4e4b-bf6e-cca862bc4b26",bBt="runframe-crisp-chat-script",LBo="tscircuit.com",$O=t=>{window.$crisp=window.$crisp||[],window.$crisp.push(t)},FBo=()=>{if(window.$crisp=window.$crisp||[],window.CRISP_WEBSITE_ID=HBo,window.__RUNFRAME_CRISP_CONFIGURED__||(window.__RUNFRAME_CRISP_CONFIGURED__=!0,$O(["do","chat:hide"]),$O(["on","chat:closed",()=>$O(["do","chat:hide"])])),!document.getElementById(bBt)){const t=document.createElement("script");t.id=bBt,t.src="https://client.crisp.chat/l.js",t.async=!0,document.head.appendChild(t)}},OBo=()=>{FBo(),$O(["do","chat:show"]),$O(["do","chat:open"])},GBo=({isCli:t,hostname:e=typeof window<"u"?window.location.hostname:void 0}={})=>e?.toLowerCase()===LBo?!1:!!t,UBo=()=>W.jsx(NBo,{children:W.jsxs(RBo,{children:[W.jsx(kBo,{asChild:!0,children:W.jsx(du,{type:"button",variant:"ghost",size:"icon","aria-label":"Get Support or Give Feedback",onClick:OBo,className:"rf-h-8 rf-w-8",children:W.jsx(huo,{className:"rf-h-4 rf-w-4 rf-text-gray-500"})})}),W.jsx(EBt,{side:"bottom",children:"Get Support or Give Feedback"})]})}),zBo=["assembly","pinout","analog_simulation","bom","circuit_json","errors","render_log","solvers"],xBe=t=>t instanceof Error?t.message:"An unknown error occurred",VBo=({code:t,fsMap:e,onRunClicked:n=void 0,errorMessage:o,errorStack:i,circuitJson:r,autoroutingGraphics:s,showRightHeaderContent:a=!0,showCodeTab:c=!1,codeTabContent:l,showJsonTab:A=!0,showRenderLogTab:u=!0,onActiveTabChange:d,renderLog:_,showImportAndFormatButtons:h=!0,className:m,headerClassName:p,leftHeaderContent:g,readOnly:f,isStreaming:y,autoroutingLog:C,onReportAutoroutingLog:I,isRunningCode:E,hasCodeChangedSinceLastRun:b,onEditEvent:P,editEvents:w,defaultActiveTab:M,defaultTab:k,availableTabs:R,autoRotate3dViewerDisabled:O,showSchematicDebugGrid:F=!1,showSchematicPorts:U=!1,onChangeShowSchematicDebugGrid:K,onChangeShowSchematicPorts:X,showToggleFullScreen:$=!0,defaultToFullScreen:oe=!1,activeEffectName:Ae,allowSelectingVersion:ne=!0,showFileMenu:re=!1,isWebEmbedded:ce=!1,isCli:ae=!1,projectName:_e,schematicSvgOptions:ye,onRerunWithDebug:ve,solverEvents:Be,onPcbBoundsSelected:ge})=>{x3t();const{versions:Pe,latestVersion:pe,lastRunEvalVersion:Ge,search:ke,setSearch:We,selectVersion:fe}=ySo(ne),qe=Z.useMemo(()=>r?r.filter(it=>it&&"error_type"in it||it.type.includes("error")):null,[r]),Oe=Z.useMemo(()=>r?r.filter(it=>it&&"warning_type"in it||it.type.includes("warning")):null,[r]),Qe=Z.useMemo(()=>r?r.some(it=>it.type==="schematic_group"):!0,[r]),Ue=Z.useMemo(()=>r?.some(it=>it.type==="pcb_panel"),[r]),Ne=Z.useMemo(()=>{if(!r||!E||qe?.length)return!1;const it=r.some(kt=>kt.type==="simulation_experiment"),xt=r.some(kt=>kt.type==="simulation_transient_voltage_graph");return it&&!xt},[r,qe,E]),be=Z.useMemo(()=>qe?.find(it=>it.type.startsWith("simulation_")),[qe]);P3t({errorMessage:o,errorStack:i,circuitJsonErrors:qe});const Fe=k??R?.[0]??"pcb",[Me,Ke]=I3t("runframe-active-tab",M??Fe,M);gSo({source:"runframe",component:"CircuitJsonPreview",isWebEmbedded:ce,activeTab:Me});const[Xe,st]=Z.useState(null),[at,ut]=Z.useState(oe),[ct,yt]=Z.useState(F),[vt,pt]=Z.useState(U),Qt=K?F:ct,Ht=X?U:vt,un=K??yt,An=X??pt;_bo(at);const Bn=Z.useCallback(it=>{Ke(it),d?.(it)},[d,Ke]),xe=()=>{ut(!at)};Z.useEffect(()=>{o&&(Me!=="errors"&&st(Me),Bn("errors"))},[o]),Z.useEffect(()=>{(Me==="code"||Me==="errors")&&r&&!o&&Bn(Xe??M??k??R?.[0]??"pcb")},[r]);const ot=Z.useCallback(it=>{window.TSCIRCUIT_3D_OBJECT_REF=it===null?void 0:it},[]);return W.jsx("div",{className:qr("flex flex-col relative rf-overflow-x-hidden rf-h-full",m),children:W.jsx("div",{className:qr("rf-md:sticky rf-md:top-2 rf-h-full",at&&"rf-fixed rf-top-0 rf-left-0 rf-w-full rf-h-full rf-bg-white rf-overflow-hidden"),children:W.jsxs(Jie,{value:Me,onValueChange:Bn,className:"rf-flex-grow rf-flex rf-flex-col rf-h-full",children:[W.jsxs("div",{className:qr("rf-flex rf-items-center rf-gap-2 rf-p-2 rf-pb-0",p),children:[g,re&&!g&&W.jsx(uBo,{isWebEmbedded:ce,circuitJson:r,projectName:_e,autoroutingLog:C,onReportAutoroutingLog:I,showSchematicDebugGrid:Qt,onChangeShowSchematicDebugGrid:un,showSchematicPorts:Ht,onChangeShowSchematicPorts:An}),(g||re)&&W.jsx("div",{className:"rf-flex-grow"}),!g&&!re&&E&&W.jsx(Z4,{className:"rf-w-4 rf-h-4 rf-animate-spin"}),!g&&!re&&W.jsx("div",{className:"rf-flex-grow"}),_&&_.progress!==1&&!o&&W.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2 rf-min-w-0 rf-max-w-xs",children:[Ae?W.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate rf-min-w-0",title:Ae,children:Ae}):_.lastRenderEvent&&W.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate rf-min-w-0",title:_.lastRenderEvent?.phase??"",children:_.lastRenderEvent?.phase??""}),W.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:W.jsx(Z4,{className:"rf-w-4 rf-h-4 rf-animate-spin"})}),W.jsxs("div",{className:"rf-text-xs rf-font-bold rf-text-gray-700 rf-tabular-nums rf-flex-shrink-0",children:[((_.progress??0)*100).toFixed(1),"%"]})]}),a&&GBo({isCli:ae})&&W.jsx(UBo,{}),a&&W.jsxs(GU,{children:[c&&W.jsx(X5,{value:"code",children:"Code"}),!R||R.includes("pcb")?W.jsxs(X5,{value:"pcb",className:"rf-whitespace-nowrap",children:[r&&W.jsx("span",{className:qr("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",b?"rf-bg-gray-500":"rf-bg-blue-500")}),"PCB"]}):null,!R||R.includes("schematic")?W.jsxs(X5,{value:"schematic",className:qr("rf-whitespace-nowrap",r&&!Qe&&"rf-opacity-50"),disabled:r?!Qe||Ue:!1,children:[r&&W.jsx("span",{className:qr("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",b?"rf-bg-gray-500":"rf-bg-blue-500")}),"Schematic"]}):null,!R||R.includes("cad")?W.jsxs(X5,{value:"cad",children:[r&&W.jsx("span",{className:qr("inline-flex items-center justify-center w-2 h-2 mr-1 text-xs font-bold text-white rounded-full",b?"rf-bg-gray-500":"rf-bg-blue-500")}),"3D"]}):null,!["pcb","cad","schematic"].includes(Me)&&W.jsx(X5,{value:Me,children:v7e(Me)}),W.jsxs(lee,{children:[W.jsx(Aee,{asChild:!0,children:W.jsxs("div",{className:"rf-whitespace-nowrap rf-p-2 rf-mr-1 rf-cursor-pointer rf-relative",children:[W.jsx(auo,{className:"rf-w-4 rf-h-4"}),(qe&&qe.length>0||o)&&W.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"})]})}),W.jsxs(zF,{className:"rf-*:text-xs rf-z-[101]",children:[zBo.filter(it=>!R||R.includes(it)).map(it=>W.jsxs(n_,{onSelect:()=>Bn(it),children:[Me!==it&&W.jsx(qxt,{className:"rf-w-3 rf-h-3 rf-opacity-30"}),Me===it&&W.jsx(HSe,{className:"rf-w-3 rf-h-3"}),W.jsx("div",{className:"rf-pr-2",children:v7e(it)}),it==="errors"&&(qe&&qe.length>0||o)&&W.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:qe?.length}),it==="solvers"&&Be&&Be.length>0&&W.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:Be.length})]},it)),W.jsx(n_,{disabled:!0,className:"rf-opacity-60 rf-cursor-default rf-select-none",children:W.jsxs("div",{className:"rf-pr-2 rf-text-xs rf-text-gray-500",children:["@tscircuit/runframe@",v3t.split(".").map((it,xt)=>xt===2?parseInt(it)+1:it).join(".")]})}),ne?W.jsxs(UF,{onOpenChange:it=>!it&&We(""),children:[W.jsx(GQ,{className:"rf-text-xs rf-opacity-60",children:W.jsxs("div",{className:"rf-pr-2 rf-text-xs rf-text-gray-500",children:["@tscircuit/eval@",Ge??pe??"latest"]})}),W.jsx(GF,{children:W.jsxs(UQ,{className:"rf-*:text-xs rf-w-40 rf-max-h-[200px] rf-overflow-y-auto",children:[W.jsx("div",{className:"rf-p-1",children:W.jsx(N3e,{value:ke,onChange:it=>We(it.target.value),placeholder:"Search...",className:"rf-h-7 rf-text-xs"})}),W.jsx(q5t,{}),W.jsx(n_,{onSelect:()=>fe(null),children:pe?`${pe} (latest)`:"latest"}),Pe.map(it=>W.jsx(n_,{onSelect:()=>fe(it),children:it},it))]})})]}):Ge&&W.jsx(n_,{disabled:!0,className:"rf-opacity-60 rf-cursor-default rf-select-none",children:W.jsxs("div",{className:"rf-pr-2 rf-text-xs rf-text-gray-500",children:["@tscircuit/eval@",Ge]})})]})]})]}),$&&W.jsx(du,{onClick:xe,variant:"ghost",children:at?W.jsx(_uo,{size:16}):W.jsx(luo,{size:16})})]}),c&&W.jsx(ff,{value:"code",className:"rf-flex-grow rf-overflow-hidden",children:W.jsx("div",{className:"rf-h-full",children:l})}),(!R||R.includes("pcb"))&&W.jsx(ff,{value:"pcb",children:W.jsx("div",{className:qr("rf-overflow-hidden",at?"rf-h-[calc(100vh-52px)]":"rf-h-full"),children:W.jsx($4,{fallbackRender:({error:it})=>W.jsx("div",{className:"rf-mt-4 rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200",children:W.jsxs("div",{className:"rf-p-4",children:[W.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-3",children:"Error loading PCB viewer"}),W.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-red-600 rf-mt-2",children:xBe(it)})]})}),children:r?W.jsx(dbo,{focusOnHover:!1,circuitJson:r,debugGraphics:s,onBoundsSelected:ge,containerClassName:qr("rf-h-full rf-w-full",at?"rf-min-h-[calc(100vh-240px)]":"rf-min-h-[620px]"),onEditEventsChanged:it=>{if(P)for(const xt of it)P(xt)}}):W.jsx(eS,{onRunClicked:n})})})}),(!R||R.includes("assembly"))&&W.jsx(ff,{value:"assembly",children:W.jsx("div",{className:qr("rf-overflow-auto",at?"rf-h-[calc(100vh-60px)]":"rf-h-full rf-min-h-[620px]"),children:W.jsx($4,{fallback:W.jsx("div",{children:"Error loading Assembly"}),children:r?W.jsx(_xo,{circuitJson:r,containerStyle:{height:"100%"},editingEnabled:!0,debugGrid:!0}):W.jsx(eS,{onRunClicked:n})})})}),(!R||R.includes("pinout"))&&W.jsx(ff,{value:"pinout",children:W.jsx("div",{className:qr("rf-overflow-auto",at?"rf-h-[calc(100vh-60px)]":"rf-h-full rf-min-h-[620px]"),children:W.jsx($4,{fallback:W.jsx("div",{children:"Error loading Pinout Viewer"}),children:r?W.jsx(mxo,{circuitJson:r,containerStyle:{height:"100%"}}):W.jsx(eS,{onRunClicked:n})})})}),(!R||R.includes("schematic"))&&W.jsx(ff,{value:"schematic",children:W.jsx("div",{className:qr("rf-overflow-auto rf-bg-white",at?"rf-h-[calc(100vh-60px)]":"rf-h-full rf-min-h-[620px]"),children:W.jsx($4,{fallbackRender:({error:it})=>W.jsx("div",{className:"rf-mt-4 rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200",children:W.jsxs("div",{className:"rf-p-4",children:[W.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-3",children:"Error loading Schematic"}),W.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-red-600 rf-mt-2",children:xBe(it)})]})}),children:r?W.jsx(Axo,{spiceSimulationEnabled:!0,circuitJson:r,containerStyle:{height:"100%"},editingEnabled:!0,onEditEvent:it=>{P?.(it)},debugGrid:Qt,showSchematicPorts:Ht,css:ye?.css,className:ye?.className}):W.jsx(eS,{onRunClicked:n})})})}),(!R||R.includes("cad"))&&W.jsx(ff,{value:"cad",children:W.jsx("div",{className:qr("rf-overflow-auto",at?"rf-h-[calc(100vh-60px)]":"rf-h-full rf-min-h-[620px]"),children:W.jsx($4,{fallbackRender:({error:it,resetErrorBoundary:xt})=>W.jsx(WAo,{error:it,resetErrorBoundary:xt}),children:r?W.jsx(YAo,{ref:ot,circuitJson:r,autoRotateDisabled:O},`cad-${at}`):W.jsx(eS,{onRunClicked:n})})})}),(!R||R.includes("analog_simulation"))&&W.jsx(ff,{value:"analog_simulation",children:W.jsx("div",{className:qr("rf-overflow-auto",at?"rf-h-[calc(100vh-60px)]":"rf-h-full rf-min-h-[620px]"),children:W.jsx($4,{fallback:W.jsx("div",{children:"Error loading Analog Simulation"}),children:r?be?W.jsx("div",{className:"rf-mt-4 rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200",children:W.jsxs("div",{className:"rf-p-4",children:[W.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-3",children:"Error running analog simulation"}),W.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-red-600 rf-mt-2",children:be.message})]})}):Ne?W.jsx("div",{className:"rf-flex rf-h-full rf-min-h-[300px] rf-items-center rf-justify-center rf-bg-slate-50",children:W.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2 rf-text-sm rf-text-slate-600",children:[W.jsx(Z4,{className:"rf-h-4 rf-w-4 rf-animate-spin"}),"Running analog simulation..."]})}):W.jsx(hxo,{circuitJson:r,containerStyle:{height:"100%"}}):W.jsx(eS,{onRunClicked:n})})})}),(!R||R.includes("bom"))&&W.jsx(ff,{value:"bom",children:W.jsx("div",{className:qr("rf-overflow-auto",at?"rf-h-[calc(100vh-60px)]":"rf-h-full rf-min-h-[620px]"),children:W.jsx($4,{fallbackRender:({error:it})=>W.jsx("div",{className:"rf-mt-4 rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200",children:W.jsxs("div",{className:"rf-p-4",children:[W.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-3",children:"Error loading Bill of Materials"}),W.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-red-600 rf-mt-2",children:xBe(it)})]})}),children:r?W.jsx(Dxo,{circuitJson:r}):W.jsx(eS,{onRunClicked:n})})})}),(!R||R.includes("circuit_json"))&&W.jsx(ff,{value:"circuit_json",children:W.jsx("div",{className:qr("rf-overflow-auto",at?"rf-h-[calc(100vh-60px)]":"rf-h-full rf-min-h-[620px]"),children:W.jsx($4,{fallback:W.jsx("div",{children:"Error loading JSON viewer"}),children:r?W.jsx(fxo,{elements:r}):W.jsx(eS,{onRunClicked:n})})})}),(!R||R.includes("errors"))&&W.jsx(ff,{value:"errors",className:"rf-h-full",children:W.jsx("div",{className:qr("rf-overflow-hidden",at?"rf-h-[calc(100vh-60px)]":"rf-h-full rf-min-h-[620px]"),children:o||qe&&qe.length>0||r?W.jsx(jho,{code:t,fsMap:e,circuitJsonErrors:qe,circuitJsonWarnings:Oe,errorMessage:o,errorStack:i,circuitJson:r,evalVersion:Ge,autoroutingLog:C,onReportAutoroutingLog:I}):W.jsx(eS,{onRunClicked:n})})}),u&&(!R||R.includes("render_log"))&&W.jsx(ff,{value:"render_log",children:W.jsx(pbo,{renderLog:_,onRerunWithDebug:ve})}),(!R||R.includes("solvers"))&&W.jsx(ff,{value:"solvers",children:W.jsx("div",{className:qr("rf-overflow-hidden",at?"rf-h-[calc(100vh-60px)]":"rf-h-full rf-min-h-[620px]"),children:W.jsx($4,{fallback:W.jsx("div",{children:"Error loading Solvers view"}),children:W.jsx(mSo,{solverEvents:Be})})})})]})})})};pMt.createRoot(document.getElementById("root")).render(W.jsx("div",{style:{height:"100vh"},children:W.jsx(VBo,{defaultActiveTab:"cad",autoRotate3dViewerDisabled:!0,showRightHeaderContent:!1,circuitJson:window.CIRCUIT_JSON||{},...window.CIRCUIT_JSON_PREVIEW_PROPS||{}})}));const YBo=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}))}));
|