@tscircuit/runframe 0.0.2159 → 0.0.2160

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.2158";
2015
+ var version = "0.0.2159";
2016
2016
  var package_default = {
2017
2017
  name: "@tscircuit/runframe",
2018
2018
  main: "dist/preview.js",
@@ -2128,7 +2128,7 @@ var package_default = {
2128
2128
  yargs: "^17.7.2"
2129
2129
  },
2130
2130
  dependencies: {
2131
- "@tscircuit/eval": "^0.0.975",
2131
+ "@tscircuit/eval": "^0.0.977",
2132
2132
  "@tscircuit/solver-utils": "^0.0.7"
2133
2133
  }
2134
2134
  };
package/dist/preview.js CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  SchematicViewer,
8
8
  useOrderDialog,
9
9
  useOrderDialogCli
10
- } from "./chunk-EYR3ICPA.js";
10
+ } from "./chunk-S7A3NEJC.js";
11
11
  export {
12
12
  BomTable,
13
13
  CadViewer,
package/dist/runner.js CHANGED
@@ -39,7 +39,7 @@ import {
39
39
  useRunFrameStore,
40
40
  useRunnerStore,
41
41
  useStyles
42
- } from "./chunk-EYR3ICPA.js";
42
+ } from "./chunk-S7A3NEJC.js";
43
43
 
44
44
  // lib/components/RunFrame/RunFrame.tsx
45
45
  import { createCircuitWebWorker } from "@tscircuit/eval/worker";
@@ -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"})]})]})},v3t=t=>t.activeSubSolver?[t,...v3t(t.activeSubSolver)]:[t],iSo=({solver:t})=>{const e=v3t(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(oSo,{solver:n})]},n.constructor.name))})},rSo=({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(iSo,{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]})]})},sSo=(t,e,n)=>{const o=t.currentPipelineStepIndex;return e<o?"Completed":e===o&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},aSo=(t,e)=>{const o=t.pipelineDef[e].solverName,i=sSo(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}},cSo=({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})},lSo=({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,"%"]})]})},ASo=t=>Object.entries(t).map(([e,n])=>`${e}: ${n}`).join(", "),uSo=({stats:t})=>{if(!t||Object.keys(t).length===0)return W.jsx("span",{children:"-"});const e=Object.entries(t),n=ASo(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))})]})},fve=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(fve);const e={};for(const[n,o]of Object.entries(t))n.startsWith("_")||(e[n]=fve(o));return e},dSo=(t,e)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${e}`);return}const n=fve(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)}`)}},hSo=({solver:t,onStepUntilPhase:e,onDownloadInput:n})=>{const o=t.pipelineDef.map((a,c)=>aSo(t,c)),i=a=>{e?.(a)},r=a=>{a.solverInstance&&(n?n(a.solverInstance,a.name):dSo(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(cSo,{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(lSo,{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(uSo,{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))})]})})]})},_So=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 mSo({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 gSo=({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(rSo,{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(_So,{fallback:W.jsx(mSo,{graphics:s}),children:W.jsx(nSo,{graphics:s})}),c&&W.jsx(hSo,{solver:t,onStepUntilPhase:l})]})};const pSo=()=>{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)},[])},fSo=t=>t.toLowerCase().includes("pack")?_uo:t.toLowerCase().includes("rout")?xuo:suo,ySo=({solverEvents:t=[]})=>{const[e,n]=Z.useState(null);pSo();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=fSo(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(gSo,{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"})})})]})},B3t=({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])},CSo=t=>{Z.useEffect(()=>{try{wDt(t)}catch{}},[t.source,t.component,t.isWebEmbedded,t.activeTab])},M3t="0.0.2158",xSo={version:M3t},yve={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},Cve=new Map,Qte=t=>{const e=Cve.get(t);return e?Object.fromEntries(Object.entries(e.stores).map(([n,o])=>[n,o.getState()])):{}},ISo=(t,e,n)=>{if(t===void 0)return{type:"untracked",connection:e.connect(n)};const o=Cve.get(n.name);if(o)return{type:"tracked",store:t,...o};const i={connection:e.connect(n),stores:{}};return Cve.set(n.name,i),{type:"tracked",store:t,...i}},w3t=(t,e={})=>(n,o,i)=>{const{enabled:r,anonymousActionType:s,store:a,...c}=e;let l;try{l=(r??(yve?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!l)return(yve?"production":void 0)!=="production"&&r&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),t(n,o,i);const{connection:A,...u}=ISo(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)=>{(yve?"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 xve(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"})]})]})},v3t=t=>t.activeSubSolver?[t,...v3t(t.activeSubSolver)]:[t],iSo=({solver:t})=>{const e=v3t(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(oSo,{solver:n})]},n.constructor.name))})},rSo=({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(iSo,{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]})]})},sSo=(t,e,n)=>{const o=t.currentPipelineStepIndex;return e<o?"Completed":e===o&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},aSo=(t,e)=>{const o=t.pipelineDef[e].solverName,i=sSo(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}},cSo=({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})},lSo=({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,"%"]})]})},ASo=t=>Object.entries(t).map(([e,n])=>`${e}: ${n}`).join(", "),uSo=({stats:t})=>{if(!t||Object.keys(t).length===0)return W.jsx("span",{children:"-"});const e=Object.entries(t),n=ASo(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))})]})},fve=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(fve);const e={};for(const[n,o]of Object.entries(t))n.startsWith("_")||(e[n]=fve(o));return e},dSo=(t,e)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${e}`);return}const n=fve(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)}`)}},hSo=({solver:t,onStepUntilPhase:e,onDownloadInput:n})=>{const o=t.pipelineDef.map((a,c)=>aSo(t,c)),i=a=>{e?.(a)},r=a=>{a.solverInstance&&(n?n(a.solverInstance,a.name):dSo(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(cSo,{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(lSo,{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(uSo,{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))})]})})]})},_So=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 mSo({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 gSo=({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(rSo,{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(_So,{fallback:W.jsx(mSo,{graphics:s}),children:W.jsx(nSo,{graphics:s})}),c&&W.jsx(hSo,{solver:t,onStepUntilPhase:l})]})};const pSo=()=>{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)},[])},fSo=t=>t.toLowerCase().includes("pack")?_uo:t.toLowerCase().includes("rout")?xuo:suo,ySo=({solverEvents:t=[]})=>{const[e,n]=Z.useState(null);pSo();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=fSo(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(gSo,{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"})})})]})},B3t=({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])},CSo=t=>{Z.useEffect(()=>{try{wDt(t)}catch{}},[t.source,t.component,t.isWebEmbedded,t.activeTab])},M3t="0.0.2159",xSo={version:M3t},yve={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},Cve=new Map,Qte=t=>{const e=Cve.get(t);return e?Object.fromEntries(Object.entries(e.stores).map(([n,o])=>[n,o.getState()])):{}},ISo=(t,e,n)=>{if(t===void 0)return{type:"untracked",connection:e.connect(n)};const o=Cve.get(n.name);if(o)return{type:"tracked",store:t,...o};const i={connection:e.connect(n),stores:{}};return Cve.set(n.name,i),{type:"tracked",store:t,...i}},w3t=(t,e={})=>(n,o,i)=>{const{enabled:r,anonymousActionType:s,store:a,...c}=e;let l;try{l=(r??(yve?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!l)return(yve?"production":void 0)!=="production"&&r&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),t(n,o,i);const{connection:A,...u}=ISo(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)=>{(yve?"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 xve(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" } } }
@@ -5794,7 +5794,7 @@ test("${l} should solve problem correctly", () => {
5794
5794
  // Add more specific assertions based on expected output
5795
5795
  // expect(solver.netLabelPlacementSolver!.netLabelPlacements).toMatchInlineSnapshot()
5796
5796
  })
5797
- `,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 V.jsxs("div",{className:`relative ${e}`,ref:i,children:[V.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&&V.jsxs("div",{className:"absolute top-full left-0 mt-1 bg-white border border-gray-300 rounded shadow-lg z-10 min-w-[150px]",children:[V.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download JSON"}),V.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),V.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:a,children:"Download test.ts"})]})]})},Hvt=t=>t.activeSubSolver?[t,...Hvt(t.activeSubSolver)]:[t],z3o=({solver:t})=>{const e=Hvt(t);return V.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:e.map((n,o)=>V.jsxs("div",{className:"flex items-center",children:[o>0&&V.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),V.jsx(U3o,{solver:n})]},n.constructor.name))})},V3o=({solver:t,triggerRender:e,animationSpeed:n=25,onSolverStarted:o,onSolverCompleted:i})=>{const[r,s]=j.useReducer(m=>!m,!1),a=j.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)};j.useEffect(()=>()=>{a.current&&clearInterval(a.current)},[]),j.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 V.jsxs("div",{className:"space-y-2 p-2 border-b",children:[V.jsx("div",{className:"flex items-center",children:V.jsx(z3o,{solver:t})}),V.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[V.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"}),V.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"}),V.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"}),V.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"}),_&&V.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"}),V.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&V.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),h&&V.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",V.jsx("span",{className:"font-medium",children:h})]}),t.solved&&V.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&V.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&V.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},Y3o=(t,e,n)=>{const o=t.currentPipelineStepIndex;return e<o?"Completed":e===o&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},K3o=(t,e)=>{const o=t.pipelineDef[e].solverName,i=Y3o(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}},W3o=({status:t})=>{const e={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return V.jsx("span",{className:`font-medium ${e[t]}`,children:t})},j3o=({progress:t})=>{if(t===0)return null;const e=Math.round(t*100);return V.jsxs("div",{className:"flex items-center gap-2",children:[V.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:V.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${e}%`}})}),V.jsxs("span",{className:"text-xs text-gray-500",children:[e,"%"]})]})},X3o=t=>Object.entries(t).map(([e,n])=>`${e}: ${n}`).join(", "),J3o=({stats:t})=>{if(!t||Object.keys(t).length===0)return V.jsx("span",{children:"-"});const e=Object.entries(t),n=X3o(t);return V.jsxs("details",{className:"cursor-pointer",children:[V.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:n}),V.jsx("div",{className:"mt-1 text-xs",children:e.map(([o,i])=>V.jsxs("div",{children:[o,": ",String(i)]},o))})]})},yBe=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(yBe);const e={};for(const[n,o]of Object.entries(t))n.startsWith("_")||(e[n]=yBe(o));return e},q3o=(t,e)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${e}`);return}const n=yBe(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)}`)}},$3o=({solver:t,onStepUntilPhase:e,onDownloadInput:n})=>{const o=t.pipelineDef.map((a,c)=>K3o(t,c)),i=a=>{e?.(a)},r=a=>{a.solverInstance&&(n?n(a.solverInstance,a.name):q3o(a.solverInstance,a.name))},s=a=>`${(a/1e3).toFixed(2)}s`;return V.jsxs("div",{className:"border-t border-gray-200",children:[V.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:V.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),V.jsx("div",{className:"overflow-x-auto",children:V.jsxs("table",{className:"w-full text-sm",children:[V.jsx("thead",{children:V.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),V.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",V.jsx("sub",{children:"0"})]}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),V.jsx("tbody",{children:o.map(a=>V.jsxs("tr",{className:`border-b border-gray-100 ${a.status==="In Progress"?"bg-yellow-50":""}`,children:[V.jsx("td",{className:"px-4 py-2",children:V.jsxs("div",{className:"flex items-center gap-2",children:[V.jsx("span",{className:"text-gray-400 w-6",children:String(a.index+1).padStart(2,"0")}),V.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:V.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:V.jsx("path",{fillRule:"evenodd",d:"M4.5 5.653c0-1.426 1.529-2.33 2.779-1.643l11.54 6.348c1.295.712 1.295 2.573 0 3.285L7.28 19.991c-1.25.687-2.779-.217-2.779-1.643V5.653z",clipRule:"evenodd"})})}),V.jsx("span",{className:"font-medium text-gray-900",children:a.name})]})}),V.jsx("td",{className:"px-4 py-2",children:V.jsx(W3o,{status:a.status})}),V.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:a.firstIteration!==null?a.firstIteration:""}),V.jsx("td",{className:"px-4 py-2 text-gray-600",children:a.iterations}),V.jsx("td",{className:"px-4 py-2",children:V.jsx(j3o,{progress:a.progress})}),V.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(a.timeSpent)}),V.jsx("td",{className:"px-4 py-2 text-gray-500",children:V.jsx(J3o,{stats:a.stats})}),V.jsx("td",{className:"px-4 py-2",children:a.solverInstance?V.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:[V.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:V.jsx("path",{fillRule:"evenodd",d:"M12 2.25a.75.75 0 01.75.75v11.69l3.22-3.22a.75.75 0 111.06 1.06l-4.5 4.5a.75.75 0 01-1.06 0l-4.5-4.5a.75.75 0 111.06-1.06l3.22 3.22V3a.75.75 0 01.75-.75zm-9 13.5a.75.75 0 01.75.75v2.25a1.5 1.5 0 001.5 1.5h13.5a1.5 1.5 0 001.5-1.5V16.5a.75.75 0 011.5 0v2.25a3 3 0 01-3 3H5.25a3 3 0 01-3-3V16.5a.75.75 0 01.75-.75z",clipRule:"evenodd"})}),V.jsx("span",{children:"Input"})]}):null})]},a.name))})]})})]})},Z3o=class extends Ur.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 evo({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 V.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${d} ${_} ${h} ${m}`,role:"img","aria-label":"Graphics fallback",children:[o.map((p,g)=>V.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)=>V.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)=>V.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)=>V.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)=>V.jsx("text",{x:p.x??0,y:p.y??0,fontSize:p.fontSize??10,fill:p.color??"black",children:p.text??""},`text-${g}`))]})}var tvo=({solver:t,animationSpeed:e=25,onSolverStarted:n,onSolverCompleted:o})=>{const[i,r]=j.useReducer(A=>A+1,0),s=j.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(A){return console.error("Visualization error:",A),{points:[],lines:[],rects:[],circles:[]}}},[t,i]),a=j.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);j.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 V.jsxs("div",{children:[V.jsx(V3o,{solver:t,triggerRender:r,animationSpeed:e,onSolverStarted:n,onSolverCompleted:o}),a?V.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):V.jsx(Z3o,{fallback:V.jsx(evo,{graphics:s}),children:V.jsx(G3o,{graphics:s})}),c&&V.jsx($3o,{solver:t,onStepUntilPhase:l})]})};const nvo=()=>{j.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)},[])},ovo=t=>t.toLowerCase().includes("pack")?lho:t.toLowerCase().includes("rout")?mho:Xdo,ivo=({solverEvents:t=[]})=>{const[e,n]=j.useState(null);nvo();const o=j.useMemo(()=>{const a=new Map;for(const c of t){const l=`${c.componentName}-${c.solverName}`;a.set(l,c)}return a},[t]),i=j.useMemo(()=>Array.from(o.keys()),[o]),r=e?o.get(e):null,s=j.useMemo(()=>{if(!r)return{instance:null,error:null,classFound:!1};const a=gge[r.solverName];if(!a)return{instance:null,error:`Solver class "${r.solverName}" not found in SOLVERS registry. Available: ${Object.keys(gge).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?V.jsx("div",{className:"rf-p-4",children:V.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:V.jsxs("div",{className:"rf-p-4",children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),V.jsx("p",{className:"rf-text-sm rf-text-gray-600",children:"Solvers will appear here when the circuit runs. Solvers are used for tasks like component packing and autorouting."})]})})}):V.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[V.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[V.jsxs("div",{className:"rf-text-xs rf-font-semibold rf-text-gray-500 rf-px-3 rf-py-2 rf-bg-gray-50 rf-border-b rf-border-gray-200",children:[i.length," ",i.length===1?"Solver":"Solvers"]}),i.map(a=>{const c=o.get(a),l=e===a;return V.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=ovo(c.solverName);return V.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[V.jsx(A,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),V.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[V.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:c.componentName}),V.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:c.solverName})]})]})})()},a)})]}),V.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:r?s.instance?V.jsx(sI,{fallback:V.jsx("div",{className:"rf-p-4",children:V.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),V.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",r.solverName]})]})}),children:V.jsx(tvo,{solver:s.instance})}):V.jsxs("div",{className:"rf-p-4",children:[V.jsxs("div",{className:"rf-mb-4",children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:r.solverName}),V.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",r.componentName]})]}),s.error&&V.jsx("div",{className:`rf-rounded-md rf-border rf-p-4 rf-mb-4 ${s.classFound?"rf-bg-red-50 rf-border-red-200":"rf-bg-yellow-50 rf-border-yellow-200"}`,children:V.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),V.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[V.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:V.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),V.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:V.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(r.solverParams,null,2)})})]})]}):V.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:V.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},Fvt=({errorMessage:t,errorStack:e,circuitJsonErrors:n})=>{j.useEffect(()=>{if(t){const o=new Error(t);e&&(o.stack=e);try{xD.captureException(o)}catch{}}},[t,e]),j.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{xD.captureException(i,{error_type:o.type})}catch{}}},[n])},Ovt=t=>{j.useEffect(()=>{try{eDn(t)}catch{}},[t.source,t.component,t.isWebEmbedded,t.activeTab])},Gvt="0.0.2158",rvo={version:Gvt},gne=Iit()(Eit(t=>({lastRunEvalVersion:void 0,setLastRunEvalVersion:e=>{t({lastRunEvalVersion:e})}}),{name:"runframe-runner-store"})),svo=t=>{const[e,n]=j.useState([]),[o,i]=j.useState(null),[r,s]=j.useState(""),[a,c]=$w("eval-version-selection",null),l=gne(_=>_.setLastRunEvalVersion),A=gne(_=>_.lastRunEvalVersion);return j.useEffect(()=>{t&&fetch("https://data.jsdelivr.com/v1/package/npm/@tscircuit/eval").then(_=>_.json()).then(_=>{if(Array.isArray(_?.versions)){let h=[..._.versions];_.tags?.latest&&(i(_.tags.latest),h=h.filter(m=>m!==_.tags.latest)),n(h)}}).catch(()=>{})},[t]),j.useEffect(()=>{t&&(a?(window.TSCIRCUIT_LATEST_EVAL_VERSION=a,l(a)):o&&(window.TSCIRCUIT_LATEST_EVAL_VERSION=o,l(o)))},[t,a,o]),{versions:j.useMemo(()=>e.filter(_=>_.includes(r)).slice(0,50),[e,r]),latestVersion:o,lastRunEvalVersion:A,search:r,setSearch:s,selectVersion:_=>{c(_),s("")}}},avo=({snippetNames:t,onSelect:e,onCancel:n,isOpen:o})=>{const[i,r]=j.useState(""),[s,a]=j.useState("");if(!o)return null;const c=t.filter(u=>u.toLowerCase().includes(s.toLowerCase())),l=s&&!t.includes(s),A=u=>{u.key==="Enter"&&(c.length===1?r(c[0]):l&&r(s))};return V.jsx("div",{className:"rf-fixed rf-inset-0 rf-bg-black rf-bg-opacity-50 rf-flex rf-items-center rf-justify-center rf-z-[100]",children:V.jsxs("div",{className:"rf-bg-white rf-rounded-lg rf-p-6 rf-w-96",children:[V.jsx("h2",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Select Snippet"}),V.jsx("input",{type:"text",className:"rf-w-full rf-px-4 rf-py-2 rf-border rf-rounded rf-mb-4",placeholder:"Search snippets or new snippet name...",value:s,onChange:u=>a(u.target.value),onKeyDown:A}),V.jsxs("div",{className:"rf-h-60 rf-overflow-y-auto",children:[c.map(u=>V.jsx("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 ${i===u?"bg-blue-50":""}`,onClick:()=>r(u),children:u},u)),l&&V.jsxs("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 text-blue-500 ${i===s?"bg-blue-50":""}`,onClick:()=>r(s),children:['Create new "',s,'"']})]}),V.jsxs("div",{className:"rf-mt-4 rf-flex rf-justify-end rf-gap-2",children:[V.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-text-gray-600 rf-hover:text-gray-800",onClick:n,children:"Cancel"}),V.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-bg-blue-500 rf-text-white rf-rounded rf-hover:bg-blue-600 rf-disabled:opacity-50",onClick:()=>i&&e(i),disabled:!i,children:i===s?`Create "${i}"`:`Save to ${i}`})]})]})})},cvo=t=>{const e=j.useRef(null),n=I0(o=>o.recentEvents);j.useEffect(()=>{if(n.length===0)return;const o=n[0];o.event_id!==e.current&&(t(o),e.current=o.event_id)},[n,t])};var pne="Dialog",[Uvt,zvt]=o5(pne),[lvo,D5]=Uvt(pne),fne=t=>{const{__scopeDialog:e,children:n,open:o,defaultOpen:i,onOpenChange:r,modal:s=!0}=t,a=j.useRef(null),c=j.useRef(null),[l,A]=v3({prop:o,defaultProp:i??!1,onChange:r,caller:pne});return V.jsx(lvo,{scope:e,triggerRef:a,contentRef:c,contentId:pp(),titleId:pp(),descriptionId:pp(),open:l,onOpenChange:A,onOpenToggle:j.useCallback(()=>A(u=>!u),[A]),modal:s,children:n})};fne.displayName=pne;var Vvt="DialogTrigger",Yvt=j.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,i=D5(Vvt,n),r=Au(e,i.triggerRef);return V.jsx(La.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":IBe(i.open),...o,ref:r,onClick:Er(t.onClick,i.onOpenToggle)})});Yvt.displayName=Vvt;var CBe="DialogPortal",[Avo,Kvt]=Uvt(CBe,{forceMount:void 0}),yne=t=>{const{__scopeDialog:e,forceMount:n,children:o,container:i}=t,r=D5(CBe,e);return V.jsx(Avo,{scope:e,forceMount:n,children:j.Children.map(o,s=>V.jsx(IC,{present:n||r.open,children:V.jsx(Tee,{asChild:!0,container:i,children:s})}))})};yne.displayName=CBe;var Cne="DialogOverlay",aG=j.forwardRef((t,e)=>{const n=Kvt(Cne,t.__scopeDialog),{forceMount:o=n.forceMount,...i}=t,r=D5(Cne,t.__scopeDialog);return r.modal?V.jsx(IC,{present:o||r.open,children:V.jsx(dvo,{...i,ref:e})}):null});aG.displayName=Cne;var uvo=K6("DialogOverlay.RemoveScroll"),dvo=j.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,i=D5(Cne,n),r=who(),s=Au(e,r);return V.jsx(Gee,{as:uvo,allowPinchZoom:!0,shards:[i.contentRef],children:V.jsx(La.div,{"data-state":IBe(i.open),...o,ref:s,style:{pointerEvents:"auto",...o.style}})})}),vT="DialogContent",cG=j.forwardRef((t,e)=>{const n=Kvt(vT,t.__scopeDialog),{forceMount:o=n.forceMount,...i}=t,r=D5(vT,t.__scopeDialog);return V.jsx(IC,{present:o||r.open,children:r.modal?V.jsx(hvo,{...i,ref:e}):V.jsx(_vo,{...i,ref:e})})});cG.displayName=vT;var hvo=j.forwardRef((t,e)=>{const n=D5(vT,t.__scopeDialog),o=j.useRef(null),i=Au(e,n.contentRef,o);return j.useEffect(()=>{const r=o.current;if(r)return h3e(r)},[]),V.jsx(Wvt,{...t,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:Er(t.onCloseAutoFocus,r=>{r.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:Er(t.onPointerDownOutside,r=>{const s=r.detail.originalEvent,a=s.button===0&&s.ctrlKey===!0;(s.button===2||a)&&r.preventDefault()}),onFocusOutside:Er(t.onFocusOutside,r=>r.preventDefault())})}),_vo=j.forwardRef((t,e)=>{const n=D5(vT,t.__scopeDialog),o=j.useRef(!1),i=j.useRef(!1);return V.jsx(Wvt,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:r=>{t.onCloseAutoFocus?.(r),r.defaultPrevented||(o.current||n.triggerRef.current?.focus(),r.preventDefault()),o.current=!1,i.current=!1},onInteractOutside:r=>{t.onInteractOutside?.(r),r.defaultPrevented||(o.current=!0,r.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const s=r.target;n.triggerRef.current?.contains(s)&&r.preventDefault(),r.detail.originalEvent.type==="focusin"&&i.current&&r.preventDefault()}})}),Wvt=j.forwardRef((t,e)=>{const{__scopeDialog:n,trapFocus:o,onOpenAutoFocus:i,onCloseAutoFocus:r,...s}=t,a=D5(vT,n);return KPe(),V.jsx(V.Fragment,{children:V.jsx(Cee,{asChild:!0,loop:!0,trapped:o,onMountAutoFocus:i,onUnmountAutoFocus:r,children:V.jsx(eO,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":IBe(a.open),...s,ref:e,deferPointerDownOutside:!0,onDismiss:()=>a.onOpenChange(!1)})})})}),jvt="DialogTitle",xne=j.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,i=D5(jvt,n);return V.jsx(La.h2,{id:i.titleId,...o,ref:e})});xne.displayName=jvt;var Xvt="DialogDescription",Ine=j.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,i=D5(Xvt,n);return V.jsx(La.p,{id:i.descriptionId,...o,ref:e})});Ine.displayName=Xvt;var Jvt="DialogClose",xBe=j.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,i=D5(Jvt,n);return V.jsx(La.button,{type:"button",...o,ref:e,onClick:Er(t.onClick,()=>i.onOpenChange(!1))})});xBe.displayName=Jvt;function IBe(t){return t?"open":"closed"}var qvt="AlertDialog",[mvo]=o5(qvt,[zvt]),lS=zvt(),$vt=t=>{const{__scopeAlertDialog:e,...n}=t,o=lS(e);return V.jsx(fne,{...o,...n,modal:!0})};$vt.displayName=qvt;var gvo="AlertDialogTrigger",pvo=j.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,i=lS(n);return V.jsx(Yvt,{...i,...o,ref:e})});pvo.displayName=gvo;var fvo="AlertDialogPortal",Zvt=t=>{const{__scopeAlertDialog:e,...n}=t,o=lS(e);return V.jsx(yne,{...o,...n})};Zvt.displayName=fvo;var yvo="AlertDialogOverlay",eBt=j.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,i=lS(n);return V.jsx(aG,{...i,...o,ref:e})});eBt.displayName=yvo;var tBt="AlertDialogContent",[Cvo,xvo]=mvo(tBt),nBt=j.forwardRef((t,e)=>{const{__scopeAlertDialog:n,children:o,...i}=t,r=lS(n),s=j.useRef(null),a=Au(e,s),c=j.useRef(null);return V.jsx(Cvo,{scope:n,cancelRef:c,children:V.jsx(cG,{role:"alertdialog",...r,...i,ref:a,onOpenAutoFocus:Er(i.onOpenAutoFocus,l=>{l.preventDefault(),c.current?.focus({preventScroll:!0})}),onPointerDownOutside:l=>l.preventDefault(),onInteractOutside:l=>l.preventDefault(),children:o})})});nBt.displayName=tBt;var Ivo="AlertDialogTitle",oBt=j.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,i=lS(n);return V.jsx(xne,{...i,...o,ref:e})});oBt.displayName=Ivo;var Evo="AlertDialogDescription",iBt=j.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,i=lS(n);return V.jsx(Ine,{...i,...o,ref:e})});iBt.displayName=Evo;var bvo="AlertDialogAction",rBt=j.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,i=lS(n);return V.jsx(xBe,{...i,...o,ref:e})});rBt.displayName=bvo;var sBt="AlertDialogCancel",aBt=j.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,{cancelRef:i}=xvo(sBt,n),r=lS(n),s=Au(e,i);return V.jsx(xBe,{...r,...o,ref:s})});aBt.displayName=sBt;var Svo=$vt,Pvo=Zvt,cBt=eBt,lBt=nBt,ABt=rBt,uBt=aBt,dBt=oBt,hBt=iBt;const _Bt=Svo,vvo=Pvo,mBt=j.forwardRef(({className:t,...e},n)=>V.jsx(cBt,{className:Hi("rf-fixed rf-inset-0 rf-z-50 rf-bg-black/80 data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0",t),...e,ref:n}));mBt.displayName=cBt.displayName;const EBe=j.forwardRef(({className:t,...e},n)=>V.jsxs(vvo,{children:[V.jsx(mBt,{}),V.jsx(lBt,{ref:n,className:Hi("rf-fixed rf-left-[50%] rf-top-[50%] rf-z-50 rf-grid rf-w-full rf-max-w-lg rf-translate-x-[-50%] rf-translate-y-[-50%] rf-gap-4 rf-border rf-border-zinc-200 rf-bg-white rf-p-6 rf-shadow-lg rf-duration-200 data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0 data-[state=closed]:rf-zoom-out-95 data-[state=open]:rf-zoom-in-95 data-[state=closed]:rf-slide-out-to-left-1/2 data-[state=closed]:rf-slide-out-to-top-[48%] data-[state=open]:rf-slide-in-from-left-1/2 data-[state=open]:rf-slide-in-from-top-[48%] sm:rf-rounded-lg dark:rf-border-zinc-800 dark:rf-bg-zinc-950",t),...e})]}));EBe.displayName=lBt.displayName;const bBe=({className:t,...e})=>V.jsx("div",{className:Hi("rf-flex rf-flex-col rf-space-y-2 rf-text-center sm:rf-text-left",t),...e});bBe.displayName="AlertDialogHeader";const SBe=({className:t,...e})=>V.jsx("div",{className:Hi("rf-flex rf-flex-col-reverse sm:rf-flex-row sm:rf-justify-end sm:rf-space-x-2",t),...e});SBe.displayName="AlertDialogFooter";const PBe=j.forwardRef(({className:t,...e},n)=>V.jsx(dBt,{ref:n,className:Hi("rf-text-lg rf-font-semibold",t),...e}));PBe.displayName=dBt.displayName;const vBe=j.forwardRef(({className:t,...e},n)=>V.jsx(hBt,{ref:n,className:Hi("rf-text-sm rf-text-zinc-500 dark:rf-text-zinc-400",t),...e}));vBe.displayName=hBt.displayName;const Bvo=j.forwardRef(({className:t,...e},n)=>V.jsx(ABt,{ref:n,className:Hi(KQ(),t),...e}));Bvo.displayName=ABt.displayName;const BBe=j.forwardRef(({className:t,...e},n)=>V.jsx(uBt,{ref:n,className:Hi(KQ({variant:"outline"}),"rf-mt-2 sm:rf-mt-0",t),...e}));BBe.displayName=uBt.displayName;function Mvo(t){const e=j.useRef({value:t,previous:t});return j.useMemo(()=>(e.current.value!==t&&(e.current.previous=e.current.value,e.current.value=t),e.current.previous),[t])}var Ene="Checkbox",[wvo]=o5(Ene),[Dvo,MBe]=wvo(Ene);function Qvo(t){const{__scopeCheckbox:e,checked:n,children:o,defaultChecked:i,disabled:r,form:s,name:a,onCheckedChange:c,required:l,value:A="on",internal_do_not_use_render:u}=t,[d,_]=v3({prop:n,defaultProp:i??!1,onChange:c,caller:Ene}),[h,m]=j.useState(null),[p,g]=j.useState(null),f=j.useRef(!1),y=h?!!s||!!h.closest("form"):!0,C={checked:d,disabled:r,setChecked:_,control:h,setControl:m,name:a,form:s,value:A,hasConsumerStoppedPropagationRef:f,required:l,defaultChecked:Qv(i)?!1:i,isFormControl:y,bubbleInput:p,setBubbleInput:g};return V.jsx(Dvo,{scope:e,...C,children:Tvo(u)?u(C):o})}var gBt="CheckboxTrigger",pBt=j.forwardRef(({__scopeCheckbox:t,onKeyDown:e,onClick:n,...o},i)=>{const{control:r,value:s,disabled:a,checked:c,required:l,setControl:A,setChecked:u,hasConsumerStoppedPropagationRef:d,isFormControl:_,bubbleInput:h}=MBe(gBt,t),m=Au(i,A),p=j.useRef(c);return j.useEffect(()=>{const g=r?.form;if(g){const f=()=>u(p.current);return g.addEventListener("reset",f),()=>g.removeEventListener("reset",f)}},[r,u]),V.jsx(La.button,{type:"button",role:"checkbox","aria-checked":Qv(c)?"mixed":c,"aria-required":l,"data-state":IBt(c),"data-disabled":a?"":void 0,disabled:a,value:s,...o,ref:m,onKeyDown:Er(e,g=>{g.key==="Enter"&&g.preventDefault()}),onClick:Er(n,g=>{u(f=>Qv(f)?!0:!f),h&&_&&(d.current=g.isPropagationStopped(),d.current||g.stopPropagation())})})});pBt.displayName=gBt;var wBe=j.forwardRef((t,e)=>{const{__scopeCheckbox:n,name:o,checked:i,defaultChecked:r,required:s,disabled:a,value:c,onCheckedChange:l,form:A,...u}=t;return V.jsx(Qvo,{__scopeCheckbox:n,checked:i,defaultChecked:r,disabled:a,required:s,onCheckedChange:l,name:o,form:A,value:c,internal_do_not_use_render:({isFormControl:d})=>V.jsxs(V.Fragment,{children:[V.jsx(pBt,{...u,ref:e,__scopeCheckbox:n}),d&&V.jsx(xBt,{__scopeCheckbox:n})]})})});wBe.displayName=Ene;var fBt="CheckboxIndicator",yBt=j.forwardRef((t,e)=>{const{__scopeCheckbox:n,forceMount:o,...i}=t,r=MBe(fBt,n);return V.jsx(IC,{present:o||Qv(r.checked)||r.checked===!0,children:V.jsx(La.span,{"data-state":IBt(r.checked),"data-disabled":r.disabled?"":void 0,...i,ref:e,style:{pointerEvents:"none",...t.style}})})});yBt.displayName=fBt;var CBt="CheckboxBubbleInput",xBt=j.forwardRef(({__scopeCheckbox:t,...e},n)=>{const{control:o,hasConsumerStoppedPropagationRef:i,checked:r,defaultChecked:s,required:a,disabled:c,name:l,value:A,form:u,bubbleInput:d,setBubbleInput:_}=MBe(CBt,t),h=Au(n,_),m=Mvo(r),p=A4t(o);j.useEffect(()=>{const f=d;if(!f)return;const y=window.HTMLInputElement.prototype,I=Object.getOwnPropertyDescriptor(y,"checked").set,E=!i.current;if(m!==r&&I){const b=new Event("click",{bubbles:E});f.indeterminate=Qv(r),I.call(f,Qv(r)?!1:r),f.dispatchEvent(b)}},[d,m,r,i]);const g=j.useRef(Qv(r)?!1:r);return V.jsx(La.input,{type:"checkbox","aria-hidden":!0,defaultChecked:s??g.current,required:a,disabled:c,name:l,value:A,form:u,...e,tabIndex:-1,ref:h,style:{...e.style,...p,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});xBt.displayName=CBt;function Tvo(t){return typeof t=="function"}function Qv(t){return t==="indeterminate"}function IBt(t){return Qv(t)?"indeterminate":t?"checked":"unchecked"}const lG=j.forwardRef(({className:t,...e},n)=>V.jsx(wBe,{ref:n,className:Hi("rf-peer rf-h-4 rf-w-4 rf-shrink-0 rf-rounded-sm rf-border rf-border-zinc-200 rf-border-zinc-900 rf-shadow focus-visible:rf-outline-none focus-visible:rf-ring-1 focus-visible:rf-ring-zinc-950 disabled:rf-cursor-not-allowed disabled:rf-opacity-50 data-[state=checked]:rf-bg-zinc-900 data-[state=checked]:rf-text-zinc-50 dark:rf-border-zinc-800 dark:rf-border-zinc-50 dark:focus-visible:rf-ring-zinc-300 dark:data-[state=checked]:rf-bg-zinc-50 dark:data-[state=checked]:rf-text-zinc-900",t),...e,children:V.jsx(yBt,{className:Hi("rf-flex rf-items-center rf-justify-center rf-text-current"),children:V.jsx(j8,{className:"rf-h-4 rf-w-4"})})}));lG.displayName=wBe.displayName;const BT=fne,Nvo=yne,EBt=j.forwardRef(({className:t,...e},n)=>V.jsx(aG,{className:Hi("rf-fixed rf-inset-0 rf-z-50 rf-bg-black/80 data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0",t),...e,ref:n}));EBt.displayName=aG.displayName;const gM=j.forwardRef(({className:t,children:e,showOverlay:n=!0,...o},i)=>V.jsxs(Nvo,{children:[V.jsx(EBt,{className:Hi(n?"":"rf-hidden")}),V.jsx(cG,{ref:i,className:Hi("rf-fixed rf-left-[50%] rf-top-[50%] rf-z-50 rf-grid rf-w-full rf-max-w-lg rf-translate-x-[-50%] rf-translate-y-[-50%] rf-gap-4 rf-border rf-border-zinc-200 rf-bg-white rf-p-6 rf-shadow-lg rf-duration-200 data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0 data-[state=closed]:rf-zoom-out-95 data-[state=open]:rf-zoom-in-95 data-[state=closed]:rf-slide-out-to-left-1/2 data-[state=closed]:rf-slide-out-to-top-[48%] data-[state=open]:rf-slide-in-from-left-1/2 data-[state=open]:rf-slide-in-from-top-[48%] sm:rf-rounded-lg dark:rf-border-zinc-800 dark:rf-bg-zinc-950",t),...o,children:e})]}));gM.displayName=cG.displayName;const pM=({className:t,...e})=>V.jsx("div",{className:Hi("rf-flex rf-flex-col rf-space-y-2 rf-text-center sm:rf-text-left",t),...e});pM.displayName="DialogHeader";const AG=({className:t,...e})=>V.jsx("div",{className:Hi("rf-flex rf-flex-col-reverse sm:rf-flex-row sm:rf-justify-end sm:rf-space-x-2",t),...e});AG.displayName="DialogFooter";const fM=j.forwardRef(({className:t,...e},n)=>V.jsx(xne,{ref:n,className:Hi("rf-text-lg rf-font-semibold",t),...e}));fM.displayName=xne.displayName;const MT=j.forwardRef(({className:t,...e},n)=>V.jsx(Ine,{ref:n,className:Hi("rf-text-sm rf-text-zinc-500 dark:rf-text-zinc-400",t),...e}));MT.displayName=Ine.displayName;const bne={"tscircuit.com":{label:"tscircuit.com",placeholder:"Search tscircuit packages...",emptyMessage:"No packages found"},jlcpcb:{label:"JLCPCB Parts",placeholder:"Search JLCPCB parts (e.g. C14663)...",emptyMessage:"No parts found"},kicad:{label:"KiCad Footprints",placeholder:"Search KiCad footprints...",emptyMessage:"No footprints found"}},Rvo="https://cdn.jsdelivr.net/npm/easyeda@latest/dist/browser/index.js";let DBe=null;const QBe=async()=>(DBe||(DBe=import(Rvo)),DBe),kvo=t=>(e,n)=>{const o=new Headers(n?.headers),i={};return o.forEach((r,s)=>{i[s]=r}),fetch(`${t?.apiBase??L1}/proxy`,{...n,headers:{...i,"X-Target-Url":e.toString(),"X-Sender-Origin":i.origin??"","X-Sender-Host":i.host??"https://easyeda.com","X-Sender-Referer":i.referer??"","X-Sender-User-Agent":i["user-agent"]??"","X-Sender-Cookie":i.cookie??"",authority:i.authority??"","content-type":i["content-type"]??"",...t?.headers}})},Lvo=async(t,e=10)=>{const n=encodeURIComponent(t),o=await fetch(`https://jlcsearch.tscircuit.com/api/search?limit=${e}&q=${n}`);if(!o.ok)throw new Error(`JLCPCB API error: ${o.status}`);return(await o.json()).components??[]},Hvo=t=>({lcscId:t.lcsc,manufacturer:t.mfr,description:t.description,partNumber:`C${t.lcsc}`,package:t.package,price:t.price,stock:t.stock,isBasic:t.is_basic}),bBt=async(t,e)=>{const{fetchEasyEDAComponent:n}=await QBe();return n(t,{fetch:kvo(e),includeModelMetadata:e?.includeModelMetadata})},Fvo=async(t,e)=>{const{convertRawEasyToTsx:n}=await QBe(),o=await bBt(t,e);return n({rawEasy:o})},Ovo=async(t,e)=>{const{EasyEdaJsonSchema:n,convertEasyEdaJsonToCircuitJson:o}=await QBe(),i=await bBt(t,{...e,includeModelMetadata:!1}),r=n.parse(i);return o(r,{shouldRecenter:!0,showDesignator:!0,useModelCdn:!1})};function Tv(t){return Array.isArray?Array.isArray(t):PBt(t)==="[object Array]"}function Gvo(t){if(typeof t=="string")return t;if(typeof t=="bigint")return t.toString();const e=t+"";return e=="0"&&1/t==-1/0?"-0":e}function TBe(t){return t==null?"":Gvo(t)}function q1(t){return typeof t=="string"}function Sne(t){return typeof t=="number"}function Uvo(t){return t===!0||t===!1||zvo(t)&&PBt(t)=="[object Boolean]"}function SBt(t){return typeof t=="object"}function zvo(t){return SBt(t)&&t!==null}function UC(t){return t!=null}function Pne(t){return!t.trim().length}function PBt(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const Vvo="Incorrect 'index' type",NBe="Invalid doc index: must be a non-negative integer within the bounds of the docs array",Yvo=t=>`Invalid value for key ${t}`,Kvo=t=>`Pattern length exceeds max of ${t}.`,Wvo=t=>`Missing ${t} property in key`,jvo=t=>`Property 'weight' in key '${t}' must be a positive integer`,Xvo="Fuse.match does not support useTokenSearch: token search requires corpus-level statistics (df, fieldCount) that a one-off string comparison does not have. Use new Fuse(...).search(...) instead.",vBt=Object.prototype.hasOwnProperty;var Jvo=class{constructor(t){this._keys=[],this._keyMap={};let e=0;t.forEach(n=>{const o=BBt(n);this._keys.push(o),this._keyMap[o.id]=o,e+=o.weight}),this._keys.forEach(n=>{n.weight/=e})}get(t){return this._keyMap[t]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}};function BBt(t){let e=null,n=null,o=null,i=1,r=null;if(q1(t)||Tv(t))o=t,e=MBt(t),n=vne(t);else{if(!vBt.call(t,"name"))throw new Error(Wvo("name"));const s=t.name;if(o=s,vBt.call(t,"weight")&&t.weight!==void 0&&(i=t.weight,i<=0))throw new Error(jvo(vne(s)));e=MBt(s),n=vne(s),r=t.getFn??null}return{path:e,id:n,weight:i,src:o,getFn:r}}function MBt(t){return Tv(t)?t:t.split(".")}function vne(t){return Tv(t)?t.join("."):t}function qvo(t,e){const n=[];let o=!1;const i=(r,s,a,c)=>{if(UC(r))if(!s[a])n.push(c!==void 0?{v:r,i:c}:r);else{const l=r[s[a]];if(!UC(l))return;if(a===s.length-1&&(q1(l)||Sne(l)||Uvo(l)||typeof l=="bigint"))n.push(c!==void 0?{v:TBe(l),i:c}:TBe(l));else if(Tv(l)){o=!0;for(let A=0,u=l.length;A<u;A+=1)i(l[A],s,a+1,A)}else s.length&&i(l,s,a+1,c)}};return i(t,q1(e)?e.split("."):e,0),o?n:n[0]}const Es=Object.freeze({...{isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(t,e)=>t.score===e.score?t.idx<e.idx?-1:1:t.score<e.score?-1:1},...{includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},...{location:0,threshold:.6,distance:100},...{useExtendedSearch:!1,useTokenSearch:!1,tokenize:void 0,tokenMatch:"any",getFn:qvo,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1}});function $vo(t=1,e=3){const n=new Map,o=Math.pow(10,e);return{get(i){let r=1,s=!1;for(let c=0;c<i.length;c++)i.charCodeAt(c)===32?s||(r++,s=!0):s=!1;if(n.has(r))return n.get(r);const a=Math.round(o/Math.pow(r,.5*t))/o;return n.set(r,a),a},clear(){n.clear()}}}var RBe=class{constructor({getFn:t=Es.getFn,fieldNormWeight:e=Es.fieldNormWeight}={}){this.norm=$vo(e,3),this.getFn=t,this.isCreated=!1,this.docs=[],this.keys=[],this._keysMap={},this.setIndexRecords()}setSources(t=[]){this.docs=t}setIndexRecords(t=[]){this.records=t}setKeys(t=[]){this.keys=t,this._keysMap={},t.forEach((e,n)=>{this._keysMap[e.id]=n})}create(){if(this.isCreated||!this.docs.length)return;this.isCreated=!0;const t=this.docs.length;this.records=new Array(t);let e=0;if(q1(this.docs[0]))for(let n=0;n<t;n++){const o=this._createStringRecord(this.docs[n],n);o&&(this.records[e++]=o)}else for(let n=0;n<t;n++)this.records[e++]=this._createObjectRecord(this.docs[n],n);this.records.length=e,this.norm.clear()}add(t,e){if(!Number.isInteger(e)||e<0)throw new Error(NBe);if(q1(t)){const o=this._createStringRecord(t,e);return o&&this.records.push(o),o}const n=this._createObjectRecord(t,e);return this.records.push(n),n}removeAt(t){if(!Number.isInteger(t)||t<0)throw new Error(NBe);for(let e=0,n=this.records.length;e<n;e+=1)if(this.records[e].i===t){this.records.splice(e,1);break}for(let e=0,n=this.records.length;e<n;e+=1)this.records[e].i>t&&(this.records[e].i-=1)}removeAll(t){const e=new Set;for(const o of t)Number.isInteger(o)&&o>=0&&e.add(o);if(e.size===0)return;this.records=this.records.filter(o=>!e.has(o.i));const n=Array.from(e).sort((o,i)=>o-i);for(const o of this.records){let i=0,r=n.length;for(;i<r;){const s=i+r>>>1;n[s]<o.i?i=s+1:r=s}o.i-=i}}getValueForItemAtKeyId(t,e){return t[this._keysMap[e]]}size(){return this.records.length}_createStringRecord(t,e){return!UC(t)||Pne(t)?null:{v:t,i:e,n:this.norm.get(t)}}_createObjectRecord(t,e){const n={i:e,$:{}};for(let o=0,i=this.keys.length;o<i;o++){const r=this.keys[o],s=r.getFn?r.getFn(t):this.getFn(t,r.path);if(UC(s)){if(Tv(s)){const a=[];for(let c=0,l=s.length;c<l;c+=1){const A=s[c];if(UC(A)){if(q1(A)){if(!Pne(A)){const u={v:A,i:c,n:this.norm.get(A)};a.push(u)}}else if(UC(A.v)){const u=q1(A.v)?A.v:TBe(A.v);if(!Pne(u)){const d={v:u,i:A.i,n:this.norm.get(u)};a.push(d)}}}}n.$[o]=a}else if(q1(s)&&!Pne(s)){const a={v:s,n:this.norm.get(s)};n.$[o]=a}}}return n}toJSON(){return{keys:this.keys.map(({getFn:t,...e})=>e),records:this.records}}};function wBt(t,e,{getFn:n=Es.getFn,fieldNormWeight:o=Es.fieldNormWeight}={}){const i=new RBe({getFn:n,fieldNormWeight:o});return i.setKeys(t.map(BBt)),i.setSources(e),i.create(),i}function Zvo(t,{getFn:e=Es.getFn,fieldNormWeight:n=Es.fieldNormWeight}={}){const{keys:o,records:i}=t,r=new RBe({getFn:e,fieldNormWeight:n});return r.setKeys(o),r.setIndexRecords(i),r}function eBo(t=[],e=Es.minMatchCharLength){const n=[];let o=-1,i=-1,r=0;for(let s=t.length;r<s;r+=1){const a=t[r];a&&o===-1?o=r:!a&&o!==-1&&(i=r-1,i-o+1>=e&&n.push([o,i]),o=-1)}return t[r-1]&&r-o>=e&&n.push([o,r-1]),n}function tBo(t,e,n,{location:o=Es.location,distance:i=Es.distance,threshold:r=Es.threshold,findAllMatches:s=Es.findAllMatches,minMatchCharLength:a=Es.minMatchCharLength,includeMatches:c=Es.includeMatches,ignoreLocation:l=Es.ignoreLocation}={}){if(e.length>32)throw new Error(Kvo(32));const A=e.length,u=t.length,d=Math.max(0,Math.min(o,u));let _=r,h=d;const m=(M,w)=>{const k=M/A;if(l)return k;const N=Math.abs(d-w);return i?k+N/i:N?1:k},p=a>1||c,g=p?Array(u):[];let f;for(;(f=t.indexOf(e,h))>-1;){const M=m(0,f);if(_=Math.min(M,_),h=f+A,p){let w=0;for(;w<A;)g[f+w]=1,w+=1}}h=-1;let y=[],C=1,I=0,E=A+u;const b=1<<A-1;for(let M=0;M<A;M+=1){let w=0,k=E;for(;w<k;)m(M,d+k)<=_?w=k:E=k,k=Math.floor((E-w)/2+w);E=k;let N=Math.max(1,d-k+1);const O=s?u:Math.min(d+k,u)+A,H=Array(O+2);H[O+1]=(1<<M)-1;for(let G=O;G>=N;G-=1){const K=G-1,J=n[t[K]];if(H[G]=(H[G+1]<<1|1)&J,M&&(H[G]|=(y[G+1]|y[G])<<1|1|y[G+1]),H[G]&b&&(C=m(M,K),C<=_)){if(_=C,h=K,I=M,h<=d)break;N=Math.max(1,2*d-h)}}if(m(M+1,d)>_)break;y=H}if(p&&h>=0){const M=Math.min(u-1,h+A-1+I);for(let w=h;w<=M;w+=1)n[t[w]]&&(g[w]=1)}const P={isMatch:h>=0,score:Math.max(.001,C)};if(p){const M=eBo(g,a);M.length?c&&(P.indices=M):P.isMatch=!1}return P}function nBo(t){const e={};for(let n=0,o=t.length;n<o;n+=1){const i=t.charAt(n);e[i]=(e[i]||0)|1<<o-n-1}return e}function kBe(t){if(t.length<=1)return t;t.sort((n,o)=>n[0]-o[0]||n[1]-o[1]);const e=[t[0]];for(let n=1,o=t.length;n<o;n+=1){const i=e[e.length-1],r=t[n];r[0]<=i[1]+1?i[1]=Math.max(i[1],r[1]):e.push(r)}return e}const DBt={ł:"l",Ł:"L",đ:"d",Đ:"D",ø:"o",Ø:"O",ħ:"h",Ħ:"H",ŧ:"t",Ŧ:"T",ı:"i",ß:"ss"},oBo=new RegExp("["+Object.keys(DBt).join("")+"]","g"),uG=typeof String.prototype.normalize=="function"?t=>t.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,"").replace(oBo,e=>DBt[e]):t=>t;var LBe=class{constructor(t,{location:e=Es.location,threshold:n=Es.threshold,distance:o=Es.distance,includeMatches:i=Es.includeMatches,findAllMatches:r=Es.findAllMatches,minMatchCharLength:s=Es.minMatchCharLength,isCaseSensitive:a=Es.isCaseSensitive,ignoreDiacritics:c=Es.ignoreDiacritics,ignoreLocation:l=Es.ignoreLocation}={}){if(this.options={location:e,threshold:n,distance:o,includeMatches:i,findAllMatches:r,minMatchCharLength:s,isCaseSensitive:a,ignoreDiacritics:c,ignoreLocation:l},t=a?t:t.toLowerCase(),t=c?uG(t):t,this.pattern=t,this.chunks=[],!this.pattern.length)return;const A=(d,_)=>{this.chunks.push({pattern:d,alphabet:nBo(d),startIndex:_})},u=this.pattern.length;if(u>32){let d=0;const _=u%32,h=u-_;for(;d<h;)A(this.pattern.substr(d,32),d),d+=32;if(_){const m=u-32;A(this.pattern.substr(m),m)}}else A(this.pattern,0)}searchIn(t){const{isCaseSensitive:e,ignoreDiacritics:n,includeMatches:o}=this.options;if(t=e?t:t.toLowerCase(),t=n?uG(t):t,this.pattern===t){const h={isMatch:!0,score:0};return o&&(h.indices=[[0,t.length-1]]),h}const{location:i,distance:r,threshold:s,findAllMatches:a,minMatchCharLength:c,ignoreLocation:l}=this.options,A=[];let u=0,d=!1;this.chunks.forEach(({pattern:h,alphabet:m,startIndex:p})=>{const{isMatch:g,score:f,indices:y}=tBo(t,h,m,{location:i+p,distance:r,threshold:s,findAllMatches:a,minMatchCharLength:c,includeMatches:o,ignoreLocation:l});g&&(d=!0),u+=f,g&&y&&A.push(...y)});const _={isMatch:d,score:d?u/this.chunks.length:1};return d&&o&&(_.indices=kBe(A)),_}};const iBo=new Set(["fuzzy","include"]);function rBo(t){return t.startsWith("inverse")}const HBe=[{type:"exact",multiRegex:/^="(.*)"$/,singleRegex:/^=(.*)$/,create:t=>({type:"exact",search(e){const n=e===t;return{isMatch:n,score:n?0:1,indices:[0,t.length-1]}}})},{type:"include",multiRegex:/^'"(.*)"$/,singleRegex:/^'(.*)$/,create:t=>({type:"include",search(e){let n=0,o;const i=[],r=t.length;for(;(o=e.indexOf(t,n))>-1;)n=o+r,i.push([o,n-1]);const s=!!i.length;return{isMatch:s,score:s?0:1,indices:i}}})},{type:"prefix-exact",multiRegex:/^\^"(.*)"$/,singleRegex:/^\^(.*)$/,create:t=>({type:"prefix-exact",search(e){const n=e.startsWith(t);return{isMatch:n,score:n?0:1,indices:[0,t.length-1]}}})},{type:"inverse-prefix-exact",multiRegex:/^!\^"(.*)"$/,singleRegex:/^!\^(.*)$/,create:t=>({type:"inverse-prefix-exact",search(e){const n=!e.startsWith(t);return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}})},{type:"inverse-suffix-exact",multiRegex:/^!"(.*)"\$$/,singleRegex:/^!(.*)\$$/,create:t=>({type:"inverse-suffix-exact",search(e){const n=!e.endsWith(t);return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}})},{type:"suffix-exact",multiRegex:/^"(.*)"\$$/,singleRegex:/^(.*)\$$/,create:t=>({type:"suffix-exact",search(e){const n=e.endsWith(t);return{isMatch:n,score:n?0:1,indices:[e.length-t.length,e.length-1]}}})},{type:"inverse-exact",multiRegex:/^!"(.*)"$/,singleRegex:/^!(.*)$/,create:t=>({type:"inverse-exact",search(e){const n=e.indexOf(t)===-1;return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}})},{type:"fuzzy",multiRegex:/^"(.*)"$/,singleRegex:/^(.*)$/,create:(t,e={})=>{const n=new LBe(t,{location:e.location??Es.location,threshold:e.threshold??Es.threshold,distance:e.distance??Es.distance,includeMatches:e.includeMatches??Es.includeMatches,findAllMatches:e.findAllMatches??Es.findAllMatches,minMatchCharLength:e.minMatchCharLength??Es.minMatchCharLength,isCaseSensitive:e.isCaseSensitive??Es.isCaseSensitive,ignoreDiacritics:e.ignoreDiacritics??Es.ignoreDiacritics,ignoreLocation:e.ignoreLocation??Es.ignoreLocation});return{type:"fuzzy",search(o){return n.searchIn(o)}}}}],QBt=HBe.length,sBo="\0",aBo="|";function cBo(t){const e=[],n=t.length;let o=0;for(;o<n;){for(;o<n&&t[o]===" ";)o++;if(o>=n)break;let i=o;for(;i<n&&t[i]!==" "&&t[i]!=='"';)i++;if(i<n&&t[i]==='"'){for(i++;i<n;){if(t[i]==='"'){const r=i+1;if(r>=n||t[r]===" "){i++;break}if(t[r]==="$"&&(r+1>=n||t[r+1]===" ")){i+=2;break}}i++}e.push(t.substring(o,i)),o=i}else{for(;i<n&&t[i]!==" ";)i++;e.push(t.substring(o,i)),o=i}}return e}function TBt(t,e){const n=t.match(e);return n?n[1]:null}function lBo(t,e={}){return t.replace(/\\\|/g,sBo).split(aBo).map(n=>{const o=cBo(n.replace(/\u0000/g,"|").trim()).filter(r=>r&&!!r.trim()),i=[];for(let r=0,s=o.length;r<s;r+=1){const a=o[r];let c=!1,l=-1;for(;!c&&++l<QBt;){const A=HBe[l],u=TBt(a,A.multiRegex);u&&(i.push(A.create(u,e)),c=!0)}if(!c)for(l=-1;++l<QBt;){const A=HBe[l],u=TBt(a,A.singleRegex);if(u){i.push(A.create(u,e));break}}}return i})}var ABo=class{constructor(t,{isCaseSensitive:e=Es.isCaseSensitive,ignoreDiacritics:n=Es.ignoreDiacritics,includeMatches:o=Es.includeMatches,minMatchCharLength:i=Es.minMatchCharLength,ignoreLocation:r=Es.ignoreLocation,findAllMatches:s=Es.findAllMatches,location:a=Es.location,threshold:c=Es.threshold,distance:l=Es.distance}={}){this.query=null,this.options={isCaseSensitive:e,ignoreDiacritics:n,includeMatches:o,minMatchCharLength:i,findAllMatches:s,ignoreLocation:r,location:a,threshold:c,distance:l},t=e?t:t.toLowerCase(),t=n?uG(t):t,this.pattern=t,this.query=lBo(this.pattern,this.options)}static condition(t,e){return e.useExtendedSearch}searchIn(t){const e=this.query;if(!e)return{isMatch:!1,score:1};const{includeMatches:n,isCaseSensitive:o,ignoreDiacritics:i}=this.options;t=o?t:t.toLowerCase(),t=i?uG(t):t;let r=0;const s=[];let a=0,c=!1;for(let l=0,A=e.length;l<A;l+=1){const u=e[l];s.length=0,r=0,c=!1;for(let d=0,_=u.length;d<_;d+=1){const h=u[d],{isMatch:m,indices:p,score:g}=h.search(t);if(m)r+=1,a+=g,rBo(h.type)&&(c=!0),n&&(iBo.has(h.type)?s.push(...p):s.push(p));else{a=0,r=0,s.length=0,c=!1;break}}if(r){const d={isMatch:!0,score:a/r};return c&&(d.hasInverse=!0),n&&(d.indices=kBe(s)),d}}return{isMatch:!1,score:1}}};const FBe=[];function OBe(...t){FBe.push(...t)}function Bne(t,e){for(let n=0,o=FBe.length;n<o;n+=1){const i=FBe[n];if(i.condition(t,e))return new i(t,e)}return new LBe(t,e)}const Mne={AND:"$and",OR:"$or"},GBe={PATH:"$path",PATTERN:"$val"},UBe=t=>!!(t[Mne.AND]||t[Mne.OR]),uBo=t=>!!t[GBe.PATH],dBo=t=>!Tv(t)&&SBt(t)&&!UBe(t),NBt=t=>({[Mne.AND]:Object.keys(t).map(e=>({[e]:t[e]}))});function RBt(t,e,{auto:n=!0}={}){const o=i=>{if(q1(i)){const c={keyId:null,pattern:i};return n&&(c.searcher=Bne(i,e)),c}const r=Object.keys(i),s=uBo(i);if(!s&&r.length>1&&!UBe(i))return o(NBt(i));if(dBo(i)){const c=s?i[GBe.PATH]:r[0],l=s?i[GBe.PATTERN]:i[c];if(!q1(l))throw new Error(Yvo(c));const A={keyId:vne(c),pattern:l};return n&&(A.searcher=Bne(l,e)),A}const a={children:[],operator:r[0]};return r.forEach(c=>{const l=i[c];Tv(l)&&l.forEach(A=>{a.children.push(o(A))})}),a};return UBe(t)||(t=NBt(t)),o(t)}function zBe(t,{ignoreFieldNorm:e=Es.ignoreFieldNorm}){let n=1;return t.forEach(({key:o,norm:i,score:r})=>{const s=o?o.weight:null;n*=Math.pow(r===0&&s?Number.EPSILON:r,(s||1)*(e?1:i))}),n}function hBo(t,{ignoreFieldNorm:e=Es.ignoreFieldNorm}){t.forEach(n=>{n.score=zBe(n.matches,{ignoreFieldNorm:e})})}var _Bo=class{constructor(t){this.limit=t,this.heap=[]}get size(){return this.heap.length}shouldInsert(t){return this.size<this.limit||t<this.heap[0].score}insert(t){this.size<this.limit?(this.heap.push(t),this._bubbleUp(this.size-1)):t.score<this.heap[0].score&&(this.heap[0]=t,this._sinkDown(0))}extractSorted(t){return this.heap.sort(t)}_bubbleUp(t){const e=this.heap;for(;t>0;){const n=t-1>>1;if(e[t].score<=e[n].score)break;const o=e[t];e[t]=e[n],e[n]=o,t=n}}_sinkDown(t){const e=this.heap,n=e.length;let o=t;do{t=o;const i=2*t+1,r=2*t+2;if(i<n&&e[i].score>e[o].score&&(o=i),r<n&&e[r].score>e[o].score&&(o=r),o!==t){const s=e[t];e[t]=e[o],e[o]=s}}while(o!==t)}};function mBo(t){const e=[];return t.matches.forEach(n=>{if(!UC(n.indices)||!n.indices.length)return;const o={indices:n.indices,value:n.value};n.key&&(o.key=n.key.id),n.idx>-1&&(o.refIndex=n.idx),e.push(o)}),e}function gBo(t,e,{includeMatches:n=Es.includeMatches,includeScore:o=Es.includeScore}={}){return t.map(i=>{const{idx:r}=i,s={item:e[r],refIndex:r};return n&&(s.matches=mBo(i)),o&&(s.score=i.score),s})}const pBo=/[\p{L}\p{M}\p{N}_]+/gu,kBt=new WeakSet;function fBo(t){kBt.has(t)||(kBt.add(t),console.warn(`[Fuse] tokenize regex ${t} lacks the global flag; only the first match per text will be returned. Add the 'g' flag.`))}function yBo(t){if(typeof t=="function"){let e=!1;return n=>{const o=t(n);if(!e&&(e=!0,!Array.isArray(o)||o.some(i=>typeof i!="string")))throw new Error(`[Fuse] tokenize function must return string[]; received ${Array.isArray(o)?"array containing non-strings":typeof o}.`);return o}}return t instanceof RegExp?(t.global||fBo(t),e=>e.match(t)||[]):e=>e.match(pBo)||[]}function VBe({isCaseSensitive:t=!1,ignoreDiacritics:e=!1,tokenize:n}={}){const o=yBo(n);return{tokenize(i){return t||(i=i.toLowerCase()),e&&(i=uG(i)),o(i)}}}var CBo=class{static condition(t,e){return e.useTokenSearch}constructor(t,e){this.options=e,this.analyzer=VBe({isCaseSensitive:e.isCaseSensitive,ignoreDiacritics:e.ignoreDiacritics,tokenize:e.tokenize});const n=this.analyzer.tokenize(t),{df:o,fieldCount:i}=e._invertedIndex;this.termSearchers=[],this.idfWeights=[];for(const r of n){this.termSearchers.push(new LBe(r,{location:e.location,threshold:e.threshold,distance:e.distance,includeMatches:e.includeMatches,findAllMatches:e.findAllMatches,minMatchCharLength:e.minMatchCharLength,isCaseSensitive:e.isCaseSensitive,ignoreDiacritics:e.ignoreDiacritics,ignoreLocation:!0}));const s=o.get(r)||0,a=Math.log(1+(i-s+.5)/(s+.5));this.idfWeights.push(a)}this.combineAll=e.tokenMatch==="all",this.numTerms=this.termSearchers.length,this.useMask=this.numTerms<=31}searchIn(t){if(!this.termSearchers.length)return{isMatch:!1,score:1};const e=[];let n=0,o=0,i=0,r=0;const s=this.combineAll&&!this.useMask?new Set:null;for(let l=0;l<this.termSearchers.length;l++){const A=this.termSearchers[l].searchIn(t),u=this.idfWeights[l];o+=u,A.isMatch&&(i++,n+=u*(1-A.score),A.indices&&e.push(...A.indices),this.combineAll&&(this.useMask?r|=1<<l:s.add(l)))}if(i===0)return{isMatch:!1,score:1};const a=o>0?1-n/o:0,c={isMatch:!0,score:Math.max(.001,a)};return this.options.includeMatches&&e.length&&(c.indices=kBe(e)),this.combineAll&&(this.useMask?c.matchedMask=r:c.matchedTerms=s,c.termCount=this.numTerms),c}};function YBe(t,e,n,o){const i=o.tokenize(e);if(!i.length)return;t.fieldCount++,t.docFieldCount.set(n,(t.docFieldCount.get(n)||0)+1);const r=new Set(i);let s=t.docTermFieldHits.get(n);s||(s=new Map,t.docTermFieldHits.set(n,s));for(const a of r)s.set(a,(s.get(a)||0)+1),t.df.set(a,(t.df.get(a)||0)+1)}function LBt(t,e,n,o){const{i,v:r,$:s}=e;if(r!==void 0){YBe(t,r,i,o);return}if(s)for(let a=0;a<n;a++){const c=s[a];if(c)if(Array.isArray(c))for(const l of c)YBe(t,l.v,i,o);else YBe(t,c.v,i,o)}}function xBo(t,e,n){const o={fieldCount:0,df:new Map,docFieldCount:new Map,docTermFieldHits:new Map};for(const i of t)LBt(o,i,e,n);return o}function IBo(t,e,n,o){LBt(t,e,n,o)}function EBo(t,e){const n=t.docFieldCount.get(e);if(n===void 0)return;t.fieldCount-=n,t.docFieldCount.delete(e);const o=t.docTermFieldHits.get(e);if(o){for(const[i,r]of o){const s=(t.df.get(i)||0)-r;s<=0?t.df.delete(i):t.df.set(i,s)}t.docTermFieldHits.delete(e)}}function HBt(t,e){if(e.length===0)return;const n=Array.from(new Set(e)).sort((a,c)=>a-c);for(const a of n)EBo(t,a);const o=a=>{let c=0,l=n.length;for(;c<l;){const A=c+l>>>1;n[A]<a?c=A+1:l=A}return a-c},i=n[0],r=new Map;for(const[a,c]of t.docFieldCount)r.set(a>i?o(a):a,c);t.docFieldCount=r;const s=new Map;for(const[a,c]of t.docTermFieldHits)s.set(a>i?o(a):a,c);t.docTermFieldHits=s}var Nv=class{constructor(t,e,n){this.options={...Es,...e},this.options.useExtendedSearch,this.options.useTokenSearch,this._keyStore=new Jvo(this.options.keys),this._docs=t,this._myIndex=null,this._invertedIndex=null,this.setCollection(t,n),this._lastQuery=null,this._lastSearcher=null}_getSearcher(t){if(this._lastQuery===t)return this._lastSearcher;const e=Bne(t,this._invertedIndex?{...this.options,_invertedIndex:this._invertedIndex}:this.options);return this._lastQuery=t,this._lastSearcher=e,e}setCollection(t,e){if(this._docs=t,e&&!(e instanceof RBe))throw new Error(Vvo);if(this._myIndex=e||wBt(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight}),this.options.useTokenSearch){const n=VBe({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});this._invertedIndex=xBo(this._myIndex.records,this._myIndex.keys.length,n)}this._invalidateSearcherCache()}add(t){if(!UC(t))return;this._docs.push(t);const e=this._myIndex.add(t,this._docs.length-1);if(this._invertedIndex&&e){const n=VBe({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});IBo(this._invertedIndex,e,this._myIndex.keys.length,n)}this._invalidateSearcherCache()}remove(t=()=>!1){const e=[],n=[];for(let o=0,i=this._docs.length;o<i;o+=1)t(this._docs[o],o)&&(e.push(this._docs[o]),n.push(o));if(n.length){this._invertedIndex&&HBt(this._invertedIndex,n);const o=new Set(n);this._docs=this._docs.filter((i,r)=>!o.has(r)),this._myIndex.removeAll(n),this._invalidateSearcherCache()}return e}removeAt(t){if(!Number.isInteger(t)||t<0||t>=this._docs.length)throw new Error(NBe);this._invertedIndex&&HBt(this._invertedIndex,[t]);const e=this._docs.splice(t,1)[0];return this._myIndex.removeAt(t),this._invalidateSearcherCache(),e}_invalidateSearcherCache(){this._lastQuery=null,this._lastSearcher=null}getIndex(){return this._myIndex}search(t,e){const{limit:n=-1}=e||{},{includeMatches:o,includeScore:i,shouldSort:r,sortFn:s,ignoreFieldNorm:a}=this.options;if(q1(t)&&!t.trim()){let A=this._docs.map((u,d)=>({item:u,refIndex:d}));return Sne(n)&&n>-1&&(A=A.slice(0,n)),A}const c=Sne(n)&&n>0&&q1(t);let l;if(c){const A=new _Bo(n);q1(this._docs[0])?this._searchStringList(t,{heap:A,ignoreFieldNorm:a}):this._searchObjectList(t,{heap:A,ignoreFieldNorm:a}),l=A.extractSorted(s)}else l=q1(t)?q1(this._docs[0])?this._searchStringList(t):this._searchObjectList(t):this._searchLogical(t),hBo(l,{ignoreFieldNorm:a}),r&&l.sort(s),Sne(n)&&n>-1&&(l=l.slice(0,n));return gBo(l,this._docs,{includeMatches:o,includeScore:i})}_searchStringList(t,{heap:e,ignoreFieldNorm:n}={}){const o=this._getSearcher(t),i=this.options.useTokenSearch&&this.options.tokenMatch==="all",{records:r}=this._myIndex,s=e?null:[];return r.forEach(({v:a,i:c,n:l})=>{if(!UC(a))return;const A=o.searchIn(a);if(A.isMatch){const u={score:A.score,value:a,norm:l,indices:A.indices};i&&(u.matchedMask=A.matchedMask,u.matchedTerms=A.matchedTerms,u.termCount=A.termCount);const d=[u];if(!i||this._coversAllTokens(d)){const _={item:a,idx:c,matches:d};e?(_.score=zBe(_.matches,{ignoreFieldNorm:n}),e.shouldInsert(_.score)&&e.insert(_)):s.push(_)}}}),s}_searchLogical(t){const e=RBt(t,this.options),n=(s,a,c)=>{if(!("children"in s)){const{keyId:d,searcher:_}=s;let h;return d===null?(h=[],this._myIndex.keys.forEach((m,p)=>{h.push(...this._findMatches({key:m,value:a[p],searcher:_}))})):h=this._findMatches({key:this._keyStore.get(d),value:this._myIndex.getValueForItemAtKeyId(a,d),searcher:_}),h&&h.length?[{idx:c,item:a,matches:h}]:[]}const{children:l,operator:A}=s,u=[];for(let d=0,_=l.length;d<_;d+=1){const h=l[d],m=n(h,a,c);if(m.length)u.push(...m);else if(A===Mne.AND)return[]}return u},o=this._myIndex.records,i=new Map,r=[];return o.forEach(({$:s,i:a})=>{if(UC(s)){const c=n(e,s,a);c.length&&(i.has(a)||(i.set(a,{idx:a,item:s,matches:[]}),r.push(i.get(a))),c.forEach(({matches:l})=>{i.get(a).matches.push(...l)}))}}),r}_searchObjectList(t,{heap:e,ignoreFieldNorm:n}={}){const o=this._getSearcher(t),i=this.options.useTokenSearch&&this.options.tokenMatch==="all",{keys:r,records:s}=this._myIndex,a=e?null:[];return s.forEach(({$:c,i:l})=>{if(!UC(c))return;const A=[];let u=!1,d=!1;if(r.forEach((_,h)=>{const m=this._findMatches({key:_,value:c[h],searcher:o});m.length?(A.push(...m),m[0].hasInverse&&(d=!0)):u=!0}),!(d&&u)&&A.length&&(!i||this._coversAllTokens(A))){const _={idx:l,item:c,matches:A};e?(_.score=zBe(_.matches,{ignoreFieldNorm:n}),e.shouldInsert(_.score)&&e.insert(_)):a.push(_)}}),a}_findMatches({key:t,value:e,searcher:n}){if(!UC(e))return[];const o=[];if(Tv(e))e.forEach(({v:i,i:r,n:s})=>{if(!UC(i))return;const a=n.searchIn(i);if(a.isMatch){const c={score:a.score,key:t,value:i,idx:r,norm:s,indices:a.indices,hasInverse:a.hasInverse};a.termCount!==void 0&&(c.matchedMask=a.matchedMask,c.matchedTerms=a.matchedTerms,c.termCount=a.termCount),o.push(c)}});else{const{v:i,n:r}=e,s=n.searchIn(i);if(s.isMatch){const a={score:s.score,key:t,value:i,norm:r,indices:s.indices,hasInverse:s.hasInverse};s.termCount!==void 0&&(a.matchedMask=s.matchedMask,a.matchedTerms=s.matchedTerms,a.termCount=s.termCount),o.push(a)}}return o}_coversAllTokens(t){const e=t.length?t[0].termCount:void 0;if(e===void 0)return!0;if(e<=31){let o=0;for(let i=0;i<t.length;i++)o|=t[i].matchedMask||0;return o===2**e-1}const n=new Set;for(let o=0;o<t.length;o++){const i=t[o].matchedTerms;if(i)for(const r of i)n.add(r)}return n.size===e}};Nv.version="7.4.2",Nv.createIndex=wBt,Nv.parseIndex=Zvo,Nv.config=Es,Nv.match=function(t,e,n){if(n&&n.useTokenSearch)throw new Error(Xvo);return Bne(t,{...Es,...n}).searchIn(e)},Nv.parseQuery=RBt,OBe(ABo),OBe(CBo),Nv.use=function(...t){t.forEach(e=>OBe(e))};var bBo=Nv;const SBo="https://kicad-mod-cache.tscircuit.com";let KBe=null,dG=null,WBe=null;const PBo=async()=>KBe||dG||(dG=fetch("https://kicad-mod-cache.tscircuit.com/kicad_files.json").then(t=>t.json()).then(t=>(KBe=t,dG=null,t)),dG),vBo=async(t,e=20)=>{const n=await PBo();return WBe||(WBe=new bBo(n)),WBe.search(t).slice(0,e).map(o=>o.item)},BBo=t=>{const e=t.replace(".pretty/","/").replace(".kicad_mod",""),n=`kicad:${e}`;return{path:t,qualifiedName:n,description:e}},MBo=t=>t.replace(/^\/+/,"").split("/").map(e=>encodeURIComponent(e)).join("/"),wBo=async t=>{const e=await fetch(`${SBo}/${MBo(t)}`);if(!e.ok)throw new Error(`KiCad footprint fetch failed: ${e.status}`);const n=await e.text(),{KicadFootprintToCircuitJsonConverter:o}=await B5("kicad-to-circuit-json"),i=new o;return i.addFile(t.split("/").pop()??"selected-footprint.kicad_mod",n),i.runUntilFinished(),i.getOutput()},FBt=t=>t?.source==="jlcpcb"||t?.source==="kicad",DBo=async(t,e)=>{if(t.source==="jlcpcb")return Ovo(t.component.partNumber,e?.jlcpcb);if(t.source==="kicad")return wBo(t.footprint.path);throw new Error("Footprint preview is not available for this source")},QBo=({query:t,placeholder:e,isSearching:n,onQueryChange:o,onSubmit:i})=>{const r=j.useCallback(s=>{s.key==="Enter"&&(s.preventDefault(),i())},[i]);return V.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2 rf-mt-4",children:[V.jsxs("div",{className:"rf-relative rf-flex-grow",children:[V.jsx(zPe,{className:"rf-absolute rf-left-2 rf-top-2.5 rf-h-4 rf-w-4 rf-text-muted-foreground"}),V.jsx(Ove,{placeholder:e,className:"rf-pl-8",spellCheck:!1,autoComplete:"off",value:t,onChange:s=>o(s.target.value),onKeyDown:r})]}),V.jsx(sl,{onClick:i,disabled:n||t.trim().length<1,className:"sm:rf-px-4 rf-px-3",children:n?V.jsx(x5,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):V.jsxs(V.Fragment,{children:[V.jsx(zPe,{className:"rf-h-4 rf-w-4 sm:rf-hidden"}),V.jsx("span",{className:"rf-hidden sm:rf-inline",children:"Search"})]})})]})},TBo=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}),NBo=t=>TBo.format(t),OBt=t=>{switch(t.source){case"tscircuit.com":{const e=t.package;return`tscircuit-${e.package_id??`${e.org_owner_tscircuit_handle??"unknown"}-${e.unscoped_name??e.name??"package"}`}`}case"jlcpcb":return`jlc-${t.component.lcscId}`;case"kicad":return`kicad-${t.footprint.path}`;default:return"unknown"}},RBo=t=>{switch(t.source){case"tscircuit.com":return t.package.unscoped_name;case"jlcpcb":return t.component.manufacturer;case"kicad":return t.footprint.qualifiedName}},kBo=t=>{switch(t.source){case"tscircuit.com":return t.package.description||(t.package.org_owner_tscircuit_handle?`Component by ${t.package.org_owner_tscircuit_handle}`:void 0);case"jlcpcb":return t.component.description;case"kicad":return t.footprint.description}},LBo=t=>{switch(t.source){case"tscircuit.com":return t.package.name;case"jlcpcb":return t.component.partNumber;case"kicad":return}},HBo=({results:t,selected:e,onSelect:n,onShowDetails:o})=>{const i=e?OBt(e):null;return V.jsx("div",{className:"rf-divide-y rf-w-full rf-overflow-hidden",children:t.map(r=>{const s=OBt(r),a=i===s,c=RBo(r),l=kBo(r),A=LBo(r),u=r.source==="jlcpcb"?r.component.stock:null,d=r.source==="jlcpcb"?r.component.price:null,_=r.source==="jlcpcb"?r.component.isBasic:null;return V.jsxs("div",{className:`rf-p-3 rf-flex rf-flex-col sm:rf-grid sm:rf-grid-cols-[minmax(0,1fr)_auto] rf-items-start sm:rf-items-center rf-cursor-pointer hover:rf-bg-zinc-100 rf-gap-2 rf-overflow-hidden ${a?"rf-bg-zinc-100":""}`,onClick:()=>n(r),children:[V.jsxs("div",{className:"rf-min-w-0 rf-overflow-hidden rf-w-full",children:[V.jsxs("div",{className:"rf-flex rf-items-start rf-gap-2 rf-min-w-0",children:[V.jsxs("div",{className:"rf-font-medium rf-text-sm rf-truncate rf-flex-1 rf-min-w-0 rf-flex rf-items-center rf-gap-1.5",children:[c,r.source==="jlcpcb"&&_!=null&&V.jsx("span",{className:`rf-text-xs rf-px-1.5 rf-py-0.5 rf-rounded rf-font-medium rf-flex-shrink-0 ${_?"rf-bg-green-100 rf-text-green-700":"rf-bg-orange-100 rf-text-orange-700"}`,children:_?"Basic":"Extended"}),r.source==="tscircuit.com"&&r.package.is_private&&V.jsx(uho,{className:"rf-ml-1 rf-h-3 rf-w-3 rf-text-zinc-400 rf-flex-shrink-0"})]}),r.source==="jlcpcb"&&u!=null?V.jsxs("div",{className:"rf-text-xs rf-text-zinc-500 rf-font-medium rf-whitespace-nowrap rf-flex-shrink-0 sm:rf-hidden",children:[u.toLocaleString()," in stock"]}):null]}),V.jsxs("div",{className:"rf-text-xs rf-text-zinc-500 rf-truncate rf-w-full",children:[A?V.jsx("span",{className:"rf-mr-2",children:A}):null,l]})]}),V.jsxs("div",{children:[r.source==="tscircuit.com"&&o?V.jsx("div",{className:"rf-flex-shrink-0 rf-w-full sm:rf-w-auto",children:V.jsx(sl,{variant:"outline",size:"sm",className:"rf-text-xs rf-w-full sm:rf-w-auto",onClick:h=>{h.stopPropagation(),o(r)},children:"See Details"})}):r.source==="jlcpcb"&&u!=null?V.jsxs("div",{className:"rf-hidden sm:rf-block rf-text-xs rf-text-zinc-500 rf-font-medium rf-whitespace-nowrap rf-flex-shrink-0",children:[u.toLocaleString()," in stock"]}):null,d!=null&&V.jsx("div",{className:"rf-hidden sm:rf-block rf-text-xs rf-text-zinc-500 rf-font-medium rf-whitespace-nowrap rf-flex-shrink-0 rf-text-right",children:NBo(d)})]})]},s)})})},FBo=({circuitJson:t,error:e,isLoading:n,height:o})=>V.jsx("section",{className:"rf-flex rf-min-w-0 rf-items-center rf-justify-center",style:{height:o},children:n?V.jsxs("div",{className:"rf-flex rf-w-full rf-items-center rf-justify-center rf-gap-2 rf-bg-zinc-950 rf-text-sm rf-text-zinc-300",style:{height:o},children:[V.jsx(x5,{className:"rf-h-4 rf-w-4 rf-animate-spin"}),"Loading preview..."]}):e?V.jsx("div",{className:"rf-flex rf-w-full rf-items-center rf-justify-center rf-bg-zinc-950 rf-p-4",style:{height:o},children:V.jsxs("div",{className:"rf-flex rf-max-w-[320px] rf-items-start rf-gap-2 rf-text-sm rf-text-zinc-300",children:[V.jsx(M5t,{className:"rf-mt-0.5 rf-h-4 rf-w-4 rf-flex-shrink-0"}),V.jsx("span",{children:e})]})}):t?V.jsx("div",{className:"rf-w-full rf-min-w-0 rf-overflow-hidden",children:V.jsx(Rvt,{circuitJson:t,height:o,allowEditing:!1,clickToInteractEnabled:!1,focusOnHover:!1,disablePcbGroups:!0})}):V.jsx("div",{className:"rf-flex rf-w-full rf-items-center rf-justify-center rf-bg-zinc-950 rf-text-sm rf-text-zinc-300",style:{height:o},children:"No preview"})}),GBt={importComponentDialog:101,importComponentDetailsDialog:102},OBo=({packageResult:t,isOpen:e,onOpenChange:n,isLoading:o,details:i,previewTab:r,onPreviewTabChange:s,isSubmitting:a,onImport:c})=>{const l=t?.package??null,A=l?.latest_pcb_preview_image_url,u=l?.latest_sch_preview_image_url,d=l?.latest_cad_preview_image_url,_=l?.unscoped_name?.split("/").pop()??l?.unscoped_name,h=l?.org_owner_tscircuit_handle??void 0,m=h?`https://tscircuit.com/${h}`:void 0,p=h&&_?`https://tscircuit.com/${h}/${_}`:void 0;return V.jsx(BT,{open:e,onOpenChange:n,children:V.jsxs(gM,{showOverlay:!1,style:{width:"calc(100vw - 2rem)",zIndex:GBt.importComponentDetailsDialog},className:"rf-max-w-5xl no-scrollbar !rf-overflow-y-auto rf-max-h-[90vh] rf-overflow-hidden rf-flex rf-flex-col rf-rounded-sm",children:[V.jsx(pM,{className:"rf-pb-4 rf-border-b",children:V.jsx("div",{className:"rf-flex rf-items-start rf-justify-between rf-gap-4",children:V.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[V.jsx(fM,{className:"rf-text-xl rf-font-semibold rf-truncate",children:_}),V.jsx(MT,{children:l?.description})]})})}),V.jsxs("div",{className:"rf-flex-1 rf-overflow-y-auto rf-py-4 rf-space-y-6",children:[h?V.jsxs("div",{children:[V.jsx("span",{className:"rf-text-xs rf-font-medium rf-text-gray-500 rf-uppercase rf-tracking-wide",children:"Created by"}),V.jsx("div",{className:"rf-mt-1 rf-text-sm rf-font-medium",children:m?V.jsx("a",{href:m,target:"_blank",rel:"noopener noreferrer",className:"rf-text-black hover:rf-underline",children:h}):h})]}):null,(d||A||u)&&V.jsx(V.Fragment,{children:V.jsxs("div",{children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Preview"}),V.jsxs(vfe,{value:r,onValueChange:g=>s(g),children:[V.jsxs(Sq,{className:"rf-inline-flex rf-h-9 rf-items-center rf-justify-center rf-rounded-lg rf-bg-zinc-100 rf-p-1 rf-text-zinc-500 dark:rf-bg-zinc-800 dark:rf-text-zinc-400",children:[A&&V.jsx(V4,{value:"pcb",children:"PCB"}),u&&V.jsx(V4,{value:"schematic",children:"Schematic"}),d&&V.jsx(V4,{value:"3d",children:"3D"})]}),V.jsxs("div",{className:"rf-mt-4",children:[V.jsx(Qf,{value:"pcb",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:A?V.jsx("img",{src:A,alt:`${_??"package"} PCB preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null}),V.jsx(Qf,{value:"schematic",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:u?V.jsx("img",{src:u,alt:`${_??"package"} schematic preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null}),V.jsx(Qf,{value:"3d",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:d?V.jsx("img",{src:d,alt:`${_??"package"} 3D preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null})]})]})]})}),i?.ai_description?V.jsxs("section",{children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-3",children:"AI Description"}),V.jsx("div",{className:"rf-bg-gray-50 rf-border rf-border-gray-200 rf-rounded-lg rf-p-4",children:V.jsx("p",{className:"rf-text-sm rf-text-gray-700 rf-leading-relaxed",children:i.ai_description})})]}):null,i?.ai_usage_instructions?V.jsxs("section",{children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-3",children:"Usage Instructions"}),V.jsx("div",{className:"rf-bg-gray-50 rf-border rf-border-gray-200 rf-rounded-lg rf-p-4",children:V.jsx("p",{className:"rf-text-sm rf-text-gray-700 rf-leading-relaxed rf-whitespace-pre-wrap",children:i.ai_usage_instructions})})]}):null,o?V.jsxs("div",{className:"rf-flex rf-justify-center rf-items-center rf-gap-2 rf-text-gray-500",children:[V.jsx(x5,{className:"rf-h-4 rf-w-4 rf-animate-spin"}),V.jsx("span",{className:"rf-text-sm",children:"Loading package details..."})]}):null]}),V.jsxs(AG,{className:"rf-pt-4 rf-border-t rf-flex rf-flex-col sm:rf-flex-row rf-justify-between rf-gap-2",children:[V.jsx("div",{className:"rf-flex-1",children:p?V.jsxs(sl,{variant:"outline",size:"sm",className:"rf-gap-2 rf-w-full sm:rf-w-auto",onClick:()=>window.open(p,"_blank"),children:[V.jsx(iho,{className:"rf-h-4 rf-w-4"}),"View on tscircuit.com"]}):null}),V.jsxs("div",{className:"rf-flex rf-flex-col sm:rf-flex-row rf-gap-2",children:[V.jsx(sl,{variant:"outline",onClick:()=>n(!1),className:"rf-order-2 sm:rf-order-1",children:"Close"}),V.jsx(sl,{onClick:c,disabled:a,className:"rf-bg-blue-600 hover:rf-bg-blue-700",children:a?V.jsx(x5,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):"Import Component"})]})]})]})})},GBo=()=>{const[t,e]=j.useState(null),[n,o]=j.useState(!1),i=j.useCallback(async(s,a)=>{o(!0);try{const c=await fetch(`https://api.tscircuit.com/packages/get?name=${encodeURIComponent(`${s}/${a}`)}`);if(!c.ok)throw new Error(`Failed to load package details: ${c.status}`);const l=await c.json();e(l.package??null)}catch(c){console.error("Failed to fetch package details",c),e(null)}finally{o(!1)}},[]),r=j.useCallback(()=>{e(null),o(!1)},[]);return{details:t,isLoading:n,fetchDetails:i,reset:r}},UBo=(t,e)=>{const[n,o]=j.useState({circuitJson:null,error:null,isLoading:!1});return j.useEffect(()=>{if(!t||!FBt(t)){o({circuitJson:null,error:null,isLoading:!1});return}let i=!1;return o({circuitJson:null,error:null,isLoading:!0}),DBo(t,e).then(r=>{i||o({circuitJson:r,error:null,isLoading:!1})}).catch(r=>{i||o({circuitJson:null,error:r instanceof Error?r.message:"Failed to load footprint preview",isLoading:!1})}),()=>{i=!0}},[t,e]),n},zBo=async(t,e)=>{const n={"Content-Type":"application/json"};e&&(n.Authorization=`Bearer ${e}`);const o=await fetch("https://registry-api.tscircuit.com/packages/search",{method:"POST",headers:n,body:JSON.stringify({query:t})});if(!o.ok)throw new Error(`tscircuit registry error: ${o.status}`);return(await o.json()).packages??[]},VBo=({sessionToken:t})=>{const[e,n]=j.useState([]),[o,i]=j.useState(!1),[r,s]=j.useState(null),[a,c]=j.useState(!1),l=j.useCallback(async u=>{const d=u.trim();if(!d)return[];i(!0),s(null);try{const h=(await zBo(d,t)).map(m=>({source:"tscircuit.com",package:m}));return n(h),h}catch(_){return console.error("Error searching tscircuit packages",_),n([]),s(_ instanceof Error?_.message:"Failed to search tscircuit packages"),[]}finally{i(!1),c(!0)}},[t]),A=j.useCallback(()=>{n([]),i(!1),s(null),c(!1)},[]);return{results:e,isSearching:o,error:r,hasSearched:a,search:l,reset:A}},YBo=t=>{const e=t.trim();return/^C\d+/i.test(e)?e.replace(/^C/i,""):e},KBo=()=>{const[t,e]=j.useState([]),[n,o]=j.useState(!1),[i,r]=j.useState(null),[s,a]=j.useState(!1),c=j.useCallback(async A=>{const u=YBo(A);if(!u)return[];o(!0),r(null);try{const _=(await Lvo(u,10)).map(h=>({source:"jlcpcb",component:Hvo(h)}));return e(_),_}catch(d){return console.error("Error searching JLCPCB components",d),e([]),r(d instanceof Error?d.message:"Failed to search JLCPCB components"),[]}finally{o(!1),a(!0)}},[]),l=j.useCallback(()=>{e([]),o(!1),r(null),a(!1)},[]);return{results:t,isSearching:n,error:i,hasSearched:s,search:c,reset:l}},WBo=()=>{const[t,e]=j.useState([]),[n,o]=j.useState(!1),[i,r]=j.useState(null),[s,a]=j.useState(!1),c=j.useCallback(async A=>{const u=A.trim();if(!u)return[];o(!0),r(null);try{const _=(await vBo(u,20)).map(h=>({source:"kicad",footprint:BBo(h)}));return e(_),_}catch(d){return console.error("Error searching KiCad footprints",d),e([]),r(d instanceof Error?d.message:"Failed to search KiCad footprints"),[]}finally{o(!1),a(!0)}},[]),l=j.useCallback(()=>{e([]),o(!1),r(null),a(!1)},[]);return{results:t,isSearching:n,error:i,hasSearched:s,search:c,reset:l}},jBo=({onTscircuitPackageSelected:t,onJlcpcbComponentTsxLoaded:e,onKicadStringSelected:n})=>{const o=[];return t&&o.push("tscircuit.com"),e&&o.push("jlcpcb"),n&&o.push("kicad"),o},XBo=({isOpen:t,onClose:e,jlcpcbProxyRequestHeaders:n,onKicadStringSelected:o,onTscircuitPackageSelected:i,onJlcpcbComponentTsxLoaded:r,jlcpcbProxyApiBase:s,tscircuitSessionToken:a})=>{mne();const c=j.useMemo(()=>jBo({onKicadStringSelected:o,onTscircuitPackageSelected:i,onJlcpcbComponentTsxLoaded:r}),[o,i,r]),l=c.length>0,A=c.length===1,[u,d]=j.useState(c[0]??"tscircuit.com"),[_,h]=j.useState(""),[m,p]=j.useState(null),{results:g,isSearching:f,error:y,hasSearched:C,search:I,reset:E}=VBo({sessionToken:a}),{results:b,isSearching:P,error:M,hasSearched:w,search:k,reset:N}=KBo(),{results:O,isSearching:H,error:G,hasSearched:K,search:J,reset:$}=WBo(),{details:ie,isLoading:Ae,fetchDetails:ne,reset:oe}=GBo(),[ce,re]=j.useState(null),[ue,fe]=j.useState(!1),[be,ve]=j.useState("pcb"),[he,Pe]=j.useState(null),[pe,Fe]=j.useState(!1),ke=j.useMemo(()=>({jlcpcb:{headers:n,apiBase:s}}),[s,n]),{circuitJson:We,error:ye,isLoading:qe}=UBo(m,ke),Oe=FBt(m);j.useEffect(()=>{Pe(null)},[m]);const Qe=j.useCallback(()=>{E(),N(),$(),p(null)},[N,$,E]);j.useEffect(()=>{t||(Qe(),h(""),fe(!1),re(null),Pe(null))},[t,Qe]),j.useEffect(()=>{h(""),p(null),u==="tscircuit.com"?E():u==="jlcpcb"?N():u==="kicad"&&$()},[u,N,$,E]);const Ue=ct=>{p(ct),re(ct),ve("pcb"),fe(!0),oe();const yt=ct.package.org_owner_tscircuit_handle,vt=ct.package.unscoped_name;if(yt&&vt){const pt=vt.split("/").pop()??vt;ne(yt,pt)}},Te=async()=>{_.trim()&&(p(null),u==="tscircuit.com"?await I(_):u==="jlcpcb"?await k(_):u==="kicad"&&await J(_))},Ie=async ct=>{try{if(Pe(null),Fe(!0),ct.source==="kicad"){if(!o)throw new Error("KiCad handler not provided");await o({result:ct,footprint:ct.footprint.qualifiedName})}else if(ct.source==="jlcpcb"){if(!r)throw new Error("JLCPCB handler not provided");const yt=await Fvo(ct.component.partNumber,{headers:n,apiBase:s});await r({result:ct,tsx:yt})}else if(ct.source==="tscircuit.com"){if(!i)throw new Error("tscircuit package handler not provided");const yt=ct.package.org_owner_tscircuit_handle,vt=ct.package.unscoped_name;if(!yt||!vt)throw new Error("Missing package metadata");const pt=vt.split("/").pop()??vt,Qt=`@tsci/${yt}.${pt}`;await i({result:ct,fullPackageName:Qt})}return!0}catch(yt){return console.error("Failed to import component",yt),Pe(yt instanceof Error?yt.message:"Failed to import component"),!1}finally{Fe(!1)}};let He=[],Me=!1,Ke=null,je=!1;u==="tscircuit.com"?(He=g,Me=f,Ke=y,je=C):u==="jlcpcb"?(He=b,Me=P,Ke=M,je=w):u==="kicad"&&(He=O,Me=H,Ke=G,je=K);const st=async()=>{if(!m)return;await Ie(m)&&(e(),Qe(),h(""))},at=ct=>{ct||e()},ut=ct=>{fe(ct),ct||re(null)};return V.jsxs(BT,{open:t,onOpenChange:at,children:[V.jsxs(gM,{style:{width:"calc(100vw - 2rem)",maxWidth:Oe?"min(1120px, calc(100vw - 2rem))":"min(672px, calc(100vw - 2rem))",zIndex:GBt.importComponentDialog},className:"rf-rounded-sm rf-max-h-[90vh] rf-overflow-y-auto rf-overflow-x-hidden rf-flex rf-flex-col",children:[V.jsxs(pM,{children:[V.jsxs(fM,{className:"rf-text-lg sm:rf-text-xl",children:["Import ",A?bne[u].label:""," ","Component"]}),V.jsx(MT,{className:"rf-text-sm",children:l?"Search for components from available sources.":"Import options are disabled because no handlers were provided."})]}),l?V.jsxs(vfe,{value:u,onValueChange:ct=>d(ct),className:"rf-min-w-0 rf-w-full",children:[!A&&V.jsx(Sq,{className:"rf-flex rf-w-full rf-gap-2",children:c.map(ct=>V.jsx(V4,{value:ct,className:"rf-flex-1 rf-text-xs sm:rf-text-sm",children:bne[ct].label},ct))}),V.jsxs("div",{className:"rf-min-w-0",style:Oe?{display:"grid",gridTemplateColumns:"minmax(0, 1fr) minmax(360px, 0.95fr)",gap:"1.5rem",alignItems:"start"}:void 0,children:[V.jsxs("div",{className:"rf-min-w-0",children:[V.jsx(QBo,{query:_,placeholder:bne[u].placeholder,isSearching:Me,onQueryChange:h,onSubmit:Te}),V.jsx("div",{className:"no-scrollbar rf-mt-4 rf-flex-1 rf-min-h-[200px] !rf-max-h-[40vh] !rf-overflow-y-auto rf-overflow-x-hidden rf-border rf-rounded-md rf-min-w-0",children:Me?V.jsxs("div",{className:"rf-p-8 rf-text-center rf-text-zinc-500",children:[V.jsx(x5,{className:"rf-h-8 rf-w-8 rf-animate-spin rf-mx-auto rf-mb-2"}),V.jsx("p",{children:"Searching..."})]}):He.length>0?V.jsx(HBo,{results:He,selected:m,onSelect:p,onShowDetails:u==="tscircuit.com"?Ue:void 0}):V.jsx("div",{className:"rf-p-8 rf-text-center rf-text-zinc-500",children:Ke?`Error: ${Ke}`:je?bne[u].emptyMessage:"Enter a search term to find components"})})]}),Oe?V.jsx("div",{className:"rf-mt-4",children:V.jsx(FBo,{circuitJson:We,error:ye,isLoading:qe,height:325})}):null]})]}):null,he?V.jsx("div",{className:"rf-text-sm rf-text-red-600 rf-mt-2",children:he}):null,V.jsxs(AG,{className:"rf-flex rf-flex-col sm:rf-flex-row rf-gap-2",children:[V.jsx(sl,{variant:"outline",onClick:e,className:"rf-order-2 sm:rf-order-1",children:"Cancel"}),V.jsx(sl,{onClick:st,disabled:!m||pe,className:"rf-order-1 sm:rf-order-2",children:pe?V.jsx(x5,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):"Import"})]})]}),V.jsx(OBo,{packageResult:ce,isOpen:ue,onOpenChange:ut,isLoading:Ae,details:ie,previewTab:be,onPreviewTabChange:ct=>ve(ct),isSubmitting:pe,onImport:()=>{ce&&Ie(ce).then(ct=>{ct&&(fe(!1),e(),Qe(),h(""))})}})]})},JBo=t=>{const e=t.match(/export const (\w+) =/);if(!e)throw new Error("Could not determine component name from TSX contents");return e[1]},UBt=t=>{const e=I0(s=>s.pushEvent),n=I0(s=>s.upsertFile),o=async({result:s,fullPackageName:a})=>{const l=s.package.unscoped_name??s.package.name;await ks.promise(e({event_type:"INSTALL_PACKAGE",full_package_name:a}),{loading:`Requesting install for "${l}"`,success:`Install requested for "${l}"`,error:A=>`Failed to request install: ${A instanceof Error?A.message:String(A)}`})},i=async({footprint:s})=>{await ks.promise(navigator.clipboard.writeText(s),{loading:`Copying "${s}"`,success:`Copied "${s}" to clipboard`,error:a=>`Failed to copy footprint: ${a instanceof Error?a.message:String(a)}`})},r=async({result:s,tsx:a})=>{const l=`imports/${JBo(a)}.tsx`;await ks.promise(n(l,a),{loading:`Importing ${s.component.partNumber}`,success:`Imported to "${l}"`,error:A=>`Failed to import component: ${A instanceof Error?A.message:String(A)}`})};return V.jsx(XBo,{...t,onTscircuitPackageSelected:o,onKicadStringSelected:i,onJlcpcbComponentTsxLoaded:r})};UBt.displayName="ImportComponentDialogForCli";const qBo=t=>{let e=t.trim().replace(/[\\/:*?"<>|]/g,"_").replace(/[\x00-\x1f]/g,"").replace(/^\.+/,"").replace(/\.+$/,"").replace(/\s+/g," ").replace(/_+/g,"_");return/^(con|prn|aux|nul|com[0-9]|lpt[0-9])$/i.test(e)&&(e=`_${e}`),e=e.slice(0,200),e||"untitled"};var jBe={exports:{}},zBt;function $Bo(){return zBt||(zBt=1,(function(t,e){var n={env:{},version:""};(function(o){t.exports=o()})(function(){return(function o(i,r,s){function a(A,u){if(!r[A]){if(!i[A]){var d=typeof lP=="function"&&lP;if(!u&&d)return d(A,!0);if(c)return c(A,!0);var _=new Error("Cannot find module '"+A+"'");throw _.code="MODULE_NOT_FOUND",_}var h=r[A]={exports:{}};i[A][0].call(h.exports,function(m){var p=i[A][1][m];return a(p||m)},h,h.exports,o,i,r,s)}return r[A].exports}for(var c=typeof lP=="function"&&lP,l=0;l<s.length;l++)a(s[l]);return a})({1:[function(o,i,r){var s=o("./utils"),a=o("./support"),c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";r.encode=function(l){for(var A,u,d,_,h,m,p,g=[],f=0,y=l.length,C=y,I=s.getTypeOf(l)!=="string";f<l.length;)C=y-f,d=I?(A=l[f++],u=f<y?l[f++]:0,f<y?l[f++]:0):(A=l.charCodeAt(f++),u=f<y?l.charCodeAt(f++):0,f<y?l.charCodeAt(f++):0),_=A>>2,h=(3&A)<<4|u>>4,m=1<C?(15&u)<<2|d>>6:64,p=2<C?63&d:64,g.push(c.charAt(_)+c.charAt(h)+c.charAt(m)+c.charAt(p));return g.join("")},r.decode=function(l){var A,u,d,_,h,m,p=0,g=0,f="data:";if(l.substr(0,f.length)===f)throw new Error("Invalid base64 input, it looks like a data url.");var y,C=3*(l=l.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(l.charAt(l.length-1)===c.charAt(64)&&C--,l.charAt(l.length-2)===c.charAt(64)&&C--,C%1!=0)throw new Error("Invalid base64 input, bad content length.");for(y=a.uint8array?new Uint8Array(0|C):new Array(0|C);p<l.length;)A=c.indexOf(l.charAt(p++))<<2|(_=c.indexOf(l.charAt(p++)))>>4,u=(15&_)<<4|(h=c.indexOf(l.charAt(p++)))>>2,d=(3&h)<<6|(m=c.indexOf(l.charAt(p++))),y[g++]=A,h!==64&&(y[g++]=u),m!==64&&(y[g++]=d);return y}},{"./support":30,"./utils":32}],2:[function(o,i,r){var s=o("./external"),a=o("./stream/DataWorker"),c=o("./stream/Crc32Probe"),l=o("./stream/DataLengthProbe");function A(u,d,_,h,m){this.compressedSize=u,this.uncompressedSize=d,this.crc32=_,this.compression=h,this.compressedContent=m}A.prototype={getContentWorker:function(){var u=new a(s.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new l("data_length")),d=this;return u.on("end",function(){if(this.streamInfo.data_length!==d.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),u},getCompressedWorker:function(){return new a(s.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},A.createWorkerFrom=function(u,d,_){return u.pipe(new c).pipe(new l("uncompressedSize")).pipe(d.compressWorker(_)).pipe(new l("compressedSize")).withStreamInfo("compression",d)},i.exports=A},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(o,i,r){var s=o("./stream/GenericWorker");r.STORE={magic:"\0\0",compressWorker:function(){return new s("STORE compression")},uncompressWorker:function(){return new s("STORE decompression")}},r.DEFLATE=o("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(o,i,r){var s=o("./utils"),a=(function(){for(var c,l=[],A=0;A<256;A++){c=A;for(var u=0;u<8;u++)c=1&c?3988292384^c>>>1:c>>>1;l[A]=c}return l})();i.exports=function(c,l){return c!==void 0&&c.length?s.getTypeOf(c)!=="string"?(function(A,u,d,_){var h=a,m=_+d;A^=-1;for(var p=_;p<m;p++)A=A>>>8^h[255&(A^u[p])];return-1^A})(0|l,c,c.length,0):(function(A,u,d,_){var h=a,m=_+d;A^=-1;for(var p=_;p<m;p++)A=A>>>8^h[255&(A^u.charCodeAt(p))];return-1^A})(0|l,c,c.length,0):0}},{"./utils":32}],5:[function(o,i,r){r.base64=!1,r.binary=!1,r.dir=!1,r.createFolders=!0,r.date=null,r.compression=null,r.compressionOptions=null,r.comment=null,r.unixPermissions=null,r.dosPermissions=null},{}],6:[function(o,i,r){var s=null;s=typeof Promise<"u"?Promise:o("lie"),i.exports={Promise:s}},{lie:37}],7:[function(o,i,r){var s=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",a=o("pako"),c=o("./utils"),l=o("./stream/GenericWorker"),A=s?"uint8array":"array";function u(d,_){l.call(this,"FlateWorker/"+d),this._pako=null,this._pakoAction=d,this._pakoOptions=_,this.meta={}}r.magic="\b\0",c.inherits(u,l),u.prototype.processChunk=function(d){this.meta=d.meta,this._pako===null&&this._createPako(),this._pako.push(c.transformTo(A,d.data),!1)},u.prototype.flush=function(){l.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},u.prototype.cleanUp=function(){l.prototype.cleanUp.call(this),this._pako=null},u.prototype._createPako=function(){this._pako=new a[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var d=this;this._pako.onData=function(_){d.push({data:_,meta:d.meta})}},r.compressWorker=function(d){return new u("Deflate",d)},r.uncompressWorker=function(){return new u("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(o,i,r){function s(h,m){var p,g="";for(p=0;p<m;p++)g+=String.fromCharCode(255&h),h>>>=8;return g}function a(h,m,p,g,f,y){var C,I,E=h.file,b=h.compression,P=y!==A.utf8encode,M=c.transformTo("string",y(E.name)),w=c.transformTo("string",A.utf8encode(E.name)),k=E.comment,N=c.transformTo("string",y(k)),O=c.transformTo("string",A.utf8encode(k)),H=w.length!==E.name.length,G=O.length!==k.length,K="",J="",$="",ie=E.dir,Ae=E.date,ne={crc32:0,compressedSize:0,uncompressedSize:0};m&&!p||(ne.crc32=h.crc32,ne.compressedSize=h.compressedSize,ne.uncompressedSize=h.uncompressedSize);var oe=0;m&&(oe|=8),P||!H&&!G||(oe|=2048);var ce=0,re=0;ie&&(ce|=16),f==="UNIX"?(re=798,ce|=(function(fe,be){var ve=fe;return fe||(ve=be?16893:33204),(65535&ve)<<16})(E.unixPermissions,ie)):(re=20,ce|=(function(fe){return 63&(fe||0)})(E.dosPermissions)),C=Ae.getUTCHours(),C<<=6,C|=Ae.getUTCMinutes(),C<<=5,C|=Ae.getUTCSeconds()/2,I=Ae.getUTCFullYear()-1980,I<<=4,I|=Ae.getUTCMonth()+1,I<<=5,I|=Ae.getUTCDate(),H&&(J=s(1,1)+s(u(M),4)+w,K+="up"+s(J.length,2)+J),G&&($=s(1,1)+s(u(N),4)+O,K+="uc"+s($.length,2)+$);var ue="";return ue+=`
5797
+ `,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 V.jsxs("div",{className:`relative ${e}`,ref:i,children:[V.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&&V.jsxs("div",{className:"absolute top-full left-0 mt-1 bg-white border border-gray-300 rounded shadow-lg z-10 min-w-[150px]",children:[V.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download JSON"}),V.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),V.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:a,children:"Download test.ts"})]})]})},Hvt=t=>t.activeSubSolver?[t,...Hvt(t.activeSubSolver)]:[t],z3o=({solver:t})=>{const e=Hvt(t);return V.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:e.map((n,o)=>V.jsxs("div",{className:"flex items-center",children:[o>0&&V.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),V.jsx(U3o,{solver:n})]},n.constructor.name))})},V3o=({solver:t,triggerRender:e,animationSpeed:n=25,onSolverStarted:o,onSolverCompleted:i})=>{const[r,s]=j.useReducer(m=>!m,!1),a=j.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)};j.useEffect(()=>()=>{a.current&&clearInterval(a.current)},[]),j.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 V.jsxs("div",{className:"space-y-2 p-2 border-b",children:[V.jsx("div",{className:"flex items-center",children:V.jsx(z3o,{solver:t})}),V.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[V.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"}),V.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"}),V.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"}),V.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"}),_&&V.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"}),V.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&V.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),h&&V.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",V.jsx("span",{className:"font-medium",children:h})]}),t.solved&&V.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&V.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&V.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},Y3o=(t,e,n)=>{const o=t.currentPipelineStepIndex;return e<o?"Completed":e===o&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},K3o=(t,e)=>{const o=t.pipelineDef[e].solverName,i=Y3o(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}},W3o=({status:t})=>{const e={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return V.jsx("span",{className:`font-medium ${e[t]}`,children:t})},j3o=({progress:t})=>{if(t===0)return null;const e=Math.round(t*100);return V.jsxs("div",{className:"flex items-center gap-2",children:[V.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:V.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${e}%`}})}),V.jsxs("span",{className:"text-xs text-gray-500",children:[e,"%"]})]})},X3o=t=>Object.entries(t).map(([e,n])=>`${e}: ${n}`).join(", "),J3o=({stats:t})=>{if(!t||Object.keys(t).length===0)return V.jsx("span",{children:"-"});const e=Object.entries(t),n=X3o(t);return V.jsxs("details",{className:"cursor-pointer",children:[V.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:n}),V.jsx("div",{className:"mt-1 text-xs",children:e.map(([o,i])=>V.jsxs("div",{children:[o,": ",String(i)]},o))})]})},yBe=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(yBe);const e={};for(const[n,o]of Object.entries(t))n.startsWith("_")||(e[n]=yBe(o));return e},q3o=(t,e)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${e}`);return}const n=yBe(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)}`)}},$3o=({solver:t,onStepUntilPhase:e,onDownloadInput:n})=>{const o=t.pipelineDef.map((a,c)=>K3o(t,c)),i=a=>{e?.(a)},r=a=>{a.solverInstance&&(n?n(a.solverInstance,a.name):q3o(a.solverInstance,a.name))},s=a=>`${(a/1e3).toFixed(2)}s`;return V.jsxs("div",{className:"border-t border-gray-200",children:[V.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:V.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),V.jsx("div",{className:"overflow-x-auto",children:V.jsxs("table",{className:"w-full text-sm",children:[V.jsx("thead",{children:V.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),V.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",V.jsx("sub",{children:"0"})]}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),V.jsx("tbody",{children:o.map(a=>V.jsxs("tr",{className:`border-b border-gray-100 ${a.status==="In Progress"?"bg-yellow-50":""}`,children:[V.jsx("td",{className:"px-4 py-2",children:V.jsxs("div",{className:"flex items-center gap-2",children:[V.jsx("span",{className:"text-gray-400 w-6",children:String(a.index+1).padStart(2,"0")}),V.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:V.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:V.jsx("path",{fillRule:"evenodd",d:"M4.5 5.653c0-1.426 1.529-2.33 2.779-1.643l11.54 6.348c1.295.712 1.295 2.573 0 3.285L7.28 19.991c-1.25.687-2.779-.217-2.779-1.643V5.653z",clipRule:"evenodd"})})}),V.jsx("span",{className:"font-medium text-gray-900",children:a.name})]})}),V.jsx("td",{className:"px-4 py-2",children:V.jsx(W3o,{status:a.status})}),V.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:a.firstIteration!==null?a.firstIteration:""}),V.jsx("td",{className:"px-4 py-2 text-gray-600",children:a.iterations}),V.jsx("td",{className:"px-4 py-2",children:V.jsx(j3o,{progress:a.progress})}),V.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(a.timeSpent)}),V.jsx("td",{className:"px-4 py-2 text-gray-500",children:V.jsx(J3o,{stats:a.stats})}),V.jsx("td",{className:"px-4 py-2",children:a.solverInstance?V.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:[V.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:V.jsx("path",{fillRule:"evenodd",d:"M12 2.25a.75.75 0 01.75.75v11.69l3.22-3.22a.75.75 0 111.06 1.06l-4.5 4.5a.75.75 0 01-1.06 0l-4.5-4.5a.75.75 0 111.06-1.06l3.22 3.22V3a.75.75 0 01.75-.75zm-9 13.5a.75.75 0 01.75.75v2.25a1.5 1.5 0 001.5 1.5h13.5a1.5 1.5 0 001.5-1.5V16.5a.75.75 0 011.5 0v2.25a3 3 0 01-3 3H5.25a3 3 0 01-3-3V16.5a.75.75 0 01.75-.75z",clipRule:"evenodd"})}),V.jsx("span",{children:"Input"})]}):null})]},a.name))})]})})]})},Z3o=class extends Ur.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 evo({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 V.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${d} ${_} ${h} ${m}`,role:"img","aria-label":"Graphics fallback",children:[o.map((p,g)=>V.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)=>V.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)=>V.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)=>V.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)=>V.jsx("text",{x:p.x??0,y:p.y??0,fontSize:p.fontSize??10,fill:p.color??"black",children:p.text??""},`text-${g}`))]})}var tvo=({solver:t,animationSpeed:e=25,onSolverStarted:n,onSolverCompleted:o})=>{const[i,r]=j.useReducer(A=>A+1,0),s=j.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(A){return console.error("Visualization error:",A),{points:[],lines:[],rects:[],circles:[]}}},[t,i]),a=j.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);j.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 V.jsxs("div",{children:[V.jsx(V3o,{solver:t,triggerRender:r,animationSpeed:e,onSolverStarted:n,onSolverCompleted:o}),a?V.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):V.jsx(Z3o,{fallback:V.jsx(evo,{graphics:s}),children:V.jsx(G3o,{graphics:s})}),c&&V.jsx($3o,{solver:t,onStepUntilPhase:l})]})};const nvo=()=>{j.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)},[])},ovo=t=>t.toLowerCase().includes("pack")?lho:t.toLowerCase().includes("rout")?mho:Xdo,ivo=({solverEvents:t=[]})=>{const[e,n]=j.useState(null);nvo();const o=j.useMemo(()=>{const a=new Map;for(const c of t){const l=`${c.componentName}-${c.solverName}`;a.set(l,c)}return a},[t]),i=j.useMemo(()=>Array.from(o.keys()),[o]),r=e?o.get(e):null,s=j.useMemo(()=>{if(!r)return{instance:null,error:null,classFound:!1};const a=gge[r.solverName];if(!a)return{instance:null,error:`Solver class "${r.solverName}" not found in SOLVERS registry. Available: ${Object.keys(gge).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?V.jsx("div",{className:"rf-p-4",children:V.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:V.jsxs("div",{className:"rf-p-4",children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),V.jsx("p",{className:"rf-text-sm rf-text-gray-600",children:"Solvers will appear here when the circuit runs. Solvers are used for tasks like component packing and autorouting."})]})})}):V.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[V.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[V.jsxs("div",{className:"rf-text-xs rf-font-semibold rf-text-gray-500 rf-px-3 rf-py-2 rf-bg-gray-50 rf-border-b rf-border-gray-200",children:[i.length," ",i.length===1?"Solver":"Solvers"]}),i.map(a=>{const c=o.get(a),l=e===a;return V.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=ovo(c.solverName);return V.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[V.jsx(A,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),V.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[V.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:c.componentName}),V.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:c.solverName})]})]})})()},a)})]}),V.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:r?s.instance?V.jsx(sI,{fallback:V.jsx("div",{className:"rf-p-4",children:V.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),V.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",r.solverName]})]})}),children:V.jsx(tvo,{solver:s.instance})}):V.jsxs("div",{className:"rf-p-4",children:[V.jsxs("div",{className:"rf-mb-4",children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:r.solverName}),V.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",r.componentName]})]}),s.error&&V.jsx("div",{className:`rf-rounded-md rf-border rf-p-4 rf-mb-4 ${s.classFound?"rf-bg-red-50 rf-border-red-200":"rf-bg-yellow-50 rf-border-yellow-200"}`,children:V.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),V.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[V.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:V.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),V.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:V.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(r.solverParams,null,2)})})]})]}):V.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:V.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},Fvt=({errorMessage:t,errorStack:e,circuitJsonErrors:n})=>{j.useEffect(()=>{if(t){const o=new Error(t);e&&(o.stack=e);try{xD.captureException(o)}catch{}}},[t,e]),j.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{xD.captureException(i,{error_type:o.type})}catch{}}},[n])},Ovt=t=>{j.useEffect(()=>{try{eDn(t)}catch{}},[t.source,t.component,t.isWebEmbedded,t.activeTab])},Gvt="0.0.2159",rvo={version:Gvt},gne=Iit()(Eit(t=>({lastRunEvalVersion:void 0,setLastRunEvalVersion:e=>{t({lastRunEvalVersion:e})}}),{name:"runframe-runner-store"})),svo=t=>{const[e,n]=j.useState([]),[o,i]=j.useState(null),[r,s]=j.useState(""),[a,c]=$w("eval-version-selection",null),l=gne(_=>_.setLastRunEvalVersion),A=gne(_=>_.lastRunEvalVersion);return j.useEffect(()=>{t&&fetch("https://data.jsdelivr.com/v1/package/npm/@tscircuit/eval").then(_=>_.json()).then(_=>{if(Array.isArray(_?.versions)){let h=[..._.versions];_.tags?.latest&&(i(_.tags.latest),h=h.filter(m=>m!==_.tags.latest)),n(h)}}).catch(()=>{})},[t]),j.useEffect(()=>{t&&(a?(window.TSCIRCUIT_LATEST_EVAL_VERSION=a,l(a)):o&&(window.TSCIRCUIT_LATEST_EVAL_VERSION=o,l(o)))},[t,a,o]),{versions:j.useMemo(()=>e.filter(_=>_.includes(r)).slice(0,50),[e,r]),latestVersion:o,lastRunEvalVersion:A,search:r,setSearch:s,selectVersion:_=>{c(_),s("")}}},avo=({snippetNames:t,onSelect:e,onCancel:n,isOpen:o})=>{const[i,r]=j.useState(""),[s,a]=j.useState("");if(!o)return null;const c=t.filter(u=>u.toLowerCase().includes(s.toLowerCase())),l=s&&!t.includes(s),A=u=>{u.key==="Enter"&&(c.length===1?r(c[0]):l&&r(s))};return V.jsx("div",{className:"rf-fixed rf-inset-0 rf-bg-black rf-bg-opacity-50 rf-flex rf-items-center rf-justify-center rf-z-[100]",children:V.jsxs("div",{className:"rf-bg-white rf-rounded-lg rf-p-6 rf-w-96",children:[V.jsx("h2",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Select Snippet"}),V.jsx("input",{type:"text",className:"rf-w-full rf-px-4 rf-py-2 rf-border rf-rounded rf-mb-4",placeholder:"Search snippets or new snippet name...",value:s,onChange:u=>a(u.target.value),onKeyDown:A}),V.jsxs("div",{className:"rf-h-60 rf-overflow-y-auto",children:[c.map(u=>V.jsx("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 ${i===u?"bg-blue-50":""}`,onClick:()=>r(u),children:u},u)),l&&V.jsxs("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 text-blue-500 ${i===s?"bg-blue-50":""}`,onClick:()=>r(s),children:['Create new "',s,'"']})]}),V.jsxs("div",{className:"rf-mt-4 rf-flex rf-justify-end rf-gap-2",children:[V.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-text-gray-600 rf-hover:text-gray-800",onClick:n,children:"Cancel"}),V.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-bg-blue-500 rf-text-white rf-rounded rf-hover:bg-blue-600 rf-disabled:opacity-50",onClick:()=>i&&e(i),disabled:!i,children:i===s?`Create "${i}"`:`Save to ${i}`})]})]})})},cvo=t=>{const e=j.useRef(null),n=I0(o=>o.recentEvents);j.useEffect(()=>{if(n.length===0)return;const o=n[0];o.event_id!==e.current&&(t(o),e.current=o.event_id)},[n,t])};var pne="Dialog",[Uvt,zvt]=o5(pne),[lvo,D5]=Uvt(pne),fne=t=>{const{__scopeDialog:e,children:n,open:o,defaultOpen:i,onOpenChange:r,modal:s=!0}=t,a=j.useRef(null),c=j.useRef(null),[l,A]=v3({prop:o,defaultProp:i??!1,onChange:r,caller:pne});return V.jsx(lvo,{scope:e,triggerRef:a,contentRef:c,contentId:pp(),titleId:pp(),descriptionId:pp(),open:l,onOpenChange:A,onOpenToggle:j.useCallback(()=>A(u=>!u),[A]),modal:s,children:n})};fne.displayName=pne;var Vvt="DialogTrigger",Yvt=j.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,i=D5(Vvt,n),r=Au(e,i.triggerRef);return V.jsx(La.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":IBe(i.open),...o,ref:r,onClick:Er(t.onClick,i.onOpenToggle)})});Yvt.displayName=Vvt;var CBe="DialogPortal",[Avo,Kvt]=Uvt(CBe,{forceMount:void 0}),yne=t=>{const{__scopeDialog:e,forceMount:n,children:o,container:i}=t,r=D5(CBe,e);return V.jsx(Avo,{scope:e,forceMount:n,children:j.Children.map(o,s=>V.jsx(IC,{present:n||r.open,children:V.jsx(Tee,{asChild:!0,container:i,children:s})}))})};yne.displayName=CBe;var Cne="DialogOverlay",aG=j.forwardRef((t,e)=>{const n=Kvt(Cne,t.__scopeDialog),{forceMount:o=n.forceMount,...i}=t,r=D5(Cne,t.__scopeDialog);return r.modal?V.jsx(IC,{present:o||r.open,children:V.jsx(dvo,{...i,ref:e})}):null});aG.displayName=Cne;var uvo=K6("DialogOverlay.RemoveScroll"),dvo=j.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,i=D5(Cne,n),r=who(),s=Au(e,r);return V.jsx(Gee,{as:uvo,allowPinchZoom:!0,shards:[i.contentRef],children:V.jsx(La.div,{"data-state":IBe(i.open),...o,ref:s,style:{pointerEvents:"auto",...o.style}})})}),vT="DialogContent",cG=j.forwardRef((t,e)=>{const n=Kvt(vT,t.__scopeDialog),{forceMount:o=n.forceMount,...i}=t,r=D5(vT,t.__scopeDialog);return V.jsx(IC,{present:o||r.open,children:r.modal?V.jsx(hvo,{...i,ref:e}):V.jsx(_vo,{...i,ref:e})})});cG.displayName=vT;var hvo=j.forwardRef((t,e)=>{const n=D5(vT,t.__scopeDialog),o=j.useRef(null),i=Au(e,n.contentRef,o);return j.useEffect(()=>{const r=o.current;if(r)return h3e(r)},[]),V.jsx(Wvt,{...t,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:Er(t.onCloseAutoFocus,r=>{r.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:Er(t.onPointerDownOutside,r=>{const s=r.detail.originalEvent,a=s.button===0&&s.ctrlKey===!0;(s.button===2||a)&&r.preventDefault()}),onFocusOutside:Er(t.onFocusOutside,r=>r.preventDefault())})}),_vo=j.forwardRef((t,e)=>{const n=D5(vT,t.__scopeDialog),o=j.useRef(!1),i=j.useRef(!1);return V.jsx(Wvt,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:r=>{t.onCloseAutoFocus?.(r),r.defaultPrevented||(o.current||n.triggerRef.current?.focus(),r.preventDefault()),o.current=!1,i.current=!1},onInteractOutside:r=>{t.onInteractOutside?.(r),r.defaultPrevented||(o.current=!0,r.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const s=r.target;n.triggerRef.current?.contains(s)&&r.preventDefault(),r.detail.originalEvent.type==="focusin"&&i.current&&r.preventDefault()}})}),Wvt=j.forwardRef((t,e)=>{const{__scopeDialog:n,trapFocus:o,onOpenAutoFocus:i,onCloseAutoFocus:r,...s}=t,a=D5(vT,n);return KPe(),V.jsx(V.Fragment,{children:V.jsx(Cee,{asChild:!0,loop:!0,trapped:o,onMountAutoFocus:i,onUnmountAutoFocus:r,children:V.jsx(eO,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":IBe(a.open),...s,ref:e,deferPointerDownOutside:!0,onDismiss:()=>a.onOpenChange(!1)})})})}),jvt="DialogTitle",xne=j.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,i=D5(jvt,n);return V.jsx(La.h2,{id:i.titleId,...o,ref:e})});xne.displayName=jvt;var Xvt="DialogDescription",Ine=j.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,i=D5(Xvt,n);return V.jsx(La.p,{id:i.descriptionId,...o,ref:e})});Ine.displayName=Xvt;var Jvt="DialogClose",xBe=j.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,i=D5(Jvt,n);return V.jsx(La.button,{type:"button",...o,ref:e,onClick:Er(t.onClick,()=>i.onOpenChange(!1))})});xBe.displayName=Jvt;function IBe(t){return t?"open":"closed"}var qvt="AlertDialog",[mvo]=o5(qvt,[zvt]),lS=zvt(),$vt=t=>{const{__scopeAlertDialog:e,...n}=t,o=lS(e);return V.jsx(fne,{...o,...n,modal:!0})};$vt.displayName=qvt;var gvo="AlertDialogTrigger",pvo=j.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,i=lS(n);return V.jsx(Yvt,{...i,...o,ref:e})});pvo.displayName=gvo;var fvo="AlertDialogPortal",Zvt=t=>{const{__scopeAlertDialog:e,...n}=t,o=lS(e);return V.jsx(yne,{...o,...n})};Zvt.displayName=fvo;var yvo="AlertDialogOverlay",eBt=j.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,i=lS(n);return V.jsx(aG,{...i,...o,ref:e})});eBt.displayName=yvo;var tBt="AlertDialogContent",[Cvo,xvo]=mvo(tBt),nBt=j.forwardRef((t,e)=>{const{__scopeAlertDialog:n,children:o,...i}=t,r=lS(n),s=j.useRef(null),a=Au(e,s),c=j.useRef(null);return V.jsx(Cvo,{scope:n,cancelRef:c,children:V.jsx(cG,{role:"alertdialog",...r,...i,ref:a,onOpenAutoFocus:Er(i.onOpenAutoFocus,l=>{l.preventDefault(),c.current?.focus({preventScroll:!0})}),onPointerDownOutside:l=>l.preventDefault(),onInteractOutside:l=>l.preventDefault(),children:o})})});nBt.displayName=tBt;var Ivo="AlertDialogTitle",oBt=j.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,i=lS(n);return V.jsx(xne,{...i,...o,ref:e})});oBt.displayName=Ivo;var Evo="AlertDialogDescription",iBt=j.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,i=lS(n);return V.jsx(Ine,{...i,...o,ref:e})});iBt.displayName=Evo;var bvo="AlertDialogAction",rBt=j.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,i=lS(n);return V.jsx(xBe,{...i,...o,ref:e})});rBt.displayName=bvo;var sBt="AlertDialogCancel",aBt=j.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,{cancelRef:i}=xvo(sBt,n),r=lS(n),s=Au(e,i);return V.jsx(xBe,{...r,...o,ref:s})});aBt.displayName=sBt;var Svo=$vt,Pvo=Zvt,cBt=eBt,lBt=nBt,ABt=rBt,uBt=aBt,dBt=oBt,hBt=iBt;const _Bt=Svo,vvo=Pvo,mBt=j.forwardRef(({className:t,...e},n)=>V.jsx(cBt,{className:Hi("rf-fixed rf-inset-0 rf-z-50 rf-bg-black/80 data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0",t),...e,ref:n}));mBt.displayName=cBt.displayName;const EBe=j.forwardRef(({className:t,...e},n)=>V.jsxs(vvo,{children:[V.jsx(mBt,{}),V.jsx(lBt,{ref:n,className:Hi("rf-fixed rf-left-[50%] rf-top-[50%] rf-z-50 rf-grid rf-w-full rf-max-w-lg rf-translate-x-[-50%] rf-translate-y-[-50%] rf-gap-4 rf-border rf-border-zinc-200 rf-bg-white rf-p-6 rf-shadow-lg rf-duration-200 data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0 data-[state=closed]:rf-zoom-out-95 data-[state=open]:rf-zoom-in-95 data-[state=closed]:rf-slide-out-to-left-1/2 data-[state=closed]:rf-slide-out-to-top-[48%] data-[state=open]:rf-slide-in-from-left-1/2 data-[state=open]:rf-slide-in-from-top-[48%] sm:rf-rounded-lg dark:rf-border-zinc-800 dark:rf-bg-zinc-950",t),...e})]}));EBe.displayName=lBt.displayName;const bBe=({className:t,...e})=>V.jsx("div",{className:Hi("rf-flex rf-flex-col rf-space-y-2 rf-text-center sm:rf-text-left",t),...e});bBe.displayName="AlertDialogHeader";const SBe=({className:t,...e})=>V.jsx("div",{className:Hi("rf-flex rf-flex-col-reverse sm:rf-flex-row sm:rf-justify-end sm:rf-space-x-2",t),...e});SBe.displayName="AlertDialogFooter";const PBe=j.forwardRef(({className:t,...e},n)=>V.jsx(dBt,{ref:n,className:Hi("rf-text-lg rf-font-semibold",t),...e}));PBe.displayName=dBt.displayName;const vBe=j.forwardRef(({className:t,...e},n)=>V.jsx(hBt,{ref:n,className:Hi("rf-text-sm rf-text-zinc-500 dark:rf-text-zinc-400",t),...e}));vBe.displayName=hBt.displayName;const Bvo=j.forwardRef(({className:t,...e},n)=>V.jsx(ABt,{ref:n,className:Hi(KQ(),t),...e}));Bvo.displayName=ABt.displayName;const BBe=j.forwardRef(({className:t,...e},n)=>V.jsx(uBt,{ref:n,className:Hi(KQ({variant:"outline"}),"rf-mt-2 sm:rf-mt-0",t),...e}));BBe.displayName=uBt.displayName;function Mvo(t){const e=j.useRef({value:t,previous:t});return j.useMemo(()=>(e.current.value!==t&&(e.current.previous=e.current.value,e.current.value=t),e.current.previous),[t])}var Ene="Checkbox",[wvo]=o5(Ene),[Dvo,MBe]=wvo(Ene);function Qvo(t){const{__scopeCheckbox:e,checked:n,children:o,defaultChecked:i,disabled:r,form:s,name:a,onCheckedChange:c,required:l,value:A="on",internal_do_not_use_render:u}=t,[d,_]=v3({prop:n,defaultProp:i??!1,onChange:c,caller:Ene}),[h,m]=j.useState(null),[p,g]=j.useState(null),f=j.useRef(!1),y=h?!!s||!!h.closest("form"):!0,C={checked:d,disabled:r,setChecked:_,control:h,setControl:m,name:a,form:s,value:A,hasConsumerStoppedPropagationRef:f,required:l,defaultChecked:Qv(i)?!1:i,isFormControl:y,bubbleInput:p,setBubbleInput:g};return V.jsx(Dvo,{scope:e,...C,children:Tvo(u)?u(C):o})}var gBt="CheckboxTrigger",pBt=j.forwardRef(({__scopeCheckbox:t,onKeyDown:e,onClick:n,...o},i)=>{const{control:r,value:s,disabled:a,checked:c,required:l,setControl:A,setChecked:u,hasConsumerStoppedPropagationRef:d,isFormControl:_,bubbleInput:h}=MBe(gBt,t),m=Au(i,A),p=j.useRef(c);return j.useEffect(()=>{const g=r?.form;if(g){const f=()=>u(p.current);return g.addEventListener("reset",f),()=>g.removeEventListener("reset",f)}},[r,u]),V.jsx(La.button,{type:"button",role:"checkbox","aria-checked":Qv(c)?"mixed":c,"aria-required":l,"data-state":IBt(c),"data-disabled":a?"":void 0,disabled:a,value:s,...o,ref:m,onKeyDown:Er(e,g=>{g.key==="Enter"&&g.preventDefault()}),onClick:Er(n,g=>{u(f=>Qv(f)?!0:!f),h&&_&&(d.current=g.isPropagationStopped(),d.current||g.stopPropagation())})})});pBt.displayName=gBt;var wBe=j.forwardRef((t,e)=>{const{__scopeCheckbox:n,name:o,checked:i,defaultChecked:r,required:s,disabled:a,value:c,onCheckedChange:l,form:A,...u}=t;return V.jsx(Qvo,{__scopeCheckbox:n,checked:i,defaultChecked:r,disabled:a,required:s,onCheckedChange:l,name:o,form:A,value:c,internal_do_not_use_render:({isFormControl:d})=>V.jsxs(V.Fragment,{children:[V.jsx(pBt,{...u,ref:e,__scopeCheckbox:n}),d&&V.jsx(xBt,{__scopeCheckbox:n})]})})});wBe.displayName=Ene;var fBt="CheckboxIndicator",yBt=j.forwardRef((t,e)=>{const{__scopeCheckbox:n,forceMount:o,...i}=t,r=MBe(fBt,n);return V.jsx(IC,{present:o||Qv(r.checked)||r.checked===!0,children:V.jsx(La.span,{"data-state":IBt(r.checked),"data-disabled":r.disabled?"":void 0,...i,ref:e,style:{pointerEvents:"none",...t.style}})})});yBt.displayName=fBt;var CBt="CheckboxBubbleInput",xBt=j.forwardRef(({__scopeCheckbox:t,...e},n)=>{const{control:o,hasConsumerStoppedPropagationRef:i,checked:r,defaultChecked:s,required:a,disabled:c,name:l,value:A,form:u,bubbleInput:d,setBubbleInput:_}=MBe(CBt,t),h=Au(n,_),m=Mvo(r),p=A4t(o);j.useEffect(()=>{const f=d;if(!f)return;const y=window.HTMLInputElement.prototype,I=Object.getOwnPropertyDescriptor(y,"checked").set,E=!i.current;if(m!==r&&I){const b=new Event("click",{bubbles:E});f.indeterminate=Qv(r),I.call(f,Qv(r)?!1:r),f.dispatchEvent(b)}},[d,m,r,i]);const g=j.useRef(Qv(r)?!1:r);return V.jsx(La.input,{type:"checkbox","aria-hidden":!0,defaultChecked:s??g.current,required:a,disabled:c,name:l,value:A,form:u,...e,tabIndex:-1,ref:h,style:{...e.style,...p,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});xBt.displayName=CBt;function Tvo(t){return typeof t=="function"}function Qv(t){return t==="indeterminate"}function IBt(t){return Qv(t)?"indeterminate":t?"checked":"unchecked"}const lG=j.forwardRef(({className:t,...e},n)=>V.jsx(wBe,{ref:n,className:Hi("rf-peer rf-h-4 rf-w-4 rf-shrink-0 rf-rounded-sm rf-border rf-border-zinc-200 rf-border-zinc-900 rf-shadow focus-visible:rf-outline-none focus-visible:rf-ring-1 focus-visible:rf-ring-zinc-950 disabled:rf-cursor-not-allowed disabled:rf-opacity-50 data-[state=checked]:rf-bg-zinc-900 data-[state=checked]:rf-text-zinc-50 dark:rf-border-zinc-800 dark:rf-border-zinc-50 dark:focus-visible:rf-ring-zinc-300 dark:data-[state=checked]:rf-bg-zinc-50 dark:data-[state=checked]:rf-text-zinc-900",t),...e,children:V.jsx(yBt,{className:Hi("rf-flex rf-items-center rf-justify-center rf-text-current"),children:V.jsx(j8,{className:"rf-h-4 rf-w-4"})})}));lG.displayName=wBe.displayName;const BT=fne,Nvo=yne,EBt=j.forwardRef(({className:t,...e},n)=>V.jsx(aG,{className:Hi("rf-fixed rf-inset-0 rf-z-50 rf-bg-black/80 data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0",t),...e,ref:n}));EBt.displayName=aG.displayName;const gM=j.forwardRef(({className:t,children:e,showOverlay:n=!0,...o},i)=>V.jsxs(Nvo,{children:[V.jsx(EBt,{className:Hi(n?"":"rf-hidden")}),V.jsx(cG,{ref:i,className:Hi("rf-fixed rf-left-[50%] rf-top-[50%] rf-z-50 rf-grid rf-w-full rf-max-w-lg rf-translate-x-[-50%] rf-translate-y-[-50%] rf-gap-4 rf-border rf-border-zinc-200 rf-bg-white rf-p-6 rf-shadow-lg rf-duration-200 data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0 data-[state=closed]:rf-zoom-out-95 data-[state=open]:rf-zoom-in-95 data-[state=closed]:rf-slide-out-to-left-1/2 data-[state=closed]:rf-slide-out-to-top-[48%] data-[state=open]:rf-slide-in-from-left-1/2 data-[state=open]:rf-slide-in-from-top-[48%] sm:rf-rounded-lg dark:rf-border-zinc-800 dark:rf-bg-zinc-950",t),...o,children:e})]}));gM.displayName=cG.displayName;const pM=({className:t,...e})=>V.jsx("div",{className:Hi("rf-flex rf-flex-col rf-space-y-2 rf-text-center sm:rf-text-left",t),...e});pM.displayName="DialogHeader";const AG=({className:t,...e})=>V.jsx("div",{className:Hi("rf-flex rf-flex-col-reverse sm:rf-flex-row sm:rf-justify-end sm:rf-space-x-2",t),...e});AG.displayName="DialogFooter";const fM=j.forwardRef(({className:t,...e},n)=>V.jsx(xne,{ref:n,className:Hi("rf-text-lg rf-font-semibold",t),...e}));fM.displayName=xne.displayName;const MT=j.forwardRef(({className:t,...e},n)=>V.jsx(Ine,{ref:n,className:Hi("rf-text-sm rf-text-zinc-500 dark:rf-text-zinc-400",t),...e}));MT.displayName=Ine.displayName;const bne={"tscircuit.com":{label:"tscircuit.com",placeholder:"Search tscircuit packages...",emptyMessage:"No packages found"},jlcpcb:{label:"JLCPCB Parts",placeholder:"Search JLCPCB parts (e.g. C14663)...",emptyMessage:"No parts found"},kicad:{label:"KiCad Footprints",placeholder:"Search KiCad footprints...",emptyMessage:"No footprints found"}},Rvo="https://cdn.jsdelivr.net/npm/easyeda@latest/dist/browser/index.js";let DBe=null;const QBe=async()=>(DBe||(DBe=import(Rvo)),DBe),kvo=t=>(e,n)=>{const o=new Headers(n?.headers),i={};return o.forEach((r,s)=>{i[s]=r}),fetch(`${t?.apiBase??L1}/proxy`,{...n,headers:{...i,"X-Target-Url":e.toString(),"X-Sender-Origin":i.origin??"","X-Sender-Host":i.host??"https://easyeda.com","X-Sender-Referer":i.referer??"","X-Sender-User-Agent":i["user-agent"]??"","X-Sender-Cookie":i.cookie??"",authority:i.authority??"","content-type":i["content-type"]??"",...t?.headers}})},Lvo=async(t,e=10)=>{const n=encodeURIComponent(t),o=await fetch(`https://jlcsearch.tscircuit.com/api/search?limit=${e}&q=${n}`);if(!o.ok)throw new Error(`JLCPCB API error: ${o.status}`);return(await o.json()).components??[]},Hvo=t=>({lcscId:t.lcsc,manufacturer:t.mfr,description:t.description,partNumber:`C${t.lcsc}`,package:t.package,price:t.price,stock:t.stock,isBasic:t.is_basic}),bBt=async(t,e)=>{const{fetchEasyEDAComponent:n}=await QBe();return n(t,{fetch:kvo(e),includeModelMetadata:e?.includeModelMetadata})},Fvo=async(t,e)=>{const{convertRawEasyToTsx:n}=await QBe(),o=await bBt(t,e);return n({rawEasy:o})},Ovo=async(t,e)=>{const{EasyEdaJsonSchema:n,convertEasyEdaJsonToCircuitJson:o}=await QBe(),i=await bBt(t,{...e,includeModelMetadata:!1}),r=n.parse(i);return o(r,{shouldRecenter:!0,showDesignator:!0,useModelCdn:!1})};function Tv(t){return Array.isArray?Array.isArray(t):PBt(t)==="[object Array]"}function Gvo(t){if(typeof t=="string")return t;if(typeof t=="bigint")return t.toString();const e=t+"";return e=="0"&&1/t==-1/0?"-0":e}function TBe(t){return t==null?"":Gvo(t)}function q1(t){return typeof t=="string"}function Sne(t){return typeof t=="number"}function Uvo(t){return t===!0||t===!1||zvo(t)&&PBt(t)=="[object Boolean]"}function SBt(t){return typeof t=="object"}function zvo(t){return SBt(t)&&t!==null}function UC(t){return t!=null}function Pne(t){return!t.trim().length}function PBt(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const Vvo="Incorrect 'index' type",NBe="Invalid doc index: must be a non-negative integer within the bounds of the docs array",Yvo=t=>`Invalid value for key ${t}`,Kvo=t=>`Pattern length exceeds max of ${t}.`,Wvo=t=>`Missing ${t} property in key`,jvo=t=>`Property 'weight' in key '${t}' must be a positive integer`,Xvo="Fuse.match does not support useTokenSearch: token search requires corpus-level statistics (df, fieldCount) that a one-off string comparison does not have. Use new Fuse(...).search(...) instead.",vBt=Object.prototype.hasOwnProperty;var Jvo=class{constructor(t){this._keys=[],this._keyMap={};let e=0;t.forEach(n=>{const o=BBt(n);this._keys.push(o),this._keyMap[o.id]=o,e+=o.weight}),this._keys.forEach(n=>{n.weight/=e})}get(t){return this._keyMap[t]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}};function BBt(t){let e=null,n=null,o=null,i=1,r=null;if(q1(t)||Tv(t))o=t,e=MBt(t),n=vne(t);else{if(!vBt.call(t,"name"))throw new Error(Wvo("name"));const s=t.name;if(o=s,vBt.call(t,"weight")&&t.weight!==void 0&&(i=t.weight,i<=0))throw new Error(jvo(vne(s)));e=MBt(s),n=vne(s),r=t.getFn??null}return{path:e,id:n,weight:i,src:o,getFn:r}}function MBt(t){return Tv(t)?t:t.split(".")}function vne(t){return Tv(t)?t.join("."):t}function qvo(t,e){const n=[];let o=!1;const i=(r,s,a,c)=>{if(UC(r))if(!s[a])n.push(c!==void 0?{v:r,i:c}:r);else{const l=r[s[a]];if(!UC(l))return;if(a===s.length-1&&(q1(l)||Sne(l)||Uvo(l)||typeof l=="bigint"))n.push(c!==void 0?{v:TBe(l),i:c}:TBe(l));else if(Tv(l)){o=!0;for(let A=0,u=l.length;A<u;A+=1)i(l[A],s,a+1,A)}else s.length&&i(l,s,a+1,c)}};return i(t,q1(e)?e.split("."):e,0),o?n:n[0]}const Es=Object.freeze({...{isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(t,e)=>t.score===e.score?t.idx<e.idx?-1:1:t.score<e.score?-1:1},...{includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},...{location:0,threshold:.6,distance:100},...{useExtendedSearch:!1,useTokenSearch:!1,tokenize:void 0,tokenMatch:"any",getFn:qvo,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1}});function $vo(t=1,e=3){const n=new Map,o=Math.pow(10,e);return{get(i){let r=1,s=!1;for(let c=0;c<i.length;c++)i.charCodeAt(c)===32?s||(r++,s=!0):s=!1;if(n.has(r))return n.get(r);const a=Math.round(o/Math.pow(r,.5*t))/o;return n.set(r,a),a},clear(){n.clear()}}}var RBe=class{constructor({getFn:t=Es.getFn,fieldNormWeight:e=Es.fieldNormWeight}={}){this.norm=$vo(e,3),this.getFn=t,this.isCreated=!1,this.docs=[],this.keys=[],this._keysMap={},this.setIndexRecords()}setSources(t=[]){this.docs=t}setIndexRecords(t=[]){this.records=t}setKeys(t=[]){this.keys=t,this._keysMap={},t.forEach((e,n)=>{this._keysMap[e.id]=n})}create(){if(this.isCreated||!this.docs.length)return;this.isCreated=!0;const t=this.docs.length;this.records=new Array(t);let e=0;if(q1(this.docs[0]))for(let n=0;n<t;n++){const o=this._createStringRecord(this.docs[n],n);o&&(this.records[e++]=o)}else for(let n=0;n<t;n++)this.records[e++]=this._createObjectRecord(this.docs[n],n);this.records.length=e,this.norm.clear()}add(t,e){if(!Number.isInteger(e)||e<0)throw new Error(NBe);if(q1(t)){const o=this._createStringRecord(t,e);return o&&this.records.push(o),o}const n=this._createObjectRecord(t,e);return this.records.push(n),n}removeAt(t){if(!Number.isInteger(t)||t<0)throw new Error(NBe);for(let e=0,n=this.records.length;e<n;e+=1)if(this.records[e].i===t){this.records.splice(e,1);break}for(let e=0,n=this.records.length;e<n;e+=1)this.records[e].i>t&&(this.records[e].i-=1)}removeAll(t){const e=new Set;for(const o of t)Number.isInteger(o)&&o>=0&&e.add(o);if(e.size===0)return;this.records=this.records.filter(o=>!e.has(o.i));const n=Array.from(e).sort((o,i)=>o-i);for(const o of this.records){let i=0,r=n.length;for(;i<r;){const s=i+r>>>1;n[s]<o.i?i=s+1:r=s}o.i-=i}}getValueForItemAtKeyId(t,e){return t[this._keysMap[e]]}size(){return this.records.length}_createStringRecord(t,e){return!UC(t)||Pne(t)?null:{v:t,i:e,n:this.norm.get(t)}}_createObjectRecord(t,e){const n={i:e,$:{}};for(let o=0,i=this.keys.length;o<i;o++){const r=this.keys[o],s=r.getFn?r.getFn(t):this.getFn(t,r.path);if(UC(s)){if(Tv(s)){const a=[];for(let c=0,l=s.length;c<l;c+=1){const A=s[c];if(UC(A)){if(q1(A)){if(!Pne(A)){const u={v:A,i:c,n:this.norm.get(A)};a.push(u)}}else if(UC(A.v)){const u=q1(A.v)?A.v:TBe(A.v);if(!Pne(u)){const d={v:u,i:A.i,n:this.norm.get(u)};a.push(d)}}}}n.$[o]=a}else if(q1(s)&&!Pne(s)){const a={v:s,n:this.norm.get(s)};n.$[o]=a}}}return n}toJSON(){return{keys:this.keys.map(({getFn:t,...e})=>e),records:this.records}}};function wBt(t,e,{getFn:n=Es.getFn,fieldNormWeight:o=Es.fieldNormWeight}={}){const i=new RBe({getFn:n,fieldNormWeight:o});return i.setKeys(t.map(BBt)),i.setSources(e),i.create(),i}function Zvo(t,{getFn:e=Es.getFn,fieldNormWeight:n=Es.fieldNormWeight}={}){const{keys:o,records:i}=t,r=new RBe({getFn:e,fieldNormWeight:n});return r.setKeys(o),r.setIndexRecords(i),r}function eBo(t=[],e=Es.minMatchCharLength){const n=[];let o=-1,i=-1,r=0;for(let s=t.length;r<s;r+=1){const a=t[r];a&&o===-1?o=r:!a&&o!==-1&&(i=r-1,i-o+1>=e&&n.push([o,i]),o=-1)}return t[r-1]&&r-o>=e&&n.push([o,r-1]),n}function tBo(t,e,n,{location:o=Es.location,distance:i=Es.distance,threshold:r=Es.threshold,findAllMatches:s=Es.findAllMatches,minMatchCharLength:a=Es.minMatchCharLength,includeMatches:c=Es.includeMatches,ignoreLocation:l=Es.ignoreLocation}={}){if(e.length>32)throw new Error(Kvo(32));const A=e.length,u=t.length,d=Math.max(0,Math.min(o,u));let _=r,h=d;const m=(M,w)=>{const k=M/A;if(l)return k;const N=Math.abs(d-w);return i?k+N/i:N?1:k},p=a>1||c,g=p?Array(u):[];let f;for(;(f=t.indexOf(e,h))>-1;){const M=m(0,f);if(_=Math.min(M,_),h=f+A,p){let w=0;for(;w<A;)g[f+w]=1,w+=1}}h=-1;let y=[],C=1,I=0,E=A+u;const b=1<<A-1;for(let M=0;M<A;M+=1){let w=0,k=E;for(;w<k;)m(M,d+k)<=_?w=k:E=k,k=Math.floor((E-w)/2+w);E=k;let N=Math.max(1,d-k+1);const O=s?u:Math.min(d+k,u)+A,H=Array(O+2);H[O+1]=(1<<M)-1;for(let G=O;G>=N;G-=1){const K=G-1,J=n[t[K]];if(H[G]=(H[G+1]<<1|1)&J,M&&(H[G]|=(y[G+1]|y[G])<<1|1|y[G+1]),H[G]&b&&(C=m(M,K),C<=_)){if(_=C,h=K,I=M,h<=d)break;N=Math.max(1,2*d-h)}}if(m(M+1,d)>_)break;y=H}if(p&&h>=0){const M=Math.min(u-1,h+A-1+I);for(let w=h;w<=M;w+=1)n[t[w]]&&(g[w]=1)}const P={isMatch:h>=0,score:Math.max(.001,C)};if(p){const M=eBo(g,a);M.length?c&&(P.indices=M):P.isMatch=!1}return P}function nBo(t){const e={};for(let n=0,o=t.length;n<o;n+=1){const i=t.charAt(n);e[i]=(e[i]||0)|1<<o-n-1}return e}function kBe(t){if(t.length<=1)return t;t.sort((n,o)=>n[0]-o[0]||n[1]-o[1]);const e=[t[0]];for(let n=1,o=t.length;n<o;n+=1){const i=e[e.length-1],r=t[n];r[0]<=i[1]+1?i[1]=Math.max(i[1],r[1]):e.push(r)}return e}const DBt={ł:"l",Ł:"L",đ:"d",Đ:"D",ø:"o",Ø:"O",ħ:"h",Ħ:"H",ŧ:"t",Ŧ:"T",ı:"i",ß:"ss"},oBo=new RegExp("["+Object.keys(DBt).join("")+"]","g"),uG=typeof String.prototype.normalize=="function"?t=>t.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,"").replace(oBo,e=>DBt[e]):t=>t;var LBe=class{constructor(t,{location:e=Es.location,threshold:n=Es.threshold,distance:o=Es.distance,includeMatches:i=Es.includeMatches,findAllMatches:r=Es.findAllMatches,minMatchCharLength:s=Es.minMatchCharLength,isCaseSensitive:a=Es.isCaseSensitive,ignoreDiacritics:c=Es.ignoreDiacritics,ignoreLocation:l=Es.ignoreLocation}={}){if(this.options={location:e,threshold:n,distance:o,includeMatches:i,findAllMatches:r,minMatchCharLength:s,isCaseSensitive:a,ignoreDiacritics:c,ignoreLocation:l},t=a?t:t.toLowerCase(),t=c?uG(t):t,this.pattern=t,this.chunks=[],!this.pattern.length)return;const A=(d,_)=>{this.chunks.push({pattern:d,alphabet:nBo(d),startIndex:_})},u=this.pattern.length;if(u>32){let d=0;const _=u%32,h=u-_;for(;d<h;)A(this.pattern.substr(d,32),d),d+=32;if(_){const m=u-32;A(this.pattern.substr(m),m)}}else A(this.pattern,0)}searchIn(t){const{isCaseSensitive:e,ignoreDiacritics:n,includeMatches:o}=this.options;if(t=e?t:t.toLowerCase(),t=n?uG(t):t,this.pattern===t){const h={isMatch:!0,score:0};return o&&(h.indices=[[0,t.length-1]]),h}const{location:i,distance:r,threshold:s,findAllMatches:a,minMatchCharLength:c,ignoreLocation:l}=this.options,A=[];let u=0,d=!1;this.chunks.forEach(({pattern:h,alphabet:m,startIndex:p})=>{const{isMatch:g,score:f,indices:y}=tBo(t,h,m,{location:i+p,distance:r,threshold:s,findAllMatches:a,minMatchCharLength:c,includeMatches:o,ignoreLocation:l});g&&(d=!0),u+=f,g&&y&&A.push(...y)});const _={isMatch:d,score:d?u/this.chunks.length:1};return d&&o&&(_.indices=kBe(A)),_}};const iBo=new Set(["fuzzy","include"]);function rBo(t){return t.startsWith("inverse")}const HBe=[{type:"exact",multiRegex:/^="(.*)"$/,singleRegex:/^=(.*)$/,create:t=>({type:"exact",search(e){const n=e===t;return{isMatch:n,score:n?0:1,indices:[0,t.length-1]}}})},{type:"include",multiRegex:/^'"(.*)"$/,singleRegex:/^'(.*)$/,create:t=>({type:"include",search(e){let n=0,o;const i=[],r=t.length;for(;(o=e.indexOf(t,n))>-1;)n=o+r,i.push([o,n-1]);const s=!!i.length;return{isMatch:s,score:s?0:1,indices:i}}})},{type:"prefix-exact",multiRegex:/^\^"(.*)"$/,singleRegex:/^\^(.*)$/,create:t=>({type:"prefix-exact",search(e){const n=e.startsWith(t);return{isMatch:n,score:n?0:1,indices:[0,t.length-1]}}})},{type:"inverse-prefix-exact",multiRegex:/^!\^"(.*)"$/,singleRegex:/^!\^(.*)$/,create:t=>({type:"inverse-prefix-exact",search(e){const n=!e.startsWith(t);return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}})},{type:"inverse-suffix-exact",multiRegex:/^!"(.*)"\$$/,singleRegex:/^!(.*)\$$/,create:t=>({type:"inverse-suffix-exact",search(e){const n=!e.endsWith(t);return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}})},{type:"suffix-exact",multiRegex:/^"(.*)"\$$/,singleRegex:/^(.*)\$$/,create:t=>({type:"suffix-exact",search(e){const n=e.endsWith(t);return{isMatch:n,score:n?0:1,indices:[e.length-t.length,e.length-1]}}})},{type:"inverse-exact",multiRegex:/^!"(.*)"$/,singleRegex:/^!(.*)$/,create:t=>({type:"inverse-exact",search(e){const n=e.indexOf(t)===-1;return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}})},{type:"fuzzy",multiRegex:/^"(.*)"$/,singleRegex:/^(.*)$/,create:(t,e={})=>{const n=new LBe(t,{location:e.location??Es.location,threshold:e.threshold??Es.threshold,distance:e.distance??Es.distance,includeMatches:e.includeMatches??Es.includeMatches,findAllMatches:e.findAllMatches??Es.findAllMatches,minMatchCharLength:e.minMatchCharLength??Es.minMatchCharLength,isCaseSensitive:e.isCaseSensitive??Es.isCaseSensitive,ignoreDiacritics:e.ignoreDiacritics??Es.ignoreDiacritics,ignoreLocation:e.ignoreLocation??Es.ignoreLocation});return{type:"fuzzy",search(o){return n.searchIn(o)}}}}],QBt=HBe.length,sBo="\0",aBo="|";function cBo(t){const e=[],n=t.length;let o=0;for(;o<n;){for(;o<n&&t[o]===" ";)o++;if(o>=n)break;let i=o;for(;i<n&&t[i]!==" "&&t[i]!=='"';)i++;if(i<n&&t[i]==='"'){for(i++;i<n;){if(t[i]==='"'){const r=i+1;if(r>=n||t[r]===" "){i++;break}if(t[r]==="$"&&(r+1>=n||t[r+1]===" ")){i+=2;break}}i++}e.push(t.substring(o,i)),o=i}else{for(;i<n&&t[i]!==" ";)i++;e.push(t.substring(o,i)),o=i}}return e}function TBt(t,e){const n=t.match(e);return n?n[1]:null}function lBo(t,e={}){return t.replace(/\\\|/g,sBo).split(aBo).map(n=>{const o=cBo(n.replace(/\u0000/g,"|").trim()).filter(r=>r&&!!r.trim()),i=[];for(let r=0,s=o.length;r<s;r+=1){const a=o[r];let c=!1,l=-1;for(;!c&&++l<QBt;){const A=HBe[l],u=TBt(a,A.multiRegex);u&&(i.push(A.create(u,e)),c=!0)}if(!c)for(l=-1;++l<QBt;){const A=HBe[l],u=TBt(a,A.singleRegex);if(u){i.push(A.create(u,e));break}}}return i})}var ABo=class{constructor(t,{isCaseSensitive:e=Es.isCaseSensitive,ignoreDiacritics:n=Es.ignoreDiacritics,includeMatches:o=Es.includeMatches,minMatchCharLength:i=Es.minMatchCharLength,ignoreLocation:r=Es.ignoreLocation,findAllMatches:s=Es.findAllMatches,location:a=Es.location,threshold:c=Es.threshold,distance:l=Es.distance}={}){this.query=null,this.options={isCaseSensitive:e,ignoreDiacritics:n,includeMatches:o,minMatchCharLength:i,findAllMatches:s,ignoreLocation:r,location:a,threshold:c,distance:l},t=e?t:t.toLowerCase(),t=n?uG(t):t,this.pattern=t,this.query=lBo(this.pattern,this.options)}static condition(t,e){return e.useExtendedSearch}searchIn(t){const e=this.query;if(!e)return{isMatch:!1,score:1};const{includeMatches:n,isCaseSensitive:o,ignoreDiacritics:i}=this.options;t=o?t:t.toLowerCase(),t=i?uG(t):t;let r=0;const s=[];let a=0,c=!1;for(let l=0,A=e.length;l<A;l+=1){const u=e[l];s.length=0,r=0,c=!1;for(let d=0,_=u.length;d<_;d+=1){const h=u[d],{isMatch:m,indices:p,score:g}=h.search(t);if(m)r+=1,a+=g,rBo(h.type)&&(c=!0),n&&(iBo.has(h.type)?s.push(...p):s.push(p));else{a=0,r=0,s.length=0,c=!1;break}}if(r){const d={isMatch:!0,score:a/r};return c&&(d.hasInverse=!0),n&&(d.indices=kBe(s)),d}}return{isMatch:!1,score:1}}};const FBe=[];function OBe(...t){FBe.push(...t)}function Bne(t,e){for(let n=0,o=FBe.length;n<o;n+=1){const i=FBe[n];if(i.condition(t,e))return new i(t,e)}return new LBe(t,e)}const Mne={AND:"$and",OR:"$or"},GBe={PATH:"$path",PATTERN:"$val"},UBe=t=>!!(t[Mne.AND]||t[Mne.OR]),uBo=t=>!!t[GBe.PATH],dBo=t=>!Tv(t)&&SBt(t)&&!UBe(t),NBt=t=>({[Mne.AND]:Object.keys(t).map(e=>({[e]:t[e]}))});function RBt(t,e,{auto:n=!0}={}){const o=i=>{if(q1(i)){const c={keyId:null,pattern:i};return n&&(c.searcher=Bne(i,e)),c}const r=Object.keys(i),s=uBo(i);if(!s&&r.length>1&&!UBe(i))return o(NBt(i));if(dBo(i)){const c=s?i[GBe.PATH]:r[0],l=s?i[GBe.PATTERN]:i[c];if(!q1(l))throw new Error(Yvo(c));const A={keyId:vne(c),pattern:l};return n&&(A.searcher=Bne(l,e)),A}const a={children:[],operator:r[0]};return r.forEach(c=>{const l=i[c];Tv(l)&&l.forEach(A=>{a.children.push(o(A))})}),a};return UBe(t)||(t=NBt(t)),o(t)}function zBe(t,{ignoreFieldNorm:e=Es.ignoreFieldNorm}){let n=1;return t.forEach(({key:o,norm:i,score:r})=>{const s=o?o.weight:null;n*=Math.pow(r===0&&s?Number.EPSILON:r,(s||1)*(e?1:i))}),n}function hBo(t,{ignoreFieldNorm:e=Es.ignoreFieldNorm}){t.forEach(n=>{n.score=zBe(n.matches,{ignoreFieldNorm:e})})}var _Bo=class{constructor(t){this.limit=t,this.heap=[]}get size(){return this.heap.length}shouldInsert(t){return this.size<this.limit||t<this.heap[0].score}insert(t){this.size<this.limit?(this.heap.push(t),this._bubbleUp(this.size-1)):t.score<this.heap[0].score&&(this.heap[0]=t,this._sinkDown(0))}extractSorted(t){return this.heap.sort(t)}_bubbleUp(t){const e=this.heap;for(;t>0;){const n=t-1>>1;if(e[t].score<=e[n].score)break;const o=e[t];e[t]=e[n],e[n]=o,t=n}}_sinkDown(t){const e=this.heap,n=e.length;let o=t;do{t=o;const i=2*t+1,r=2*t+2;if(i<n&&e[i].score>e[o].score&&(o=i),r<n&&e[r].score>e[o].score&&(o=r),o!==t){const s=e[t];e[t]=e[o],e[o]=s}}while(o!==t)}};function mBo(t){const e=[];return t.matches.forEach(n=>{if(!UC(n.indices)||!n.indices.length)return;const o={indices:n.indices,value:n.value};n.key&&(o.key=n.key.id),n.idx>-1&&(o.refIndex=n.idx),e.push(o)}),e}function gBo(t,e,{includeMatches:n=Es.includeMatches,includeScore:o=Es.includeScore}={}){return t.map(i=>{const{idx:r}=i,s={item:e[r],refIndex:r};return n&&(s.matches=mBo(i)),o&&(s.score=i.score),s})}const pBo=/[\p{L}\p{M}\p{N}_]+/gu,kBt=new WeakSet;function fBo(t){kBt.has(t)||(kBt.add(t),console.warn(`[Fuse] tokenize regex ${t} lacks the global flag; only the first match per text will be returned. Add the 'g' flag.`))}function yBo(t){if(typeof t=="function"){let e=!1;return n=>{const o=t(n);if(!e&&(e=!0,!Array.isArray(o)||o.some(i=>typeof i!="string")))throw new Error(`[Fuse] tokenize function must return string[]; received ${Array.isArray(o)?"array containing non-strings":typeof o}.`);return o}}return t instanceof RegExp?(t.global||fBo(t),e=>e.match(t)||[]):e=>e.match(pBo)||[]}function VBe({isCaseSensitive:t=!1,ignoreDiacritics:e=!1,tokenize:n}={}){const o=yBo(n);return{tokenize(i){return t||(i=i.toLowerCase()),e&&(i=uG(i)),o(i)}}}var CBo=class{static condition(t,e){return e.useTokenSearch}constructor(t,e){this.options=e,this.analyzer=VBe({isCaseSensitive:e.isCaseSensitive,ignoreDiacritics:e.ignoreDiacritics,tokenize:e.tokenize});const n=this.analyzer.tokenize(t),{df:o,fieldCount:i}=e._invertedIndex;this.termSearchers=[],this.idfWeights=[];for(const r of n){this.termSearchers.push(new LBe(r,{location:e.location,threshold:e.threshold,distance:e.distance,includeMatches:e.includeMatches,findAllMatches:e.findAllMatches,minMatchCharLength:e.minMatchCharLength,isCaseSensitive:e.isCaseSensitive,ignoreDiacritics:e.ignoreDiacritics,ignoreLocation:!0}));const s=o.get(r)||0,a=Math.log(1+(i-s+.5)/(s+.5));this.idfWeights.push(a)}this.combineAll=e.tokenMatch==="all",this.numTerms=this.termSearchers.length,this.useMask=this.numTerms<=31}searchIn(t){if(!this.termSearchers.length)return{isMatch:!1,score:1};const e=[];let n=0,o=0,i=0,r=0;const s=this.combineAll&&!this.useMask?new Set:null;for(let l=0;l<this.termSearchers.length;l++){const A=this.termSearchers[l].searchIn(t),u=this.idfWeights[l];o+=u,A.isMatch&&(i++,n+=u*(1-A.score),A.indices&&e.push(...A.indices),this.combineAll&&(this.useMask?r|=1<<l:s.add(l)))}if(i===0)return{isMatch:!1,score:1};const a=o>0?1-n/o:0,c={isMatch:!0,score:Math.max(.001,a)};return this.options.includeMatches&&e.length&&(c.indices=kBe(e)),this.combineAll&&(this.useMask?c.matchedMask=r:c.matchedTerms=s,c.termCount=this.numTerms),c}};function YBe(t,e,n,o){const i=o.tokenize(e);if(!i.length)return;t.fieldCount++,t.docFieldCount.set(n,(t.docFieldCount.get(n)||0)+1);const r=new Set(i);let s=t.docTermFieldHits.get(n);s||(s=new Map,t.docTermFieldHits.set(n,s));for(const a of r)s.set(a,(s.get(a)||0)+1),t.df.set(a,(t.df.get(a)||0)+1)}function LBt(t,e,n,o){const{i,v:r,$:s}=e;if(r!==void 0){YBe(t,r,i,o);return}if(s)for(let a=0;a<n;a++){const c=s[a];if(c)if(Array.isArray(c))for(const l of c)YBe(t,l.v,i,o);else YBe(t,c.v,i,o)}}function xBo(t,e,n){const o={fieldCount:0,df:new Map,docFieldCount:new Map,docTermFieldHits:new Map};for(const i of t)LBt(o,i,e,n);return o}function IBo(t,e,n,o){LBt(t,e,n,o)}function EBo(t,e){const n=t.docFieldCount.get(e);if(n===void 0)return;t.fieldCount-=n,t.docFieldCount.delete(e);const o=t.docTermFieldHits.get(e);if(o){for(const[i,r]of o){const s=(t.df.get(i)||0)-r;s<=0?t.df.delete(i):t.df.set(i,s)}t.docTermFieldHits.delete(e)}}function HBt(t,e){if(e.length===0)return;const n=Array.from(new Set(e)).sort((a,c)=>a-c);for(const a of n)EBo(t,a);const o=a=>{let c=0,l=n.length;for(;c<l;){const A=c+l>>>1;n[A]<a?c=A+1:l=A}return a-c},i=n[0],r=new Map;for(const[a,c]of t.docFieldCount)r.set(a>i?o(a):a,c);t.docFieldCount=r;const s=new Map;for(const[a,c]of t.docTermFieldHits)s.set(a>i?o(a):a,c);t.docTermFieldHits=s}var Nv=class{constructor(t,e,n){this.options={...Es,...e},this.options.useExtendedSearch,this.options.useTokenSearch,this._keyStore=new Jvo(this.options.keys),this._docs=t,this._myIndex=null,this._invertedIndex=null,this.setCollection(t,n),this._lastQuery=null,this._lastSearcher=null}_getSearcher(t){if(this._lastQuery===t)return this._lastSearcher;const e=Bne(t,this._invertedIndex?{...this.options,_invertedIndex:this._invertedIndex}:this.options);return this._lastQuery=t,this._lastSearcher=e,e}setCollection(t,e){if(this._docs=t,e&&!(e instanceof RBe))throw new Error(Vvo);if(this._myIndex=e||wBt(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight}),this.options.useTokenSearch){const n=VBe({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});this._invertedIndex=xBo(this._myIndex.records,this._myIndex.keys.length,n)}this._invalidateSearcherCache()}add(t){if(!UC(t))return;this._docs.push(t);const e=this._myIndex.add(t,this._docs.length-1);if(this._invertedIndex&&e){const n=VBe({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});IBo(this._invertedIndex,e,this._myIndex.keys.length,n)}this._invalidateSearcherCache()}remove(t=()=>!1){const e=[],n=[];for(let o=0,i=this._docs.length;o<i;o+=1)t(this._docs[o],o)&&(e.push(this._docs[o]),n.push(o));if(n.length){this._invertedIndex&&HBt(this._invertedIndex,n);const o=new Set(n);this._docs=this._docs.filter((i,r)=>!o.has(r)),this._myIndex.removeAll(n),this._invalidateSearcherCache()}return e}removeAt(t){if(!Number.isInteger(t)||t<0||t>=this._docs.length)throw new Error(NBe);this._invertedIndex&&HBt(this._invertedIndex,[t]);const e=this._docs.splice(t,1)[0];return this._myIndex.removeAt(t),this._invalidateSearcherCache(),e}_invalidateSearcherCache(){this._lastQuery=null,this._lastSearcher=null}getIndex(){return this._myIndex}search(t,e){const{limit:n=-1}=e||{},{includeMatches:o,includeScore:i,shouldSort:r,sortFn:s,ignoreFieldNorm:a}=this.options;if(q1(t)&&!t.trim()){let A=this._docs.map((u,d)=>({item:u,refIndex:d}));return Sne(n)&&n>-1&&(A=A.slice(0,n)),A}const c=Sne(n)&&n>0&&q1(t);let l;if(c){const A=new _Bo(n);q1(this._docs[0])?this._searchStringList(t,{heap:A,ignoreFieldNorm:a}):this._searchObjectList(t,{heap:A,ignoreFieldNorm:a}),l=A.extractSorted(s)}else l=q1(t)?q1(this._docs[0])?this._searchStringList(t):this._searchObjectList(t):this._searchLogical(t),hBo(l,{ignoreFieldNorm:a}),r&&l.sort(s),Sne(n)&&n>-1&&(l=l.slice(0,n));return gBo(l,this._docs,{includeMatches:o,includeScore:i})}_searchStringList(t,{heap:e,ignoreFieldNorm:n}={}){const o=this._getSearcher(t),i=this.options.useTokenSearch&&this.options.tokenMatch==="all",{records:r}=this._myIndex,s=e?null:[];return r.forEach(({v:a,i:c,n:l})=>{if(!UC(a))return;const A=o.searchIn(a);if(A.isMatch){const u={score:A.score,value:a,norm:l,indices:A.indices};i&&(u.matchedMask=A.matchedMask,u.matchedTerms=A.matchedTerms,u.termCount=A.termCount);const d=[u];if(!i||this._coversAllTokens(d)){const _={item:a,idx:c,matches:d};e?(_.score=zBe(_.matches,{ignoreFieldNorm:n}),e.shouldInsert(_.score)&&e.insert(_)):s.push(_)}}}),s}_searchLogical(t){const e=RBt(t,this.options),n=(s,a,c)=>{if(!("children"in s)){const{keyId:d,searcher:_}=s;let h;return d===null?(h=[],this._myIndex.keys.forEach((m,p)=>{h.push(...this._findMatches({key:m,value:a[p],searcher:_}))})):h=this._findMatches({key:this._keyStore.get(d),value:this._myIndex.getValueForItemAtKeyId(a,d),searcher:_}),h&&h.length?[{idx:c,item:a,matches:h}]:[]}const{children:l,operator:A}=s,u=[];for(let d=0,_=l.length;d<_;d+=1){const h=l[d],m=n(h,a,c);if(m.length)u.push(...m);else if(A===Mne.AND)return[]}return u},o=this._myIndex.records,i=new Map,r=[];return o.forEach(({$:s,i:a})=>{if(UC(s)){const c=n(e,s,a);c.length&&(i.has(a)||(i.set(a,{idx:a,item:s,matches:[]}),r.push(i.get(a))),c.forEach(({matches:l})=>{i.get(a).matches.push(...l)}))}}),r}_searchObjectList(t,{heap:e,ignoreFieldNorm:n}={}){const o=this._getSearcher(t),i=this.options.useTokenSearch&&this.options.tokenMatch==="all",{keys:r,records:s}=this._myIndex,a=e?null:[];return s.forEach(({$:c,i:l})=>{if(!UC(c))return;const A=[];let u=!1,d=!1;if(r.forEach((_,h)=>{const m=this._findMatches({key:_,value:c[h],searcher:o});m.length?(A.push(...m),m[0].hasInverse&&(d=!0)):u=!0}),!(d&&u)&&A.length&&(!i||this._coversAllTokens(A))){const _={idx:l,item:c,matches:A};e?(_.score=zBe(_.matches,{ignoreFieldNorm:n}),e.shouldInsert(_.score)&&e.insert(_)):a.push(_)}}),a}_findMatches({key:t,value:e,searcher:n}){if(!UC(e))return[];const o=[];if(Tv(e))e.forEach(({v:i,i:r,n:s})=>{if(!UC(i))return;const a=n.searchIn(i);if(a.isMatch){const c={score:a.score,key:t,value:i,idx:r,norm:s,indices:a.indices,hasInverse:a.hasInverse};a.termCount!==void 0&&(c.matchedMask=a.matchedMask,c.matchedTerms=a.matchedTerms,c.termCount=a.termCount),o.push(c)}});else{const{v:i,n:r}=e,s=n.searchIn(i);if(s.isMatch){const a={score:s.score,key:t,value:i,norm:r,indices:s.indices,hasInverse:s.hasInverse};s.termCount!==void 0&&(a.matchedMask=s.matchedMask,a.matchedTerms=s.matchedTerms,a.termCount=s.termCount),o.push(a)}}return o}_coversAllTokens(t){const e=t.length?t[0].termCount:void 0;if(e===void 0)return!0;if(e<=31){let o=0;for(let i=0;i<t.length;i++)o|=t[i].matchedMask||0;return o===2**e-1}const n=new Set;for(let o=0;o<t.length;o++){const i=t[o].matchedTerms;if(i)for(const r of i)n.add(r)}return n.size===e}};Nv.version="7.4.2",Nv.createIndex=wBt,Nv.parseIndex=Zvo,Nv.config=Es,Nv.match=function(t,e,n){if(n&&n.useTokenSearch)throw new Error(Xvo);return Bne(t,{...Es,...n}).searchIn(e)},Nv.parseQuery=RBt,OBe(ABo),OBe(CBo),Nv.use=function(...t){t.forEach(e=>OBe(e))};var bBo=Nv;const SBo="https://kicad-mod-cache.tscircuit.com";let KBe=null,dG=null,WBe=null;const PBo=async()=>KBe||dG||(dG=fetch("https://kicad-mod-cache.tscircuit.com/kicad_files.json").then(t=>t.json()).then(t=>(KBe=t,dG=null,t)),dG),vBo=async(t,e=20)=>{const n=await PBo();return WBe||(WBe=new bBo(n)),WBe.search(t).slice(0,e).map(o=>o.item)},BBo=t=>{const e=t.replace(".pretty/","/").replace(".kicad_mod",""),n=`kicad:${e}`;return{path:t,qualifiedName:n,description:e}},MBo=t=>t.replace(/^\/+/,"").split("/").map(e=>encodeURIComponent(e)).join("/"),wBo=async t=>{const e=await fetch(`${SBo}/${MBo(t)}`);if(!e.ok)throw new Error(`KiCad footprint fetch failed: ${e.status}`);const n=await e.text(),{KicadFootprintToCircuitJsonConverter:o}=await B5("kicad-to-circuit-json"),i=new o;return i.addFile(t.split("/").pop()??"selected-footprint.kicad_mod",n),i.runUntilFinished(),i.getOutput()},FBt=t=>t?.source==="jlcpcb"||t?.source==="kicad",DBo=async(t,e)=>{if(t.source==="jlcpcb")return Ovo(t.component.partNumber,e?.jlcpcb);if(t.source==="kicad")return wBo(t.footprint.path);throw new Error("Footprint preview is not available for this source")},QBo=({query:t,placeholder:e,isSearching:n,onQueryChange:o,onSubmit:i})=>{const r=j.useCallback(s=>{s.key==="Enter"&&(s.preventDefault(),i())},[i]);return V.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2 rf-mt-4",children:[V.jsxs("div",{className:"rf-relative rf-flex-grow",children:[V.jsx(zPe,{className:"rf-absolute rf-left-2 rf-top-2.5 rf-h-4 rf-w-4 rf-text-muted-foreground"}),V.jsx(Ove,{placeholder:e,className:"rf-pl-8",spellCheck:!1,autoComplete:"off",value:t,onChange:s=>o(s.target.value),onKeyDown:r})]}),V.jsx(sl,{onClick:i,disabled:n||t.trim().length<1,className:"sm:rf-px-4 rf-px-3",children:n?V.jsx(x5,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):V.jsxs(V.Fragment,{children:[V.jsx(zPe,{className:"rf-h-4 rf-w-4 sm:rf-hidden"}),V.jsx("span",{className:"rf-hidden sm:rf-inline",children:"Search"})]})})]})},TBo=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}),NBo=t=>TBo.format(t),OBt=t=>{switch(t.source){case"tscircuit.com":{const e=t.package;return`tscircuit-${e.package_id??`${e.org_owner_tscircuit_handle??"unknown"}-${e.unscoped_name??e.name??"package"}`}`}case"jlcpcb":return`jlc-${t.component.lcscId}`;case"kicad":return`kicad-${t.footprint.path}`;default:return"unknown"}},RBo=t=>{switch(t.source){case"tscircuit.com":return t.package.unscoped_name;case"jlcpcb":return t.component.manufacturer;case"kicad":return t.footprint.qualifiedName}},kBo=t=>{switch(t.source){case"tscircuit.com":return t.package.description||(t.package.org_owner_tscircuit_handle?`Component by ${t.package.org_owner_tscircuit_handle}`:void 0);case"jlcpcb":return t.component.description;case"kicad":return t.footprint.description}},LBo=t=>{switch(t.source){case"tscircuit.com":return t.package.name;case"jlcpcb":return t.component.partNumber;case"kicad":return}},HBo=({results:t,selected:e,onSelect:n,onShowDetails:o})=>{const i=e?OBt(e):null;return V.jsx("div",{className:"rf-divide-y rf-w-full rf-overflow-hidden",children:t.map(r=>{const s=OBt(r),a=i===s,c=RBo(r),l=kBo(r),A=LBo(r),u=r.source==="jlcpcb"?r.component.stock:null,d=r.source==="jlcpcb"?r.component.price:null,_=r.source==="jlcpcb"?r.component.isBasic:null;return V.jsxs("div",{className:`rf-p-3 rf-flex rf-flex-col sm:rf-grid sm:rf-grid-cols-[minmax(0,1fr)_auto] rf-items-start sm:rf-items-center rf-cursor-pointer hover:rf-bg-zinc-100 rf-gap-2 rf-overflow-hidden ${a?"rf-bg-zinc-100":""}`,onClick:()=>n(r),children:[V.jsxs("div",{className:"rf-min-w-0 rf-overflow-hidden rf-w-full",children:[V.jsxs("div",{className:"rf-flex rf-items-start rf-gap-2 rf-min-w-0",children:[V.jsxs("div",{className:"rf-font-medium rf-text-sm rf-truncate rf-flex-1 rf-min-w-0 rf-flex rf-items-center rf-gap-1.5",children:[c,r.source==="jlcpcb"&&_!=null&&V.jsx("span",{className:`rf-text-xs rf-px-1.5 rf-py-0.5 rf-rounded rf-font-medium rf-flex-shrink-0 ${_?"rf-bg-green-100 rf-text-green-700":"rf-bg-orange-100 rf-text-orange-700"}`,children:_?"Basic":"Extended"}),r.source==="tscircuit.com"&&r.package.is_private&&V.jsx(uho,{className:"rf-ml-1 rf-h-3 rf-w-3 rf-text-zinc-400 rf-flex-shrink-0"})]}),r.source==="jlcpcb"&&u!=null?V.jsxs("div",{className:"rf-text-xs rf-text-zinc-500 rf-font-medium rf-whitespace-nowrap rf-flex-shrink-0 sm:rf-hidden",children:[u.toLocaleString()," in stock"]}):null]}),V.jsxs("div",{className:"rf-text-xs rf-text-zinc-500 rf-truncate rf-w-full",children:[A?V.jsx("span",{className:"rf-mr-2",children:A}):null,l]})]}),V.jsxs("div",{children:[r.source==="tscircuit.com"&&o?V.jsx("div",{className:"rf-flex-shrink-0 rf-w-full sm:rf-w-auto",children:V.jsx(sl,{variant:"outline",size:"sm",className:"rf-text-xs rf-w-full sm:rf-w-auto",onClick:h=>{h.stopPropagation(),o(r)},children:"See Details"})}):r.source==="jlcpcb"&&u!=null?V.jsxs("div",{className:"rf-hidden sm:rf-block rf-text-xs rf-text-zinc-500 rf-font-medium rf-whitespace-nowrap rf-flex-shrink-0",children:[u.toLocaleString()," in stock"]}):null,d!=null&&V.jsx("div",{className:"rf-hidden sm:rf-block rf-text-xs rf-text-zinc-500 rf-font-medium rf-whitespace-nowrap rf-flex-shrink-0 rf-text-right",children:NBo(d)})]})]},s)})})},FBo=({circuitJson:t,error:e,isLoading:n,height:o})=>V.jsx("section",{className:"rf-flex rf-min-w-0 rf-items-center rf-justify-center",style:{height:o},children:n?V.jsxs("div",{className:"rf-flex rf-w-full rf-items-center rf-justify-center rf-gap-2 rf-bg-zinc-950 rf-text-sm rf-text-zinc-300",style:{height:o},children:[V.jsx(x5,{className:"rf-h-4 rf-w-4 rf-animate-spin"}),"Loading preview..."]}):e?V.jsx("div",{className:"rf-flex rf-w-full rf-items-center rf-justify-center rf-bg-zinc-950 rf-p-4",style:{height:o},children:V.jsxs("div",{className:"rf-flex rf-max-w-[320px] rf-items-start rf-gap-2 rf-text-sm rf-text-zinc-300",children:[V.jsx(M5t,{className:"rf-mt-0.5 rf-h-4 rf-w-4 rf-flex-shrink-0"}),V.jsx("span",{children:e})]})}):t?V.jsx("div",{className:"rf-w-full rf-min-w-0 rf-overflow-hidden",children:V.jsx(Rvt,{circuitJson:t,height:o,allowEditing:!1,clickToInteractEnabled:!1,focusOnHover:!1,disablePcbGroups:!0})}):V.jsx("div",{className:"rf-flex rf-w-full rf-items-center rf-justify-center rf-bg-zinc-950 rf-text-sm rf-text-zinc-300",style:{height:o},children:"No preview"})}),GBt={importComponentDialog:101,importComponentDetailsDialog:102},OBo=({packageResult:t,isOpen:e,onOpenChange:n,isLoading:o,details:i,previewTab:r,onPreviewTabChange:s,isSubmitting:a,onImport:c})=>{const l=t?.package??null,A=l?.latest_pcb_preview_image_url,u=l?.latest_sch_preview_image_url,d=l?.latest_cad_preview_image_url,_=l?.unscoped_name?.split("/").pop()??l?.unscoped_name,h=l?.org_owner_tscircuit_handle??void 0,m=h?`https://tscircuit.com/${h}`:void 0,p=h&&_?`https://tscircuit.com/${h}/${_}`:void 0;return V.jsx(BT,{open:e,onOpenChange:n,children:V.jsxs(gM,{showOverlay:!1,style:{width:"calc(100vw - 2rem)",zIndex:GBt.importComponentDetailsDialog},className:"rf-max-w-5xl no-scrollbar !rf-overflow-y-auto rf-max-h-[90vh] rf-overflow-hidden rf-flex rf-flex-col rf-rounded-sm",children:[V.jsx(pM,{className:"rf-pb-4 rf-border-b",children:V.jsx("div",{className:"rf-flex rf-items-start rf-justify-between rf-gap-4",children:V.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[V.jsx(fM,{className:"rf-text-xl rf-font-semibold rf-truncate",children:_}),V.jsx(MT,{children:l?.description})]})})}),V.jsxs("div",{className:"rf-flex-1 rf-overflow-y-auto rf-py-4 rf-space-y-6",children:[h?V.jsxs("div",{children:[V.jsx("span",{className:"rf-text-xs rf-font-medium rf-text-gray-500 rf-uppercase rf-tracking-wide",children:"Created by"}),V.jsx("div",{className:"rf-mt-1 rf-text-sm rf-font-medium",children:m?V.jsx("a",{href:m,target:"_blank",rel:"noopener noreferrer",className:"rf-text-black hover:rf-underline",children:h}):h})]}):null,(d||A||u)&&V.jsx(V.Fragment,{children:V.jsxs("div",{children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Preview"}),V.jsxs(vfe,{value:r,onValueChange:g=>s(g),children:[V.jsxs(Sq,{className:"rf-inline-flex rf-h-9 rf-items-center rf-justify-center rf-rounded-lg rf-bg-zinc-100 rf-p-1 rf-text-zinc-500 dark:rf-bg-zinc-800 dark:rf-text-zinc-400",children:[A&&V.jsx(V4,{value:"pcb",children:"PCB"}),u&&V.jsx(V4,{value:"schematic",children:"Schematic"}),d&&V.jsx(V4,{value:"3d",children:"3D"})]}),V.jsxs("div",{className:"rf-mt-4",children:[V.jsx(Qf,{value:"pcb",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:A?V.jsx("img",{src:A,alt:`${_??"package"} PCB preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null}),V.jsx(Qf,{value:"schematic",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:u?V.jsx("img",{src:u,alt:`${_??"package"} schematic preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null}),V.jsx(Qf,{value:"3d",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:d?V.jsx("img",{src:d,alt:`${_??"package"} 3D preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null})]})]})]})}),i?.ai_description?V.jsxs("section",{children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-3",children:"AI Description"}),V.jsx("div",{className:"rf-bg-gray-50 rf-border rf-border-gray-200 rf-rounded-lg rf-p-4",children:V.jsx("p",{className:"rf-text-sm rf-text-gray-700 rf-leading-relaxed",children:i.ai_description})})]}):null,i?.ai_usage_instructions?V.jsxs("section",{children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-3",children:"Usage Instructions"}),V.jsx("div",{className:"rf-bg-gray-50 rf-border rf-border-gray-200 rf-rounded-lg rf-p-4",children:V.jsx("p",{className:"rf-text-sm rf-text-gray-700 rf-leading-relaxed rf-whitespace-pre-wrap",children:i.ai_usage_instructions})})]}):null,o?V.jsxs("div",{className:"rf-flex rf-justify-center rf-items-center rf-gap-2 rf-text-gray-500",children:[V.jsx(x5,{className:"rf-h-4 rf-w-4 rf-animate-spin"}),V.jsx("span",{className:"rf-text-sm",children:"Loading package details..."})]}):null]}),V.jsxs(AG,{className:"rf-pt-4 rf-border-t rf-flex rf-flex-col sm:rf-flex-row rf-justify-between rf-gap-2",children:[V.jsx("div",{className:"rf-flex-1",children:p?V.jsxs(sl,{variant:"outline",size:"sm",className:"rf-gap-2 rf-w-full sm:rf-w-auto",onClick:()=>window.open(p,"_blank"),children:[V.jsx(iho,{className:"rf-h-4 rf-w-4"}),"View on tscircuit.com"]}):null}),V.jsxs("div",{className:"rf-flex rf-flex-col sm:rf-flex-row rf-gap-2",children:[V.jsx(sl,{variant:"outline",onClick:()=>n(!1),className:"rf-order-2 sm:rf-order-1",children:"Close"}),V.jsx(sl,{onClick:c,disabled:a,className:"rf-bg-blue-600 hover:rf-bg-blue-700",children:a?V.jsx(x5,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):"Import Component"})]})]})]})})},GBo=()=>{const[t,e]=j.useState(null),[n,o]=j.useState(!1),i=j.useCallback(async(s,a)=>{o(!0);try{const c=await fetch(`https://api.tscircuit.com/packages/get?name=${encodeURIComponent(`${s}/${a}`)}`);if(!c.ok)throw new Error(`Failed to load package details: ${c.status}`);const l=await c.json();e(l.package??null)}catch(c){console.error("Failed to fetch package details",c),e(null)}finally{o(!1)}},[]),r=j.useCallback(()=>{e(null),o(!1)},[]);return{details:t,isLoading:n,fetchDetails:i,reset:r}},UBo=(t,e)=>{const[n,o]=j.useState({circuitJson:null,error:null,isLoading:!1});return j.useEffect(()=>{if(!t||!FBt(t)){o({circuitJson:null,error:null,isLoading:!1});return}let i=!1;return o({circuitJson:null,error:null,isLoading:!0}),DBo(t,e).then(r=>{i||o({circuitJson:r,error:null,isLoading:!1})}).catch(r=>{i||o({circuitJson:null,error:r instanceof Error?r.message:"Failed to load footprint preview",isLoading:!1})}),()=>{i=!0}},[t,e]),n},zBo=async(t,e)=>{const n={"Content-Type":"application/json"};e&&(n.Authorization=`Bearer ${e}`);const o=await fetch("https://registry-api.tscircuit.com/packages/search",{method:"POST",headers:n,body:JSON.stringify({query:t})});if(!o.ok)throw new Error(`tscircuit registry error: ${o.status}`);return(await o.json()).packages??[]},VBo=({sessionToken:t})=>{const[e,n]=j.useState([]),[o,i]=j.useState(!1),[r,s]=j.useState(null),[a,c]=j.useState(!1),l=j.useCallback(async u=>{const d=u.trim();if(!d)return[];i(!0),s(null);try{const h=(await zBo(d,t)).map(m=>({source:"tscircuit.com",package:m}));return n(h),h}catch(_){return console.error("Error searching tscircuit packages",_),n([]),s(_ instanceof Error?_.message:"Failed to search tscircuit packages"),[]}finally{i(!1),c(!0)}},[t]),A=j.useCallback(()=>{n([]),i(!1),s(null),c(!1)},[]);return{results:e,isSearching:o,error:r,hasSearched:a,search:l,reset:A}},YBo=t=>{const e=t.trim();return/^C\d+/i.test(e)?e.replace(/^C/i,""):e},KBo=()=>{const[t,e]=j.useState([]),[n,o]=j.useState(!1),[i,r]=j.useState(null),[s,a]=j.useState(!1),c=j.useCallback(async A=>{const u=YBo(A);if(!u)return[];o(!0),r(null);try{const _=(await Lvo(u,10)).map(h=>({source:"jlcpcb",component:Hvo(h)}));return e(_),_}catch(d){return console.error("Error searching JLCPCB components",d),e([]),r(d instanceof Error?d.message:"Failed to search JLCPCB components"),[]}finally{o(!1),a(!0)}},[]),l=j.useCallback(()=>{e([]),o(!1),r(null),a(!1)},[]);return{results:t,isSearching:n,error:i,hasSearched:s,search:c,reset:l}},WBo=()=>{const[t,e]=j.useState([]),[n,o]=j.useState(!1),[i,r]=j.useState(null),[s,a]=j.useState(!1),c=j.useCallback(async A=>{const u=A.trim();if(!u)return[];o(!0),r(null);try{const _=(await vBo(u,20)).map(h=>({source:"kicad",footprint:BBo(h)}));return e(_),_}catch(d){return console.error("Error searching KiCad footprints",d),e([]),r(d instanceof Error?d.message:"Failed to search KiCad footprints"),[]}finally{o(!1),a(!0)}},[]),l=j.useCallback(()=>{e([]),o(!1),r(null),a(!1)},[]);return{results:t,isSearching:n,error:i,hasSearched:s,search:c,reset:l}},jBo=({onTscircuitPackageSelected:t,onJlcpcbComponentTsxLoaded:e,onKicadStringSelected:n})=>{const o=[];return t&&o.push("tscircuit.com"),e&&o.push("jlcpcb"),n&&o.push("kicad"),o},XBo=({isOpen:t,onClose:e,jlcpcbProxyRequestHeaders:n,onKicadStringSelected:o,onTscircuitPackageSelected:i,onJlcpcbComponentTsxLoaded:r,jlcpcbProxyApiBase:s,tscircuitSessionToken:a})=>{mne();const c=j.useMemo(()=>jBo({onKicadStringSelected:o,onTscircuitPackageSelected:i,onJlcpcbComponentTsxLoaded:r}),[o,i,r]),l=c.length>0,A=c.length===1,[u,d]=j.useState(c[0]??"tscircuit.com"),[_,h]=j.useState(""),[m,p]=j.useState(null),{results:g,isSearching:f,error:y,hasSearched:C,search:I,reset:E}=VBo({sessionToken:a}),{results:b,isSearching:P,error:M,hasSearched:w,search:k,reset:N}=KBo(),{results:O,isSearching:H,error:G,hasSearched:K,search:J,reset:$}=WBo(),{details:ie,isLoading:Ae,fetchDetails:ne,reset:oe}=GBo(),[ce,re]=j.useState(null),[ue,fe]=j.useState(!1),[be,ve]=j.useState("pcb"),[he,Pe]=j.useState(null),[pe,Fe]=j.useState(!1),ke=j.useMemo(()=>({jlcpcb:{headers:n,apiBase:s}}),[s,n]),{circuitJson:We,error:ye,isLoading:qe}=UBo(m,ke),Oe=FBt(m);j.useEffect(()=>{Pe(null)},[m]);const Qe=j.useCallback(()=>{E(),N(),$(),p(null)},[N,$,E]);j.useEffect(()=>{t||(Qe(),h(""),fe(!1),re(null),Pe(null))},[t,Qe]),j.useEffect(()=>{h(""),p(null),u==="tscircuit.com"?E():u==="jlcpcb"?N():u==="kicad"&&$()},[u,N,$,E]);const Ue=ct=>{p(ct),re(ct),ve("pcb"),fe(!0),oe();const yt=ct.package.org_owner_tscircuit_handle,vt=ct.package.unscoped_name;if(yt&&vt){const pt=vt.split("/").pop()??vt;ne(yt,pt)}},Te=async()=>{_.trim()&&(p(null),u==="tscircuit.com"?await I(_):u==="jlcpcb"?await k(_):u==="kicad"&&await J(_))},Ie=async ct=>{try{if(Pe(null),Fe(!0),ct.source==="kicad"){if(!o)throw new Error("KiCad handler not provided");await o({result:ct,footprint:ct.footprint.qualifiedName})}else if(ct.source==="jlcpcb"){if(!r)throw new Error("JLCPCB handler not provided");const yt=await Fvo(ct.component.partNumber,{headers:n,apiBase:s});await r({result:ct,tsx:yt})}else if(ct.source==="tscircuit.com"){if(!i)throw new Error("tscircuit package handler not provided");const yt=ct.package.org_owner_tscircuit_handle,vt=ct.package.unscoped_name;if(!yt||!vt)throw new Error("Missing package metadata");const pt=vt.split("/").pop()??vt,Qt=`@tsci/${yt}.${pt}`;await i({result:ct,fullPackageName:Qt})}return!0}catch(yt){return console.error("Failed to import component",yt),Pe(yt instanceof Error?yt.message:"Failed to import component"),!1}finally{Fe(!1)}};let He=[],Me=!1,Ke=null,je=!1;u==="tscircuit.com"?(He=g,Me=f,Ke=y,je=C):u==="jlcpcb"?(He=b,Me=P,Ke=M,je=w):u==="kicad"&&(He=O,Me=H,Ke=G,je=K);const st=async()=>{if(!m)return;await Ie(m)&&(e(),Qe(),h(""))},at=ct=>{ct||e()},ut=ct=>{fe(ct),ct||re(null)};return V.jsxs(BT,{open:t,onOpenChange:at,children:[V.jsxs(gM,{style:{width:"calc(100vw - 2rem)",maxWidth:Oe?"min(1120px, calc(100vw - 2rem))":"min(672px, calc(100vw - 2rem))",zIndex:GBt.importComponentDialog},className:"rf-rounded-sm rf-max-h-[90vh] rf-overflow-y-auto rf-overflow-x-hidden rf-flex rf-flex-col",children:[V.jsxs(pM,{children:[V.jsxs(fM,{className:"rf-text-lg sm:rf-text-xl",children:["Import ",A?bne[u].label:""," ","Component"]}),V.jsx(MT,{className:"rf-text-sm",children:l?"Search for components from available sources.":"Import options are disabled because no handlers were provided."})]}),l?V.jsxs(vfe,{value:u,onValueChange:ct=>d(ct),className:"rf-min-w-0 rf-w-full",children:[!A&&V.jsx(Sq,{className:"rf-flex rf-w-full rf-gap-2",children:c.map(ct=>V.jsx(V4,{value:ct,className:"rf-flex-1 rf-text-xs sm:rf-text-sm",children:bne[ct].label},ct))}),V.jsxs("div",{className:"rf-min-w-0",style:Oe?{display:"grid",gridTemplateColumns:"minmax(0, 1fr) minmax(360px, 0.95fr)",gap:"1.5rem",alignItems:"start"}:void 0,children:[V.jsxs("div",{className:"rf-min-w-0",children:[V.jsx(QBo,{query:_,placeholder:bne[u].placeholder,isSearching:Me,onQueryChange:h,onSubmit:Te}),V.jsx("div",{className:"no-scrollbar rf-mt-4 rf-flex-1 rf-min-h-[200px] !rf-max-h-[40vh] !rf-overflow-y-auto rf-overflow-x-hidden rf-border rf-rounded-md rf-min-w-0",children:Me?V.jsxs("div",{className:"rf-p-8 rf-text-center rf-text-zinc-500",children:[V.jsx(x5,{className:"rf-h-8 rf-w-8 rf-animate-spin rf-mx-auto rf-mb-2"}),V.jsx("p",{children:"Searching..."})]}):He.length>0?V.jsx(HBo,{results:He,selected:m,onSelect:p,onShowDetails:u==="tscircuit.com"?Ue:void 0}):V.jsx("div",{className:"rf-p-8 rf-text-center rf-text-zinc-500",children:Ke?`Error: ${Ke}`:je?bne[u].emptyMessage:"Enter a search term to find components"})})]}),Oe?V.jsx("div",{className:"rf-mt-4",children:V.jsx(FBo,{circuitJson:We,error:ye,isLoading:qe,height:325})}):null]})]}):null,he?V.jsx("div",{className:"rf-text-sm rf-text-red-600 rf-mt-2",children:he}):null,V.jsxs(AG,{className:"rf-flex rf-flex-col sm:rf-flex-row rf-gap-2",children:[V.jsx(sl,{variant:"outline",onClick:e,className:"rf-order-2 sm:rf-order-1",children:"Cancel"}),V.jsx(sl,{onClick:st,disabled:!m||pe,className:"rf-order-1 sm:rf-order-2",children:pe?V.jsx(x5,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):"Import"})]})]}),V.jsx(OBo,{packageResult:ce,isOpen:ue,onOpenChange:ut,isLoading:Ae,details:ie,previewTab:be,onPreviewTabChange:ct=>ve(ct),isSubmitting:pe,onImport:()=>{ce&&Ie(ce).then(ct=>{ct&&(fe(!1),e(),Qe(),h(""))})}})]})},JBo=t=>{const e=t.match(/export const (\w+) =/);if(!e)throw new Error("Could not determine component name from TSX contents");return e[1]},UBt=t=>{const e=I0(s=>s.pushEvent),n=I0(s=>s.upsertFile),o=async({result:s,fullPackageName:a})=>{const l=s.package.unscoped_name??s.package.name;await ks.promise(e({event_type:"INSTALL_PACKAGE",full_package_name:a}),{loading:`Requesting install for "${l}"`,success:`Install requested for "${l}"`,error:A=>`Failed to request install: ${A instanceof Error?A.message:String(A)}`})},i=async({footprint:s})=>{await ks.promise(navigator.clipboard.writeText(s),{loading:`Copying "${s}"`,success:`Copied "${s}" to clipboard`,error:a=>`Failed to copy footprint: ${a instanceof Error?a.message:String(a)}`})},r=async({result:s,tsx:a})=>{const l=`imports/${JBo(a)}.tsx`;await ks.promise(n(l,a),{loading:`Importing ${s.component.partNumber}`,success:`Imported to "${l}"`,error:A=>`Failed to import component: ${A instanceof Error?A.message:String(A)}`})};return V.jsx(XBo,{...t,onTscircuitPackageSelected:o,onKicadStringSelected:i,onJlcpcbComponentTsxLoaded:r})};UBt.displayName="ImportComponentDialogForCli";const qBo=t=>{let e=t.trim().replace(/[\\/:*?"<>|]/g,"_").replace(/[\x00-\x1f]/g,"").replace(/^\.+/,"").replace(/\.+$/,"").replace(/\s+/g," ").replace(/_+/g,"_");return/^(con|prn|aux|nul|com[0-9]|lpt[0-9])$/i.test(e)&&(e=`_${e}`),e=e.slice(0,200),e||"untitled"};var jBe={exports:{}},zBt;function $Bo(){return zBt||(zBt=1,(function(t,e){var n={env:{},version:""};(function(o){t.exports=o()})(function(){return(function o(i,r,s){function a(A,u){if(!r[A]){if(!i[A]){var d=typeof lP=="function"&&lP;if(!u&&d)return d(A,!0);if(c)return c(A,!0);var _=new Error("Cannot find module '"+A+"'");throw _.code="MODULE_NOT_FOUND",_}var h=r[A]={exports:{}};i[A][0].call(h.exports,function(m){var p=i[A][1][m];return a(p||m)},h,h.exports,o,i,r,s)}return r[A].exports}for(var c=typeof lP=="function"&&lP,l=0;l<s.length;l++)a(s[l]);return a})({1:[function(o,i,r){var s=o("./utils"),a=o("./support"),c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";r.encode=function(l){for(var A,u,d,_,h,m,p,g=[],f=0,y=l.length,C=y,I=s.getTypeOf(l)!=="string";f<l.length;)C=y-f,d=I?(A=l[f++],u=f<y?l[f++]:0,f<y?l[f++]:0):(A=l.charCodeAt(f++),u=f<y?l.charCodeAt(f++):0,f<y?l.charCodeAt(f++):0),_=A>>2,h=(3&A)<<4|u>>4,m=1<C?(15&u)<<2|d>>6:64,p=2<C?63&d:64,g.push(c.charAt(_)+c.charAt(h)+c.charAt(m)+c.charAt(p));return g.join("")},r.decode=function(l){var A,u,d,_,h,m,p=0,g=0,f="data:";if(l.substr(0,f.length)===f)throw new Error("Invalid base64 input, it looks like a data url.");var y,C=3*(l=l.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(l.charAt(l.length-1)===c.charAt(64)&&C--,l.charAt(l.length-2)===c.charAt(64)&&C--,C%1!=0)throw new Error("Invalid base64 input, bad content length.");for(y=a.uint8array?new Uint8Array(0|C):new Array(0|C);p<l.length;)A=c.indexOf(l.charAt(p++))<<2|(_=c.indexOf(l.charAt(p++)))>>4,u=(15&_)<<4|(h=c.indexOf(l.charAt(p++)))>>2,d=(3&h)<<6|(m=c.indexOf(l.charAt(p++))),y[g++]=A,h!==64&&(y[g++]=u),m!==64&&(y[g++]=d);return y}},{"./support":30,"./utils":32}],2:[function(o,i,r){var s=o("./external"),a=o("./stream/DataWorker"),c=o("./stream/Crc32Probe"),l=o("./stream/DataLengthProbe");function A(u,d,_,h,m){this.compressedSize=u,this.uncompressedSize=d,this.crc32=_,this.compression=h,this.compressedContent=m}A.prototype={getContentWorker:function(){var u=new a(s.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new l("data_length")),d=this;return u.on("end",function(){if(this.streamInfo.data_length!==d.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),u},getCompressedWorker:function(){return new a(s.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},A.createWorkerFrom=function(u,d,_){return u.pipe(new c).pipe(new l("uncompressedSize")).pipe(d.compressWorker(_)).pipe(new l("compressedSize")).withStreamInfo("compression",d)},i.exports=A},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(o,i,r){var s=o("./stream/GenericWorker");r.STORE={magic:"\0\0",compressWorker:function(){return new s("STORE compression")},uncompressWorker:function(){return new s("STORE decompression")}},r.DEFLATE=o("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(o,i,r){var s=o("./utils"),a=(function(){for(var c,l=[],A=0;A<256;A++){c=A;for(var u=0;u<8;u++)c=1&c?3988292384^c>>>1:c>>>1;l[A]=c}return l})();i.exports=function(c,l){return c!==void 0&&c.length?s.getTypeOf(c)!=="string"?(function(A,u,d,_){var h=a,m=_+d;A^=-1;for(var p=_;p<m;p++)A=A>>>8^h[255&(A^u[p])];return-1^A})(0|l,c,c.length,0):(function(A,u,d,_){var h=a,m=_+d;A^=-1;for(var p=_;p<m;p++)A=A>>>8^h[255&(A^u.charCodeAt(p))];return-1^A})(0|l,c,c.length,0):0}},{"./utils":32}],5:[function(o,i,r){r.base64=!1,r.binary=!1,r.dir=!1,r.createFolders=!0,r.date=null,r.compression=null,r.compressionOptions=null,r.comment=null,r.unixPermissions=null,r.dosPermissions=null},{}],6:[function(o,i,r){var s=null;s=typeof Promise<"u"?Promise:o("lie"),i.exports={Promise:s}},{lie:37}],7:[function(o,i,r){var s=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",a=o("pako"),c=o("./utils"),l=o("./stream/GenericWorker"),A=s?"uint8array":"array";function u(d,_){l.call(this,"FlateWorker/"+d),this._pako=null,this._pakoAction=d,this._pakoOptions=_,this.meta={}}r.magic="\b\0",c.inherits(u,l),u.prototype.processChunk=function(d){this.meta=d.meta,this._pako===null&&this._createPako(),this._pako.push(c.transformTo(A,d.data),!1)},u.prototype.flush=function(){l.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},u.prototype.cleanUp=function(){l.prototype.cleanUp.call(this),this._pako=null},u.prototype._createPako=function(){this._pako=new a[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var d=this;this._pako.onData=function(_){d.push({data:_,meta:d.meta})}},r.compressWorker=function(d){return new u("Deflate",d)},r.uncompressWorker=function(){return new u("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(o,i,r){function s(h,m){var p,g="";for(p=0;p<m;p++)g+=String.fromCharCode(255&h),h>>>=8;return g}function a(h,m,p,g,f,y){var C,I,E=h.file,b=h.compression,P=y!==A.utf8encode,M=c.transformTo("string",y(E.name)),w=c.transformTo("string",A.utf8encode(E.name)),k=E.comment,N=c.transformTo("string",y(k)),O=c.transformTo("string",A.utf8encode(k)),H=w.length!==E.name.length,G=O.length!==k.length,K="",J="",$="",ie=E.dir,Ae=E.date,ne={crc32:0,compressedSize:0,uncompressedSize:0};m&&!p||(ne.crc32=h.crc32,ne.compressedSize=h.compressedSize,ne.uncompressedSize=h.uncompressedSize);var oe=0;m&&(oe|=8),P||!H&&!G||(oe|=2048);var ce=0,re=0;ie&&(ce|=16),f==="UNIX"?(re=798,ce|=(function(fe,be){var ve=fe;return fe||(ve=be?16893:33204),(65535&ve)<<16})(E.unixPermissions,ie)):(re=20,ce|=(function(fe){return 63&(fe||0)})(E.dosPermissions)),C=Ae.getUTCHours(),C<<=6,C|=Ae.getUTCMinutes(),C<<=5,C|=Ae.getUTCSeconds()/2,I=Ae.getUTCFullYear()-1980,I<<=4,I|=Ae.getUTCMonth()+1,I<<=5,I|=Ae.getUTCDate(),H&&(J=s(1,1)+s(u(M),4)+w,K+="up"+s(J.length,2)+J),G&&($=s(1,1)+s(u(N),4)+O,K+="uc"+s($.length,2)+$);var ue="";return ue+=`
5798
5798
  \0`,ue+=s(oe,2),ue+=b.magic,ue+=s(C,2),ue+=s(I,2),ue+=s(ne.crc32,4),ue+=s(ne.compressedSize,4),ue+=s(ne.uncompressedSize,4),ue+=s(M.length,2),ue+=s(K.length,2),{fileRecord:d.LOCAL_FILE_HEADER+ue+M+K,dirRecord:d.CENTRAL_FILE_HEADER+s(re,2)+ue+s(N.length,2)+"\0\0\0\0"+s(ce,4)+s(g,4)+M+K+N}}var c=o("../utils"),l=o("../stream/GenericWorker"),A=o("../utf8"),u=o("../crc32"),d=o("../signature");function _(h,m,p,g){l.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=m,this.zipPlatform=p,this.encodeFileName=g,this.streamFiles=h,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}c.inherits(_,l),_.prototype.push=function(h){var m=h.meta.percent||0,p=this.entriesCount,g=this._sources.length;this.accumulate?this.contentBuffer.push(h):(this.bytesWritten+=h.data.length,l.prototype.push.call(this,{data:h.data,meta:{currentFile:this.currentFile,percent:p?(m+100*(p-g-1))/p:100}}))},_.prototype.openedSource=function(h){this.currentSourceOffset=this.bytesWritten,this.currentFile=h.file.name;var m=this.streamFiles&&!h.file.dir;if(m){var p=a(h,m,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:p.fileRecord,meta:{percent:0}})}else this.accumulate=!0},_.prototype.closedSource=function(h){this.accumulate=!1;var m=this.streamFiles&&!h.file.dir,p=a(h,m,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(p.dirRecord),m)this.push({data:(function(g){return d.DATA_DESCRIPTOR+s(g.crc32,4)+s(g.compressedSize,4)+s(g.uncompressedSize,4)})(h),meta:{percent:100}});else for(this.push({data:p.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},_.prototype.flush=function(){for(var h=this.bytesWritten,m=0;m<this.dirRecords.length;m++)this.push({data:this.dirRecords[m],meta:{percent:100}});var p=this.bytesWritten-h,g=(function(f,y,C,I,E){var b=c.transformTo("string",E(I));return d.CENTRAL_DIRECTORY_END+"\0\0\0\0"+s(f,2)+s(f,2)+s(y,4)+s(C,4)+s(b.length,2)+b})(this.dirRecords.length,p,h,this.zipComment,this.encodeFileName);this.push({data:g,meta:{percent:100}})},_.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},_.prototype.registerPrevious=function(h){this._sources.push(h);var m=this;return h.on("data",function(p){m.processChunk(p)}),h.on("end",function(){m.closedSource(m.previous.streamInfo),m._sources.length?m.prepareNextSource():m.end()}),h.on("error",function(p){m.error(p)}),this},_.prototype.resume=function(){return!!l.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},_.prototype.error=function(h){var m=this._sources;if(!l.prototype.error.call(this,h))return!1;for(var p=0;p<m.length;p++)try{m[p].error(h)}catch{}return!0},_.prototype.lock=function(){l.prototype.lock.call(this);for(var h=this._sources,m=0;m<h.length;m++)h[m].lock()},i.exports=_},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(o,i,r){var s=o("../compressions"),a=o("./ZipFileWorker");r.generateWorker=function(c,l,A){var u=new a(l.streamFiles,A,l.platform,l.encodeFileName),d=0;try{c.forEach(function(_,h){d++;var m=(function(y,C){var I=y||C,E=s[I];if(!E)throw new Error(I+" is not a valid compression method !");return E})(h.options.compression,l.compression),p=h.options.compressionOptions||l.compressionOptions||{},g=h.dir,f=h.date;h._compressWorker(m,p).withStreamInfo("file",{name:_,dir:g,date:f,comment:h.comment||"",unixPermissions:h.unixPermissions,dosPermissions:h.dosPermissions}).pipe(u)}),u.entriesCount=d}catch(_){u.error(_)}return u}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(o,i,r){function s(){if(!(this instanceof s))return new s;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var a=new s;for(var c in this)typeof this[c]!="function"&&(a[c]=this[c]);return a}}(s.prototype=o("./object")).loadAsync=o("./load"),s.support=o("./support"),s.defaults=o("./defaults"),s.version="3.10.1",s.loadAsync=function(a,c){return new s().loadAsync(a,c)},s.external=o("./external"),i.exports=s},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(o,i,r){var s=o("./utils"),a=o("./external"),c=o("./utf8"),l=o("./zipEntries"),A=o("./stream/Crc32Probe"),u=o("./nodejsUtils");function d(_){return new a.Promise(function(h,m){var p=_.decompressed.getContentWorker().pipe(new A);p.on("error",function(g){m(g)}).on("end",function(){p.streamInfo.crc32!==_.decompressed.crc32?m(new Error("Corrupted zip : CRC32 mismatch")):h()}).resume()})}i.exports=function(_,h){var m=this;return h=s.extend(h||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:c.utf8decode}),u.isNode&&u.isStream(_)?a.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):s.prepareContent("the loaded zip file",_,!0,h.optimizedBinaryString,h.base64).then(function(p){var g=new l(h);return g.load(p),g}).then(function(p){var g=[a.Promise.resolve(p)],f=p.files;if(h.checkCRC32)for(var y=0;y<f.length;y++)g.push(d(f[y]));return a.Promise.all(g)}).then(function(p){for(var g=p.shift(),f=g.files,y=0;y<f.length;y++){var C=f[y],I=C.fileNameStr,E=s.resolve(C.fileNameStr);m.file(E,C.decompressed,{binary:!0,optimizedBinaryString:!0,date:C.date,dir:C.dir,comment:C.fileCommentStr.length?C.fileCommentStr:null,unixPermissions:C.unixPermissions,dosPermissions:C.dosPermissions,createFolders:h.createFolders}),C.dir||(m.file(E).unsafeOriginalName=I)}return g.zipComment.length&&(m.comment=g.zipComment),m})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(o,i,r){var s=o("../utils"),a=o("../stream/GenericWorker");function c(l,A){a.call(this,"Nodejs stream input adapter for "+l),this._upstreamEnded=!1,this._bindStream(A)}s.inherits(c,a),c.prototype._bindStream=function(l){var A=this;(this._stream=l).pause(),l.on("data",function(u){A.push({data:u,meta:{percent:0}})}).on("error",function(u){A.isPaused?this.generatedError=u:A.error(u)}).on("end",function(){A.isPaused?A._upstreamEnded=!0:A.end()})},c.prototype.pause=function(){return!!a.prototype.pause.call(this)&&(this._stream.pause(),!0)},c.prototype.resume=function(){return!!a.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},i.exports=c},{"../stream/GenericWorker":28,"../utils":32}],13:[function(o,i,r){var s=o("readable-stream").Readable;function a(c,l,A){s.call(this,l),this._helper=c;var u=this;c.on("data",function(d,_){u.push(d)||u._helper.pause(),A&&A(_)}).on("error",function(d){u.emit("error",d)}).on("end",function(){u.push(null)})}o("../utils").inherits(a,s),a.prototype._read=function(){this._helper.resume()},i.exports=a},{"../utils":32,"readable-stream":16}],14:[function(o,i,r){i.exports={isNode:typeof Buffer<"u",newBufferFrom:function(s,a){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(s,a);if(typeof s=="number")throw new Error('The "data" argument must not be a number');return new Buffer(s,a)},allocBuffer:function(s){if(Buffer.alloc)return Buffer.alloc(s);var a=new Buffer(s);return a.fill(0),a},isBuffer:function(s){return Buffer.isBuffer(s)},isStream:function(s){return s&&typeof s.on=="function"&&typeof s.pause=="function"&&typeof s.resume=="function"}}},{}],15:[function(o,i,r){function s(E,b,P){var M,w=c.getTypeOf(b),k=c.extend(P||{},u);k.date=k.date||new Date,k.compression!==null&&(k.compression=k.compression.toUpperCase()),typeof k.unixPermissions=="string"&&(k.unixPermissions=parseInt(k.unixPermissions,8)),k.unixPermissions&&16384&k.unixPermissions&&(k.dir=!0),k.dosPermissions&&16&k.dosPermissions&&(k.dir=!0),k.dir&&(E=f(E)),k.createFolders&&(M=g(E))&&y.call(this,M,!0);var N=w==="string"&&k.binary===!1&&k.base64===!1;P&&P.binary!==void 0||(k.binary=!N),(b instanceof d&&b.uncompressedSize===0||k.dir||!b||b.length===0)&&(k.base64=!1,k.binary=!0,b="",k.compression="STORE",w="string");var O=null;O=b instanceof d||b instanceof l?b:m.isNode&&m.isStream(b)?new p(E,b):c.prepareContent(E,b,k.binary,k.optimizedBinaryString,k.base64);var H=new _(E,O,k);this.files[E]=H}var a=o("./utf8"),c=o("./utils"),l=o("./stream/GenericWorker"),A=o("./stream/StreamHelper"),u=o("./defaults"),d=o("./compressedObject"),_=o("./zipObject"),h=o("./generate"),m=o("./nodejsUtils"),p=o("./nodejs/NodejsStreamInputAdapter"),g=function(E){E.slice(-1)==="/"&&(E=E.substring(0,E.length-1));var b=E.lastIndexOf("/");return 0<b?E.substring(0,b):""},f=function(E){return E.slice(-1)!=="/"&&(E+="/"),E},y=function(E,b){return b=b!==void 0?b:u.createFolders,E=f(E),this.files[E]||s.call(this,E,null,{dir:!0,createFolders:b}),this.files[E]};function C(E){return Object.prototype.toString.call(E)==="[object RegExp]"}var I={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(E){var b,P,M;for(b in this.files)M=this.files[b],(P=b.slice(this.root.length,b.length))&&b.slice(0,this.root.length)===this.root&&E(P,M)},filter:function(E){var b=[];return this.forEach(function(P,M){E(P,M)&&b.push(M)}),b},file:function(E,b,P){if(arguments.length!==1)return E=this.root+E,s.call(this,E,b,P),this;if(C(E)){var M=E;return this.filter(function(k,N){return!N.dir&&M.test(k)})}var w=this.files[this.root+E];return w&&!w.dir?w:null},folder:function(E){if(!E)return this;if(C(E))return this.filter(function(w,k){return k.dir&&E.test(w)});var b=this.root+E,P=y.call(this,b),M=this.clone();return M.root=P.name,M},remove:function(E){E=this.root+E;var b=this.files[E];if(b||(E.slice(-1)!=="/"&&(E+="/"),b=this.files[E]),b&&!b.dir)delete this.files[E];else for(var P=this.filter(function(w,k){return k.name.slice(0,E.length)===E}),M=0;M<P.length;M++)delete this.files[P[M].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(E){var b,P={};try{if((P=c.extend(E||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:a.utf8encode})).type=P.type.toLowerCase(),P.compression=P.compression.toUpperCase(),P.type==="binarystring"&&(P.type="string"),!P.type)throw new Error("No output type specified.");c.checkSupport(P.type),P.platform!=="darwin"&&P.platform!=="freebsd"&&P.platform!=="linux"&&P.platform!=="sunos"||(P.platform="UNIX"),P.platform==="win32"&&(P.platform="DOS");var M=P.comment||this.comment||"";b=h.generateWorker(this,P,M)}catch(w){(b=new l("error")).error(w)}return new A(b,P.type||"string",P.mimeType)},generateAsync:function(E,b){return this.generateInternalStream(E).accumulate(b)},generateNodeStream:function(E,b){return(E=E||{}).type||(E.type="nodebuffer"),this.generateInternalStream(E).toNodejsStream(b)}};i.exports=I},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(o,i,r){i.exports=o("stream")},{stream:void 0}],17:[function(o,i,r){var s=o("./DataReader");function a(c){s.call(this,c);for(var l=0;l<this.data.length;l++)c[l]=255&c[l]}o("../utils").inherits(a,s),a.prototype.byteAt=function(c){return this.data[this.zero+c]},a.prototype.lastIndexOfSignature=function(c){for(var l=c.charCodeAt(0),A=c.charCodeAt(1),u=c.charCodeAt(2),d=c.charCodeAt(3),_=this.length-4;0<=_;--_)if(this.data[_]===l&&this.data[_+1]===A&&this.data[_+2]===u&&this.data[_+3]===d)return _-this.zero;return-1},a.prototype.readAndCheckSignature=function(c){var l=c.charCodeAt(0),A=c.charCodeAt(1),u=c.charCodeAt(2),d=c.charCodeAt(3),_=this.readData(4);return l===_[0]&&A===_[1]&&u===_[2]&&d===_[3]},a.prototype.readData=function(c){if(this.checkOffset(c),c===0)return[];var l=this.data.slice(this.zero+this.index,this.zero+this.index+c);return this.index+=c,l},i.exports=a},{"../utils":32,"./DataReader":18}],18:[function(o,i,r){var s=o("../utils");function a(c){this.data=c,this.length=c.length,this.index=0,this.zero=0}a.prototype={checkOffset:function(c){this.checkIndex(this.index+c)},checkIndex:function(c){if(this.length<this.zero+c||c<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+c+"). Corrupted zip ?")},setIndex:function(c){this.checkIndex(c),this.index=c},skip:function(c){this.setIndex(this.index+c)},byteAt:function(){},readInt:function(c){var l,A=0;for(this.checkOffset(c),l=this.index+c-1;l>=this.index;l--)A=(A<<8)+this.byteAt(l);return this.index+=c,A},readString:function(c){return s.transformTo("string",this.readData(c))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var c=this.readInt(4);return new Date(Date.UTC(1980+(c>>25&127),(c>>21&15)-1,c>>16&31,c>>11&31,c>>5&63,(31&c)<<1))}},i.exports=a},{"../utils":32}],19:[function(o,i,r){var s=o("./Uint8ArrayReader");function a(c){s.call(this,c)}o("../utils").inherits(a,s),a.prototype.readData=function(c){this.checkOffset(c);var l=this.data.slice(this.zero+this.index,this.zero+this.index+c);return this.index+=c,l},i.exports=a},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(o,i,r){var s=o("./DataReader");function a(c){s.call(this,c)}o("../utils").inherits(a,s),a.prototype.byteAt=function(c){return this.data.charCodeAt(this.zero+c)},a.prototype.lastIndexOfSignature=function(c){return this.data.lastIndexOf(c)-this.zero},a.prototype.readAndCheckSignature=function(c){return c===this.readData(4)},a.prototype.readData=function(c){this.checkOffset(c);var l=this.data.slice(this.zero+this.index,this.zero+this.index+c);return this.index+=c,l},i.exports=a},{"../utils":32,"./DataReader":18}],21:[function(o,i,r){var s=o("./ArrayReader");function a(c){s.call(this,c)}o("../utils").inherits(a,s),a.prototype.readData=function(c){if(this.checkOffset(c),c===0)return new Uint8Array(0);var l=this.data.subarray(this.zero+this.index,this.zero+this.index+c);return this.index+=c,l},i.exports=a},{"../utils":32,"./ArrayReader":17}],22:[function(o,i,r){var s=o("../utils"),a=o("../support"),c=o("./ArrayReader"),l=o("./StringReader"),A=o("./NodeBufferReader"),u=o("./Uint8ArrayReader");i.exports=function(d){var _=s.getTypeOf(d);return s.checkSupport(_),_!=="string"||a.uint8array?_==="nodebuffer"?new A(d):a.uint8array?new u(s.transformTo("uint8array",d)):new c(s.transformTo("array",d)):new l(d)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(o,i,r){r.LOCAL_FILE_HEADER="PK",r.CENTRAL_FILE_HEADER="PK",r.CENTRAL_DIRECTORY_END="PK",r.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",r.ZIP64_CENTRAL_DIRECTORY_END="PK",r.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(o,i,r){var s=o("./GenericWorker"),a=o("../utils");function c(l){s.call(this,"ConvertWorker to "+l),this.destType=l}a.inherits(c,s),c.prototype.processChunk=function(l){this.push({data:a.transformTo(this.destType,l.data),meta:l.meta})},i.exports=c},{"../utils":32,"./GenericWorker":28}],25:[function(o,i,r){var s=o("./GenericWorker"),a=o("../crc32");function c(){s.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}o("../utils").inherits(c,s),c.prototype.processChunk=function(l){this.streamInfo.crc32=a(l.data,this.streamInfo.crc32||0),this.push(l)},i.exports=c},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(o,i,r){var s=o("../utils"),a=o("./GenericWorker");function c(l){a.call(this,"DataLengthProbe for "+l),this.propName=l,this.withStreamInfo(l,0)}s.inherits(c,a),c.prototype.processChunk=function(l){if(l){var A=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=A+l.data.length}a.prototype.processChunk.call(this,l)},i.exports=c},{"../utils":32,"./GenericWorker":28}],27:[function(o,i,r){var s=o("../utils"),a=o("./GenericWorker");function c(l){a.call(this,"DataWorker");var A=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,l.then(function(u){A.dataIsReady=!0,A.data=u,A.max=u&&u.length||0,A.type=s.getTypeOf(u),A.isPaused||A._tickAndRepeat()},function(u){A.error(u)})}s.inherits(c,a),c.prototype.cleanUp=function(){a.prototype.cleanUp.call(this),this.data=null},c.prototype.resume=function(){return!!a.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,s.delay(this._tickAndRepeat,[],this)),!0)},c.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(s.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},c.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var l=null,A=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":l=this.data.substring(this.index,A);break;case"uint8array":l=this.data.subarray(this.index,A);break;case"array":case"nodebuffer":l=this.data.slice(this.index,A)}return this.index=A,this.push({data:l,meta:{percent:this.max?this.index/this.max*100:0}})},i.exports=c},{"../utils":32,"./GenericWorker":28}],28:[function(o,i,r){function s(a){this.name=a||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}s.prototype={push:function(a){this.emit("data",a)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(a){this.emit("error",a)}return!0},error:function(a){return!this.isFinished&&(this.isPaused?this.generatedError=a:(this.isFinished=!0,this.emit("error",a),this.previous&&this.previous.error(a),this.cleanUp()),!0)},on:function(a,c){return this._listeners[a].push(c),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(a,c){if(this._listeners[a])for(var l=0;l<this._listeners[a].length;l++)this._listeners[a][l].call(this,c)},pipe:function(a){return a.registerPrevious(this)},registerPrevious:function(a){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=a.streamInfo,this.mergeStreamInfo(),this.previous=a;var c=this;return a.on("data",function(l){c.processChunk(l)}),a.on("end",function(){c.end()}),a.on("error",function(l){c.error(l)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var a=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),a=!0),this.previous&&this.previous.resume(),!a},flush:function(){},processChunk:function(a){this.push(a)},withStreamInfo:function(a,c){return this.extraStreamInfo[a]=c,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var a in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,a)&&(this.streamInfo[a]=this.extraStreamInfo[a])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var a="Worker "+this.name;return this.previous?this.previous+" -> "+a:a}},i.exports=s},{}],29:[function(o,i,r){var s=o("../utils"),a=o("./ConvertWorker"),c=o("./GenericWorker"),l=o("../base64"),A=o("../support"),u=o("../external"),d=null;if(A.nodestream)try{d=o("../nodejs/NodejsStreamOutputAdapter")}catch{}function _(m,p){return new u.Promise(function(g,f){var y=[],C=m._internalType,I=m._outputType,E=m._mimeType;m.on("data",function(b,P){y.push(b),p&&p(P)}).on("error",function(b){y=[],f(b)}).on("end",function(){try{var b=(function(P,M,w){switch(P){case"blob":return s.newBlob(s.transformTo("arraybuffer",M),w);case"base64":return l.encode(M);default:return s.transformTo(P,M)}})(I,(function(P,M){var w,k=0,N=null,O=0;for(w=0;w<M.length;w++)O+=M[w].length;switch(P){case"string":return M.join("");case"array":return Array.prototype.concat.apply([],M);case"uint8array":for(N=new Uint8Array(O),w=0;w<M.length;w++)N.set(M[w],k),k+=M[w].length;return N;case"nodebuffer":return Buffer.concat(M);default:throw new Error("concat : unsupported type '"+P+"'")}})(C,y),E);g(b)}catch(P){f(P)}y=[]}).resume()})}function h(m,p,g){var f=p;switch(p){case"blob":case"arraybuffer":f="uint8array";break;case"base64":f="string"}try{this._internalType=f,this._outputType=p,this._mimeType=g,s.checkSupport(f),this._worker=m.pipe(new a(f)),m.lock()}catch(y){this._worker=new c("error"),this._worker.error(y)}}h.prototype={accumulate:function(m){return _(this,m)},on:function(m,p){var g=this;return m==="data"?this._worker.on(m,function(f){p.call(g,f.data,f.meta)}):this._worker.on(m,function(){s.delay(p,arguments,g)}),this},resume:function(){return s.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(m){if(s.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new d(this,{objectMode:this._outputType!=="nodebuffer"},m)}},i.exports=h},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(o,i,r){if(r.base64=!0,r.array=!0,r.string=!0,r.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",r.nodebuffer=typeof Buffer<"u",r.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")r.blob=!1;else{var s=new ArrayBuffer(0);try{r.blob=new Blob([s],{type:"application/zip"}).size===0}catch{try{var a=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);a.append(s),r.blob=a.getBlob("application/zip").size===0}catch{r.blob=!1}}}try{r.nodestream=!!o("readable-stream").Readable}catch{r.nodestream=!1}},{"readable-stream":16}],31:[function(o,i,r){for(var s=o("./utils"),a=o("./support"),c=o("./nodejsUtils"),l=o("./stream/GenericWorker"),A=new Array(256),u=0;u<256;u++)A[u]=252<=u?6:248<=u?5:240<=u?4:224<=u?3:192<=u?2:1;A[254]=A[254]=1;function d(){l.call(this,"utf-8 decode"),this.leftOver=null}function _(){l.call(this,"utf-8 encode")}r.utf8encode=function(h){return a.nodebuffer?c.newBufferFrom(h,"utf-8"):(function(m){var p,g,f,y,C,I=m.length,E=0;for(y=0;y<I;y++)(64512&(g=m.charCodeAt(y)))==55296&&y+1<I&&(64512&(f=m.charCodeAt(y+1)))==56320&&(g=65536+(g-55296<<10)+(f-56320),y++),E+=g<128?1:g<2048?2:g<65536?3:4;for(p=a.uint8array?new Uint8Array(E):new Array(E),y=C=0;C<E;y++)(64512&(g=m.charCodeAt(y)))==55296&&y+1<I&&(64512&(f=m.charCodeAt(y+1)))==56320&&(g=65536+(g-55296<<10)+(f-56320),y++),g<128?p[C++]=g:(g<2048?p[C++]=192|g>>>6:(g<65536?p[C++]=224|g>>>12:(p[C++]=240|g>>>18,p[C++]=128|g>>>12&63),p[C++]=128|g>>>6&63),p[C++]=128|63&g);return p})(h)},r.utf8decode=function(h){return a.nodebuffer?s.transformTo("nodebuffer",h).toString("utf-8"):(function(m){var p,g,f,y,C=m.length,I=new Array(2*C);for(p=g=0;p<C;)if((f=m[p++])<128)I[g++]=f;else if(4<(y=A[f]))I[g++]=65533,p+=y-1;else{for(f&=y===2?31:y===3?15:7;1<y&&p<C;)f=f<<6|63&m[p++],y--;1<y?I[g++]=65533:f<65536?I[g++]=f:(f-=65536,I[g++]=55296|f>>10&1023,I[g++]=56320|1023&f)}return I.length!==g&&(I.subarray?I=I.subarray(0,g):I.length=g),s.applyFromCharCode(I)})(h=s.transformTo(a.uint8array?"uint8array":"array",h))},s.inherits(d,l),d.prototype.processChunk=function(h){var m=s.transformTo(a.uint8array?"uint8array":"array",h.data);if(this.leftOver&&this.leftOver.length){if(a.uint8array){var p=m;(m=new Uint8Array(p.length+this.leftOver.length)).set(this.leftOver,0),m.set(p,this.leftOver.length)}else m=this.leftOver.concat(m);this.leftOver=null}var g=(function(y,C){var I;for((C=C||y.length)>y.length&&(C=y.length),I=C-1;0<=I&&(192&y[I])==128;)I--;return I<0||I===0?C:I+A[y[I]]>C?I:C})(m),f=m;g!==m.length&&(a.uint8array?(f=m.subarray(0,g),this.leftOver=m.subarray(g,m.length)):(f=m.slice(0,g),this.leftOver=m.slice(g,m.length))),this.push({data:r.utf8decode(f),meta:h.meta})},d.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:r.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},r.Utf8DecodeWorker=d,s.inherits(_,l),_.prototype.processChunk=function(h){this.push({data:r.utf8encode(h.data),meta:h.meta})},r.Utf8EncodeWorker=_},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(o,i,r){var s=o("./support"),a=o("./base64"),c=o("./nodejsUtils"),l=o("./external");function A(p){return p}function u(p,g){for(var f=0;f<p.length;++f)g[f]=255&p.charCodeAt(f);return g}o("setimmediate"),r.newBlob=function(p,g){r.checkSupport("blob");try{return new Blob([p],{type:g})}catch{try{var f=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return f.append(p),f.getBlob(g)}catch{throw new Error("Bug : can't construct the Blob.")}}};var d={stringifyByChunk:function(p,g,f){var y=[],C=0,I=p.length;if(I<=f)return String.fromCharCode.apply(null,p);for(;C<I;)g==="array"||g==="nodebuffer"?y.push(String.fromCharCode.apply(null,p.slice(C,Math.min(C+f,I)))):y.push(String.fromCharCode.apply(null,p.subarray(C,Math.min(C+f,I)))),C+=f;return y.join("")},stringifyByChar:function(p){for(var g="",f=0;f<p.length;f++)g+=String.fromCharCode(p[f]);return g},applyCanBeUsed:{uint8array:(function(){try{return s.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}})(),nodebuffer:(function(){try{return s.nodebuffer&&String.fromCharCode.apply(null,c.allocBuffer(1)).length===1}catch{return!1}})()}};function _(p){var g=65536,f=r.getTypeOf(p),y=!0;if(f==="uint8array"?y=d.applyCanBeUsed.uint8array:f==="nodebuffer"&&(y=d.applyCanBeUsed.nodebuffer),y)for(;1<g;)try{return d.stringifyByChunk(p,f,g)}catch{g=Math.floor(g/2)}return d.stringifyByChar(p)}function h(p,g){for(var f=0;f<p.length;f++)g[f]=p[f];return g}r.applyFromCharCode=_;var m={};m.string={string:A,array:function(p){return u(p,new Array(p.length))},arraybuffer:function(p){return m.string.uint8array(p).buffer},uint8array:function(p){return u(p,new Uint8Array(p.length))},nodebuffer:function(p){return u(p,c.allocBuffer(p.length))}},m.array={string:_,array:A,arraybuffer:function(p){return new Uint8Array(p).buffer},uint8array:function(p){return new Uint8Array(p)},nodebuffer:function(p){return c.newBufferFrom(p)}},m.arraybuffer={string:function(p){return _(new Uint8Array(p))},array:function(p){return h(new Uint8Array(p),new Array(p.byteLength))},arraybuffer:A,uint8array:function(p){return new Uint8Array(p)},nodebuffer:function(p){return c.newBufferFrom(new Uint8Array(p))}},m.uint8array={string:_,array:function(p){return h(p,new Array(p.length))},arraybuffer:function(p){return p.buffer},uint8array:A,nodebuffer:function(p){return c.newBufferFrom(p)}},m.nodebuffer={string:_,array:function(p){return h(p,new Array(p.length))},arraybuffer:function(p){return m.nodebuffer.uint8array(p).buffer},uint8array:function(p){return h(p,new Uint8Array(p.length))},nodebuffer:A},r.transformTo=function(p,g){if(g=g||"",!p)return g;r.checkSupport(p);var f=r.getTypeOf(g);return m[f][p](g)},r.resolve=function(p){for(var g=p.split("/"),f=[],y=0;y<g.length;y++){var C=g[y];C==="."||C===""&&y!==0&&y!==g.length-1||(C===".."?f.pop():f.push(C))}return f.join("/")},r.getTypeOf=function(p){return typeof p=="string"?"string":Object.prototype.toString.call(p)==="[object Array]"?"array":s.nodebuffer&&c.isBuffer(p)?"nodebuffer":s.uint8array&&p instanceof Uint8Array?"uint8array":s.arraybuffer&&p instanceof ArrayBuffer?"arraybuffer":void 0},r.checkSupport=function(p){if(!s[p.toLowerCase()])throw new Error(p+" is not supported by this platform")},r.MAX_VALUE_16BITS=65535,r.MAX_VALUE_32BITS=-1,r.pretty=function(p){var g,f,y="";for(f=0;f<(p||"").length;f++)y+="\\x"+((g=p.charCodeAt(f))<16?"0":"")+g.toString(16).toUpperCase();return y},r.delay=function(p,g,f){setImmediate(function(){p.apply(f||null,g||[])})},r.inherits=function(p,g){function f(){}f.prototype=g.prototype,p.prototype=new f},r.extend=function(){var p,g,f={};for(p=0;p<arguments.length;p++)for(g in arguments[p])Object.prototype.hasOwnProperty.call(arguments[p],g)&&f[g]===void 0&&(f[g]=arguments[p][g]);return f},r.prepareContent=function(p,g,f,y,C){return l.Promise.resolve(g).then(function(I){return s.blob&&(I instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(I))!==-1)&&typeof FileReader<"u"?new l.Promise(function(E,b){var P=new FileReader;P.onload=function(M){E(M.target.result)},P.onerror=function(M){b(M.target.error)},P.readAsArrayBuffer(I)}):I}).then(function(I){var E=r.getTypeOf(I);return E?(E==="arraybuffer"?I=r.transformTo("uint8array",I):E==="string"&&(C?I=a.decode(I):f&&y!==!0&&(I=(function(b){return u(b,s.uint8array?new Uint8Array(b.length):new Array(b.length))})(I))),I):l.Promise.reject(new Error("Can't read the data of '"+p+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(o,i,r){var s=o("./reader/readerFor"),a=o("./utils"),c=o("./signature"),l=o("./zipEntry"),A=o("./support");function u(d){this.files=[],this.loadOptions=d}u.prototype={checkSignature:function(d){if(!this.reader.readAndCheckSignature(d)){this.reader.index-=4;var _=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+a.pretty(_)+", expected "+a.pretty(d)+")")}},isSignature:function(d,_){var h=this.reader.index;this.reader.setIndex(d);var m=this.reader.readString(4)===_;return this.reader.setIndex(h),m},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var d=this.reader.readData(this.zipCommentLength),_=A.uint8array?"uint8array":"array",h=a.transformTo(_,d);this.zipComment=this.loadOptions.decodeFileName(h)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var d,_,h,m=this.zip64EndOfCentralSize-44;0<m;)d=this.reader.readInt(2),_=this.reader.readInt(4),h=this.reader.readData(_),this.zip64ExtensibleData[d]={id:d,length:_,value:h}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var d,_;for(d=0;d<this.files.length;d++)_=this.files[d],this.reader.setIndex(_.localHeaderOffset),this.checkSignature(c.LOCAL_FILE_HEADER),_.readLocalPart(this.reader),_.handleUTF8(),_.processAttributes()},readCentralDir:function(){var d;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(c.CENTRAL_FILE_HEADER);)(d=new l({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(d);if(this.centralDirRecords!==this.files.length&&this.centralDirRecords!==0&&this.files.length===0)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var d=this.reader.lastIndexOfSignature(c.CENTRAL_DIRECTORY_END);if(d<0)throw this.isSignature(0,c.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(d);var _=d;if(this.checkSignature(c.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===a.MAX_VALUE_16BITS||this.diskWithCentralDirStart===a.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===a.MAX_VALUE_16BITS||this.centralDirRecords===a.MAX_VALUE_16BITS||this.centralDirSize===a.MAX_VALUE_32BITS||this.centralDirOffset===a.MAX_VALUE_32BITS){if(this.zip64=!0,(d=this.reader.lastIndexOfSignature(c.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(d),this.checkSignature(c.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,c.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(c.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(c.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var h=this.centralDirOffset+this.centralDirSize;this.zip64&&(h+=20,h+=12+this.zip64EndOfCentralSize);var m=_-h;if(0<m)this.isSignature(_,c.CENTRAL_FILE_HEADER)||(this.reader.zero=m);else if(m<0)throw new Error("Corrupted zip: missing "+Math.abs(m)+" bytes.")},prepareReader:function(d){this.reader=s(d)},load:function(d){this.prepareReader(d),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},i.exports=u},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(o,i,r){var s=o("./reader/readerFor"),a=o("./utils"),c=o("./compressedObject"),l=o("./crc32"),A=o("./utf8"),u=o("./compressions"),d=o("./support");function _(h,m){this.options=h,this.loadOptions=m}_.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(h){var m,p;if(h.skip(22),this.fileNameLength=h.readInt(2),p=h.readInt(2),this.fileName=h.readData(this.fileNameLength),h.skip(p),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((m=(function(g){for(var f in u)if(Object.prototype.hasOwnProperty.call(u,f)&&u[f].magic===g)return u[f];return null})(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+a.pretty(this.compressionMethod)+" unknown (inner file : "+a.transformTo("string",this.fileName)+")");this.decompressed=new c(this.compressedSize,this.uncompressedSize,this.crc32,m,h.readData(this.compressedSize))},readCentralPart:function(h){this.versionMadeBy=h.readInt(2),h.skip(2),this.bitFlag=h.readInt(2),this.compressionMethod=h.readString(2),this.date=h.readDate(),this.crc32=h.readInt(4),this.compressedSize=h.readInt(4),this.uncompressedSize=h.readInt(4);var m=h.readInt(2);if(this.extraFieldsLength=h.readInt(2),this.fileCommentLength=h.readInt(2),this.diskNumberStart=h.readInt(2),this.internalFileAttributes=h.readInt(2),this.externalFileAttributes=h.readInt(4),this.localHeaderOffset=h.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");h.skip(m),this.readExtraFields(h),this.parseZIP64ExtraField(h),this.fileComment=h.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var h=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),h==0&&(this.dosPermissions=63&this.externalFileAttributes),h==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var h=s(this.extraFields[1].value);this.uncompressedSize===a.MAX_VALUE_32BITS&&(this.uncompressedSize=h.readInt(8)),this.compressedSize===a.MAX_VALUE_32BITS&&(this.compressedSize=h.readInt(8)),this.localHeaderOffset===a.MAX_VALUE_32BITS&&(this.localHeaderOffset=h.readInt(8)),this.diskNumberStart===a.MAX_VALUE_32BITS&&(this.diskNumberStart=h.readInt(4))}},readExtraFields:function(h){var m,p,g,f=h.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});h.index+4<f;)m=h.readInt(2),p=h.readInt(2),g=h.readData(p),this.extraFields[m]={id:m,length:p,value:g};h.setIndex(f)},handleUTF8:function(){var h=d.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=A.utf8decode(this.fileName),this.fileCommentStr=A.utf8decode(this.fileComment);else{var m=this.findExtraFieldUnicodePath();if(m!==null)this.fileNameStr=m;else{var p=a.transformTo(h,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(p)}var g=this.findExtraFieldUnicodeComment();if(g!==null)this.fileCommentStr=g;else{var f=a.transformTo(h,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(f)}}},findExtraFieldUnicodePath:function(){var h=this.extraFields[28789];if(h){var m=s(h.value);return m.readInt(1)!==1||l(this.fileName)!==m.readInt(4)?null:A.utf8decode(m.readData(h.length-5))}return null},findExtraFieldUnicodeComment:function(){var h=this.extraFields[25461];if(h){var m=s(h.value);return m.readInt(1)!==1||l(this.fileComment)!==m.readInt(4)?null:A.utf8decode(m.readData(h.length-5))}return null}},i.exports=_},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(o,i,r){function s(m,p,g){this.name=m,this.dir=g.dir,this.date=g.date,this.comment=g.comment,this.unixPermissions=g.unixPermissions,this.dosPermissions=g.dosPermissions,this._data=p,this._dataBinary=g.binary,this.options={compression:g.compression,compressionOptions:g.compressionOptions}}var a=o("./stream/StreamHelper"),c=o("./stream/DataWorker"),l=o("./utf8"),A=o("./compressedObject"),u=o("./stream/GenericWorker");s.prototype={internalStream:function(m){var p=null,g="string";try{if(!m)throw new Error("No output type specified.");var f=(g=m.toLowerCase())==="string"||g==="text";g!=="binarystring"&&g!=="text"||(g="string"),p=this._decompressWorker();var y=!this._dataBinary;y&&!f&&(p=p.pipe(new l.Utf8EncodeWorker)),!y&&f&&(p=p.pipe(new l.Utf8DecodeWorker))}catch(C){(p=new u("error")).error(C)}return new a(p,g,"")},async:function(m,p){return this.internalStream(m).accumulate(p)},nodeStream:function(m,p){return this.internalStream(m||"nodebuffer").toNodejsStream(p)},_compressWorker:function(m,p){if(this._data instanceof A&&this._data.compression.magic===m.magic)return this._data.getCompressedWorker();var g=this._decompressWorker();return this._dataBinary||(g=g.pipe(new l.Utf8EncodeWorker)),A.createWorkerFrom(g,m,p)},_decompressWorker:function(){return this._data instanceof A?this._data.getContentWorker():this._data instanceof u?this._data:new c(this._data)}};for(var d=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],_=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},h=0;h<d.length;h++)s.prototype[d[h]]=_;i.exports=s},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(o,i,r){(function(s){var a,c,l=s.MutationObserver||s.WebKitMutationObserver;if(l){var A=0,u=new l(m),d=s.document.createTextNode("");u.observe(d,{characterData:!0}),a=function(){d.data=A=++A%2}}else if(s.setImmediate||s.MessageChannel===void 0)a="document"in s&&"onreadystatechange"in s.document.createElement("script")?function(){var p=s.document.createElement("script");p.onreadystatechange=function(){m(),p.onreadystatechange=null,p.parentNode.removeChild(p),p=null},s.document.documentElement.appendChild(p)}:function(){setTimeout(m,0)};else{var _=new s.MessageChannel;_.port1.onmessage=m,a=function(){_.port2.postMessage(0)}}var h=[];function m(){var p,g;c=!0;for(var f=h.length;f;){for(g=h,h=[],p=-1;++p<f;)g[p]();f=h.length}c=!1}i.exports=function(p){h.push(p)!==1||c||a()}}).call(this,typeof fU<"u"?fU:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(o,i,r){var s=o("immediate");function a(){}var c={},l=["REJECTED"],A=["FULFILLED"],u=["PENDING"];function d(f){if(typeof f!="function")throw new TypeError("resolver must be a function");this.state=u,this.queue=[],this.outcome=void 0,f!==a&&p(this,f)}function _(f,y,C){this.promise=f,typeof y=="function"&&(this.onFulfilled=y,this.callFulfilled=this.otherCallFulfilled),typeof C=="function"&&(this.onRejected=C,this.callRejected=this.otherCallRejected)}function h(f,y,C){s(function(){var I;try{I=y(C)}catch(E){return c.reject(f,E)}I===f?c.reject(f,new TypeError("Cannot resolve promise with itself")):c.resolve(f,I)})}function m(f){var y=f&&f.then;if(f&&(typeof f=="object"||typeof f=="function")&&typeof y=="function")return function(){y.apply(f,arguments)}}function p(f,y){var C=!1;function I(P){C||(C=!0,c.reject(f,P))}function E(P){C||(C=!0,c.resolve(f,P))}var b=g(function(){y(E,I)});b.status==="error"&&I(b.value)}function g(f,y){var C={};try{C.value=f(y),C.status="success"}catch(I){C.status="error",C.value=I}return C}(i.exports=d).prototype.finally=function(f){if(typeof f!="function")return this;var y=this.constructor;return this.then(function(C){return y.resolve(f()).then(function(){return C})},function(C){return y.resolve(f()).then(function(){throw C})})},d.prototype.catch=function(f){return this.then(null,f)},d.prototype.then=function(f,y){if(typeof f!="function"&&this.state===A||typeof y!="function"&&this.state===l)return this;var C=new this.constructor(a);return this.state!==u?h(C,this.state===A?f:y,this.outcome):this.queue.push(new _(C,f,y)),C},_.prototype.callFulfilled=function(f){c.resolve(this.promise,f)},_.prototype.otherCallFulfilled=function(f){h(this.promise,this.onFulfilled,f)},_.prototype.callRejected=function(f){c.reject(this.promise,f)},_.prototype.otherCallRejected=function(f){h(this.promise,this.onRejected,f)},c.resolve=function(f,y){var C=g(m,y);if(C.status==="error")return c.reject(f,C.value);var I=C.value;if(I)p(f,I);else{f.state=A,f.outcome=y;for(var E=-1,b=f.queue.length;++E<b;)f.queue[E].callFulfilled(y)}return f},c.reject=function(f,y){f.state=l,f.outcome=y;for(var C=-1,I=f.queue.length;++C<I;)f.queue[C].callRejected(y);return f},d.resolve=function(f){return f instanceof this?f:c.resolve(new this(a),f)},d.reject=function(f){var y=new this(a);return c.reject(y,f)},d.all=function(f){var y=this;if(Object.prototype.toString.call(f)!=="[object Array]")return this.reject(new TypeError("must be an array"));var C=f.length,I=!1;if(!C)return this.resolve([]);for(var E=new Array(C),b=0,P=-1,M=new this(a);++P<C;)w(f[P],P);return M;function w(k,N){y.resolve(k).then(function(O){E[N]=O,++b!==C||I||(I=!0,c.resolve(M,E))},function(O){I||(I=!0,c.reject(M,O))})}},d.race=function(f){var y=this;if(Object.prototype.toString.call(f)!=="[object Array]")return this.reject(new TypeError("must be an array"));var C=f.length,I=!1;if(!C)return this.resolve([]);for(var E=-1,b=new this(a);++E<C;)P=f[E],y.resolve(P).then(function(M){I||(I=!0,c.resolve(b,M))},function(M){I||(I=!0,c.reject(b,M))});var P;return b}},{immediate:36}],38:[function(o,i,r){var s={};(0,o("./lib/utils/common").assign)(s,o("./lib/deflate"),o("./lib/inflate"),o("./lib/zlib/constants")),i.exports=s},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(o,i,r){var s=o("./zlib/deflate"),a=o("./utils/common"),c=o("./utils/strings"),l=o("./zlib/messages"),A=o("./zlib/zstream"),u=Object.prototype.toString,d=0,_=-1,h=0,m=8;function p(f){if(!(this instanceof p))return new p(f);this.options=a.assign({level:_,method:m,chunkSize:16384,windowBits:15,memLevel:8,strategy:h,to:""},f||{});var y=this.options;y.raw&&0<y.windowBits?y.windowBits=-y.windowBits:y.gzip&&0<y.windowBits&&y.windowBits<16&&(y.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new A,this.strm.avail_out=0;var C=s.deflateInit2(this.strm,y.level,y.method,y.windowBits,y.memLevel,y.strategy);if(C!==d)throw new Error(l[C]);if(y.header&&s.deflateSetHeader(this.strm,y.header),y.dictionary){var I;if(I=typeof y.dictionary=="string"?c.string2buf(y.dictionary):u.call(y.dictionary)==="[object ArrayBuffer]"?new Uint8Array(y.dictionary):y.dictionary,(C=s.deflateSetDictionary(this.strm,I))!==d)throw new Error(l[C]);this._dict_set=!0}}function g(f,y){var C=new p(y);if(C.push(f,!0),C.err)throw C.msg||l[C.err];return C.result}p.prototype.push=function(f,y){var C,I,E=this.strm,b=this.options.chunkSize;if(this.ended)return!1;I=y===~~y?y:y===!0?4:0,typeof f=="string"?E.input=c.string2buf(f):u.call(f)==="[object ArrayBuffer]"?E.input=new Uint8Array(f):E.input=f,E.next_in=0,E.avail_in=E.input.length;do{if(E.avail_out===0&&(E.output=new a.Buf8(b),E.next_out=0,E.avail_out=b),(C=s.deflate(E,I))!==1&&C!==d)return this.onEnd(C),!(this.ended=!0);E.avail_out!==0&&(E.avail_in!==0||I!==4&&I!==2)||(this.options.to==="string"?this.onData(c.buf2binstring(a.shrinkBuf(E.output,E.next_out))):this.onData(a.shrinkBuf(E.output,E.next_out)))}while((0<E.avail_in||E.avail_out===0)&&C!==1);return I===4?(C=s.deflateEnd(this.strm),this.onEnd(C),this.ended=!0,C===d):I!==2||(this.onEnd(d),!(E.avail_out=0))},p.prototype.onData=function(f){this.chunks.push(f)},p.prototype.onEnd=function(f){f===d&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=a.flattenChunks(this.chunks)),this.chunks=[],this.err=f,this.msg=this.strm.msg},r.Deflate=p,r.deflate=g,r.deflateRaw=function(f,y){return(y=y||{}).raw=!0,g(f,y)},r.gzip=function(f,y){return(y=y||{}).gzip=!0,g(f,y)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(o,i,r){var s=o("./zlib/inflate"),a=o("./utils/common"),c=o("./utils/strings"),l=o("./zlib/constants"),A=o("./zlib/messages"),u=o("./zlib/zstream"),d=o("./zlib/gzheader"),_=Object.prototype.toString;function h(p){if(!(this instanceof h))return new h(p);this.options=a.assign({chunkSize:16384,windowBits:0,to:""},p||{});var g=this.options;g.raw&&0<=g.windowBits&&g.windowBits<16&&(g.windowBits=-g.windowBits,g.windowBits===0&&(g.windowBits=-15)),!(0<=g.windowBits&&g.windowBits<16)||p&&p.windowBits||(g.windowBits+=32),15<g.windowBits&&g.windowBits<48&&(15&g.windowBits)==0&&(g.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new u,this.strm.avail_out=0;var f=s.inflateInit2(this.strm,g.windowBits);if(f!==l.Z_OK)throw new Error(A[f]);this.header=new d,s.inflateGetHeader(this.strm,this.header)}function m(p,g){var f=new h(g);if(f.push(p,!0),f.err)throw f.msg||A[f.err];return f.result}h.prototype.push=function(p,g){var f,y,C,I,E,b,P=this.strm,M=this.options.chunkSize,w=this.options.dictionary,k=!1;if(this.ended)return!1;y=g===~~g?g:g===!0?l.Z_FINISH:l.Z_NO_FLUSH,typeof p=="string"?P.input=c.binstring2buf(p):_.call(p)==="[object ArrayBuffer]"?P.input=new Uint8Array(p):P.input=p,P.next_in=0,P.avail_in=P.input.length;do{if(P.avail_out===0&&(P.output=new a.Buf8(M),P.next_out=0,P.avail_out=M),(f=s.inflate(P,l.Z_NO_FLUSH))===l.Z_NEED_DICT&&w&&(b=typeof w=="string"?c.string2buf(w):_.call(w)==="[object ArrayBuffer]"?new Uint8Array(w):w,f=s.inflateSetDictionary(this.strm,b)),f===l.Z_BUF_ERROR&&k===!0&&(f=l.Z_OK,k=!1),f!==l.Z_STREAM_END&&f!==l.Z_OK)return this.onEnd(f),!(this.ended=!0);P.next_out&&(P.avail_out!==0&&f!==l.Z_STREAM_END&&(P.avail_in!==0||y!==l.Z_FINISH&&y!==l.Z_SYNC_FLUSH)||(this.options.to==="string"?(C=c.utf8border(P.output,P.next_out),I=P.next_out-C,E=c.buf2string(P.output,C),P.next_out=I,P.avail_out=M-I,I&&a.arraySet(P.output,P.output,C,I,0),this.onData(E)):this.onData(a.shrinkBuf(P.output,P.next_out)))),P.avail_in===0&&P.avail_out===0&&(k=!0)}while((0<P.avail_in||P.avail_out===0)&&f!==l.Z_STREAM_END);return f===l.Z_STREAM_END&&(y=l.Z_FINISH),y===l.Z_FINISH?(f=s.inflateEnd(this.strm),this.onEnd(f),this.ended=!0,f===l.Z_OK):y!==l.Z_SYNC_FLUSH||(this.onEnd(l.Z_OK),!(P.avail_out=0))},h.prototype.onData=function(p){this.chunks.push(p)},h.prototype.onEnd=function(p){p===l.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=a.flattenChunks(this.chunks)),this.chunks=[],this.err=p,this.msg=this.strm.msg},r.Inflate=h,r.inflate=m,r.inflateRaw=function(p,g){return(g=g||{}).raw=!0,m(p,g)},r.ungzip=m},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(o,i,r){var s=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";r.assign=function(l){for(var A=Array.prototype.slice.call(arguments,1);A.length;){var u=A.shift();if(u){if(typeof u!="object")throw new TypeError(u+"must be non-object");for(var d in u)u.hasOwnProperty(d)&&(l[d]=u[d])}}return l},r.shrinkBuf=function(l,A){return l.length===A?l:l.subarray?l.subarray(0,A):(l.length=A,l)};var a={arraySet:function(l,A,u,d,_){if(A.subarray&&l.subarray)l.set(A.subarray(u,u+d),_);else for(var h=0;h<d;h++)l[_+h]=A[u+h]},flattenChunks:function(l){var A,u,d,_,h,m;for(A=d=0,u=l.length;A<u;A++)d+=l[A].length;for(m=new Uint8Array(d),A=_=0,u=l.length;A<u;A++)h=l[A],m.set(h,_),_+=h.length;return m}},c={arraySet:function(l,A,u,d,_){for(var h=0;h<d;h++)l[_+h]=A[u+h]},flattenChunks:function(l){return[].concat.apply([],l)}};r.setTyped=function(l){l?(r.Buf8=Uint8Array,r.Buf16=Uint16Array,r.Buf32=Int32Array,r.assign(r,a)):(r.Buf8=Array,r.Buf16=Array,r.Buf32=Array,r.assign(r,c))},r.setTyped(s)},{}],42:[function(o,i,r){var s=o("./common"),a=!0,c=!0;try{String.fromCharCode.apply(null,[0])}catch{a=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{c=!1}for(var l=new s.Buf8(256),A=0;A<256;A++)l[A]=252<=A?6:248<=A?5:240<=A?4:224<=A?3:192<=A?2:1;function u(d,_){if(_<65537&&(d.subarray&&c||!d.subarray&&a))return String.fromCharCode.apply(null,s.shrinkBuf(d,_));for(var h="",m=0;m<_;m++)h+=String.fromCharCode(d[m]);return h}l[254]=l[254]=1,r.string2buf=function(d){var _,h,m,p,g,f=d.length,y=0;for(p=0;p<f;p++)(64512&(h=d.charCodeAt(p)))==55296&&p+1<f&&(64512&(m=d.charCodeAt(p+1)))==56320&&(h=65536+(h-55296<<10)+(m-56320),p++),y+=h<128?1:h<2048?2:h<65536?3:4;for(_=new s.Buf8(y),p=g=0;g<y;p++)(64512&(h=d.charCodeAt(p)))==55296&&p+1<f&&(64512&(m=d.charCodeAt(p+1)))==56320&&(h=65536+(h-55296<<10)+(m-56320),p++),h<128?_[g++]=h:(h<2048?_[g++]=192|h>>>6:(h<65536?_[g++]=224|h>>>12:(_[g++]=240|h>>>18,_[g++]=128|h>>>12&63),_[g++]=128|h>>>6&63),_[g++]=128|63&h);return _},r.buf2binstring=function(d){return u(d,d.length)},r.binstring2buf=function(d){for(var _=new s.Buf8(d.length),h=0,m=_.length;h<m;h++)_[h]=d.charCodeAt(h);return _},r.buf2string=function(d,_){var h,m,p,g,f=_||d.length,y=new Array(2*f);for(h=m=0;h<f;)if((p=d[h++])<128)y[m++]=p;else if(4<(g=l[p]))y[m++]=65533,h+=g-1;else{for(p&=g===2?31:g===3?15:7;1<g&&h<f;)p=p<<6|63&d[h++],g--;1<g?y[m++]=65533:p<65536?y[m++]=p:(p-=65536,y[m++]=55296|p>>10&1023,y[m++]=56320|1023&p)}return u(y,m)},r.utf8border=function(d,_){var h;for((_=_||d.length)>d.length&&(_=d.length),h=_-1;0<=h&&(192&d[h])==128;)h--;return h<0||h===0?_:h+l[d[h]]>_?h:_}},{"./common":41}],43:[function(o,i,r){i.exports=function(s,a,c,l){for(var A=65535&s|0,u=s>>>16&65535|0,d=0;c!==0;){for(c-=d=2e3<c?2e3:c;u=u+(A=A+a[l++]|0)|0,--d;);A%=65521,u%=65521}return A|u<<16|0}},{}],44:[function(o,i,r){i.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(o,i,r){var s=(function(){for(var a,c=[],l=0;l<256;l++){a=l;for(var A=0;A<8;A++)a=1&a?3988292384^a>>>1:a>>>1;c[l]=a}return c})();i.exports=function(a,c,l,A){var u=s,d=A+l;a^=-1;for(var _=A;_<d;_++)a=a>>>8^u[255&(a^c[_])];return-1^a}},{}],46:[function(o,i,r){var s,a=o("../utils/common"),c=o("./trees"),l=o("./adler32"),A=o("./crc32"),u=o("./messages"),d=0,_=4,h=0,m=-2,p=-1,g=4,f=2,y=8,C=9,I=286,E=30,b=19,P=2*I+1,M=15,w=3,k=258,N=k+w+1,O=42,H=113,G=1,K=2,J=3,$=4;function ie(ye,qe){return ye.msg=u[qe],qe}function Ae(ye){return(ye<<1)-(4<ye?9:0)}function ne(ye){for(var qe=ye.length;0<=--qe;)ye[qe]=0}function oe(ye){var qe=ye.state,Oe=qe.pending;Oe>ye.avail_out&&(Oe=ye.avail_out),Oe!==0&&(a.arraySet(ye.output,qe.pending_buf,qe.pending_out,Oe,ye.next_out),ye.next_out+=Oe,qe.pending_out+=Oe,ye.total_out+=Oe,ye.avail_out-=Oe,qe.pending-=Oe,qe.pending===0&&(qe.pending_out=0))}function ce(ye,qe){c._tr_flush_block(ye,0<=ye.block_start?ye.block_start:-1,ye.strstart-ye.block_start,qe),ye.block_start=ye.strstart,oe(ye.strm)}function re(ye,qe){ye.pending_buf[ye.pending++]=qe}function ue(ye,qe){ye.pending_buf[ye.pending++]=qe>>>8&255,ye.pending_buf[ye.pending++]=255&qe}function fe(ye,qe){var Oe,Qe,Ue=ye.max_chain_length,Te=ye.strstart,Ie=ye.prev_length,He=ye.nice_match,Me=ye.strstart>ye.w_size-N?ye.strstart-(ye.w_size-N):0,Ke=ye.window,je=ye.w_mask,st=ye.prev,at=ye.strstart+k,ut=Ke[Te+Ie-1],ct=Ke[Te+Ie];ye.prev_length>=ye.good_match&&(Ue>>=2),He>ye.lookahead&&(He=ye.lookahead);do if(Ke[(Oe=qe)+Ie]===ct&&Ke[Oe+Ie-1]===ut&&Ke[Oe]===Ke[Te]&&Ke[++Oe]===Ke[Te+1]){Te+=2,Oe++;do;while(Ke[++Te]===Ke[++Oe]&&Ke[++Te]===Ke[++Oe]&&Ke[++Te]===Ke[++Oe]&&Ke[++Te]===Ke[++Oe]&&Ke[++Te]===Ke[++Oe]&&Ke[++Te]===Ke[++Oe]&&Ke[++Te]===Ke[++Oe]&&Ke[++Te]===Ke[++Oe]&&Te<at);if(Qe=k-(at-Te),Te=at-k,Ie<Qe){if(ye.match_start=qe,He<=(Ie=Qe))break;ut=Ke[Te+Ie-1],ct=Ke[Te+Ie]}}while((qe=st[qe&je])>Me&&--Ue!=0);return Ie<=ye.lookahead?Ie:ye.lookahead}function be(ye){var qe,Oe,Qe,Ue,Te,Ie,He,Me,Ke,je,st=ye.w_size;do{if(Ue=ye.window_size-ye.lookahead-ye.strstart,ye.strstart>=st+(st-N)){for(a.arraySet(ye.window,ye.window,st,st,0),ye.match_start-=st,ye.strstart-=st,ye.block_start-=st,qe=Oe=ye.hash_size;Qe=ye.head[--qe],ye.head[qe]=st<=Qe?Qe-st:0,--Oe;);for(qe=Oe=st;Qe=ye.prev[--qe],ye.prev[qe]=st<=Qe?Qe-st:0,--Oe;);Ue+=st}if(ye.strm.avail_in===0)break;if(Ie=ye.strm,He=ye.window,Me=ye.strstart+ye.lookahead,Ke=Ue,je=void 0,je=Ie.avail_in,Ke<je&&(je=Ke),Oe=je===0?0:(Ie.avail_in-=je,a.arraySet(He,Ie.input,Ie.next_in,je,Me),Ie.state.wrap===1?Ie.adler=l(Ie.adler,He,je,Me):Ie.state.wrap===2&&(Ie.adler=A(Ie.adler,He,je,Me)),Ie.next_in+=je,Ie.total_in+=je,je),ye.lookahead+=Oe,ye.lookahead+ye.insert>=w)for(Te=ye.strstart-ye.insert,ye.ins_h=ye.window[Te],ye.ins_h=(ye.ins_h<<ye.hash_shift^ye.window[Te+1])&ye.hash_mask;ye.insert&&(ye.ins_h=(ye.ins_h<<ye.hash_shift^ye.window[Te+w-1])&ye.hash_mask,ye.prev[Te&ye.w_mask]=ye.head[ye.ins_h],ye.head[ye.ins_h]=Te,Te++,ye.insert--,!(ye.lookahead+ye.insert<w)););}while(ye.lookahead<N&&ye.strm.avail_in!==0)}function ve(ye,qe){for(var Oe,Qe;;){if(ye.lookahead<N){if(be(ye),ye.lookahead<N&&qe===d)return G;if(ye.lookahead===0)break}if(Oe=0,ye.lookahead>=w&&(ye.ins_h=(ye.ins_h<<ye.hash_shift^ye.window[ye.strstart+w-1])&ye.hash_mask,Oe=ye.prev[ye.strstart&ye.w_mask]=ye.head[ye.ins_h],ye.head[ye.ins_h]=ye.strstart),Oe!==0&&ye.strstart-Oe<=ye.w_size-N&&(ye.match_length=fe(ye,Oe)),ye.match_length>=w)if(Qe=c._tr_tally(ye,ye.strstart-ye.match_start,ye.match_length-w),ye.lookahead-=ye.match_length,ye.match_length<=ye.max_lazy_match&&ye.lookahead>=w){for(ye.match_length--;ye.strstart++,ye.ins_h=(ye.ins_h<<ye.hash_shift^ye.window[ye.strstart+w-1])&ye.hash_mask,Oe=ye.prev[ye.strstart&ye.w_mask]=ye.head[ye.ins_h],ye.head[ye.ins_h]=ye.strstart,--ye.match_length!=0;);ye.strstart++}else ye.strstart+=ye.match_length,ye.match_length=0,ye.ins_h=ye.window[ye.strstart],ye.ins_h=(ye.ins_h<<ye.hash_shift^ye.window[ye.strstart+1])&ye.hash_mask;else Qe=c._tr_tally(ye,0,ye.window[ye.strstart]),ye.lookahead--,ye.strstart++;if(Qe&&(ce(ye,!1),ye.strm.avail_out===0))return G}return ye.insert=ye.strstart<w-1?ye.strstart:w-1,qe===_?(ce(ye,!0),ye.strm.avail_out===0?J:$):ye.last_lit&&(ce(ye,!1),ye.strm.avail_out===0)?G:K}function he(ye,qe){for(var Oe,Qe,Ue;;){if(ye.lookahead<N){if(be(ye),ye.lookahead<N&&qe===d)return G;if(ye.lookahead===0)break}if(Oe=0,ye.lookahead>=w&&(ye.ins_h=(ye.ins_h<<ye.hash_shift^ye.window[ye.strstart+w-1])&ye.hash_mask,Oe=ye.prev[ye.strstart&ye.w_mask]=ye.head[ye.ins_h],ye.head[ye.ins_h]=ye.strstart),ye.prev_length=ye.match_length,ye.prev_match=ye.match_start,ye.match_length=w-1,Oe!==0&&ye.prev_length<ye.max_lazy_match&&ye.strstart-Oe<=ye.w_size-N&&(ye.match_length=fe(ye,Oe),ye.match_length<=5&&(ye.strategy===1||ye.match_length===w&&4096<ye.strstart-ye.match_start)&&(ye.match_length=w-1)),ye.prev_length>=w&&ye.match_length<=ye.prev_length){for(Ue=ye.strstart+ye.lookahead-w,Qe=c._tr_tally(ye,ye.strstart-1-ye.prev_match,ye.prev_length-w),ye.lookahead-=ye.prev_length-1,ye.prev_length-=2;++ye.strstart<=Ue&&(ye.ins_h=(ye.ins_h<<ye.hash_shift^ye.window[ye.strstart+w-1])&ye.hash_mask,Oe=ye.prev[ye.strstart&ye.w_mask]=ye.head[ye.ins_h],ye.head[ye.ins_h]=ye.strstart),--ye.prev_length!=0;);if(ye.match_available=0,ye.match_length=w-1,ye.strstart++,Qe&&(ce(ye,!1),ye.strm.avail_out===0))return G}else if(ye.match_available){if((Qe=c._tr_tally(ye,0,ye.window[ye.strstart-1]))&&ce(ye,!1),ye.strstart++,ye.lookahead--,ye.strm.avail_out===0)return G}else ye.match_available=1,ye.strstart++,ye.lookahead--}return ye.match_available&&(Qe=c._tr_tally(ye,0,ye.window[ye.strstart-1]),ye.match_available=0),ye.insert=ye.strstart<w-1?ye.strstart:w-1,qe===_?(ce(ye,!0),ye.strm.avail_out===0?J:$):ye.last_lit&&(ce(ye,!1),ye.strm.avail_out===0)?G:K}function Pe(ye,qe,Oe,Qe,Ue){this.good_length=ye,this.max_lazy=qe,this.nice_length=Oe,this.max_chain=Qe,this.func=Ue}function pe(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=y,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new a.Buf16(2*P),this.dyn_dtree=new a.Buf16(2*(2*E+1)),this.bl_tree=new a.Buf16(2*(2*b+1)),ne(this.dyn_ltree),ne(this.dyn_dtree),ne(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new a.Buf16(M+1),this.heap=new a.Buf16(2*I+1),ne(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new a.Buf16(2*I+1),ne(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function Fe(ye){var qe;return ye&&ye.state?(ye.total_in=ye.total_out=0,ye.data_type=f,(qe=ye.state).pending=0,qe.pending_out=0,qe.wrap<0&&(qe.wrap=-qe.wrap),qe.status=qe.wrap?O:H,ye.adler=qe.wrap===2?0:1,qe.last_flush=d,c._tr_init(qe),h):ie(ye,m)}function ke(ye){var qe=Fe(ye);return qe===h&&(function(Oe){Oe.window_size=2*Oe.w_size,ne(Oe.head),Oe.max_lazy_match=s[Oe.level].max_lazy,Oe.good_match=s[Oe.level].good_length,Oe.nice_match=s[Oe.level].nice_length,Oe.max_chain_length=s[Oe.level].max_chain,Oe.strstart=0,Oe.block_start=0,Oe.lookahead=0,Oe.insert=0,Oe.match_length=Oe.prev_length=w-1,Oe.match_available=0,Oe.ins_h=0})(ye.state),qe}function We(ye,qe,Oe,Qe,Ue,Te){if(!ye)return m;var Ie=1;if(qe===p&&(qe=6),Qe<0?(Ie=0,Qe=-Qe):15<Qe&&(Ie=2,Qe-=16),Ue<1||C<Ue||Oe!==y||Qe<8||15<Qe||qe<0||9<qe||Te<0||g<Te)return ie(ye,m);Qe===8&&(Qe=9);var He=new pe;return(ye.state=He).strm=ye,He.wrap=Ie,He.gzhead=null,He.w_bits=Qe,He.w_size=1<<He.w_bits,He.w_mask=He.w_size-1,He.hash_bits=Ue+7,He.hash_size=1<<He.hash_bits,He.hash_mask=He.hash_size-1,He.hash_shift=~~((He.hash_bits+w-1)/w),He.window=new a.Buf8(2*He.w_size),He.head=new a.Buf16(He.hash_size),He.prev=new a.Buf16(He.w_size),He.lit_bufsize=1<<Ue+6,He.pending_buf_size=4*He.lit_bufsize,He.pending_buf=new a.Buf8(He.pending_buf_size),He.d_buf=1*He.lit_bufsize,He.l_buf=3*He.lit_bufsize,He.level=qe,He.strategy=Te,He.method=Oe,ke(ye)}s=[new Pe(0,0,0,0,function(ye,qe){var Oe=65535;for(Oe>ye.pending_buf_size-5&&(Oe=ye.pending_buf_size-5);;){if(ye.lookahead<=1){if(be(ye),ye.lookahead===0&&qe===d)return G;if(ye.lookahead===0)break}ye.strstart+=ye.lookahead,ye.lookahead=0;var Qe=ye.block_start+Oe;if((ye.strstart===0||ye.strstart>=Qe)&&(ye.lookahead=ye.strstart-Qe,ye.strstart=Qe,ce(ye,!1),ye.strm.avail_out===0)||ye.strstart-ye.block_start>=ye.w_size-N&&(ce(ye,!1),ye.strm.avail_out===0))return G}return ye.insert=0,qe===_?(ce(ye,!0),ye.strm.avail_out===0?J:$):(ye.strstart>ye.block_start&&(ce(ye,!1),ye.strm.avail_out),G)}),new Pe(4,4,8,4,ve),new Pe(4,5,16,8,ve),new Pe(4,6,32,32,ve),new Pe(4,4,16,16,he),new Pe(8,16,32,32,he),new Pe(8,16,128,128,he),new Pe(8,32,128,256,he),new Pe(32,128,258,1024,he),new Pe(32,258,258,4096,he)],r.deflateInit=function(ye,qe){return We(ye,qe,y,15,8,0)},r.deflateInit2=We,r.deflateReset=ke,r.deflateResetKeep=Fe,r.deflateSetHeader=function(ye,qe){return ye&&ye.state?ye.state.wrap!==2?m:(ye.state.gzhead=qe,h):m},r.deflate=function(ye,qe){var Oe,Qe,Ue,Te;if(!ye||!ye.state||5<qe||qe<0)return ye?ie(ye,m):m;if(Qe=ye.state,!ye.output||!ye.input&&ye.avail_in!==0||Qe.status===666&&qe!==_)return ie(ye,ye.avail_out===0?-5:m);if(Qe.strm=ye,Oe=Qe.last_flush,Qe.last_flush=qe,Qe.status===O)if(Qe.wrap===2)ye.adler=0,re(Qe,31),re(Qe,139),re(Qe,8),Qe.gzhead?(re(Qe,(Qe.gzhead.text?1:0)+(Qe.gzhead.hcrc?2:0)+(Qe.gzhead.extra?4:0)+(Qe.gzhead.name?8:0)+(Qe.gzhead.comment?16:0)),re(Qe,255&Qe.gzhead.time),re(Qe,Qe.gzhead.time>>8&255),re(Qe,Qe.gzhead.time>>16&255),re(Qe,Qe.gzhead.time>>24&255),re(Qe,Qe.level===9?2:2<=Qe.strategy||Qe.level<2?4:0),re(Qe,255&Qe.gzhead.os),Qe.gzhead.extra&&Qe.gzhead.extra.length&&(re(Qe,255&Qe.gzhead.extra.length),re(Qe,Qe.gzhead.extra.length>>8&255)),Qe.gzhead.hcrc&&(ye.adler=A(ye.adler,Qe.pending_buf,Qe.pending,0)),Qe.gzindex=0,Qe.status=69):(re(Qe,0),re(Qe,0),re(Qe,0),re(Qe,0),re(Qe,0),re(Qe,Qe.level===9?2:2<=Qe.strategy||Qe.level<2?4:0),re(Qe,3),Qe.status=H);else{var Ie=y+(Qe.w_bits-8<<4)<<8;Ie|=(2<=Qe.strategy||Qe.level<2?0:Qe.level<6?1:Qe.level===6?2:3)<<6,Qe.strstart!==0&&(Ie|=32),Ie+=31-Ie%31,Qe.status=H,ue(Qe,Ie),Qe.strstart!==0&&(ue(Qe,ye.adler>>>16),ue(Qe,65535&ye.adler)),ye.adler=1}if(Qe.status===69)if(Qe.gzhead.extra){for(Ue=Qe.pending;Qe.gzindex<(65535&Qe.gzhead.extra.length)&&(Qe.pending!==Qe.pending_buf_size||(Qe.gzhead.hcrc&&Qe.pending>Ue&&(ye.adler=A(ye.adler,Qe.pending_buf,Qe.pending-Ue,Ue)),oe(ye),Ue=Qe.pending,Qe.pending!==Qe.pending_buf_size));)re(Qe,255&Qe.gzhead.extra[Qe.gzindex]),Qe.gzindex++;Qe.gzhead.hcrc&&Qe.pending>Ue&&(ye.adler=A(ye.adler,Qe.pending_buf,Qe.pending-Ue,Ue)),Qe.gzindex===Qe.gzhead.extra.length&&(Qe.gzindex=0,Qe.status=73)}else Qe.status=73;if(Qe.status===73)if(Qe.gzhead.name){Ue=Qe.pending;do{if(Qe.pending===Qe.pending_buf_size&&(Qe.gzhead.hcrc&&Qe.pending>Ue&&(ye.adler=A(ye.adler,Qe.pending_buf,Qe.pending-Ue,Ue)),oe(ye),Ue=Qe.pending,Qe.pending===Qe.pending_buf_size)){Te=1;break}Te=Qe.gzindex<Qe.gzhead.name.length?255&Qe.gzhead.name.charCodeAt(Qe.gzindex++):0,re(Qe,Te)}while(Te!==0);Qe.gzhead.hcrc&&Qe.pending>Ue&&(ye.adler=A(ye.adler,Qe.pending_buf,Qe.pending-Ue,Ue)),Te===0&&(Qe.gzindex=0,Qe.status=91)}else Qe.status=91;if(Qe.status===91)if(Qe.gzhead.comment){Ue=Qe.pending;do{if(Qe.pending===Qe.pending_buf_size&&(Qe.gzhead.hcrc&&Qe.pending>Ue&&(ye.adler=A(ye.adler,Qe.pending_buf,Qe.pending-Ue,Ue)),oe(ye),Ue=Qe.pending,Qe.pending===Qe.pending_buf_size)){Te=1;break}Te=Qe.gzindex<Qe.gzhead.comment.length?255&Qe.gzhead.comment.charCodeAt(Qe.gzindex++):0,re(Qe,Te)}while(Te!==0);Qe.gzhead.hcrc&&Qe.pending>Ue&&(ye.adler=A(ye.adler,Qe.pending_buf,Qe.pending-Ue,Ue)),Te===0&&(Qe.status=103)}else Qe.status=103;if(Qe.status===103&&(Qe.gzhead.hcrc?(Qe.pending+2>Qe.pending_buf_size&&oe(ye),Qe.pending+2<=Qe.pending_buf_size&&(re(Qe,255&ye.adler),re(Qe,ye.adler>>8&255),ye.adler=0,Qe.status=H)):Qe.status=H),Qe.pending!==0){if(oe(ye),ye.avail_out===0)return Qe.last_flush=-1,h}else if(ye.avail_in===0&&Ae(qe)<=Ae(Oe)&&qe!==_)return ie(ye,-5);if(Qe.status===666&&ye.avail_in!==0)return ie(ye,-5);if(ye.avail_in!==0||Qe.lookahead!==0||qe!==d&&Qe.status!==666){var He=Qe.strategy===2?(function(Me,Ke){for(var je;;){if(Me.lookahead===0&&(be(Me),Me.lookahead===0)){if(Ke===d)return G;break}if(Me.match_length=0,je=c._tr_tally(Me,0,Me.window[Me.strstart]),Me.lookahead--,Me.strstart++,je&&(ce(Me,!1),Me.strm.avail_out===0))return G}return Me.insert=0,Ke===_?(ce(Me,!0),Me.strm.avail_out===0?J:$):Me.last_lit&&(ce(Me,!1),Me.strm.avail_out===0)?G:K})(Qe,qe):Qe.strategy===3?(function(Me,Ke){for(var je,st,at,ut,ct=Me.window;;){if(Me.lookahead<=k){if(be(Me),Me.lookahead<=k&&Ke===d)return G;if(Me.lookahead===0)break}if(Me.match_length=0,Me.lookahead>=w&&0<Me.strstart&&(st=ct[at=Me.strstart-1])===ct[++at]&&st===ct[++at]&&st===ct[++at]){ut=Me.strstart+k;do;while(st===ct[++at]&&st===ct[++at]&&st===ct[++at]&&st===ct[++at]&&st===ct[++at]&&st===ct[++at]&&st===ct[++at]&&st===ct[++at]&&at<ut);Me.match_length=k-(ut-at),Me.match_length>Me.lookahead&&(Me.match_length=Me.lookahead)}if(Me.match_length>=w?(je=c._tr_tally(Me,1,Me.match_length-w),Me.lookahead-=Me.match_length,Me.strstart+=Me.match_length,Me.match_length=0):(je=c._tr_tally(Me,0,Me.window[Me.strstart]),Me.lookahead--,Me.strstart++),je&&(ce(Me,!1),Me.strm.avail_out===0))return G}return Me.insert=0,Ke===_?(ce(Me,!0),Me.strm.avail_out===0?J:$):Me.last_lit&&(ce(Me,!1),Me.strm.avail_out===0)?G:K})(Qe,qe):s[Qe.level].func(Qe,qe);if(He!==J&&He!==$||(Qe.status=666),He===G||He===J)return ye.avail_out===0&&(Qe.last_flush=-1),h;if(He===K&&(qe===1?c._tr_align(Qe):qe!==5&&(c._tr_stored_block(Qe,0,0,!1),qe===3&&(ne(Qe.head),Qe.lookahead===0&&(Qe.strstart=0,Qe.block_start=0,Qe.insert=0))),oe(ye),ye.avail_out===0))return Qe.last_flush=-1,h}return qe!==_?h:Qe.wrap<=0?1:(Qe.wrap===2?(re(Qe,255&ye.adler),re(Qe,ye.adler>>8&255),re(Qe,ye.adler>>16&255),re(Qe,ye.adler>>24&255),re(Qe,255&ye.total_in),re(Qe,ye.total_in>>8&255),re(Qe,ye.total_in>>16&255),re(Qe,ye.total_in>>24&255)):(ue(Qe,ye.adler>>>16),ue(Qe,65535&ye.adler)),oe(ye),0<Qe.wrap&&(Qe.wrap=-Qe.wrap),Qe.pending!==0?h:1)},r.deflateEnd=function(ye){var qe;return ye&&ye.state?(qe=ye.state.status)!==O&&qe!==69&&qe!==73&&qe!==91&&qe!==103&&qe!==H&&qe!==666?ie(ye,m):(ye.state=null,qe===H?ie(ye,-3):h):m},r.deflateSetDictionary=function(ye,qe){var Oe,Qe,Ue,Te,Ie,He,Me,Ke,je=qe.length;if(!ye||!ye.state||(Te=(Oe=ye.state).wrap)===2||Te===1&&Oe.status!==O||Oe.lookahead)return m;for(Te===1&&(ye.adler=l(ye.adler,qe,je,0)),Oe.wrap=0,je>=Oe.w_size&&(Te===0&&(ne(Oe.head),Oe.strstart=0,Oe.block_start=0,Oe.insert=0),Ke=new a.Buf8(Oe.w_size),a.arraySet(Ke,qe,je-Oe.w_size,Oe.w_size,0),qe=Ke,je=Oe.w_size),Ie=ye.avail_in,He=ye.next_in,Me=ye.input,ye.avail_in=je,ye.next_in=0,ye.input=qe,be(Oe);Oe.lookahead>=w;){for(Qe=Oe.strstart,Ue=Oe.lookahead-(w-1);Oe.ins_h=(Oe.ins_h<<Oe.hash_shift^Oe.window[Qe+w-1])&Oe.hash_mask,Oe.prev[Qe&Oe.w_mask]=Oe.head[Oe.ins_h],Oe.head[Oe.ins_h]=Qe,Qe++,--Ue;);Oe.strstart=Qe,Oe.lookahead=w-1,be(Oe)}return Oe.strstart+=Oe.lookahead,Oe.block_start=Oe.strstart,Oe.insert=Oe.lookahead,Oe.lookahead=0,Oe.match_length=Oe.prev_length=w-1,Oe.match_available=0,ye.next_in=He,ye.input=Me,ye.avail_in=Ie,Oe.wrap=Te,h},r.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(o,i,r){i.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(o,i,r){i.exports=function(s,a){var c,l,A,u,d,_,h,m,p,g,f,y,C,I,E,b,P,M,w,k,N,O,H,G,K;c=s.state,l=s.next_in,G=s.input,A=l+(s.avail_in-5),u=s.next_out,K=s.output,d=u-(a-s.avail_out),_=u+(s.avail_out-257),h=c.dmax,m=c.wsize,p=c.whave,g=c.wnext,f=c.window,y=c.hold,C=c.bits,I=c.lencode,E=c.distcode,b=(1<<c.lenbits)-1,P=(1<<c.distbits)-1;e:do{C<15&&(y+=G[l++]<<C,C+=8,y+=G[l++]<<C,C+=8),M=I[y&b];t:for(;;){if(y>>>=w=M>>>24,C-=w,(w=M>>>16&255)===0)K[u++]=65535&M;else{if(!(16&w)){if((64&w)==0){M=I[(65535&M)+(y&(1<<w)-1)];continue t}if(32&w){c.mode=12;break e}s.msg="invalid literal/length code",c.mode=30;break e}k=65535&M,(w&=15)&&(C<w&&(y+=G[l++]<<C,C+=8),k+=y&(1<<w)-1,y>>>=w,C-=w),C<15&&(y+=G[l++]<<C,C+=8,y+=G[l++]<<C,C+=8),M=E[y&P];n:for(;;){if(y>>>=w=M>>>24,C-=w,!(16&(w=M>>>16&255))){if((64&w)==0){M=E[(65535&M)+(y&(1<<w)-1)];continue n}s.msg="invalid distance code",c.mode=30;break e}if(N=65535&M,C<(w&=15)&&(y+=G[l++]<<C,(C+=8)<w&&(y+=G[l++]<<C,C+=8)),h<(N+=y&(1<<w)-1)){s.msg="invalid distance too far back",c.mode=30;break e}if(y>>>=w,C-=w,(w=u-d)<N){if(p<(w=N-w)&&c.sane){s.msg="invalid distance too far back",c.mode=30;break e}if(H=f,(O=0)===g){if(O+=m-w,w<k){for(k-=w;K[u++]=f[O++],--w;);O=u-N,H=K}}else if(g<w){if(O+=m+g-w,(w-=g)<k){for(k-=w;K[u++]=f[O++],--w;);if(O=0,g<k){for(k-=w=g;K[u++]=f[O++],--w;);O=u-N,H=K}}}else if(O+=g-w,w<k){for(k-=w;K[u++]=f[O++],--w;);O=u-N,H=K}for(;2<k;)K[u++]=H[O++],K[u++]=H[O++],K[u++]=H[O++],k-=3;k&&(K[u++]=H[O++],1<k&&(K[u++]=H[O++]))}else{for(O=u-N;K[u++]=K[O++],K[u++]=K[O++],K[u++]=K[O++],2<(k-=3););k&&(K[u++]=K[O++],1<k&&(K[u++]=K[O++]))}break}}break}}while(l<A&&u<_);l-=k=C>>3,y&=(1<<(C-=k<<3))-1,s.next_in=l,s.next_out=u,s.avail_in=l<A?A-l+5:5-(l-A),s.avail_out=u<_?_-u+257:257-(u-_),c.hold=y,c.bits=C}},{}],49:[function(o,i,r){var s=o("../utils/common"),a=o("./adler32"),c=o("./crc32"),l=o("./inffast"),A=o("./inftrees"),u=1,d=2,_=0,h=-2,m=1,p=852,g=592;function f(O){return(O>>>24&255)+(O>>>8&65280)+((65280&O)<<8)+((255&O)<<24)}function y(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new s.Buf16(320),this.work=new s.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function C(O){var H;return O&&O.state?(H=O.state,O.total_in=O.total_out=H.total=0,O.msg="",H.wrap&&(O.adler=1&H.wrap),H.mode=m,H.last=0,H.havedict=0,H.dmax=32768,H.head=null,H.hold=0,H.bits=0,H.lencode=H.lendyn=new s.Buf32(p),H.distcode=H.distdyn=new s.Buf32(g),H.sane=1,H.back=-1,_):h}function I(O){var H;return O&&O.state?((H=O.state).wsize=0,H.whave=0,H.wnext=0,C(O)):h}function E(O,H){var G,K;return O&&O.state?(K=O.state,H<0?(G=0,H=-H):(G=1+(H>>4),H<48&&(H&=15)),H&&(H<8||15<H)?h:(K.window!==null&&K.wbits!==H&&(K.window=null),K.wrap=G,K.wbits=H,I(O))):h}function b(O,H){var G,K;return O?(K=new y,(O.state=K).window=null,(G=E(O,H))!==_&&(O.state=null),G):h}var P,M,w=!0;function k(O){if(w){var H;for(P=new s.Buf32(512),M=new s.Buf32(32),H=0;H<144;)O.lens[H++]=8;for(;H<256;)O.lens[H++]=9;for(;H<280;)O.lens[H++]=7;for(;H<288;)O.lens[H++]=8;for(A(u,O.lens,0,288,P,0,O.work,{bits:9}),H=0;H<32;)O.lens[H++]=5;A(d,O.lens,0,32,M,0,O.work,{bits:5}),w=!1}O.lencode=P,O.lenbits=9,O.distcode=M,O.distbits=5}function N(O,H,G,K){var J,$=O.state;return $.window===null&&($.wsize=1<<$.wbits,$.wnext=0,$.whave=0,$.window=new s.Buf8($.wsize)),K>=$.wsize?(s.arraySet($.window,H,G-$.wsize,$.wsize,0),$.wnext=0,$.whave=$.wsize):(K<(J=$.wsize-$.wnext)&&(J=K),s.arraySet($.window,H,G-K,J,$.wnext),(K-=J)?(s.arraySet($.window,H,G-K,K,0),$.wnext=K,$.whave=$.wsize):($.wnext+=J,$.wnext===$.wsize&&($.wnext=0),$.whave<$.wsize&&($.whave+=J))),0}r.inflateReset=I,r.inflateReset2=E,r.inflateResetKeep=C,r.inflateInit=function(O){return b(O,15)},r.inflateInit2=b,r.inflate=function(O,H){var G,K,J,$,ie,Ae,ne,oe,ce,re,ue,fe,be,ve,he,Pe,pe,Fe,ke,We,ye,qe,Oe,Qe,Ue=0,Te=new s.Buf8(4),Ie=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!O||!O.state||!O.output||!O.input&&O.avail_in!==0)return h;(G=O.state).mode===12&&(G.mode=13),ie=O.next_out,J=O.output,ne=O.avail_out,$=O.next_in,K=O.input,Ae=O.avail_in,oe=G.hold,ce=G.bits,re=Ae,ue=ne,qe=_;e:for(;;)switch(G.mode){case m:if(G.wrap===0){G.mode=13;break}for(;ce<16;){if(Ae===0)break e;Ae--,oe+=K[$++]<<ce,ce+=8}if(2&G.wrap&&oe===35615){Te[G.check=0]=255&oe,Te[1]=oe>>>8&255,G.check=c(G.check,Te,2,0),ce=oe=0,G.mode=2;break}if(G.flags=0,G.head&&(G.head.done=!1),!(1&G.wrap)||(((255&oe)<<8)+(oe>>8))%31){O.msg="incorrect header check",G.mode=30;break}if((15&oe)!=8){O.msg="unknown compression method",G.mode=30;break}if(ce-=4,ye=8+(15&(oe>>>=4)),G.wbits===0)G.wbits=ye;else if(ye>G.wbits){O.msg="invalid window size",G.mode=30;break}G.dmax=1<<ye,O.adler=G.check=1,G.mode=512&oe?10:12,ce=oe=0;break;case 2:for(;ce<16;){if(Ae===0)break e;Ae--,oe+=K[$++]<<ce,ce+=8}if(G.flags=oe,(255&G.flags)!=8){O.msg="unknown compression method",G.mode=30;break}if(57344&G.flags){O.msg="unknown header flags set",G.mode=30;break}G.head&&(G.head.text=oe>>8&1),512&G.flags&&(Te[0]=255&oe,Te[1]=oe>>>8&255,G.check=c(G.check,Te,2,0)),ce=oe=0,G.mode=3;case 3:for(;ce<32;){if(Ae===0)break e;Ae--,oe+=K[$++]<<ce,ce+=8}G.head&&(G.head.time=oe),512&G.flags&&(Te[0]=255&oe,Te[1]=oe>>>8&255,Te[2]=oe>>>16&255,Te[3]=oe>>>24&255,G.check=c(G.check,Te,4,0)),ce=oe=0,G.mode=4;case 4:for(;ce<16;){if(Ae===0)break e;Ae--,oe+=K[$++]<<ce,ce+=8}G.head&&(G.head.xflags=255&oe,G.head.os=oe>>8),512&G.flags&&(Te[0]=255&oe,Te[1]=oe>>>8&255,G.check=c(G.check,Te,2,0)),ce=oe=0,G.mode=5;case 5:if(1024&G.flags){for(;ce<16;){if(Ae===0)break e;Ae--,oe+=K[$++]<<ce,ce+=8}G.length=oe,G.head&&(G.head.extra_len=oe),512&G.flags&&(Te[0]=255&oe,Te[1]=oe>>>8&255,G.check=c(G.check,Te,2,0)),ce=oe=0}else G.head&&(G.head.extra=null);G.mode=6;case 6:if(1024&G.flags&&(Ae<(fe=G.length)&&(fe=Ae),fe&&(G.head&&(ye=G.head.extra_len-G.length,G.head.extra||(G.head.extra=new Array(G.head.extra_len)),s.arraySet(G.head.extra,K,$,fe,ye)),512&G.flags&&(G.check=c(G.check,K,fe,$)),Ae-=fe,$+=fe,G.length-=fe),G.length))break e;G.length=0,G.mode=7;case 7:if(2048&G.flags){if(Ae===0)break e;for(fe=0;ye=K[$+fe++],G.head&&ye&&G.length<65536&&(G.head.name+=String.fromCharCode(ye)),ye&&fe<Ae;);if(512&G.flags&&(G.check=c(G.check,K,fe,$)),Ae-=fe,$+=fe,ye)break e}else G.head&&(G.head.name=null);G.length=0,G.mode=8;case 8:if(4096&G.flags){if(Ae===0)break e;for(fe=0;ye=K[$+fe++],G.head&&ye&&G.length<65536&&(G.head.comment+=String.fromCharCode(ye)),ye&&fe<Ae;);if(512&G.flags&&(G.check=c(G.check,K,fe,$)),Ae-=fe,$+=fe,ye)break e}else G.head&&(G.head.comment=null);G.mode=9;case 9:if(512&G.flags){for(;ce<16;){if(Ae===0)break e;Ae--,oe+=K[$++]<<ce,ce+=8}if(oe!==(65535&G.check)){O.msg="header crc mismatch",G.mode=30;break}ce=oe=0}G.head&&(G.head.hcrc=G.flags>>9&1,G.head.done=!0),O.adler=G.check=0,G.mode=12;break;case 10:for(;ce<32;){if(Ae===0)break e;Ae--,oe+=K[$++]<<ce,ce+=8}O.adler=G.check=f(oe),ce=oe=0,G.mode=11;case 11:if(G.havedict===0)return O.next_out=ie,O.avail_out=ne,O.next_in=$,O.avail_in=Ae,G.hold=oe,G.bits=ce,2;O.adler=G.check=1,G.mode=12;case 12:if(H===5||H===6)break e;case 13:if(G.last){oe>>>=7&ce,ce-=7&ce,G.mode=27;break}for(;ce<3;){if(Ae===0)break e;Ae--,oe+=K[$++]<<ce,ce+=8}switch(G.last=1&oe,ce-=1,3&(oe>>>=1)){case 0:G.mode=14;break;case 1:if(k(G),G.mode=20,H!==6)break;oe>>>=2,ce-=2;break e;case 2:G.mode=17;break;case 3:O.msg="invalid block type",G.mode=30}oe>>>=2,ce-=2;break;case 14:for(oe>>>=7&ce,ce-=7&ce;ce<32;){if(Ae===0)break e;Ae--,oe+=K[$++]<<ce,ce+=8}if((65535&oe)!=(oe>>>16^65535)){O.msg="invalid stored block lengths",G.mode=30;break}if(G.length=65535&oe,ce=oe=0,G.mode=15,H===6)break e;case 15:G.mode=16;case 16:if(fe=G.length){if(Ae<fe&&(fe=Ae),ne<fe&&(fe=ne),fe===0)break e;s.arraySet(J,K,$,fe,ie),Ae-=fe,$+=fe,ne-=fe,ie+=fe,G.length-=fe;break}G.mode=12;break;case 17:for(;ce<14;){if(Ae===0)break e;Ae--,oe+=K[$++]<<ce,ce+=8}if(G.nlen=257+(31&oe),oe>>>=5,ce-=5,G.ndist=1+(31&oe),oe>>>=5,ce-=5,G.ncode=4+(15&oe),oe>>>=4,ce-=4,286<G.nlen||30<G.ndist){O.msg="too many length or distance symbols",G.mode=30;break}G.have=0,G.mode=18;case 18:for(;G.have<G.ncode;){for(;ce<3;){if(Ae===0)break e;Ae--,oe+=K[$++]<<ce,ce+=8}G.lens[Ie[G.have++]]=7&oe,oe>>>=3,ce-=3}for(;G.have<19;)G.lens[Ie[G.have++]]=0;if(G.lencode=G.lendyn,G.lenbits=7,Oe={bits:G.lenbits},qe=A(0,G.lens,0,19,G.lencode,0,G.work,Oe),G.lenbits=Oe.bits,qe){O.msg="invalid code lengths set",G.mode=30;break}G.have=0,G.mode=19;case 19:for(;G.have<G.nlen+G.ndist;){for(;Pe=(Ue=G.lencode[oe&(1<<G.lenbits)-1])>>>16&255,pe=65535&Ue,!((he=Ue>>>24)<=ce);){if(Ae===0)break e;Ae--,oe+=K[$++]<<ce,ce+=8}if(pe<16)oe>>>=he,ce-=he,G.lens[G.have++]=pe;else{if(pe===16){for(Qe=he+2;ce<Qe;){if(Ae===0)break e;Ae--,oe+=K[$++]<<ce,ce+=8}if(oe>>>=he,ce-=he,G.have===0){O.msg="invalid bit length repeat",G.mode=30;break}ye=G.lens[G.have-1],fe=3+(3&oe),oe>>>=2,ce-=2}else if(pe===17){for(Qe=he+3;ce<Qe;){if(Ae===0)break e;Ae--,oe+=K[$++]<<ce,ce+=8}ce-=he,ye=0,fe=3+(7&(oe>>>=he)),oe>>>=3,ce-=3}else{for(Qe=he+7;ce<Qe;){if(Ae===0)break e;Ae--,oe+=K[$++]<<ce,ce+=8}ce-=he,ye=0,fe=11+(127&(oe>>>=he)),oe>>>=7,ce-=7}if(G.have+fe>G.nlen+G.ndist){O.msg="invalid bit length repeat",G.mode=30;break}for(;fe--;)G.lens[G.have++]=ye}}if(G.mode===30)break;if(G.lens[256]===0){O.msg="invalid code -- missing end-of-block",G.mode=30;break}if(G.lenbits=9,Oe={bits:G.lenbits},qe=A(u,G.lens,0,G.nlen,G.lencode,0,G.work,Oe),G.lenbits=Oe.bits,qe){O.msg="invalid literal/lengths set",G.mode=30;break}if(G.distbits=6,G.distcode=G.distdyn,Oe={bits:G.distbits},qe=A(d,G.lens,G.nlen,G.ndist,G.distcode,0,G.work,Oe),G.distbits=Oe.bits,qe){O.msg="invalid distances set",G.mode=30;break}if(G.mode=20,H===6)break e;case 20:G.mode=21;case 21:if(6<=Ae&&258<=ne){O.next_out=ie,O.avail_out=ne,O.next_in=$,O.avail_in=Ae,G.hold=oe,G.bits=ce,l(O,ue),ie=O.next_out,J=O.output,ne=O.avail_out,$=O.next_in,K=O.input,Ae=O.avail_in,oe=G.hold,ce=G.bits,G.mode===12&&(G.back=-1);break}for(G.back=0;Pe=(Ue=G.lencode[oe&(1<<G.lenbits)-1])>>>16&255,pe=65535&Ue,!((he=Ue>>>24)<=ce);){if(Ae===0)break e;Ae--,oe+=K[$++]<<ce,ce+=8}if(Pe&&(240&Pe)==0){for(Fe=he,ke=Pe,We=pe;Pe=(Ue=G.lencode[We+((oe&(1<<Fe+ke)-1)>>Fe)])>>>16&255,pe=65535&Ue,!(Fe+(he=Ue>>>24)<=ce);){if(Ae===0)break e;Ae--,oe+=K[$++]<<ce,ce+=8}oe>>>=Fe,ce-=Fe,G.back+=Fe}if(oe>>>=he,ce-=he,G.back+=he,G.length=pe,Pe===0){G.mode=26;break}if(32&Pe){G.back=-1,G.mode=12;break}if(64&Pe){O.msg="invalid literal/length code",G.mode=30;break}G.extra=15&Pe,G.mode=22;case 22:if(G.extra){for(Qe=G.extra;ce<Qe;){if(Ae===0)break e;Ae--,oe+=K[$++]<<ce,ce+=8}G.length+=oe&(1<<G.extra)-1,oe>>>=G.extra,ce-=G.extra,G.back+=G.extra}G.was=G.length,G.mode=23;case 23:for(;Pe=(Ue=G.distcode[oe&(1<<G.distbits)-1])>>>16&255,pe=65535&Ue,!((he=Ue>>>24)<=ce);){if(Ae===0)break e;Ae--,oe+=K[$++]<<ce,ce+=8}if((240&Pe)==0){for(Fe=he,ke=Pe,We=pe;Pe=(Ue=G.distcode[We+((oe&(1<<Fe+ke)-1)>>Fe)])>>>16&255,pe=65535&Ue,!(Fe+(he=Ue>>>24)<=ce);){if(Ae===0)break e;Ae--,oe+=K[$++]<<ce,ce+=8}oe>>>=Fe,ce-=Fe,G.back+=Fe}if(oe>>>=he,ce-=he,G.back+=he,64&Pe){O.msg="invalid distance code",G.mode=30;break}G.offset=pe,G.extra=15&Pe,G.mode=24;case 24:if(G.extra){for(Qe=G.extra;ce<Qe;){if(Ae===0)break e;Ae--,oe+=K[$++]<<ce,ce+=8}G.offset+=oe&(1<<G.extra)-1,oe>>>=G.extra,ce-=G.extra,G.back+=G.extra}if(G.offset>G.dmax){O.msg="invalid distance too far back",G.mode=30;break}G.mode=25;case 25:if(ne===0)break e;if(fe=ue-ne,G.offset>fe){if((fe=G.offset-fe)>G.whave&&G.sane){O.msg="invalid distance too far back",G.mode=30;break}be=fe>G.wnext?(fe-=G.wnext,G.wsize-fe):G.wnext-fe,fe>G.length&&(fe=G.length),ve=G.window}else ve=J,be=ie-G.offset,fe=G.length;for(ne<fe&&(fe=ne),ne-=fe,G.length-=fe;J[ie++]=ve[be++],--fe;);G.length===0&&(G.mode=21);break;case 26:if(ne===0)break e;J[ie++]=G.length,ne--,G.mode=21;break;case 27:if(G.wrap){for(;ce<32;){if(Ae===0)break e;Ae--,oe|=K[$++]<<ce,ce+=8}if(ue-=ne,O.total_out+=ue,G.total+=ue,ue&&(O.adler=G.check=G.flags?c(G.check,J,ue,ie-ue):a(G.check,J,ue,ie-ue)),ue=ne,(G.flags?oe:f(oe))!==G.check){O.msg="incorrect data check",G.mode=30;break}ce=oe=0}G.mode=28;case 28:if(G.wrap&&G.flags){for(;ce<32;){if(Ae===0)break e;Ae--,oe+=K[$++]<<ce,ce+=8}if(oe!==(4294967295&G.total)){O.msg="incorrect length check",G.mode=30;break}ce=oe=0}G.mode=29;case 29:qe=1;break e;case 30:qe=-3;break e;case 31:return-4;default:return h}return O.next_out=ie,O.avail_out=ne,O.next_in=$,O.avail_in=Ae,G.hold=oe,G.bits=ce,(G.wsize||ue!==O.avail_out&&G.mode<30&&(G.mode<27||H!==4))&&N(O,O.output,O.next_out,ue-O.avail_out)?(G.mode=31,-4):(re-=O.avail_in,ue-=O.avail_out,O.total_in+=re,O.total_out+=ue,G.total+=ue,G.wrap&&ue&&(O.adler=G.check=G.flags?c(G.check,J,ue,O.next_out-ue):a(G.check,J,ue,O.next_out-ue)),O.data_type=G.bits+(G.last?64:0)+(G.mode===12?128:0)+(G.mode===20||G.mode===15?256:0),(re==0&&ue===0||H===4)&&qe===_&&(qe=-5),qe)},r.inflateEnd=function(O){if(!O||!O.state)return h;var H=O.state;return H.window&&(H.window=null),O.state=null,_},r.inflateGetHeader=function(O,H){var G;return O&&O.state?(2&(G=O.state).wrap)==0?h:((G.head=H).done=!1,_):h},r.inflateSetDictionary=function(O,H){var G,K=H.length;return O&&O.state?(G=O.state).wrap!==0&&G.mode!==11?h:G.mode===11&&a(1,H,K,0)!==G.check?-3:N(O,H,K,K)?(G.mode=31,-4):(G.havedict=1,_):h},r.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(o,i,r){var s=o("../utils/common"),a=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],c=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],l=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],A=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];i.exports=function(u,d,_,h,m,p,g,f){var y,C,I,E,b,P,M,w,k,N=f.bits,O=0,H=0,G=0,K=0,J=0,$=0,ie=0,Ae=0,ne=0,oe=0,ce=null,re=0,ue=new s.Buf16(16),fe=new s.Buf16(16),be=null,ve=0;for(O=0;O<=15;O++)ue[O]=0;for(H=0;H<h;H++)ue[d[_+H]]++;for(J=N,K=15;1<=K&&ue[K]===0;K--);if(K<J&&(J=K),K===0)return m[p++]=20971520,m[p++]=20971520,f.bits=1,0;for(G=1;G<K&&ue[G]===0;G++);for(J<G&&(J=G),O=Ae=1;O<=15;O++)if(Ae<<=1,(Ae-=ue[O])<0)return-1;if(0<Ae&&(u===0||K!==1))return-1;for(fe[1]=0,O=1;O<15;O++)fe[O+1]=fe[O]+ue[O];for(H=0;H<h;H++)d[_+H]!==0&&(g[fe[d[_+H]]++]=H);if(P=u===0?(ce=be=g,19):u===1?(ce=a,re-=257,be=c,ve-=257,256):(ce=l,be=A,-1),O=G,b=p,ie=H=oe=0,I=-1,E=(ne=1<<($=J))-1,u===1&&852<ne||u===2&&592<ne)return 1;for(;;){for(M=O-ie,k=g[H]<P?(w=0,g[H]):g[H]>P?(w=be[ve+g[H]],ce[re+g[H]]):(w=96,0),y=1<<O-ie,G=C=1<<$;m[b+(oe>>ie)+(C-=y)]=M<<24|w<<16|k|0,C!==0;);for(y=1<<O-1;oe&y;)y>>=1;if(y!==0?(oe&=y-1,oe+=y):oe=0,H++,--ue[O]==0){if(O===K)break;O=d[_+g[H]]}if(J<O&&(oe&E)!==I){for(ie===0&&(ie=J),b+=G,Ae=1<<($=O-ie);$+ie<K&&!((Ae-=ue[$+ie])<=0);)$++,Ae<<=1;if(ne+=1<<$,u===1&&852<ne||u===2&&592<ne)return 1;m[I=oe&E]=J<<24|$<<16|b-p|0}}return oe!==0&&(m[b+oe]=O-ie<<24|64<<16|0),f.bits=J,0}},{"../utils/common":41}],51:[function(o,i,r){i.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(o,i,r){var s=o("../utils/common"),a=0,c=1;function l(Ue){for(var Te=Ue.length;0<=--Te;)Ue[Te]=0}var A=0,u=29,d=256,_=d+1+u,h=30,m=19,p=2*_+1,g=15,f=16,y=7,C=256,I=16,E=17,b=18,P=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],M=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],w=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],k=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],N=new Array(2*(_+2));l(N);var O=new Array(2*h);l(O);var H=new Array(512);l(H);var G=new Array(256);l(G);var K=new Array(u);l(K);var J,$,ie,Ae=new Array(h);function ne(Ue,Te,Ie,He,Me){this.static_tree=Ue,this.extra_bits=Te,this.extra_base=Ie,this.elems=He,this.max_length=Me,this.has_stree=Ue&&Ue.length}function oe(Ue,Te){this.dyn_tree=Ue,this.max_code=0,this.stat_desc=Te}function ce(Ue){return Ue<256?H[Ue]:H[256+(Ue>>>7)]}function re(Ue,Te){Ue.pending_buf[Ue.pending++]=255&Te,Ue.pending_buf[Ue.pending++]=Te>>>8&255}function ue(Ue,Te,Ie){Ue.bi_valid>f-Ie?(Ue.bi_buf|=Te<<Ue.bi_valid&65535,re(Ue,Ue.bi_buf),Ue.bi_buf=Te>>f-Ue.bi_valid,Ue.bi_valid+=Ie-f):(Ue.bi_buf|=Te<<Ue.bi_valid&65535,Ue.bi_valid+=Ie)}function fe(Ue,Te,Ie){ue(Ue,Ie[2*Te],Ie[2*Te+1])}function be(Ue,Te){for(var Ie=0;Ie|=1&Ue,Ue>>>=1,Ie<<=1,0<--Te;);return Ie>>>1}function ve(Ue,Te,Ie){var He,Me,Ke=new Array(g+1),je=0;for(He=1;He<=g;He++)Ke[He]=je=je+Ie[He-1]<<1;for(Me=0;Me<=Te;Me++){var st=Ue[2*Me+1];st!==0&&(Ue[2*Me]=be(Ke[st]++,st))}}function he(Ue){var Te;for(Te=0;Te<_;Te++)Ue.dyn_ltree[2*Te]=0;for(Te=0;Te<h;Te++)Ue.dyn_dtree[2*Te]=0;for(Te=0;Te<m;Te++)Ue.bl_tree[2*Te]=0;Ue.dyn_ltree[2*C]=1,Ue.opt_len=Ue.static_len=0,Ue.last_lit=Ue.matches=0}function Pe(Ue){8<Ue.bi_valid?re(Ue,Ue.bi_buf):0<Ue.bi_valid&&(Ue.pending_buf[Ue.pending++]=Ue.bi_buf),Ue.bi_buf=0,Ue.bi_valid=0}function pe(Ue,Te,Ie,He){var Me=2*Te,Ke=2*Ie;return Ue[Me]<Ue[Ke]||Ue[Me]===Ue[Ke]&&He[Te]<=He[Ie]}function Fe(Ue,Te,Ie){for(var He=Ue.heap[Ie],Me=Ie<<1;Me<=Ue.heap_len&&(Me<Ue.heap_len&&pe(Te,Ue.heap[Me+1],Ue.heap[Me],Ue.depth)&&Me++,!pe(Te,He,Ue.heap[Me],Ue.depth));)Ue.heap[Ie]=Ue.heap[Me],Ie=Me,Me<<=1;Ue.heap[Ie]=He}function ke(Ue,Te,Ie){var He,Me,Ke,je,st=0;if(Ue.last_lit!==0)for(;He=Ue.pending_buf[Ue.d_buf+2*st]<<8|Ue.pending_buf[Ue.d_buf+2*st+1],Me=Ue.pending_buf[Ue.l_buf+st],st++,He===0?fe(Ue,Me,Te):(fe(Ue,(Ke=G[Me])+d+1,Te),(je=P[Ke])!==0&&ue(Ue,Me-=K[Ke],je),fe(Ue,Ke=ce(--He),Ie),(je=M[Ke])!==0&&ue(Ue,He-=Ae[Ke],je)),st<Ue.last_lit;);fe(Ue,C,Te)}function We(Ue,Te){var Ie,He,Me,Ke=Te.dyn_tree,je=Te.stat_desc.static_tree,st=Te.stat_desc.has_stree,at=Te.stat_desc.elems,ut=-1;for(Ue.heap_len=0,Ue.heap_max=p,Ie=0;Ie<at;Ie++)Ke[2*Ie]!==0?(Ue.heap[++Ue.heap_len]=ut=Ie,Ue.depth[Ie]=0):Ke[2*Ie+1]=0;for(;Ue.heap_len<2;)Ke[2*(Me=Ue.heap[++Ue.heap_len]=ut<2?++ut:0)]=1,Ue.depth[Me]=0,Ue.opt_len--,st&&(Ue.static_len-=je[2*Me+1]);for(Te.max_code=ut,Ie=Ue.heap_len>>1;1<=Ie;Ie--)Fe(Ue,Ke,Ie);for(Me=at;Ie=Ue.heap[1],Ue.heap[1]=Ue.heap[Ue.heap_len--],Fe(Ue,Ke,1),He=Ue.heap[1],Ue.heap[--Ue.heap_max]=Ie,Ue.heap[--Ue.heap_max]=He,Ke[2*Me]=Ke[2*Ie]+Ke[2*He],Ue.depth[Me]=(Ue.depth[Ie]>=Ue.depth[He]?Ue.depth[Ie]:Ue.depth[He])+1,Ke[2*Ie+1]=Ke[2*He+1]=Me,Ue.heap[1]=Me++,Fe(Ue,Ke,1),2<=Ue.heap_len;);Ue.heap[--Ue.heap_max]=Ue.heap[1],(function(ct,yt){var vt,pt,Qt,Lt,un,An,Bn=yt.dyn_tree,xe=yt.max_code,ot=yt.stat_desc.static_tree,it=yt.stat_desc.has_stree,xt=yt.stat_desc.extra_bits,kt=yt.stat_desc.extra_base,Gt=yt.stat_desc.max_length,cn=0;for(Lt=0;Lt<=g;Lt++)ct.bl_count[Lt]=0;for(Bn[2*ct.heap[ct.heap_max]+1]=0,vt=ct.heap_max+1;vt<p;vt++)Gt<(Lt=Bn[2*Bn[2*(pt=ct.heap[vt])+1]+1]+1)&&(Lt=Gt,cn++),Bn[2*pt+1]=Lt,xe<pt||(ct.bl_count[Lt]++,un=0,kt<=pt&&(un=xt[pt-kt]),An=Bn[2*pt],ct.opt_len+=An*(Lt+un),it&&(ct.static_len+=An*(ot[2*pt+1]+un)));if(cn!==0){do{for(Lt=Gt-1;ct.bl_count[Lt]===0;)Lt--;ct.bl_count[Lt]--,ct.bl_count[Lt+1]+=2,ct.bl_count[Gt]--,cn-=2}while(0<cn);for(Lt=Gt;Lt!==0;Lt--)for(pt=ct.bl_count[Lt];pt!==0;)xe<(Qt=ct.heap[--vt])||(Bn[2*Qt+1]!==Lt&&(ct.opt_len+=(Lt-Bn[2*Qt+1])*Bn[2*Qt],Bn[2*Qt+1]=Lt),pt--)}})(Ue,Te),ve(Ke,ut,Ue.bl_count)}function ye(Ue,Te,Ie){var He,Me,Ke=-1,je=Te[1],st=0,at=7,ut=4;for(je===0&&(at=138,ut=3),Te[2*(Ie+1)+1]=65535,He=0;He<=Ie;He++)Me=je,je=Te[2*(He+1)+1],++st<at&&Me===je||(st<ut?Ue.bl_tree[2*Me]+=st:Me!==0?(Me!==Ke&&Ue.bl_tree[2*Me]++,Ue.bl_tree[2*I]++):st<=10?Ue.bl_tree[2*E]++:Ue.bl_tree[2*b]++,Ke=Me,ut=(st=0)===je?(at=138,3):Me===je?(at=6,3):(at=7,4))}function qe(Ue,Te,Ie){var He,Me,Ke=-1,je=Te[1],st=0,at=7,ut=4;for(je===0&&(at=138,ut=3),He=0;He<=Ie;He++)if(Me=je,je=Te[2*(He+1)+1],!(++st<at&&Me===je)){if(st<ut)for(;fe(Ue,Me,Ue.bl_tree),--st!=0;);else Me!==0?(Me!==Ke&&(fe(Ue,Me,Ue.bl_tree),st--),fe(Ue,I,Ue.bl_tree),ue(Ue,st-3,2)):st<=10?(fe(Ue,E,Ue.bl_tree),ue(Ue,st-3,3)):(fe(Ue,b,Ue.bl_tree),ue(Ue,st-11,7));Ke=Me,ut=(st=0)===je?(at=138,3):Me===je?(at=6,3):(at=7,4)}}l(Ae);var Oe=!1;function Qe(Ue,Te,Ie,He){ue(Ue,(A<<1)+(He?1:0),3),(function(Me,Ke,je,st){Pe(Me),re(Me,je),re(Me,~je),s.arraySet(Me.pending_buf,Me.window,Ke,je,Me.pending),Me.pending+=je})(Ue,Te,Ie)}r._tr_init=function(Ue){Oe||((function(){var Te,Ie,He,Me,Ke,je=new Array(g+1);for(Me=He=0;Me<u-1;Me++)for(K[Me]=He,Te=0;Te<1<<P[Me];Te++)G[He++]=Me;for(G[He-1]=Me,Me=Ke=0;Me<16;Me++)for(Ae[Me]=Ke,Te=0;Te<1<<M[Me];Te++)H[Ke++]=Me;for(Ke>>=7;Me<h;Me++)for(Ae[Me]=Ke<<7,Te=0;Te<1<<M[Me]-7;Te++)H[256+Ke++]=Me;for(Ie=0;Ie<=g;Ie++)je[Ie]=0;for(Te=0;Te<=143;)N[2*Te+1]=8,Te++,je[8]++;for(;Te<=255;)N[2*Te+1]=9,Te++,je[9]++;for(;Te<=279;)N[2*Te+1]=7,Te++,je[7]++;for(;Te<=287;)N[2*Te+1]=8,Te++,je[8]++;for(ve(N,_+1,je),Te=0;Te<h;Te++)O[2*Te+1]=5,O[2*Te]=be(Te,5);J=new ne(N,P,d+1,_,g),$=new ne(O,M,0,h,g),ie=new ne(new Array(0),w,0,m,y)})(),Oe=!0),Ue.l_desc=new oe(Ue.dyn_ltree,J),Ue.d_desc=new oe(Ue.dyn_dtree,$),Ue.bl_desc=new oe(Ue.bl_tree,ie),Ue.bi_buf=0,Ue.bi_valid=0,he(Ue)},r._tr_stored_block=Qe,r._tr_flush_block=function(Ue,Te,Ie,He){var Me,Ke,je=0;0<Ue.level?(Ue.strm.data_type===2&&(Ue.strm.data_type=(function(st){var at,ut=4093624447;for(at=0;at<=31;at++,ut>>>=1)if(1&ut&&st.dyn_ltree[2*at]!==0)return a;if(st.dyn_ltree[18]!==0||st.dyn_ltree[20]!==0||st.dyn_ltree[26]!==0)return c;for(at=32;at<d;at++)if(st.dyn_ltree[2*at]!==0)return c;return a})(Ue)),We(Ue,Ue.l_desc),We(Ue,Ue.d_desc),je=(function(st){var at;for(ye(st,st.dyn_ltree,st.l_desc.max_code),ye(st,st.dyn_dtree,st.d_desc.max_code),We(st,st.bl_desc),at=m-1;3<=at&&st.bl_tree[2*k[at]+1]===0;at--);return st.opt_len+=3*(at+1)+5+5+4,at})(Ue),Me=Ue.opt_len+3+7>>>3,(Ke=Ue.static_len+3+7>>>3)<=Me&&(Me=Ke)):Me=Ke=Ie+5,Ie+4<=Me&&Te!==-1?Qe(Ue,Te,Ie,He):Ue.strategy===4||Ke===Me?(ue(Ue,2+(He?1:0),3),ke(Ue,N,O)):(ue(Ue,4+(He?1:0),3),(function(st,at,ut,ct){var yt;for(ue(st,at-257,5),ue(st,ut-1,5),ue(st,ct-4,4),yt=0;yt<ct;yt++)ue(st,st.bl_tree[2*k[yt]+1],3);qe(st,st.dyn_ltree,at-1),qe(st,st.dyn_dtree,ut-1)})(Ue,Ue.l_desc.max_code+1,Ue.d_desc.max_code+1,je+1),ke(Ue,Ue.dyn_ltree,Ue.dyn_dtree)),he(Ue),He&&Pe(Ue)},r._tr_tally=function(Ue,Te,Ie){return Ue.pending_buf[Ue.d_buf+2*Ue.last_lit]=Te>>>8&255,Ue.pending_buf[Ue.d_buf+2*Ue.last_lit+1]=255&Te,Ue.pending_buf[Ue.l_buf+Ue.last_lit]=255&Ie,Ue.last_lit++,Te===0?Ue.dyn_ltree[2*Ie]++:(Ue.matches++,Te--,Ue.dyn_ltree[2*(G[Ie]+d+1)]++,Ue.dyn_dtree[2*ce(Te)]++),Ue.last_lit===Ue.lit_bufsize-1},r._tr_align=function(Ue){ue(Ue,2,3),fe(Ue,C,N),(function(Te){Te.bi_valid===16?(re(Te,Te.bi_buf),Te.bi_buf=0,Te.bi_valid=0):8<=Te.bi_valid&&(Te.pending_buf[Te.pending++]=255&Te.bi_buf,Te.bi_buf>>=8,Te.bi_valid-=8)})(Ue)}},{"../utils/common":41}],53:[function(o,i,r){i.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(o,i,r){(function(s){(function(a,c){if(!a.setImmediate){var l,A,u,d,_=1,h={},m=!1,p=a.document,g=Object.getPrototypeOf&&Object.getPrototypeOf(a);g=g&&g.setTimeout?g:a,l={}.toString.call(a.process)==="[object process]"?function(I){n.nextTick(function(){y(I)})}:(function(){if(a.postMessage&&!a.importScripts){var I=!0,E=a.onmessage;return a.onmessage=function(){I=!1},a.postMessage("","*"),a.onmessage=E,I}})()?(d="setImmediate$"+Math.random()+"$",a.addEventListener?a.addEventListener("message",C,!1):a.attachEvent("onmessage",C),function(I){a.postMessage(d+I,"*")}):a.MessageChannel?((u=new MessageChannel).port1.onmessage=function(I){y(I.data)},function(I){u.port2.postMessage(I)}):p&&"onreadystatechange"in p.createElement("script")?(A=p.documentElement,function(I){var E=p.createElement("script");E.onreadystatechange=function(){y(I),E.onreadystatechange=null,A.removeChild(E),E=null},A.appendChild(E)}):function(I){setTimeout(y,0,I)},g.setImmediate=function(I){typeof I!="function"&&(I=new Function(""+I));for(var E=new Array(arguments.length-1),b=0;b<E.length;b++)E[b]=arguments[b+1];var P={callback:I,args:E};return h[_]=P,l(_),_++},g.clearImmediate=f}function f(I){delete h[I]}function y(I){if(m)setTimeout(y,0,I);else{var E=h[I];if(E){m=!0;try{(function(b){var P=b.callback,M=b.args;switch(M.length){case 0:P();break;case 1:P(M[0]);break;case 2:P(M[0],M[1]);break;case 3:P(M[0],M[1],M[2]);break;default:P.apply(c,M)}})(E)}finally{f(I),m=!1}}}}function C(I){I.source===a&&typeof I.data=="string"&&I.data.indexOf(d)===0&&y(+I.data.slice(d.length))}})(typeof self>"u"?s===void 0?this:s:self)}).call(this,typeof fU<"u"?fU:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(jBe)),jBe.exports}var ZBo=$Bo();const XBe=NI(ZBo),AS=(t,e)=>{const{fileName:n,mimeType:o="text/plain"}=e,i=t instanceof Blob?t:new Blob([t],{type:o}),r=URL.createObjectURL(i),s=document.createElement("a");s.href=r,s.download=n,document.body.appendChild(s),s.click(),setTimeout(()=>{document.body.removeChild(s),URL.revokeObjectURL(r)},0)},e6o=async({circuitJson:t,projectName:e})=>{await ks.promise((async()=>{const n=new XBe,[{stringifyGerberCommandLayers:o,convertSoupToGerberCommands:i,convertSoupToExcellonDrillCommands:r,stringifyExcellonDrill:s},{convertCircuitJsonToBomRows:a,convertBomRowsToCsv:c},{convertCircuitJsonToPickAndPlaceCsv:l}]=await Promise.all([B5("circuit-json-to-gerber"),B5("circuit-json-to-bom-csv"),B5("circuit-json-to-pnp-csv")]),A=t.filter(y=>!("error_type"in y)&&!("warning_type"in y)),u=i(A,{flip_y_axis:!1}),d=o(u);for(const[y,C]of Object.entries(d))n.file(`gerber/${y}.gbr`,C);const _=r({circuitJson:A,is_plated:!0,flip_y_axis:!1}),h=s(_);n.file("gerber/drill.drl",h);const m=await a({circuitJson:t}),p=await c(m);n.file("bom.csv",p);const g=await l(t);n.file("pick_and_place.csv",g);const f=await n.generateAsync({type:"blob"});AS(f,{fileName:`${e}_fabrication_files.zip`})})(),{loading:"Generating fabrication files...",success:"Fabrication ZIP ready",error:n=>`Failed to generate fabrication files: ${n instanceof Error?n.message:String(n)}`})},t6o=async({circuitJson:t,projectName:e})=>{let n;try{const{convertCircuitJsonToGltf:o}=await B5("circuit-json-to-gltf");console.log("convertCircuitJsonToGltf",o);const i=await o(t,{format:"glb",boardTextureResolution:1024});if(!i||!(i instanceof ArrayBuffer))throw new Error("Invalid GLB data returned from converter");n=new Blob([i],{type:"model/gltf-binary"})}catch(o){console.error("GLB Export Error:",o);return}AS(n,{fileName:`${e}.glb`})},n6o=async({circuitJson:t,libraryName:e})=>{const{CircuitJsonToKicadLibraryConverter:n}=await B5("circuit-json-to-kicad"),o=new n(t,{libraryName:e,footprintLibraryName:e});o.runUntilFinished();const i=o.getOutput(),r=new XBe;r.file(`${e}.kicad_sym`,i.kicadSymString);for(const s of i.footprints){const a=r.folder(`${e}.pretty`);a&&a.file(`${s.footprintName}.kicad_mod`,`${s.kicadModString}
5799
5799
  `)}if(i.model3dSourcePaths.length>0){const s=r.folder(`${e}.3dshapes`);if(s)for(const a of i.model3dSourcePaths)try{const c=a.split("/").pop()||a,l=await fetch(a);if(l.ok){const A=await l.arrayBuffer();s.file(c,A)}}catch{}}return r.file("fp-lib-table",i.fpLibTableString),r.file("sym-lib-table",i.symLibTableString),r},o6o=async({circuitJson:t,projectName:e})=>{await ks.promise((async()=>{const o=await(await n6o({circuitJson:t,libraryName:e})).generateAsync({type:"blob"});AS(o,{fileName:`${e}_kicad_library.zip`})})(),{loading:"Generating KiCad library...",success:"KiCad library ZIP ready",error:n=>`Failed to generate KiCad library: ${n instanceof Error?n.message:String(n)}`})},i6o=async({circuitJson:t,projectName:e})=>{const{CircuitJsonToKicadPcbConverter:n,CircuitJsonToKicadSchConverter:o,CircuitJsonToKicadProConverter:i,resolveAndLoadKicad3dModelFiles:r}=await B5("circuit-json-to-kicad"),s=new o(t);s.runUntilFinished();const a=s.getOutputString(),c=new n(t,{includeBuiltin3dModels:!0,projectName:e});c.runUntilFinished();const l=c.getOutputString(),A=new i(t,{projectName:e,schematicFilename:`${e}.kicad_sch`,pcbFilename:`${e}.kicad_pcb`});A.runUntilFinished();const u=A.getOutputString(),d=new XBe;return d.file(`${e}.kicad_sch`,a),d.file(`${e}.kicad_pcb`,l),d.file(`${e}.kicad_pro`,u),await r({projectName:e,model3dSourcePaths:c.getModel3dSourcePaths(),fetch,onModelFile:({outputPath:_,content:h})=>{d.file(_,h)},onError:({sourcePath:_})=>{console.warn(`Failed to load 3D model from ${_}`)}}),d},r6o=async({circuitJson:t,projectName:e})=>{await ks.promise((async()=>{const o=await(await i6o({circuitJson:t,projectName:e})).generateAsync({type:"blob"});AS(o,{fileName:`${e}_kicad_project.zip`})})(),{loading:"Generating KiCad project...",success:"KiCad project ZIP ready",error:n=>`Failed to generate KiCad project: ${n instanceof Error?n.message:String(n)}`})},VBt=async({circuitJson:t,projectName:e,options:n={}})=>{try{const{convertCircuitJsonToLbrn:o}=await B5("circuit-json-to-lbrn"),r=(await o(t,{includeSilkscreen:n.includeSilkscreen??!1,includeOxidationCleaningLayer:n.includeOxidationCleaningLayer??!0})).toXml(),s=new Blob([r],{type:"application/lbrn"});AS(s,{fileName:`${e}.lbrn2`})}catch(o){const i=o instanceof Error?o.message:"Unknown error";ks.error(`Failed to export to LBRN format: ${i}`)}},s6o=async({circuitJson:t,projectName:e})=>{const{convertCircuitJsonToPinoutSvg:n}=await B5("circuit-to-svg"),o=n(t);AS(o,{fileName:`${e}-pinout.svg`,mimeType:"image/svg+xml"})},a6o=async({circuitJson:t,projectName:e})=>{const{circuitJsonToStep:n}=await B5("circuit-json-to-step"),o=t.find(l=>l.type==="pcb_board"),i=o&&"width"in o?o.width:void 0,r=o&&"height"in o?o.height:void 0,s=o&&"thickness"in o?o.thickness:void 0;if(i===void 0||r===void 0||s===void 0){ks.error("Board dimensions not found. Please add a pcb_board with width, height, and thickness to your circuit.");return}let a;try{a=await n(t,{boardWidth:i,boardHeight:r,boardThickness:s,productName:e,includeComponents:!0,includeExternalMeshes:!0})}catch(l){const A=l instanceof Error?l.message:"Unknown error";ks.error(`Failed to convert circuit to STEP format: ${A}`);return}const c=new Blob([a],{type:"application/step"});try{AS(c,{fileName:`${e}.step`})}catch(l){const A=l instanceof Error?l.message:"Unknown error";ks.error(`Failed to download STEP file: ${A}`)}},c6o=[{extension:"json",name:"Circuit JSON"},{extension:"json",name:"Simple Route JSON"},{extension:"zip",name:"Fabrication Files"},{extension:"zip",name:"KiCad Project"},{extension:"zip",name:"KiCad Library"},{extension:"glb",name:"GLB (Binary GLTF)"},{extension:"svg",name:"Pinout SVG"},{extension:"step",name:"STEP"},{extension:"lbrn2",name:"LightBurn"}],l6o=async({exportName:t,circuitJson:e,simpleRouteJson:n,projectName:o})=>{const i=qBo(o);if(t==="Fabrication Files"){await e6o({circuitJson:e,projectName:i});return}if(t==="KiCad Project"){await r6o({circuitJson:e,projectName:i});return}if(t==="KiCad Library"){await o6o({circuitJson:e,projectName:i});return}if(t==="Circuit JSON"){AS(JSON.stringify(e,null,2),{fileName:`${i}.circuit.json`,mimeType:"application/json"});return}if(t==="Simple Route JSON"){if(!n)throw new Error("No Simple Route JSON available to export");AS(JSON.stringify(n,null,2),{fileName:`${i}.simple-route.json`,mimeType:"application/json"});return}if(t==="GLB (Binary GLTF)"){await t6o({circuitJson:e,projectName:i});return}if(t==="Pinout SVG"){s6o({circuitJson:e,projectName:i});return}if(t==="STEP"){await a6o({circuitJson:e,projectName:i});return}if(t==="LightBurn"){await VBt({circuitJson:e,projectName:i});return}throw new Error(`Unsupported export type: "${t}"`)},A6o=({packageName:t,onSelectReview:e})=>{const n=I0(u=>u.fsMap),o=I0(u=>u.circuitJson),[i,r]=j.useState([]),[s,a]=j.useState(!1),[c,l]=j.useState(!1);j.useEffect(()=>{!t||!bq()||(a(!0),mH.get("ai_reviews/list",{searchParams:{package_name:t}}).json().then(u=>r(u.ai_reviews)).catch(u=>{console.error("Failed to load AI reviews",u),ks.error("Failed to load AI reviews")}).finally(()=>a(!1)))},[t]);const A=async()=>{if(!o){ks.error("Need Circuit JSON to Request AI Review");return}if(!bq()){ks.error("Missing registry token");return}l(!0);try{const{ai_review:u}=await mH.post("ai_reviews/create",{json:{package_name:t??"unknown",fs_map:Object.fromEntries(n),circuit_json:o}}).json();r(d=>[u,...d]),e(u),ks.success("AI review requested")}catch(u){console.error("Failed to create AI review",u),ks.error("Failed to request AI review")}finally{l(!1)}};return V.jsxs(V.Fragment,{children:[V.jsxs(pM,{children:[V.jsx(fM,{children:"AI Review"}),V.jsx(MT,{children:"Select an AI review or request a new one."})]}),V.jsx("div",{className:"rf-flex rf-gap-4 rf-mt-4",children:V.jsx("div",{className:"rf-w-48 rf-h-64 rf-overflow-y-auto rf-border rf-rounded rf-p-2 rf-flex-shrink-0",children:s?V.jsx("div",{className:"rf-text-sm",children:"Loading..."}):i.length>0?i.map(u=>V.jsx("div",{className:"rf-text-sm rf-p-2 rf-cursor-pointer rf-rounded hover:rf-bg-zinc-100",onClick:()=>e(u),children:new Date(u.created_at||"").toLocaleString()},u.ai_review_id)):V.jsx("div",{className:"rf-text-sm rf-text-muted-foreground",children:"No AI reviews found."})})}),V.jsx(AG,{className:"rf-mt-4",children:V.jsx(sl,{onClick:A,disabled:c,children:c?"Requesting...":"Review my Board"})})]})};function JBe(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var yM=JBe();function YBt(t){yM=t}var hG={exec:()=>null};function ql(t,e=""){let n=typeof t=="string"?t:t.source;const o={replace:(i,r)=>{let s=typeof r=="string"?r:r.source;return s=s.replace($1.caret,"$1"),n=n.replace(i,s),o},getRegex:()=>new RegExp(n,e)};return o}var $1={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:t=>new RegExp(`^( {0,3}${t})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}#`),htmlBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}<(?:[a-z].*>|!--)`,"i")},u6o=/^(?:[ \t]*(?:\n|$))+/,d6o=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,h6o=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,_G=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,_6o=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,qBe=/(?:[*+-]|\d{1,9}[.)])/,KBt=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,WBt=ql(KBt).replace(/bull/g,qBe).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),m6o=ql(KBt).replace(/bull/g,qBe).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),$Be=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,g6o=/^[^\n]+/,ZBe=/(?!\s*\])(?:\\.|[^\[\]\\])+/,p6o=ql(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",ZBe).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),f6o=ql(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,qBe).getRegex(),wne="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",e6e=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,y6o=ql("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",e6e).replace("tag",wne).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),jBt=ql($Be).replace("hr",_G).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",wne).getRegex(),C6o=ql(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",jBt).getRegex(),t6e={blockquote:C6o,code:d6o,def:p6o,fences:h6o,heading:_6o,hr:_G,html:y6o,lheading:WBt,list:f6o,newline:u6o,paragraph:jBt,table:hG,text:g6o},XBt=ql("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",_G).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",wne).getRegex(),x6o={...t6e,lheading:m6o,table:XBt,paragraph:ql($Be).replace("hr",_G).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",XBt).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",wne).getRegex()},I6o={...t6e,html:ql(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",e6e).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:hG,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:ql($Be).replace("hr",_G).replace("heading",` *#{1,6} *[^
5800
5800
  ]`).replace("lheading",WBt).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},E6o=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,b6o=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,JBt=/^( {2,}|\\)\n(?!\s*$)/,S6o=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Dne=/[\p{P}\p{S}]/u,n6e=/[\s\p{P}\p{S}]/u,qBt=/[^\s\p{P}\p{S}]/u,P6o=ql(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,n6e).getRegex(),$Bt=/(?!~)[\p{P}\p{S}]/u,v6o=/(?!~)[\s\p{P}\p{S}]/u,B6o=/(?:[^\s\p{P}\p{S}]|~)/u,M6o=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,ZBt=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,w6o=ql(ZBt,"u").replace(/punct/g,Dne).getRegex(),D6o=ql(ZBt,"u").replace(/punct/g,$Bt).getRegex(),e6t="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",Q6o=ql(e6t,"gu").replace(/notPunctSpace/g,qBt).replace(/punctSpace/g,n6e).replace(/punct/g,Dne).getRegex(),T6o=ql(e6t,"gu").replace(/notPunctSpace/g,B6o).replace(/punctSpace/g,v6o).replace(/punct/g,$Bt).getRegex(),N6o=ql("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,qBt).replace(/punctSpace/g,n6e).replace(/punct/g,Dne).getRegex(),R6o=ql(/\\(punct)/,"gu").replace(/punct/g,Dne).getRegex(),k6o=ql(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),L6o=ql(e6e).replace("(?:-->|$)","-->").getRegex(),H6o=ql("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",L6o).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Qne=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,F6o=ql(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",Qne).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),t6t=ql(/^!?\[(label)\]\[(ref)\]/).replace("label",Qne).replace("ref",ZBe).getRegex(),n6t=ql(/^!?\[(ref)\](?:\[\])?/).replace("ref",ZBe).getRegex(),O6o=ql("reflink|nolink(?!\\()","g").replace("reflink",t6t).replace("nolink",n6t).getRegex(),o6e={_backpedal:hG,anyPunctuation:R6o,autolink:k6o,blockSkip:M6o,br:JBt,code:b6o,del:hG,emStrongLDelim:w6o,emStrongRDelimAst:Q6o,emStrongRDelimUnd:N6o,escape:E6o,link:F6o,nolink:n6t,punctuation:P6o,reflink:t6t,reflinkSearch:O6o,tag:H6o,text:S6o,url:hG},G6o={...o6e,link:ql(/^!?\[(label)\]\((.*?)\)/).replace("label",Qne).getRegex(),reflink:ql(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Qne).getRegex()},i6e={...o6e,emStrongRDelimAst:T6o,emStrongLDelim:D6o,url:ql(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,"i").replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},U6o={...i6e,br:ql(JBt).replace("{2,}","*").getRegex(),text:ql(i6e.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Tne={normal:t6e,gfm:x6o,pedantic:I6o},mG={normal:o6e,gfm:i6e,breaks:U6o,pedantic:G6o},z6o={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},o6t=t=>z6o[t];function xE(t,e){if(e){if($1.escapeTest.test(t))return t.replace($1.escapeReplace,o6t)}else if($1.escapeTestNoEncode.test(t))return t.replace($1.escapeReplaceNoEncode,o6t);return t}function i6t(t){try{t=encodeURI(t).replace($1.percentDecode,"%")}catch{return null}return t}function r6t(t,e){const n=t.replace($1.findPipe,(r,s,a)=>{let c=!1,l=s;for(;--l>=0&&a[l]==="\\";)c=!c;return c?"|":" |"}),o=n.split($1.splitPipe);let i=0;if(o[0].trim()||o.shift(),o.length>0&&!o.at(-1)?.trim()&&o.pop(),e)if(o.length>e)o.splice(e);else for(;o.length<e;)o.push("");for(;i<o.length;i++)o[i]=o[i].trim().replace($1.slashPipe,"|");return o}function gG(t,e,n){const o=t.length;if(o===0)return"";let i=0;for(;i<o&&t.charAt(o-i-1)===e;)i++;return t.slice(0,o-i)}function V6o(t,e){if(t.indexOf(e[1])===-1)return-1;let n=0;for(let o=0;o<t.length;o++)if(t[o]==="\\")o++;else if(t[o]===e[0])n++;else if(t[o]===e[1]&&(n--,n<0))return o;return n>0?-2:-1}function s6t(t,e,n,o,i){const r=e.href,s=e.title||null,a=t[1].replace(i.other.outputLinkReplace,"$1");o.state.inLink=!0;const c={type:t[0].charAt(0)==="!"?"image":"link",raw:n,href:r,title:s,text:a,tokens:o.inlineTokens(a)};return o.state.inLink=!1,c}function Y6o(t,e,n){const o=t.match(n.other.indentCodeCompensation);if(o===null)return e;const i=o[1];return e.split(`
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@tscircuit/runframe",
3
3
  "main": "dist/preview.js",
4
4
  "type": "module",
5
- "version": "0.0.2159",
5
+ "version": "0.0.2160",
6
6
  "exports": {
7
7
  ".": "./dist/preview.js",
8
8
  "./preview": "./dist/preview.js",
@@ -113,7 +113,7 @@
113
113
  "yargs": "^17.7.2"
114
114
  },
115
115
  "dependencies": {
116
- "@tscircuit/eval": "^0.0.975",
116
+ "@tscircuit/eval": "^0.0.977",
117
117
  "@tscircuit/solver-utils": "^0.0.7"
118
118
  }
119
119
  }