@tscircuit/runframe 0.0.2204 → 0.0.2206
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.
|
@@ -2177,7 +2177,7 @@ var usePostHogActivity = (properties) => {
|
|
|
2177
2177
|
};
|
|
2178
2178
|
|
|
2179
2179
|
// package.json
|
|
2180
|
-
var version = "0.0.
|
|
2180
|
+
var version = "0.0.2205";
|
|
2181
2181
|
var package_default = {
|
|
2182
2182
|
name: "@tscircuit/runframe",
|
|
2183
2183
|
main: "dist/preview.js",
|
|
@@ -2293,7 +2293,7 @@ var package_default = {
|
|
|
2293
2293
|
yargs: "^17.7.2"
|
|
2294
2294
|
},
|
|
2295
2295
|
dependencies: {
|
|
2296
|
-
"@tscircuit/eval": "^0.0.
|
|
2296
|
+
"@tscircuit/eval": "^0.0.1008",
|
|
2297
2297
|
"@tscircuit/solver-utils": "^0.0.7"
|
|
2298
2298
|
}
|
|
2299
2299
|
};
|
package/dist/preview.js
CHANGED
package/dist/runner.js
CHANGED
|
@@ -5779,7 +5779,7 @@ test("${l} should solve problem correctly", () => {
|
|
|
5779
5779
|
// Add more specific assertions based on expected output
|
|
5780
5780
|
// expect(solver.netLabelPlacementSolver!.netLabelPlacements).toMatchInlineSnapshot()
|
|
5781
5781
|
})
|
|
5782
|
-
`,u=new Blob([A],{type:"text/plain"}),d=URL.createObjectURL(u),h=document.createElement("a");h.href=d,h.download=`${l}.test.ts`,h.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 j.jsxs("div",{className:`relative ${e}`,ref:i,children:[j.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>o(!n),title:`Download options for ${t.constructor.name}`,children:t.constructor.name}),n&&j.jsxs("div",{className:"absolute top-full left-0 mt-1 bg-white border border-gray-300 rounded shadow-lg z-10 min-w-[150px]",children:[j.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download JSON"}),j.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),j.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:a,children:"Download test.ts"})]})]})},d7t=t=>t.activeSubSolver?[t,...d7t(t.activeSubSolver)]:[t],j7o=({solver:t})=>{const e=d7t(t);return j.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:e.map((n,o)=>j.jsxs("div",{className:"flex items-center",children:[o>0&&j.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),j.jsx(W7o,{solver:n})]},n.constructor.name))})},X7o=({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 h=t.getCurrentPhase!==void 0,_=h?t.getCurrentPhase():null;return j.jsxs("div",{className:"space-y-2 p-2 border-b",children:[j.jsx("div",{className:"flex items-center",children:j.jsx(j7o,{solver:t})}),j.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[j.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"}),j.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"}),j.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"}),j.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"}),h&&j.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"}),j.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&j.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),_&&j.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",j.jsx("span",{className:"font-medium",children:_})]}),t.solved&&j.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&j.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&j.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},J7o=(t,e,n)=>{const o=t.currentPipelineStepIndex;return e<o?"Completed":e===o&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},$7o=(t,e)=>{const o=t.pipelineDef[e].solverName,i=J7o(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],h=d?t.firstIterationOfPhase?.[d.solverName]:void 0;h!==void 0&&s!==null?c=h-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}},q7o=({status:t})=>{const e={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return j.jsx("span",{className:`font-medium ${e[t]}`,children:t})},Z7o=({progress:t})=>{if(t===0)return null;const e=Math.round(t*100);return j.jsxs("div",{className:"flex items-center gap-2",children:[j.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:j.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${e}%`}})}),j.jsxs("span",{className:"text-xs text-gray-500",children:[e,"%"]})]})},ewo=t=>Object.entries(t).map(([e,n])=>`${e}: ${n}`).join(", "),two=({stats:t})=>{if(!t||Object.keys(t).length===0)return j.jsx("span",{children:"-"});const e=Object.entries(t),n=ewo(t);return j.jsxs("details",{className:"cursor-pointer",children:[j.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:n}),j.jsx("div",{className:"mt-1 text-xs",children:e.map(([o,i])=>j.jsxs("div",{children:[o,": ",String(i)]},o))})]})},mBe=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(mBe);const e={};for(const[n,o]of Object.entries(t))n.startsWith("_")||(e[n]=mBe(o));return e},nwo=(t,e)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${e}`);return}const n=mBe(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)}`)}},owo=({solver:t,onStepUntilPhase:e,onDownloadInput:n})=>{const o=t.pipelineDef.map((a,c)=>$7o(t,c)),i=a=>{e?.(a)},r=a=>{a.solverInstance&&(n?n(a.solverInstance,a.name):nwo(a.solverInstance,a.name))},s=a=>`${(a/1e3).toFixed(2)}s`;return j.jsxs("div",{className:"border-t border-gray-200",children:[j.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:j.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),j.jsx("div",{className:"overflow-x-auto",children:j.jsxs("table",{className:"w-full text-sm",children:[j.jsx("thead",{children:j.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[j.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),j.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),j.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",j.jsx("sub",{children:"0"})]}),j.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),j.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),j.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),j.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),j.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),j.jsx("tbody",{children:o.map(a=>j.jsxs("tr",{className:`border-b border-gray-100 ${a.status==="In Progress"?"bg-yellow-50":""}`,children:[j.jsx("td",{className:"px-4 py-2",children:j.jsxs("div",{className:"flex items-center gap-2",children:[j.jsx("span",{className:"text-gray-400 w-6",children:String(a.index+1).padStart(2,"0")}),j.jsx("button",{onClick:()=>i(a.name),disabled:a.status==="Completed"||t.solved||t.failed,className:"text-blue-500 hover:text-blue-700 disabled:text-gray-300 disabled:cursor-not-allowed",title:`Step until ${a.name} completes`,children:j.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:j.jsx("path",{fillRule:"evenodd",d:"M4.5 5.653c0-1.426 1.529-2.33 2.779-1.643l11.54 6.348c1.295.712 1.295 2.573 0 3.285L7.28 19.991c-1.25.687-2.779-.217-2.779-1.643V5.653z",clipRule:"evenodd"})})}),j.jsx("span",{className:"font-medium text-gray-900",children:a.name})]})}),j.jsx("td",{className:"px-4 py-2",children:j.jsx(q7o,{status:a.status})}),j.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:a.firstIteration!==null?a.firstIteration:""}),j.jsx("td",{className:"px-4 py-2 text-gray-600",children:a.iterations}),j.jsx("td",{className:"px-4 py-2",children:j.jsx(Z7o,{progress:a.progress})}),j.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(a.timeSpent)}),j.jsx("td",{className:"px-4 py-2 text-gray-500",children:j.jsx(two,{stats:a.stats})}),j.jsx("td",{className:"px-4 py-2",children:a.solverInstance?j.jsxs("button",{onClick:()=>r(a),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${a.name}`,children:[j.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:j.jsx("path",{fillRule:"evenodd",d:"M12 2.25a.75.75 0 01.75.75v11.69l3.22-3.22a.75.75 0 111.06 1.06l-4.5 4.5a.75.75 0 01-1.06 0l-4.5-4.5a.75.75 0 111.06-1.06l3.22 3.22V3a.75.75 0 01.75-.75zm-9 13.5a.75.75 0 01.75.75v2.25a1.5 1.5 0 001.5 1.5h13.5a1.5 1.5 0 001.5-1.5V16.5a.75.75 0 011.5 0v2.25a3 3 0 01-3 3H5.25a3 3 0 01-3-3V16.5a.75.75 0 01.75-.75z",clipRule:"evenodd"})}),j.jsx("span",{children:"Input"})]}):null})]},a.name))})]})})]})},iwo=class extends Yr.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 rwo({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,x=p.height??0;A(g,f),A(g+y,f+x)}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,h=a-u,_=Math.max(1,c-s+2*u),m=Math.max(1,l-a+2*u);return j.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${d} ${h} ${_} ${m}`,role:"img","aria-label":"Graphics fallback",children:[o.map((p,g)=>j.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)=>j.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)=>j.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)=>j.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)=>j.jsx("text",{x:p.x??0,y:p.y??0,fontSize:p.fontSize??10,fill:p.color??"black",children:p.text??""},`text-${g}`))]})}var swo=({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 j.jsxs("div",{children:[j.jsx(X7o,{solver:t,triggerRender:r,animationSpeed:e,onSolverStarted:n,onSolverCompleted:o}),a?j.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):j.jsx(iwo,{fallback:j.jsx(rwo,{graphics:s}),children:j.jsx(K7o,{graphics:s})}),c&&j.jsx(owo,{solver:t,onStepUntilPhase:l})]})};const awo=()=>{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)},[])},cwo=1e3,OE=(t,e)=>{const{fileName:n,mimeType:o="text/plain"}=e,i=t instanceof Blob?t:new Blob([t],{type:o}),r=URL.createObjectURL(i),s=document.createElement("a");s.href=r,s.download=n,s.target="_blank",s.rel="noopener noreferrer",s.style.display="none",document.body.appendChild(s),s.click(),document.body.removeChild(s),setTimeout(()=>{URL.revokeObjectURL(r)},cwo)},_7t=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"},GE="https://github.com/tscircuit/tscircuit-autorouter/issues/new",h7t="https://github.com/tscircuit/copper-pour-solver/issues/new",m7t="https://github.com/tscircuit/calculate-packing/issues/new",g7t="https://github.com/tscircuit/schematic-trace-solver/issues/new?template=json-bug-report.yml",lwo={PackSolver2:m7t,AutoroutingPipelineSolver:GE,AssignableAutoroutingPipeline2:GE,AssignableAutoroutingPipeline3:GE,AutoroutingPipeline1_OriginalUnravel:GE,AutoroutingPipelineSolver3_HgPortPointPathing:GE,AutoroutingPipelineSolver4:GE,AutoroutingPipelineSolver5:GE,AutoroutingPipelineSolver7_MultiGraph:GE,AutoroutingPipelineSolver8:GE,CopperPourPipelineSolver:h7t,SchematicTracePipelineSolver:g7t},Awo=t=>t.toLowerCase().includes("pack")?Cpo:t.toLowerCase().includes("rout")?Bpo:hpo,p7t=t=>{const e=lwo[t];if(e)return e;const n=t.toLowerCase();return n.includes("autorout")?GE:n.includes("schematic")&&n.includes("trace")?g7t:n.includes("copperpour")?h7t:n.includes("pack")?m7t:null},uwo=t=>`${_7t(`${t.componentName}-${t.solverName}`)}-solver-input.json`,f7t=t=>{OE(JSON.stringify(t.solverParams,null,2),{fileName:uwo(t),mimeType:"application/json"})},dwo=({solverEvent:t})=>{const e=p7t(t.solverName);return j.jsxs("div",{className:"rf-flex rf-items-center rf-justify-end rf-gap-2 rf-border-b rf-border-gray-200 rf-bg-gray-50 rf-px-4 rf-py-2",children:[j.jsxs(Al,{type:"button",variant:"outline",size:"sm",onClick:()=>f7t(t),children:[j.jsx(KPe,{className:"rf-w-4 rf-h-4"}),"Download"]}),e?j.jsx(Al,{asChild:!0,variant:"outline",size:"sm",children:j.jsxs("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:[j.jsx(Mee,{className:"rf-w-4 rf-h-4"}),"Report"]})}):j.jsxs(Al,{type:"button",variant:"outline",size:"sm",disabled:!0,title:"No report link configured for this solver",children:[j.jsx(Mee,{className:"rf-w-4 rf-h-4"}),"Report"]})]})},_wo=({solverEvent:t})=>{const e=p7t(t.solverName);return e?j.jsx(Al,{asChild:!0,variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8",children:j.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",title:"Report solver bug","aria-label":"Report solver bug",children:j.jsx(Mee,{className:"rf-w-4 rf-h-4"})})}):j.jsx(Al,{type:"button",variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8",disabled:!0,title:"No report link configured for this solver","aria-label":"Report solver bug",children:j.jsx(Mee,{className:"rf-w-4 rf-h-4"})})},hwo=({solverEvents:t=[]})=>{const[e,n]=Z.useState(null);awo();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=t2e[r.solverName];if(!a)return{instance:null,error:`Solver class "${r.solverName}" not found in SOLVERS registry. Available: ${Object.keys(t2e).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?j.jsx("div",{className:"rf-p-4",children:j.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:j.jsxs("div",{className:"rf-p-4",children:[j.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),j.jsx("p",{className:"rf-text-sm rf-text-gray-600",children:"Solvers will appear here when the circuit runs. Solvers are used for tasks like component packing and autorouting."})]})})}):j.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[j.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[j.jsxs("div",{className:"rf-text-xs rf-font-semibold rf-text-gray-500 rf-px-3 rf-py-2 rf-bg-gray-50 rf-border-b rf-border-gray-200",children:[i.length," ",i.length===1?"Solver":"Solvers"]}),i.map(a=>{const c=o.get(a),l=e===a;return j.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=Awo(c.solverName);return j.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[j.jsx(A,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),j.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[j.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:c.componentName}),j.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:c.solverName})]})]})})()},a)})]}),j.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:r?s.instance?j.jsxs("div",{className:"rf-flex rf-h-full rf-flex-col rf-overflow-y-auto",children:[j.jsx(dwo,{solverEvent:r}),j.jsx("div",{className:"rf-min-h-0 rf-flex-1",children:j.jsx(bE,{fallback:j.jsx("div",{className:"rf-p-4",children:j.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[j.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),j.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",r.solverName]})]})}),children:j.jsx(swo,{solver:s.instance})})})]}):j.jsxs("div",{className:"rf-p-4",children:[j.jsxs("div",{className:"rf-mb-4",children:[j.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:r.solverName}),j.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",r.componentName]})]}),s.error&&j.jsx("div",{className:`rf-rounded-md rf-border rf-p-4 rf-mb-4 ${s.classFound?"rf-bg-red-50 rf-border-red-200":"rf-bg-yellow-50 rf-border-yellow-200"}`,children:j.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),j.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[j.jsxs("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50 rf-flex rf-items-center rf-justify-between rf-gap-2",children:[j.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"}),j.jsxs("div",{className:"rf-flex rf-items-center rf-gap-1",children:[j.jsx(_wo,{solverEvent:r}),j.jsx(Al,{type:"button",variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8","aria-label":"Download solver input JSON",title:"Download solver input JSON",onClick:()=>f7t(r),children:j.jsx(KPe,{className:"rf-w-4 rf-h-4"})})]})]}),j.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:j.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(r.solverParams,null,2)})})]})]}):j.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:j.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},y7t=({errorMessage:t,errorStack:e,circuitJsonErrors:n})=>{Z.useEffect(()=>{if(t){const o=new Error(t);e&&(o.stack=e);try{OM.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{OM.captureException(i,{error_type:o.type})}catch{}}},[n])},mwo=t=>{Z.useEffect(()=>{try{CLt(t)}catch{}},[t.source,t.component,t.isWebEmbedded,t.activeTab])},x7t="0.0.2203",gwo={version:x7t},gBe={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},pBe=new Map,Hne=t=>{const e=pBe.get(t);return e?Object.fromEntries(Object.entries(e.stores).map(([n,o])=>[n,o.getState()])):{}},pwo=(t,e,n)=>{if(t===void 0)return{type:"untracked",connection:e.connect(n)};const o=pBe.get(n.name);if(o)return{type:"tracked",store:t,...o};const i={connection:e.connect(n),stores:{}};return pBe.set(n.name,i),{type:"tracked",store:t,...i}},C7t=(t,e={})=>(n,o,i)=>{const{enabled:r,anonymousActionType:s,store:a,...c}=e;let l;try{l=(r??(gBe?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!l)return(gBe?"production":void 0)!=="production"&&r&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),t(n,o,i);const{connection:A,...u}=pwo(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}`},{...Hne(c.name),[a]:i.getState()}),f)};const h=(...m)=>{const p=d;d=!1,n(...m),d=p},_=t(i.setState,o,i);if(u.type==="untracked"?A?.init(_):(u.stores[u.store]=i,A?.init(Object.fromEntries(Object.entries(u.stores).map(([m,p])=>[m,m===u.store?_:p.getState()])))),i.dispatchFromDevtools&&typeof i.dispatch=="function"){let m=!1;const p=i.dispatch;i.dispatch=(...g)=>{(gBe?"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 fBe(m.payload,g=>{if(g.type==="__setState"){if(a===void 0){h(g.state);return}Object.keys(g.state).length!==1&&console.error(`
|
|
5782
|
+
`,u=new Blob([A],{type:"text/plain"}),d=URL.createObjectURL(u),h=document.createElement("a");h.href=d,h.download=`${l}.test.ts`,h.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 j.jsxs("div",{className:`relative ${e}`,ref:i,children:[j.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>o(!n),title:`Download options for ${t.constructor.name}`,children:t.constructor.name}),n&&j.jsxs("div",{className:"absolute top-full left-0 mt-1 bg-white border border-gray-300 rounded shadow-lg z-10 min-w-[150px]",children:[j.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download JSON"}),j.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),j.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:a,children:"Download test.ts"})]})]})},d7t=t=>t.activeSubSolver?[t,...d7t(t.activeSubSolver)]:[t],j7o=({solver:t})=>{const e=d7t(t);return j.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:e.map((n,o)=>j.jsxs("div",{className:"flex items-center",children:[o>0&&j.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),j.jsx(W7o,{solver:n})]},n.constructor.name))})},X7o=({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 h=t.getCurrentPhase!==void 0,_=h?t.getCurrentPhase():null;return j.jsxs("div",{className:"space-y-2 p-2 border-b",children:[j.jsx("div",{className:"flex items-center",children:j.jsx(j7o,{solver:t})}),j.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[j.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"}),j.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"}),j.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"}),j.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"}),h&&j.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"}),j.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&j.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),_&&j.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",j.jsx("span",{className:"font-medium",children:_})]}),t.solved&&j.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&j.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&j.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},J7o=(t,e,n)=>{const o=t.currentPipelineStepIndex;return e<o?"Completed":e===o&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},$7o=(t,e)=>{const o=t.pipelineDef[e].solverName,i=J7o(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],h=d?t.firstIterationOfPhase?.[d.solverName]:void 0;h!==void 0&&s!==null?c=h-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}},q7o=({status:t})=>{const e={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return j.jsx("span",{className:`font-medium ${e[t]}`,children:t})},Z7o=({progress:t})=>{if(t===0)return null;const e=Math.round(t*100);return j.jsxs("div",{className:"flex items-center gap-2",children:[j.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:j.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${e}%`}})}),j.jsxs("span",{className:"text-xs text-gray-500",children:[e,"%"]})]})},ewo=t=>Object.entries(t).map(([e,n])=>`${e}: ${n}`).join(", "),two=({stats:t})=>{if(!t||Object.keys(t).length===0)return j.jsx("span",{children:"-"});const e=Object.entries(t),n=ewo(t);return j.jsxs("details",{className:"cursor-pointer",children:[j.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:n}),j.jsx("div",{className:"mt-1 text-xs",children:e.map(([o,i])=>j.jsxs("div",{children:[o,": ",String(i)]},o))})]})},mBe=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(mBe);const e={};for(const[n,o]of Object.entries(t))n.startsWith("_")||(e[n]=mBe(o));return e},nwo=(t,e)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${e}`);return}const n=mBe(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)}`)}},owo=({solver:t,onStepUntilPhase:e,onDownloadInput:n})=>{const o=t.pipelineDef.map((a,c)=>$7o(t,c)),i=a=>{e?.(a)},r=a=>{a.solverInstance&&(n?n(a.solverInstance,a.name):nwo(a.solverInstance,a.name))},s=a=>`${(a/1e3).toFixed(2)}s`;return j.jsxs("div",{className:"border-t border-gray-200",children:[j.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:j.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),j.jsx("div",{className:"overflow-x-auto",children:j.jsxs("table",{className:"w-full text-sm",children:[j.jsx("thead",{children:j.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[j.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),j.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),j.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",j.jsx("sub",{children:"0"})]}),j.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),j.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),j.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),j.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),j.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),j.jsx("tbody",{children:o.map(a=>j.jsxs("tr",{className:`border-b border-gray-100 ${a.status==="In Progress"?"bg-yellow-50":""}`,children:[j.jsx("td",{className:"px-4 py-2",children:j.jsxs("div",{className:"flex items-center gap-2",children:[j.jsx("span",{className:"text-gray-400 w-6",children:String(a.index+1).padStart(2,"0")}),j.jsx("button",{onClick:()=>i(a.name),disabled:a.status==="Completed"||t.solved||t.failed,className:"text-blue-500 hover:text-blue-700 disabled:text-gray-300 disabled:cursor-not-allowed",title:`Step until ${a.name} completes`,children:j.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:j.jsx("path",{fillRule:"evenodd",d:"M4.5 5.653c0-1.426 1.529-2.33 2.779-1.643l11.54 6.348c1.295.712 1.295 2.573 0 3.285L7.28 19.991c-1.25.687-2.779-.217-2.779-1.643V5.653z",clipRule:"evenodd"})})}),j.jsx("span",{className:"font-medium text-gray-900",children:a.name})]})}),j.jsx("td",{className:"px-4 py-2",children:j.jsx(q7o,{status:a.status})}),j.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:a.firstIteration!==null?a.firstIteration:""}),j.jsx("td",{className:"px-4 py-2 text-gray-600",children:a.iterations}),j.jsx("td",{className:"px-4 py-2",children:j.jsx(Z7o,{progress:a.progress})}),j.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(a.timeSpent)}),j.jsx("td",{className:"px-4 py-2 text-gray-500",children:j.jsx(two,{stats:a.stats})}),j.jsx("td",{className:"px-4 py-2",children:a.solverInstance?j.jsxs("button",{onClick:()=>r(a),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${a.name}`,children:[j.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:j.jsx("path",{fillRule:"evenodd",d:"M12 2.25a.75.75 0 01.75.75v11.69l3.22-3.22a.75.75 0 111.06 1.06l-4.5 4.5a.75.75 0 01-1.06 0l-4.5-4.5a.75.75 0 111.06-1.06l3.22 3.22V3a.75.75 0 01.75-.75zm-9 13.5a.75.75 0 01.75.75v2.25a1.5 1.5 0 001.5 1.5h13.5a1.5 1.5 0 001.5-1.5V16.5a.75.75 0 011.5 0v2.25a3 3 0 01-3 3H5.25a3 3 0 01-3-3V16.5a.75.75 0 01.75-.75z",clipRule:"evenodd"})}),j.jsx("span",{children:"Input"})]}):null})]},a.name))})]})})]})},iwo=class extends Yr.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 rwo({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,x=p.height??0;A(g,f),A(g+y,f+x)}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,h=a-u,_=Math.max(1,c-s+2*u),m=Math.max(1,l-a+2*u);return j.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${d} ${h} ${_} ${m}`,role:"img","aria-label":"Graphics fallback",children:[o.map((p,g)=>j.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)=>j.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)=>j.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)=>j.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)=>j.jsx("text",{x:p.x??0,y:p.y??0,fontSize:p.fontSize??10,fill:p.color??"black",children:p.text??""},`text-${g}`))]})}var swo=({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 j.jsxs("div",{children:[j.jsx(X7o,{solver:t,triggerRender:r,animationSpeed:e,onSolverStarted:n,onSolverCompleted:o}),a?j.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):j.jsx(iwo,{fallback:j.jsx(rwo,{graphics:s}),children:j.jsx(K7o,{graphics:s})}),c&&j.jsx(owo,{solver:t,onStepUntilPhase:l})]})};const awo=()=>{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)},[])},cwo=1e3,OE=(t,e)=>{const{fileName:n,mimeType:o="text/plain"}=e,i=t instanceof Blob?t:new Blob([t],{type:o}),r=URL.createObjectURL(i),s=document.createElement("a");s.href=r,s.download=n,s.target="_blank",s.rel="noopener noreferrer",s.style.display="none",document.body.appendChild(s),s.click(),document.body.removeChild(s),setTimeout(()=>{URL.revokeObjectURL(r)},cwo)},_7t=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"},GE="https://github.com/tscircuit/tscircuit-autorouter/issues/new",h7t="https://github.com/tscircuit/copper-pour-solver/issues/new",m7t="https://github.com/tscircuit/calculate-packing/issues/new",g7t="https://github.com/tscircuit/schematic-trace-solver/issues/new?template=json-bug-report.yml",lwo={PackSolver2:m7t,AutoroutingPipelineSolver:GE,AssignableAutoroutingPipeline2:GE,AssignableAutoroutingPipeline3:GE,AutoroutingPipeline1_OriginalUnravel:GE,AutoroutingPipelineSolver3_HgPortPointPathing:GE,AutoroutingPipelineSolver4:GE,AutoroutingPipelineSolver5:GE,AutoroutingPipelineSolver7_MultiGraph:GE,AutoroutingPipelineSolver8:GE,CopperPourPipelineSolver:h7t,SchematicTracePipelineSolver:g7t},Awo=t=>t.toLowerCase().includes("pack")?Cpo:t.toLowerCase().includes("rout")?Bpo:hpo,p7t=t=>{const e=lwo[t];if(e)return e;const n=t.toLowerCase();return n.includes("autorout")?GE:n.includes("schematic")&&n.includes("trace")?g7t:n.includes("copperpour")?h7t:n.includes("pack")?m7t:null},uwo=t=>`${_7t(`${t.componentName}-${t.solverName}`)}-solver-input.json`,f7t=t=>{OE(JSON.stringify(t.solverParams,null,2),{fileName:uwo(t),mimeType:"application/json"})},dwo=({solverEvent:t})=>{const e=p7t(t.solverName);return j.jsxs("div",{className:"rf-flex rf-items-center rf-justify-end rf-gap-2 rf-border-b rf-border-gray-200 rf-bg-gray-50 rf-px-4 rf-py-2",children:[j.jsxs(Al,{type:"button",variant:"outline",size:"sm",onClick:()=>f7t(t),children:[j.jsx(KPe,{className:"rf-w-4 rf-h-4"}),"Download"]}),e?j.jsx(Al,{asChild:!0,variant:"outline",size:"sm",children:j.jsxs("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:[j.jsx(Mee,{className:"rf-w-4 rf-h-4"}),"Report"]})}):j.jsxs(Al,{type:"button",variant:"outline",size:"sm",disabled:!0,title:"No report link configured for this solver",children:[j.jsx(Mee,{className:"rf-w-4 rf-h-4"}),"Report"]})]})},_wo=({solverEvent:t})=>{const e=p7t(t.solverName);return e?j.jsx(Al,{asChild:!0,variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8",children:j.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",title:"Report solver bug","aria-label":"Report solver bug",children:j.jsx(Mee,{className:"rf-w-4 rf-h-4"})})}):j.jsx(Al,{type:"button",variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8",disabled:!0,title:"No report link configured for this solver","aria-label":"Report solver bug",children:j.jsx(Mee,{className:"rf-w-4 rf-h-4"})})},hwo=({solverEvents:t=[]})=>{const[e,n]=Z.useState(null);awo();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=t2e[r.solverName];if(!a)return{instance:null,error:`Solver class "${r.solverName}" not found in SOLVERS registry. Available: ${Object.keys(t2e).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?j.jsx("div",{className:"rf-p-4",children:j.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:j.jsxs("div",{className:"rf-p-4",children:[j.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),j.jsx("p",{className:"rf-text-sm rf-text-gray-600",children:"Solvers will appear here when the circuit runs. Solvers are used for tasks like component packing and autorouting."})]})})}):j.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[j.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[j.jsxs("div",{className:"rf-text-xs rf-font-semibold rf-text-gray-500 rf-px-3 rf-py-2 rf-bg-gray-50 rf-border-b rf-border-gray-200",children:[i.length," ",i.length===1?"Solver":"Solvers"]}),i.map(a=>{const c=o.get(a),l=e===a;return j.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=Awo(c.solverName);return j.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[j.jsx(A,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),j.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[j.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:c.componentName}),j.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:c.solverName})]})]})})()},a)})]}),j.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:r?s.instance?j.jsxs("div",{className:"rf-flex rf-h-full rf-flex-col rf-overflow-y-auto",children:[j.jsx(dwo,{solverEvent:r}),j.jsx("div",{className:"rf-min-h-0 rf-flex-1",children:j.jsx(bE,{fallback:j.jsx("div",{className:"rf-p-4",children:j.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[j.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),j.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",r.solverName]})]})}),children:j.jsx(swo,{solver:s.instance})})})]}):j.jsxs("div",{className:"rf-p-4",children:[j.jsxs("div",{className:"rf-mb-4",children:[j.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:r.solverName}),j.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",r.componentName]})]}),s.error&&j.jsx("div",{className:`rf-rounded-md rf-border rf-p-4 rf-mb-4 ${s.classFound?"rf-bg-red-50 rf-border-red-200":"rf-bg-yellow-50 rf-border-yellow-200"}`,children:j.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),j.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[j.jsxs("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50 rf-flex rf-items-center rf-justify-between rf-gap-2",children:[j.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"}),j.jsxs("div",{className:"rf-flex rf-items-center rf-gap-1",children:[j.jsx(_wo,{solverEvent:r}),j.jsx(Al,{type:"button",variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8","aria-label":"Download solver input JSON",title:"Download solver input JSON",onClick:()=>f7t(r),children:j.jsx(KPe,{className:"rf-w-4 rf-h-4"})})]})]}),j.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:j.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(r.solverParams,null,2)})})]})]}):j.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:j.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},y7t=({errorMessage:t,errorStack:e,circuitJsonErrors:n})=>{Z.useEffect(()=>{if(t){const o=new Error(t);e&&(o.stack=e);try{OM.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{OM.captureException(i,{error_type:o.type})}catch{}}},[n])},mwo=t=>{Z.useEffect(()=>{try{CLt(t)}catch{}},[t.source,t.component,t.isWebEmbedded,t.activeTab])},x7t="0.0.2205",gwo={version:x7t},gBe={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},pBe=new Map,Hne=t=>{const e=pBe.get(t);return e?Object.fromEntries(Object.entries(e.stores).map(([n,o])=>[n,o.getState()])):{}},pwo=(t,e,n)=>{if(t===void 0)return{type:"untracked",connection:e.connect(n)};const o=pBe.get(n.name);if(o)return{type:"tracked",store:t,...o};const i={connection:e.connect(n),stores:{}};return pBe.set(n.name,i),{type:"tracked",store:t,...i}},C7t=(t,e={})=>(n,o,i)=>{const{enabled:r,anonymousActionType:s,store:a,...c}=e;let l;try{l=(r??(gBe?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!l)return(gBe?"production":void 0)!=="production"&&r&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),t(n,o,i);const{connection:A,...u}=pwo(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}`},{...Hne(c.name),[a]:i.getState()}),f)};const h=(...m)=>{const p=d;d=!1,n(...m),d=p},_=t(i.setState,o,i);if(u.type==="untracked"?A?.init(_):(u.stores[u.store]=i,A?.init(Object.fromEntries(Object.entries(u.stores).map(([m,p])=>[m,m===u.store?_:p.getState()])))),i.dispatchFromDevtools&&typeof i.dispatch=="function"){let m=!1;const p=i.dispatch;i.dispatch=(...g)=>{(gBe?"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 fBe(m.payload,g=>{if(g.type==="__setState"){if(a===void 0){h(g.state);return}Object.keys(g.state).length!==1&&console.error(`
|
|
5783
5783
|
[zustand devtools middleware] Unsupported __setState action format.
|
|
5784
5784
|
When using 'store' option in devtools(), the 'state' should have only one key, which is a value of 'store' that was passed in devtools(),
|
|
5785
5785
|
and value of this only key should be a state object. Example: { "type": "__setState", "state": { "abc123Store": { "foo": "bar" } } }
|
package/dist/standalone.min.js
CHANGED
|
@@ -5783,7 +5783,7 @@ test("${l} should solve problem correctly", () => {
|
|
|
5783
5783
|
// Add more specific assertions based on expected output
|
|
5784
5784
|
// expect(solver.netLabelPlacementSolver!.netLabelPlacements).toMatchInlineSnapshot()
|
|
5785
5785
|
})
|
|
5786
|
-
`,u=new Blob([A],{type:"text/plain"}),d=URL.createObjectURL(u),h=document.createElement("a");h.href=d,h.download=`${l}.test.ts`,h.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 Y.jsxs("div",{className:`relative ${e}`,ref:i,children:[Y.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&&Y.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:[Y.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download JSON"}),Y.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),Y.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:a,children:"Download test.ts"})]})]})},Ewt=t=>t.activeSubSolver?[t,...Ewt(t.activeSubSolver)]:[t],QTo=({solver:t})=>{const e=Ewt(t);return Y.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:e.map((n,o)=>Y.jsxs("div",{className:"flex items-center",children:[o>0&&Y.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),Y.jsx(TTo,{solver:n})]},n.constructor.name))})},NTo=({solver:t,triggerRender:e,animationSpeed:n=25,onSolverStarted:o,onSolverCompleted:i})=>{const[r,s]=X.useReducer(m=>!m,!1),a=X.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)};X.useEffect(()=>()=>{a.current&&clearInterval(a.current)},[]),X.useEffect(()=>{(t.solved||t.failed)&&r&&(a.current&&(clearInterval(a.current),a.current=void 0),s())},[t.solved,t.failed,r]);const h=t.getCurrentPhase!==void 0,_=h?t.getCurrentPhase():null;return Y.jsxs("div",{className:"space-y-2 p-2 border-b",children:[Y.jsx("div",{className:"flex items-center",children:Y.jsx(QTo,{solver:t})}),Y.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[Y.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"}),Y.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"}),Y.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"}),Y.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"}),h&&Y.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"}),Y.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&Y.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),_&&Y.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",Y.jsx("span",{className:"font-medium",children:_})]}),t.solved&&Y.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&Y.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&Y.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},RTo=(t,e,n)=>{const o=t.currentPipelineStepIndex;return e<o?"Completed":e===o&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},kTo=(t,e)=>{const o=t.pipelineDef[e].solverName,i=RTo(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],h=d?t.firstIterationOfPhase?.[d.solverName]:void 0;h!==void 0&&s!==null?c=h-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}},LTo=({status:t})=>{const e={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return Y.jsx("span",{className:`font-medium ${e[t]}`,children:t})},HTo=({progress:t})=>{if(t===0)return null;const e=Math.round(t*100);return Y.jsxs("div",{className:"flex items-center gap-2",children:[Y.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:Y.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${e}%`}})}),Y.jsxs("span",{className:"text-xs text-gray-500",children:[e,"%"]})]})},FTo=t=>Object.entries(t).map(([e,n])=>`${e}: ${n}`).join(", "),OTo=({stats:t})=>{if(!t||Object.keys(t).length===0)return Y.jsx("span",{children:"-"});const e=Object.entries(t),n=FTo(t);return Y.jsxs("details",{className:"cursor-pointer",children:[Y.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:n}),Y.jsx("div",{className:"mt-1 text-xs",children:e.map(([o,i])=>Y.jsxs("div",{children:[o,": ",String(i)]},o))})]})},g8e=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(g8e);const e={};for(const[n,o]of Object.entries(t))n.startsWith("_")||(e[n]=g8e(o));return e},GTo=(t,e)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${e}`);return}const n=g8e(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)}`)}},UTo=({solver:t,onStepUntilPhase:e,onDownloadInput:n})=>{const o=t.pipelineDef.map((a,c)=>kTo(t,c)),i=a=>{e?.(a)},r=a=>{a.solverInstance&&(n?n(a.solverInstance,a.name):GTo(a.solverInstance,a.name))},s=a=>`${(a/1e3).toFixed(2)}s`;return Y.jsxs("div",{className:"border-t border-gray-200",children:[Y.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:Y.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),Y.jsx("div",{className:"overflow-x-auto",children:Y.jsxs("table",{className:"w-full text-sm",children:[Y.jsx("thead",{children:Y.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[Y.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),Y.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),Y.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",Y.jsx("sub",{children:"0"})]}),Y.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),Y.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),Y.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),Y.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),Y.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),Y.jsx("tbody",{children:o.map(a=>Y.jsxs("tr",{className:`border-b border-gray-100 ${a.status==="In Progress"?"bg-yellow-50":""}`,children:[Y.jsx("td",{className:"px-4 py-2",children:Y.jsxs("div",{className:"flex items-center gap-2",children:[Y.jsx("span",{className:"text-gray-400 w-6",children:String(a.index+1).padStart(2,"0")}),Y.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:Y.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:Y.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"})})}),Y.jsx("span",{className:"font-medium text-gray-900",children:a.name})]})}),Y.jsx("td",{className:"px-4 py-2",children:Y.jsx(LTo,{status:a.status})}),Y.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:a.firstIteration!==null?a.firstIteration:""}),Y.jsx("td",{className:"px-4 py-2 text-gray-600",children:a.iterations}),Y.jsx("td",{className:"px-4 py-2",children:Y.jsx(HTo,{progress:a.progress})}),Y.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(a.timeSpent)}),Y.jsx("td",{className:"px-4 py-2 text-gray-500",children:Y.jsx(OTo,{stats:a.stats})}),Y.jsx("td",{className:"px-4 py-2",children:a.solverInstance?Y.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:[Y.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:Y.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"})}),Y.jsx("span",{children:"Input"})]}):null})]},a.name))})]})})]})},zTo=class extends Wr.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 VTo({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,x=p.height??0;A(g,f),A(g+y,f+x)}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,h=a-u,_=Math.max(1,c-s+2*u),m=Math.max(1,l-a+2*u);return Y.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${d} ${h} ${_} ${m}`,role:"img","aria-label":"Graphics fallback",children:[o.map((p,g)=>Y.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)=>Y.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)=>Y.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)=>Y.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)=>Y.jsx("text",{x:p.x??0,y:p.y??0,fontSize:p.fontSize??10,fill:p.color??"black",children:p.text??""},`text-${g}`))]})}var YTo=({solver:t,animationSpeed:e=25,onSolverStarted:n,onSolverCompleted:o})=>{const[i,r]=X.useReducer(A=>A+1,0),s=X.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(A){return console.error("Visualization error:",A),{points:[],lines:[],rects:[],circles:[]}}},[t,i]),a=X.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);X.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 Y.jsxs("div",{children:[Y.jsx(NTo,{solver:t,triggerRender:r,animationSpeed:e,onSolverStarted:n,onSolverCompleted:o}),a?Y.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):Y.jsx(zTo,{fallback:Y.jsx(VTo,{graphics:s}),children:Y.jsx(DTo,{graphics:s})}),c&&Y.jsx(UTo,{solver:t,onStepUntilPhase:l})]})};const KTo=()=>{X.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)},[])},WTo=1e3,XE=(t,e)=>{const{fileName:n,mimeType:o="text/plain"}=e,i=t instanceof Blob?t:new Blob([t],{type:o}),r=URL.createObjectURL(i),s=document.createElement("a");s.href=r,s.download=n,s.target="_blank",s.rel="noopener noreferrer",s.style.display="none",document.body.appendChild(s),s.click(),document.body.removeChild(s),setTimeout(()=>{URL.revokeObjectURL(r)},WTo)},bwt=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"},$E="https://github.com/tscircuit/tscircuit-autorouter/issues/new",Swt="https://github.com/tscircuit/copper-pour-solver/issues/new",Pwt="https://github.com/tscircuit/calculate-packing/issues/new",vwt="https://github.com/tscircuit/schematic-trace-solver/issues/new?template=json-bug-report.yml",jTo={PackSolver2:Pwt,AutoroutingPipelineSolver:$E,AssignableAutoroutingPipeline2:$E,AssignableAutoroutingPipeline3:$E,AutoroutingPipeline1_OriginalUnravel:$E,AutoroutingPipelineSolver3_HgPortPointPathing:$E,AutoroutingPipelineSolver4:$E,AutoroutingPipelineSolver5:$E,AutoroutingPipelineSolver7_MultiGraph:$E,AutoroutingPipelineSolver8:$E,CopperPourPipelineSolver:Swt,SchematicTracePipelineSolver:vwt},XTo=t=>t.toLowerCase().includes("pack")?g2o:t.toLowerCase().includes("rout")?I2o:o2o,Bwt=t=>{const e=jTo[t];if(e)return e;const n=t.toLowerCase();return n.includes("autorout")?$E:n.includes("schematic")&&n.includes("trace")?vwt:n.includes("copperpour")?Swt:n.includes("pack")?Pwt:null},$To=t=>`${bwt(`${t.componentName}-${t.solverName}`)}-solver-input.json`,Mwt=t=>{XE(JSON.stringify(t.solverParams,null,2),{fileName:$To(t),mimeType:"application/json"})},JTo=({solverEvent:t})=>{const e=Bwt(t.solverName);return Y.jsxs("div",{className:"rf-flex rf-items-center rf-justify-end rf-gap-2 rf-border-b rf-border-gray-200 rf-bg-gray-50 rf-px-4 rf-py-2",children:[Y.jsxs(Ya,{type:"button",variant:"outline",size:"sm",onClick:()=>Mwt(t),children:[Y.jsx($ve,{className:"rf-w-4 rf-h-4"}),"Download"]}),e?Y.jsx(Ya,{asChild:!0,variant:"outline",size:"sm",children:Y.jsxs("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:[Y.jsx(ute,{className:"rf-w-4 rf-h-4"}),"Report"]})}):Y.jsxs(Ya,{type:"button",variant:"outline",size:"sm",disabled:!0,title:"No report link configured for this solver",children:[Y.jsx(ute,{className:"rf-w-4 rf-h-4"}),"Report"]})]})},qTo=({solverEvent:t})=>{const e=Bwt(t.solverName);return e?Y.jsx(Ya,{asChild:!0,variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8",children:Y.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",title:"Report solver bug","aria-label":"Report solver bug",children:Y.jsx(ute,{className:"rf-w-4 rf-h-4"})})}):Y.jsx(Ya,{type:"button",variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8",disabled:!0,title:"No report link configured for this solver","aria-label":"Report solver bug",children:Y.jsx(ute,{className:"rf-w-4 rf-h-4"})})},ZTo=({solverEvents:t=[]})=>{const[e,n]=X.useState(null);KTo();const o=X.useMemo(()=>{const a=new Map;for(const c of t){const l=`${c.componentName}-${c.solverName}`;a.set(l,c)}return a},[t]),i=X.useMemo(()=>Array.from(o.keys()),[o]),r=e?o.get(e):null,s=X.useMemo(()=>{if(!r)return{instance:null,error:null,classFound:!1};const a=bpe[r.solverName];if(!a)return{instance:null,error:`Solver class "${r.solverName}" not found in SOLVERS registry. Available: ${Object.keys(bpe).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?Y.jsx("div",{className:"rf-p-4",children:Y.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:Y.jsxs("div",{className:"rf-p-4",children:[Y.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),Y.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."})]})})}):Y.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[Y.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[Y.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 Y.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=XTo(c.solverName);return Y.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[Y.jsx(A,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),Y.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[Y.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:c.componentName}),Y.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:c.solverName})]})]})})()},a)})]}),Y.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:r?s.instance?Y.jsxs("div",{className:"rf-flex rf-h-full rf-flex-col rf-overflow-y-auto",children:[Y.jsx(JTo,{solverEvent:r}),Y.jsx("div",{className:"rf-min-h-0 rf-flex-1",children:Y.jsx(MI,{fallback:Y.jsx("div",{className:"rf-p-4",children:Y.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[Y.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),Y.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",r.solverName]})]})}),children:Y.jsx(YTo,{solver:s.instance})})})]}):Y.jsxs("div",{className:"rf-p-4",children:[Y.jsxs("div",{className:"rf-mb-4",children:[Y.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:r.solverName}),Y.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",r.componentName]})]}),s.error&&Y.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:Y.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),Y.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[Y.jsxs("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50 rf-flex rf-items-center rf-justify-between rf-gap-2",children:[Y.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"}),Y.jsxs("div",{className:"rf-flex rf-items-center rf-gap-1",children:[Y.jsx(qTo,{solverEvent:r}),Y.jsx(Ya,{type:"button",variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8","aria-label":"Download solver input JSON",title:"Download solver input JSON",onClick:()=>Mwt(r),children:Y.jsx($ve,{className:"rf-w-4 rf-h-4"})})]})]}),Y.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:Y.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)})})]})]}):Y.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:Y.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},wwt=({errorMessage:t,errorStack:e,circuitJsonErrors:n})=>{X.useEffect(()=>{if(t){const o=new Error(t);e&&(o.stack=e);try{cT.captureException(o)}catch{}}},[t,e]),X.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{cT.captureException(i,{error_type:o.type})}catch{}}},[n])},Dwt=t=>{X.useEffect(()=>{try{oHn(t)}catch{}},[t.source,t.component,t.isWebEmbedded,t.activeTab])},Twt="0.0.2203",eQo={version:Twt},Coe=lat()(Aat(t=>({lastRunEvalVersion:void 0,setLastRunEvalVersion:e=>{t({lastRunEvalVersion:e})}}),{name:"runframe-runner-store"})),tQo=t=>{const[e,n]=X.useState([]),[o,i]=X.useState(null),[r,s]=X.useState(""),[a,c]=FD("eval-version-selection",null),l=Coe(h=>h.setLastRunEvalVersion),A=Coe(h=>h.lastRunEvalVersion);return X.useEffect(()=>{t&&fetch("https://data.jsdelivr.com/v1/package/npm/@tscircuit/eval").then(h=>h.json()).then(h=>{if(Array.isArray(h?.versions)){let _=[...h.versions];h.tags?.latest&&(i(h.tags.latest),_=_.filter(m=>m!==h.tags.latest)),n(_)}}).catch(()=>{})},[t]),X.useEffect(()=>{t&&(a?(window.TSCIRCUIT_LATEST_EVAL_VERSION=a,l(a)):o&&(window.TSCIRCUIT_LATEST_EVAL_VERSION=o,l(o)))},[t,a,o]),{versions:X.useMemo(()=>e.filter(h=>h.includes(r)).slice(0,50),[e,r]),latestVersion:o,lastRunEvalVersion:A,search:r,setSearch:s,selectVersion:h=>{c(h),s("")}}},nQo=({snippetNames:t,onSelect:e,onCancel:n,isOpen:o})=>{const[i,r]=X.useState(""),[s,a]=X.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 Y.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:Y.jsxs("div",{className:"rf-bg-white rf-rounded-lg rf-p-6 rf-w-96",children:[Y.jsx("h2",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Select Snippet"}),Y.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}),Y.jsxs("div",{className:"rf-h-60 rf-overflow-y-auto",children:[c.map(u=>Y.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&&Y.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,'"']})]}),Y.jsxs("div",{className:"rf-mt-4 rf-flex rf-justify-end rf-gap-2",children:[Y.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-text-gray-600 rf-hover:text-gray-800",onClick:n,children:"Cancel"}),Y.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}`})]})]})})},oQo=t=>{const e=X.useRef(null),n=T0(o=>o.recentEvents);X.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 Ioe="Dialog",[Qwt,Nwt]=v5(Ioe),[iQo,n4]=Qwt(Ioe),Eoe=t=>{const{__scopeDialog:e,children:n,open:o,defaultOpen:i,onOpenChange:r,modal:s=!0}=t,a=X.useRef(null),c=X.useRef(null),[l,A]=r3({prop:o,defaultProp:i??!1,onChange:r,caller:Ioe});return Y.jsx(iQo,{scope:e,triggerRef:a,contentRef:c,contentId:Tp(),titleId:Tp(),descriptionId:Tp(),open:l,onOpenChange:A,onOpenToggle:X.useCallback(()=>A(u=>!u),[A]),modal:s,children:n})};Eoe.displayName=Ioe;var Rwt="DialogTrigger",kwt=X.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,i=n4(Rwt,n),r=yu(e,i.triggerRef);return Y.jsx(Ua.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":y8e(i.open),...o,ref:r,onClick:wr(t.onClick,i.onOpenToggle)})});kwt.displayName=Rwt;var p8e="DialogPortal",[rQo,Lwt]=Qwt(p8e,{forceMount:void 0}),boe=t=>{const{__scopeDialog:e,forceMount:n,children:o,container:i}=t,r=n4(p8e,e);return Y.jsx(rQo,{scope:e,forceMount:n,children:X.Children.map(o,s=>Y.jsx(Gx,{present:n||r.open,children:Y.jsx(Pte,{asChild:!0,container:i,children:s})}))})};boe.displayName=p8e;var Soe="DialogOverlay",rU=X.forwardRef((t,e)=>{const n=Lwt(Soe,t.__scopeDialog),{forceMount:o=n.forceMount,...i}=t,r=n4(Soe,t.__scopeDialog);return r.modal?Y.jsx(Gx,{present:o||r.open,children:Y.jsx(aQo,{...i,ref:e})}):null});rU.displayName=Soe;var sQo=M8("DialogOverlay.RemoveScroll"),aQo=X.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,i=n4(Soe,n),r=L2o(),s=yu(e,r);return Y.jsx(Nte,{as:sQo,allowPinchZoom:!0,shards:[i.contentRef],children:Y.jsx(Ua.div,{"data-state":y8e(i.open),...o,ref:s,style:{pointerEvents:"auto",...o.style}})})}),pN="DialogContent",sU=X.forwardRef((t,e)=>{const n=Lwt(pN,t.__scopeDialog),{forceMount:o=n.forceMount,...i}=t,r=n4(pN,t.__scopeDialog);return Y.jsx(Gx,{present:o||r.open,children:r.modal?Y.jsx(cQo,{...i,ref:e}):Y.jsx(lQo,{...i,ref:e})})});sU.displayName=pN;var cQo=X.forwardRef((t,e)=>{const n=n4(pN,t.__scopeDialog),o=X.useRef(null),i=yu(e,n.contentRef,o);return X.useEffect(()=>{const r=o.current;if(r)return C3e(r)},[]),Y.jsx(Hwt,{...t,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:wr(t.onCloseAutoFocus,r=>{r.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:wr(t.onPointerDownOutside,r=>{const s=r.detail.originalEvent,a=s.button===0&&s.ctrlKey===!0;(s.button===2||a)&&r.preventDefault()}),onFocusOutside:wr(t.onFocusOutside,r=>r.preventDefault())})}),lQo=X.forwardRef((t,e)=>{const n=n4(pN,t.__scopeDialog),o=X.useRef(!1),i=X.useRef(!1);return Y.jsx(Hwt,{...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()}})}),Hwt=X.forwardRef((t,e)=>{const{__scopeDialog:n,trapFocus:o,onOpenAutoFocus:i,onCloseAutoFocus:r,...s}=t,a=n4(pN,n);return e3e(),Y.jsx(Y.Fragment,{children:Y.jsx(_te,{asChild:!0,loop:!0,trapped:o,onMountAutoFocus:i,onUnmountAutoFocus:r,children:Y.jsx(WO,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":y8e(a.open),...s,ref:e,deferPointerDownOutside:!0,onDismiss:()=>a.onOpenChange(!1)})})})}),Fwt="DialogTitle",Poe=X.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,i=n4(Fwt,n);return Y.jsx(Ua.h2,{id:i.titleId,...o,ref:e})});Poe.displayName=Fwt;var Owt="DialogDescription",voe=X.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,i=n4(Owt,n);return Y.jsx(Ua.p,{id:i.descriptionId,...o,ref:e})});voe.displayName=Owt;var Gwt="DialogClose",f8e=X.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,i=n4(Gwt,n);return Y.jsx(Ua.button,{type:"button",...o,ref:e,onClick:wr(t.onClick,()=>i.onOpenChange(!1))})});f8e.displayName=Gwt;function y8e(t){return t?"open":"closed"}var Uwt="AlertDialog",[AQo]=v5(Uwt,[Nwt]),KS=Nwt(),zwt=t=>{const{__scopeAlertDialog:e,...n}=t,o=KS(e);return Y.jsx(Eoe,{...o,...n,modal:!0})};zwt.displayName=Uwt;var uQo="AlertDialogTrigger",dQo=X.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,i=KS(n);return Y.jsx(kwt,{...i,...o,ref:e})});dQo.displayName=uQo;var _Qo="AlertDialogPortal",Vwt=t=>{const{__scopeAlertDialog:e,...n}=t,o=KS(e);return Y.jsx(boe,{...o,...n})};Vwt.displayName=_Qo;var hQo="AlertDialogOverlay",Ywt=X.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,i=KS(n);return Y.jsx(rU,{...i,...o,ref:e})});Ywt.displayName=hQo;var Kwt="AlertDialogContent",[mQo,gQo]=AQo(Kwt),Wwt=X.forwardRef((t,e)=>{const{__scopeAlertDialog:n,children:o,...i}=t,r=KS(n),s=X.useRef(null),a=yu(e,s),c=X.useRef(null);return Y.jsx(mQo,{scope:n,cancelRef:c,children:Y.jsx(sU,{role:"alertdialog",...r,...i,ref:a,onOpenAutoFocus:wr(i.onOpenAutoFocus,l=>{l.preventDefault(),c.current?.focus({preventScroll:!0})}),onPointerDownOutside:l=>l.preventDefault(),onInteractOutside:l=>l.preventDefault(),children:o})})});Wwt.displayName=Kwt;var pQo="AlertDialogTitle",jwt=X.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,i=KS(n);return Y.jsx(Poe,{...i,...o,ref:e})});jwt.displayName=pQo;var fQo="AlertDialogDescription",Xwt=X.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,i=KS(n);return Y.jsx(voe,{...i,...o,ref:e})});Xwt.displayName=fQo;var yQo="AlertDialogAction",$wt=X.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,i=KS(n);return Y.jsx(f8e,{...i,...o,ref:e})});$wt.displayName=yQo;var Jwt="AlertDialogCancel",qwt=X.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,{cancelRef:i}=gQo(Jwt,n),r=KS(n),s=yu(e,i);return Y.jsx(f8e,{...r,...o,ref:s})});qwt.displayName=Jwt;var xQo=zwt,CQo=Vwt,Zwt=Ywt,eDt=Wwt,tDt=$wt,nDt=qwt,oDt=jwt,iDt=Xwt;const rDt=xQo,IQo=CQo,sDt=X.forwardRef(({className:t,...e},n)=>Y.jsx(Zwt,{className:zi("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}));sDt.displayName=Zwt.displayName;const x8e=X.forwardRef(({className:t,...e},n)=>Y.jsxs(IQo,{children:[Y.jsx(sDt,{}),Y.jsx(eDt,{ref:n,className:zi("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})]}));x8e.displayName=eDt.displayName;const C8e=({className:t,...e})=>Y.jsx("div",{className:zi("rf-flex rf-flex-col rf-space-y-2 rf-text-center sm:rf-text-left",t),...e});C8e.displayName="AlertDialogHeader";const I8e=({className:t,...e})=>Y.jsx("div",{className:zi("rf-flex rf-flex-col-reverse sm:rf-flex-row sm:rf-justify-end sm:rf-space-x-2",t),...e});I8e.displayName="AlertDialogFooter";const E8e=X.forwardRef(({className:t,...e},n)=>Y.jsx(oDt,{ref:n,className:zi("rf-text-lg rf-font-semibold",t),...e}));E8e.displayName=oDt.displayName;const b8e=X.forwardRef(({className:t,...e},n)=>Y.jsx(iDt,{ref:n,className:zi("rf-text-sm rf-text-zinc-500 dark:rf-text-zinc-400",t),...e}));b8e.displayName=iDt.displayName;const EQo=X.forwardRef(({className:t,...e},n)=>Y.jsx(tDt,{ref:n,className:zi(QQ(),t),...e}));EQo.displayName=tDt.displayName;const S8e=X.forwardRef(({className:t,...e},n)=>Y.jsx(nDt,{ref:n,className:zi(QQ({variant:"outline"}),"rf-mt-2 sm:rf-mt-0",t),...e}));S8e.displayName=nDt.displayName;function bQo(t){const e=X.useRef({value:t,previous:t});return X.useMemo(()=>(e.current.value!==t&&(e.current.previous=e.current.value,e.current.value=t),e.current.previous),[t])}var Boe="Checkbox",[SQo]=v5(Boe),[PQo,P8e]=SQo(Boe);function vQo(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,h]=r3({prop:n,defaultProp:i??!1,onChange:c,caller:Boe}),[_,m]=X.useState(null),[p,g]=X.useState(null),f=X.useRef(!1),y=_?!!s||!!_.closest("form"):!0,x={checked:d,disabled:r,setChecked:h,control:_,setControl:m,name:a,form:s,value:A,hasConsumerStoppedPropagationRef:f,required:l,defaultChecked:m6(i)?!1:i,isFormControl:y,bubbleInput:p,setBubbleInput:g};return Y.jsx(PQo,{scope:e,...x,children:BQo(u)?u(x):o})}var aDt="CheckboxTrigger",cDt=X.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:h,bubbleInput:_}=P8e(aDt,t),m=yu(i,A),p=X.useRef(c);return X.useEffect(()=>{const g=r?.form;if(g){const f=()=>u(p.current);return g.addEventListener("reset",f),()=>g.removeEventListener("reset",f)}},[r,u]),Y.jsx(Ua.button,{type:"button",role:"checkbox","aria-checked":m6(c)?"mixed":c,"aria-required":l,"data-state":_Dt(c),"data-disabled":a?"":void 0,disabled:a,value:s,...o,ref:m,onKeyDown:wr(e,g=>{g.key==="Enter"&&g.preventDefault()}),onClick:wr(n,g=>{u(f=>m6(f)?!0:!f),_&&h&&(d.current=g.isPropagationStopped(),d.current||g.stopPropagation())})})});cDt.displayName=aDt;var v8e=X.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 Y.jsx(vQo,{__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})=>Y.jsxs(Y.Fragment,{children:[Y.jsx(cDt,{...u,ref:e,__scopeCheckbox:n}),d&&Y.jsx(dDt,{__scopeCheckbox:n})]})})});v8e.displayName=Boe;var lDt="CheckboxIndicator",ADt=X.forwardRef((t,e)=>{const{__scopeCheckbox:n,forceMount:o,...i}=t,r=P8e(lDt,n);return Y.jsx(Gx,{present:o||m6(r.checked)||r.checked===!0,children:Y.jsx(Ua.span,{"data-state":_Dt(r.checked),"data-disabled":r.disabled?"":void 0,...i,ref:e,style:{pointerEvents:"none",...t.style}})})});ADt.displayName=lDt;var uDt="CheckboxBubbleInput",dDt=X.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:h}=P8e(uDt,t),_=yu(n,h),m=bQo(r),p=oSt(o);X.useEffect(()=>{const f=d;if(!f)return;const y=window.HTMLInputElement.prototype,C=Object.getOwnPropertyDescriptor(y,"checked").set,E=!i.current;if(m!==r&&C){const b=new Event("click",{bubbles:E});f.indeterminate=m6(r),C.call(f,m6(r)?!1:r),f.dispatchEvent(b)}},[d,m,r,i]);const g=X.useRef(m6(r)?!1:r);return Y.jsx(Ua.input,{type:"checkbox","aria-hidden":!0,defaultChecked:s??g.current,required:a,disabled:c,name:l,value:A,form:u,...e,tabIndex:-1,ref:_,style:{...e.style,...p,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});dDt.displayName=uDt;function BQo(t){return typeof t=="function"}function m6(t){return t==="indeterminate"}function _Dt(t){return m6(t)?"indeterminate":t?"checked":"unchecked"}const aU=X.forwardRef(({className:t,...e},n)=>Y.jsx(v8e,{ref:n,className:zi("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:Y.jsx(ADt,{className:zi("rf-flex rf-items-center rf-justify-center rf-text-current"),children:Y.jsx(w9,{className:"rf-h-4 rf-w-4"})})}));aU.displayName=v8e.displayName;const fN=Eoe,MQo=boe,hDt=X.forwardRef(({className:t,...e},n)=>Y.jsx(rU,{className:zi("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}));hDt.displayName=rU.displayName;const tM=X.forwardRef(({className:t,children:e,showOverlay:n=!0,...o},i)=>Y.jsxs(MQo,{children:[Y.jsx(hDt,{className:zi(n?"":"rf-hidden")}),Y.jsx(sU,{ref:i,className:zi("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})]}));tM.displayName=sU.displayName;const nM=({className:t,...e})=>Y.jsx("div",{className:zi("rf-flex rf-flex-col rf-space-y-2 rf-text-center sm:rf-text-left",t),...e});nM.displayName="DialogHeader";const cU=({className:t,...e})=>Y.jsx("div",{className:zi("rf-flex rf-flex-col-reverse sm:rf-flex-row sm:rf-justify-end sm:rf-space-x-2",t),...e});cU.displayName="DialogFooter";const oM=X.forwardRef(({className:t,...e},n)=>Y.jsx(Poe,{ref:n,className:zi("rf-text-lg rf-font-semibold",t),...e}));oM.displayName=Poe.displayName;const yN=X.forwardRef(({className:t,...e},n)=>Y.jsx(voe,{ref:n,className:zi("rf-text-sm rf-text-zinc-500 dark:rf-text-zinc-400",t),...e}));yN.displayName=voe.displayName;const Moe={"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"}},wQo="https://cdn.jsdelivr.net/npm/easyeda@latest/dist/browser/index.js";let B8e=null;const M8e=async()=>(B8e||(B8e=import(wQo)),B8e),DQo=t=>(e,n)=>{const o=new Headers(n?.headers),i={};return o.forEach((r,s)=>{i[s]=r}),fetch(`${t?.apiBase??Z1}/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}})},TQo=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??[]},QQo=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}),mDt=async(t,e)=>{const{fetchEasyEDAComponent:n}=await M8e();return n(t,{fetch:DQo(e),includeModelMetadata:e?.includeModelMetadata})},NQo=async(t,e)=>{const{convertRawEasyToTsx:n}=await M8e(),o=await mDt(t,e);return n({rawEasy:o})},RQo=async(t,e)=>{const{EasyEdaJsonSchema:n,convertEasyEdaJsonToCircuitJson:o}=await M8e(),i=await mDt(t,{...e,includeModelMetadata:!1}),r=n.parse(i);return o(r,{shouldRecenter:!0,showDesignator:!0,useModelCdn:!1})};function g6(t){return Array.isArray?Array.isArray(t):pDt(t)==="[object Array]"}function kQo(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 w8e(t){return t==null?"":kQo(t)}function _2(t){return typeof t=="string"}function woe(t){return typeof t=="number"}function LQo(t){return t===!0||t===!1||HQo(t)&&pDt(t)=="[object Boolean]"}function gDt(t){return typeof t=="object"}function HQo(t){return gDt(t)&&t!==null}function lC(t){return t!=null}function Doe(t){return!t.trim().length}function pDt(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const FQo="Incorrect 'index' type",D8e="Invalid doc index: must be a non-negative integer within the bounds of the docs array",OQo=t=>`Invalid value for key ${t}`,GQo=t=>`Pattern length exceeds max of ${t}.`,UQo=t=>`Missing ${t} property in key`,zQo=t=>`Property 'weight' in key '${t}' must be a positive integer`,VQo="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.",fDt=Object.prototype.hasOwnProperty;var YQo=class{constructor(t){this._keys=[],this._keyMap={};let e=0;t.forEach(n=>{const o=yDt(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 yDt(t){let e=null,n=null,o=null,i=1,r=null;if(_2(t)||g6(t))o=t,e=xDt(t),n=Toe(t);else{if(!fDt.call(t,"name"))throw new Error(UQo("name"));const s=t.name;if(o=s,fDt.call(t,"weight")&&t.weight!==void 0&&(i=t.weight,i<=0))throw new Error(zQo(Toe(s)));e=xDt(s),n=Toe(s),r=t.getFn??null}return{path:e,id:n,weight:i,src:o,getFn:r}}function xDt(t){return g6(t)?t:t.split(".")}function Toe(t){return g6(t)?t.join("."):t}function KQo(t,e){const n=[];let o=!1;const i=(r,s,a,c)=>{if(lC(r))if(!s[a])n.push(c!==void 0?{v:r,i:c}:r);else{const l=r[s[a]];if(!lC(l))return;if(a===s.length-1&&(_2(l)||woe(l)||LQo(l)||typeof l=="bigint"))n.push(c!==void 0?{v:w8e(l),i:c}:w8e(l));else if(g6(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,_2(e)?e.split("."):e,0),o?n:n[0]}const vs=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:KQo,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1}});function WQo(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 T8e=class{constructor({getFn:t=vs.getFn,fieldNormWeight:e=vs.fieldNormWeight}={}){this.norm=WQo(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(_2(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(D8e);if(_2(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(D8e);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!lC(t)||Doe(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(lC(s)){if(g6(s)){const a=[];for(let c=0,l=s.length;c<l;c+=1){const A=s[c];if(lC(A)){if(_2(A)){if(!Doe(A)){const u={v:A,i:c,n:this.norm.get(A)};a.push(u)}}else if(lC(A.v)){const u=_2(A.v)?A.v:w8e(A.v);if(!Doe(u)){const d={v:u,i:A.i,n:this.norm.get(u)};a.push(d)}}}}n.$[o]=a}else if(_2(s)&&!Doe(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 CDt(t,e,{getFn:n=vs.getFn,fieldNormWeight:o=vs.fieldNormWeight}={}){const i=new T8e({getFn:n,fieldNormWeight:o});return i.setKeys(t.map(yDt)),i.setSources(e),i.create(),i}function jQo(t,{getFn:e=vs.getFn,fieldNormWeight:n=vs.fieldNormWeight}={}){const{keys:o,records:i}=t,r=new T8e({getFn:e,fieldNormWeight:n});return r.setKeys(o),r.setIndexRecords(i),r}function XQo(t=[],e=vs.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 $Qo(t,e,n,{location:o=vs.location,distance:i=vs.distance,threshold:r=vs.threshold,findAllMatches:s=vs.findAllMatches,minMatchCharLength:a=vs.minMatchCharLength,includeMatches:c=vs.includeMatches,ignoreLocation:l=vs.ignoreLocation}={}){if(e.length>32)throw new Error(GQo(32));const A=e.length,u=t.length,d=Math.max(0,Math.min(o,u));let h=r,_=d;const m=(M,w)=>{const k=M/A;if(l)return k;const Q=Math.abs(d-w);return i?k+Q/i:Q?1:k},p=a>1||c,g=p?Array(u):[];let f;for(;(f=t.indexOf(e,_))>-1;){const M=m(0,f);if(h=Math.min(M,h),_=f+A,p){let w=0;for(;w<A;)g[f+w]=1,w+=1}}_=-1;let y=[],x=1,C=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)<=h?w=k:E=k,k=Math.floor((E-w)/2+w);E=k;let Q=Math.max(1,d-k+1);const O=s?u:Math.min(d+k,u)+A,F=Array(O+2);F[O+1]=(1<<M)-1;for(let z=O;z>=Q;z-=1){const K=z-1,$=n[t[K]];if(F[z]=(F[z+1]<<1|1)&$,M&&(F[z]|=(y[z+1]|y[z])<<1|1|y[z+1]),F[z]&b&&(x=m(M,K),x<=h)){if(h=x,_=K,C=M,_<=d)break;Q=Math.max(1,2*d-_)}}if(m(M+1,d)>h)break;y=F}if(p&&_>=0){const M=Math.min(u-1,_+A-1+C);for(let w=_;w<=M;w+=1)n[t[w]]&&(g[w]=1)}const P={isMatch:_>=0,score:Math.max(.001,x)};if(p){const M=XQo(g,a);M.length?c&&(P.indices=M):P.isMatch=!1}return P}function JQo(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 Q8e(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 IDt={ł:"l",Ł:"L",đ:"d",Đ:"D",ø:"o",Ø:"O",ħ:"h",Ħ:"H",ŧ:"t",Ŧ:"T",ı:"i",ß:"ss"},qQo=new RegExp("["+Object.keys(IDt).join("")+"]","g"),lU=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(qQo,e=>IDt[e]):t=>t;var N8e=class{constructor(t,{location:e=vs.location,threshold:n=vs.threshold,distance:o=vs.distance,includeMatches:i=vs.includeMatches,findAllMatches:r=vs.findAllMatches,minMatchCharLength:s=vs.minMatchCharLength,isCaseSensitive:a=vs.isCaseSensitive,ignoreDiacritics:c=vs.ignoreDiacritics,ignoreLocation:l=vs.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?lU(t):t,this.pattern=t,this.chunks=[],!this.pattern.length)return;const A=(d,h)=>{this.chunks.push({pattern:d,alphabet:JQo(d),startIndex:h})},u=this.pattern.length;if(u>32){let d=0;const h=u%32,_=u-h;for(;d<_;)A(this.pattern.substr(d,32),d),d+=32;if(h){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?lU(t):t,this.pattern===t){const _={isMatch:!0,score:0};return o&&(_.indices=[[0,t.length-1]]),_}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:_,alphabet:m,startIndex:p})=>{const{isMatch:g,score:f,indices:y}=$Qo(t,_,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 h={isMatch:d,score:d?u/this.chunks.length:1};return d&&o&&(h.indices=Q8e(A)),h}};const ZQo=new Set(["fuzzy","include"]);function eNo(t){return t.startsWith("inverse")}const R8e=[{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 N8e(t,{location:e.location??vs.location,threshold:e.threshold??vs.threshold,distance:e.distance??vs.distance,includeMatches:e.includeMatches??vs.includeMatches,findAllMatches:e.findAllMatches??vs.findAllMatches,minMatchCharLength:e.minMatchCharLength??vs.minMatchCharLength,isCaseSensitive:e.isCaseSensitive??vs.isCaseSensitive,ignoreDiacritics:e.ignoreDiacritics??vs.ignoreDiacritics,ignoreLocation:e.ignoreLocation??vs.ignoreLocation});return{type:"fuzzy",search(o){return n.searchIn(o)}}}}],EDt=R8e.length,tNo="\0",nNo="|";function oNo(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 bDt(t,e){const n=t.match(e);return n?n[1]:null}function iNo(t,e={}){return t.replace(/\\\|/g,tNo).split(nNo).map(n=>{const o=oNo(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<EDt;){const A=R8e[l],u=bDt(a,A.multiRegex);u&&(i.push(A.create(u,e)),c=!0)}if(!c)for(l=-1;++l<EDt;){const A=R8e[l],u=bDt(a,A.singleRegex);if(u){i.push(A.create(u,e));break}}}return i})}var rNo=class{constructor(t,{isCaseSensitive:e=vs.isCaseSensitive,ignoreDiacritics:n=vs.ignoreDiacritics,includeMatches:o=vs.includeMatches,minMatchCharLength:i=vs.minMatchCharLength,ignoreLocation:r=vs.ignoreLocation,findAllMatches:s=vs.findAllMatches,location:a=vs.location,threshold:c=vs.threshold,distance:l=vs.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?lU(t):t,this.pattern=t,this.query=iNo(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?lU(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,h=u.length;d<h;d+=1){const _=u[d],{isMatch:m,indices:p,score:g}=_.search(t);if(m)r+=1,a+=g,eNo(_.type)&&(c=!0),n&&(ZQo.has(_.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=Q8e(s)),d}}return{isMatch:!1,score:1}}};const k8e=[];function L8e(...t){k8e.push(...t)}function Qoe(t,e){for(let n=0,o=k8e.length;n<o;n+=1){const i=k8e[n];if(i.condition(t,e))return new i(t,e)}return new N8e(t,e)}const Noe={AND:"$and",OR:"$or"},H8e={PATH:"$path",PATTERN:"$val"},F8e=t=>!!(t[Noe.AND]||t[Noe.OR]),sNo=t=>!!t[H8e.PATH],aNo=t=>!g6(t)&&gDt(t)&&!F8e(t),SDt=t=>({[Noe.AND]:Object.keys(t).map(e=>({[e]:t[e]}))});function PDt(t,e,{auto:n=!0}={}){const o=i=>{if(_2(i)){const c={keyId:null,pattern:i};return n&&(c.searcher=Qoe(i,e)),c}const r=Object.keys(i),s=sNo(i);if(!s&&r.length>1&&!F8e(i))return o(SDt(i));if(aNo(i)){const c=s?i[H8e.PATH]:r[0],l=s?i[H8e.PATTERN]:i[c];if(!_2(l))throw new Error(OQo(c));const A={keyId:Toe(c),pattern:l};return n&&(A.searcher=Qoe(l,e)),A}const a={children:[],operator:r[0]};return r.forEach(c=>{const l=i[c];g6(l)&&l.forEach(A=>{a.children.push(o(A))})}),a};return F8e(t)||(t=SDt(t)),o(t)}function O8e(t,{ignoreFieldNorm:e=vs.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 cNo(t,{ignoreFieldNorm:e=vs.ignoreFieldNorm}){t.forEach(n=>{n.score=O8e(n.matches,{ignoreFieldNorm:e})})}var lNo=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 ANo(t){const e=[];return t.matches.forEach(n=>{if(!lC(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 uNo(t,e,{includeMatches:n=vs.includeMatches,includeScore:o=vs.includeScore}={}){return t.map(i=>{const{idx:r}=i,s={item:e[r],refIndex:r};return n&&(s.matches=ANo(i)),o&&(s.score=i.score),s})}const dNo=/[\p{L}\p{M}\p{N}_]+/gu,vDt=new WeakSet;function _No(t){vDt.has(t)||(vDt.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 hNo(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||_No(t),e=>e.match(t)||[]):e=>e.match(dNo)||[]}function G8e({isCaseSensitive:t=!1,ignoreDiacritics:e=!1,tokenize:n}={}){const o=hNo(n);return{tokenize(i){return t||(i=i.toLowerCase()),e&&(i=lU(i)),o(i)}}}var mNo=class{static condition(t,e){return e.useTokenSearch}constructor(t,e){this.options=e,this.analyzer=G8e({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 N8e(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=Q8e(e)),this.combineAll&&(this.useMask?c.matchedMask=r:c.matchedTerms=s,c.termCount=this.numTerms),c}};function U8e(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 BDt(t,e,n,o){const{i,v:r,$:s}=e;if(r!==void 0){U8e(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)U8e(t,l.v,i,o);else U8e(t,c.v,i,o)}}function gNo(t,e,n){const o={fieldCount:0,df:new Map,docFieldCount:new Map,docTermFieldHits:new Map};for(const i of t)BDt(o,i,e,n);return o}function pNo(t,e,n,o){BDt(t,e,n,o)}function fNo(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 MDt(t,e){if(e.length===0)return;const n=Array.from(new Set(e)).sort((a,c)=>a-c);for(const a of n)fNo(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 p6=class{constructor(t,e,n){this.options={...vs,...e},this.options.useExtendedSearch,this.options.useTokenSearch,this._keyStore=new YQo(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=Qoe(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 T8e))throw new Error(FQo);if(this._myIndex=e||CDt(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight}),this.options.useTokenSearch){const n=G8e({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});this._invertedIndex=gNo(this._myIndex.records,this._myIndex.keys.length,n)}this._invalidateSearcherCache()}add(t){if(!lC(t))return;this._docs.push(t);const e=this._myIndex.add(t,this._docs.length-1);if(this._invertedIndex&&e){const n=G8e({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});pNo(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&&MDt(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(D8e);this._invertedIndex&&MDt(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(_2(t)&&!t.trim()){let A=this._docs.map((u,d)=>({item:u,refIndex:d}));return woe(n)&&n>-1&&(A=A.slice(0,n)),A}const c=woe(n)&&n>0&&_2(t);let l;if(c){const A=new lNo(n);_2(this._docs[0])?this._searchStringList(t,{heap:A,ignoreFieldNorm:a}):this._searchObjectList(t,{heap:A,ignoreFieldNorm:a}),l=A.extractSorted(s)}else l=_2(t)?_2(this._docs[0])?this._searchStringList(t):this._searchObjectList(t):this._searchLogical(t),cNo(l,{ignoreFieldNorm:a}),r&&l.sort(s),woe(n)&&n>-1&&(l=l.slice(0,n));return uNo(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(!lC(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 h={item:a,idx:c,matches:d};e?(h.score=O8e(h.matches,{ignoreFieldNorm:n}),e.shouldInsert(h.score)&&e.insert(h)):s.push(h)}}}),s}_searchLogical(t){const e=PDt(t,this.options),n=(s,a,c)=>{if(!("children"in s)){const{keyId:d,searcher:h}=s;let _;return d===null?(_=[],this._myIndex.keys.forEach((m,p)=>{_.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}),_&&_.length?[{idx:c,item:a,matches:_}]:[]}const{children:l,operator:A}=s,u=[];for(let d=0,h=l.length;d<h;d+=1){const _=l[d],m=n(_,a,c);if(m.length)u.push(...m);else if(A===Noe.AND)return[]}return u},o=this._myIndex.records,i=new Map,r=[];return o.forEach(({$:s,i:a})=>{if(lC(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(!lC(c))return;const A=[];let u=!1,d=!1;if(r.forEach((h,_)=>{const m=this._findMatches({key:h,value:c[_],searcher:o});m.length?(A.push(...m),m[0].hasInverse&&(d=!0)):u=!0}),!(d&&u)&&A.length&&(!i||this._coversAllTokens(A))){const h={idx:l,item:c,matches:A};e?(h.score=O8e(h.matches,{ignoreFieldNorm:n}),e.shouldInsert(h.score)&&e.insert(h)):a.push(h)}}),a}_findMatches({key:t,value:e,searcher:n}){if(!lC(e))return[];const o=[];if(g6(e))e.forEach(({v:i,i:r,n:s})=>{if(!lC(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}};p6.version="7.4.2",p6.createIndex=CDt,p6.parseIndex=jQo,p6.config=vs,p6.match=function(t,e,n){if(n&&n.useTokenSearch)throw new Error(VQo);return Qoe(t,{...vs,...n}).searchIn(e)},p6.parseQuery=PDt,L8e(rNo),L8e(mNo),p6.use=function(...t){t.forEach(e=>L8e(e))};var yNo=p6;const xNo="https://kicad-mod-cache.tscircuit.com";let z8e=null,AU=null,V8e=null;const CNo=async()=>z8e||AU||(AU=fetch("https://kicad-mod-cache.tscircuit.com/kicad_files.json").then(t=>t.json()).then(t=>(z8e=t,AU=null,t)),AU),INo=async(t,e=20)=>{const n=await CNo();return V8e||(V8e=new yNo(n)),V8e.search(t).slice(0,e).map(o=>o.item)},ENo=t=>{const e=t.replace(".pretty/","/").replace(".kicad_mod",""),n=`kicad:${e}`;return{path:t,qualifiedName:n,description:e}},bNo=t=>t.replace(/^\/+/,"").split("/").map(e=>encodeURIComponent(e)).join("/"),SNo=async t=>{const e=await fetch(`${xNo}/${bNo(t)}`);if(!e.ok)throw new Error(`KiCad footprint fetch failed: ${e.status}`);const n=await e.text(),{KicadFootprintToCircuitJsonConverter:o}=await q5("kicad-to-circuit-json"),i=new o;return i.addFile(t.split("/").pop()??"selected-footprint.kicad_mod",n),i.runUntilFinished(),i.getOutput()},wDt=t=>t?.source==="jlcpcb"||t?.source==="kicad",PNo=async(t,e)=>{if(t.source==="jlcpcb")return RQo(t.component.partNumber,e?.jlcpcb);if(t.source==="kicad")return SNo(t.footprint.path);throw new Error("Footprint preview is not available for this source")},vNo=({query:t,placeholder:e,isSearching:n,onQueryChange:o,onSubmit:i})=>{const r=X.useCallback(s=>{s.key==="Enter"&&(s.preventDefault(),i())},[i]);return Y.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2 rf-mt-4",children:[Y.jsxs("div",{className:"rf-relative rf-flex-grow",children:[Y.jsx(Jve,{className:"rf-absolute rf-left-2 rf-top-2.5 rf-h-4 rf-w-4 rf-text-muted-foreground"}),Y.jsx(X6e,{placeholder:e,className:"rf-pl-8",spellCheck:!1,autoComplete:"off",value:t,onChange:s=>o(s.target.value),onKeyDown:r})]}),Y.jsx(Ya,{onClick:i,disabled:n||t.trim().length<1,className:"sm:rf-px-4 rf-px-3",children:n?Y.jsx(Y5,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):Y.jsxs(Y.Fragment,{children:[Y.jsx(Jve,{className:"rf-h-4 rf-w-4 sm:rf-hidden"}),Y.jsx("span",{className:"rf-hidden sm:rf-inline",children:"Search"})]})})]})},BNo=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}),MNo=t=>BNo.format(t),DDt=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"}},wNo=t=>{switch(t.source){case"tscircuit.com":return t.package.unscoped_name;case"jlcpcb":return t.component.manufacturer;case"kicad":return t.footprint.qualifiedName}},DNo=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}},TNo=t=>{switch(t.source){case"tscircuit.com":return t.package.name;case"jlcpcb":return t.component.partNumber;case"kicad":return}},QNo=({results:t,selected:e,onSelect:n,onShowDetails:o})=>{const i=e?DDt(e):null;return Y.jsx("div",{className:"rf-divide-y rf-w-full rf-overflow-hidden",children:t.map(r=>{const s=DDt(r),a=i===s,c=wNo(r),l=DNo(r),A=TNo(r),u=r.source==="jlcpcb"?r.component.stock:null,d=r.source==="jlcpcb"?r.component.price:null,h=r.source==="jlcpcb"?r.component.isBasic:null;return Y.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:[Y.jsxs("div",{className:"rf-min-w-0 rf-overflow-hidden rf-w-full",children:[Y.jsxs("div",{className:"rf-flex rf-items-start rf-gap-2 rf-min-w-0",children:[Y.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"&&h!=null&&Y.jsx("span",{className:`rf-text-xs rf-px-1.5 rf-py-0.5 rf-rounded rf-font-medium rf-flex-shrink-0 ${h?"rf-bg-green-100 rf-text-green-700":"rf-bg-orange-100 rf-text-orange-700"}`,children:h?"Basic":"Extended"}),r.source==="tscircuit.com"&&r.package.is_private&&Y.jsx(f2o,{className:"rf-ml-1 rf-h-3 rf-w-3 rf-text-zinc-400 rf-flex-shrink-0"})]}),r.source==="jlcpcb"&&u!=null?Y.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]}),Y.jsxs("div",{className:"rf-text-xs rf-text-zinc-500 rf-truncate rf-w-full",children:[A?Y.jsx("span",{className:"rf-mr-2",children:A}):null,l]})]}),Y.jsxs("div",{children:[r.source==="tscircuit.com"&&o?Y.jsx("div",{className:"rf-flex-shrink-0 rf-w-full sm:rf-w-auto",children:Y.jsx(Ya,{variant:"outline",size:"sm",className:"rf-text-xs rf-w-full sm:rf-w-auto",onClick:_=>{_.stopPropagation(),o(r)},children:"See Details"})}):r.source==="jlcpcb"&&u!=null?Y.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&&Y.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:MNo(d)})]})]},s)})})},NNo=({circuitJson:t,error:e,isLoading:n,height:o})=>Y.jsx("section",{className:"rf-flex rf-min-w-0 rf-items-center rf-justify-center",style:{height:o},children:n?Y.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:[Y.jsx(Y5,{className:"rf-h-4 rf-w-4 rf-animate-spin"}),"Loading preview..."]}):e?Y.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:Y.jsxs("div",{className:"rf-flex rf-max-w-[320px] rf-items-start rf-gap-2 rf-text-sm rf-text-zinc-300",children:[Y.jsx(Ibt,{className:"rf-mt-0.5 rf-h-4 rf-w-4 rf-flex-shrink-0"}),Y.jsx("span",{children:e})]})}):t?Y.jsx("div",{className:"rf-w-full rf-min-w-0 rf-overflow-hidden",children:Y.jsx(xwt,{circuitJson:t,height:o,allowEditing:!1,clickToInteractEnabled:!1,focusOnHover:!1,disablePcbGroups:!0})}):Y.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"})}),TDt={importComponentDialog:101,importComponentDetailsDialog:102},RNo=({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,h=l?.unscoped_name?.split("/").pop()??l?.unscoped_name,_=l?.org_owner_tscircuit_handle??void 0,m=_?`https://tscircuit.com/${_}`:void 0,p=_&&h?`https://tscircuit.com/${_}/${h}`:void 0;return Y.jsx(fN,{open:e,onOpenChange:n,children:Y.jsxs(tM,{showOverlay:!1,style:{width:"calc(100vw - 2rem)",zIndex:TDt.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:[Y.jsx(nM,{className:"rf-pb-4 rf-border-b",children:Y.jsx("div",{className:"rf-flex rf-items-start rf-justify-between rf-gap-4",children:Y.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[Y.jsx(oM,{className:"rf-text-xl rf-font-semibold rf-truncate",children:h}),Y.jsx(yN,{children:l?.description})]})})}),Y.jsxs("div",{className:"rf-flex-1 rf-overflow-y-auto rf-py-4 rf-space-y-6",children:[_?Y.jsxs("div",{children:[Y.jsx("span",{className:"rf-text-xs rf-font-medium rf-text-gray-500 rf-uppercase rf-tracking-wide",children:"Created by"}),Y.jsx("div",{className:"rf-mt-1 rf-text-sm rf-font-medium",children:m?Y.jsx("a",{href:m,target:"_blank",rel:"noopener noreferrer",className:"rf-text-black hover:rf-underline",children:_}):_})]}):null,(d||A||u)&&Y.jsx(Y.Fragment,{children:Y.jsxs("div",{children:[Y.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Preview"}),Y.jsxs(R1e,{value:r,onValueChange:g=>s(g),children:[Y.jsxs(fq,{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&&Y.jsx(mE,{value:"pcb",children:"PCB"}),u&&Y.jsx(mE,{value:"schematic",children:"Schematic"}),d&&Y.jsx(mE,{value:"3d",children:"3D"})]}),Y.jsxs("div",{className:"rf-mt-4",children:[Y.jsx(Wf,{value:"pcb",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:A?Y.jsx("img",{src:A,alt:`${h??"package"} PCB preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null}),Y.jsx(Wf,{value:"schematic",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:u?Y.jsx("img",{src:u,alt:`${h??"package"} schematic preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null}),Y.jsx(Wf,{value:"3d",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:d?Y.jsx("img",{src:d,alt:`${h??"package"} 3D preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null})]})]})]})}),i?.ai_description?Y.jsxs("section",{children:[Y.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-3",children:"AI Description"}),Y.jsx("div",{className:"rf-bg-gray-50 rf-border rf-border-gray-200 rf-rounded-lg rf-p-4",children:Y.jsx("p",{className:"rf-text-sm rf-text-gray-700 rf-leading-relaxed",children:i.ai_description})})]}):null,i?.ai_usage_instructions?Y.jsxs("section",{children:[Y.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-3",children:"Usage Instructions"}),Y.jsx("div",{className:"rf-bg-gray-50 rf-border rf-border-gray-200 rf-rounded-lg rf-p-4",children:Y.jsx("p",{className:"rf-text-sm rf-text-gray-700 rf-leading-relaxed rf-whitespace-pre-wrap",children:i.ai_usage_instructions})})]}):null,o?Y.jsxs("div",{className:"rf-flex rf-justify-center rf-items-center rf-gap-2 rf-text-gray-500",children:[Y.jsx(Y5,{className:"rf-h-4 rf-w-4 rf-animate-spin"}),Y.jsx("span",{className:"rf-text-sm",children:"Loading package details..."})]}):null]}),Y.jsxs(cU,{className:"rf-pt-4 rf-border-t rf-flex rf-flex-col sm:rf-flex-row rf-justify-between rf-gap-2",children:[Y.jsx("div",{className:"rf-flex-1",children:p?Y.jsxs(Ya,{variant:"outline",size:"sm",className:"rf-gap-2 rf-w-full sm:rf-w-auto",onClick:()=>window.open(p,"_blank"),children:[Y.jsx(u2o,{className:"rf-h-4 rf-w-4"}),"View on tscircuit.com"]}):null}),Y.jsxs("div",{className:"rf-flex rf-flex-col sm:rf-flex-row rf-gap-2",children:[Y.jsx(Ya,{variant:"outline",onClick:()=>n(!1),className:"rf-order-2 sm:rf-order-1",children:"Close"}),Y.jsx(Ya,{onClick:c,disabled:a,className:"rf-bg-blue-600 hover:rf-bg-blue-700",children:a?Y.jsx(Y5,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):"Import Component"})]})]})]})})},kNo=()=>{const[t,e]=X.useState(null),[n,o]=X.useState(!1),i=X.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=X.useCallback(()=>{e(null),o(!1)},[]);return{details:t,isLoading:n,fetchDetails:i,reset:r}},LNo=(t,e)=>{const[n,o]=X.useState({circuitJson:null,error:null,isLoading:!1});return X.useEffect(()=>{if(!t||!wDt(t)){o({circuitJson:null,error:null,isLoading:!1});return}let i=!1;return o({circuitJson:null,error:null,isLoading:!0}),PNo(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},HNo=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??[]},FNo=({sessionToken:t})=>{const[e,n]=X.useState([]),[o,i]=X.useState(!1),[r,s]=X.useState(null),[a,c]=X.useState(!1),l=X.useCallback(async u=>{const d=u.trim();if(!d)return[];i(!0),s(null);try{const _=(await HNo(d,t)).map(m=>({source:"tscircuit.com",package:m}));return n(_),_}catch(h){return console.error("Error searching tscircuit packages",h),n([]),s(h instanceof Error?h.message:"Failed to search tscircuit packages"),[]}finally{i(!1),c(!0)}},[t]),A=X.useCallback(()=>{n([]),i(!1),s(null),c(!1)},[]);return{results:e,isSearching:o,error:r,hasSearched:a,search:l,reset:A}},ONo=t=>{const e=t.trim();return/^C\d+/i.test(e)?e.replace(/^C/i,""):e},GNo=()=>{const[t,e]=X.useState([]),[n,o]=X.useState(!1),[i,r]=X.useState(null),[s,a]=X.useState(!1),c=X.useCallback(async A=>{const u=ONo(A);if(!u)return[];o(!0),r(null);try{const h=(await TQo(u,10)).map(_=>({source:"jlcpcb",component:QQo(_)}));return e(h),h}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=X.useCallback(()=>{e([]),o(!1),r(null),a(!1)},[]);return{results:t,isSearching:n,error:i,hasSearched:s,search:c,reset:l}},UNo=()=>{const[t,e]=X.useState([]),[n,o]=X.useState(!1),[i,r]=X.useState(null),[s,a]=X.useState(!1),c=X.useCallback(async A=>{const u=A.trim();if(!u)return[];o(!0),r(null);try{const h=(await INo(u,20)).map(_=>({source:"kicad",footprint:ENo(_)}));return e(h),h}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=X.useCallback(()=>{e([]),o(!1),r(null),a(!1)},[]);return{results:t,isSearching:n,error:i,hasSearched:s,search:c,reset:l}},zNo=({onTscircuitPackageSelected:t,onJlcpcbComponentTsxLoaded:e,onKicadStringSelected:n})=>{const o=[];return t&&o.push("tscircuit.com"),e&&o.push("jlcpcb"),n&&o.push("kicad"),o},VNo=({isOpen:t,onClose:e,jlcpcbProxyRequestHeaders:n,onKicadStringSelected:o,onTscircuitPackageSelected:i,onJlcpcbComponentTsxLoaded:r,jlcpcbProxyApiBase:s,tscircuitSessionToken:a})=>{xoe();const c=X.useMemo(()=>zNo({onKicadStringSelected:o,onTscircuitPackageSelected:i,onJlcpcbComponentTsxLoaded:r}),[o,i,r]),l=c.length>0,A=c.length===1,[u,d]=X.useState(c[0]??"tscircuit.com"),[h,_]=X.useState(""),[m,p]=X.useState(null),{results:g,isSearching:f,error:y,hasSearched:x,search:C,reset:E}=FNo({sessionToken:a}),{results:b,isSearching:P,error:M,hasSearched:w,search:k,reset:Q}=GNo(),{results:O,isSearching:F,error:z,hasSearched:K,search:$,reset:J}=UNo(),{details:oe,isLoading:ue,fetchDetails:ne,reset:ie}=kNo(),[ce,re]=X.useState(null),[le,xe]=X.useState(!1),[be,ve]=X.useState("pcb"),[_e,Pe]=X.useState(null),[pe,Ge]=X.useState(!1),Le=X.useMemo(()=>({jlcpcb:{headers:n,apiBase:s}}),[s,n]),{circuitJson:$e,error:fe,isLoading:Ze}=LNo(m,Le),Ue=wDt(m);X.useEffect(()=>{Pe(null)},[m]);const Qe=X.useCallback(()=>{E(),Q(),J(),p(null)},[Q,J,E]);X.useEffect(()=>{t||(Qe(),_(""),xe(!1),re(null),Pe(null))},[t,Qe]),X.useEffect(()=>{_(""),p(null),u==="tscircuit.com"?E():u==="jlcpcb"?Q():u==="kicad"&&J()},[u,Q,J,E]);const Ye=At=>{p(At),re(At),ve("pcb"),xe(!0),ie();const xt=At.package.org_owner_tscircuit_handle,Bt=At.package.unscoped_name;if(xt&&Bt){const ft=Bt.split("/").pop()??Bt;ne(xt,ft)}},Ne=async()=>{h.trim()&&(p(null),u==="tscircuit.com"?await C(h):u==="jlcpcb"?await k(h):u==="kicad"&&await $(h))},Ie=async At=>{try{if(Pe(null),Ge(!0),At.source==="kicad"){if(!o)throw new Error("KiCad handler not provided");await o({result:At,footprint:At.footprint.qualifiedName})}else if(At.source==="jlcpcb"){if(!r)throw new Error("JLCPCB handler not provided");const xt=await NQo(At.component.partNumber,{headers:n,apiBase:s});await r({result:At,tsx:xt})}else if(At.source==="tscircuit.com"){if(!i)throw new Error("tscircuit package handler not provided");const xt=At.package.org_owner_tscircuit_handle,Bt=At.package.unscoped_name;if(!xt||!Bt)throw new Error("Missing package metadata");const ft=Bt.split("/").pop()??Bt,Dt=`@tsci/${xt}.${ft}`;await i({result:At,fullPackageName:Dt})}return!0}catch(xt){return console.error("Failed to import component",xt),Pe(xt instanceof Error?xt.message:"Failed to import component"),!1}finally{Ge(!1)}};let Oe=[],Me=!1,We=null,Je=!1;u==="tscircuit.com"?(Oe=g,Me=f,We=y,Je=x):u==="jlcpcb"?(Oe=b,Me=P,We=M,Je=w):u==="kicad"&&(Oe=O,Me=F,We=z,Je=K);const ct=async()=>{if(!m)return;await Ie(m)&&(e(),Qe(),_(""))},lt=At=>{At||e()},dt=At=>{xe(At),At||re(null)};return Y.jsxs(fN,{open:t,onOpenChange:lt,children:[Y.jsxs(tM,{style:{width:"calc(100vw - 2rem)",maxWidth:Ue?"min(1120px, calc(100vw - 2rem))":"min(672px, calc(100vw - 2rem))",zIndex:TDt.importComponentDialog},className:"rf-rounded-sm rf-max-h-[90vh] rf-overflow-y-auto rf-overflow-x-hidden rf-flex rf-flex-col",children:[Y.jsxs(nM,{children:[Y.jsxs(oM,{className:"rf-text-lg sm:rf-text-xl",children:["Import ",A?Moe[u].label:""," ","Component"]}),Y.jsx(yN,{className:"rf-text-sm",children:l?"Search for components from available sources.":"Import options are disabled because no handlers were provided."})]}),l?Y.jsxs(R1e,{value:u,onValueChange:At=>d(At),className:"rf-min-w-0 rf-w-full",children:[!A&&Y.jsx(fq,{className:"rf-flex rf-w-full rf-gap-2",children:c.map(At=>Y.jsx(mE,{value:At,className:"rf-flex-1 rf-text-xs sm:rf-text-sm",children:Moe[At].label},At))}),Y.jsxs("div",{className:"rf-min-w-0",style:Ue?{display:"grid",gridTemplateColumns:"minmax(0, 1fr) minmax(360px, 0.95fr)",gap:"1.5rem",alignItems:"start"}:void 0,children:[Y.jsxs("div",{className:"rf-min-w-0",children:[Y.jsx(vNo,{query:h,placeholder:Moe[u].placeholder,isSearching:Me,onQueryChange:_,onSubmit:Ne}),Y.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?Y.jsxs("div",{className:"rf-p-8 rf-text-center rf-text-zinc-500",children:[Y.jsx(Y5,{className:"rf-h-8 rf-w-8 rf-animate-spin rf-mx-auto rf-mb-2"}),Y.jsx("p",{children:"Searching..."})]}):Oe.length>0?Y.jsx(QNo,{results:Oe,selected:m,onSelect:p,onShowDetails:u==="tscircuit.com"?Ye:void 0}):Y.jsx("div",{className:"rf-p-8 rf-text-center rf-text-zinc-500",children:We?`Error: ${We}`:Je?Moe[u].emptyMessage:"Enter a search term to find components"})})]}),Ue?Y.jsx("div",{className:"rf-mt-4",children:Y.jsx(NNo,{circuitJson:$e,error:fe,isLoading:Ze,height:325})}):null]})]}):null,_e?Y.jsx("div",{className:"rf-text-sm rf-text-red-600 rf-mt-2",children:_e}):null,Y.jsxs(cU,{className:"rf-flex rf-flex-col sm:rf-flex-row rf-gap-2",children:[Y.jsx(Ya,{variant:"outline",onClick:e,className:"rf-order-2 sm:rf-order-1",children:"Cancel"}),Y.jsx(Ya,{onClick:ct,disabled:!m||pe,className:"rf-order-1 sm:rf-order-2",children:pe?Y.jsx(Y5,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):"Import"})]})]}),Y.jsx(RNo,{packageResult:ce,isOpen:le,onOpenChange:dt,isLoading:ue,details:oe,previewTab:be,onPreviewTabChange:At=>ve(At),isSubmitting:pe,onImport:()=>{ce&&Ie(ce).then(At=>{At&&(xe(!1),e(),Qe(),_(""))})}})]})},YNo=t=>{const e=t.match(/export const (\w+) =/);if(!e)throw new Error("Could not determine component name from TSX contents");return e[1]},QDt=t=>{const e=T0(s=>s.pushEvent),n=T0(s=>s.upsertFile),o=async({result:s,fullPackageName:a})=>{const l=s.package.unscoped_name??s.package.name;await Os.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 Os.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/${YNo(a)}.tsx`;await Os.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 Y.jsx(VNo,{...t,onTscircuitPackageSelected:o,onKicadStringSelected:i,onJlcpcbComponentTsxLoaded:r})};QDt.displayName="ImportComponentDialogForCli";var Y8e={exports:{}},NDt;function KNo(){return NDt||(NDt=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 zP=="function"&&zP;if(!u&&d)return d(A,!0);if(c)return c(A,!0);var h=new Error("Cannot find module '"+A+"'");throw h.code="MODULE_NOT_FOUND",h}var _=r[A]={exports:{}};i[A][0].call(_.exports,function(m){var p=i[A][1][m];return a(p||m)},_,_.exports,o,i,r,s)}return r[A].exports}for(var c=typeof zP=="function"&&zP,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,x=y,C=s.getTypeOf(l)!=="string";f<l.length;)x=y-f,d=C?(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),h=A>>2,_=(3&A)<<4|u>>4,m=1<x?(15&u)<<2|d>>6:64,p=2<x?63&d:64,g.push(c.charAt(h)+c.charAt(_)+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,x=3*(l=l.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(l.charAt(l.length-1)===c.charAt(64)&&x--,l.charAt(l.length-2)===c.charAt(64)&&x--,x%1!=0)throw new Error("Invalid base64 input, bad content length.");for(y=a.uint8array?new Uint8Array(0|x):new Array(0|x);p<l.length;)A=c.indexOf(l.charAt(p++))<<2|(h=c.indexOf(l.charAt(p++)))>>4,u=(15&h)<<4|(_=c.indexOf(l.charAt(p++)))>>2,d=(3&_)<<6|(m=c.indexOf(l.charAt(p++))),y[g++]=A,_!==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=h,this.compression=_,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,h){return u.pipe(new c).pipe(new l("uncompressedSize")).pipe(d.compressWorker(h)).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,h){var _=a,m=h+d;A^=-1;for(var p=h;p<m;p++)A=A>>>8^_[255&(A^u[p])];return-1^A})(0|l,c,c.length,0):(function(A,u,d,h){var _=a,m=h+d;A^=-1;for(var p=h;p<m;p++)A=A>>>8^_[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,h){l.call(this,"FlateWorker/"+d),this._pako=null,this._pakoAction=d,this._pakoOptions=h,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(h){d.push({data:h,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(_,m){var p,g="";for(p=0;p<m;p++)g+=String.fromCharCode(255&_),_>>>=8;return g}function a(_,m,p,g,f,y){var x,C,E=_.file,b=_.compression,P=y!==A.utf8encode,M=c.transformTo("string",y(E.name)),w=c.transformTo("string",A.utf8encode(E.name)),k=E.comment,Q=c.transformTo("string",y(k)),O=c.transformTo("string",A.utf8encode(k)),F=w.length!==E.name.length,z=O.length!==k.length,K="",$="",J="",oe=E.dir,ue=E.date,ne={crc32:0,compressedSize:0,uncompressedSize:0};m&&!p||(ne.crc32=_.crc32,ne.compressedSize=_.compressedSize,ne.uncompressedSize=_.uncompressedSize);var ie=0;m&&(ie|=8),P||!F&&!z||(ie|=2048);var ce=0,re=0;oe&&(ce|=16),f==="UNIX"?(re=798,ce|=(function(xe,be){var ve=xe;return xe||(ve=be?16893:33204),(65535&ve)<<16})(E.unixPermissions,oe)):(re=20,ce|=(function(xe){return 63&(xe||0)})(E.dosPermissions)),x=ue.getUTCHours(),x<<=6,x|=ue.getUTCMinutes(),x<<=5,x|=ue.getUTCSeconds()/2,C=ue.getUTCFullYear()-1980,C<<=4,C|=ue.getUTCMonth()+1,C<<=5,C|=ue.getUTCDate(),F&&($=s(1,1)+s(u(M),4)+w,K+="up"+s($.length,2)+$),z&&(J=s(1,1)+s(u(Q),4)+O,K+="uc"+s(J.length,2)+J);var le="";return le+=`
|
|
5786
|
+
`,u=new Blob([A],{type:"text/plain"}),d=URL.createObjectURL(u),h=document.createElement("a");h.href=d,h.download=`${l}.test.ts`,h.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 Y.jsxs("div",{className:`relative ${e}`,ref:i,children:[Y.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&&Y.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:[Y.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download JSON"}),Y.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),Y.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:a,children:"Download test.ts"})]})]})},Ewt=t=>t.activeSubSolver?[t,...Ewt(t.activeSubSolver)]:[t],QTo=({solver:t})=>{const e=Ewt(t);return Y.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:e.map((n,o)=>Y.jsxs("div",{className:"flex items-center",children:[o>0&&Y.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),Y.jsx(TTo,{solver:n})]},n.constructor.name))})},NTo=({solver:t,triggerRender:e,animationSpeed:n=25,onSolverStarted:o,onSolverCompleted:i})=>{const[r,s]=X.useReducer(m=>!m,!1),a=X.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)};X.useEffect(()=>()=>{a.current&&clearInterval(a.current)},[]),X.useEffect(()=>{(t.solved||t.failed)&&r&&(a.current&&(clearInterval(a.current),a.current=void 0),s())},[t.solved,t.failed,r]);const h=t.getCurrentPhase!==void 0,_=h?t.getCurrentPhase():null;return Y.jsxs("div",{className:"space-y-2 p-2 border-b",children:[Y.jsx("div",{className:"flex items-center",children:Y.jsx(QTo,{solver:t})}),Y.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[Y.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"}),Y.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"}),Y.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"}),Y.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"}),h&&Y.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"}),Y.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&Y.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),_&&Y.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",Y.jsx("span",{className:"font-medium",children:_})]}),t.solved&&Y.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&Y.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&Y.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},RTo=(t,e,n)=>{const o=t.currentPipelineStepIndex;return e<o?"Completed":e===o&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},kTo=(t,e)=>{const o=t.pipelineDef[e].solverName,i=RTo(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],h=d?t.firstIterationOfPhase?.[d.solverName]:void 0;h!==void 0&&s!==null?c=h-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}},LTo=({status:t})=>{const e={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return Y.jsx("span",{className:`font-medium ${e[t]}`,children:t})},HTo=({progress:t})=>{if(t===0)return null;const e=Math.round(t*100);return Y.jsxs("div",{className:"flex items-center gap-2",children:[Y.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:Y.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${e}%`}})}),Y.jsxs("span",{className:"text-xs text-gray-500",children:[e,"%"]})]})},FTo=t=>Object.entries(t).map(([e,n])=>`${e}: ${n}`).join(", "),OTo=({stats:t})=>{if(!t||Object.keys(t).length===0)return Y.jsx("span",{children:"-"});const e=Object.entries(t),n=FTo(t);return Y.jsxs("details",{className:"cursor-pointer",children:[Y.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:n}),Y.jsx("div",{className:"mt-1 text-xs",children:e.map(([o,i])=>Y.jsxs("div",{children:[o,": ",String(i)]},o))})]})},g8e=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(g8e);const e={};for(const[n,o]of Object.entries(t))n.startsWith("_")||(e[n]=g8e(o));return e},GTo=(t,e)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${e}`);return}const n=g8e(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)}`)}},UTo=({solver:t,onStepUntilPhase:e,onDownloadInput:n})=>{const o=t.pipelineDef.map((a,c)=>kTo(t,c)),i=a=>{e?.(a)},r=a=>{a.solverInstance&&(n?n(a.solverInstance,a.name):GTo(a.solverInstance,a.name))},s=a=>`${(a/1e3).toFixed(2)}s`;return Y.jsxs("div",{className:"border-t border-gray-200",children:[Y.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:Y.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),Y.jsx("div",{className:"overflow-x-auto",children:Y.jsxs("table",{className:"w-full text-sm",children:[Y.jsx("thead",{children:Y.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[Y.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),Y.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),Y.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",Y.jsx("sub",{children:"0"})]}),Y.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),Y.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),Y.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),Y.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),Y.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),Y.jsx("tbody",{children:o.map(a=>Y.jsxs("tr",{className:`border-b border-gray-100 ${a.status==="In Progress"?"bg-yellow-50":""}`,children:[Y.jsx("td",{className:"px-4 py-2",children:Y.jsxs("div",{className:"flex items-center gap-2",children:[Y.jsx("span",{className:"text-gray-400 w-6",children:String(a.index+1).padStart(2,"0")}),Y.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:Y.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:Y.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"})})}),Y.jsx("span",{className:"font-medium text-gray-900",children:a.name})]})}),Y.jsx("td",{className:"px-4 py-2",children:Y.jsx(LTo,{status:a.status})}),Y.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:a.firstIteration!==null?a.firstIteration:""}),Y.jsx("td",{className:"px-4 py-2 text-gray-600",children:a.iterations}),Y.jsx("td",{className:"px-4 py-2",children:Y.jsx(HTo,{progress:a.progress})}),Y.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(a.timeSpent)}),Y.jsx("td",{className:"px-4 py-2 text-gray-500",children:Y.jsx(OTo,{stats:a.stats})}),Y.jsx("td",{className:"px-4 py-2",children:a.solverInstance?Y.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:[Y.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:Y.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"})}),Y.jsx("span",{children:"Input"})]}):null})]},a.name))})]})})]})},zTo=class extends Wr.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 VTo({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,x=p.height??0;A(g,f),A(g+y,f+x)}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,h=a-u,_=Math.max(1,c-s+2*u),m=Math.max(1,l-a+2*u);return Y.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${d} ${h} ${_} ${m}`,role:"img","aria-label":"Graphics fallback",children:[o.map((p,g)=>Y.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)=>Y.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)=>Y.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)=>Y.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)=>Y.jsx("text",{x:p.x??0,y:p.y??0,fontSize:p.fontSize??10,fill:p.color??"black",children:p.text??""},`text-${g}`))]})}var YTo=({solver:t,animationSpeed:e=25,onSolverStarted:n,onSolverCompleted:o})=>{const[i,r]=X.useReducer(A=>A+1,0),s=X.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(A){return console.error("Visualization error:",A),{points:[],lines:[],rects:[],circles:[]}}},[t,i]),a=X.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);X.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 Y.jsxs("div",{children:[Y.jsx(NTo,{solver:t,triggerRender:r,animationSpeed:e,onSolverStarted:n,onSolverCompleted:o}),a?Y.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):Y.jsx(zTo,{fallback:Y.jsx(VTo,{graphics:s}),children:Y.jsx(DTo,{graphics:s})}),c&&Y.jsx(UTo,{solver:t,onStepUntilPhase:l})]})};const KTo=()=>{X.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)},[])},WTo=1e3,XE=(t,e)=>{const{fileName:n,mimeType:o="text/plain"}=e,i=t instanceof Blob?t:new Blob([t],{type:o}),r=URL.createObjectURL(i),s=document.createElement("a");s.href=r,s.download=n,s.target="_blank",s.rel="noopener noreferrer",s.style.display="none",document.body.appendChild(s),s.click(),document.body.removeChild(s),setTimeout(()=>{URL.revokeObjectURL(r)},WTo)},bwt=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"},$E="https://github.com/tscircuit/tscircuit-autorouter/issues/new",Swt="https://github.com/tscircuit/copper-pour-solver/issues/new",Pwt="https://github.com/tscircuit/calculate-packing/issues/new",vwt="https://github.com/tscircuit/schematic-trace-solver/issues/new?template=json-bug-report.yml",jTo={PackSolver2:Pwt,AutoroutingPipelineSolver:$E,AssignableAutoroutingPipeline2:$E,AssignableAutoroutingPipeline3:$E,AutoroutingPipeline1_OriginalUnravel:$E,AutoroutingPipelineSolver3_HgPortPointPathing:$E,AutoroutingPipelineSolver4:$E,AutoroutingPipelineSolver5:$E,AutoroutingPipelineSolver7_MultiGraph:$E,AutoroutingPipelineSolver8:$E,CopperPourPipelineSolver:Swt,SchematicTracePipelineSolver:vwt},XTo=t=>t.toLowerCase().includes("pack")?g2o:t.toLowerCase().includes("rout")?I2o:o2o,Bwt=t=>{const e=jTo[t];if(e)return e;const n=t.toLowerCase();return n.includes("autorout")?$E:n.includes("schematic")&&n.includes("trace")?vwt:n.includes("copperpour")?Swt:n.includes("pack")?Pwt:null},$To=t=>`${bwt(`${t.componentName}-${t.solverName}`)}-solver-input.json`,Mwt=t=>{XE(JSON.stringify(t.solverParams,null,2),{fileName:$To(t),mimeType:"application/json"})},JTo=({solverEvent:t})=>{const e=Bwt(t.solverName);return Y.jsxs("div",{className:"rf-flex rf-items-center rf-justify-end rf-gap-2 rf-border-b rf-border-gray-200 rf-bg-gray-50 rf-px-4 rf-py-2",children:[Y.jsxs(Ya,{type:"button",variant:"outline",size:"sm",onClick:()=>Mwt(t),children:[Y.jsx($ve,{className:"rf-w-4 rf-h-4"}),"Download"]}),e?Y.jsx(Ya,{asChild:!0,variant:"outline",size:"sm",children:Y.jsxs("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:[Y.jsx(ute,{className:"rf-w-4 rf-h-4"}),"Report"]})}):Y.jsxs(Ya,{type:"button",variant:"outline",size:"sm",disabled:!0,title:"No report link configured for this solver",children:[Y.jsx(ute,{className:"rf-w-4 rf-h-4"}),"Report"]})]})},qTo=({solverEvent:t})=>{const e=Bwt(t.solverName);return e?Y.jsx(Ya,{asChild:!0,variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8",children:Y.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",title:"Report solver bug","aria-label":"Report solver bug",children:Y.jsx(ute,{className:"rf-w-4 rf-h-4"})})}):Y.jsx(Ya,{type:"button",variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8",disabled:!0,title:"No report link configured for this solver","aria-label":"Report solver bug",children:Y.jsx(ute,{className:"rf-w-4 rf-h-4"})})},ZTo=({solverEvents:t=[]})=>{const[e,n]=X.useState(null);KTo();const o=X.useMemo(()=>{const a=new Map;for(const c of t){const l=`${c.componentName}-${c.solverName}`;a.set(l,c)}return a},[t]),i=X.useMemo(()=>Array.from(o.keys()),[o]),r=e?o.get(e):null,s=X.useMemo(()=>{if(!r)return{instance:null,error:null,classFound:!1};const a=bpe[r.solverName];if(!a)return{instance:null,error:`Solver class "${r.solverName}" not found in SOLVERS registry. Available: ${Object.keys(bpe).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?Y.jsx("div",{className:"rf-p-4",children:Y.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:Y.jsxs("div",{className:"rf-p-4",children:[Y.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),Y.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."})]})})}):Y.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[Y.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[Y.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 Y.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=XTo(c.solverName);return Y.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[Y.jsx(A,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),Y.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[Y.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:c.componentName}),Y.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:c.solverName})]})]})})()},a)})]}),Y.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:r?s.instance?Y.jsxs("div",{className:"rf-flex rf-h-full rf-flex-col rf-overflow-y-auto",children:[Y.jsx(JTo,{solverEvent:r}),Y.jsx("div",{className:"rf-min-h-0 rf-flex-1",children:Y.jsx(MI,{fallback:Y.jsx("div",{className:"rf-p-4",children:Y.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[Y.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),Y.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",r.solverName]})]})}),children:Y.jsx(YTo,{solver:s.instance})})})]}):Y.jsxs("div",{className:"rf-p-4",children:[Y.jsxs("div",{className:"rf-mb-4",children:[Y.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:r.solverName}),Y.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",r.componentName]})]}),s.error&&Y.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:Y.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),Y.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[Y.jsxs("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50 rf-flex rf-items-center rf-justify-between rf-gap-2",children:[Y.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"}),Y.jsxs("div",{className:"rf-flex rf-items-center rf-gap-1",children:[Y.jsx(qTo,{solverEvent:r}),Y.jsx(Ya,{type:"button",variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8","aria-label":"Download solver input JSON",title:"Download solver input JSON",onClick:()=>Mwt(r),children:Y.jsx($ve,{className:"rf-w-4 rf-h-4"})})]})]}),Y.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:Y.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)})})]})]}):Y.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:Y.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},wwt=({errorMessage:t,errorStack:e,circuitJsonErrors:n})=>{X.useEffect(()=>{if(t){const o=new Error(t);e&&(o.stack=e);try{cT.captureException(o)}catch{}}},[t,e]),X.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{cT.captureException(i,{error_type:o.type})}catch{}}},[n])},Dwt=t=>{X.useEffect(()=>{try{oHn(t)}catch{}},[t.source,t.component,t.isWebEmbedded,t.activeTab])},Twt="0.0.2205",eQo={version:Twt},Coe=lat()(Aat(t=>({lastRunEvalVersion:void 0,setLastRunEvalVersion:e=>{t({lastRunEvalVersion:e})}}),{name:"runframe-runner-store"})),tQo=t=>{const[e,n]=X.useState([]),[o,i]=X.useState(null),[r,s]=X.useState(""),[a,c]=FD("eval-version-selection",null),l=Coe(h=>h.setLastRunEvalVersion),A=Coe(h=>h.lastRunEvalVersion);return X.useEffect(()=>{t&&fetch("https://data.jsdelivr.com/v1/package/npm/@tscircuit/eval").then(h=>h.json()).then(h=>{if(Array.isArray(h?.versions)){let _=[...h.versions];h.tags?.latest&&(i(h.tags.latest),_=_.filter(m=>m!==h.tags.latest)),n(_)}}).catch(()=>{})},[t]),X.useEffect(()=>{t&&(a?(window.TSCIRCUIT_LATEST_EVAL_VERSION=a,l(a)):o&&(window.TSCIRCUIT_LATEST_EVAL_VERSION=o,l(o)))},[t,a,o]),{versions:X.useMemo(()=>e.filter(h=>h.includes(r)).slice(0,50),[e,r]),latestVersion:o,lastRunEvalVersion:A,search:r,setSearch:s,selectVersion:h=>{c(h),s("")}}},nQo=({snippetNames:t,onSelect:e,onCancel:n,isOpen:o})=>{const[i,r]=X.useState(""),[s,a]=X.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 Y.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:Y.jsxs("div",{className:"rf-bg-white rf-rounded-lg rf-p-6 rf-w-96",children:[Y.jsx("h2",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Select Snippet"}),Y.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}),Y.jsxs("div",{className:"rf-h-60 rf-overflow-y-auto",children:[c.map(u=>Y.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&&Y.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,'"']})]}),Y.jsxs("div",{className:"rf-mt-4 rf-flex rf-justify-end rf-gap-2",children:[Y.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-text-gray-600 rf-hover:text-gray-800",onClick:n,children:"Cancel"}),Y.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}`})]})]})})},oQo=t=>{const e=X.useRef(null),n=T0(o=>o.recentEvents);X.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 Ioe="Dialog",[Qwt,Nwt]=v5(Ioe),[iQo,n4]=Qwt(Ioe),Eoe=t=>{const{__scopeDialog:e,children:n,open:o,defaultOpen:i,onOpenChange:r,modal:s=!0}=t,a=X.useRef(null),c=X.useRef(null),[l,A]=r3({prop:o,defaultProp:i??!1,onChange:r,caller:Ioe});return Y.jsx(iQo,{scope:e,triggerRef:a,contentRef:c,contentId:Tp(),titleId:Tp(),descriptionId:Tp(),open:l,onOpenChange:A,onOpenToggle:X.useCallback(()=>A(u=>!u),[A]),modal:s,children:n})};Eoe.displayName=Ioe;var Rwt="DialogTrigger",kwt=X.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,i=n4(Rwt,n),r=yu(e,i.triggerRef);return Y.jsx(Ua.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":y8e(i.open),...o,ref:r,onClick:wr(t.onClick,i.onOpenToggle)})});kwt.displayName=Rwt;var p8e="DialogPortal",[rQo,Lwt]=Qwt(p8e,{forceMount:void 0}),boe=t=>{const{__scopeDialog:e,forceMount:n,children:o,container:i}=t,r=n4(p8e,e);return Y.jsx(rQo,{scope:e,forceMount:n,children:X.Children.map(o,s=>Y.jsx(Gx,{present:n||r.open,children:Y.jsx(Pte,{asChild:!0,container:i,children:s})}))})};boe.displayName=p8e;var Soe="DialogOverlay",rU=X.forwardRef((t,e)=>{const n=Lwt(Soe,t.__scopeDialog),{forceMount:o=n.forceMount,...i}=t,r=n4(Soe,t.__scopeDialog);return r.modal?Y.jsx(Gx,{present:o||r.open,children:Y.jsx(aQo,{...i,ref:e})}):null});rU.displayName=Soe;var sQo=M8("DialogOverlay.RemoveScroll"),aQo=X.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,i=n4(Soe,n),r=L2o(),s=yu(e,r);return Y.jsx(Nte,{as:sQo,allowPinchZoom:!0,shards:[i.contentRef],children:Y.jsx(Ua.div,{"data-state":y8e(i.open),...o,ref:s,style:{pointerEvents:"auto",...o.style}})})}),pN="DialogContent",sU=X.forwardRef((t,e)=>{const n=Lwt(pN,t.__scopeDialog),{forceMount:o=n.forceMount,...i}=t,r=n4(pN,t.__scopeDialog);return Y.jsx(Gx,{present:o||r.open,children:r.modal?Y.jsx(cQo,{...i,ref:e}):Y.jsx(lQo,{...i,ref:e})})});sU.displayName=pN;var cQo=X.forwardRef((t,e)=>{const n=n4(pN,t.__scopeDialog),o=X.useRef(null),i=yu(e,n.contentRef,o);return X.useEffect(()=>{const r=o.current;if(r)return C3e(r)},[]),Y.jsx(Hwt,{...t,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:wr(t.onCloseAutoFocus,r=>{r.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:wr(t.onPointerDownOutside,r=>{const s=r.detail.originalEvent,a=s.button===0&&s.ctrlKey===!0;(s.button===2||a)&&r.preventDefault()}),onFocusOutside:wr(t.onFocusOutside,r=>r.preventDefault())})}),lQo=X.forwardRef((t,e)=>{const n=n4(pN,t.__scopeDialog),o=X.useRef(!1),i=X.useRef(!1);return Y.jsx(Hwt,{...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()}})}),Hwt=X.forwardRef((t,e)=>{const{__scopeDialog:n,trapFocus:o,onOpenAutoFocus:i,onCloseAutoFocus:r,...s}=t,a=n4(pN,n);return e3e(),Y.jsx(Y.Fragment,{children:Y.jsx(_te,{asChild:!0,loop:!0,trapped:o,onMountAutoFocus:i,onUnmountAutoFocus:r,children:Y.jsx(WO,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":y8e(a.open),...s,ref:e,deferPointerDownOutside:!0,onDismiss:()=>a.onOpenChange(!1)})})})}),Fwt="DialogTitle",Poe=X.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,i=n4(Fwt,n);return Y.jsx(Ua.h2,{id:i.titleId,...o,ref:e})});Poe.displayName=Fwt;var Owt="DialogDescription",voe=X.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,i=n4(Owt,n);return Y.jsx(Ua.p,{id:i.descriptionId,...o,ref:e})});voe.displayName=Owt;var Gwt="DialogClose",f8e=X.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,i=n4(Gwt,n);return Y.jsx(Ua.button,{type:"button",...o,ref:e,onClick:wr(t.onClick,()=>i.onOpenChange(!1))})});f8e.displayName=Gwt;function y8e(t){return t?"open":"closed"}var Uwt="AlertDialog",[AQo]=v5(Uwt,[Nwt]),KS=Nwt(),zwt=t=>{const{__scopeAlertDialog:e,...n}=t,o=KS(e);return Y.jsx(Eoe,{...o,...n,modal:!0})};zwt.displayName=Uwt;var uQo="AlertDialogTrigger",dQo=X.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,i=KS(n);return Y.jsx(kwt,{...i,...o,ref:e})});dQo.displayName=uQo;var _Qo="AlertDialogPortal",Vwt=t=>{const{__scopeAlertDialog:e,...n}=t,o=KS(e);return Y.jsx(boe,{...o,...n})};Vwt.displayName=_Qo;var hQo="AlertDialogOverlay",Ywt=X.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,i=KS(n);return Y.jsx(rU,{...i,...o,ref:e})});Ywt.displayName=hQo;var Kwt="AlertDialogContent",[mQo,gQo]=AQo(Kwt),Wwt=X.forwardRef((t,e)=>{const{__scopeAlertDialog:n,children:o,...i}=t,r=KS(n),s=X.useRef(null),a=yu(e,s),c=X.useRef(null);return Y.jsx(mQo,{scope:n,cancelRef:c,children:Y.jsx(sU,{role:"alertdialog",...r,...i,ref:a,onOpenAutoFocus:wr(i.onOpenAutoFocus,l=>{l.preventDefault(),c.current?.focus({preventScroll:!0})}),onPointerDownOutside:l=>l.preventDefault(),onInteractOutside:l=>l.preventDefault(),children:o})})});Wwt.displayName=Kwt;var pQo="AlertDialogTitle",jwt=X.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,i=KS(n);return Y.jsx(Poe,{...i,...o,ref:e})});jwt.displayName=pQo;var fQo="AlertDialogDescription",Xwt=X.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,i=KS(n);return Y.jsx(voe,{...i,...o,ref:e})});Xwt.displayName=fQo;var yQo="AlertDialogAction",$wt=X.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,i=KS(n);return Y.jsx(f8e,{...i,...o,ref:e})});$wt.displayName=yQo;var Jwt="AlertDialogCancel",qwt=X.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,{cancelRef:i}=gQo(Jwt,n),r=KS(n),s=yu(e,i);return Y.jsx(f8e,{...r,...o,ref:s})});qwt.displayName=Jwt;var xQo=zwt,CQo=Vwt,Zwt=Ywt,eDt=Wwt,tDt=$wt,nDt=qwt,oDt=jwt,iDt=Xwt;const rDt=xQo,IQo=CQo,sDt=X.forwardRef(({className:t,...e},n)=>Y.jsx(Zwt,{className:zi("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}));sDt.displayName=Zwt.displayName;const x8e=X.forwardRef(({className:t,...e},n)=>Y.jsxs(IQo,{children:[Y.jsx(sDt,{}),Y.jsx(eDt,{ref:n,className:zi("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})]}));x8e.displayName=eDt.displayName;const C8e=({className:t,...e})=>Y.jsx("div",{className:zi("rf-flex rf-flex-col rf-space-y-2 rf-text-center sm:rf-text-left",t),...e});C8e.displayName="AlertDialogHeader";const I8e=({className:t,...e})=>Y.jsx("div",{className:zi("rf-flex rf-flex-col-reverse sm:rf-flex-row sm:rf-justify-end sm:rf-space-x-2",t),...e});I8e.displayName="AlertDialogFooter";const E8e=X.forwardRef(({className:t,...e},n)=>Y.jsx(oDt,{ref:n,className:zi("rf-text-lg rf-font-semibold",t),...e}));E8e.displayName=oDt.displayName;const b8e=X.forwardRef(({className:t,...e},n)=>Y.jsx(iDt,{ref:n,className:zi("rf-text-sm rf-text-zinc-500 dark:rf-text-zinc-400",t),...e}));b8e.displayName=iDt.displayName;const EQo=X.forwardRef(({className:t,...e},n)=>Y.jsx(tDt,{ref:n,className:zi(QQ(),t),...e}));EQo.displayName=tDt.displayName;const S8e=X.forwardRef(({className:t,...e},n)=>Y.jsx(nDt,{ref:n,className:zi(QQ({variant:"outline"}),"rf-mt-2 sm:rf-mt-0",t),...e}));S8e.displayName=nDt.displayName;function bQo(t){const e=X.useRef({value:t,previous:t});return X.useMemo(()=>(e.current.value!==t&&(e.current.previous=e.current.value,e.current.value=t),e.current.previous),[t])}var Boe="Checkbox",[SQo]=v5(Boe),[PQo,P8e]=SQo(Boe);function vQo(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,h]=r3({prop:n,defaultProp:i??!1,onChange:c,caller:Boe}),[_,m]=X.useState(null),[p,g]=X.useState(null),f=X.useRef(!1),y=_?!!s||!!_.closest("form"):!0,x={checked:d,disabled:r,setChecked:h,control:_,setControl:m,name:a,form:s,value:A,hasConsumerStoppedPropagationRef:f,required:l,defaultChecked:m6(i)?!1:i,isFormControl:y,bubbleInput:p,setBubbleInput:g};return Y.jsx(PQo,{scope:e,...x,children:BQo(u)?u(x):o})}var aDt="CheckboxTrigger",cDt=X.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:h,bubbleInput:_}=P8e(aDt,t),m=yu(i,A),p=X.useRef(c);return X.useEffect(()=>{const g=r?.form;if(g){const f=()=>u(p.current);return g.addEventListener("reset",f),()=>g.removeEventListener("reset",f)}},[r,u]),Y.jsx(Ua.button,{type:"button",role:"checkbox","aria-checked":m6(c)?"mixed":c,"aria-required":l,"data-state":_Dt(c),"data-disabled":a?"":void 0,disabled:a,value:s,...o,ref:m,onKeyDown:wr(e,g=>{g.key==="Enter"&&g.preventDefault()}),onClick:wr(n,g=>{u(f=>m6(f)?!0:!f),_&&h&&(d.current=g.isPropagationStopped(),d.current||g.stopPropagation())})})});cDt.displayName=aDt;var v8e=X.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 Y.jsx(vQo,{__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})=>Y.jsxs(Y.Fragment,{children:[Y.jsx(cDt,{...u,ref:e,__scopeCheckbox:n}),d&&Y.jsx(dDt,{__scopeCheckbox:n})]})})});v8e.displayName=Boe;var lDt="CheckboxIndicator",ADt=X.forwardRef((t,e)=>{const{__scopeCheckbox:n,forceMount:o,...i}=t,r=P8e(lDt,n);return Y.jsx(Gx,{present:o||m6(r.checked)||r.checked===!0,children:Y.jsx(Ua.span,{"data-state":_Dt(r.checked),"data-disabled":r.disabled?"":void 0,...i,ref:e,style:{pointerEvents:"none",...t.style}})})});ADt.displayName=lDt;var uDt="CheckboxBubbleInput",dDt=X.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:h}=P8e(uDt,t),_=yu(n,h),m=bQo(r),p=oSt(o);X.useEffect(()=>{const f=d;if(!f)return;const y=window.HTMLInputElement.prototype,C=Object.getOwnPropertyDescriptor(y,"checked").set,E=!i.current;if(m!==r&&C){const b=new Event("click",{bubbles:E});f.indeterminate=m6(r),C.call(f,m6(r)?!1:r),f.dispatchEvent(b)}},[d,m,r,i]);const g=X.useRef(m6(r)?!1:r);return Y.jsx(Ua.input,{type:"checkbox","aria-hidden":!0,defaultChecked:s??g.current,required:a,disabled:c,name:l,value:A,form:u,...e,tabIndex:-1,ref:_,style:{...e.style,...p,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});dDt.displayName=uDt;function BQo(t){return typeof t=="function"}function m6(t){return t==="indeterminate"}function _Dt(t){return m6(t)?"indeterminate":t?"checked":"unchecked"}const aU=X.forwardRef(({className:t,...e},n)=>Y.jsx(v8e,{ref:n,className:zi("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:Y.jsx(ADt,{className:zi("rf-flex rf-items-center rf-justify-center rf-text-current"),children:Y.jsx(w9,{className:"rf-h-4 rf-w-4"})})}));aU.displayName=v8e.displayName;const fN=Eoe,MQo=boe,hDt=X.forwardRef(({className:t,...e},n)=>Y.jsx(rU,{className:zi("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}));hDt.displayName=rU.displayName;const tM=X.forwardRef(({className:t,children:e,showOverlay:n=!0,...o},i)=>Y.jsxs(MQo,{children:[Y.jsx(hDt,{className:zi(n?"":"rf-hidden")}),Y.jsx(sU,{ref:i,className:zi("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})]}));tM.displayName=sU.displayName;const nM=({className:t,...e})=>Y.jsx("div",{className:zi("rf-flex rf-flex-col rf-space-y-2 rf-text-center sm:rf-text-left",t),...e});nM.displayName="DialogHeader";const cU=({className:t,...e})=>Y.jsx("div",{className:zi("rf-flex rf-flex-col-reverse sm:rf-flex-row sm:rf-justify-end sm:rf-space-x-2",t),...e});cU.displayName="DialogFooter";const oM=X.forwardRef(({className:t,...e},n)=>Y.jsx(Poe,{ref:n,className:zi("rf-text-lg rf-font-semibold",t),...e}));oM.displayName=Poe.displayName;const yN=X.forwardRef(({className:t,...e},n)=>Y.jsx(voe,{ref:n,className:zi("rf-text-sm rf-text-zinc-500 dark:rf-text-zinc-400",t),...e}));yN.displayName=voe.displayName;const Moe={"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"}},wQo="https://cdn.jsdelivr.net/npm/easyeda@latest/dist/browser/index.js";let B8e=null;const M8e=async()=>(B8e||(B8e=import(wQo)),B8e),DQo=t=>(e,n)=>{const o=new Headers(n?.headers),i={};return o.forEach((r,s)=>{i[s]=r}),fetch(`${t?.apiBase??Z1}/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}})},TQo=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??[]},QQo=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}),mDt=async(t,e)=>{const{fetchEasyEDAComponent:n}=await M8e();return n(t,{fetch:DQo(e),includeModelMetadata:e?.includeModelMetadata})},NQo=async(t,e)=>{const{convertRawEasyToTsx:n}=await M8e(),o=await mDt(t,e);return n({rawEasy:o})},RQo=async(t,e)=>{const{EasyEdaJsonSchema:n,convertEasyEdaJsonToCircuitJson:o}=await M8e(),i=await mDt(t,{...e,includeModelMetadata:!1}),r=n.parse(i);return o(r,{shouldRecenter:!0,showDesignator:!0,useModelCdn:!1})};function g6(t){return Array.isArray?Array.isArray(t):pDt(t)==="[object Array]"}function kQo(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 w8e(t){return t==null?"":kQo(t)}function _2(t){return typeof t=="string"}function woe(t){return typeof t=="number"}function LQo(t){return t===!0||t===!1||HQo(t)&&pDt(t)=="[object Boolean]"}function gDt(t){return typeof t=="object"}function HQo(t){return gDt(t)&&t!==null}function lC(t){return t!=null}function Doe(t){return!t.trim().length}function pDt(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const FQo="Incorrect 'index' type",D8e="Invalid doc index: must be a non-negative integer within the bounds of the docs array",OQo=t=>`Invalid value for key ${t}`,GQo=t=>`Pattern length exceeds max of ${t}.`,UQo=t=>`Missing ${t} property in key`,zQo=t=>`Property 'weight' in key '${t}' must be a positive integer`,VQo="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.",fDt=Object.prototype.hasOwnProperty;var YQo=class{constructor(t){this._keys=[],this._keyMap={};let e=0;t.forEach(n=>{const o=yDt(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 yDt(t){let e=null,n=null,o=null,i=1,r=null;if(_2(t)||g6(t))o=t,e=xDt(t),n=Toe(t);else{if(!fDt.call(t,"name"))throw new Error(UQo("name"));const s=t.name;if(o=s,fDt.call(t,"weight")&&t.weight!==void 0&&(i=t.weight,i<=0))throw new Error(zQo(Toe(s)));e=xDt(s),n=Toe(s),r=t.getFn??null}return{path:e,id:n,weight:i,src:o,getFn:r}}function xDt(t){return g6(t)?t:t.split(".")}function Toe(t){return g6(t)?t.join("."):t}function KQo(t,e){const n=[];let o=!1;const i=(r,s,a,c)=>{if(lC(r))if(!s[a])n.push(c!==void 0?{v:r,i:c}:r);else{const l=r[s[a]];if(!lC(l))return;if(a===s.length-1&&(_2(l)||woe(l)||LQo(l)||typeof l=="bigint"))n.push(c!==void 0?{v:w8e(l),i:c}:w8e(l));else if(g6(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,_2(e)?e.split("."):e,0),o?n:n[0]}const vs=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:KQo,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1}});function WQo(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 T8e=class{constructor({getFn:t=vs.getFn,fieldNormWeight:e=vs.fieldNormWeight}={}){this.norm=WQo(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(_2(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(D8e);if(_2(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(D8e);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!lC(t)||Doe(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(lC(s)){if(g6(s)){const a=[];for(let c=0,l=s.length;c<l;c+=1){const A=s[c];if(lC(A)){if(_2(A)){if(!Doe(A)){const u={v:A,i:c,n:this.norm.get(A)};a.push(u)}}else if(lC(A.v)){const u=_2(A.v)?A.v:w8e(A.v);if(!Doe(u)){const d={v:u,i:A.i,n:this.norm.get(u)};a.push(d)}}}}n.$[o]=a}else if(_2(s)&&!Doe(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 CDt(t,e,{getFn:n=vs.getFn,fieldNormWeight:o=vs.fieldNormWeight}={}){const i=new T8e({getFn:n,fieldNormWeight:o});return i.setKeys(t.map(yDt)),i.setSources(e),i.create(),i}function jQo(t,{getFn:e=vs.getFn,fieldNormWeight:n=vs.fieldNormWeight}={}){const{keys:o,records:i}=t,r=new T8e({getFn:e,fieldNormWeight:n});return r.setKeys(o),r.setIndexRecords(i),r}function XQo(t=[],e=vs.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 $Qo(t,e,n,{location:o=vs.location,distance:i=vs.distance,threshold:r=vs.threshold,findAllMatches:s=vs.findAllMatches,minMatchCharLength:a=vs.minMatchCharLength,includeMatches:c=vs.includeMatches,ignoreLocation:l=vs.ignoreLocation}={}){if(e.length>32)throw new Error(GQo(32));const A=e.length,u=t.length,d=Math.max(0,Math.min(o,u));let h=r,_=d;const m=(M,w)=>{const k=M/A;if(l)return k;const Q=Math.abs(d-w);return i?k+Q/i:Q?1:k},p=a>1||c,g=p?Array(u):[];let f;for(;(f=t.indexOf(e,_))>-1;){const M=m(0,f);if(h=Math.min(M,h),_=f+A,p){let w=0;for(;w<A;)g[f+w]=1,w+=1}}_=-1;let y=[],x=1,C=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)<=h?w=k:E=k,k=Math.floor((E-w)/2+w);E=k;let Q=Math.max(1,d-k+1);const O=s?u:Math.min(d+k,u)+A,F=Array(O+2);F[O+1]=(1<<M)-1;for(let z=O;z>=Q;z-=1){const K=z-1,$=n[t[K]];if(F[z]=(F[z+1]<<1|1)&$,M&&(F[z]|=(y[z+1]|y[z])<<1|1|y[z+1]),F[z]&b&&(x=m(M,K),x<=h)){if(h=x,_=K,C=M,_<=d)break;Q=Math.max(1,2*d-_)}}if(m(M+1,d)>h)break;y=F}if(p&&_>=0){const M=Math.min(u-1,_+A-1+C);for(let w=_;w<=M;w+=1)n[t[w]]&&(g[w]=1)}const P={isMatch:_>=0,score:Math.max(.001,x)};if(p){const M=XQo(g,a);M.length?c&&(P.indices=M):P.isMatch=!1}return P}function JQo(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 Q8e(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 IDt={ł:"l",Ł:"L",đ:"d",Đ:"D",ø:"o",Ø:"O",ħ:"h",Ħ:"H",ŧ:"t",Ŧ:"T",ı:"i",ß:"ss"},qQo=new RegExp("["+Object.keys(IDt).join("")+"]","g"),lU=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(qQo,e=>IDt[e]):t=>t;var N8e=class{constructor(t,{location:e=vs.location,threshold:n=vs.threshold,distance:o=vs.distance,includeMatches:i=vs.includeMatches,findAllMatches:r=vs.findAllMatches,minMatchCharLength:s=vs.minMatchCharLength,isCaseSensitive:a=vs.isCaseSensitive,ignoreDiacritics:c=vs.ignoreDiacritics,ignoreLocation:l=vs.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?lU(t):t,this.pattern=t,this.chunks=[],!this.pattern.length)return;const A=(d,h)=>{this.chunks.push({pattern:d,alphabet:JQo(d),startIndex:h})},u=this.pattern.length;if(u>32){let d=0;const h=u%32,_=u-h;for(;d<_;)A(this.pattern.substr(d,32),d),d+=32;if(h){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?lU(t):t,this.pattern===t){const _={isMatch:!0,score:0};return o&&(_.indices=[[0,t.length-1]]),_}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:_,alphabet:m,startIndex:p})=>{const{isMatch:g,score:f,indices:y}=$Qo(t,_,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 h={isMatch:d,score:d?u/this.chunks.length:1};return d&&o&&(h.indices=Q8e(A)),h}};const ZQo=new Set(["fuzzy","include"]);function eNo(t){return t.startsWith("inverse")}const R8e=[{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 N8e(t,{location:e.location??vs.location,threshold:e.threshold??vs.threshold,distance:e.distance??vs.distance,includeMatches:e.includeMatches??vs.includeMatches,findAllMatches:e.findAllMatches??vs.findAllMatches,minMatchCharLength:e.minMatchCharLength??vs.minMatchCharLength,isCaseSensitive:e.isCaseSensitive??vs.isCaseSensitive,ignoreDiacritics:e.ignoreDiacritics??vs.ignoreDiacritics,ignoreLocation:e.ignoreLocation??vs.ignoreLocation});return{type:"fuzzy",search(o){return n.searchIn(o)}}}}],EDt=R8e.length,tNo="\0",nNo="|";function oNo(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 bDt(t,e){const n=t.match(e);return n?n[1]:null}function iNo(t,e={}){return t.replace(/\\\|/g,tNo).split(nNo).map(n=>{const o=oNo(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<EDt;){const A=R8e[l],u=bDt(a,A.multiRegex);u&&(i.push(A.create(u,e)),c=!0)}if(!c)for(l=-1;++l<EDt;){const A=R8e[l],u=bDt(a,A.singleRegex);if(u){i.push(A.create(u,e));break}}}return i})}var rNo=class{constructor(t,{isCaseSensitive:e=vs.isCaseSensitive,ignoreDiacritics:n=vs.ignoreDiacritics,includeMatches:o=vs.includeMatches,minMatchCharLength:i=vs.minMatchCharLength,ignoreLocation:r=vs.ignoreLocation,findAllMatches:s=vs.findAllMatches,location:a=vs.location,threshold:c=vs.threshold,distance:l=vs.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?lU(t):t,this.pattern=t,this.query=iNo(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?lU(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,h=u.length;d<h;d+=1){const _=u[d],{isMatch:m,indices:p,score:g}=_.search(t);if(m)r+=1,a+=g,eNo(_.type)&&(c=!0),n&&(ZQo.has(_.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=Q8e(s)),d}}return{isMatch:!1,score:1}}};const k8e=[];function L8e(...t){k8e.push(...t)}function Qoe(t,e){for(let n=0,o=k8e.length;n<o;n+=1){const i=k8e[n];if(i.condition(t,e))return new i(t,e)}return new N8e(t,e)}const Noe={AND:"$and",OR:"$or"},H8e={PATH:"$path",PATTERN:"$val"},F8e=t=>!!(t[Noe.AND]||t[Noe.OR]),sNo=t=>!!t[H8e.PATH],aNo=t=>!g6(t)&&gDt(t)&&!F8e(t),SDt=t=>({[Noe.AND]:Object.keys(t).map(e=>({[e]:t[e]}))});function PDt(t,e,{auto:n=!0}={}){const o=i=>{if(_2(i)){const c={keyId:null,pattern:i};return n&&(c.searcher=Qoe(i,e)),c}const r=Object.keys(i),s=sNo(i);if(!s&&r.length>1&&!F8e(i))return o(SDt(i));if(aNo(i)){const c=s?i[H8e.PATH]:r[0],l=s?i[H8e.PATTERN]:i[c];if(!_2(l))throw new Error(OQo(c));const A={keyId:Toe(c),pattern:l};return n&&(A.searcher=Qoe(l,e)),A}const a={children:[],operator:r[0]};return r.forEach(c=>{const l=i[c];g6(l)&&l.forEach(A=>{a.children.push(o(A))})}),a};return F8e(t)||(t=SDt(t)),o(t)}function O8e(t,{ignoreFieldNorm:e=vs.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 cNo(t,{ignoreFieldNorm:e=vs.ignoreFieldNorm}){t.forEach(n=>{n.score=O8e(n.matches,{ignoreFieldNorm:e})})}var lNo=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 ANo(t){const e=[];return t.matches.forEach(n=>{if(!lC(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 uNo(t,e,{includeMatches:n=vs.includeMatches,includeScore:o=vs.includeScore}={}){return t.map(i=>{const{idx:r}=i,s={item:e[r],refIndex:r};return n&&(s.matches=ANo(i)),o&&(s.score=i.score),s})}const dNo=/[\p{L}\p{M}\p{N}_]+/gu,vDt=new WeakSet;function _No(t){vDt.has(t)||(vDt.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 hNo(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||_No(t),e=>e.match(t)||[]):e=>e.match(dNo)||[]}function G8e({isCaseSensitive:t=!1,ignoreDiacritics:e=!1,tokenize:n}={}){const o=hNo(n);return{tokenize(i){return t||(i=i.toLowerCase()),e&&(i=lU(i)),o(i)}}}var mNo=class{static condition(t,e){return e.useTokenSearch}constructor(t,e){this.options=e,this.analyzer=G8e({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 N8e(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=Q8e(e)),this.combineAll&&(this.useMask?c.matchedMask=r:c.matchedTerms=s,c.termCount=this.numTerms),c}};function U8e(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 BDt(t,e,n,o){const{i,v:r,$:s}=e;if(r!==void 0){U8e(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)U8e(t,l.v,i,o);else U8e(t,c.v,i,o)}}function gNo(t,e,n){const o={fieldCount:0,df:new Map,docFieldCount:new Map,docTermFieldHits:new Map};for(const i of t)BDt(o,i,e,n);return o}function pNo(t,e,n,o){BDt(t,e,n,o)}function fNo(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 MDt(t,e){if(e.length===0)return;const n=Array.from(new Set(e)).sort((a,c)=>a-c);for(const a of n)fNo(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 p6=class{constructor(t,e,n){this.options={...vs,...e},this.options.useExtendedSearch,this.options.useTokenSearch,this._keyStore=new YQo(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=Qoe(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 T8e))throw new Error(FQo);if(this._myIndex=e||CDt(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight}),this.options.useTokenSearch){const n=G8e({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});this._invertedIndex=gNo(this._myIndex.records,this._myIndex.keys.length,n)}this._invalidateSearcherCache()}add(t){if(!lC(t))return;this._docs.push(t);const e=this._myIndex.add(t,this._docs.length-1);if(this._invertedIndex&&e){const n=G8e({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});pNo(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&&MDt(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(D8e);this._invertedIndex&&MDt(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(_2(t)&&!t.trim()){let A=this._docs.map((u,d)=>({item:u,refIndex:d}));return woe(n)&&n>-1&&(A=A.slice(0,n)),A}const c=woe(n)&&n>0&&_2(t);let l;if(c){const A=new lNo(n);_2(this._docs[0])?this._searchStringList(t,{heap:A,ignoreFieldNorm:a}):this._searchObjectList(t,{heap:A,ignoreFieldNorm:a}),l=A.extractSorted(s)}else l=_2(t)?_2(this._docs[0])?this._searchStringList(t):this._searchObjectList(t):this._searchLogical(t),cNo(l,{ignoreFieldNorm:a}),r&&l.sort(s),woe(n)&&n>-1&&(l=l.slice(0,n));return uNo(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(!lC(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 h={item:a,idx:c,matches:d};e?(h.score=O8e(h.matches,{ignoreFieldNorm:n}),e.shouldInsert(h.score)&&e.insert(h)):s.push(h)}}}),s}_searchLogical(t){const e=PDt(t,this.options),n=(s,a,c)=>{if(!("children"in s)){const{keyId:d,searcher:h}=s;let _;return d===null?(_=[],this._myIndex.keys.forEach((m,p)=>{_.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}),_&&_.length?[{idx:c,item:a,matches:_}]:[]}const{children:l,operator:A}=s,u=[];for(let d=0,h=l.length;d<h;d+=1){const _=l[d],m=n(_,a,c);if(m.length)u.push(...m);else if(A===Noe.AND)return[]}return u},o=this._myIndex.records,i=new Map,r=[];return o.forEach(({$:s,i:a})=>{if(lC(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(!lC(c))return;const A=[];let u=!1,d=!1;if(r.forEach((h,_)=>{const m=this._findMatches({key:h,value:c[_],searcher:o});m.length?(A.push(...m),m[0].hasInverse&&(d=!0)):u=!0}),!(d&&u)&&A.length&&(!i||this._coversAllTokens(A))){const h={idx:l,item:c,matches:A};e?(h.score=O8e(h.matches,{ignoreFieldNorm:n}),e.shouldInsert(h.score)&&e.insert(h)):a.push(h)}}),a}_findMatches({key:t,value:e,searcher:n}){if(!lC(e))return[];const o=[];if(g6(e))e.forEach(({v:i,i:r,n:s})=>{if(!lC(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}};p6.version="7.4.2",p6.createIndex=CDt,p6.parseIndex=jQo,p6.config=vs,p6.match=function(t,e,n){if(n&&n.useTokenSearch)throw new Error(VQo);return Qoe(t,{...vs,...n}).searchIn(e)},p6.parseQuery=PDt,L8e(rNo),L8e(mNo),p6.use=function(...t){t.forEach(e=>L8e(e))};var yNo=p6;const xNo="https://kicad-mod-cache.tscircuit.com";let z8e=null,AU=null,V8e=null;const CNo=async()=>z8e||AU||(AU=fetch("https://kicad-mod-cache.tscircuit.com/kicad_files.json").then(t=>t.json()).then(t=>(z8e=t,AU=null,t)),AU),INo=async(t,e=20)=>{const n=await CNo();return V8e||(V8e=new yNo(n)),V8e.search(t).slice(0,e).map(o=>o.item)},ENo=t=>{const e=t.replace(".pretty/","/").replace(".kicad_mod",""),n=`kicad:${e}`;return{path:t,qualifiedName:n,description:e}},bNo=t=>t.replace(/^\/+/,"").split("/").map(e=>encodeURIComponent(e)).join("/"),SNo=async t=>{const e=await fetch(`${xNo}/${bNo(t)}`);if(!e.ok)throw new Error(`KiCad footprint fetch failed: ${e.status}`);const n=await e.text(),{KicadFootprintToCircuitJsonConverter:o}=await q5("kicad-to-circuit-json"),i=new o;return i.addFile(t.split("/").pop()??"selected-footprint.kicad_mod",n),i.runUntilFinished(),i.getOutput()},wDt=t=>t?.source==="jlcpcb"||t?.source==="kicad",PNo=async(t,e)=>{if(t.source==="jlcpcb")return RQo(t.component.partNumber,e?.jlcpcb);if(t.source==="kicad")return SNo(t.footprint.path);throw new Error("Footprint preview is not available for this source")},vNo=({query:t,placeholder:e,isSearching:n,onQueryChange:o,onSubmit:i})=>{const r=X.useCallback(s=>{s.key==="Enter"&&(s.preventDefault(),i())},[i]);return Y.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2 rf-mt-4",children:[Y.jsxs("div",{className:"rf-relative rf-flex-grow",children:[Y.jsx(Jve,{className:"rf-absolute rf-left-2 rf-top-2.5 rf-h-4 rf-w-4 rf-text-muted-foreground"}),Y.jsx(X6e,{placeholder:e,className:"rf-pl-8",spellCheck:!1,autoComplete:"off",value:t,onChange:s=>o(s.target.value),onKeyDown:r})]}),Y.jsx(Ya,{onClick:i,disabled:n||t.trim().length<1,className:"sm:rf-px-4 rf-px-3",children:n?Y.jsx(Y5,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):Y.jsxs(Y.Fragment,{children:[Y.jsx(Jve,{className:"rf-h-4 rf-w-4 sm:rf-hidden"}),Y.jsx("span",{className:"rf-hidden sm:rf-inline",children:"Search"})]})})]})},BNo=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}),MNo=t=>BNo.format(t),DDt=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"}},wNo=t=>{switch(t.source){case"tscircuit.com":return t.package.unscoped_name;case"jlcpcb":return t.component.manufacturer;case"kicad":return t.footprint.qualifiedName}},DNo=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}},TNo=t=>{switch(t.source){case"tscircuit.com":return t.package.name;case"jlcpcb":return t.component.partNumber;case"kicad":return}},QNo=({results:t,selected:e,onSelect:n,onShowDetails:o})=>{const i=e?DDt(e):null;return Y.jsx("div",{className:"rf-divide-y rf-w-full rf-overflow-hidden",children:t.map(r=>{const s=DDt(r),a=i===s,c=wNo(r),l=DNo(r),A=TNo(r),u=r.source==="jlcpcb"?r.component.stock:null,d=r.source==="jlcpcb"?r.component.price:null,h=r.source==="jlcpcb"?r.component.isBasic:null;return Y.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:[Y.jsxs("div",{className:"rf-min-w-0 rf-overflow-hidden rf-w-full",children:[Y.jsxs("div",{className:"rf-flex rf-items-start rf-gap-2 rf-min-w-0",children:[Y.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"&&h!=null&&Y.jsx("span",{className:`rf-text-xs rf-px-1.5 rf-py-0.5 rf-rounded rf-font-medium rf-flex-shrink-0 ${h?"rf-bg-green-100 rf-text-green-700":"rf-bg-orange-100 rf-text-orange-700"}`,children:h?"Basic":"Extended"}),r.source==="tscircuit.com"&&r.package.is_private&&Y.jsx(f2o,{className:"rf-ml-1 rf-h-3 rf-w-3 rf-text-zinc-400 rf-flex-shrink-0"})]}),r.source==="jlcpcb"&&u!=null?Y.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]}),Y.jsxs("div",{className:"rf-text-xs rf-text-zinc-500 rf-truncate rf-w-full",children:[A?Y.jsx("span",{className:"rf-mr-2",children:A}):null,l]})]}),Y.jsxs("div",{children:[r.source==="tscircuit.com"&&o?Y.jsx("div",{className:"rf-flex-shrink-0 rf-w-full sm:rf-w-auto",children:Y.jsx(Ya,{variant:"outline",size:"sm",className:"rf-text-xs rf-w-full sm:rf-w-auto",onClick:_=>{_.stopPropagation(),o(r)},children:"See Details"})}):r.source==="jlcpcb"&&u!=null?Y.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&&Y.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:MNo(d)})]})]},s)})})},NNo=({circuitJson:t,error:e,isLoading:n,height:o})=>Y.jsx("section",{className:"rf-flex rf-min-w-0 rf-items-center rf-justify-center",style:{height:o},children:n?Y.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:[Y.jsx(Y5,{className:"rf-h-4 rf-w-4 rf-animate-spin"}),"Loading preview..."]}):e?Y.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:Y.jsxs("div",{className:"rf-flex rf-max-w-[320px] rf-items-start rf-gap-2 rf-text-sm rf-text-zinc-300",children:[Y.jsx(Ibt,{className:"rf-mt-0.5 rf-h-4 rf-w-4 rf-flex-shrink-0"}),Y.jsx("span",{children:e})]})}):t?Y.jsx("div",{className:"rf-w-full rf-min-w-0 rf-overflow-hidden",children:Y.jsx(xwt,{circuitJson:t,height:o,allowEditing:!1,clickToInteractEnabled:!1,focusOnHover:!1,disablePcbGroups:!0})}):Y.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"})}),TDt={importComponentDialog:101,importComponentDetailsDialog:102},RNo=({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,h=l?.unscoped_name?.split("/").pop()??l?.unscoped_name,_=l?.org_owner_tscircuit_handle??void 0,m=_?`https://tscircuit.com/${_}`:void 0,p=_&&h?`https://tscircuit.com/${_}/${h}`:void 0;return Y.jsx(fN,{open:e,onOpenChange:n,children:Y.jsxs(tM,{showOverlay:!1,style:{width:"calc(100vw - 2rem)",zIndex:TDt.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:[Y.jsx(nM,{className:"rf-pb-4 rf-border-b",children:Y.jsx("div",{className:"rf-flex rf-items-start rf-justify-between rf-gap-4",children:Y.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[Y.jsx(oM,{className:"rf-text-xl rf-font-semibold rf-truncate",children:h}),Y.jsx(yN,{children:l?.description})]})})}),Y.jsxs("div",{className:"rf-flex-1 rf-overflow-y-auto rf-py-4 rf-space-y-6",children:[_?Y.jsxs("div",{children:[Y.jsx("span",{className:"rf-text-xs rf-font-medium rf-text-gray-500 rf-uppercase rf-tracking-wide",children:"Created by"}),Y.jsx("div",{className:"rf-mt-1 rf-text-sm rf-font-medium",children:m?Y.jsx("a",{href:m,target:"_blank",rel:"noopener noreferrer",className:"rf-text-black hover:rf-underline",children:_}):_})]}):null,(d||A||u)&&Y.jsx(Y.Fragment,{children:Y.jsxs("div",{children:[Y.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Preview"}),Y.jsxs(R1e,{value:r,onValueChange:g=>s(g),children:[Y.jsxs(fq,{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&&Y.jsx(mE,{value:"pcb",children:"PCB"}),u&&Y.jsx(mE,{value:"schematic",children:"Schematic"}),d&&Y.jsx(mE,{value:"3d",children:"3D"})]}),Y.jsxs("div",{className:"rf-mt-4",children:[Y.jsx(Wf,{value:"pcb",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:A?Y.jsx("img",{src:A,alt:`${h??"package"} PCB preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null}),Y.jsx(Wf,{value:"schematic",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:u?Y.jsx("img",{src:u,alt:`${h??"package"} schematic preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null}),Y.jsx(Wf,{value:"3d",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:d?Y.jsx("img",{src:d,alt:`${h??"package"} 3D preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null})]})]})]})}),i?.ai_description?Y.jsxs("section",{children:[Y.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-3",children:"AI Description"}),Y.jsx("div",{className:"rf-bg-gray-50 rf-border rf-border-gray-200 rf-rounded-lg rf-p-4",children:Y.jsx("p",{className:"rf-text-sm rf-text-gray-700 rf-leading-relaxed",children:i.ai_description})})]}):null,i?.ai_usage_instructions?Y.jsxs("section",{children:[Y.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-3",children:"Usage Instructions"}),Y.jsx("div",{className:"rf-bg-gray-50 rf-border rf-border-gray-200 rf-rounded-lg rf-p-4",children:Y.jsx("p",{className:"rf-text-sm rf-text-gray-700 rf-leading-relaxed rf-whitespace-pre-wrap",children:i.ai_usage_instructions})})]}):null,o?Y.jsxs("div",{className:"rf-flex rf-justify-center rf-items-center rf-gap-2 rf-text-gray-500",children:[Y.jsx(Y5,{className:"rf-h-4 rf-w-4 rf-animate-spin"}),Y.jsx("span",{className:"rf-text-sm",children:"Loading package details..."})]}):null]}),Y.jsxs(cU,{className:"rf-pt-4 rf-border-t rf-flex rf-flex-col sm:rf-flex-row rf-justify-between rf-gap-2",children:[Y.jsx("div",{className:"rf-flex-1",children:p?Y.jsxs(Ya,{variant:"outline",size:"sm",className:"rf-gap-2 rf-w-full sm:rf-w-auto",onClick:()=>window.open(p,"_blank"),children:[Y.jsx(u2o,{className:"rf-h-4 rf-w-4"}),"View on tscircuit.com"]}):null}),Y.jsxs("div",{className:"rf-flex rf-flex-col sm:rf-flex-row rf-gap-2",children:[Y.jsx(Ya,{variant:"outline",onClick:()=>n(!1),className:"rf-order-2 sm:rf-order-1",children:"Close"}),Y.jsx(Ya,{onClick:c,disabled:a,className:"rf-bg-blue-600 hover:rf-bg-blue-700",children:a?Y.jsx(Y5,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):"Import Component"})]})]})]})})},kNo=()=>{const[t,e]=X.useState(null),[n,o]=X.useState(!1),i=X.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=X.useCallback(()=>{e(null),o(!1)},[]);return{details:t,isLoading:n,fetchDetails:i,reset:r}},LNo=(t,e)=>{const[n,o]=X.useState({circuitJson:null,error:null,isLoading:!1});return X.useEffect(()=>{if(!t||!wDt(t)){o({circuitJson:null,error:null,isLoading:!1});return}let i=!1;return o({circuitJson:null,error:null,isLoading:!0}),PNo(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},HNo=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??[]},FNo=({sessionToken:t})=>{const[e,n]=X.useState([]),[o,i]=X.useState(!1),[r,s]=X.useState(null),[a,c]=X.useState(!1),l=X.useCallback(async u=>{const d=u.trim();if(!d)return[];i(!0),s(null);try{const _=(await HNo(d,t)).map(m=>({source:"tscircuit.com",package:m}));return n(_),_}catch(h){return console.error("Error searching tscircuit packages",h),n([]),s(h instanceof Error?h.message:"Failed to search tscircuit packages"),[]}finally{i(!1),c(!0)}},[t]),A=X.useCallback(()=>{n([]),i(!1),s(null),c(!1)},[]);return{results:e,isSearching:o,error:r,hasSearched:a,search:l,reset:A}},ONo=t=>{const e=t.trim();return/^C\d+/i.test(e)?e.replace(/^C/i,""):e},GNo=()=>{const[t,e]=X.useState([]),[n,o]=X.useState(!1),[i,r]=X.useState(null),[s,a]=X.useState(!1),c=X.useCallback(async A=>{const u=ONo(A);if(!u)return[];o(!0),r(null);try{const h=(await TQo(u,10)).map(_=>({source:"jlcpcb",component:QQo(_)}));return e(h),h}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=X.useCallback(()=>{e([]),o(!1),r(null),a(!1)},[]);return{results:t,isSearching:n,error:i,hasSearched:s,search:c,reset:l}},UNo=()=>{const[t,e]=X.useState([]),[n,o]=X.useState(!1),[i,r]=X.useState(null),[s,a]=X.useState(!1),c=X.useCallback(async A=>{const u=A.trim();if(!u)return[];o(!0),r(null);try{const h=(await INo(u,20)).map(_=>({source:"kicad",footprint:ENo(_)}));return e(h),h}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=X.useCallback(()=>{e([]),o(!1),r(null),a(!1)},[]);return{results:t,isSearching:n,error:i,hasSearched:s,search:c,reset:l}},zNo=({onTscircuitPackageSelected:t,onJlcpcbComponentTsxLoaded:e,onKicadStringSelected:n})=>{const o=[];return t&&o.push("tscircuit.com"),e&&o.push("jlcpcb"),n&&o.push("kicad"),o},VNo=({isOpen:t,onClose:e,jlcpcbProxyRequestHeaders:n,onKicadStringSelected:o,onTscircuitPackageSelected:i,onJlcpcbComponentTsxLoaded:r,jlcpcbProxyApiBase:s,tscircuitSessionToken:a})=>{xoe();const c=X.useMemo(()=>zNo({onKicadStringSelected:o,onTscircuitPackageSelected:i,onJlcpcbComponentTsxLoaded:r}),[o,i,r]),l=c.length>0,A=c.length===1,[u,d]=X.useState(c[0]??"tscircuit.com"),[h,_]=X.useState(""),[m,p]=X.useState(null),{results:g,isSearching:f,error:y,hasSearched:x,search:C,reset:E}=FNo({sessionToken:a}),{results:b,isSearching:P,error:M,hasSearched:w,search:k,reset:Q}=GNo(),{results:O,isSearching:F,error:z,hasSearched:K,search:$,reset:J}=UNo(),{details:oe,isLoading:ue,fetchDetails:ne,reset:ie}=kNo(),[ce,re]=X.useState(null),[le,xe]=X.useState(!1),[be,ve]=X.useState("pcb"),[_e,Pe]=X.useState(null),[pe,Ge]=X.useState(!1),Le=X.useMemo(()=>({jlcpcb:{headers:n,apiBase:s}}),[s,n]),{circuitJson:$e,error:fe,isLoading:Ze}=LNo(m,Le),Ue=wDt(m);X.useEffect(()=>{Pe(null)},[m]);const Qe=X.useCallback(()=>{E(),Q(),J(),p(null)},[Q,J,E]);X.useEffect(()=>{t||(Qe(),_(""),xe(!1),re(null),Pe(null))},[t,Qe]),X.useEffect(()=>{_(""),p(null),u==="tscircuit.com"?E():u==="jlcpcb"?Q():u==="kicad"&&J()},[u,Q,J,E]);const Ye=At=>{p(At),re(At),ve("pcb"),xe(!0),ie();const xt=At.package.org_owner_tscircuit_handle,Bt=At.package.unscoped_name;if(xt&&Bt){const ft=Bt.split("/").pop()??Bt;ne(xt,ft)}},Ne=async()=>{h.trim()&&(p(null),u==="tscircuit.com"?await C(h):u==="jlcpcb"?await k(h):u==="kicad"&&await $(h))},Ie=async At=>{try{if(Pe(null),Ge(!0),At.source==="kicad"){if(!o)throw new Error("KiCad handler not provided");await o({result:At,footprint:At.footprint.qualifiedName})}else if(At.source==="jlcpcb"){if(!r)throw new Error("JLCPCB handler not provided");const xt=await NQo(At.component.partNumber,{headers:n,apiBase:s});await r({result:At,tsx:xt})}else if(At.source==="tscircuit.com"){if(!i)throw new Error("tscircuit package handler not provided");const xt=At.package.org_owner_tscircuit_handle,Bt=At.package.unscoped_name;if(!xt||!Bt)throw new Error("Missing package metadata");const ft=Bt.split("/").pop()??Bt,Dt=`@tsci/${xt}.${ft}`;await i({result:At,fullPackageName:Dt})}return!0}catch(xt){return console.error("Failed to import component",xt),Pe(xt instanceof Error?xt.message:"Failed to import component"),!1}finally{Ge(!1)}};let Oe=[],Me=!1,We=null,Je=!1;u==="tscircuit.com"?(Oe=g,Me=f,We=y,Je=x):u==="jlcpcb"?(Oe=b,Me=P,We=M,Je=w):u==="kicad"&&(Oe=O,Me=F,We=z,Je=K);const ct=async()=>{if(!m)return;await Ie(m)&&(e(),Qe(),_(""))},lt=At=>{At||e()},dt=At=>{xe(At),At||re(null)};return Y.jsxs(fN,{open:t,onOpenChange:lt,children:[Y.jsxs(tM,{style:{width:"calc(100vw - 2rem)",maxWidth:Ue?"min(1120px, calc(100vw - 2rem))":"min(672px, calc(100vw - 2rem))",zIndex:TDt.importComponentDialog},className:"rf-rounded-sm rf-max-h-[90vh] rf-overflow-y-auto rf-overflow-x-hidden rf-flex rf-flex-col",children:[Y.jsxs(nM,{children:[Y.jsxs(oM,{className:"rf-text-lg sm:rf-text-xl",children:["Import ",A?Moe[u].label:""," ","Component"]}),Y.jsx(yN,{className:"rf-text-sm",children:l?"Search for components from available sources.":"Import options are disabled because no handlers were provided."})]}),l?Y.jsxs(R1e,{value:u,onValueChange:At=>d(At),className:"rf-min-w-0 rf-w-full",children:[!A&&Y.jsx(fq,{className:"rf-flex rf-w-full rf-gap-2",children:c.map(At=>Y.jsx(mE,{value:At,className:"rf-flex-1 rf-text-xs sm:rf-text-sm",children:Moe[At].label},At))}),Y.jsxs("div",{className:"rf-min-w-0",style:Ue?{display:"grid",gridTemplateColumns:"minmax(0, 1fr) minmax(360px, 0.95fr)",gap:"1.5rem",alignItems:"start"}:void 0,children:[Y.jsxs("div",{className:"rf-min-w-0",children:[Y.jsx(vNo,{query:h,placeholder:Moe[u].placeholder,isSearching:Me,onQueryChange:_,onSubmit:Ne}),Y.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?Y.jsxs("div",{className:"rf-p-8 rf-text-center rf-text-zinc-500",children:[Y.jsx(Y5,{className:"rf-h-8 rf-w-8 rf-animate-spin rf-mx-auto rf-mb-2"}),Y.jsx("p",{children:"Searching..."})]}):Oe.length>0?Y.jsx(QNo,{results:Oe,selected:m,onSelect:p,onShowDetails:u==="tscircuit.com"?Ye:void 0}):Y.jsx("div",{className:"rf-p-8 rf-text-center rf-text-zinc-500",children:We?`Error: ${We}`:Je?Moe[u].emptyMessage:"Enter a search term to find components"})})]}),Ue?Y.jsx("div",{className:"rf-mt-4",children:Y.jsx(NNo,{circuitJson:$e,error:fe,isLoading:Ze,height:325})}):null]})]}):null,_e?Y.jsx("div",{className:"rf-text-sm rf-text-red-600 rf-mt-2",children:_e}):null,Y.jsxs(cU,{className:"rf-flex rf-flex-col sm:rf-flex-row rf-gap-2",children:[Y.jsx(Ya,{variant:"outline",onClick:e,className:"rf-order-2 sm:rf-order-1",children:"Cancel"}),Y.jsx(Ya,{onClick:ct,disabled:!m||pe,className:"rf-order-1 sm:rf-order-2",children:pe?Y.jsx(Y5,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):"Import"})]})]}),Y.jsx(RNo,{packageResult:ce,isOpen:le,onOpenChange:dt,isLoading:ue,details:oe,previewTab:be,onPreviewTabChange:At=>ve(At),isSubmitting:pe,onImport:()=>{ce&&Ie(ce).then(At=>{At&&(xe(!1),e(),Qe(),_(""))})}})]})},YNo=t=>{const e=t.match(/export const (\w+) =/);if(!e)throw new Error("Could not determine component name from TSX contents");return e[1]},QDt=t=>{const e=T0(s=>s.pushEvent),n=T0(s=>s.upsertFile),o=async({result:s,fullPackageName:a})=>{const l=s.package.unscoped_name??s.package.name;await Os.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 Os.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/${YNo(a)}.tsx`;await Os.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 Y.jsx(VNo,{...t,onTscircuitPackageSelected:o,onKicadStringSelected:i,onJlcpcbComponentTsxLoaded:r})};QDt.displayName="ImportComponentDialogForCli";var Y8e={exports:{}},NDt;function KNo(){return NDt||(NDt=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 zP=="function"&&zP;if(!u&&d)return d(A,!0);if(c)return c(A,!0);var h=new Error("Cannot find module '"+A+"'");throw h.code="MODULE_NOT_FOUND",h}var _=r[A]={exports:{}};i[A][0].call(_.exports,function(m){var p=i[A][1][m];return a(p||m)},_,_.exports,o,i,r,s)}return r[A].exports}for(var c=typeof zP=="function"&&zP,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,x=y,C=s.getTypeOf(l)!=="string";f<l.length;)x=y-f,d=C?(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),h=A>>2,_=(3&A)<<4|u>>4,m=1<x?(15&u)<<2|d>>6:64,p=2<x?63&d:64,g.push(c.charAt(h)+c.charAt(_)+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,x=3*(l=l.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(l.charAt(l.length-1)===c.charAt(64)&&x--,l.charAt(l.length-2)===c.charAt(64)&&x--,x%1!=0)throw new Error("Invalid base64 input, bad content length.");for(y=a.uint8array?new Uint8Array(0|x):new Array(0|x);p<l.length;)A=c.indexOf(l.charAt(p++))<<2|(h=c.indexOf(l.charAt(p++)))>>4,u=(15&h)<<4|(_=c.indexOf(l.charAt(p++)))>>2,d=(3&_)<<6|(m=c.indexOf(l.charAt(p++))),y[g++]=A,_!==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=h,this.compression=_,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,h){return u.pipe(new c).pipe(new l("uncompressedSize")).pipe(d.compressWorker(h)).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,h){var _=a,m=h+d;A^=-1;for(var p=h;p<m;p++)A=A>>>8^_[255&(A^u[p])];return-1^A})(0|l,c,c.length,0):(function(A,u,d,h){var _=a,m=h+d;A^=-1;for(var p=h;p<m;p++)A=A>>>8^_[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,h){l.call(this,"FlateWorker/"+d),this._pako=null,this._pakoAction=d,this._pakoOptions=h,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(h){d.push({data:h,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(_,m){var p,g="";for(p=0;p<m;p++)g+=String.fromCharCode(255&_),_>>>=8;return g}function a(_,m,p,g,f,y){var x,C,E=_.file,b=_.compression,P=y!==A.utf8encode,M=c.transformTo("string",y(E.name)),w=c.transformTo("string",A.utf8encode(E.name)),k=E.comment,Q=c.transformTo("string",y(k)),O=c.transformTo("string",A.utf8encode(k)),F=w.length!==E.name.length,z=O.length!==k.length,K="",$="",J="",oe=E.dir,ue=E.date,ne={crc32:0,compressedSize:0,uncompressedSize:0};m&&!p||(ne.crc32=_.crc32,ne.compressedSize=_.compressedSize,ne.uncompressedSize=_.uncompressedSize);var ie=0;m&&(ie|=8),P||!F&&!z||(ie|=2048);var ce=0,re=0;oe&&(ce|=16),f==="UNIX"?(re=798,ce|=(function(xe,be){var ve=xe;return xe||(ve=be?16893:33204),(65535&ve)<<16})(E.unixPermissions,oe)):(re=20,ce|=(function(xe){return 63&(xe||0)})(E.dosPermissions)),x=ue.getUTCHours(),x<<=6,x|=ue.getUTCMinutes(),x<<=5,x|=ue.getUTCSeconds()/2,C=ue.getUTCFullYear()-1980,C<<=4,C|=ue.getUTCMonth()+1,C<<=5,C|=ue.getUTCDate(),F&&($=s(1,1)+s(u(M),4)+w,K+="up"+s($.length,2)+$),z&&(J=s(1,1)+s(u(Q),4)+O,K+="uc"+s(J.length,2)+J);var le="";return le+=`
|
|
5787
5787
|
\0`,le+=s(ie,2),le+=b.magic,le+=s(x,2),le+=s(C,2),le+=s(ne.crc32,4),le+=s(ne.compressedSize,4),le+=s(ne.uncompressedSize,4),le+=s(M.length,2),le+=s(K.length,2),{fileRecord:d.LOCAL_FILE_HEADER+le+M+K,dirRecord:d.CENTRAL_FILE_HEADER+s(re,2)+le+s(Q.length,2)+"\0\0\0\0"+s(ce,4)+s(g,4)+M+K+Q}}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=_,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}c.inherits(h,l),h.prototype.push=function(_){var m=_.meta.percent||0,p=this.entriesCount,g=this._sources.length;this.accumulate?this.contentBuffer.push(_):(this.bytesWritten+=_.data.length,l.prototype.push.call(this,{data:_.data,meta:{currentFile:this.currentFile,percent:p?(m+100*(p-g-1))/p:100}}))},h.prototype.openedSource=function(_){this.currentSourceOffset=this.bytesWritten,this.currentFile=_.file.name;var m=this.streamFiles&&!_.file.dir;if(m){var p=a(_,m,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:p.fileRecord,meta:{percent:0}})}else this.accumulate=!0},h.prototype.closedSource=function(_){this.accumulate=!1;var m=this.streamFiles&&!_.file.dir,p=a(_,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)})(_),meta:{percent:100}});else for(this.push({data:p.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},h.prototype.flush=function(){for(var _=this.bytesWritten,m=0;m<this.dirRecords.length;m++)this.push({data:this.dirRecords[m],meta:{percent:100}});var p=this.bytesWritten-_,g=(function(f,y,x,C,E){var b=c.transformTo("string",E(C));return d.CENTRAL_DIRECTORY_END+"\0\0\0\0"+s(f,2)+s(f,2)+s(y,4)+s(x,4)+s(b.length,2)+b})(this.dirRecords.length,p,_,this.zipComment,this.encodeFileName);this.push({data:g,meta:{percent:100}})},h.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},h.prototype.registerPrevious=function(_){this._sources.push(_);var m=this;return _.on("data",function(p){m.processChunk(p)}),_.on("end",function(){m.closedSource(m.previous.streamInfo),m._sources.length?m.prepareNextSource():m.end()}),_.on("error",function(p){m.error(p)}),this},h.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))},h.prototype.error=function(_){var m=this._sources;if(!l.prototype.error.call(this,_))return!1;for(var p=0;p<m.length;p++)try{m[p].error(_)}catch{}return!0},h.prototype.lock=function(){l.prototype.lock.call(this);for(var _=this._sources,m=0;m<_.length;m++)_[m].lock()},i.exports=h},{"../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,x){var C=y||x,E=s[C];if(!E)throw new Error(C+" is not a valid compression method !");return E})(_.options.compression,l.compression),p=_.options.compressionOptions||l.compressionOptions||{},g=_.dir,f=_.date;_._compressWorker(m,p).withStreamInfo("file",{name:h,dir:g,date:f,comment:_.comment||"",unixPermissions:_.unixPermissions,dosPermissions:_.dosPermissions}).pipe(u)}),u.entriesCount=d}catch(h){u.error(h)}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(h){return new a.Promise(function(_,m){var p=h.decompressed.getContentWorker().pipe(new A);p.on("error",function(g){m(g)}).on("end",function(){p.streamInfo.crc32!==h.decompressed.crc32?m(new Error("Corrupted zip : CRC32 mismatch")):_()}).resume()})}i.exports=function(h,_){var m=this;return _=s.extend(_||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:c.utf8decode}),u.isNode&&u.isStream(h)?a.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):s.prepareContent("the loaded zip file",h,!0,_.optimizedBinaryString,_.base64).then(function(p){var g=new l(_);return g.load(p),g}).then(function(p){var g=[a.Promise.resolve(p)],f=p.files;if(_.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 x=f[y],C=x.fileNameStr,E=s.resolve(x.fileNameStr);m.file(E,x.decompressed,{binary:!0,optimizedBinaryString:!0,date:x.date,dir:x.dir,comment:x.fileCommentStr.length?x.fileCommentStr:null,unixPermissions:x.unixPermissions,dosPermissions:x.dosPermissions,createFolders:_.createFolders}),x.dir||(m.file(E).unsafeOriginalName=C)}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,h){u.push(d)||u._helper.pause(),A&&A(h)}).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 Q=w==="string"&&k.binary===!1&&k.base64===!1;P&&P.binary!==void 0||(k.binary=!Q),(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 F=new h(E,O,k);this.files[E]=F}var a=o("./utf8"),c=o("./utils"),l=o("./stream/GenericWorker"),A=o("./stream/StreamHelper"),u=o("./defaults"),d=o("./compressedObject"),h=o("./zipObject"),_=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 x(E){return Object.prototype.toString.call(E)==="[object RegExp]"}var C={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(x(E)){var M=E;return this.filter(function(k,Q){return!Q.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(x(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=_.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=C},{"./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),h=this.length-4;0<=h;--h)if(this.data[h]===l&&this.data[h+1]===A&&this.data[h+2]===u&&this.data[h+3]===d)return h-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),h=this.readData(4);return l===h[0]&&A===h[1]&&u===h[2]&&d===h[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 h=s.getTypeOf(d);return s.checkSupport(h),h!=="string"||a.uint8array?h==="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 h(m,p){return new u.Promise(function(g,f){var y=[],x=m._internalType,C=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)}})(C,(function(P,M){var w,k=0,Q=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(Q=new Uint8Array(O),w=0;w<M.length;w++)Q.set(M[w],k),k+=M[w].length;return Q;case"nodebuffer":return Buffer.concat(M);default:throw new Error("concat : unsupported type '"+P+"'")}})(x,y),E);g(b)}catch(P){f(P)}y=[]}).resume()})}function _(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)}}_.prototype={accumulate:function(m){return h(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=_},{"../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 h(){l.call(this,"utf-8 encode")}r.utf8encode=function(_){return a.nodebuffer?c.newBufferFrom(_,"utf-8"):(function(m){var p,g,f,y,x,C=m.length,E=0;for(y=0;y<C;y++)(64512&(g=m.charCodeAt(y)))==55296&&y+1<C&&(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=x=0;x<E;y++)(64512&(g=m.charCodeAt(y)))==55296&&y+1<C&&(64512&(f=m.charCodeAt(y+1)))==56320&&(g=65536+(g-55296<<10)+(f-56320),y++),g<128?p[x++]=g:(g<2048?p[x++]=192|g>>>6:(g<65536?p[x++]=224|g>>>12:(p[x++]=240|g>>>18,p[x++]=128|g>>>12&63),p[x++]=128|g>>>6&63),p[x++]=128|63&g);return p})(_)},r.utf8decode=function(_){return a.nodebuffer?s.transformTo("nodebuffer",_).toString("utf-8"):(function(m){var p,g,f,y,x=m.length,C=new Array(2*x);for(p=g=0;p<x;)if((f=m[p++])<128)C[g++]=f;else if(4<(y=A[f]))C[g++]=65533,p+=y-1;else{for(f&=y===2?31:y===3?15:7;1<y&&p<x;)f=f<<6|63&m[p++],y--;1<y?C[g++]=65533:f<65536?C[g++]=f:(f-=65536,C[g++]=55296|f>>10&1023,C[g++]=56320|1023&f)}return C.length!==g&&(C.subarray?C=C.subarray(0,g):C.length=g),s.applyFromCharCode(C)})(_=s.transformTo(a.uint8array?"uint8array":"array",_))},s.inherits(d,l),d.prototype.processChunk=function(_){var m=s.transformTo(a.uint8array?"uint8array":"array",_.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,x){var C;for((x=x||y.length)>y.length&&(x=y.length),C=x-1;0<=C&&(192&y[C])==128;)C--;return C<0||C===0?x:C+A[y[C]]>x?C:x})(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:_.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(h,l),h.prototype.processChunk=function(_){this.push({data:r.utf8encode(_.data),meta:_.meta})},r.Utf8EncodeWorker=h},{"./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=[],x=0,C=p.length;if(C<=f)return String.fromCharCode.apply(null,p);for(;x<C;)g==="array"||g==="nodebuffer"?y.push(String.fromCharCode.apply(null,p.slice(x,Math.min(x+f,C)))):y.push(String.fromCharCode.apply(null,p.subarray(x,Math.min(x+f,C)))),x+=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 h(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 _(p,g){for(var f=0;f<p.length;f++)g[f]=p[f];return g}r.applyFromCharCode=h;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:h,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 h(new Uint8Array(p))},array:function(p){return _(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:h,array:function(p){return _(p,new Array(p.length))},arraybuffer:function(p){return p.buffer},uint8array:A,nodebuffer:function(p){return c.newBufferFrom(p)}},m.nodebuffer={string:h,array:function(p){return _(p,new Array(p.length))},arraybuffer:function(p){return m.nodebuffer.uint8array(p).buffer},uint8array:function(p){return _(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 x=g[y];x==="."||x===""&&y!==0&&y!==g.length-1||(x===".."?f.pop():f.push(x))}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,x){return l.Promise.resolve(g).then(function(C){return s.blob&&(C instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(C))!==-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(C)}):C}).then(function(C){var E=r.getTypeOf(C);return E?(E==="arraybuffer"?C=r.transformTo("uint8array",C):E==="string"&&(x?C=a.decode(C):f&&y!==!0&&(C=(function(b){return u(b,s.uint8array?new Uint8Array(b.length):new Array(b.length))})(C))),C):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 h=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+a.pretty(h)+", expected "+a.pretty(d)+")")}},isSignature:function(d,h){var _=this.reader.index;this.reader.setIndex(d);var m=this.reader.readString(4)===h;return this.reader.setIndex(_),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),h=A.uint8array?"uint8array":"array",_=a.transformTo(h,d);this.zipComment=this.loadOptions.decodeFileName(_)},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),h=this.reader.readInt(4),_=this.reader.readData(h),this.zip64ExtensibleData[d]={id:d,length:h,value:_}},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,h;for(d=0;d<this.files.length;d++)h=this.files[d],this.reader.setIndex(h.localHeaderOffset),this.checkSignature(c.LOCAL_FILE_HEADER),h.readLocalPart(this.reader),h.handleUTF8(),h.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 h=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 _=this.centralDirOffset+this.centralDirSize;this.zip64&&(_+=20,_+=12+this.zip64EndOfCentralSize);var m=h-_;if(0<m)this.isSignature(h,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=_,this.loadOptions=m}h.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(_){var m,p;if(_.skip(22),this.fileNameLength=_.readInt(2),p=_.readInt(2),this.fileName=_.readData(this.fileNameLength),_.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,_.readData(this.compressedSize))},readCentralPart:function(_){this.versionMadeBy=_.readInt(2),_.skip(2),this.bitFlag=_.readInt(2),this.compressionMethod=_.readString(2),this.date=_.readDate(),this.crc32=_.readInt(4),this.compressedSize=_.readInt(4),this.uncompressedSize=_.readInt(4);var m=_.readInt(2);if(this.extraFieldsLength=_.readInt(2),this.fileCommentLength=_.readInt(2),this.diskNumberStart=_.readInt(2),this.internalFileAttributes=_.readInt(2),this.externalFileAttributes=_.readInt(4),this.localHeaderOffset=_.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");_.skip(m),this.readExtraFields(_),this.parseZIP64ExtraField(_),this.fileComment=_.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var _=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),_==0&&(this.dosPermissions=63&this.externalFileAttributes),_==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var _=s(this.extraFields[1].value);this.uncompressedSize===a.MAX_VALUE_32BITS&&(this.uncompressedSize=_.readInt(8)),this.compressedSize===a.MAX_VALUE_32BITS&&(this.compressedSize=_.readInt(8)),this.localHeaderOffset===a.MAX_VALUE_32BITS&&(this.localHeaderOffset=_.readInt(8)),this.diskNumberStart===a.MAX_VALUE_32BITS&&(this.diskNumberStart=_.readInt(4))}},readExtraFields:function(_){var m,p,g,f=_.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});_.index+4<f;)m=_.readInt(2),p=_.readInt(2),g=_.readData(p),this.extraFields[m]={id:m,length:p,value:g};_.setIndex(f)},handleUTF8:function(){var _=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(_,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(p)}var g=this.findExtraFieldUnicodeComment();if(g!==null)this.fileCommentStr=g;else{var f=a.transformTo(_,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(f)}}},findExtraFieldUnicodePath:function(){var _=this.extraFields[28789];if(_){var m=s(_.value);return m.readInt(1)!==1||l(this.fileName)!==m.readInt(4)?null:A.utf8decode(m.readData(_.length-5))}return null},findExtraFieldUnicodeComment:function(){var _=this.extraFields[25461];if(_){var m=s(_.value);return m.readInt(1)!==1||l(this.fileComment)!==m.readInt(4)?null:A.utf8decode(m.readData(_.length-5))}return null}},i.exports=h},{"./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(x){(p=new u("error")).error(x)}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"],h=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},_=0;_<d.length;_++)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 h=new s.MessageChannel;h.port1.onmessage=m,a=function(){h.port2.postMessage(0)}}var _=[];function m(){var p,g;c=!0;for(var f=_.length;f;){for(g=_,_=[],p=-1;++p<f;)g[p]();f=_.length}c=!1}i.exports=function(p){_.push(p)!==1||c||a()}}).call(this,typeof gz<"u"?gz: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 h(f,y,x){this.promise=f,typeof y=="function"&&(this.onFulfilled=y,this.callFulfilled=this.otherCallFulfilled),typeof x=="function"&&(this.onRejected=x,this.callRejected=this.otherCallRejected)}function _(f,y,x){s(function(){var C;try{C=y(x)}catch(E){return c.reject(f,E)}C===f?c.reject(f,new TypeError("Cannot resolve promise with itself")):c.resolve(f,C)})}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 x=!1;function C(P){x||(x=!0,c.reject(f,P))}function E(P){x||(x=!0,c.resolve(f,P))}var b=g(function(){y(E,C)});b.status==="error"&&C(b.value)}function g(f,y){var x={};try{x.value=f(y),x.status="success"}catch(C){x.status="error",x.value=C}return x}(i.exports=d).prototype.finally=function(f){if(typeof f!="function")return this;var y=this.constructor;return this.then(function(x){return y.resolve(f()).then(function(){return x})},function(x){return y.resolve(f()).then(function(){throw x})})},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 x=new this.constructor(a);return this.state!==u?_(x,this.state===A?f:y,this.outcome):this.queue.push(new h(x,f,y)),x},h.prototype.callFulfilled=function(f){c.resolve(this.promise,f)},h.prototype.otherCallFulfilled=function(f){_(this.promise,this.onFulfilled,f)},h.prototype.callRejected=function(f){c.reject(this.promise,f)},h.prototype.otherCallRejected=function(f){_(this.promise,this.onRejected,f)},c.resolve=function(f,y){var x=g(m,y);if(x.status==="error")return c.reject(f,x.value);var C=x.value;if(C)p(f,C);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 x=-1,C=f.queue.length;++x<C;)f.queue[x].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 x=f.length,C=!1;if(!x)return this.resolve([]);for(var E=new Array(x),b=0,P=-1,M=new this(a);++P<x;)w(f[P],P);return M;function w(k,Q){y.resolve(k).then(function(O){E[Q]=O,++b!==x||C||(C=!0,c.resolve(M,E))},function(O){C||(C=!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 x=f.length,C=!1;if(!x)return this.resolve([]);for(var E=-1,b=new this(a);++E<x;)P=f[E],y.resolve(P).then(function(M){C||(C=!0,c.resolve(b,M))},function(M){C||(C=!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,h=-1,_=0,m=8;function p(f){if(!(this instanceof p))return new p(f);this.options=a.assign({level:h,method:m,chunkSize:16384,windowBits:15,memLevel:8,strategy:_,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 x=s.deflateInit2(this.strm,y.level,y.method,y.windowBits,y.memLevel,y.strategy);if(x!==d)throw new Error(l[x]);if(y.header&&s.deflateSetHeader(this.strm,y.header),y.dictionary){var C;if(C=typeof y.dictionary=="string"?c.string2buf(y.dictionary):u.call(y.dictionary)==="[object ArrayBuffer]"?new Uint8Array(y.dictionary):y.dictionary,(x=s.deflateSetDictionary(this.strm,C))!==d)throw new Error(l[x]);this._dict_set=!0}}function g(f,y){var x=new p(y);if(x.push(f,!0),x.err)throw x.msg||l[x.err];return x.result}p.prototype.push=function(f,y){var x,C,E=this.strm,b=this.options.chunkSize;if(this.ended)return!1;C=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),(x=s.deflate(E,C))!==1&&x!==d)return this.onEnd(x),!(this.ended=!0);E.avail_out!==0&&(E.avail_in!==0||C!==4&&C!==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)&&x!==1);return C===4?(x=s.deflateEnd(this.strm),this.onEnd(x),this.ended=!0,x===d):C!==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"),h=Object.prototype.toString;function _(p){if(!(this instanceof _))return new _(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 _(g);if(f.push(p,!0),f.err)throw f.msg||A[f.err];return f.result}_.prototype.push=function(p,g){var f,y,x,C,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):h.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):h.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"?(x=c.utf8border(P.output,P.next_out),C=P.next_out-x,E=c.buf2string(P.output,x),P.next_out=C,P.avail_out=M-C,C&&a.arraySet(P.output,P.output,x,C,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))},_.prototype.onData=function(p){this.chunks.push(p)},_.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=_,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,h){if(A.subarray&&l.subarray)l.set(A.subarray(u,u+d),h);else for(var _=0;_<d;_++)l[h+_]=A[u+_]},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=h=0,u=l.length;A<u;A++)_=l[A],m.set(_,h),h+=_.length;return m}},c={arraySet:function(l,A,u,d,h){for(var _=0;_<d;_++)l[h+_]=A[u+_]},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,h){if(h<65537&&(d.subarray&&c||!d.subarray&&a))return String.fromCharCode.apply(null,s.shrinkBuf(d,h));for(var _="",m=0;m<h;m++)_+=String.fromCharCode(d[m]);return _}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&(_=d.charCodeAt(p)))==55296&&p+1<f&&(64512&(m=d.charCodeAt(p+1)))==56320&&(_=65536+(_-55296<<10)+(m-56320),p++),y+=_<128?1:_<2048?2:_<65536?3:4;for(h=new s.Buf8(y),p=g=0;g<y;p++)(64512&(_=d.charCodeAt(p)))==55296&&p+1<f&&(64512&(m=d.charCodeAt(p+1)))==56320&&(_=65536+(_-55296<<10)+(m-56320),p++),_<128?h[g++]=_:(_<2048?h[g++]=192|_>>>6:(_<65536?h[g++]=224|_>>>12:(h[g++]=240|_>>>18,h[g++]=128|_>>>12&63),h[g++]=128|_>>>6&63),h[g++]=128|63&_);return h},r.buf2binstring=function(d){return u(d,d.length)},r.binstring2buf=function(d){for(var h=new s.Buf8(d.length),_=0,m=h.length;_<m;_++)h[_]=d.charCodeAt(_);return h},r.buf2string=function(d,h){var _,m,p,g,f=h||d.length,y=new Array(2*f);for(_=m=0;_<f;)if((p=d[_++])<128)y[m++]=p;else if(4<(g=l[p]))y[m++]=65533,_+=g-1;else{for(p&=g===2?31:g===3?15:7;1<g&&_<f;)p=p<<6|63&d[_++],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,h){var _;for((h=h||d.length)>d.length&&(h=d.length),_=h-1;0<=_&&(192&d[_])==128;)_--;return _<0||_===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 h=A;h<d;h++)a=a>>>8^u[255&(a^c[h])];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,h=4,_=0,m=-2,p=-1,g=4,f=2,y=8,x=9,C=286,E=30,b=19,P=2*C+1,M=15,w=3,k=258,Q=k+w+1,O=42,F=113,z=1,K=2,$=3,J=4;function oe(fe,Ze){return fe.msg=u[Ze],Ze}function ue(fe){return(fe<<1)-(4<fe?9:0)}function ne(fe){for(var Ze=fe.length;0<=--Ze;)fe[Ze]=0}function ie(fe){var Ze=fe.state,Ue=Ze.pending;Ue>fe.avail_out&&(Ue=fe.avail_out),Ue!==0&&(a.arraySet(fe.output,Ze.pending_buf,Ze.pending_out,Ue,fe.next_out),fe.next_out+=Ue,Ze.pending_out+=Ue,fe.total_out+=Ue,fe.avail_out-=Ue,Ze.pending-=Ue,Ze.pending===0&&(Ze.pending_out=0))}function ce(fe,Ze){c._tr_flush_block(fe,0<=fe.block_start?fe.block_start:-1,fe.strstart-fe.block_start,Ze),fe.block_start=fe.strstart,ie(fe.strm)}function re(fe,Ze){fe.pending_buf[fe.pending++]=Ze}function le(fe,Ze){fe.pending_buf[fe.pending++]=Ze>>>8&255,fe.pending_buf[fe.pending++]=255&Ze}function xe(fe,Ze){var Ue,Qe,Ye=fe.max_chain_length,Ne=fe.strstart,Ie=fe.prev_length,Oe=fe.nice_match,Me=fe.strstart>fe.w_size-Q?fe.strstart-(fe.w_size-Q):0,We=fe.window,Je=fe.w_mask,ct=fe.prev,lt=fe.strstart+k,dt=We[Ne+Ie-1],At=We[Ne+Ie];fe.prev_length>=fe.good_match&&(Ye>>=2),Oe>fe.lookahead&&(Oe=fe.lookahead);do if(We[(Ue=Ze)+Ie]===At&&We[Ue+Ie-1]===dt&&We[Ue]===We[Ne]&&We[++Ue]===We[Ne+1]){Ne+=2,Ue++;do;while(We[++Ne]===We[++Ue]&&We[++Ne]===We[++Ue]&&We[++Ne]===We[++Ue]&&We[++Ne]===We[++Ue]&&We[++Ne]===We[++Ue]&&We[++Ne]===We[++Ue]&&We[++Ne]===We[++Ue]&&We[++Ne]===We[++Ue]&&Ne<lt);if(Qe=k-(lt-Ne),Ne=lt-k,Ie<Qe){if(fe.match_start=Ze,Oe<=(Ie=Qe))break;dt=We[Ne+Ie-1],At=We[Ne+Ie]}}while((Ze=ct[Ze&Je])>Me&&--Ye!=0);return Ie<=fe.lookahead?Ie:fe.lookahead}function be(fe){var Ze,Ue,Qe,Ye,Ne,Ie,Oe,Me,We,Je,ct=fe.w_size;do{if(Ye=fe.window_size-fe.lookahead-fe.strstart,fe.strstart>=ct+(ct-Q)){for(a.arraySet(fe.window,fe.window,ct,ct,0),fe.match_start-=ct,fe.strstart-=ct,fe.block_start-=ct,Ze=Ue=fe.hash_size;Qe=fe.head[--Ze],fe.head[Ze]=ct<=Qe?Qe-ct:0,--Ue;);for(Ze=Ue=ct;Qe=fe.prev[--Ze],fe.prev[Ze]=ct<=Qe?Qe-ct:0,--Ue;);Ye+=ct}if(fe.strm.avail_in===0)break;if(Ie=fe.strm,Oe=fe.window,Me=fe.strstart+fe.lookahead,We=Ye,Je=void 0,Je=Ie.avail_in,We<Je&&(Je=We),Ue=Je===0?0:(Ie.avail_in-=Je,a.arraySet(Oe,Ie.input,Ie.next_in,Je,Me),Ie.state.wrap===1?Ie.adler=l(Ie.adler,Oe,Je,Me):Ie.state.wrap===2&&(Ie.adler=A(Ie.adler,Oe,Je,Me)),Ie.next_in+=Je,Ie.total_in+=Je,Je),fe.lookahead+=Ue,fe.lookahead+fe.insert>=w)for(Ne=fe.strstart-fe.insert,fe.ins_h=fe.window[Ne],fe.ins_h=(fe.ins_h<<fe.hash_shift^fe.window[Ne+1])&fe.hash_mask;fe.insert&&(fe.ins_h=(fe.ins_h<<fe.hash_shift^fe.window[Ne+w-1])&fe.hash_mask,fe.prev[Ne&fe.w_mask]=fe.head[fe.ins_h],fe.head[fe.ins_h]=Ne,Ne++,fe.insert--,!(fe.lookahead+fe.insert<w)););}while(fe.lookahead<Q&&fe.strm.avail_in!==0)}function ve(fe,Ze){for(var Ue,Qe;;){if(fe.lookahead<Q){if(be(fe),fe.lookahead<Q&&Ze===d)return z;if(fe.lookahead===0)break}if(Ue=0,fe.lookahead>=w&&(fe.ins_h=(fe.ins_h<<fe.hash_shift^fe.window[fe.strstart+w-1])&fe.hash_mask,Ue=fe.prev[fe.strstart&fe.w_mask]=fe.head[fe.ins_h],fe.head[fe.ins_h]=fe.strstart),Ue!==0&&fe.strstart-Ue<=fe.w_size-Q&&(fe.match_length=xe(fe,Ue)),fe.match_length>=w)if(Qe=c._tr_tally(fe,fe.strstart-fe.match_start,fe.match_length-w),fe.lookahead-=fe.match_length,fe.match_length<=fe.max_lazy_match&&fe.lookahead>=w){for(fe.match_length--;fe.strstart++,fe.ins_h=(fe.ins_h<<fe.hash_shift^fe.window[fe.strstart+w-1])&fe.hash_mask,Ue=fe.prev[fe.strstart&fe.w_mask]=fe.head[fe.ins_h],fe.head[fe.ins_h]=fe.strstart,--fe.match_length!=0;);fe.strstart++}else fe.strstart+=fe.match_length,fe.match_length=0,fe.ins_h=fe.window[fe.strstart],fe.ins_h=(fe.ins_h<<fe.hash_shift^fe.window[fe.strstart+1])&fe.hash_mask;else Qe=c._tr_tally(fe,0,fe.window[fe.strstart]),fe.lookahead--,fe.strstart++;if(Qe&&(ce(fe,!1),fe.strm.avail_out===0))return z}return fe.insert=fe.strstart<w-1?fe.strstart:w-1,Ze===h?(ce(fe,!0),fe.strm.avail_out===0?$:J):fe.last_lit&&(ce(fe,!1),fe.strm.avail_out===0)?z:K}function _e(fe,Ze){for(var Ue,Qe,Ye;;){if(fe.lookahead<Q){if(be(fe),fe.lookahead<Q&&Ze===d)return z;if(fe.lookahead===0)break}if(Ue=0,fe.lookahead>=w&&(fe.ins_h=(fe.ins_h<<fe.hash_shift^fe.window[fe.strstart+w-1])&fe.hash_mask,Ue=fe.prev[fe.strstart&fe.w_mask]=fe.head[fe.ins_h],fe.head[fe.ins_h]=fe.strstart),fe.prev_length=fe.match_length,fe.prev_match=fe.match_start,fe.match_length=w-1,Ue!==0&&fe.prev_length<fe.max_lazy_match&&fe.strstart-Ue<=fe.w_size-Q&&(fe.match_length=xe(fe,Ue),fe.match_length<=5&&(fe.strategy===1||fe.match_length===w&&4096<fe.strstart-fe.match_start)&&(fe.match_length=w-1)),fe.prev_length>=w&&fe.match_length<=fe.prev_length){for(Ye=fe.strstart+fe.lookahead-w,Qe=c._tr_tally(fe,fe.strstart-1-fe.prev_match,fe.prev_length-w),fe.lookahead-=fe.prev_length-1,fe.prev_length-=2;++fe.strstart<=Ye&&(fe.ins_h=(fe.ins_h<<fe.hash_shift^fe.window[fe.strstart+w-1])&fe.hash_mask,Ue=fe.prev[fe.strstart&fe.w_mask]=fe.head[fe.ins_h],fe.head[fe.ins_h]=fe.strstart),--fe.prev_length!=0;);if(fe.match_available=0,fe.match_length=w-1,fe.strstart++,Qe&&(ce(fe,!1),fe.strm.avail_out===0))return z}else if(fe.match_available){if((Qe=c._tr_tally(fe,0,fe.window[fe.strstart-1]))&&ce(fe,!1),fe.strstart++,fe.lookahead--,fe.strm.avail_out===0)return z}else fe.match_available=1,fe.strstart++,fe.lookahead--}return fe.match_available&&(Qe=c._tr_tally(fe,0,fe.window[fe.strstart-1]),fe.match_available=0),fe.insert=fe.strstart<w-1?fe.strstart:w-1,Ze===h?(ce(fe,!0),fe.strm.avail_out===0?$:J):fe.last_lit&&(ce(fe,!1),fe.strm.avail_out===0)?z:K}function Pe(fe,Ze,Ue,Qe,Ye){this.good_length=fe,this.max_lazy=Ze,this.nice_length=Ue,this.max_chain=Qe,this.func=Ye}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*C+1),ne(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new a.Buf16(2*C+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 Ge(fe){var Ze;return fe&&fe.state?(fe.total_in=fe.total_out=0,fe.data_type=f,(Ze=fe.state).pending=0,Ze.pending_out=0,Ze.wrap<0&&(Ze.wrap=-Ze.wrap),Ze.status=Ze.wrap?O:F,fe.adler=Ze.wrap===2?0:1,Ze.last_flush=d,c._tr_init(Ze),_):oe(fe,m)}function Le(fe){var Ze=Ge(fe);return Ze===_&&(function(Ue){Ue.window_size=2*Ue.w_size,ne(Ue.head),Ue.max_lazy_match=s[Ue.level].max_lazy,Ue.good_match=s[Ue.level].good_length,Ue.nice_match=s[Ue.level].nice_length,Ue.max_chain_length=s[Ue.level].max_chain,Ue.strstart=0,Ue.block_start=0,Ue.lookahead=0,Ue.insert=0,Ue.match_length=Ue.prev_length=w-1,Ue.match_available=0,Ue.ins_h=0})(fe.state),Ze}function $e(fe,Ze,Ue,Qe,Ye,Ne){if(!fe)return m;var Ie=1;if(Ze===p&&(Ze=6),Qe<0?(Ie=0,Qe=-Qe):15<Qe&&(Ie=2,Qe-=16),Ye<1||x<Ye||Ue!==y||Qe<8||15<Qe||Ze<0||9<Ze||Ne<0||g<Ne)return oe(fe,m);Qe===8&&(Qe=9);var Oe=new pe;return(fe.state=Oe).strm=fe,Oe.wrap=Ie,Oe.gzhead=null,Oe.w_bits=Qe,Oe.w_size=1<<Oe.w_bits,Oe.w_mask=Oe.w_size-1,Oe.hash_bits=Ye+7,Oe.hash_size=1<<Oe.hash_bits,Oe.hash_mask=Oe.hash_size-1,Oe.hash_shift=~~((Oe.hash_bits+w-1)/w),Oe.window=new a.Buf8(2*Oe.w_size),Oe.head=new a.Buf16(Oe.hash_size),Oe.prev=new a.Buf16(Oe.w_size),Oe.lit_bufsize=1<<Ye+6,Oe.pending_buf_size=4*Oe.lit_bufsize,Oe.pending_buf=new a.Buf8(Oe.pending_buf_size),Oe.d_buf=1*Oe.lit_bufsize,Oe.l_buf=3*Oe.lit_bufsize,Oe.level=Ze,Oe.strategy=Ne,Oe.method=Ue,Le(fe)}s=[new Pe(0,0,0,0,function(fe,Ze){var Ue=65535;for(Ue>fe.pending_buf_size-5&&(Ue=fe.pending_buf_size-5);;){if(fe.lookahead<=1){if(be(fe),fe.lookahead===0&&Ze===d)return z;if(fe.lookahead===0)break}fe.strstart+=fe.lookahead,fe.lookahead=0;var Qe=fe.block_start+Ue;if((fe.strstart===0||fe.strstart>=Qe)&&(fe.lookahead=fe.strstart-Qe,fe.strstart=Qe,ce(fe,!1),fe.strm.avail_out===0)||fe.strstart-fe.block_start>=fe.w_size-Q&&(ce(fe,!1),fe.strm.avail_out===0))return z}return fe.insert=0,Ze===h?(ce(fe,!0),fe.strm.avail_out===0?$:J):(fe.strstart>fe.block_start&&(ce(fe,!1),fe.strm.avail_out),z)}),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,_e),new Pe(8,16,32,32,_e),new Pe(8,16,128,128,_e),new Pe(8,32,128,256,_e),new Pe(32,128,258,1024,_e),new Pe(32,258,258,4096,_e)],r.deflateInit=function(fe,Ze){return $e(fe,Ze,y,15,8,0)},r.deflateInit2=$e,r.deflateReset=Le,r.deflateResetKeep=Ge,r.deflateSetHeader=function(fe,Ze){return fe&&fe.state?fe.state.wrap!==2?m:(fe.state.gzhead=Ze,_):m},r.deflate=function(fe,Ze){var Ue,Qe,Ye,Ne;if(!fe||!fe.state||5<Ze||Ze<0)return fe?oe(fe,m):m;if(Qe=fe.state,!fe.output||!fe.input&&fe.avail_in!==0||Qe.status===666&&Ze!==h)return oe(fe,fe.avail_out===0?-5:m);if(Qe.strm=fe,Ue=Qe.last_flush,Qe.last_flush=Ze,Qe.status===O)if(Qe.wrap===2)fe.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&&(fe.adler=A(fe.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=F);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=F,le(Qe,Ie),Qe.strstart!==0&&(le(Qe,fe.adler>>>16),le(Qe,65535&fe.adler)),fe.adler=1}if(Qe.status===69)if(Qe.gzhead.extra){for(Ye=Qe.pending;Qe.gzindex<(65535&Qe.gzhead.extra.length)&&(Qe.pending!==Qe.pending_buf_size||(Qe.gzhead.hcrc&&Qe.pending>Ye&&(fe.adler=A(fe.adler,Qe.pending_buf,Qe.pending-Ye,Ye)),ie(fe),Ye=Qe.pending,Qe.pending!==Qe.pending_buf_size));)re(Qe,255&Qe.gzhead.extra[Qe.gzindex]),Qe.gzindex++;Qe.gzhead.hcrc&&Qe.pending>Ye&&(fe.adler=A(fe.adler,Qe.pending_buf,Qe.pending-Ye,Ye)),Qe.gzindex===Qe.gzhead.extra.length&&(Qe.gzindex=0,Qe.status=73)}else Qe.status=73;if(Qe.status===73)if(Qe.gzhead.name){Ye=Qe.pending;do{if(Qe.pending===Qe.pending_buf_size&&(Qe.gzhead.hcrc&&Qe.pending>Ye&&(fe.adler=A(fe.adler,Qe.pending_buf,Qe.pending-Ye,Ye)),ie(fe),Ye=Qe.pending,Qe.pending===Qe.pending_buf_size)){Ne=1;break}Ne=Qe.gzindex<Qe.gzhead.name.length?255&Qe.gzhead.name.charCodeAt(Qe.gzindex++):0,re(Qe,Ne)}while(Ne!==0);Qe.gzhead.hcrc&&Qe.pending>Ye&&(fe.adler=A(fe.adler,Qe.pending_buf,Qe.pending-Ye,Ye)),Ne===0&&(Qe.gzindex=0,Qe.status=91)}else Qe.status=91;if(Qe.status===91)if(Qe.gzhead.comment){Ye=Qe.pending;do{if(Qe.pending===Qe.pending_buf_size&&(Qe.gzhead.hcrc&&Qe.pending>Ye&&(fe.adler=A(fe.adler,Qe.pending_buf,Qe.pending-Ye,Ye)),ie(fe),Ye=Qe.pending,Qe.pending===Qe.pending_buf_size)){Ne=1;break}Ne=Qe.gzindex<Qe.gzhead.comment.length?255&Qe.gzhead.comment.charCodeAt(Qe.gzindex++):0,re(Qe,Ne)}while(Ne!==0);Qe.gzhead.hcrc&&Qe.pending>Ye&&(fe.adler=A(fe.adler,Qe.pending_buf,Qe.pending-Ye,Ye)),Ne===0&&(Qe.status=103)}else Qe.status=103;if(Qe.status===103&&(Qe.gzhead.hcrc?(Qe.pending+2>Qe.pending_buf_size&&ie(fe),Qe.pending+2<=Qe.pending_buf_size&&(re(Qe,255&fe.adler),re(Qe,fe.adler>>8&255),fe.adler=0,Qe.status=F)):Qe.status=F),Qe.pending!==0){if(ie(fe),fe.avail_out===0)return Qe.last_flush=-1,_}else if(fe.avail_in===0&&ue(Ze)<=ue(Ue)&&Ze!==h)return oe(fe,-5);if(Qe.status===666&&fe.avail_in!==0)return oe(fe,-5);if(fe.avail_in!==0||Qe.lookahead!==0||Ze!==d&&Qe.status!==666){var Oe=Qe.strategy===2?(function(Me,We){for(var Je;;){if(Me.lookahead===0&&(be(Me),Me.lookahead===0)){if(We===d)return z;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 z}return Me.insert=0,We===h?(ce(Me,!0),Me.strm.avail_out===0?$:J):Me.last_lit&&(ce(Me,!1),Me.strm.avail_out===0)?z:K})(Qe,Ze):Qe.strategy===3?(function(Me,We){for(var Je,ct,lt,dt,At=Me.window;;){if(Me.lookahead<=k){if(be(Me),Me.lookahead<=k&&We===d)return z;if(Me.lookahead===0)break}if(Me.match_length=0,Me.lookahead>=w&&0<Me.strstart&&(ct=At[lt=Me.strstart-1])===At[++lt]&&ct===At[++lt]&&ct===At[++lt]){dt=Me.strstart+k;do;while(ct===At[++lt]&&ct===At[++lt]&&ct===At[++lt]&&ct===At[++lt]&&ct===At[++lt]&&ct===At[++lt]&&ct===At[++lt]&&ct===At[++lt]&<<dt);Me.match_length=k-(dt-lt),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 z}return Me.insert=0,We===h?(ce(Me,!0),Me.strm.avail_out===0?$:J):Me.last_lit&&(ce(Me,!1),Me.strm.avail_out===0)?z:K})(Qe,Ze):s[Qe.level].func(Qe,Ze);if(Oe!==$&&Oe!==J||(Qe.status=666),Oe===z||Oe===$)return fe.avail_out===0&&(Qe.last_flush=-1),_;if(Oe===K&&(Ze===1?c._tr_align(Qe):Ze!==5&&(c._tr_stored_block(Qe,0,0,!1),Ze===3&&(ne(Qe.head),Qe.lookahead===0&&(Qe.strstart=0,Qe.block_start=0,Qe.insert=0))),ie(fe),fe.avail_out===0))return Qe.last_flush=-1,_}return Ze!==h?_:Qe.wrap<=0?1:(Qe.wrap===2?(re(Qe,255&fe.adler),re(Qe,fe.adler>>8&255),re(Qe,fe.adler>>16&255),re(Qe,fe.adler>>24&255),re(Qe,255&fe.total_in),re(Qe,fe.total_in>>8&255),re(Qe,fe.total_in>>16&255),re(Qe,fe.total_in>>24&255)):(le(Qe,fe.adler>>>16),le(Qe,65535&fe.adler)),ie(fe),0<Qe.wrap&&(Qe.wrap=-Qe.wrap),Qe.pending!==0?_:1)},r.deflateEnd=function(fe){var Ze;return fe&&fe.state?(Ze=fe.state.status)!==O&&Ze!==69&&Ze!==73&&Ze!==91&&Ze!==103&&Ze!==F&&Ze!==666?oe(fe,m):(fe.state=null,Ze===F?oe(fe,-3):_):m},r.deflateSetDictionary=function(fe,Ze){var Ue,Qe,Ye,Ne,Ie,Oe,Me,We,Je=Ze.length;if(!fe||!fe.state||(Ne=(Ue=fe.state).wrap)===2||Ne===1&&Ue.status!==O||Ue.lookahead)return m;for(Ne===1&&(fe.adler=l(fe.adler,Ze,Je,0)),Ue.wrap=0,Je>=Ue.w_size&&(Ne===0&&(ne(Ue.head),Ue.strstart=0,Ue.block_start=0,Ue.insert=0),We=new a.Buf8(Ue.w_size),a.arraySet(We,Ze,Je-Ue.w_size,Ue.w_size,0),Ze=We,Je=Ue.w_size),Ie=fe.avail_in,Oe=fe.next_in,Me=fe.input,fe.avail_in=Je,fe.next_in=0,fe.input=Ze,be(Ue);Ue.lookahead>=w;){for(Qe=Ue.strstart,Ye=Ue.lookahead-(w-1);Ue.ins_h=(Ue.ins_h<<Ue.hash_shift^Ue.window[Qe+w-1])&Ue.hash_mask,Ue.prev[Qe&Ue.w_mask]=Ue.head[Ue.ins_h],Ue.head[Ue.ins_h]=Qe,Qe++,--Ye;);Ue.strstart=Qe,Ue.lookahead=w-1,be(Ue)}return Ue.strstart+=Ue.lookahead,Ue.block_start=Ue.strstart,Ue.insert=Ue.lookahead,Ue.lookahead=0,Ue.match_length=Ue.prev_length=w-1,Ue.match_available=0,fe.next_in=Oe,fe.input=Me,fe.avail_in=Ie,Ue.wrap=Ne,_},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,x,C,E,b,P,M,w,k,Q,O,F,z,K;c=s.state,l=s.next_in,z=s.input,A=l+(s.avail_in-5),u=s.next_out,K=s.output,d=u-(a-s.avail_out),h=u+(s.avail_out-257),_=c.dmax,m=c.wsize,p=c.whave,g=c.wnext,f=c.window,y=c.hold,x=c.bits,C=c.lencode,E=c.distcode,b=(1<<c.lenbits)-1,P=(1<<c.distbits)-1;e:do{x<15&&(y+=z[l++]<<x,x+=8,y+=z[l++]<<x,x+=8),M=C[y&b];t:for(;;){if(y>>>=w=M>>>24,x-=w,(w=M>>>16&255)===0)K[u++]=65535&M;else{if(!(16&w)){if((64&w)==0){M=C[(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)&&(x<w&&(y+=z[l++]<<x,x+=8),k+=y&(1<<w)-1,y>>>=w,x-=w),x<15&&(y+=z[l++]<<x,x+=8,y+=z[l++]<<x,x+=8),M=E[y&P];n:for(;;){if(y>>>=w=M>>>24,x-=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(Q=65535&M,x<(w&=15)&&(y+=z[l++]<<x,(x+=8)<w&&(y+=z[l++]<<x,x+=8)),_<(Q+=y&(1<<w)-1)){s.msg="invalid distance too far back",c.mode=30;break e}if(y>>>=w,x-=w,(w=u-d)<Q){if(p<(w=Q-w)&&c.sane){s.msg="invalid distance too far back",c.mode=30;break e}if(F=f,(O=0)===g){if(O+=m-w,w<k){for(k-=w;K[u++]=f[O++],--w;);O=u-Q,F=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-Q,F=K}}}else if(O+=g-w,w<k){for(k-=w;K[u++]=f[O++],--w;);O=u-Q,F=K}for(;2<k;)K[u++]=F[O++],K[u++]=F[O++],K[u++]=F[O++],k-=3;k&&(K[u++]=F[O++],1<k&&(K[u++]=F[O++]))}else{for(O=u-Q;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<h);l-=k=x>>3,y&=(1<<(x-=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<h?h-u+257:257-(u-h),c.hold=y,c.bits=x}},{}],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,h=0,_=-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 x(O){var F;return O&&O.state?(F=O.state,O.total_in=O.total_out=F.total=0,O.msg="",F.wrap&&(O.adler=1&F.wrap),F.mode=m,F.last=0,F.havedict=0,F.dmax=32768,F.head=null,F.hold=0,F.bits=0,F.lencode=F.lendyn=new s.Buf32(p),F.distcode=F.distdyn=new s.Buf32(g),F.sane=1,F.back=-1,h):_}function C(O){var F;return O&&O.state?((F=O.state).wsize=0,F.whave=0,F.wnext=0,x(O)):_}function E(O,F){var z,K;return O&&O.state?(K=O.state,F<0?(z=0,F=-F):(z=1+(F>>4),F<48&&(F&=15)),F&&(F<8||15<F)?_:(K.window!==null&&K.wbits!==F&&(K.window=null),K.wrap=z,K.wbits=F,C(O))):_}function b(O,F){var z,K;return O?(K=new y,(O.state=K).window=null,(z=E(O,F))!==h&&(O.state=null),z):_}var P,M,w=!0;function k(O){if(w){var F;for(P=new s.Buf32(512),M=new s.Buf32(32),F=0;F<144;)O.lens[F++]=8;for(;F<256;)O.lens[F++]=9;for(;F<280;)O.lens[F++]=7;for(;F<288;)O.lens[F++]=8;for(A(u,O.lens,0,288,P,0,O.work,{bits:9}),F=0;F<32;)O.lens[F++]=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 Q(O,F,z,K){var $,J=O.state;return J.window===null&&(J.wsize=1<<J.wbits,J.wnext=0,J.whave=0,J.window=new s.Buf8(J.wsize)),K>=J.wsize?(s.arraySet(J.window,F,z-J.wsize,J.wsize,0),J.wnext=0,J.whave=J.wsize):(K<($=J.wsize-J.wnext)&&($=K),s.arraySet(J.window,F,z-K,$,J.wnext),(K-=$)?(s.arraySet(J.window,F,z-K,K,0),J.wnext=K,J.whave=J.wsize):(J.wnext+=$,J.wnext===J.wsize&&(J.wnext=0),J.whave<J.wsize&&(J.whave+=$))),0}r.inflateReset=C,r.inflateReset2=E,r.inflateResetKeep=x,r.inflateInit=function(O){return b(O,15)},r.inflateInit2=b,r.inflate=function(O,F){var z,K,$,J,oe,ue,ne,ie,ce,re,le,xe,be,ve,_e,Pe,pe,Ge,Le,$e,fe,Ze,Ue,Qe,Ye=0,Ne=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 _;(z=O.state).mode===12&&(z.mode=13),oe=O.next_out,$=O.output,ne=O.avail_out,J=O.next_in,K=O.input,ue=O.avail_in,ie=z.hold,ce=z.bits,re=ue,le=ne,Ze=h;e:for(;;)switch(z.mode){case m:if(z.wrap===0){z.mode=13;break}for(;ce<16;){if(ue===0)break e;ue--,ie+=K[J++]<<ce,ce+=8}if(2&z.wrap&&ie===35615){Ne[z.check=0]=255&ie,Ne[1]=ie>>>8&255,z.check=c(z.check,Ne,2,0),ce=ie=0,z.mode=2;break}if(z.flags=0,z.head&&(z.head.done=!1),!(1&z.wrap)||(((255&ie)<<8)+(ie>>8))%31){O.msg="incorrect header check",z.mode=30;break}if((15&ie)!=8){O.msg="unknown compression method",z.mode=30;break}if(ce-=4,fe=8+(15&(ie>>>=4)),z.wbits===0)z.wbits=fe;else if(fe>z.wbits){O.msg="invalid window size",z.mode=30;break}z.dmax=1<<fe,O.adler=z.check=1,z.mode=512&ie?10:12,ce=ie=0;break;case 2:for(;ce<16;){if(ue===0)break e;ue--,ie+=K[J++]<<ce,ce+=8}if(z.flags=ie,(255&z.flags)!=8){O.msg="unknown compression method",z.mode=30;break}if(57344&z.flags){O.msg="unknown header flags set",z.mode=30;break}z.head&&(z.head.text=ie>>8&1),512&z.flags&&(Ne[0]=255&ie,Ne[1]=ie>>>8&255,z.check=c(z.check,Ne,2,0)),ce=ie=0,z.mode=3;case 3:for(;ce<32;){if(ue===0)break e;ue--,ie+=K[J++]<<ce,ce+=8}z.head&&(z.head.time=ie),512&z.flags&&(Ne[0]=255&ie,Ne[1]=ie>>>8&255,Ne[2]=ie>>>16&255,Ne[3]=ie>>>24&255,z.check=c(z.check,Ne,4,0)),ce=ie=0,z.mode=4;case 4:for(;ce<16;){if(ue===0)break e;ue--,ie+=K[J++]<<ce,ce+=8}z.head&&(z.head.xflags=255&ie,z.head.os=ie>>8),512&z.flags&&(Ne[0]=255&ie,Ne[1]=ie>>>8&255,z.check=c(z.check,Ne,2,0)),ce=ie=0,z.mode=5;case 5:if(1024&z.flags){for(;ce<16;){if(ue===0)break e;ue--,ie+=K[J++]<<ce,ce+=8}z.length=ie,z.head&&(z.head.extra_len=ie),512&z.flags&&(Ne[0]=255&ie,Ne[1]=ie>>>8&255,z.check=c(z.check,Ne,2,0)),ce=ie=0}else z.head&&(z.head.extra=null);z.mode=6;case 6:if(1024&z.flags&&(ue<(xe=z.length)&&(xe=ue),xe&&(z.head&&(fe=z.head.extra_len-z.length,z.head.extra||(z.head.extra=new Array(z.head.extra_len)),s.arraySet(z.head.extra,K,J,xe,fe)),512&z.flags&&(z.check=c(z.check,K,xe,J)),ue-=xe,J+=xe,z.length-=xe),z.length))break e;z.length=0,z.mode=7;case 7:if(2048&z.flags){if(ue===0)break e;for(xe=0;fe=K[J+xe++],z.head&&fe&&z.length<65536&&(z.head.name+=String.fromCharCode(fe)),fe&&xe<ue;);if(512&z.flags&&(z.check=c(z.check,K,xe,J)),ue-=xe,J+=xe,fe)break e}else z.head&&(z.head.name=null);z.length=0,z.mode=8;case 8:if(4096&z.flags){if(ue===0)break e;for(xe=0;fe=K[J+xe++],z.head&&fe&&z.length<65536&&(z.head.comment+=String.fromCharCode(fe)),fe&&xe<ue;);if(512&z.flags&&(z.check=c(z.check,K,xe,J)),ue-=xe,J+=xe,fe)break e}else z.head&&(z.head.comment=null);z.mode=9;case 9:if(512&z.flags){for(;ce<16;){if(ue===0)break e;ue--,ie+=K[J++]<<ce,ce+=8}if(ie!==(65535&z.check)){O.msg="header crc mismatch",z.mode=30;break}ce=ie=0}z.head&&(z.head.hcrc=z.flags>>9&1,z.head.done=!0),O.adler=z.check=0,z.mode=12;break;case 10:for(;ce<32;){if(ue===0)break e;ue--,ie+=K[J++]<<ce,ce+=8}O.adler=z.check=f(ie),ce=ie=0,z.mode=11;case 11:if(z.havedict===0)return O.next_out=oe,O.avail_out=ne,O.next_in=J,O.avail_in=ue,z.hold=ie,z.bits=ce,2;O.adler=z.check=1,z.mode=12;case 12:if(F===5||F===6)break e;case 13:if(z.last){ie>>>=7&ce,ce-=7&ce,z.mode=27;break}for(;ce<3;){if(ue===0)break e;ue--,ie+=K[J++]<<ce,ce+=8}switch(z.last=1&ie,ce-=1,3&(ie>>>=1)){case 0:z.mode=14;break;case 1:if(k(z),z.mode=20,F!==6)break;ie>>>=2,ce-=2;break e;case 2:z.mode=17;break;case 3:O.msg="invalid block type",z.mode=30}ie>>>=2,ce-=2;break;case 14:for(ie>>>=7&ce,ce-=7&ce;ce<32;){if(ue===0)break e;ue--,ie+=K[J++]<<ce,ce+=8}if((65535&ie)!=(ie>>>16^65535)){O.msg="invalid stored block lengths",z.mode=30;break}if(z.length=65535&ie,ce=ie=0,z.mode=15,F===6)break e;case 15:z.mode=16;case 16:if(xe=z.length){if(ue<xe&&(xe=ue),ne<xe&&(xe=ne),xe===0)break e;s.arraySet($,K,J,xe,oe),ue-=xe,J+=xe,ne-=xe,oe+=xe,z.length-=xe;break}z.mode=12;break;case 17:for(;ce<14;){if(ue===0)break e;ue--,ie+=K[J++]<<ce,ce+=8}if(z.nlen=257+(31&ie),ie>>>=5,ce-=5,z.ndist=1+(31&ie),ie>>>=5,ce-=5,z.ncode=4+(15&ie),ie>>>=4,ce-=4,286<z.nlen||30<z.ndist){O.msg="too many length or distance symbols",z.mode=30;break}z.have=0,z.mode=18;case 18:for(;z.have<z.ncode;){for(;ce<3;){if(ue===0)break e;ue--,ie+=K[J++]<<ce,ce+=8}z.lens[Ie[z.have++]]=7&ie,ie>>>=3,ce-=3}for(;z.have<19;)z.lens[Ie[z.have++]]=0;if(z.lencode=z.lendyn,z.lenbits=7,Ue={bits:z.lenbits},Ze=A(0,z.lens,0,19,z.lencode,0,z.work,Ue),z.lenbits=Ue.bits,Ze){O.msg="invalid code lengths set",z.mode=30;break}z.have=0,z.mode=19;case 19:for(;z.have<z.nlen+z.ndist;){for(;Pe=(Ye=z.lencode[ie&(1<<z.lenbits)-1])>>>16&255,pe=65535&Ye,!((_e=Ye>>>24)<=ce);){if(ue===0)break e;ue--,ie+=K[J++]<<ce,ce+=8}if(pe<16)ie>>>=_e,ce-=_e,z.lens[z.have++]=pe;else{if(pe===16){for(Qe=_e+2;ce<Qe;){if(ue===0)break e;ue--,ie+=K[J++]<<ce,ce+=8}if(ie>>>=_e,ce-=_e,z.have===0){O.msg="invalid bit length repeat",z.mode=30;break}fe=z.lens[z.have-1],xe=3+(3&ie),ie>>>=2,ce-=2}else if(pe===17){for(Qe=_e+3;ce<Qe;){if(ue===0)break e;ue--,ie+=K[J++]<<ce,ce+=8}ce-=_e,fe=0,xe=3+(7&(ie>>>=_e)),ie>>>=3,ce-=3}else{for(Qe=_e+7;ce<Qe;){if(ue===0)break e;ue--,ie+=K[J++]<<ce,ce+=8}ce-=_e,fe=0,xe=11+(127&(ie>>>=_e)),ie>>>=7,ce-=7}if(z.have+xe>z.nlen+z.ndist){O.msg="invalid bit length repeat",z.mode=30;break}for(;xe--;)z.lens[z.have++]=fe}}if(z.mode===30)break;if(z.lens[256]===0){O.msg="invalid code -- missing end-of-block",z.mode=30;break}if(z.lenbits=9,Ue={bits:z.lenbits},Ze=A(u,z.lens,0,z.nlen,z.lencode,0,z.work,Ue),z.lenbits=Ue.bits,Ze){O.msg="invalid literal/lengths set",z.mode=30;break}if(z.distbits=6,z.distcode=z.distdyn,Ue={bits:z.distbits},Ze=A(d,z.lens,z.nlen,z.ndist,z.distcode,0,z.work,Ue),z.distbits=Ue.bits,Ze){O.msg="invalid distances set",z.mode=30;break}if(z.mode=20,F===6)break e;case 20:z.mode=21;case 21:if(6<=ue&&258<=ne){O.next_out=oe,O.avail_out=ne,O.next_in=J,O.avail_in=ue,z.hold=ie,z.bits=ce,l(O,le),oe=O.next_out,$=O.output,ne=O.avail_out,J=O.next_in,K=O.input,ue=O.avail_in,ie=z.hold,ce=z.bits,z.mode===12&&(z.back=-1);break}for(z.back=0;Pe=(Ye=z.lencode[ie&(1<<z.lenbits)-1])>>>16&255,pe=65535&Ye,!((_e=Ye>>>24)<=ce);){if(ue===0)break e;ue--,ie+=K[J++]<<ce,ce+=8}if(Pe&&(240&Pe)==0){for(Ge=_e,Le=Pe,$e=pe;Pe=(Ye=z.lencode[$e+((ie&(1<<Ge+Le)-1)>>Ge)])>>>16&255,pe=65535&Ye,!(Ge+(_e=Ye>>>24)<=ce);){if(ue===0)break e;ue--,ie+=K[J++]<<ce,ce+=8}ie>>>=Ge,ce-=Ge,z.back+=Ge}if(ie>>>=_e,ce-=_e,z.back+=_e,z.length=pe,Pe===0){z.mode=26;break}if(32&Pe){z.back=-1,z.mode=12;break}if(64&Pe){O.msg="invalid literal/length code",z.mode=30;break}z.extra=15&Pe,z.mode=22;case 22:if(z.extra){for(Qe=z.extra;ce<Qe;){if(ue===0)break e;ue--,ie+=K[J++]<<ce,ce+=8}z.length+=ie&(1<<z.extra)-1,ie>>>=z.extra,ce-=z.extra,z.back+=z.extra}z.was=z.length,z.mode=23;case 23:for(;Pe=(Ye=z.distcode[ie&(1<<z.distbits)-1])>>>16&255,pe=65535&Ye,!((_e=Ye>>>24)<=ce);){if(ue===0)break e;ue--,ie+=K[J++]<<ce,ce+=8}if((240&Pe)==0){for(Ge=_e,Le=Pe,$e=pe;Pe=(Ye=z.distcode[$e+((ie&(1<<Ge+Le)-1)>>Ge)])>>>16&255,pe=65535&Ye,!(Ge+(_e=Ye>>>24)<=ce);){if(ue===0)break e;ue--,ie+=K[J++]<<ce,ce+=8}ie>>>=Ge,ce-=Ge,z.back+=Ge}if(ie>>>=_e,ce-=_e,z.back+=_e,64&Pe){O.msg="invalid distance code",z.mode=30;break}z.offset=pe,z.extra=15&Pe,z.mode=24;case 24:if(z.extra){for(Qe=z.extra;ce<Qe;){if(ue===0)break e;ue--,ie+=K[J++]<<ce,ce+=8}z.offset+=ie&(1<<z.extra)-1,ie>>>=z.extra,ce-=z.extra,z.back+=z.extra}if(z.offset>z.dmax){O.msg="invalid distance too far back",z.mode=30;break}z.mode=25;case 25:if(ne===0)break e;if(xe=le-ne,z.offset>xe){if((xe=z.offset-xe)>z.whave&&z.sane){O.msg="invalid distance too far back",z.mode=30;break}be=xe>z.wnext?(xe-=z.wnext,z.wsize-xe):z.wnext-xe,xe>z.length&&(xe=z.length),ve=z.window}else ve=$,be=oe-z.offset,xe=z.length;for(ne<xe&&(xe=ne),ne-=xe,z.length-=xe;$[oe++]=ve[be++],--xe;);z.length===0&&(z.mode=21);break;case 26:if(ne===0)break e;$[oe++]=z.length,ne--,z.mode=21;break;case 27:if(z.wrap){for(;ce<32;){if(ue===0)break e;ue--,ie|=K[J++]<<ce,ce+=8}if(le-=ne,O.total_out+=le,z.total+=le,le&&(O.adler=z.check=z.flags?c(z.check,$,le,oe-le):a(z.check,$,le,oe-le)),le=ne,(z.flags?ie:f(ie))!==z.check){O.msg="incorrect data check",z.mode=30;break}ce=ie=0}z.mode=28;case 28:if(z.wrap&&z.flags){for(;ce<32;){if(ue===0)break e;ue--,ie+=K[J++]<<ce,ce+=8}if(ie!==(4294967295&z.total)){O.msg="incorrect length check",z.mode=30;break}ce=ie=0}z.mode=29;case 29:Ze=1;break e;case 30:Ze=-3;break e;case 31:return-4;default:return _}return O.next_out=oe,O.avail_out=ne,O.next_in=J,O.avail_in=ue,z.hold=ie,z.bits=ce,(z.wsize||le!==O.avail_out&&z.mode<30&&(z.mode<27||F!==4))&&Q(O,O.output,O.next_out,le-O.avail_out)?(z.mode=31,-4):(re-=O.avail_in,le-=O.avail_out,O.total_in+=re,O.total_out+=le,z.total+=le,z.wrap&&le&&(O.adler=z.check=z.flags?c(z.check,$,le,O.next_out-le):a(z.check,$,le,O.next_out-le)),O.data_type=z.bits+(z.last?64:0)+(z.mode===12?128:0)+(z.mode===20||z.mode===15?256:0),(re==0&&le===0||F===4)&&Ze===h&&(Ze=-5),Ze)},r.inflateEnd=function(O){if(!O||!O.state)return _;var F=O.state;return F.window&&(F.window=null),O.state=null,h},r.inflateGetHeader=function(O,F){var z;return O&&O.state?(2&(z=O.state).wrap)==0?_:((z.head=F).done=!1,h):_},r.inflateSetDictionary=function(O,F){var z,K=F.length;return O&&O.state?(z=O.state).wrap!==0&&z.mode!==11?_:z.mode===11&&a(1,F,K,0)!==z.check?-3:Q(O,F,K,K)?(z.mode=31,-4):(z.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,x,C,E,b,P,M,w,k,Q=f.bits,O=0,F=0,z=0,K=0,$=0,J=0,oe=0,ue=0,ne=0,ie=0,ce=null,re=0,le=new s.Buf16(16),xe=new s.Buf16(16),be=null,ve=0;for(O=0;O<=15;O++)le[O]=0;for(F=0;F<_;F++)le[d[h+F]]++;for($=Q,K=15;1<=K&&le[K]===0;K--);if(K<$&&($=K),K===0)return m[p++]=20971520,m[p++]=20971520,f.bits=1,0;for(z=1;z<K&&le[z]===0;z++);for($<z&&($=z),O=ue=1;O<=15;O++)if(ue<<=1,(ue-=le[O])<0)return-1;if(0<ue&&(u===0||K!==1))return-1;for(xe[1]=0,O=1;O<15;O++)xe[O+1]=xe[O]+le[O];for(F=0;F<_;F++)d[h+F]!==0&&(g[xe[d[h+F]]++]=F);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=z,b=p,oe=F=ie=0,C=-1,E=(ne=1<<(J=$))-1,u===1&&852<ne||u===2&&592<ne)return 1;for(;;){for(M=O-oe,k=g[F]<P?(w=0,g[F]):g[F]>P?(w=be[ve+g[F]],ce[re+g[F]]):(w=96,0),y=1<<O-oe,z=x=1<<J;m[b+(ie>>oe)+(x-=y)]=M<<24|w<<16|k|0,x!==0;);for(y=1<<O-1;ie&y;)y>>=1;if(y!==0?(ie&=y-1,ie+=y):ie=0,F++,--le[O]==0){if(O===K)break;O=d[h+g[F]]}if($<O&&(ie&E)!==C){for(oe===0&&(oe=$),b+=z,ue=1<<(J=O-oe);J+oe<K&&!((ue-=le[J+oe])<=0);)J++,ue<<=1;if(ne+=1<<J,u===1&&852<ne||u===2&&592<ne)return 1;m[C=ie&E]=$<<24|J<<16|b-p|0}}return ie!==0&&(m[b+ie]=O-oe<<24|64<<16|0),f.bits=$,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(Ye){for(var Ne=Ye.length;0<=--Ne;)Ye[Ne]=0}var A=0,u=29,d=256,h=d+1+u,_=30,m=19,p=2*h+1,g=15,f=16,y=7,x=256,C=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],Q=new Array(2*(h+2));l(Q);var O=new Array(2*_);l(O);var F=new Array(512);l(F);var z=new Array(256);l(z);var K=new Array(u);l(K);var $,J,oe,ue=new Array(_);function ne(Ye,Ne,Ie,Oe,Me){this.static_tree=Ye,this.extra_bits=Ne,this.extra_base=Ie,this.elems=Oe,this.max_length=Me,this.has_stree=Ye&&Ye.length}function ie(Ye,Ne){this.dyn_tree=Ye,this.max_code=0,this.stat_desc=Ne}function ce(Ye){return Ye<256?F[Ye]:F[256+(Ye>>>7)]}function re(Ye,Ne){Ye.pending_buf[Ye.pending++]=255&Ne,Ye.pending_buf[Ye.pending++]=Ne>>>8&255}function le(Ye,Ne,Ie){Ye.bi_valid>f-Ie?(Ye.bi_buf|=Ne<<Ye.bi_valid&65535,re(Ye,Ye.bi_buf),Ye.bi_buf=Ne>>f-Ye.bi_valid,Ye.bi_valid+=Ie-f):(Ye.bi_buf|=Ne<<Ye.bi_valid&65535,Ye.bi_valid+=Ie)}function xe(Ye,Ne,Ie){le(Ye,Ie[2*Ne],Ie[2*Ne+1])}function be(Ye,Ne){for(var Ie=0;Ie|=1&Ye,Ye>>>=1,Ie<<=1,0<--Ne;);return Ie>>>1}function ve(Ye,Ne,Ie){var Oe,Me,We=new Array(g+1),Je=0;for(Oe=1;Oe<=g;Oe++)We[Oe]=Je=Je+Ie[Oe-1]<<1;for(Me=0;Me<=Ne;Me++){var ct=Ye[2*Me+1];ct!==0&&(Ye[2*Me]=be(We[ct]++,ct))}}function _e(Ye){var Ne;for(Ne=0;Ne<h;Ne++)Ye.dyn_ltree[2*Ne]=0;for(Ne=0;Ne<_;Ne++)Ye.dyn_dtree[2*Ne]=0;for(Ne=0;Ne<m;Ne++)Ye.bl_tree[2*Ne]=0;Ye.dyn_ltree[2*x]=1,Ye.opt_len=Ye.static_len=0,Ye.last_lit=Ye.matches=0}function Pe(Ye){8<Ye.bi_valid?re(Ye,Ye.bi_buf):0<Ye.bi_valid&&(Ye.pending_buf[Ye.pending++]=Ye.bi_buf),Ye.bi_buf=0,Ye.bi_valid=0}function pe(Ye,Ne,Ie,Oe){var Me=2*Ne,We=2*Ie;return Ye[Me]<Ye[We]||Ye[Me]===Ye[We]&&Oe[Ne]<=Oe[Ie]}function Ge(Ye,Ne,Ie){for(var Oe=Ye.heap[Ie],Me=Ie<<1;Me<=Ye.heap_len&&(Me<Ye.heap_len&&pe(Ne,Ye.heap[Me+1],Ye.heap[Me],Ye.depth)&&Me++,!pe(Ne,Oe,Ye.heap[Me],Ye.depth));)Ye.heap[Ie]=Ye.heap[Me],Ie=Me,Me<<=1;Ye.heap[Ie]=Oe}function Le(Ye,Ne,Ie){var Oe,Me,We,Je,ct=0;if(Ye.last_lit!==0)for(;Oe=Ye.pending_buf[Ye.d_buf+2*ct]<<8|Ye.pending_buf[Ye.d_buf+2*ct+1],Me=Ye.pending_buf[Ye.l_buf+ct],ct++,Oe===0?xe(Ye,Me,Ne):(xe(Ye,(We=z[Me])+d+1,Ne),(Je=P[We])!==0&&le(Ye,Me-=K[We],Je),xe(Ye,We=ce(--Oe),Ie),(Je=M[We])!==0&&le(Ye,Oe-=ue[We],Je)),ct<Ye.last_lit;);xe(Ye,x,Ne)}function $e(Ye,Ne){var Ie,Oe,Me,We=Ne.dyn_tree,Je=Ne.stat_desc.static_tree,ct=Ne.stat_desc.has_stree,lt=Ne.stat_desc.elems,dt=-1;for(Ye.heap_len=0,Ye.heap_max=p,Ie=0;Ie<lt;Ie++)We[2*Ie]!==0?(Ye.heap[++Ye.heap_len]=dt=Ie,Ye.depth[Ie]=0):We[2*Ie+1]=0;for(;Ye.heap_len<2;)We[2*(Me=Ye.heap[++Ye.heap_len]=dt<2?++dt:0)]=1,Ye.depth[Me]=0,Ye.opt_len--,ct&&(Ye.static_len-=Je[2*Me+1]);for(Ne.max_code=dt,Ie=Ye.heap_len>>1;1<=Ie;Ie--)Ge(Ye,We,Ie);for(Me=lt;Ie=Ye.heap[1],Ye.heap[1]=Ye.heap[Ye.heap_len--],Ge(Ye,We,1),Oe=Ye.heap[1],Ye.heap[--Ye.heap_max]=Ie,Ye.heap[--Ye.heap_max]=Oe,We[2*Me]=We[2*Ie]+We[2*Oe],Ye.depth[Me]=(Ye.depth[Ie]>=Ye.depth[Oe]?Ye.depth[Ie]:Ye.depth[Oe])+1,We[2*Ie+1]=We[2*Oe+1]=Me,Ye.heap[1]=Me++,Ge(Ye,We,1),2<=Ye.heap_len;);Ye.heap[--Ye.heap_max]=Ye.heap[1],(function(At,xt){var Bt,ft,Dt,Ht,dn,un,Tn=xt.dyn_tree,ye=xt.max_code,rt=xt.stat_desc.static_tree,st=xt.stat_desc.has_stree,It=xt.stat_desc.extra_bits,Lt=xt.stat_desc.extra_base,zt=xt.stat_desc.max_length,ln=0;for(Ht=0;Ht<=g;Ht++)At.bl_count[Ht]=0;for(Tn[2*At.heap[At.heap_max]+1]=0,Bt=At.heap_max+1;Bt<p;Bt++)zt<(Ht=Tn[2*Tn[2*(ft=At.heap[Bt])+1]+1]+1)&&(Ht=zt,ln++),Tn[2*ft+1]=Ht,ye<ft||(At.bl_count[Ht]++,dn=0,Lt<=ft&&(dn=It[ft-Lt]),un=Tn[2*ft],At.opt_len+=un*(Ht+dn),st&&(At.static_len+=un*(rt[2*ft+1]+dn)));if(ln!==0){do{for(Ht=zt-1;At.bl_count[Ht]===0;)Ht--;At.bl_count[Ht]--,At.bl_count[Ht+1]+=2,At.bl_count[zt]--,ln-=2}while(0<ln);for(Ht=zt;Ht!==0;Ht--)for(ft=At.bl_count[Ht];ft!==0;)ye<(Dt=At.heap[--Bt])||(Tn[2*Dt+1]!==Ht&&(At.opt_len+=(Ht-Tn[2*Dt+1])*Tn[2*Dt],Tn[2*Dt+1]=Ht),ft--)}})(Ye,Ne),ve(We,dt,Ye.bl_count)}function fe(Ye,Ne,Ie){var Oe,Me,We=-1,Je=Ne[1],ct=0,lt=7,dt=4;for(Je===0&&(lt=138,dt=3),Ne[2*(Ie+1)+1]=65535,Oe=0;Oe<=Ie;Oe++)Me=Je,Je=Ne[2*(Oe+1)+1],++ct<lt&&Me===Je||(ct<dt?Ye.bl_tree[2*Me]+=ct:Me!==0?(Me!==We&&Ye.bl_tree[2*Me]++,Ye.bl_tree[2*C]++):ct<=10?Ye.bl_tree[2*E]++:Ye.bl_tree[2*b]++,We=Me,dt=(ct=0)===Je?(lt=138,3):Me===Je?(lt=6,3):(lt=7,4))}function Ze(Ye,Ne,Ie){var Oe,Me,We=-1,Je=Ne[1],ct=0,lt=7,dt=4;for(Je===0&&(lt=138,dt=3),Oe=0;Oe<=Ie;Oe++)if(Me=Je,Je=Ne[2*(Oe+1)+1],!(++ct<lt&&Me===Je)){if(ct<dt)for(;xe(Ye,Me,Ye.bl_tree),--ct!=0;);else Me!==0?(Me!==We&&(xe(Ye,Me,Ye.bl_tree),ct--),xe(Ye,C,Ye.bl_tree),le(Ye,ct-3,2)):ct<=10?(xe(Ye,E,Ye.bl_tree),le(Ye,ct-3,3)):(xe(Ye,b,Ye.bl_tree),le(Ye,ct-11,7));We=Me,dt=(ct=0)===Je?(lt=138,3):Me===Je?(lt=6,3):(lt=7,4)}}l(ue);var Ue=!1;function Qe(Ye,Ne,Ie,Oe){le(Ye,(A<<1)+(Oe?1:0),3),(function(Me,We,Je,ct){Pe(Me),re(Me,Je),re(Me,~Je),s.arraySet(Me.pending_buf,Me.window,We,Je,Me.pending),Me.pending+=Je})(Ye,Ne,Ie)}r._tr_init=function(Ye){Ue||((function(){var Ne,Ie,Oe,Me,We,Je=new Array(g+1);for(Me=Oe=0;Me<u-1;Me++)for(K[Me]=Oe,Ne=0;Ne<1<<P[Me];Ne++)z[Oe++]=Me;for(z[Oe-1]=Me,Me=We=0;Me<16;Me++)for(ue[Me]=We,Ne=0;Ne<1<<M[Me];Ne++)F[We++]=Me;for(We>>=7;Me<_;Me++)for(ue[Me]=We<<7,Ne=0;Ne<1<<M[Me]-7;Ne++)F[256+We++]=Me;for(Ie=0;Ie<=g;Ie++)Je[Ie]=0;for(Ne=0;Ne<=143;)Q[2*Ne+1]=8,Ne++,Je[8]++;for(;Ne<=255;)Q[2*Ne+1]=9,Ne++,Je[9]++;for(;Ne<=279;)Q[2*Ne+1]=7,Ne++,Je[7]++;for(;Ne<=287;)Q[2*Ne+1]=8,Ne++,Je[8]++;for(ve(Q,h+1,Je),Ne=0;Ne<_;Ne++)O[2*Ne+1]=5,O[2*Ne]=be(Ne,5);$=new ne(Q,P,d+1,h,g),J=new ne(O,M,0,_,g),oe=new ne(new Array(0),w,0,m,y)})(),Ue=!0),Ye.l_desc=new ie(Ye.dyn_ltree,$),Ye.d_desc=new ie(Ye.dyn_dtree,J),Ye.bl_desc=new ie(Ye.bl_tree,oe),Ye.bi_buf=0,Ye.bi_valid=0,_e(Ye)},r._tr_stored_block=Qe,r._tr_flush_block=function(Ye,Ne,Ie,Oe){var Me,We,Je=0;0<Ye.level?(Ye.strm.data_type===2&&(Ye.strm.data_type=(function(ct){var lt,dt=4093624447;for(lt=0;lt<=31;lt++,dt>>>=1)if(1&dt&&ct.dyn_ltree[2*lt]!==0)return a;if(ct.dyn_ltree[18]!==0||ct.dyn_ltree[20]!==0||ct.dyn_ltree[26]!==0)return c;for(lt=32;lt<d;lt++)if(ct.dyn_ltree[2*lt]!==0)return c;return a})(Ye)),$e(Ye,Ye.l_desc),$e(Ye,Ye.d_desc),Je=(function(ct){var lt;for(fe(ct,ct.dyn_ltree,ct.l_desc.max_code),fe(ct,ct.dyn_dtree,ct.d_desc.max_code),$e(ct,ct.bl_desc),lt=m-1;3<=lt&&ct.bl_tree[2*k[lt]+1]===0;lt--);return ct.opt_len+=3*(lt+1)+5+5+4,lt})(Ye),Me=Ye.opt_len+3+7>>>3,(We=Ye.static_len+3+7>>>3)<=Me&&(Me=We)):Me=We=Ie+5,Ie+4<=Me&&Ne!==-1?Qe(Ye,Ne,Ie,Oe):Ye.strategy===4||We===Me?(le(Ye,2+(Oe?1:0),3),Le(Ye,Q,O)):(le(Ye,4+(Oe?1:0),3),(function(ct,lt,dt,At){var xt;for(le(ct,lt-257,5),le(ct,dt-1,5),le(ct,At-4,4),xt=0;xt<At;xt++)le(ct,ct.bl_tree[2*k[xt]+1],3);Ze(ct,ct.dyn_ltree,lt-1),Ze(ct,ct.dyn_dtree,dt-1)})(Ye,Ye.l_desc.max_code+1,Ye.d_desc.max_code+1,Je+1),Le(Ye,Ye.dyn_ltree,Ye.dyn_dtree)),_e(Ye),Oe&&Pe(Ye)},r._tr_tally=function(Ye,Ne,Ie){return Ye.pending_buf[Ye.d_buf+2*Ye.last_lit]=Ne>>>8&255,Ye.pending_buf[Ye.d_buf+2*Ye.last_lit+1]=255&Ne,Ye.pending_buf[Ye.l_buf+Ye.last_lit]=255&Ie,Ye.last_lit++,Ne===0?Ye.dyn_ltree[2*Ie]++:(Ye.matches++,Ne--,Ye.dyn_ltree[2*(z[Ie]+d+1)]++,Ye.dyn_dtree[2*ce(Ne)]++),Ye.last_lit===Ye.lit_bufsize-1},r._tr_align=function(Ye){le(Ye,2,3),xe(Ye,x,Q),(function(Ne){Ne.bi_valid===16?(re(Ne,Ne.bi_buf),Ne.bi_buf=0,Ne.bi_valid=0):8<=Ne.bi_valid&&(Ne.pending_buf[Ne.pending++]=255&Ne.bi_buf,Ne.bi_buf>>=8,Ne.bi_valid-=8)})(Ye)}},{"../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,h=1,_={},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(C){n.nextTick(function(){y(C)})}:(function(){if(a.postMessage&&!a.importScripts){var C=!0,E=a.onmessage;return a.onmessage=function(){C=!1},a.postMessage("","*"),a.onmessage=E,C}})()?(d="setImmediate$"+Math.random()+"$",a.addEventListener?a.addEventListener("message",x,!1):a.attachEvent("onmessage",x),function(C){a.postMessage(d+C,"*")}):a.MessageChannel?((u=new MessageChannel).port1.onmessage=function(C){y(C.data)},function(C){u.port2.postMessage(C)}):p&&"onreadystatechange"in p.createElement("script")?(A=p.documentElement,function(C){var E=p.createElement("script");E.onreadystatechange=function(){y(C),E.onreadystatechange=null,A.removeChild(E),E=null},A.appendChild(E)}):function(C){setTimeout(y,0,C)},g.setImmediate=function(C){typeof C!="function"&&(C=new Function(""+C));for(var E=new Array(arguments.length-1),b=0;b<E.length;b++)E[b]=arguments[b+1];var P={callback:C,args:E};return _[h]=P,l(h),h++},g.clearImmediate=f}function f(C){delete _[C]}function y(C){if(m)setTimeout(y,0,C);else{var E=_[C];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(C),m=!1}}}}function x(C){C.source===a&&typeof C.data=="string"&&C.data.indexOf(d)===0&&y(+C.data.slice(d.length))}})(typeof self>"u"?s===void 0?this:s:self)}).call(this,typeof gz<"u"?gz:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(Y8e)),Y8e.exports}var WNo=KNo();const K8e=o5(WNo),jNo=async({circuitJson:t,projectName:e})=>{await Os.promise((async()=>{const n=new K8e,[{stringifyGerberCommandLayers:o,convertSoupToGerberCommands:i,convertSoupToExcellonDrillCommands:r,stringifyExcellonDrill:s},{convertCircuitJsonToBomRows:a,convertBomRowsToCsv:c},{convertCircuitJsonToPickAndPlaceCsv:l}]=await Promise.all([q5("circuit-json-to-gerber"),q5("circuit-json-to-bom-csv"),q5("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,x]of Object.entries(d))n.file(`gerber/${y}.gbr`,x);const h=r({circuitJson:A,is_plated:!0,flip_y_axis:!1}),_=s(h);n.file("gerber/drill.drl",_);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"});XE(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)}`})},XNo=async({circuitJson:t,projectName:e})=>{let n;try{const{convertCircuitJsonToGltf:o}=await q5("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}XE(n,{fileName:`${e}.glb`})},$No=async({circuitJson:t,libraryName:e})=>{const{CircuitJsonToKicadLibraryConverter:n}=await q5("circuit-json-to-kicad"),o=new n(t,{libraryName:e,footprintLibraryName:e});o.runUntilFinished();const i=o.getOutput(),r=new K8e;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}
|
|
5788
5788
|
`)}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},JNo=async({circuitJson:t,projectName:e})=>{await Os.promise((async()=>{const o=await(await $No({circuitJson:t,libraryName:e})).generateAsync({type:"blob"});XE(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)}`})},qNo=async({circuitJson:t,projectName:e})=>{const{CircuitJsonToKicadPcbConverter:n,CircuitJsonToKicadSchConverter:o,CircuitJsonToKicadProConverter:i,resolveAndLoadKicad3dModelFiles:r}=await q5("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 K8e;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:h,content:_})=>{d.file(h,_)},onError:({sourcePath:h})=>{console.warn(`Failed to load 3D model from ${h}`)}}),d},ZNo=async({circuitJson:t,projectName:e})=>{await Os.promise((async()=>{const o=await(await qNo({circuitJson:t,projectName:e})).generateAsync({type:"blob"});XE(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)}`})},RDt=async({circuitJson:t,projectName:e,options:n={}})=>{try{const{convertCircuitJsonToLbrn:o}=await q5("circuit-json-to-lbrn"),r=(await o(t,{includeSilkscreen:n.includeSilkscreen??!1,includeOxidationCleaningLayer:n.includeOxidationCleaningLayer??!0})).toXml(),s=new Blob([r],{type:"application/lbrn"});XE(s,{fileName:`${e}.lbrn2`})}catch(o){const i=o instanceof Error?o.message:"Unknown error";Os.error(`Failed to export to LBRN format: ${i}`)}},eRo=async({circuitJson:t,projectName:e})=>{const{convertCircuitJsonToPinoutSvg:n}=await q5("circuit-to-svg"),o=n(t);XE(o,{fileName:`${e}-pinout.svg`,mimeType:"image/svg+xml"})},tRo=async({circuitJson:t,projectName:e})=>{const{circuitJsonToStep:n}=await q5("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){Os.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";Os.error(`Failed to convert circuit to STEP format: ${A}`);return}const c=new Blob([a],{type:"application/step"});try{XE(c,{fileName:`${e}.step`})}catch(l){const A=l instanceof Error?l.message:"Unknown error";Os.error(`Failed to download STEP file: ${A}`)}},nRo=[{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"}],oRo=async({exportName:t,circuitJson:e,simpleRouteJson:n,projectName:o})=>{const i=bwt(o);if(t==="Fabrication Files"){await jNo({circuitJson:e,projectName:i});return}if(t==="KiCad Project"){await ZNo({circuitJson:e,projectName:i});return}if(t==="KiCad Library"){await JNo({circuitJson:e,projectName:i});return}if(t==="Circuit JSON"){XE(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");XE(JSON.stringify(n,null,2),{fileName:`${i}.simple-route.json`,mimeType:"application/json"});return}if(t==="GLB (Binary GLTF)"){await XNo({circuitJson:e,projectName:i});return}if(t==="Pinout SVG"){eRo({circuitJson:e,projectName:i});return}if(t==="STEP"){await tRo({circuitJson:e,projectName:i});return}if(t==="LightBurn"){await RDt({circuitJson:e,projectName:i});return}throw new Error(`Unsupported export type: "${t}"`)},iRo=({packageName:t,onSelectReview:e})=>{const n=T0(u=>u.fsMap),o=T0(u=>u.circuitJson),[i,r]=X.useState([]),[s,a]=X.useState(!1),[c,l]=X.useState(!1);X.useEffect(()=>{!t||!pq()||(a(!0),aF.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),Os.error("Failed to load AI reviews")}).finally(()=>a(!1)))},[t]);const A=async()=>{if(!o){Os.error("Need Circuit JSON to Request AI Review");return}if(!pq()){Os.error("Missing registry token");return}l(!0);try{const{ai_review:u}=await aF.post("ai_reviews/create",{json:{package_name:t??"unknown",fs_map:Object.fromEntries(n),circuit_json:o}}).json();r(d=>[u,...d]),e(u),Os.success("AI review requested")}catch(u){console.error("Failed to create AI review",u),Os.error("Failed to request AI review")}finally{l(!1)}};return Y.jsxs(Y.Fragment,{children:[Y.jsxs(nM,{children:[Y.jsx(oM,{children:"AI Review"}),Y.jsx(yN,{children:"Select an AI review or request a new one."})]}),Y.jsx("div",{className:"rf-flex rf-gap-4 rf-mt-4",children:Y.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?Y.jsx("div",{className:"rf-text-sm",children:"Loading..."}):i.length>0?i.map(u=>Y.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)):Y.jsx("div",{className:"rf-text-sm rf-text-muted-foreground",children:"No AI reviews found."})})}),Y.jsx(cU,{className:"rf-mt-4",children:Y.jsx(Ya,{onClick:A,disabled:c,children:c?"Requesting...":"Review my Board"})})]})};function W8e(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var iM=W8e();function kDt(t){iM=t}var uU={exec:()=>null};function iA(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(h2.caret,"$1"),n=n.replace(i,s),o},getRegex:()=>new RegExp(n,e)};return o}var h2={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")},rRo=/^(?:[ \t]*(?:\n|$))+/,sRo=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,aRo=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,dU=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,cRo=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,j8e=/(?:[*+-]|\d{1,9}[.)])/,LDt=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,HDt=iA(LDt).replace(/bull/g,j8e).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(),lRo=iA(LDt).replace(/bull/g,j8e).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(),X8e=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,ARo=/^[^\n]+/,$8e=/(?!\s*\])(?:\\.|[^\[\]\\])+/,uRo=iA(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",$8e).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),dRo=iA(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,j8e).getRegex(),Roe="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",J8e=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,_Ro=iA("^ {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",J8e).replace("tag",Roe).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),FDt=iA(X8e).replace("hr",dU).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",Roe).getRegex(),hRo=iA(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",FDt).getRegex(),q8e={blockquote:hRo,code:sRo,def:uRo,fences:aRo,heading:cRo,hr:dU,html:_Ro,lheading:HDt,list:dRo,newline:rRo,paragraph:FDt,table:uU,text:ARo},ODt=iA("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",dU).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",Roe).getRegex(),mRo={...q8e,lheading:lRo,table:ODt,paragraph:iA(X8e).replace("hr",dU).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",ODt).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",Roe).getRegex()},gRo={...q8e,html:iA(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",J8e).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:uU,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:iA(X8e).replace("hr",dU).replace("heading",` *#{1,6} *[^
|
|
5789
5789
|
]`).replace("lheading",HDt).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},pRo=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,fRo=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,GDt=/^( {2,}|\\)\n(?!\s*$)/,yRo=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,koe=/[\p{P}\p{S}]/u,Z8e=/[\s\p{P}\p{S}]/u,UDt=/[^\s\p{P}\p{S}]/u,xRo=iA(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Z8e).getRegex(),zDt=/(?!~)[\p{P}\p{S}]/u,CRo=/(?!~)[\s\p{P}\p{S}]/u,IRo=/(?:[^\s\p{P}\p{S}]|~)/u,ERo=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,VDt=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,bRo=iA(VDt,"u").replace(/punct/g,koe).getRegex(),SRo=iA(VDt,"u").replace(/punct/g,zDt).getRegex(),YDt="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",PRo=iA(YDt,"gu").replace(/notPunctSpace/g,UDt).replace(/punctSpace/g,Z8e).replace(/punct/g,koe).getRegex(),vRo=iA(YDt,"gu").replace(/notPunctSpace/g,IRo).replace(/punctSpace/g,CRo).replace(/punct/g,zDt).getRegex(),BRo=iA("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,UDt).replace(/punctSpace/g,Z8e).replace(/punct/g,koe).getRegex(),MRo=iA(/\\(punct)/,"gu").replace(/punct/g,koe).getRegex(),wRo=iA(/^<(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(),DRo=iA(J8e).replace("(?:-->|$)","-->").getRegex(),TRo=iA("^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",DRo).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Loe=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,QRo=iA(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",Loe).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),KDt=iA(/^!?\[(label)\]\[(ref)\]/).replace("label",Loe).replace("ref",$8e).getRegex(),WDt=iA(/^!?\[(ref)\](?:\[\])?/).replace("ref",$8e).getRegex(),NRo=iA("reflink|nolink(?!\\()","g").replace("reflink",KDt).replace("nolink",WDt).getRegex(),e9e={_backpedal:uU,anyPunctuation:MRo,autolink:wRo,blockSkip:ERo,br:GDt,code:fRo,del:uU,emStrongLDelim:bRo,emStrongRDelimAst:PRo,emStrongRDelimUnd:BRo,escape:pRo,link:QRo,nolink:WDt,punctuation:xRo,reflink:KDt,reflinkSearch:NRo,tag:TRo,text:yRo,url:uU},RRo={...e9e,link:iA(/^!?\[(label)\]\((.*?)\)/).replace("label",Loe).getRegex(),reflink:iA(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Loe).getRegex()},t9e={...e9e,emStrongRDelimAst:vRo,emStrongLDelim:SRo,url:iA(/^((?: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.!#$%&'*+\/=?_`{\|}~-]+@)))/},kRo={...t9e,br:iA(GDt).replace("{2,}","*").getRegex(),text:iA(t9e.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Hoe={normal:q8e,gfm:mRo,pedantic:gRo},_U={normal:e9e,gfm:t9e,breaks:kRo,pedantic:RRo},LRo={"&":"&","<":"<",">":">",'"':""","'":"'"},jDt=t=>LRo[t];function JE(t,e){if(e){if(h2.escapeTest.test(t))return t.replace(h2.escapeReplace,jDt)}else if(h2.escapeTestNoEncode.test(t))return t.replace(h2.escapeReplaceNoEncode,jDt);return t}function XDt(t){try{t=encodeURI(t).replace(h2.percentDecode,"%")}catch{return null}return t}function $Dt(t,e){const n=t.replace(h2.findPipe,(r,s,a)=>{let c=!1,l=s;for(;--l>=0&&a[l]==="\\";)c=!c;return c?"|":" |"}),o=n.split(h2.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(h2.slashPipe,"|");return o}function hU(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 HRo(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 JDt(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 FRo(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.
|
|
5
|
+
"version": "0.0.2206",
|
|
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.
|
|
116
|
+
"@tscircuit/eval": "^0.0.1008",
|
|
117
117
|
"@tscircuit/solver-utils": "^0.0.7"
|
|
118
118
|
}
|
|
119
119
|
}
|