@tscircuit/runframe 0.0.2251 → 0.0.2253

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.2250";
2180
+ var version = "0.0.2251";
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.1039",
2296
+ "@tscircuit/eval": "^0.0.1041",
2297
2297
  "@tscircuit/solver-utils": "^0.0.7"
2298
2298
  }
2299
2299
  };
package/dist/preview.js CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  SchematicViewer,
8
8
  useOrderDialog,
9
9
  useOrderDialogCli
10
- } from "./chunk-TQNGE5UD.js";
10
+ } from "./chunk-ZHEZNFNV.js";
11
11
  export {
12
12
  BomTable,
13
13
  CadViewer,
package/dist/runner.js CHANGED
@@ -39,7 +39,7 @@ import {
39
39
  useRunFrameStore,
40
40
  useRunnerStore,
41
41
  useStyles
42
- } from "./chunk-TQNGE5UD.js";
42
+ } from "./chunk-ZHEZNFNV.js";
43
43
 
44
44
  // lib/components/RunFrame/RunFrame.tsx
45
45
  import { createCircuitWebWorker } from "@tscircuit/eval/worker";
@@ -5779,7 +5779,7 @@ test("${c} should solve problem correctly", () => {
5779
5779
  // Add more specific assertions based on expected output
5780
5780
  // expect(solver.netLabelPlacementSolver!.netLabelPlacements).toMatchInlineSnapshot()
5781
5781
  })
5782
- `,g=new Blob([l],{type:"text/plain"}),u=URL.createObjectURL(g),d=document.createElement("a");d.href=u,d.download=`${c}.test.ts`,d.click(),URL.revokeObjectURL(u)}catch(a){alert(`Error generating test.ts for ${t.constructor.name}: ${a instanceof Error?a.message:String(a)}`)}o(!1)};return q.jsxs("div",{className:`relative ${e}`,ref:i,children:[q.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&&q.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:[q.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download JSON"}),q.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:A,children:"Download page.tsx"}),q.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download test.ts"})]})]})},_Pt=t=>t.activeSubSolver?[t,..._Pt(t.activeSubSolver)]:[t],yMo=({solver:t})=>{const e=_Pt(t);return q.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:e.map((n,o)=>q.jsxs("div",{className:"flex items-center",children:[o>0&&q.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),q.jsx(fMo,{solver:n})]},n.constructor.name))})},EMo=({solver:t,triggerRender:e,animationSpeed:n=25,onSolverStarted:o,onSolverCompleted:i})=>{const[r,A]=te.useReducer(_=>!_,!1),s=te.useRef(void 0),a=()=>{!t.solved&&!t.failed&&(t.step(),e())},c=()=>{!t.solved&&!t.failed&&(o&&o(t),t.solve(),e(),i&&i(t))},l=()=>{r?(s.current&&(clearInterval(s.current),s.current=void 0),A()):(A(),s.current=setInterval(()=>{if(t.solved||t.failed){s.current&&(clearInterval(s.current),s.current=void 0),A(),e(),i&&t.solved&&i(t);return}t.step(),e()},n))},g=()=>{const _=t;if(_.getCurrentPhase&&!t.solved&&!t.failed){const p=_.getCurrentPhase();for(;_.getCurrentPhase()===p&&!t.solved&&!t.failed;)t.step();e()}},u=()=>{if(t.solved||t.failed||r)return;const _=window.prompt("Step until which iteration?",`${t.iterations}`);if(_===null)return;const p=Number(_);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)};te.useEffect(()=>()=>{s.current&&clearInterval(s.current)},[]),te.useEffect(()=>{(t.solved||t.failed)&&r&&(s.current&&(clearInterval(s.current),s.current=void 0),A())},[t.solved,t.failed,r]);const d=t.getCurrentPhase!==void 0,h=d?t.getCurrentPhase():null;return q.jsxs("div",{className:"space-y-2 p-2 border-b",children:[q.jsx("div",{className:"flex items-center",children:q.jsx(yMo,{solver:t})}),q.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[q.jsx("button",{onClick:a,disabled:t.solved||t.failed||r,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),q.jsx("button",{onClick:c,disabled:t.solved||t.failed||r,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),q.jsx("button",{onClick:l,disabled:t.solved||t.failed,className:`px-3 py-1 rounded text-white text-sm ${r?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:r?"Stop":"Animate"}),q.jsx("button",{onClick:u,disabled:t.solved||t.failed||r,className:"bg-orange-500 hover:bg-orange-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step Until Iteration"}),d&&q.jsx("button",{onClick:g,disabled:t.solved||t.failed||r,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),q.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&q.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),h&&q.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",q.jsx("span",{className:"font-medium",children:h})]}),t.solved&&q.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&q.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&q.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},BMo=(t,e,n)=>{const o=t.currentPipelineStepIndex;return e<o?"Completed":e===o&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},xMo=(t,e)=>{const o=t.pipelineDef[e].solverName,i=BMo(t,e),r=t[o],A=t.firstIterationOfPhase?.[o]??null,s=t.iterations;let a=0;if(i==="Completed"){const u=t.pipelineDef[e+1],d=u?t.firstIterationOfPhase?.[u.solverName]:void 0;d!==void 0&&A!==null?a=d-A:A!==null&&(a=s-A)}else i==="In Progress"&&A!==null&&(a=s-A);const c=t.timeSpentOnPhase?.[o]??0;let l=0;i==="Completed"?l=1:i==="In Progress"&&r&&(l=r.progress??0);const g=r?.stats??null;return{index:e,name:o,status:i,firstIteration:A,iterations:a,progress:l,timeSpent:c,stats:g&&Object.keys(g).length>0?g:null,solverInstance:r??null}},QMo=({status:t})=>{const e={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return q.jsx("span",{className:`font-medium ${e[t]}`,children:t})},SMo=({progress:t})=>{if(t===0)return null;const e=Math.round(t*100);return q.jsxs("div",{className:"flex items-center gap-2",children:[q.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:q.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${e}%`}})}),q.jsxs("span",{className:"text-xs text-gray-500",children:[e,"%"]})]})},bMo=t=>Object.entries(t).map(([e,n])=>`${e}: ${n}`).join(", "),DMo=({stats:t})=>{if(!t||Object.keys(t).length===0)return q.jsx("span",{children:"-"});const e=Object.entries(t),n=bMo(t);return q.jsxs("details",{className:"cursor-pointer",children:[q.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:n}),q.jsx("div",{className:"mt-1 text-xs",children:e.map(([o,i])=>q.jsxs("div",{children:[o,": ",String(i)]},o))})]})},TDe=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(TDe);const e={};for(const[n,o]of Object.entries(t))n.startsWith("_")||(e[n]=TDe(o));return e},MMo=(t,e)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${e}`);return}const n=TDe(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)}`)}},PMo=({solver:t,onStepUntilPhase:e,onDownloadInput:n})=>{const o=t.pipelineDef.map((s,a)=>xMo(t,a)),i=s=>{e?.(s)},r=s=>{s.solverInstance&&(n?n(s.solverInstance,s.name):MMo(s.solverInstance,s.name))},A=s=>`${(s/1e3).toFixed(2)}s`;return q.jsxs("div",{className:"border-t border-gray-200",children:[q.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:q.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),q.jsx("div",{className:"overflow-x-auto",children:q.jsxs("table",{className:"w-full text-sm",children:[q.jsx("thead",{children:q.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[q.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),q.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),q.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",q.jsx("sub",{children:"0"})]}),q.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),q.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),q.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),q.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),q.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),q.jsx("tbody",{children:o.map(s=>q.jsxs("tr",{className:`border-b border-gray-100 ${s.status==="In Progress"?"bg-yellow-50":""}`,children:[q.jsx("td",{className:"px-4 py-2",children:q.jsxs("div",{className:"flex items-center gap-2",children:[q.jsx("span",{className:"text-gray-400 w-6",children:String(s.index+1).padStart(2,"0")}),q.jsx("button",{onClick:()=>i(s.name),disabled:s.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 ${s.name} completes`,children:q.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:q.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"})})}),q.jsx("span",{className:"font-medium text-gray-900",children:s.name})]})}),q.jsx("td",{className:"px-4 py-2",children:q.jsx(QMo,{status:s.status})}),q.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:s.firstIteration!==null?s.firstIteration:""}),q.jsx("td",{className:"px-4 py-2 text-gray-600",children:s.iterations}),q.jsx("td",{className:"px-4 py-2",children:q.jsx(SMo,{progress:s.progress})}),q.jsx("td",{className:"px-4 py-2 text-gray-600",children:A(s.timeSpent)}),q.jsx("td",{className:"px-4 py-2 text-gray-500",children:q.jsx(DMo,{stats:s.stats})}),q.jsx("td",{className:"px-4 py-2",children:s.solverInstance?q.jsxs("button",{onClick:()=>r(s),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${s.name}`,children:[q.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:q.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"})}),q.jsx("span",{children:"Input"})]}):null})]},s.name))})]})})]})},wMo=class extends Vr.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 vMo({graphics:t}){const e=t.points??[],n=t.lines??[],o=t.rects??[],i=t.circles??[],r=t.texts??[];let A=Number.POSITIVE_INFINITY,s=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,c=Number.NEGATIVE_INFINITY;const l=(p,m)=>{typeof p=="number"&&(p<A&&(A=p),p>a&&(a=p)),typeof m=="number"&&(m<s&&(s=m),m>c&&(c=m))};for(const p of e)l(p.x,p.y);for(const p of n){const m=p.points??[];for(const I of m)l(I.x,I.y)}for(const p of o){const m=p.x??0,I=p.y??0,C=p.width??0,f=p.height??0;l(m,I),l(m+C,I+f)}for(const p of i){const m=p.x??0,I=p.y??0,C=p.radius??1;l(m-C,I-C),l(m+C,I+C)}for(const p of r)l(p.x,p.y);(!isFinite(A)||!isFinite(s)||!isFinite(a)||!isFinite(c))&&(A=-20,s=-20,a=20,c=20);const g=10,u=A-g,d=s-g,h=Math.max(1,a-A+2*g),_=Math.max(1,c-s+2*g);return q.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${u} ${d} ${h} ${_}`,role:"img","aria-label":"Graphics fallback",children:[o.map((p,m)=>q.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-${m}`)),n.map((p,m)=>q.jsx("polyline",{fill:"none",stroke:p.strokeColor??"black",strokeWidth:p.strokeWidth??1,points:(p.points??[]).map(I=>`${I.x??0},${I.y??0}`).join(" ")},`line-${m}`)),i.map((p,m)=>q.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-${m}`)),e.map((p,m)=>q.jsx("circle",{cx:p.x??0,cy:p.y??0,r:p.radius??1.5,fill:p.color??"black"},`point-${m}`)),r.map((p,m)=>q.jsx("text",{x:p.x??0,y:p.y??0,fontSize:p.fontSize??10,fill:p.color??"black",children:p.text??""},`text-${m}`))]})}var NMo=({solver:t,animationSpeed:e=25,onSolverStarted:n,onSolverCompleted:o})=>{const[i,r]=te.useReducer(l=>l+1,0),A=te.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(l){return console.error("Visualization error:",l),{points:[],lines:[],rects:[],circles:[]}}},[t,i]),s=te.useMemo(()=>(A.rects?.length||0)===0&&(A.lines?.length||0)===0&&(A.points?.length||0)===0&&(A.circles?.length||0)===0,[A]);te.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const l=document.createElement("script");l.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(l)}},[]);const a=t.pipelineDef!==void 0,c=l=>{const g=t;if(!t.solved&&!t.failed){for(;!t.solved&&!t.failed&&g.currentPipelineStepIndex<=g.pipelineDef.findIndex(u=>u.solverName===l);)t.step();r()}};return q.jsxs("div",{children:[q.jsx(EMo,{solver:t,triggerRender:r,animationSpeed:e,onSolverStarted:n,onSolverCompleted:o}),s?q.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):q.jsx(wMo,{fallback:q.jsx(vMo,{graphics:A}),children:q.jsx(CMo,{graphics:A})}),a&&q.jsx(PMo,{solver:t,onStepUntilPhase:c})]})};const RMo=()=>{te.useEffect(()=>{const t="tailwind-cdn-script";if(document.getElementById(t)||window.tailwind)return;const e=document.createElement("div");e.className="hidden",document.body.appendChild(e);const n=window.getComputedStyle(e).display==="none";if(document.body.removeChild(e),n)return;const o=document.createElement("script");o.id=t,o.src="https://cdn.tailwindcss.com",document.head.appendChild(o)},[])},TMo=1e3,fQ=(t,e)=>{const{fileName:n,mimeType:o="text/plain"}=e,i=t instanceof Blob?t:new Blob([t],{type:o}),r=URL.createObjectURL(i),A=document.createElement("a");A.href=r,A.download=n,A.target="_blank",A.rel="noopener noreferrer",A.style.display="none",document.body.appendChild(A),A.click(),document.body.removeChild(A),setTimeout(()=>{URL.revokeObjectURL(r)},TMo)},mPt=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"},yQ="https://github.com/tscircuit/tscircuit-autorouter/issues/new",pPt="https://github.com/tscircuit/copper-pour-solver/issues/new",IPt="https://github.com/tscircuit/calculate-packing/issues/new",CPt="https://github.com/tscircuit/schematic-trace-solver/issues/new?template=json-bug-report.yml",kMo={PackSolver2:IPt,AutoroutingPipelineSolver:yQ,AssignableAutoroutingPipeline2:yQ,AssignableAutoroutingPipeline3:yQ,AutoroutingPipeline1_OriginalUnravel:yQ,AutoroutingPipelineSolver3_HgPortPointPathing:yQ,AutoroutingPipelineSolver4:yQ,AutoroutingPipelineSolver5:yQ,AutoroutingPipelineSolver7_MultiGraph:yQ,AutoroutingPipelineSolver8:yQ,CopperPourPipelineSolver:pPt,SchematicTracePipelineSolver:CPt},FMo=t=>t.toLowerCase().includes("pack")?Z_o:t.toLowerCase().includes("rout")?Amo:z_o,fPt=t=>{const e=kMo[t];if(e)return e;const n=t.toLowerCase();return n.includes("autorout")?yQ:n.includes("schematic")&&n.includes("trace")?CPt:n.includes("copperpour")?pPt:n.includes("pack")?IPt:null},LMo=t=>`${mPt(`${t.componentName}-${t.solverName}`)}-solver-input.json`,yPt=t=>{fQ(JSON.stringify(t.solverParams,null,2),{fileName:LMo(t),mimeType:"application/json"})},HMo=({solverEvent:t})=>{const e=fPt(t.solverName);return q.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:[q.jsxs(cc,{type:"button",variant:"outline",size:"sm",onClick:()=>yPt(t),children:[q.jsx(z5e,{className:"rf-w-4 rf-h-4"}),"Download"]}),e?q.jsx(cc,{asChild:!0,variant:"outline",size:"sm",children:q.jsxs("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:[q.jsx(TZ,{className:"rf-w-4 rf-h-4"}),"Report"]})}):q.jsxs(cc,{type:"button",variant:"outline",size:"sm",disabled:!0,title:"No report link configured for this solver",children:[q.jsx(TZ,{className:"rf-w-4 rf-h-4"}),"Report"]})]})},GMo=({solverEvent:t})=>{const e=fPt(t.solverName);return e?q.jsx(cc,{asChild:!0,variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8",children:q.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",title:"Report solver bug","aria-label":"Report solver bug",children:q.jsx(TZ,{className:"rf-w-4 rf-h-4"})})}):q.jsx(cc,{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:q.jsx(TZ,{className:"rf-w-4 rf-h-4"})})},OMo=({solverEvents:t=[]})=>{const[e,n]=te.useState(null);RMo();const o=te.useMemo(()=>{const s=new Map;for(const a of t){const c=`${a.componentName}-${a.solverName}`;s.set(c,a)}return s},[t]),i=te.useMemo(()=>Array.from(o.keys()),[o]),r=e?o.get(e):null,A=te.useMemo(()=>{if(!r)return{instance:null,error:null,classFound:!1};const s=XIe[r.solverName];if(!s)return{instance:null,error:`Solver class "${r.solverName}" not found in SOLVERS registry. Available: ${Object.keys(XIe).join(", ")}`,classFound:!1};try{const a=r.solverParams,c=a?.input!==void 0?a.input:a;return{instance:new s(c),error:null,classFound:!0}}catch(a){const c=a instanceof Error?a.message:String(a);return console.error("Failed to reconstruct solver:",a),{instance:null,error:`Failed to instantiate solver: ${c}`,classFound:!0}}},[r]);return t.length===0?q.jsx("div",{className:"rf-p-4",children:q.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:q.jsxs("div",{className:"rf-p-4",children:[q.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),q.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."})]})})}):q.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[q.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[q.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(s=>{const a=o.get(s),c=e===s;return q.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${c?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>n(s),children:(()=>{const l=FMo(a.solverName);return q.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[q.jsx(l,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),q.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[q.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:a.componentName}),q.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:a.solverName})]})]})})()},s)})]}),q.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:r?A.instance?q.jsxs("div",{className:"rf-flex rf-h-full rf-flex-col rf-overflow-y-auto",children:[q.jsx(HMo,{solverEvent:r}),q.jsx("div",{className:"rf-min-h-0 rf-flex-1",children:q.jsx(aQ,{fallback:q.jsx("div",{className:"rf-p-4",children:q.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[q.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),q.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",r.solverName]})]})}),children:q.jsx(NMo,{solver:A.instance})})})]}):q.jsxs("div",{className:"rf-p-4",children:[q.jsxs("div",{className:"rf-mb-4",children:[q.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:r.solverName}),q.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",r.componentName]})]}),A.error&&q.jsx("div",{className:`rf-rounded-md rf-border rf-p-4 rf-mb-4 ${A.classFound?"rf-bg-red-50 rf-border-red-200":"rf-bg-yellow-50 rf-border-yellow-200"}`,children:q.jsx("p",{className:`rf-text-sm ${A.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:A.error})}),q.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[q.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:[q.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"}),q.jsxs("div",{className:"rf-flex rf-items-center rf-gap-1",children:[q.jsx(GMo,{solverEvent:r}),q.jsx(cc,{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:()=>yPt(r),children:q.jsx(z5e,{className:"rf-w-4 rf-h-4"})})]})]}),q.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:q.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)})})]})]}):q.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:q.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},EPt=({errorMessage:t,errorStack:e,circuitJsonErrors:n})=>{te.useEffect(()=>{if(t){const o=new Error(t);e&&(o.stack=e);try{iv.captureException(o)}catch{}}},[t,e]),te.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{iv.captureException(i,{error_type:o.type})}catch{}}},[n])},KMo=t=>{te.useEffect(()=>{try{NTt(t)}catch{}},[t.source,t.component,t.isWebEmbedded,t.activeTab])},BPt="0.0.2250",UMo={version:BPt},kDe={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},FDe=new Map,mte=t=>{const e=FDe.get(t);return e?Object.fromEntries(Object.entries(e.stores).map(([n,o])=>[n,o.getState()])):{}},YMo=(t,e,n)=>{if(t===void 0)return{type:"untracked",connection:e.connect(n)};const o=FDe.get(n.name);if(o)return{type:"tracked",store:t,...o};const i={connection:e.connect(n),stores:{}};return FDe.set(n.name,i),{type:"tracked",store:t,...i}},xPt=(t,e={})=>(n,o,i)=>{const{enabled:r,anonymousActionType:A,store:s,...a}=e;let c;try{c=(r??(kDe?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!c)return(kDe?"production":void 0)!=="production"&&r&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),t(n,o,i);const{connection:l,...g}=YMo(s,c,a);let u=!0;i.setState=(_,p,m)=>{const I=n(_,p);if(!u)return I;const C=m===void 0?{type:A||"anonymous"}:typeof m=="string"?{type:m}:m;return s===void 0?(l?.send(C,o()),I):(l?.send({...C,type:`${s}/${C.type}`},{...mte(a.name),[s]:i.getState()}),I)};const d=(..._)=>{const p=u;u=!1,n(..._),u=p},h=t(i.setState,o,i);if(g.type==="untracked"?l?.init(h):(g.stores[g.store]=i,l?.init(Object.fromEntries(Object.entries(g.stores).map(([_,p])=>[_,_===g.store?h:p.getState()])))),i.dispatchFromDevtools&&typeof i.dispatch=="function"){let _=!1;const p=i.dispatch;i.dispatch=(...m)=>{(kDe?"production":void 0)!=="production"&&m[0].type==="__setState"&&!_&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),_=!0),p(...m)}}return l.subscribe(_=>{var p;switch(_.type){case"ACTION":if(typeof _.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return LDe(_.payload,m=>{if(m.type==="__setState"){if(s===void 0){d(m.state);return}Object.keys(m.state).length!==1&&console.error(`
5782
+ `,g=new Blob([l],{type:"text/plain"}),u=URL.createObjectURL(g),d=document.createElement("a");d.href=u,d.download=`${c}.test.ts`,d.click(),URL.revokeObjectURL(u)}catch(a){alert(`Error generating test.ts for ${t.constructor.name}: ${a instanceof Error?a.message:String(a)}`)}o(!1)};return q.jsxs("div",{className:`relative ${e}`,ref:i,children:[q.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&&q.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:[q.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download JSON"}),q.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:A,children:"Download page.tsx"}),q.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download test.ts"})]})]})},_Pt=t=>t.activeSubSolver?[t,..._Pt(t.activeSubSolver)]:[t],yMo=({solver:t})=>{const e=_Pt(t);return q.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:e.map((n,o)=>q.jsxs("div",{className:"flex items-center",children:[o>0&&q.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),q.jsx(fMo,{solver:n})]},n.constructor.name))})},EMo=({solver:t,triggerRender:e,animationSpeed:n=25,onSolverStarted:o,onSolverCompleted:i})=>{const[r,A]=te.useReducer(_=>!_,!1),s=te.useRef(void 0),a=()=>{!t.solved&&!t.failed&&(t.step(),e())},c=()=>{!t.solved&&!t.failed&&(o&&o(t),t.solve(),e(),i&&i(t))},l=()=>{r?(s.current&&(clearInterval(s.current),s.current=void 0),A()):(A(),s.current=setInterval(()=>{if(t.solved||t.failed){s.current&&(clearInterval(s.current),s.current=void 0),A(),e(),i&&t.solved&&i(t);return}t.step(),e()},n))},g=()=>{const _=t;if(_.getCurrentPhase&&!t.solved&&!t.failed){const p=_.getCurrentPhase();for(;_.getCurrentPhase()===p&&!t.solved&&!t.failed;)t.step();e()}},u=()=>{if(t.solved||t.failed||r)return;const _=window.prompt("Step until which iteration?",`${t.iterations}`);if(_===null)return;const p=Number(_);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)};te.useEffect(()=>()=>{s.current&&clearInterval(s.current)},[]),te.useEffect(()=>{(t.solved||t.failed)&&r&&(s.current&&(clearInterval(s.current),s.current=void 0),A())},[t.solved,t.failed,r]);const d=t.getCurrentPhase!==void 0,h=d?t.getCurrentPhase():null;return q.jsxs("div",{className:"space-y-2 p-2 border-b",children:[q.jsx("div",{className:"flex items-center",children:q.jsx(yMo,{solver:t})}),q.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[q.jsx("button",{onClick:a,disabled:t.solved||t.failed||r,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),q.jsx("button",{onClick:c,disabled:t.solved||t.failed||r,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),q.jsx("button",{onClick:l,disabled:t.solved||t.failed,className:`px-3 py-1 rounded text-white text-sm ${r?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:r?"Stop":"Animate"}),q.jsx("button",{onClick:u,disabled:t.solved||t.failed||r,className:"bg-orange-500 hover:bg-orange-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step Until Iteration"}),d&&q.jsx("button",{onClick:g,disabled:t.solved||t.failed||r,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),q.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&q.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),h&&q.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",q.jsx("span",{className:"font-medium",children:h})]}),t.solved&&q.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&q.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&q.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},BMo=(t,e,n)=>{const o=t.currentPipelineStepIndex;return e<o?"Completed":e===o&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},xMo=(t,e)=>{const o=t.pipelineDef[e].solverName,i=BMo(t,e),r=t[o],A=t.firstIterationOfPhase?.[o]??null,s=t.iterations;let a=0;if(i==="Completed"){const u=t.pipelineDef[e+1],d=u?t.firstIterationOfPhase?.[u.solverName]:void 0;d!==void 0&&A!==null?a=d-A:A!==null&&(a=s-A)}else i==="In Progress"&&A!==null&&(a=s-A);const c=t.timeSpentOnPhase?.[o]??0;let l=0;i==="Completed"?l=1:i==="In Progress"&&r&&(l=r.progress??0);const g=r?.stats??null;return{index:e,name:o,status:i,firstIteration:A,iterations:a,progress:l,timeSpent:c,stats:g&&Object.keys(g).length>0?g:null,solverInstance:r??null}},QMo=({status:t})=>{const e={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return q.jsx("span",{className:`font-medium ${e[t]}`,children:t})},SMo=({progress:t})=>{if(t===0)return null;const e=Math.round(t*100);return q.jsxs("div",{className:"flex items-center gap-2",children:[q.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:q.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${e}%`}})}),q.jsxs("span",{className:"text-xs text-gray-500",children:[e,"%"]})]})},bMo=t=>Object.entries(t).map(([e,n])=>`${e}: ${n}`).join(", "),DMo=({stats:t})=>{if(!t||Object.keys(t).length===0)return q.jsx("span",{children:"-"});const e=Object.entries(t),n=bMo(t);return q.jsxs("details",{className:"cursor-pointer",children:[q.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:n}),q.jsx("div",{className:"mt-1 text-xs",children:e.map(([o,i])=>q.jsxs("div",{children:[o,": ",String(i)]},o))})]})},TDe=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(TDe);const e={};for(const[n,o]of Object.entries(t))n.startsWith("_")||(e[n]=TDe(o));return e},MMo=(t,e)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${e}`);return}const n=TDe(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)}`)}},PMo=({solver:t,onStepUntilPhase:e,onDownloadInput:n})=>{const o=t.pipelineDef.map((s,a)=>xMo(t,a)),i=s=>{e?.(s)},r=s=>{s.solverInstance&&(n?n(s.solverInstance,s.name):MMo(s.solverInstance,s.name))},A=s=>`${(s/1e3).toFixed(2)}s`;return q.jsxs("div",{className:"border-t border-gray-200",children:[q.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:q.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),q.jsx("div",{className:"overflow-x-auto",children:q.jsxs("table",{className:"w-full text-sm",children:[q.jsx("thead",{children:q.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[q.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),q.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),q.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",q.jsx("sub",{children:"0"})]}),q.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),q.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),q.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),q.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),q.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),q.jsx("tbody",{children:o.map(s=>q.jsxs("tr",{className:`border-b border-gray-100 ${s.status==="In Progress"?"bg-yellow-50":""}`,children:[q.jsx("td",{className:"px-4 py-2",children:q.jsxs("div",{className:"flex items-center gap-2",children:[q.jsx("span",{className:"text-gray-400 w-6",children:String(s.index+1).padStart(2,"0")}),q.jsx("button",{onClick:()=>i(s.name),disabled:s.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 ${s.name} completes`,children:q.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:q.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"})})}),q.jsx("span",{className:"font-medium text-gray-900",children:s.name})]})}),q.jsx("td",{className:"px-4 py-2",children:q.jsx(QMo,{status:s.status})}),q.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:s.firstIteration!==null?s.firstIteration:""}),q.jsx("td",{className:"px-4 py-2 text-gray-600",children:s.iterations}),q.jsx("td",{className:"px-4 py-2",children:q.jsx(SMo,{progress:s.progress})}),q.jsx("td",{className:"px-4 py-2 text-gray-600",children:A(s.timeSpent)}),q.jsx("td",{className:"px-4 py-2 text-gray-500",children:q.jsx(DMo,{stats:s.stats})}),q.jsx("td",{className:"px-4 py-2",children:s.solverInstance?q.jsxs("button",{onClick:()=>r(s),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${s.name}`,children:[q.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:q.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"})}),q.jsx("span",{children:"Input"})]}):null})]},s.name))})]})})]})},wMo=class extends Vr.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 vMo({graphics:t}){const e=t.points??[],n=t.lines??[],o=t.rects??[],i=t.circles??[],r=t.texts??[];let A=Number.POSITIVE_INFINITY,s=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,c=Number.NEGATIVE_INFINITY;const l=(p,m)=>{typeof p=="number"&&(p<A&&(A=p),p>a&&(a=p)),typeof m=="number"&&(m<s&&(s=m),m>c&&(c=m))};for(const p of e)l(p.x,p.y);for(const p of n){const m=p.points??[];for(const I of m)l(I.x,I.y)}for(const p of o){const m=p.x??0,I=p.y??0,C=p.width??0,f=p.height??0;l(m,I),l(m+C,I+f)}for(const p of i){const m=p.x??0,I=p.y??0,C=p.radius??1;l(m-C,I-C),l(m+C,I+C)}for(const p of r)l(p.x,p.y);(!isFinite(A)||!isFinite(s)||!isFinite(a)||!isFinite(c))&&(A=-20,s=-20,a=20,c=20);const g=10,u=A-g,d=s-g,h=Math.max(1,a-A+2*g),_=Math.max(1,c-s+2*g);return q.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${u} ${d} ${h} ${_}`,role:"img","aria-label":"Graphics fallback",children:[o.map((p,m)=>q.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-${m}`)),n.map((p,m)=>q.jsx("polyline",{fill:"none",stroke:p.strokeColor??"black",strokeWidth:p.strokeWidth??1,points:(p.points??[]).map(I=>`${I.x??0},${I.y??0}`).join(" ")},`line-${m}`)),i.map((p,m)=>q.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-${m}`)),e.map((p,m)=>q.jsx("circle",{cx:p.x??0,cy:p.y??0,r:p.radius??1.5,fill:p.color??"black"},`point-${m}`)),r.map((p,m)=>q.jsx("text",{x:p.x??0,y:p.y??0,fontSize:p.fontSize??10,fill:p.color??"black",children:p.text??""},`text-${m}`))]})}var NMo=({solver:t,animationSpeed:e=25,onSolverStarted:n,onSolverCompleted:o})=>{const[i,r]=te.useReducer(l=>l+1,0),A=te.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(l){return console.error("Visualization error:",l),{points:[],lines:[],rects:[],circles:[]}}},[t,i]),s=te.useMemo(()=>(A.rects?.length||0)===0&&(A.lines?.length||0)===0&&(A.points?.length||0)===0&&(A.circles?.length||0)===0,[A]);te.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const l=document.createElement("script");l.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(l)}},[]);const a=t.pipelineDef!==void 0,c=l=>{const g=t;if(!t.solved&&!t.failed){for(;!t.solved&&!t.failed&&g.currentPipelineStepIndex<=g.pipelineDef.findIndex(u=>u.solverName===l);)t.step();r()}};return q.jsxs("div",{children:[q.jsx(EMo,{solver:t,triggerRender:r,animationSpeed:e,onSolverStarted:n,onSolverCompleted:o}),s?q.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):q.jsx(wMo,{fallback:q.jsx(vMo,{graphics:A}),children:q.jsx(CMo,{graphics:A})}),a&&q.jsx(PMo,{solver:t,onStepUntilPhase:c})]})};const RMo=()=>{te.useEffect(()=>{const t="tailwind-cdn-script";if(document.getElementById(t)||window.tailwind)return;const e=document.createElement("div");e.className="hidden",document.body.appendChild(e);const n=window.getComputedStyle(e).display==="none";if(document.body.removeChild(e),n)return;const o=document.createElement("script");o.id=t,o.src="https://cdn.tailwindcss.com",document.head.appendChild(o)},[])},TMo=1e3,fQ=(t,e)=>{const{fileName:n,mimeType:o="text/plain"}=e,i=t instanceof Blob?t:new Blob([t],{type:o}),r=URL.createObjectURL(i),A=document.createElement("a");A.href=r,A.download=n,A.target="_blank",A.rel="noopener noreferrer",A.style.display="none",document.body.appendChild(A),A.click(),document.body.removeChild(A),setTimeout(()=>{URL.revokeObjectURL(r)},TMo)},mPt=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"},yQ="https://github.com/tscircuit/tscircuit-autorouter/issues/new",pPt="https://github.com/tscircuit/copper-pour-solver/issues/new",IPt="https://github.com/tscircuit/calculate-packing/issues/new",CPt="https://github.com/tscircuit/schematic-trace-solver/issues/new?template=json-bug-report.yml",kMo={PackSolver2:IPt,AutoroutingPipelineSolver:yQ,AssignableAutoroutingPipeline2:yQ,AssignableAutoroutingPipeline3:yQ,AutoroutingPipeline1_OriginalUnravel:yQ,AutoroutingPipelineSolver3_HgPortPointPathing:yQ,AutoroutingPipelineSolver4:yQ,AutoroutingPipelineSolver5:yQ,AutoroutingPipelineSolver7_MultiGraph:yQ,AutoroutingPipelineSolver8:yQ,CopperPourPipelineSolver:pPt,SchematicTracePipelineSolver:CPt},FMo=t=>t.toLowerCase().includes("pack")?Z_o:t.toLowerCase().includes("rout")?Amo:z_o,fPt=t=>{const e=kMo[t];if(e)return e;const n=t.toLowerCase();return n.includes("autorout")?yQ:n.includes("schematic")&&n.includes("trace")?CPt:n.includes("copperpour")?pPt:n.includes("pack")?IPt:null},LMo=t=>`${mPt(`${t.componentName}-${t.solverName}`)}-solver-input.json`,yPt=t=>{fQ(JSON.stringify(t.solverParams,null,2),{fileName:LMo(t),mimeType:"application/json"})},HMo=({solverEvent:t})=>{const e=fPt(t.solverName);return q.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:[q.jsxs(cc,{type:"button",variant:"outline",size:"sm",onClick:()=>yPt(t),children:[q.jsx(z5e,{className:"rf-w-4 rf-h-4"}),"Download"]}),e?q.jsx(cc,{asChild:!0,variant:"outline",size:"sm",children:q.jsxs("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:[q.jsx(TZ,{className:"rf-w-4 rf-h-4"}),"Report"]})}):q.jsxs(cc,{type:"button",variant:"outline",size:"sm",disabled:!0,title:"No report link configured for this solver",children:[q.jsx(TZ,{className:"rf-w-4 rf-h-4"}),"Report"]})]})},GMo=({solverEvent:t})=>{const e=fPt(t.solverName);return e?q.jsx(cc,{asChild:!0,variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8",children:q.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",title:"Report solver bug","aria-label":"Report solver bug",children:q.jsx(TZ,{className:"rf-w-4 rf-h-4"})})}):q.jsx(cc,{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:q.jsx(TZ,{className:"rf-w-4 rf-h-4"})})},OMo=({solverEvents:t=[]})=>{const[e,n]=te.useState(null);RMo();const o=te.useMemo(()=>{const s=new Map;for(const a of t){const c=`${a.componentName}-${a.solverName}`;s.set(c,a)}return s},[t]),i=te.useMemo(()=>Array.from(o.keys()),[o]),r=e?o.get(e):null,A=te.useMemo(()=>{if(!r)return{instance:null,error:null,classFound:!1};const s=XIe[r.solverName];if(!s)return{instance:null,error:`Solver class "${r.solverName}" not found in SOLVERS registry. Available: ${Object.keys(XIe).join(", ")}`,classFound:!1};try{const a=r.solverParams,c=a?.input!==void 0?a.input:a;return{instance:new s(c),error:null,classFound:!0}}catch(a){const c=a instanceof Error?a.message:String(a);return console.error("Failed to reconstruct solver:",a),{instance:null,error:`Failed to instantiate solver: ${c}`,classFound:!0}}},[r]);return t.length===0?q.jsx("div",{className:"rf-p-4",children:q.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:q.jsxs("div",{className:"rf-p-4",children:[q.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),q.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."})]})})}):q.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[q.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[q.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(s=>{const a=o.get(s),c=e===s;return q.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${c?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>n(s),children:(()=>{const l=FMo(a.solverName);return q.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[q.jsx(l,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),q.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[q.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:a.componentName}),q.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:a.solverName})]})]})})()},s)})]}),q.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:r?A.instance?q.jsxs("div",{className:"rf-flex rf-h-full rf-flex-col rf-overflow-y-auto",children:[q.jsx(HMo,{solverEvent:r}),q.jsx("div",{className:"rf-min-h-0 rf-flex-1",children:q.jsx(aQ,{fallback:q.jsx("div",{className:"rf-p-4",children:q.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[q.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),q.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",r.solverName]})]})}),children:q.jsx(NMo,{solver:A.instance})})})]}):q.jsxs("div",{className:"rf-p-4",children:[q.jsxs("div",{className:"rf-mb-4",children:[q.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:r.solverName}),q.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",r.componentName]})]}),A.error&&q.jsx("div",{className:`rf-rounded-md rf-border rf-p-4 rf-mb-4 ${A.classFound?"rf-bg-red-50 rf-border-red-200":"rf-bg-yellow-50 rf-border-yellow-200"}`,children:q.jsx("p",{className:`rf-text-sm ${A.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:A.error})}),q.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[q.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:[q.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"}),q.jsxs("div",{className:"rf-flex rf-items-center rf-gap-1",children:[q.jsx(GMo,{solverEvent:r}),q.jsx(cc,{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:()=>yPt(r),children:q.jsx(z5e,{className:"rf-w-4 rf-h-4"})})]})]}),q.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:q.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)})})]})]}):q.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:q.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},EPt=({errorMessage:t,errorStack:e,circuitJsonErrors:n})=>{te.useEffect(()=>{if(t){const o=new Error(t);e&&(o.stack=e);try{iv.captureException(o)}catch{}}},[t,e]),te.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{iv.captureException(i,{error_type:o.type})}catch{}}},[n])},KMo=t=>{te.useEffect(()=>{try{NTt(t)}catch{}},[t.source,t.component,t.isWebEmbedded,t.activeTab])},BPt="0.0.2251",UMo={version:BPt},kDe={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},FDe=new Map,mte=t=>{const e=FDe.get(t);return e?Object.fromEntries(Object.entries(e.stores).map(([n,o])=>[n,o.getState()])):{}},YMo=(t,e,n)=>{if(t===void 0)return{type:"untracked",connection:e.connect(n)};const o=FDe.get(n.name);if(o)return{type:"tracked",store:t,...o};const i={connection:e.connect(n),stores:{}};return FDe.set(n.name,i),{type:"tracked",store:t,...i}},xPt=(t,e={})=>(n,o,i)=>{const{enabled:r,anonymousActionType:A,store:s,...a}=e;let c;try{c=(r??(kDe?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!c)return(kDe?"production":void 0)!=="production"&&r&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),t(n,o,i);const{connection:l,...g}=YMo(s,c,a);let u=!0;i.setState=(_,p,m)=>{const I=n(_,p);if(!u)return I;const C=m===void 0?{type:A||"anonymous"}:typeof m=="string"?{type:m}:m;return s===void 0?(l?.send(C,o()),I):(l?.send({...C,type:`${s}/${C.type}`},{...mte(a.name),[s]:i.getState()}),I)};const d=(..._)=>{const p=u;u=!1,n(..._),u=p},h=t(i.setState,o,i);if(g.type==="untracked"?l?.init(h):(g.stores[g.store]=i,l?.init(Object.fromEntries(Object.entries(g.stores).map(([_,p])=>[_,_===g.store?h:p.getState()])))),i.dispatchFromDevtools&&typeof i.dispatch=="function"){let _=!1;const p=i.dispatch;i.dispatch=(...m)=>{(kDe?"production":void 0)!=="production"&&m[0].type==="__setState"&&!_&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),_=!0),p(...m)}}return l.subscribe(_=>{var p;switch(_.type){case"ACTION":if(typeof _.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return LDe(_.payload,m=>{if(m.type==="__setState"){if(s===void 0){d(m.state);return}Object.keys(m.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" } } }
@@ -5783,7 +5783,7 @@ test("${c} should solve problem correctly", () => {
5783
5783
  // Add more specific assertions based on expected output
5784
5784
  // expect(solver.netLabelPlacementSolver!.netLabelPlacements).toMatchInlineSnapshot()
5785
5785
  })
5786
- `,g=new Blob([l],{type:"text/plain"}),u=URL.createObjectURL(g),d=document.createElement("a");d.href=u,d.download=`${c}.test.ts`,d.click(),URL.revokeObjectURL(u)}catch(a){alert(`Error generating test.ts for ${t.constructor.name}: ${a instanceof Error?a.message:String(a)}`)}o(!1)};return V.jsxs("div",{className:`relative ${e}`,ref:i,children:[V.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>o(!n),title:`Download options for ${t.constructor.name}`,children:t.constructor.name}),n&&V.jsxs("div",{className:"absolute top-full left-0 mt-1 bg-white border border-gray-300 rounded shadow-lg z-10 min-w-[150px]",children:[V.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download JSON"}),V.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:A,children:"Download page.tsx"}),V.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download test.ts"})]})]})},S3t=t=>t.activeSubSolver?[t,...S3t(t.activeSubSolver)]:[t],A3o=({solver:t})=>{const e=S3t(t);return V.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:e.map((n,o)=>V.jsxs("div",{className:"flex items-center",children:[o>0&&V.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),V.jsx(r3o,{solver:n})]},n.constructor.name))})},s3o=({solver:t,triggerRender:e,animationSpeed:n=25,onSolverStarted:o,onSolverCompleted:i})=>{const[r,A]=j.useReducer(_=>!_,!1),s=j.useRef(void 0),a=()=>{!t.solved&&!t.failed&&(t.step(),e())},c=()=>{!t.solved&&!t.failed&&(o&&o(t),t.solve(),e(),i&&i(t))},l=()=>{r?(s.current&&(clearInterval(s.current),s.current=void 0),A()):(A(),s.current=setInterval(()=>{if(t.solved||t.failed){s.current&&(clearInterval(s.current),s.current=void 0),A(),e(),i&&t.solved&&i(t);return}t.step(),e()},n))},g=()=>{const _=t;if(_.getCurrentPhase&&!t.solved&&!t.failed){const p=_.getCurrentPhase();for(;_.getCurrentPhase()===p&&!t.solved&&!t.failed;)t.step();e()}},u=()=>{if(t.solved||t.failed||r)return;const _=window.prompt("Step until which iteration?",`${t.iterations}`);if(_===null)return;const p=Number(_);if(!Number.isFinite(p)){window.alert("Please enter a valid number for the iteration");return}for(;t.iterations<p&&!t.solved&&!t.failed;)t.step();e(),t.solved&&i&&i(t)};j.useEffect(()=>()=>{s.current&&clearInterval(s.current)},[]),j.useEffect(()=>{(t.solved||t.failed)&&r&&(s.current&&(clearInterval(s.current),s.current=void 0),A())},[t.solved,t.failed,r]);const d=t.getCurrentPhase!==void 0,h=d?t.getCurrentPhase():null;return V.jsxs("div",{className:"space-y-2 p-2 border-b",children:[V.jsx("div",{className:"flex items-center",children:V.jsx(A3o,{solver:t})}),V.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[V.jsx("button",{onClick:a,disabled:t.solved||t.failed||r,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),V.jsx("button",{onClick:c,disabled:t.solved||t.failed||r,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),V.jsx("button",{onClick:l,disabled:t.solved||t.failed,className:`px-3 py-1 rounded text-white text-sm ${r?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:r?"Stop":"Animate"}),V.jsx("button",{onClick:u,disabled:t.solved||t.failed||r,className:"bg-orange-500 hover:bg-orange-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step Until Iteration"}),d&&V.jsx("button",{onClick:g,disabled:t.solved||t.failed||r,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),V.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&V.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),h&&V.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",V.jsx("span",{className:"font-medium",children:h})]}),t.solved&&V.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&V.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&V.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},a3o=(t,e,n)=>{const o=t.currentPipelineStepIndex;return e<o?"Completed":e===o&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},c3o=(t,e)=>{const o=t.pipelineDef[e].solverName,i=a3o(t,e),r=t[o],A=t.firstIterationOfPhase?.[o]??null,s=t.iterations;let a=0;if(i==="Completed"){const u=t.pipelineDef[e+1],d=u?t.firstIterationOfPhase?.[u.solverName]:void 0;d!==void 0&&A!==null?a=d-A:A!==null&&(a=s-A)}else i==="In Progress"&&A!==null&&(a=s-A);const c=t.timeSpentOnPhase?.[o]??0;let l=0;i==="Completed"?l=1:i==="In Progress"&&r&&(l=r.progress??0);const g=r?.stats??null;return{index:e,name:o,status:i,firstIteration:A,iterations:a,progress:l,timeSpent:c,stats:g&&Object.keys(g).length>0?g:null,solverInstance:r??null}},l3o=({status:t})=>{const e={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return V.jsx("span",{className:`font-medium ${e[t]}`,children:t})},g3o=({progress:t})=>{if(t===0)return null;const e=Math.round(t*100);return V.jsxs("div",{className:"flex items-center gap-2",children:[V.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:V.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${e}%`}})}),V.jsxs("span",{className:"text-xs text-gray-500",children:[e,"%"]})]})},u3o=t=>Object.entries(t).map(([e,n])=>`${e}: ${n}`).join(", "),h3o=({stats:t})=>{if(!t||Object.keys(t).length===0)return V.jsx("span",{children:"-"});const e=Object.entries(t),n=u3o(t);return V.jsxs("details",{className:"cursor-pointer",children:[V.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:n}),V.jsx("div",{className:"mt-1 text-xs",children:e.map(([o,i])=>V.jsxs("div",{children:[o,": ",String(i)]},o))})]})},kMe=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(kMe);const e={};for(const[n,o]of Object.entries(t))n.startsWith("_")||(e[n]=kMe(o));return e},d3o=(t,e)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${e}`);return}const n=kMe(t.getConstructorParams()),o=new Blob([JSON.stringify(n,null,2)],{type:"application/json"}),i=URL.createObjectURL(o),r=document.createElement("a");r.href=i,r.download=`${e}_input.json`,r.click(),URL.revokeObjectURL(i)}catch(n){alert(`Error downloading input for ${e}: ${n instanceof Error?n.message:String(n)}`)}},_3o=({solver:t,onStepUntilPhase:e,onDownloadInput:n})=>{const o=t.pipelineDef.map((s,a)=>c3o(t,a)),i=s=>{e?.(s)},r=s=>{s.solverInstance&&(n?n(s.solverInstance,s.name):d3o(s.solverInstance,s.name))},A=s=>`${(s/1e3).toFixed(2)}s`;return V.jsxs("div",{className:"border-t border-gray-200",children:[V.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:V.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),V.jsx("div",{className:"overflow-x-auto",children:V.jsxs("table",{className:"w-full text-sm",children:[V.jsx("thead",{children:V.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),V.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",V.jsx("sub",{children:"0"})]}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),V.jsx("tbody",{children:o.map(s=>V.jsxs("tr",{className:`border-b border-gray-100 ${s.status==="In Progress"?"bg-yellow-50":""}`,children:[V.jsx("td",{className:"px-4 py-2",children:V.jsxs("div",{className:"flex items-center gap-2",children:[V.jsx("span",{className:"text-gray-400 w-6",children:String(s.index+1).padStart(2,"0")}),V.jsx("button",{onClick:()=>i(s.name),disabled:s.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 ${s.name} completes`,children:V.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:V.jsx("path",{fillRule:"evenodd",d:"M4.5 5.653c0-1.426 1.529-2.33 2.779-1.643l11.54 6.348c1.295.712 1.295 2.573 0 3.285L7.28 19.991c-1.25.687-2.779-.217-2.779-1.643V5.653z",clipRule:"evenodd"})})}),V.jsx("span",{className:"font-medium text-gray-900",children:s.name})]})}),V.jsx("td",{className:"px-4 py-2",children:V.jsx(l3o,{status:s.status})}),V.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:s.firstIteration!==null?s.firstIteration:""}),V.jsx("td",{className:"px-4 py-2 text-gray-600",children:s.iterations}),V.jsx("td",{className:"px-4 py-2",children:V.jsx(g3o,{progress:s.progress})}),V.jsx("td",{className:"px-4 py-2 text-gray-600",children:A(s.timeSpent)}),V.jsx("td",{className:"px-4 py-2 text-gray-500",children:V.jsx(h3o,{stats:s.stats})}),V.jsx("td",{className:"px-4 py-2",children:s.solverInstance?V.jsxs("button",{onClick:()=>r(s),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${s.name}`,children:[V.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:V.jsx("path",{fillRule:"evenodd",d:"M12 2.25a.75.75 0 01.75.75v11.69l3.22-3.22a.75.75 0 111.06 1.06l-4.5 4.5a.75.75 0 01-1.06 0l-4.5-4.5a.75.75 0 111.06-1.06l3.22 3.22V3a.75.75 0 01.75-.75zm-9 13.5a.75.75 0 01.75.75v2.25a1.5 1.5 0 001.5 1.5h13.5a1.5 1.5 0 001.5-1.5V16.5a.75.75 0 011.5 0v2.25a3 3 0 01-3 3H5.25a3 3 0 01-3-3V16.5a.75.75 0 01.75-.75z",clipRule:"evenodd"})}),V.jsx("span",{children:"Input"})]}):null})]},s.name))})]})})]})},m3o=class extends Jr.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 p3o({graphics:t}){const e=t.points??[],n=t.lines??[],o=t.rects??[],i=t.circles??[],r=t.texts??[];let A=Number.POSITIVE_INFINITY,s=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,c=Number.NEGATIVE_INFINITY;const l=(p,m)=>{typeof p=="number"&&(p<A&&(A=p),p>a&&(a=p)),typeof m=="number"&&(m<s&&(s=m),m>c&&(c=m))};for(const p of e)l(p.x,p.y);for(const p of n){const m=p.points??[];for(const I of m)l(I.x,I.y)}for(const p of o){const m=p.x??0,I=p.y??0,C=p.width??0,f=p.height??0;l(m,I),l(m+C,I+f)}for(const p of i){const m=p.x??0,I=p.y??0,C=p.radius??1;l(m-C,I-C),l(m+C,I+C)}for(const p of r)l(p.x,p.y);(!isFinite(A)||!isFinite(s)||!isFinite(a)||!isFinite(c))&&(A=-20,s=-20,a=20,c=20);const g=10,u=A-g,d=s-g,h=Math.max(1,a-A+2*g),_=Math.max(1,c-s+2*g);return V.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${u} ${d} ${h} ${_}`,role:"img","aria-label":"Graphics fallback",children:[o.map((p,m)=>V.jsx("rect",{x:p.x??0,y:p.y??0,width:p.width??0,height:p.height??0,fill:"none",stroke:p.strokeColor??"black",strokeWidth:p.strokeWidth??1},`rect-${m}`)),n.map((p,m)=>V.jsx("polyline",{fill:"none",stroke:p.strokeColor??"black",strokeWidth:p.strokeWidth??1,points:(p.points??[]).map(I=>`${I.x??0},${I.y??0}`).join(" ")},`line-${m}`)),i.map((p,m)=>V.jsx("circle",{cx:p.x??0,cy:p.y??0,r:p.radius??1.5,fill:p.fillColor??"none",stroke:p.strokeColor??"black",strokeWidth:p.strokeWidth??1},`circle-${m}`)),e.map((p,m)=>V.jsx("circle",{cx:p.x??0,cy:p.y??0,r:p.radius??1.5,fill:p.color??"black"},`point-${m}`)),r.map((p,m)=>V.jsx("text",{x:p.x??0,y:p.y??0,fontSize:p.fontSize??10,fill:p.color??"black",children:p.text??""},`text-${m}`))]})}var I3o=({solver:t,animationSpeed:e=25,onSolverStarted:n,onSolverCompleted:o})=>{const[i,r]=j.useReducer(l=>l+1,0),A=j.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(l){return console.error("Visualization error:",l),{points:[],lines:[],rects:[],circles:[]}}},[t,i]),s=j.useMemo(()=>(A.rects?.length||0)===0&&(A.lines?.length||0)===0&&(A.points?.length||0)===0&&(A.circles?.length||0)===0,[A]);j.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const l=document.createElement("script");l.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(l)}},[]);const a=t.pipelineDef!==void 0,c=l=>{const g=t;if(!t.solved&&!t.failed){for(;!t.solved&&!t.failed&&g.currentPipelineStepIndex<=g.pipelineDef.findIndex(u=>u.solverName===l);)t.step();r()}};return V.jsxs("div",{children:[V.jsx(s3o,{solver:t,triggerRender:r,animationSpeed:e,onSolverStarted:n,onSolverCompleted:o}),s?V.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):V.jsx(m3o,{fallback:V.jsx(p3o,{graphics:A}),children:V.jsx(i3o,{graphics:A})}),a&&V.jsx(_3o,{solver:t,onStepUntilPhase:c})]})};const C3o=()=>{j.useEffect(()=>{const t="tailwind-cdn-script";if(document.getElementById(t)||window.tailwind)return;const e=document.createElement("div");e.className="hidden",document.body.appendChild(e);const n=window.getComputedStyle(e).display==="none";if(document.body.removeChild(e),n)return;const o=document.createElement("script");o.id=t,o.src="https://cdn.tailwindcss.com",document.head.appendChild(o)},[])},f3o=1e3,MQ=(t,e)=>{const{fileName:n,mimeType:o="text/plain"}=e,i=t instanceof Blob?t:new Blob([t],{type:o}),r=URL.createObjectURL(i),A=document.createElement("a");A.href=r,A.download=n,A.target="_blank",A.rel="noopener noreferrer",A.style.display="none",document.body.appendChild(A),A.click(),document.body.removeChild(A),setTimeout(()=>{URL.revokeObjectURL(r)},f3o)},b3t=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"},wQ="https://github.com/tscircuit/tscircuit-autorouter/issues/new",D3t="https://github.com/tscircuit/copper-pour-solver/issues/new",M3t="https://github.com/tscircuit/calculate-packing/issues/new",w3t="https://github.com/tscircuit/schematic-trace-solver/issues/new?template=json-bug-report.yml",y3o={PackSolver2:M3t,AutoroutingPipelineSolver:wQ,AssignableAutoroutingPipeline2:wQ,AssignableAutoroutingPipeline3:wQ,AutoroutingPipeline1_OriginalUnravel:wQ,AutoroutingPipelineSolver3_HgPortPointPathing:wQ,AutoroutingPipelineSolver4:wQ,AutoroutingPipelineSolver5:wQ,AutoroutingPipelineSolver7_MultiGraph:wQ,AutoroutingPipelineSolver8:wQ,CopperPourPipelineSolver:D3t,SchematicTracePipelineSolver:w3t},E3o=t=>t.toLowerCase().includes("pack")?qIo:t.toLowerCase().includes("rout")?eCo:TIo,P3t=t=>{const e=y3o[t];if(e)return e;const n=t.toLowerCase();return n.includes("autorout")?wQ:n.includes("schematic")&&n.includes("trace")?w3t:n.includes("copperpour")?D3t:n.includes("pack")?M3t:null},B3o=t=>`${b3t(`${t.componentName}-${t.solverName}`)}-solver-input.json`,v3t=t=>{MQ(JSON.stringify(t.solverParams,null,2),{fileName:B3o(t),mimeType:"application/json"})},x3o=({solverEvent:t})=>{const e=P3t(t.solverName);return V.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:[V.jsxs(Vs,{type:"button",variant:"outline",size:"sm",onClick:()=>v3t(t),children:[V.jsx(j4e,{className:"rf-w-4 rf-h-4"}),"Download"]}),e?V.jsx(Vs,{asChild:!0,variant:"outline",size:"sm",children:V.jsxs("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:[V.jsx(pee,{className:"rf-w-4 rf-h-4"}),"Report"]})}):V.jsxs(Vs,{type:"button",variant:"outline",size:"sm",disabled:!0,title:"No report link configured for this solver",children:[V.jsx(pee,{className:"rf-w-4 rf-h-4"}),"Report"]})]})},Q3o=({solverEvent:t})=>{const e=P3t(t.solverName);return e?V.jsx(Vs,{asChild:!0,variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8",children:V.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",title:"Report solver bug","aria-label":"Report solver bug",children:V.jsx(pee,{className:"rf-w-4 rf-h-4"})})}):V.jsx(Vs,{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:V.jsx(pee,{className:"rf-w-4 rf-h-4"})})},S3o=({solverEvents:t=[]})=>{const[e,n]=j.useState(null);C3o();const o=j.useMemo(()=>{const s=new Map;for(const a of t){const c=`${a.componentName}-${a.solverName}`;s.set(c,a)}return s},[t]),i=j.useMemo(()=>Array.from(o.keys()),[o]),r=e?o.get(e):null,A=j.useMemo(()=>{if(!r)return{instance:null,error:null,classFound:!1};const s=_me[r.solverName];if(!s)return{instance:null,error:`Solver class "${r.solverName}" not found in SOLVERS registry. Available: ${Object.keys(_me).join(", ")}`,classFound:!1};try{const a=r.solverParams,c=a?.input!==void 0?a.input:a;return{instance:new s(c),error:null,classFound:!0}}catch(a){const c=a instanceof Error?a.message:String(a);return console.error("Failed to reconstruct solver:",a),{instance:null,error:`Failed to instantiate solver: ${c}`,classFound:!0}}},[r]);return t.length===0?V.jsx("div",{className:"rf-p-4",children:V.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:V.jsxs("div",{className:"rf-p-4",children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),V.jsx("p",{className:"rf-text-sm rf-text-gray-600",children:"Solvers will appear here when the circuit runs. Solvers are used for tasks like component packing and autorouting."})]})})}):V.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[V.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[V.jsxs("div",{className:"rf-text-xs rf-font-semibold rf-text-gray-500 rf-px-3 rf-py-2 rf-bg-gray-50 rf-border-b rf-border-gray-200",children:[i.length," ",i.length===1?"Solver":"Solvers"]}),i.map(s=>{const a=o.get(s),c=e===s;return V.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${c?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>n(s),children:(()=>{const l=E3o(a.solverName);return V.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[V.jsx(l,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),V.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[V.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:a.componentName}),V.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:a.solverName})]})]})})()},s)})]}),V.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:r?A.instance?V.jsxs("div",{className:"rf-flex rf-h-full rf-flex-col rf-overflow-y-auto",children:[V.jsx(x3o,{solverEvent:r}),V.jsx("div",{className:"rf-min-h-0 rf-flex-1",children:V.jsx(y2,{fallback:V.jsx("div",{className:"rf-p-4",children:V.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),V.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",r.solverName]})]})}),children:V.jsx(I3o,{solver:A.instance})})})]}):V.jsxs("div",{className:"rf-p-4",children:[V.jsxs("div",{className:"rf-mb-4",children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:r.solverName}),V.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",r.componentName]})]}),A.error&&V.jsx("div",{className:`rf-rounded-md rf-border rf-p-4 rf-mb-4 ${A.classFound?"rf-bg-red-50 rf-border-red-200":"rf-bg-yellow-50 rf-border-yellow-200"}`,children:V.jsx("p",{className:`rf-text-sm ${A.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:A.error})}),V.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[V.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:[V.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"}),V.jsxs("div",{className:"rf-flex rf-items-center rf-gap-1",children:[V.jsx(Q3o,{solverEvent:r}),V.jsx(Vs,{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:()=>v3t(r),children:V.jsx(j4e,{className:"rf-w-4 rf-h-4"})})]})]}),V.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:V.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(r.solverParams,null,2)})})]})]}):V.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:V.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},N3t=({errorMessage:t,errorStack:e,circuitJsonErrors:n})=>{j.useEffect(()=>{if(t){const o=new Error(t);e&&(o.stack=e);try{b9.captureException(o)}catch{}}},[t,e]),j.useEffect(()=>{if(n&&n.length>0)for(const o of n){const i=new Error(o.message||"Circuit JSON Error");o.stack&&(i.stack=o.stack);try{b9.captureException(i,{error_type:o.type})}catch{}}},[n])},R3t=t=>{j.useEffect(()=>{try{Tkn(t)}catch{}},[t.source,t.component,t.isWebEmbedded,t.activeTab])},T3t="0.0.2250",b3o={version:T3t},ene=aAt()(cAt(t=>({lastRunEvalVersion:void 0,setLastRunEvalVersion:e=>{t({lastRunEvalVersion:e})}}),{name:"runframe-runner-store"})),D3o=t=>{const[e,n]=j.useState([]),[o,i]=j.useState(null),[r,A]=j.useState(""),[s,a]=r9("eval-version-selection",null),c=ene(d=>d.setLastRunEvalVersion),l=ene(d=>d.lastRunEvalVersion);return j.useEffect(()=>{t&&fetch("https://data.jsdelivr.com/v1/package/npm/@tscircuit/eval").then(d=>d.json()).then(d=>{if(Array.isArray(d?.versions)){let h=[...d.versions];d.tags?.latest&&(i(d.tags.latest),h=h.filter(_=>_!==d.tags.latest)),n(h)}}).catch(()=>{})},[t]),j.useEffect(()=>{t&&(s?(window.TSCIRCUIT_LATEST_EVAL_VERSION=s,c(s)):o&&(window.TSCIRCUIT_LATEST_EVAL_VERSION=o,c(o)))},[t,s,o]),{versions:j.useMemo(()=>e.filter(d=>d.includes(r)).slice(0,50),[e,r]),latestVersion:o,lastRunEvalVersion:l,search:r,setSearch:A,selectVersion:d=>{a(d),A("")}}},M3o=({snippetNames:t,onSelect:e,onCancel:n,isOpen:o})=>{const[i,r]=j.useState(""),[A,s]=j.useState("");if(!o)return null;const a=t.filter(g=>g.toLowerCase().includes(A.toLowerCase())),c=A&&!t.includes(A),l=g=>{g.key==="Enter"&&(a.length===1?r(a[0]):c&&r(A))};return V.jsx("div",{className:"rf-fixed rf-inset-0 rf-bg-black rf-bg-opacity-50 rf-flex rf-items-center rf-justify-center rf-z-[100]",children:V.jsxs("div",{className:"rf-bg-white rf-rounded-lg rf-p-6 rf-w-96",children:[V.jsx("h2",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Select Snippet"}),V.jsx("input",{type:"text",className:"rf-w-full rf-px-4 rf-py-2 rf-border rf-rounded rf-mb-4",placeholder:"Search snippets or new snippet name...",value:A,onChange:g=>s(g.target.value),onKeyDown:l}),V.jsxs("div",{className:"rf-h-60 rf-overflow-y-auto",children:[a.map(g=>V.jsx("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 ${i===g?"bg-blue-50":""}`,onClick:()=>r(g),children:g},g)),c&&V.jsxs("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 text-blue-500 ${i===A?"bg-blue-50":""}`,onClick:()=>r(A),children:['Create new "',A,'"']})]}),V.jsxs("div",{className:"rf-mt-4 rf-flex rf-justify-end rf-gap-2",children:[V.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-text-gray-600 rf-hover:text-gray-800",onClick:n,children:"Cancel"}),V.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-bg-blue-500 rf-text-white rf-rounded rf-hover:bg-blue-600 rf-disabled:opacity-50",onClick:()=>i&&e(i),disabled:!i,children:i===A?`Create "${i}"`:`Save to ${i}`})]})]})})},w3o=t=>{const e=j.useRef(null),n=w0(o=>o.recentEvents);j.useEffect(()=>{if(n.length===0)return;const o=n[0];o.event_id!==e.current&&(t(o),e.current=o.event_id)},[n,t])};var tne="Dialog",[k3t,F3t]=_B(tne),[P3o,OB]=k3t(tne),nne=t=>{const{__scopeDialog:e,children:n,open:o,defaultOpen:i,onOpenChange:r,modal:A=!0}=t,s=j.useRef(null),a=j.useRef(null),[c,l]=Lb({prop:o,defaultProp:i??!1,onChange:r,caller:tne});return V.jsx(P3o,{scope:e,triggerRef:s,contentRef:a,contentId:bp(),titleId:bp(),descriptionId:bp(),open:c,onOpenChange:l,onOpenToggle:j.useCallback(()=>l(g=>!g),[l]),modal:A,children:n})};nne.displayName=tne;var L3t="DialogTrigger",H3t=j.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,i=OB(L3t,n),r=mg(e,i.triggerRef);return V.jsx(Us.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":HMe(i.open),...o,ref:r,onClick:wr(t.onClick,i.onOpenToggle)})});H3t.displayName=L3t;var FMe="DialogPortal",[v3o,G3t]=k3t(FMe,{forceMount:void 0}),one=t=>{const{__scopeDialog:e,forceMount:n,children:o,container:i}=t,r=OB(FMe,e);return V.jsx(v3o,{scope:e,forceMount:n,children:j.Children.map(o,A=>V.jsx(Ry,{present:n||r.open,children:V.jsx(Nee,{asChild:!0,container:i,children:A})}))})};one.displayName=FMe;var ine="DialogOverlay",lO=j.forwardRef((t,e)=>{const n=G3t(ine,t.__scopeDialog),{forceMount:o=n.forceMount,...i}=t,r=OB(ine,t.__scopeDialog);return r.modal?V.jsx(Ry,{present:o||r.open,children:V.jsx(R3o,{...i,ref:e})}):null});lO.displayName=ine;var N3o=iP("DialogOverlay.RemoveScroll"),R3o=j.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,i=OB(ine,n),r=_Co(),A=mg(e,r);return V.jsx(Oee,{as:N3o,allowPinchZoom:!0,shards:[i.contentRef],children:V.jsx(Us.div,{"data-state":HMe(i.open),...o,ref:A,style:{pointerEvents:"auto",...o.style}})})}),wN="DialogContent",gO=j.forwardRef((t,e)=>{const n=G3t(wN,t.__scopeDialog),{forceMount:o=n.forceMount,...i}=t,r=OB(wN,t.__scopeDialog);return V.jsx(Ry,{present:o||r.open,children:r.modal?V.jsx(T3o,{...i,ref:e}):V.jsx(k3o,{...i,ref:e})})});gO.displayName=wN;var T3o=j.forwardRef((t,e)=>{const n=OB(wN,t.__scopeDialog),o=j.useRef(null),i=mg(e,n.contentRef,o);return j.useEffect(()=>{const r=o.current;if(r)return fbe(r)},[]),V.jsx(O3t,{...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 A=r.detail.originalEvent,s=A.button===0&&A.ctrlKey===!0;(A.button===2||s)&&r.preventDefault()}),onFocusOutside:wr(t.onFocusOutside,r=>r.preventDefault())})}),k3o=j.forwardRef((t,e)=>{const n=OB(wN,t.__scopeDialog),o=j.useRef(!1),i=j.useRef(!1);return V.jsx(O3t,{...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 A=r.target;n.triggerRef.current?.contains(A)&&r.preventDefault(),r.detail.originalEvent.type==="focusin"&&i.current&&r.preventDefault()}})}),O3t=j.forwardRef((t,e)=>{const{__scopeDialog:n,trapFocus:o,onOpenAutoFocus:i,onCloseAutoFocus:r,...A}=t,s=OB(wN,n);return ebe(),V.jsx(V.Fragment,{children:V.jsx(Cee,{asChild:!0,loop:!0,trapped:o,onMountAutoFocus:i,onUnmountAutoFocus:r,children:V.jsx(IG,{role:"dialog",id:s.contentId,"aria-describedby":s.descriptionId,"aria-labelledby":s.titleId,"data-state":HMe(s.open),...A,ref:e,deferPointerDownOutside:!0,onDismiss:()=>s.onOpenChange(!1)})})})}),K3t="DialogTitle",rne=j.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,i=OB(K3t,n);return V.jsx(Us.h2,{id:i.titleId,...o,ref:e})});rne.displayName=K3t;var U3t="DialogDescription",Ane=j.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,i=OB(U3t,n);return V.jsx(Us.p,{id:i.descriptionId,...o,ref:e})});Ane.displayName=U3t;var Y3t="DialogClose",LMe=j.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,i=OB(Y3t,n);return V.jsx(Us.button,{type:"button",...o,ref:e,onClick:wr(t.onClick,()=>i.onOpenChange(!1))})});LMe.displayName=Y3t;function HMe(t){return t?"open":"closed"}var V3t="AlertDialog",[F3o]=_B(V3t,[F3t]),B5=F3t(),z3t=t=>{const{__scopeAlertDialog:e,...n}=t,o=B5(e);return V.jsx(nne,{...o,...n,modal:!0})};z3t.displayName=V3t;var L3o="AlertDialogTrigger",H3o=j.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,i=B5(n);return V.jsx(H3t,{...i,...o,ref:e})});H3o.displayName=L3o;var G3o="AlertDialogPortal",J3t=t=>{const{__scopeAlertDialog:e,...n}=t,o=B5(e);return V.jsx(one,{...o,...n})};J3t.displayName=G3o;var O3o="AlertDialogOverlay",q3t=j.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,i=B5(n);return V.jsx(lO,{...i,...o,ref:e})});q3t.displayName=O3o;var W3t="AlertDialogContent",[K3o,U3o]=F3o(W3t),j3t=j.forwardRef((t,e)=>{const{__scopeAlertDialog:n,children:o,...i}=t,r=B5(n),A=j.useRef(null),s=mg(e,A),a=j.useRef(null);return V.jsx(K3o,{scope:n,cancelRef:a,children:V.jsx(gO,{role:"alertdialog",...r,...i,ref:s,onOpenAutoFocus:wr(i.onOpenAutoFocus,c=>{c.preventDefault(),a.current?.focus({preventScroll:!0})}),onPointerDownOutside:c=>c.preventDefault(),onInteractOutside:c=>c.preventDefault(),children:o})})});j3t.displayName=W3t;var Y3o="AlertDialogTitle",X3t=j.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,i=B5(n);return V.jsx(rne,{...i,...o,ref:e})});X3t.displayName=Y3o;var V3o="AlertDialogDescription",$3t=j.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,i=B5(n);return V.jsx(Ane,{...i,...o,ref:e})});$3t.displayName=V3o;var z3o="AlertDialogAction",Z3t=j.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,i=B5(n);return V.jsx(LMe,{...i,...o,ref:e})});Z3t.displayName=z3o;var evt="AlertDialogCancel",tvt=j.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,{cancelRef:i}=U3o(evt,n),r=B5(n),A=mg(e,i);return V.jsx(LMe,{...r,...o,ref:A})});tvt.displayName=evt;var J3o=z3t,q3o=J3t,nvt=q3t,ovt=j3t,ivt=Z3t,rvt=tvt,Avt=X3t,svt=$3t;const avt=J3o,W3o=q3o,cvt=j.forwardRef(({className:t,...e},n)=>V.jsx(nvt,{className:Ui("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}));cvt.displayName=nvt.displayName;const GMe=j.forwardRef(({className:t,...e},n)=>V.jsxs(W3o,{children:[V.jsx(cvt,{}),V.jsx(ovt,{ref:n,className:Ui("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})]}));GMe.displayName=ovt.displayName;const OMe=({className:t,...e})=>V.jsx("div",{className:Ui("rf-flex rf-flex-col rf-space-y-2 rf-text-center sm:rf-text-left",t),...e});OMe.displayName="AlertDialogHeader";const KMe=({className:t,...e})=>V.jsx("div",{className:Ui("rf-flex rf-flex-col-reverse sm:rf-flex-row sm:rf-justify-end sm:rf-space-x-2",t),...e});KMe.displayName="AlertDialogFooter";const UMe=j.forwardRef(({className:t,...e},n)=>V.jsx(Avt,{ref:n,className:Ui("rf-text-lg rf-font-semibold",t),...e}));UMe.displayName=Avt.displayName;const YMe=j.forwardRef(({className:t,...e},n)=>V.jsx(svt,{ref:n,className:Ui("rf-text-sm rf-text-zinc-500 dark:rf-text-zinc-400",t),...e}));YMe.displayName=svt.displayName;const j3o=j.forwardRef(({className:t,...e},n)=>V.jsx(ivt,{ref:n,className:Ui($7(),t),...e}));j3o.displayName=ivt.displayName;const VMe=j.forwardRef(({className:t,...e},n)=>V.jsx(rvt,{ref:n,className:Ui($7({variant:"outline"}),"rf-mt-2 sm:rf-mt-0",t),...e}));VMe.displayName=rvt.displayName;function X3o(t){const e=j.useRef({value:t,previous:t});return j.useMemo(()=>(e.current.value!==t&&(e.current.previous=e.current.value,e.current.value=t),e.current.previous),[t])}var sne="Checkbox",[$3o]=_B(sne),[Z3o,zMe]=$3o(sne);function evo(t){const{__scopeCheckbox:e,checked:n,children:o,defaultChecked:i,disabled:r,form:A,name:s,onCheckedChange:a,required:c,value:l="on",internal_do_not_use_render:g}=t,[u,d]=Lb({prop:n,defaultProp:i??!1,onChange:a,caller:sne}),[h,_]=j.useState(null),[p,m]=j.useState(null),I=j.useRef(!1),C=h?!!A||!!h.closest("form"):!0,f={checked:u,disabled:r,setChecked:d,control:h,setControl:_,name:s,form:A,value:l,hasConsumerStoppedPropagationRef:I,required:c,defaultChecked:YD(i)?!1:i,isFormControl:C,bubbleInput:p,setBubbleInput:m};return V.jsx(Z3o,{scope:e,...f,children:tvo(g)?g(f):o})}var lvt="CheckboxTrigger",gvt=j.forwardRef(({__scopeCheckbox:t,onKeyDown:e,onClick:n,...o},i)=>{const{control:r,value:A,disabled:s,checked:a,required:c,setControl:l,setChecked:g,hasConsumerStoppedPropagationRef:u,isFormControl:d,bubbleInput:h}=zMe(lvt,t),_=mg(i,l),p=j.useRef(a);return j.useEffect(()=>{const m=r?.form;if(m){const I=()=>g(p.current);return m.addEventListener("reset",I),()=>m.removeEventListener("reset",I)}},[r,g]),V.jsx(Us.button,{type:"button",role:"checkbox","aria-checked":YD(a)?"mixed":a,"aria-required":c,"data-state":mvt(a),"data-disabled":s?"":void 0,disabled:s,value:A,...o,ref:_,onKeyDown:wr(e,m=>{m.key==="Enter"&&m.preventDefault()}),onClick:wr(n,m=>{g(I=>YD(I)?!0:!I),h&&d&&(u.current=m.isPropagationStopped(),u.current||m.stopPropagation())})})});gvt.displayName=lvt;var JMe=j.forwardRef((t,e)=>{const{__scopeCheckbox:n,name:o,checked:i,defaultChecked:r,required:A,disabled:s,value:a,onCheckedChange:c,form:l,...g}=t;return V.jsx(evo,{__scopeCheckbox:n,checked:i,defaultChecked:r,disabled:s,required:A,onCheckedChange:c,name:o,form:l,value:a,internal_do_not_use_render:({isFormControl:u})=>V.jsxs(V.Fragment,{children:[V.jsx(gvt,{...g,ref:e,__scopeCheckbox:n}),u&&V.jsx(_vt,{__scopeCheckbox:n})]})})});JMe.displayName=sne;var uvt="CheckboxIndicator",hvt=j.forwardRef((t,e)=>{const{__scopeCheckbox:n,forceMount:o,...i}=t,r=zMe(uvt,n);return V.jsx(Ry,{present:o||YD(r.checked)||r.checked===!0,children:V.jsx(Us.span,{"data-state":mvt(r.checked),"data-disabled":r.disabled?"":void 0,...i,ref:e,style:{pointerEvents:"none",...t.style}})})});hvt.displayName=uvt;var dvt="CheckboxBubbleInput",_vt=j.forwardRef(({__scopeCheckbox:t,...e},n)=>{const{control:o,hasConsumerStoppedPropagationRef:i,checked:r,defaultChecked:A,required:s,disabled:a,name:c,value:l,form:g,bubbleInput:u,setBubbleInput:d}=zMe(dvt,t),h=mg(n,d),_=X3o(r),p=ASt(o);j.useEffect(()=>{const I=u;if(!I)return;const C=window.HTMLInputElement.prototype,y=Object.getOwnPropertyDescriptor(C,"checked").set,B=!i.current;if(_!==r&&y){const x=new Event("click",{bubbles:B});I.indeterminate=YD(r),y.call(I,YD(r)?!1:r),I.dispatchEvent(x)}},[u,_,r,i]);const m=j.useRef(YD(r)?!1:r);return V.jsx(Us.input,{type:"checkbox","aria-hidden":!0,defaultChecked:A??m.current,required:s,disabled:a,name:c,value:l,form:g,...e,tabIndex:-1,ref:h,style:{...e.style,...p,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});_vt.displayName=dvt;function tvo(t){return typeof t=="function"}function YD(t){return t==="indeterminate"}function mvt(t){return YD(t)?"indeterminate":t?"checked":"unchecked"}const uO=j.forwardRef(({className:t,...e},n)=>V.jsx(JMe,{ref:n,className:Ui("rf-peer rf-h-4 rf-w-4 rf-shrink-0 rf-rounded-sm rf-border rf-border-zinc-200 rf-border-zinc-900 rf-shadow focus-visible:rf-outline-none focus-visible:rf-ring-1 focus-visible:rf-ring-zinc-950 disabled:rf-cursor-not-allowed disabled:rf-opacity-50 data-[state=checked]:rf-bg-zinc-900 data-[state=checked]:rf-text-zinc-50 dark:rf-border-zinc-800 dark:rf-border-zinc-50 dark:focus-visible:rf-ring-zinc-300 dark:data-[state=checked]:rf-bg-zinc-50 dark:data-[state=checked]:rf-text-zinc-900",t),...e,children:V.jsx(hvt,{className:Ui("rf-flex rf-items-center rf-justify-center rf-text-current"),children:V.jsx(r3,{className:"rf-h-4 rf-w-4"})})}));uO.displayName=JMe.displayName;const PN=nne,nvo=one,pvt=j.forwardRef(({className:t,...e},n)=>V.jsx(lO,{className:Ui("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}));pvt.displayName=lO.displayName;const f3=j.forwardRef(({className:t,children:e,showOverlay:n=!0,...o},i)=>V.jsxs(nvo,{children:[V.jsx(pvt,{className:Ui(n?"":"rf-hidden")}),V.jsx(gO,{ref:i,className:Ui("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})]}));f3.displayName=gO.displayName;const y3=({className:t,...e})=>V.jsx("div",{className:Ui("rf-flex rf-flex-col rf-space-y-2 rf-text-center sm:rf-text-left",t),...e});y3.displayName="DialogHeader";const hO=({className:t,...e})=>V.jsx("div",{className:Ui("rf-flex rf-flex-col-reverse sm:rf-flex-row sm:rf-justify-end sm:rf-space-x-2",t),...e});hO.displayName="DialogFooter";const E3=j.forwardRef(({className:t,...e},n)=>V.jsx(rne,{ref:n,className:Ui("rf-text-lg rf-font-semibold",t),...e}));E3.displayName=rne.displayName;const vN=j.forwardRef(({className:t,...e},n)=>V.jsx(Ane,{ref:n,className:Ui("rf-text-sm rf-text-zinc-500 dark:rf-text-zinc-400",t),...e}));vN.displayName=Ane.displayName;const ane={"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"}},ovo="https://cdn.jsdelivr.net/npm/easyeda@latest/dist/browser/index.js";let qMe=null;const WMe=async()=>(qMe||(qMe=import(ovo)),qMe),ivo=t=>(e,n)=>{const o=new Headers(n?.headers),i={};return o.forEach((r,A)=>{i[A]=r}),fetch(`${t?.apiBase??zC}/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}})},rvo=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??[]},Avo=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}),Ivt=async(t,e)=>{const{fetchEasyEDAComponent:n}=await WMe();return n(t,{fetch:ivo(e),includeModelMetadata:e?.includeModelMetadata})},svo=async(t,e)=>{const{convertRawEasyToTsx:n}=await WMe(),o=await Ivt(t,e);return n({rawEasy:o})},avo=async(t,e)=>{const{EasyEdaJsonSchema:n,convertEasyEdaJsonToCircuitJson:o}=await WMe(),i=await Ivt(t,{...e,includeModelMetadata:!1}),r=n.parse(i);return o(r,{shouldRecenter:!0,showDesignator:!0,useModelCdn:!1})};function VD(t){return Array.isArray?Array.isArray(t):fvt(t)==="[object Array]"}function cvo(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 jMe(t){return t==null?"":cvo(t)}function ZI(t){return typeof t=="string"}function cne(t){return typeof t=="number"}function lvo(t){return t===!0||t===!1||gvo(t)&&fvt(t)=="[object Boolean]"}function Cvt(t){return typeof t=="object"}function gvo(t){return Cvt(t)&&t!==null}function eE(t){return t!=null}function lne(t){return!t.trim().length}function fvt(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const uvo="Incorrect 'index' type",XMe="Invalid doc index: must be a non-negative integer within the bounds of the docs array",hvo=t=>`Invalid value for key ${t}`,dvo=t=>`Pattern length exceeds max of ${t}.`,_vo=t=>`Missing ${t} property in key`,mvo=t=>`Property 'weight' in key '${t}' must be a positive integer`,pvo="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.",yvt=Object.prototype.hasOwnProperty;var Ivo=class{constructor(t){this._keys=[],this._keyMap={};let e=0;t.forEach(n=>{const o=Evt(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 Evt(t){let e=null,n=null,o=null,i=1,r=null;if(ZI(t)||VD(t))o=t,e=Bvt(t),n=gne(t);else{if(!yvt.call(t,"name"))throw new Error(_vo("name"));const A=t.name;if(o=A,yvt.call(t,"weight")&&t.weight!==void 0&&(i=t.weight,i<=0))throw new Error(mvo(gne(A)));e=Bvt(A),n=gne(A),r=t.getFn??null}return{path:e,id:n,weight:i,src:o,getFn:r}}function Bvt(t){return VD(t)?t:t.split(".")}function gne(t){return VD(t)?t.join("."):t}function Cvo(t,e){const n=[];let o=!1;const i=(r,A,s,a)=>{if(eE(r))if(!A[s])n.push(a!==void 0?{v:r,i:a}:r);else{const c=r[A[s]];if(!eE(c))return;if(s===A.length-1&&(ZI(c)||cne(c)||lvo(c)||typeof c=="bigint"))n.push(a!==void 0?{v:jMe(c),i:a}:jMe(c));else if(VD(c)){o=!0;for(let l=0,g=c.length;l<g;l+=1)i(c[l],A,s+1,l)}else A.length&&i(c,A,s+1,a)}};return i(t,ZI(e)?e.split("."):e,0),o?n:n[0]}const bA=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:Cvo,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1}});function fvo(t){return t>=9&&t<=13||t===32||t===160}function yvo(t=1,e=3){const n=new Map,o=Math.pow(10,e);return{get(i){let r=0,A=!1;for(let a=0;a<i.length;a++)fvo(i.charCodeAt(a))?A=!1:A||(r++,A=!0);if(r===0&&(r=1),n.has(r))return n.get(r);const s=Math.round(o/Math.pow(r,.5*t))/o;return n.set(r,s),s},clear(){n.clear()}}}var $Me=class{constructor({getFn:t=bA.getFn,fieldNormWeight:e=bA.fieldNormWeight}={}){this.norm=yvo(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(ZI(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(XMe);if(ZI(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(XMe);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 A=i+r>>>1;n[A]<o.i?i=A+1:r=A}o.i-=i}}getValueForItemAtKeyId(t,e){return t[this._keysMap[e]]}size(){return this.records.length}_createStringRecord(t,e){return!eE(t)||lne(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],A=r.getFn?r.getFn(t):this.getFn(t,r.path);if(eE(A)){if(VD(A)){const s=[];for(let a=0,c=A.length;a<c;a+=1){const l=A[a];if(eE(l)){if(ZI(l)){if(!lne(l)){const g={v:l,i:a,n:this.norm.get(l)};s.push(g)}}else if(eE(l.v)){const g=ZI(l.v)?l.v:jMe(l.v);if(!lne(g)){const u={v:g,i:l.i,n:this.norm.get(g)};s.push(u)}}}}n.$[o]=s}else if(ZI(A)&&!lne(A)){const s={v:A,n:this.norm.get(A)};n.$[o]=s}}}return n}toJSON(){return{keys:this.keys.map(({getFn:t,...e})=>e),records:this.records}}};function xvt(t,e,{getFn:n=bA.getFn,fieldNormWeight:o=bA.fieldNormWeight}={}){const i=new $Me({getFn:n,fieldNormWeight:o});return i.setKeys(t.map(Evt)),i.setSources(e),i.create(),i}function Evo(t,{getFn:e=bA.getFn,fieldNormWeight:n=bA.fieldNormWeight}={}){const{keys:o,records:i}=t,r=new $Me({getFn:e,fieldNormWeight:n});return r.setKeys(o),r.setIndexRecords(i),r}function Bvo(t=[],e=bA.minMatchCharLength){const n=[];let o=-1,i=-1,r=0;for(let A=t.length;r<A;r+=1){const s=t[r];s&&o===-1?o=r:!s&&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 xvo(t,e,n,{location:o=bA.location,distance:i=bA.distance,threshold:r=bA.threshold,findAllMatches:A=bA.findAllMatches,minMatchCharLength:s=bA.minMatchCharLength,includeMatches:a=bA.includeMatches,ignoreLocation:c=bA.ignoreLocation}={}){if(e.length>32)throw new Error(dvo(32));const l=e.length,g=t.length,u=Math.max(0,Math.min(o,g));let d=r,h=u;const _=(M,w)=>{const k=M/l;if(c)return k;const N=Math.abs(u-w);return i?k+N/i:N?1:k},p=s>1||a,m=p?Array(g):[];let I;for(;(I=t.indexOf(e,h))>-1;){const M=_(0,I);if(d=Math.min(M,d),h=I+l,p){let w=0;for(;w<l;)m[I+w]=1,w+=1}}h=-1;let C=[],f=1,y=0,B=l+g;const x=1<<l-1;for(let M=0;M<l;M+=1){let w=0,k=B;for(;w<k;)_(M,u+k)<=d?w=k:B=k,k=Math.floor((B-w)/2+w);B=k;let N=Math.max(1,u-k+1);const H=A?g:Math.min(u+k,g)+l,G=Array(H+2);G[H+1]=(1<<M)-1;for(let U=H;U>=N;U-=1){const J=U-1,W=n[t[J]];if(G[U]=(G[U+1]<<1|1)&W,M&&(G[U]|=(C[U+1]|C[U])<<1|1|C[U+1]),G[U]&x&&(f=_(M,J),f<=d)){if(d=f,h=J,y=M,h<=u)break;N=Math.max(1,2*u-h)}}if(_(M+1,u)>d)break;C=G}if(p&&h>=0){const M=Math.min(g-1,h+l-1+y);for(let w=h;w<=M;w+=1)n[t[w]]&&(m[w]=1)}const S={isMatch:h>=0,score:Math.max(.001,f)};if(p){const M=Bvo(m,s);M.length?a&&(S.indices=M):S.isMatch=!1}return S}function Qvo(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 ZMe(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 Qvt={ł:"l",Ł:"L",đ:"d",Đ:"D",ø:"o",Ø:"O",ħ:"h",Ħ:"H",ŧ:"t",Ŧ:"T",ı:"i",ß:"ss"},Svo=new RegExp("["+Object.keys(Qvt).join("")+"]","g"),dO=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(Svo,e=>Qvt[e]):t=>t;var ewe=class{constructor(t,{location:e=bA.location,threshold:n=bA.threshold,distance:o=bA.distance,includeMatches:i=bA.includeMatches,findAllMatches:r=bA.findAllMatches,minMatchCharLength:A=bA.minMatchCharLength,isCaseSensitive:s=bA.isCaseSensitive,ignoreDiacritics:a=bA.ignoreDiacritics,ignoreLocation:c=bA.ignoreLocation}={}){if(this.options={location:e,threshold:n,distance:o,includeMatches:i,findAllMatches:r,minMatchCharLength:A,isCaseSensitive:s,ignoreDiacritics:a,ignoreLocation:c},t=s?t:t.toLowerCase(),t=a?dO(t):t,this.pattern=t,this.chunks=[],!this.pattern.length)return;const l=(u,d)=>{this.chunks.push({pattern:u,alphabet:Qvo(u),startIndex:d})},g=this.pattern.length;if(g>32){let u=0;const d=g%32,h=g-d;for(;u<h;)l(this.pattern.substr(u,32),u),u+=32;if(d){const _=g-32;l(this.pattern.substr(_),_)}}else l(this.pattern,0)}searchIn(t){const{isCaseSensitive:e,ignoreDiacritics:n,includeMatches:o}=this.options;if(t=e?t:t.toLowerCase(),t=n?dO(t):t,this.pattern===t){if(t.length<this.options.minMatchCharLength)return{isMatch:!1,score:1};const h={isMatch:!0,score:0};return o&&(h.indices=[[0,t.length-1]]),h}const{location:i,distance:r,threshold:A,findAllMatches:s,minMatchCharLength:a,ignoreLocation:c}=this.options,l=[];let g=0,u=!1;this.chunks.forEach(({pattern:h,alphabet:_,startIndex:p})=>{const{isMatch:m,score:I,indices:C}=xvo(t,h,_,{location:i+p,distance:r,threshold:A,findAllMatches:s,minMatchCharLength:a,includeMatches:o,ignoreLocation:c});m&&(u=!0),g+=I,m&&C&&l.push(...C)});const d={isMatch:u,score:u?g/this.chunks.length:1};return u&&o&&(d.indices=ZMe(l)),d}};const bvo=new Set(["fuzzy","include"]);function Dvo(t){return t.startsWith("inverse")}const twe=[{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 A=!!i.length;return{isMatch:A,score:A?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 ewe(t,{location:e.location??bA.location,threshold:e.threshold??bA.threshold,distance:e.distance??bA.distance,includeMatches:e.includeMatches??bA.includeMatches,findAllMatches:e.findAllMatches??bA.findAllMatches,minMatchCharLength:e.minMatchCharLength??bA.minMatchCharLength,isCaseSensitive:e.isCaseSensitive??bA.isCaseSensitive,ignoreDiacritics:e.ignoreDiacritics??bA.ignoreDiacritics,ignoreLocation:e.ignoreLocation??bA.ignoreLocation});return{type:"fuzzy",search(o){return n.searchIn(o)}}}}],Svt=twe.length,Mvo="\0",wvo="|";function Pvo(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 bvt(t,e){const n=t.match(e);return n?n[1]:null}function vvo(t,e={}){return t.replace(/\\\|/g,Mvo).split(wvo).map(n=>{const o=Pvo(n.replace(/\u0000/g,"|").trim()).filter(r=>r&&!!r.trim()),i=[];for(let r=0,A=o.length;r<A;r+=1){const s=o[r];let a=!1,c=-1;for(;!a&&++c<Svt;){const l=twe[c],g=bvt(s,l.multiRegex);g&&(i.push(l.create(g,e)),a=!0)}if(!a)for(c=-1;++c<Svt;){const l=twe[c],g=bvt(s,l.singleRegex);if(g){i.push(l.create(g,e));break}}}return i})}var Nvo=class{constructor(t,{isCaseSensitive:e=bA.isCaseSensitive,ignoreDiacritics:n=bA.ignoreDiacritics,includeMatches:o=bA.includeMatches,minMatchCharLength:i=bA.minMatchCharLength,ignoreLocation:r=bA.ignoreLocation,findAllMatches:A=bA.findAllMatches,location:s=bA.location,threshold:a=bA.threshold,distance:c=bA.distance}={}){this.query=null,this.options={isCaseSensitive:e,ignoreDiacritics:n,includeMatches:o,minMatchCharLength:i,findAllMatches:A,ignoreLocation:r,location:s,threshold:a,distance:c},t=e?t:t.toLowerCase(),t=n?dO(t):t,this.pattern=t,this.query=vvo(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?dO(t):t;let r=0;const A=[];let s=0,a=!1;for(let c=0,l=e.length;c<l;c+=1){const g=e[c];A.length=0,r=0,a=!1;for(let u=0,d=g.length;u<d;u+=1){const h=g[u],{isMatch:_,indices:p,score:m}=h.search(t);if(_)r+=1,s+=m,Dvo(h.type)&&(a=!0),n&&(bvo.has(h.type)?A.push(...p):A.push(p));else{s=0,r=0,A.length=0,a=!1;break}}if(r){const u={isMatch:!0,score:s/r};return a&&(u.hasInverse=!0),n&&(u.indices=ZMe(A)),u}}return{isMatch:!1,score:1}}};const nwe=[];function owe(...t){nwe.push(...t)}function une(t,e){for(let n=0,o=nwe.length;n<o;n+=1){const i=nwe[n];if(i.condition(t,e))return new i(t,e)}return new ewe(t,e)}const hne={AND:"$and",OR:"$or"},iwe={PATH:"$path",PATTERN:"$val"},rwe=t=>!!(t[hne.AND]||t[hne.OR]),Rvo=t=>!!t[iwe.PATH],Tvo=t=>!VD(t)&&Cvt(t)&&!rwe(t),Dvt=t=>({[hne.AND]:Object.keys(t).map(e=>({[e]:t[e]}))});function Mvt(t,e,{auto:n=!0}={}){const o=i=>{if(ZI(i)){const a={keyId:null,pattern:i};return n&&(a.searcher=une(i,e)),a}const r=Object.keys(i),A=Rvo(i);if(!A&&r.length>1&&!rwe(i))return o(Dvt(i));if(Tvo(i)){const a=A?i[iwe.PATH]:r[0],c=A?i[iwe.PATTERN]:i[a];if(!ZI(c))throw new Error(hvo(a));const l={keyId:gne(a),pattern:c};return n&&(l.searcher=une(c,e)),l}const s={children:[],operator:r[0]};return r.forEach(a=>{const c=i[a];VD(c)&&c.forEach(l=>{s.children.push(o(l))})}),s};return rwe(t)||(t=Dvt(t)),o(t)}function Awe(t,{ignoreFieldNorm:e=bA.ignoreFieldNorm}){let n=1;return t.forEach(({key:o,norm:i,score:r})=>{const A=o?o.weight:null;n*=Math.pow(r===0&&A?Number.EPSILON:r,(A||1)*(e?1:i))}),n}function kvo(t,{ignoreFieldNorm:e=bA.ignoreFieldNorm}){t.forEach(n=>{n.score=Awe(n.matches,{ignoreFieldNorm:e})})}var Fvo=class{constructor(t,e){this.limit=t,this.heap=[],this.comparator=e}get size(){return this.heap.length}insert(t){this.size<this.limit?(this.heap.push(t),this._bubbleUp(this.size-1)):this.comparator(t,this.heap[0])<0&&(this.heap[0]=t,this._sinkDown(0))}extractSorted(){return this.heap.sort(this.comparator)}_bubbleUp(t){const e=this.heap;for(;t>0;){const n=t-1>>1;if(this.comparator(e[t],e[n])<=0)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&&this.comparator(e[i],e[o])>0&&(o=i),r<n&&this.comparator(e[r],e[o])>0&&(o=r),o!==t){const A=e[t];e[t]=e[o],e[o]=A}}while(o!==t)}};function Lvo(t){const e=[];return t.matches.forEach(n=>{if(!eE(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 Hvo(t,e,{includeMatches:n=bA.includeMatches,includeScore:o=bA.includeScore}={}){return t.map(i=>{const{idx:r}=i,A={item:e[r],refIndex:r};return n&&(A.matches=Lvo(i)),o&&(A.score=i.score),A})}const Gvo=/[\p{L}\p{M}\p{N}_]+/gu,wvt=new WeakSet;function Ovo(t){wvt.has(t)||(wvt.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 Kvo(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||Ovo(t),e=>e.match(t)||[]):e=>e.match(Gvo)||[]}function swe({isCaseSensitive:t=!1,ignoreDiacritics:e=!1,tokenize:n}={}){const o=Kvo(n);return{tokenize(i){return t||(i=i.toLowerCase()),e&&(i=dO(i)),o(i)}}}var Uvo=class{static condition(t,e){return e.useTokenSearch}constructor(t,e){this.options=e,this.analyzer=swe({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 ewe(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 A=o.get(r)||0,s=Math.log(1+(i-A+.5)/(A+.5));this.idfWeights.push(s)}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 A=this.combineAll&&!this.useMask?new Set:null;for(let c=0;c<this.termSearchers.length;c++){const l=this.termSearchers[c].searchIn(t),g=this.idfWeights[c];o+=g,l.isMatch&&(i++,n+=g*(1-l.score),l.indices&&e.push(...l.indices),this.combineAll&&(this.useMask?r|=1<<c:A.add(c)))}if(i===0)return{isMatch:!1,score:1};const s=o>0?1-n/o:0,a={isMatch:!0,score:Math.max(.001,s)};return this.options.includeMatches&&e.length&&(a.indices=ZMe(e)),this.combineAll&&(this.useMask?a.matchedMask=r:a.matchedTerms=A,a.termCount=this.numTerms),a}};function awe(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 A=t.docTermFieldHits.get(n);A||(A=new Map,t.docTermFieldHits.set(n,A));for(const s of r)A.set(s,(A.get(s)||0)+1),t.df.set(s,(t.df.get(s)||0)+1)}function Pvt(t,e,n,o){const{i,v:r,$:A}=e;if(r!==void 0){awe(t,r,i,o);return}if(A)for(let s=0;s<n;s++){const a=A[s];if(a)if(Array.isArray(a))for(const c of a)awe(t,c.v,i,o);else awe(t,a.v,i,o)}}function Yvo(t,e,n){const o={fieldCount:0,df:new Map,docFieldCount:new Map,docTermFieldHits:new Map};for(const i of t)Pvt(o,i,e,n);return o}function Vvo(t,e,n,o){Pvt(t,e,n,o)}function zvo(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 A=(t.df.get(i)||0)-r;A<=0?t.df.delete(i):t.df.set(i,A)}t.docTermFieldHits.delete(e)}}function vvt(t,e){if(e.length===0)return;const n=Array.from(new Set(e)).sort((s,a)=>s-a);for(const s of n)zvo(t,s);const o=s=>{let a=0,c=n.length;for(;a<c;){const l=a+c>>>1;n[l]<s?a=l+1:c=l}return s-a},i=n[0],r=new Map;for(const[s,a]of t.docFieldCount)r.set(s>i?o(s):s,a);t.docFieldCount=r;const A=new Map;for(const[s,a]of t.docTermFieldHits)A.set(s>i?o(s):s,a);t.docTermFieldHits=A}var zD=class{constructor(t,e,n){this.options={...bA,...e},this.options.useExtendedSearch,this.options.useTokenSearch,this._keyStore=new Ivo(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=une(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 $Me))throw new Error(uvo);if(this._myIndex=e||xvt(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight}),this.options.useTokenSearch){const n=swe({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});this._invertedIndex=Yvo(this._myIndex.records,this._myIndex.keys.length,n)}this._invalidateSearcherCache()}add(t){if(!eE(t))return;this._docs.push(t);const e=this._myIndex.add(t,this._docs.length-1);if(this._invertedIndex&&e){const n=swe({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});Vvo(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&&vvt(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(XMe);this._invertedIndex&&vvt(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}_normalizedKeys(){return this._myIndex.keys.map(t=>this._keyStore.get(t.id)||t)}search(t,e){const{limit:n=-1}=e||{},{includeMatches:o,includeScore:i,shouldSort:r,sortFn:A,ignoreFieldNorm:s}=this.options;if(ZI(t)&&!t.trim()){let u=this._docs.map((d,h)=>({item:d,refIndex:h}));return cne(n)&&n>-1&&(u=u.slice(0,n)),u}const a=r&&cne(n)&&n>0&&ZI(t),c=A,l=(u,d)=>c(u,d)||u.idx-d.idx;let g;if(a){const u=new Fvo(n,l);ZI(this._docs[0])?this._searchStringList(t,{heap:u,ignoreFieldNorm:s}):this._searchObjectList(t,{heap:u,ignoreFieldNorm:s}),g=u.extractSorted()}else g=ZI(t)?ZI(this._docs[0])?this._searchStringList(t):this._searchObjectList(t):this._searchLogical(t),kvo(g,{ignoreFieldNorm:s}),r&&g.sort(ZI(t)?l:c),cne(n)&&n>-1&&(g=g.slice(0,n));return Hvo(g,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,A=e?null:[];return r.forEach(({v:s,i:a,n:c})=>{if(!eE(s))return;const l=o.searchIn(s);if(l.isMatch){const g={score:l.score,value:s,norm:c,indices:l.indices};i&&(g.matchedMask=l.matchedMask,g.matchedTerms=l.matchedTerms,g.termCount=l.termCount);const u=[g];if(!i||this._coversAllTokens(u)){const d={item:s,idx:a,matches:u};e?(d.score=Awe(d.matches,{ignoreFieldNorm:n}),e.insert(d)):A.push(d)}}}),A}_searchLogical(t){const e=Mvt(t,this.options),n=this._normalizedKeys(),o=(s,a,c)=>{if(!("children"in s)){const{keyId:d,searcher:h}=s;let _;return d===null?(_=[],n.forEach((p,m)=>{_.push(...this._findMatches({key:p,value:a[m],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:g}=s,u=[];for(let d=0,h=l.length;d<h;d+=1){const _=l[d],p=o(_,a,c);if(p.length)u.push(...p);else if(g===hne.AND)return[]}return u},i=this._myIndex.records,r=new Map,A=[];return i.forEach(({$:s,i:a})=>{if(eE(s)){const c=o(e,s,a);c.length&&(r.has(a)||(r.set(a,{idx:a,item:s,matches:[]}),A.push(r.get(a))),c.forEach(({matches:l})=>{r.get(a).matches.push(...l)}))}}),A}_searchObjectList(t,{heap:e,ignoreFieldNorm:n}={}){const o=this._getSearcher(t),i=this.options.useTokenSearch&&this.options.tokenMatch==="all",{records:r}=this._myIndex,A=this._normalizedKeys(),s=e?null:[];return r.forEach(({$:a,i:c})=>{if(!eE(a))return;const l=[];let g=!1,u=!1;if(A.forEach((d,h)=>{const _=this._findMatches({key:d,value:a[h],searcher:o});_.length?(l.push(..._),_[0].hasInverse&&(u=!0)):g=!0}),!(u&&g)&&l.length&&(!i||this._coversAllTokens(l))){const d={idx:c,item:a,matches:l};e?(d.score=Awe(d.matches,{ignoreFieldNorm:n}),e.insert(d)):s.push(d)}}),s}_findMatches({key:t,value:e,searcher:n}){if(!eE(e))return[];const o=[];if(VD(e))e.forEach(({v:i,i:r,n:A})=>{if(!eE(i))return;const s=n.searchIn(i);if(s.isMatch){const a={score:s.score,key:t,value:i,idx:r,norm:A,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)}});else{const{v:i,n:r}=e,A=n.searchIn(i);if(A.isMatch){const s={score:A.score,key:t,value:i,norm:r,indices:A.indices,hasInverse:A.hasInverse};A.termCount!==void 0&&(s.matchedMask=A.matchedMask,s.matchedTerms=A.matchedTerms,s.termCount=A.termCount),o.push(s)}}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}};zD.version="7.5.0",zD.createIndex=xvt,zD.parseIndex=Evo,zD.config=bA,zD.match=function(t,e,n){if(n&&n.useTokenSearch)throw new Error(pvo);return une(t,{...bA,...n}).searchIn(e)},zD.parseQuery=Mvt,owe(Nvo),owe(Uvo),zD.use=function(...t){t.forEach(e=>owe(e))};var Jvo=zD;const qvo="https://kicad-mod-cache.tscircuit.com";let cwe=null,_O=null,lwe=null;const Wvo=async()=>cwe||_O||(_O=fetch("https://kicad-mod-cache.tscircuit.com/kicad_files.json").then(t=>t.json()).then(t=>(cwe=t,_O=null,t)),_O),jvo=async(t,e=20)=>{const n=await Wvo();return lwe||(lwe=new Jvo(n)),lwe.search(t).slice(0,e).map(o=>o.item)},Xvo=t=>{const e=t.replace(".pretty/","/").replace(".kicad_mod",""),n=`kicad:${e}`;return{path:t,qualifiedName:n,description:e}},$vo=t=>t.replace(/^\/+/,"").split("/").map(e=>encodeURIComponent(e)).join("/"),Zvo=async t=>{const e=await fetch(`${qvo}/${$vo(t)}`);if(!e.ok)throw new Error(`KiCad footprint fetch failed: ${e.status}`);const n=await e.text(),{KicadFootprintToCircuitJsonConverter:o}=await FB("kicad-to-circuit-json"),i=new o;return i.addFile(t.split("/").pop()??"selected-footprint.kicad_mod",n),i.runUntilFinished(),i.getOutput()},Nvt=t=>t?.source==="jlcpcb"||t?.source==="kicad",e6o=async(t,e)=>{if(t.source==="jlcpcb")return avo(t.component.partNumber,e?.jlcpcb);if(t.source==="kicad")return Zvo(t.footprint.path);throw new Error("Footprint preview is not available for this source")},t6o=({query:t,placeholder:e,isSearching:n,onQueryChange:o,onSubmit:i})=>{const r=j.useCallback(A=>{A.key==="Enter"&&(A.preventDefault(),i())},[i]);return V.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2 rf-mt-4",children:[V.jsxs("div",{className:"rf-relative rf-flex-grow",children:[V.jsx(X4e,{className:"rf-absolute rf-left-2 rf-top-2.5 rf-h-4 rf-w-4 rf-text-muted-foreground"}),V.jsx(_De,{placeholder:e,className:"rf-pl-8",spellCheck:!1,autoComplete:"off",value:t,onChange:A=>o(A.target.value),onKeyDown:r})]}),V.jsx(Vs,{onClick:i,disabled:n||t.trim().length<1,className:"sm:rf-px-4 rf-px-3",children:n?V.jsx(RB,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):V.jsxs(V.Fragment,{children:[V.jsx(X4e,{className:"rf-h-4 rf-w-4 sm:rf-hidden"}),V.jsx("span",{className:"rf-hidden sm:rf-inline",children:"Search"})]})})]})},n6o=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}),o6o=t=>n6o.format(t),Rvt=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"}},i6o=t=>{switch(t.source){case"tscircuit.com":return t.package.unscoped_name;case"jlcpcb":return t.component.isDirectLookup?t.component.partNumber:t.component.manufacturer;case"kicad":return t.footprint.qualifiedName}},r6o=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}},A6o=t=>{switch(t.source){case"tscircuit.com":return t.package.name;case"jlcpcb":return t.component.isDirectLookup?void 0:t.component.partNumber;case"kicad":return}},s6o=({results:t,selected:e,onSelect:n,onShowDetails:o})=>{const i=e?Rvt(e):null;return V.jsx("div",{className:"rf-divide-y rf-w-full rf-overflow-hidden",children:t.map(r=>{const A=Rvt(r),s=i===A,a=i6o(r),c=r6o(r),l=A6o(r),g=r.source==="jlcpcb"?r.component.stock:null,u=r.source==="jlcpcb"?r.component.price:null,d=r.source==="jlcpcb"?r.component.isBasic:null,h=r.source==="jlcpcb"?r.component.isDirectLookup:!1;return V.jsxs("div",{className:`rf-p-3 rf-flex rf-flex-col sm:rf-grid sm:rf-grid-cols-[minmax(0,1fr)_auto] rf-items-start sm:rf-items-center rf-cursor-pointer hover:rf-bg-zinc-100 rf-gap-2 rf-overflow-hidden ${s?"rf-bg-zinc-100":""}`,onClick:()=>n(r),children:[V.jsxs("div",{className:"rf-min-w-0 rf-overflow-hidden rf-w-full",children:[V.jsxs("div",{className:"rf-flex rf-items-start rf-gap-2 rf-min-w-0",children:[V.jsxs("div",{className:"rf-font-medium rf-text-sm rf-truncate rf-flex-1 rf-min-w-0 rf-flex rf-items-center rf-gap-1.5",children:[a,r.source==="jlcpcb"&&d!=null&&V.jsx("span",{className:`rf-text-xs rf-px-1.5 rf-py-0.5 rf-rounded rf-font-medium rf-flex-shrink-0 ${d?"rf-bg-green-100 rf-text-green-700":"rf-bg-orange-100 rf-text-orange-700"}`,children:d?"Basic":"Extended"}),h&&V.jsx("span",{className:"rf-text-xs rf-px-1.5 rf-py-0.5 rf-rounded rf-font-medium rf-flex-shrink-0 rf-bg-blue-100 rf-text-blue-700",children:"Direct lookup"}),r.source==="tscircuit.com"&&r.package.is_private&&V.jsx(jIo,{className:"rf-ml-1 rf-h-3 rf-w-3 rf-text-zinc-400 rf-flex-shrink-0"})]}),r.source==="jlcpcb"&&g!=null?V.jsxs("div",{className:"rf-text-xs rf-text-zinc-500 rf-font-medium rf-whitespace-nowrap rf-flex-shrink-0 sm:rf-hidden",children:[g.toLocaleString()," in stock"]}):null]}),V.jsxs("div",{className:"rf-text-xs rf-text-zinc-500 rf-truncate rf-w-full",children:[l?V.jsx("span",{className:"rf-mr-2",children:l}):null,c]})]}),V.jsxs("div",{children:[r.source==="tscircuit.com"&&o?V.jsx("div",{className:"rf-flex-shrink-0 rf-w-full sm:rf-w-auto",children:V.jsx(Vs,{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"&&g!=null?V.jsxs("div",{className:"rf-hidden sm:rf-block rf-text-xs rf-text-zinc-500 rf-font-medium rf-whitespace-nowrap rf-flex-shrink-0",children:[g.toLocaleString()," in stock"]}):null,u!=null&&V.jsx("div",{className:"rf-hidden sm:rf-block rf-text-xs rf-text-zinc-500 rf-font-medium rf-whitespace-nowrap rf-flex-shrink-0 rf-text-right",children:o6o(u)})]})]},A)})})},a6o=({circuitJson:t,error:e,isLoading:n,height:o})=>V.jsx("section",{className:"rf-flex rf-min-w-0 rf-items-center rf-justify-center",style:{height:o},children:n?V.jsxs("div",{className:"rf-flex rf-w-full rf-items-center rf-justify-center rf-gap-2 rf-bg-zinc-950 rf-text-sm rf-text-zinc-300",style:{height:o},children:[V.jsx(RB,{className:"rf-h-4 rf-w-4 rf-animate-spin"}),"Loading preview..."]}):e?V.jsx("div",{className:"rf-flex rf-w-full rf-items-center rf-justify-center rf-bg-zinc-950 rf-p-4",style:{height:o},children:V.jsxs("div",{className:"rf-flex rf-max-w-[320px] rf-items-start rf-gap-2 rf-text-sm rf-text-zinc-300",children:[V.jsx(SQt,{className:"rf-mt-0.5 rf-h-4 rf-w-4 rf-flex-shrink-0"}),V.jsx("span",{children:e})]})}):t?V.jsx("div",{className:"rf-w-full rf-min-w-0 rf-overflow-hidden",children:V.jsx(B3t,{circuitJson:t,height:o,allowEditing:!1,clickToInteractEnabled:!1,focusOnHover:!1,disablePcbGroups:!0})}):V.jsx("div",{className:"rf-flex rf-w-full rf-items-center rf-justify-center rf-bg-zinc-950 rf-text-sm rf-text-zinc-300",style:{height:o},children:"No preview"})}),Tvt={importComponentDialog:101,importComponentDetailsDialog:102},c6o=({packageResult:t,isOpen:e,onOpenChange:n,isLoading:o,details:i,previewTab:r,onPreviewTabChange:A,isSubmitting:s,onImport:a})=>{const c=t?.package??null,l=c?.latest_pcb_preview_image_url,g=c?.latest_sch_preview_image_url,u=c?.latest_cad_preview_image_url,d=c?.unscoped_name?.split("/").pop()??c?.unscoped_name,h=c?.org_owner_tscircuit_handle??void 0,_=h?`https://tscircuit.com/${h}`:void 0,p=h&&d?`https://tscircuit.com/${h}/${d}`:void 0;return V.jsx(PN,{open:e,onOpenChange:n,children:V.jsxs(f3,{showOverlay:!1,style:{width:"calc(100vw - 2rem)",zIndex:Tvt.importComponentDetailsDialog},className:"rf-max-w-5xl no-scrollbar !rf-overflow-y-auto rf-max-h-[90vh] rf-overflow-hidden rf-flex rf-flex-col rf-rounded-sm",children:[V.jsx(y3,{className:"rf-pb-4 rf-border-b",children:V.jsx("div",{className:"rf-flex rf-items-start rf-justify-between rf-gap-4",children:V.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[V.jsx(E3,{className:"rf-text-xl rf-font-semibold rf-truncate",children:d}),V.jsx(vN,{children:c?.description})]})})}),V.jsxs("div",{className:"rf-flex-1 rf-overflow-y-auto rf-py-4 rf-space-y-6",children:[h?V.jsxs("div",{children:[V.jsx("span",{className:"rf-text-xs rf-font-medium rf-text-gray-500 rf-uppercase rf-tracking-wide",children:"Created by"}),V.jsx("div",{className:"rf-mt-1 rf-text-sm rf-font-medium",children:_?V.jsx("a",{href:_,target:"_blank",rel:"noopener noreferrer",className:"rf-text-black hover:rf-underline",children:h}):h})]}):null,(u||l||g)&&V.jsx(V.Fragment,{children:V.jsxs("div",{children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Preview"}),V.jsxs(TIe,{value:r,onValueChange:m=>A(m),children:[V.jsxs(xX,{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:[l&&V.jsx(Zx,{value:"pcb",children:"PCB"}),g&&V.jsx(Zx,{value:"schematic",children:"Schematic"}),u&&V.jsx(Zx,{value:"3d",children:"3D"})]}),V.jsxs("div",{className:"rf-mt-4",children:[V.jsx(OI,{value:"pcb",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:l?V.jsx("img",{src:l,alt:`${d??"package"} PCB preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null}),V.jsx(OI,{value:"schematic",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:g?V.jsx("img",{src:g,alt:`${d??"package"} schematic preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null}),V.jsx(OI,{value:"3d",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:u?V.jsx("img",{src:u,alt:`${d??"package"} 3D preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null})]})]})]})}),i?.ai_description?V.jsxs("section",{children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-3",children:"AI Description"}),V.jsx("div",{className:"rf-bg-gray-50 rf-border rf-border-gray-200 rf-rounded-lg rf-p-4",children:V.jsx("p",{className:"rf-text-sm rf-text-gray-700 rf-leading-relaxed",children:i.ai_description})})]}):null,i?.ai_usage_instructions?V.jsxs("section",{children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-3",children:"Usage Instructions"}),V.jsx("div",{className:"rf-bg-gray-50 rf-border rf-border-gray-200 rf-rounded-lg rf-p-4",children:V.jsx("p",{className:"rf-text-sm rf-text-gray-700 rf-leading-relaxed rf-whitespace-pre-wrap",children:i.ai_usage_instructions})})]}):null,o?V.jsxs("div",{className:"rf-flex rf-justify-center rf-items-center rf-gap-2 rf-text-gray-500",children:[V.jsx(RB,{className:"rf-h-4 rf-w-4 rf-animate-spin"}),V.jsx("span",{className:"rf-text-sm",children:"Loading package details..."})]}):null]}),V.jsxs(hO,{className:"rf-pt-4 rf-border-t rf-flex rf-flex-col sm:rf-flex-row rf-justify-between rf-gap-2",children:[V.jsx("div",{className:"rf-flex-1",children:p?V.jsxs(Vs,{variant:"outline",size:"sm",className:"rf-gap-2 rf-w-full sm:rf-w-auto",onClick:()=>window.open(p,"_blank"),children:[V.jsx(UIo,{className:"rf-h-4 rf-w-4"}),"View on tscircuit.com"]}):null}),V.jsxs("div",{className:"rf-flex rf-flex-col sm:rf-flex-row rf-gap-2",children:[V.jsx(Vs,{variant:"outline",onClick:()=>n(!1),className:"rf-order-2 sm:rf-order-1",children:"Close"}),V.jsx(Vs,{onClick:a,disabled:s,className:"rf-bg-blue-600 hover:rf-bg-blue-700",children:s?V.jsx(RB,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):"Import Component"})]})]})]})})},l6o=()=>{const[t,e]=j.useState(null),[n,o]=j.useState(!1),i=j.useCallback(async(A,s)=>{o(!0);try{const a=await fetch(`https://api.tscircuit.com/packages/get?name=${encodeURIComponent(`${A}/${s}`)}`);if(!a.ok)throw new Error(`Failed to load package details: ${a.status}`);const c=await a.json();e(c.package??null)}catch(a){console.error("Failed to fetch package details",a),e(null)}finally{o(!1)}},[]),r=j.useCallback(()=>{e(null),o(!1)},[]);return{details:t,isLoading:n,fetchDetails:i,reset:r}},g6o=(t,e)=>{const[n,o]=j.useState({circuitJson:null,error:null,isLoading:!1});return j.useEffect(()=>{if(!t||!Nvt(t)){o({circuitJson:null,error:null,isLoading:!1});return}let i=!1;return o({circuitJson:null,error:null,isLoading:!0}),e6o(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},u6o=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??[]},h6o=({sessionToken:t})=>{const[e,n]=j.useState([]),[o,i]=j.useState(!1),[r,A]=j.useState(null),[s,a]=j.useState(!1),c=j.useCallback(async g=>{const u=g.trim();if(!u)return[];i(!0),A(null);try{const h=(await u6o(u,t)).map(_=>({source:"tscircuit.com",package:_}));return n(h),h}catch(d){return console.error("Error searching tscircuit packages",d),n([]),A(d instanceof Error?d.message:"Failed to search tscircuit packages"),[]}finally{i(!1),a(!0)}},[t]),l=j.useCallback(()=>{n([]),i(!1),A(null),a(!1)},[]);return{results:e,isSearching:o,error:r,hasSearched:s,search:c,reset:l}},d6o=t=>{const e=/^C(\d+)$/i.exec(t.trim());if(!e)return null;const n=Number(e[1]);if(!Number.isSafeInteger(n))return null;const o=`C${e[1]}`;return{source:"jlcpcb",component:{lcscId:n,manufacturer:o,partNumber:o,description:"Import directly from EasyEDA; stock and availability are unknown",package:"",isDirectLookup:!0}}},kvt=(t,e)=>{const n=d6o(t);return n?e.some(i=>i.component.partNumber.toUpperCase()===n.component.partNumber)?e:[n,...e]:e},_6o=t=>{const e=t.trim();return/^C\d+/i.test(e)?e.replace(/^C/i,""):e},m6o=()=>{const[t,e]=j.useState([]),[n,o]=j.useState(!1),[i,r]=j.useState(null),[A,s]=j.useState(!1),a=j.useCallback(async l=>{const g=_6o(l);if(!g)return[];o(!0),r(null);try{const u=await rvo(g,10),d=kvt(l,u.map(h=>({source:"jlcpcb",component:Avo(h)})));return e(d),d}catch(u){console.error("Error searching JLCPCB components",u);const d=kvt(l,[]);return e(d),r(d.length>0?null:u instanceof Error?u.message:"Failed to search JLCPCB components"),d}finally{o(!1),s(!0)}},[]),c=j.useCallback(()=>{e([]),o(!1),r(null),s(!1)},[]);return{results:t,isSearching:n,error:i,hasSearched:A,search:a,reset:c}},p6o=()=>{const[t,e]=j.useState([]),[n,o]=j.useState(!1),[i,r]=j.useState(null),[A,s]=j.useState(!1),a=j.useCallback(async l=>{const g=l.trim();if(!g)return[];o(!0),r(null);try{const d=(await jvo(g,20)).map(h=>({source:"kicad",footprint:Xvo(h)}));return e(d),d}catch(u){return console.error("Error searching KiCad footprints",u),e([]),r(u instanceof Error?u.message:"Failed to search KiCad footprints"),[]}finally{o(!1),s(!0)}},[]),c=j.useCallback(()=>{e([]),o(!1),r(null),s(!1)},[]);return{results:t,isSearching:n,error:i,hasSearched:A,search:a,reset:c}},I6o=({onTscircuitPackageSelected:t,onJlcpcbComponentTsxLoaded:e,onKicadStringSelected:n})=>{const o=[];return t&&o.push("tscircuit.com"),e&&o.push("jlcpcb"),n&&o.push("kicad"),o},C6o=({isOpen:t,onClose:e,jlcpcbProxyRequestHeaders:n,onKicadStringSelected:o,onTscircuitPackageSelected:i,onJlcpcbComponentTsxLoaded:r,jlcpcbProxyApiBase:A,tscircuitSessionToken:s})=>{Zte();const a=j.useMemo(()=>I6o({onKicadStringSelected:o,onTscircuitPackageSelected:i,onJlcpcbComponentTsxLoaded:r}),[o,i,r]),c=a.length>0,l=a.length===1,[g,u]=j.useState(a[0]??"tscircuit.com"),[d,h]=j.useState(""),[_,p]=j.useState(null),{results:m,isSearching:I,error:C,hasSearched:f,search:y,reset:B}=h6o({sessionToken:s}),{results:x,isSearching:S,error:M,hasSearched:w,search:k,reset:N}=m6o(),{results:H,isSearching:G,error:U,hasSearched:J,search:W,reset:X}=p6o(),{details:oe,isLoading:ce,fetchDetails:ee,reset:ie}=l6o(),[ae,re]=j.useState(null),[le,ye]=j.useState(!1),[xe,be]=j.useState("pcb"),[he,Se]=j.useState(null),[Ie,Ge]=j.useState(!1),Je=j.useMemo(()=>({jlcpcb:{headers:n,apiBase:A}}),[A,n]),{circuitJson:Ze,error:pe,isLoading:et}=g6o(_,Je),Le=Nvt(_);j.useEffect(()=>{Se(null)},[_]);const Pe=j.useCallback(()=>{B(),N(),X(),p(null)},[N,X,B]);j.useEffect(()=>{t||(Pe(),h(""),ye(!1),re(null),Se(null))},[t,Pe]),j.useEffect(()=>{h(""),p(null),g==="tscircuit.com"?B():g==="jlcpcb"?N():g==="kicad"&&X()},[g,N,X,B]);const Ue=ct=>{p(ct),re(ct),be("pcb"),ye(!0),ie();const ft=ct.package.org_owner_tscircuit_handle,Dt=ct.package.unscoped_name;if(ft&&Dt){const Ct=Dt.split("/").pop()??Dt;ee(ft,Ct)}},Ne=async()=>{d.trim()&&(p(null),g==="tscircuit.com"?await y(d):g==="jlcpcb"?await k(d):g==="kicad"&&await W(d))},Ee=async ct=>{try{if(Se(null),Ge(!0),ct.source==="kicad"){if(!o)throw new Error("KiCad handler not provided");await o({result:ct,footprint:ct.footprint.qualifiedName})}else if(ct.source==="jlcpcb"){if(!r)throw new Error("JLCPCB handler not provided");const ft=await svo(ct.component.partNumber,{headers:n,apiBase:A});await r({result:ct,tsx:ft})}else if(ct.source==="tscircuit.com"){if(!i)throw new Error("tscircuit package handler not provided");const ft=ct.package.org_owner_tscircuit_handle,Dt=ct.package.unscoped_name;if(!ft||!Dt)throw new Error("Missing package metadata");const Ct=Dt.split("/").pop()??Dt,Nt=`@tsci/${ft}.${Ct}`;await i({result:ct,fullPackageName:Nt})}return!0}catch(ft){return console.error("Failed to import component",ft),Se(ft instanceof Error?ft.message:"Failed to import component"),!1}finally{Ge(!1)}};let Oe=[],we=!1,Ve=null,je=!1;g==="tscircuit.com"?(Oe=m,we=I,Ve=C,je=f):g==="jlcpcb"?(Oe=x,we=S,Ve=M,je=w):g==="kicad"&&(Oe=H,we=G,Ve=U,je=J);const At=async()=>{if(!_)return;await Ee(_)&&(e(),Pe(),h(""))},at=ct=>{ct||e()},gt=ct=>{ye(ct),ct||re(null)};return V.jsxs(PN,{open:t,onOpenChange:at,children:[V.jsxs(f3,{style:{width:"calc(100vw - 2rem)",maxWidth:Le?"min(1120px, calc(100vw - 2rem))":"min(672px, calc(100vw - 2rem))",zIndex:Tvt.importComponentDialog},className:"rf-rounded-sm rf-max-h-[90vh] rf-overflow-y-auto rf-overflow-x-hidden rf-flex rf-flex-col",children:[V.jsxs(y3,{children:[V.jsxs(E3,{className:"rf-text-lg sm:rf-text-xl",children:["Import ",l?ane[g].label:""," ","Component"]}),V.jsx(vN,{className:"rf-text-sm",children:c?"Search for components from available sources.":"Import options are disabled because no handlers were provided."})]}),c?V.jsxs(TIe,{value:g,onValueChange:ct=>u(ct),className:"rf-min-w-0 rf-w-full",children:[!l&&V.jsx(xX,{className:"rf-flex rf-w-full rf-gap-2",children:a.map(ct=>V.jsx(Zx,{value:ct,className:"rf-flex-1 rf-text-xs sm:rf-text-sm",children:ane[ct].label},ct))}),V.jsxs("div",{className:"rf-min-w-0",style:Le?{display:"grid",gridTemplateColumns:"minmax(0, 1fr) minmax(360px, 0.95fr)",gap:"1.5rem",alignItems:"start"}:void 0,children:[V.jsxs("div",{className:"rf-min-w-0",children:[V.jsx(t6o,{query:d,placeholder:ane[g].placeholder,isSearching:we,onQueryChange:h,onSubmit:Ne}),V.jsx("div",{className:"no-scrollbar rf-mt-4 rf-flex-1 rf-min-h-[200px] !rf-max-h-[40vh] !rf-overflow-y-auto rf-overflow-x-hidden rf-border rf-rounded-md rf-min-w-0",children:we?V.jsxs("div",{className:"rf-p-8 rf-text-center rf-text-zinc-500",children:[V.jsx(RB,{className:"rf-h-8 rf-w-8 rf-animate-spin rf-mx-auto rf-mb-2"}),V.jsx("p",{children:"Searching..."})]}):Oe.length>0?V.jsx(s6o,{results:Oe,selected:_,onSelect:p,onShowDetails:g==="tscircuit.com"?Ue:void 0}):V.jsx("div",{className:"rf-p-8 rf-text-center rf-text-zinc-500",children:Ve?`Error: ${Ve}`:je?ane[g].emptyMessage:"Enter a search term to find components"})})]}),Le?V.jsx("div",{className:"rf-mt-4",children:V.jsx(a6o,{circuitJson:Ze,error:pe,isLoading:et,height:325})}):null]})]}):null,he?V.jsx("div",{className:"rf-text-sm rf-text-red-600 rf-mt-2",children:he}):null,V.jsxs(hO,{className:"rf-flex rf-flex-col sm:rf-flex-row rf-gap-2",children:[V.jsx(Vs,{variant:"outline",onClick:e,className:"rf-order-2 sm:rf-order-1",children:"Cancel"}),V.jsx(Vs,{onClick:At,disabled:!_||Ie,className:"rf-order-1 sm:rf-order-2",children:Ie?V.jsx(RB,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):"Import"})]})]}),V.jsx(c6o,{packageResult:ae,isOpen:le,onOpenChange:gt,isLoading:ce,details:oe,previewTab:xe,onPreviewTabChange:ct=>be(ct),isSubmitting:Ie,onImport:()=>{ae&&Ee(ae).then(ct=>{ct&&(ye(!1),e(),Pe(),h(""))})}})]})},f6o=t=>{const e=t.match(/export const (\w+) =/);if(!e)throw new Error("Could not determine component name from TSX contents");return e[1]},Fvt=t=>{const e=w0(A=>A.pushEvent),n=w0(A=>A.upsertFile),o=async({result:A,fullPackageName:s})=>{const c=A.package.unscoped_name??A.package.name;await GA.promise(e({event_type:"INSTALL_PACKAGE",full_package_name:s}),{loading:`Requesting install for "${c}"`,success:`Install requested for "${c}"`,error:l=>`Failed to request install: ${l instanceof Error?l.message:String(l)}`})},i=async({footprint:A})=>{await GA.promise(navigator.clipboard.writeText(A),{loading:`Copying "${A}"`,success:`Copied "${A}" to clipboard`,error:s=>`Failed to copy footprint: ${s instanceof Error?s.message:String(s)}`})},r=async({result:A,tsx:s})=>{const c=`imports/${f6o(s)}.tsx`;await GA.promise(n(c,s),{loading:`Importing ${A.component.partNumber}`,success:`Imported to "${c}"`,error:l=>`Failed to import component: ${l instanceof Error?l.message:String(l)}`})};return V.jsx(C6o,{...t,onTscircuitPackageSelected:o,onKicadStringSelected:i,onJlcpcbComponentTsxLoaded:r})};Fvt.displayName="ImportComponentDialogForCli";var gwe={exports:{}},Lvt;function y6o(){return Lvt||(Lvt=1,(function(t,e){var n={env:{},version:""};(function(o){t.exports=o()})(function(){return(function o(i,r,A){function s(l,g){if(!r[l]){if(!i[l]){var u=typeof y4=="function"&&y4;if(!g&&u)return u(l,!0);if(a)return a(l,!0);var d=new Error("Cannot find module '"+l+"'");throw d.code="MODULE_NOT_FOUND",d}var h=r[l]={exports:{}};i[l][0].call(h.exports,function(_){var p=i[l][1][_];return s(p||_)},h,h.exports,o,i,r,A)}return r[l].exports}for(var a=typeof y4=="function"&&y4,c=0;c<A.length;c++)s(A[c]);return s})({1:[function(o,i,r){var A=o("./utils"),s=o("./support"),a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";r.encode=function(c){for(var l,g,u,d,h,_,p,m=[],I=0,C=c.length,f=C,y=A.getTypeOf(c)!=="string";I<c.length;)f=C-I,u=y?(l=c[I++],g=I<C?c[I++]:0,I<C?c[I++]:0):(l=c.charCodeAt(I++),g=I<C?c.charCodeAt(I++):0,I<C?c.charCodeAt(I++):0),d=l>>2,h=(3&l)<<4|g>>4,_=1<f?(15&g)<<2|u>>6:64,p=2<f?63&u:64,m.push(a.charAt(d)+a.charAt(h)+a.charAt(_)+a.charAt(p));return m.join("")},r.decode=function(c){var l,g,u,d,h,_,p=0,m=0,I="data:";if(c.substr(0,I.length)===I)throw new Error("Invalid base64 input, it looks like a data url.");var C,f=3*(c=c.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(c.charAt(c.length-1)===a.charAt(64)&&f--,c.charAt(c.length-2)===a.charAt(64)&&f--,f%1!=0)throw new Error("Invalid base64 input, bad content length.");for(C=s.uint8array?new Uint8Array(0|f):new Array(0|f);p<c.length;)l=a.indexOf(c.charAt(p++))<<2|(d=a.indexOf(c.charAt(p++)))>>4,g=(15&d)<<4|(h=a.indexOf(c.charAt(p++)))>>2,u=(3&h)<<6|(_=a.indexOf(c.charAt(p++))),C[m++]=l,h!==64&&(C[m++]=g),_!==64&&(C[m++]=u);return C}},{"./support":30,"./utils":32}],2:[function(o,i,r){var A=o("./external"),s=o("./stream/DataWorker"),a=o("./stream/Crc32Probe"),c=o("./stream/DataLengthProbe");function l(g,u,d,h,_){this.compressedSize=g,this.uncompressedSize=u,this.crc32=d,this.compression=h,this.compressedContent=_}l.prototype={getContentWorker:function(){var g=new s(A.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new c("data_length")),u=this;return g.on("end",function(){if(this.streamInfo.data_length!==u.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),g},getCompressedWorker:function(){return new s(A.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},l.createWorkerFrom=function(g,u,d){return g.pipe(new a).pipe(new c("uncompressedSize")).pipe(u.compressWorker(d)).pipe(new c("compressedSize")).withStreamInfo("compression",u)},i.exports=l},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(o,i,r){var A=o("./stream/GenericWorker");r.STORE={magic:"\0\0",compressWorker:function(){return new A("STORE compression")},uncompressWorker:function(){return new A("STORE decompression")}},r.DEFLATE=o("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(o,i,r){var A=o("./utils"),s=(function(){for(var a,c=[],l=0;l<256;l++){a=l;for(var g=0;g<8;g++)a=1&a?3988292384^a>>>1:a>>>1;c[l]=a}return c})();i.exports=function(a,c){return a!==void 0&&a.length?A.getTypeOf(a)!=="string"?(function(l,g,u,d){var h=s,_=d+u;l^=-1;for(var p=d;p<_;p++)l=l>>>8^h[255&(l^g[p])];return-1^l})(0|c,a,a.length,0):(function(l,g,u,d){var h=s,_=d+u;l^=-1;for(var p=d;p<_;p++)l=l>>>8^h[255&(l^g.charCodeAt(p))];return-1^l})(0|c,a,a.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 A=null;A=typeof Promise<"u"?Promise:o("lie"),i.exports={Promise:A}},{lie:37}],7:[function(o,i,r){var A=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",s=o("pako"),a=o("./utils"),c=o("./stream/GenericWorker"),l=A?"uint8array":"array";function g(u,d){c.call(this,"FlateWorker/"+u),this._pako=null,this._pakoAction=u,this._pakoOptions=d,this.meta={}}r.magic="\b\0",a.inherits(g,c),g.prototype.processChunk=function(u){this.meta=u.meta,this._pako===null&&this._createPako(),this._pako.push(a.transformTo(l,u.data),!1)},g.prototype.flush=function(){c.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},g.prototype.cleanUp=function(){c.prototype.cleanUp.call(this),this._pako=null},g.prototype._createPako=function(){this._pako=new s[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var u=this;this._pako.onData=function(d){u.push({data:d,meta:u.meta})}},r.compressWorker=function(u){return new g("Deflate",u)},r.uncompressWorker=function(){return new g("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(o,i,r){function A(h,_){var p,m="";for(p=0;p<_;p++)m+=String.fromCharCode(255&h),h>>>=8;return m}function s(h,_,p,m,I,C){var f,y,B=h.file,x=h.compression,S=C!==l.utf8encode,M=a.transformTo("string",C(B.name)),w=a.transformTo("string",l.utf8encode(B.name)),k=B.comment,N=a.transformTo("string",C(k)),H=a.transformTo("string",l.utf8encode(k)),G=w.length!==B.name.length,U=H.length!==k.length,J="",W="",X="",oe=B.dir,ce=B.date,ee={crc32:0,compressedSize:0,uncompressedSize:0};_&&!p||(ee.crc32=h.crc32,ee.compressedSize=h.compressedSize,ee.uncompressedSize=h.uncompressedSize);var ie=0;_&&(ie|=8),S||!G&&!U||(ie|=2048);var ae=0,re=0;oe&&(ae|=16),I==="UNIX"?(re=798,ae|=(function(ye,xe){var be=ye;return ye||(be=xe?16893:33204),(65535&be)<<16})(B.unixPermissions,oe)):(re=20,ae|=(function(ye){return 63&(ye||0)})(B.dosPermissions)),f=ce.getUTCHours(),f<<=6,f|=ce.getUTCMinutes(),f<<=5,f|=ce.getUTCSeconds()/2,y=ce.getUTCFullYear()-1980,y<<=4,y|=ce.getUTCMonth()+1,y<<=5,y|=ce.getUTCDate(),G&&(W=A(1,1)+A(g(M),4)+w,J+="up"+A(W.length,2)+W),U&&(X=A(1,1)+A(g(N),4)+H,J+="uc"+A(X.length,2)+X);var le="";return le+=`
5786
+ `,g=new Blob([l],{type:"text/plain"}),u=URL.createObjectURL(g),d=document.createElement("a");d.href=u,d.download=`${c}.test.ts`,d.click(),URL.revokeObjectURL(u)}catch(a){alert(`Error generating test.ts for ${t.constructor.name}: ${a instanceof Error?a.message:String(a)}`)}o(!1)};return V.jsxs("div",{className:`relative ${e}`,ref:i,children:[V.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>o(!n),title:`Download options for ${t.constructor.name}`,children:t.constructor.name}),n&&V.jsxs("div",{className:"absolute top-full left-0 mt-1 bg-white border border-gray-300 rounded shadow-lg z-10 min-w-[150px]",children:[V.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download JSON"}),V.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:A,children:"Download page.tsx"}),V.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download test.ts"})]})]})},S3t=t=>t.activeSubSolver?[t,...S3t(t.activeSubSolver)]:[t],A3o=({solver:t})=>{const e=S3t(t);return V.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:e.map((n,o)=>V.jsxs("div",{className:"flex items-center",children:[o>0&&V.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),V.jsx(r3o,{solver:n})]},n.constructor.name))})},s3o=({solver:t,triggerRender:e,animationSpeed:n=25,onSolverStarted:o,onSolverCompleted:i})=>{const[r,A]=j.useReducer(_=>!_,!1),s=j.useRef(void 0),a=()=>{!t.solved&&!t.failed&&(t.step(),e())},c=()=>{!t.solved&&!t.failed&&(o&&o(t),t.solve(),e(),i&&i(t))},l=()=>{r?(s.current&&(clearInterval(s.current),s.current=void 0),A()):(A(),s.current=setInterval(()=>{if(t.solved||t.failed){s.current&&(clearInterval(s.current),s.current=void 0),A(),e(),i&&t.solved&&i(t);return}t.step(),e()},n))},g=()=>{const _=t;if(_.getCurrentPhase&&!t.solved&&!t.failed){const p=_.getCurrentPhase();for(;_.getCurrentPhase()===p&&!t.solved&&!t.failed;)t.step();e()}},u=()=>{if(t.solved||t.failed||r)return;const _=window.prompt("Step until which iteration?",`${t.iterations}`);if(_===null)return;const p=Number(_);if(!Number.isFinite(p)){window.alert("Please enter a valid number for the iteration");return}for(;t.iterations<p&&!t.solved&&!t.failed;)t.step();e(),t.solved&&i&&i(t)};j.useEffect(()=>()=>{s.current&&clearInterval(s.current)},[]),j.useEffect(()=>{(t.solved||t.failed)&&r&&(s.current&&(clearInterval(s.current),s.current=void 0),A())},[t.solved,t.failed,r]);const d=t.getCurrentPhase!==void 0,h=d?t.getCurrentPhase():null;return V.jsxs("div",{className:"space-y-2 p-2 border-b",children:[V.jsx("div",{className:"flex items-center",children:V.jsx(A3o,{solver:t})}),V.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[V.jsx("button",{onClick:a,disabled:t.solved||t.failed||r,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),V.jsx("button",{onClick:c,disabled:t.solved||t.failed||r,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),V.jsx("button",{onClick:l,disabled:t.solved||t.failed,className:`px-3 py-1 rounded text-white text-sm ${r?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:r?"Stop":"Animate"}),V.jsx("button",{onClick:u,disabled:t.solved||t.failed||r,className:"bg-orange-500 hover:bg-orange-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step Until Iteration"}),d&&V.jsx("button",{onClick:g,disabled:t.solved||t.failed||r,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),V.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&V.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),h&&V.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",V.jsx("span",{className:"font-medium",children:h})]}),t.solved&&V.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&V.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&V.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},a3o=(t,e,n)=>{const o=t.currentPipelineStepIndex;return e<o?"Completed":e===o&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},c3o=(t,e)=>{const o=t.pipelineDef[e].solverName,i=a3o(t,e),r=t[o],A=t.firstIterationOfPhase?.[o]??null,s=t.iterations;let a=0;if(i==="Completed"){const u=t.pipelineDef[e+1],d=u?t.firstIterationOfPhase?.[u.solverName]:void 0;d!==void 0&&A!==null?a=d-A:A!==null&&(a=s-A)}else i==="In Progress"&&A!==null&&(a=s-A);const c=t.timeSpentOnPhase?.[o]??0;let l=0;i==="Completed"?l=1:i==="In Progress"&&r&&(l=r.progress??0);const g=r?.stats??null;return{index:e,name:o,status:i,firstIteration:A,iterations:a,progress:l,timeSpent:c,stats:g&&Object.keys(g).length>0?g:null,solverInstance:r??null}},l3o=({status:t})=>{const e={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return V.jsx("span",{className:`font-medium ${e[t]}`,children:t})},g3o=({progress:t})=>{if(t===0)return null;const e=Math.round(t*100);return V.jsxs("div",{className:"flex items-center gap-2",children:[V.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:V.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${e}%`}})}),V.jsxs("span",{className:"text-xs text-gray-500",children:[e,"%"]})]})},u3o=t=>Object.entries(t).map(([e,n])=>`${e}: ${n}`).join(", "),h3o=({stats:t})=>{if(!t||Object.keys(t).length===0)return V.jsx("span",{children:"-"});const e=Object.entries(t),n=u3o(t);return V.jsxs("details",{className:"cursor-pointer",children:[V.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:n}),V.jsx("div",{className:"mt-1 text-xs",children:e.map(([o,i])=>V.jsxs("div",{children:[o,": ",String(i)]},o))})]})},kMe=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(kMe);const e={};for(const[n,o]of Object.entries(t))n.startsWith("_")||(e[n]=kMe(o));return e},d3o=(t,e)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${e}`);return}const n=kMe(t.getConstructorParams()),o=new Blob([JSON.stringify(n,null,2)],{type:"application/json"}),i=URL.createObjectURL(o),r=document.createElement("a");r.href=i,r.download=`${e}_input.json`,r.click(),URL.revokeObjectURL(i)}catch(n){alert(`Error downloading input for ${e}: ${n instanceof Error?n.message:String(n)}`)}},_3o=({solver:t,onStepUntilPhase:e,onDownloadInput:n})=>{const o=t.pipelineDef.map((s,a)=>c3o(t,a)),i=s=>{e?.(s)},r=s=>{s.solverInstance&&(n?n(s.solverInstance,s.name):d3o(s.solverInstance,s.name))},A=s=>`${(s/1e3).toFixed(2)}s`;return V.jsxs("div",{className:"border-t border-gray-200",children:[V.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:V.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),V.jsx("div",{className:"overflow-x-auto",children:V.jsxs("table",{className:"w-full text-sm",children:[V.jsx("thead",{children:V.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),V.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",V.jsx("sub",{children:"0"})]}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),V.jsx("tbody",{children:o.map(s=>V.jsxs("tr",{className:`border-b border-gray-100 ${s.status==="In Progress"?"bg-yellow-50":""}`,children:[V.jsx("td",{className:"px-4 py-2",children:V.jsxs("div",{className:"flex items-center gap-2",children:[V.jsx("span",{className:"text-gray-400 w-6",children:String(s.index+1).padStart(2,"0")}),V.jsx("button",{onClick:()=>i(s.name),disabled:s.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 ${s.name} completes`,children:V.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:V.jsx("path",{fillRule:"evenodd",d:"M4.5 5.653c0-1.426 1.529-2.33 2.779-1.643l11.54 6.348c1.295.712 1.295 2.573 0 3.285L7.28 19.991c-1.25.687-2.779-.217-2.779-1.643V5.653z",clipRule:"evenodd"})})}),V.jsx("span",{className:"font-medium text-gray-900",children:s.name})]})}),V.jsx("td",{className:"px-4 py-2",children:V.jsx(l3o,{status:s.status})}),V.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:s.firstIteration!==null?s.firstIteration:""}),V.jsx("td",{className:"px-4 py-2 text-gray-600",children:s.iterations}),V.jsx("td",{className:"px-4 py-2",children:V.jsx(g3o,{progress:s.progress})}),V.jsx("td",{className:"px-4 py-2 text-gray-600",children:A(s.timeSpent)}),V.jsx("td",{className:"px-4 py-2 text-gray-500",children:V.jsx(h3o,{stats:s.stats})}),V.jsx("td",{className:"px-4 py-2",children:s.solverInstance?V.jsxs("button",{onClick:()=>r(s),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${s.name}`,children:[V.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:V.jsx("path",{fillRule:"evenodd",d:"M12 2.25a.75.75 0 01.75.75v11.69l3.22-3.22a.75.75 0 111.06 1.06l-4.5 4.5a.75.75 0 01-1.06 0l-4.5-4.5a.75.75 0 111.06-1.06l3.22 3.22V3a.75.75 0 01.75-.75zm-9 13.5a.75.75 0 01.75.75v2.25a1.5 1.5 0 001.5 1.5h13.5a1.5 1.5 0 001.5-1.5V16.5a.75.75 0 011.5 0v2.25a3 3 0 01-3 3H5.25a3 3 0 01-3-3V16.5a.75.75 0 01.75-.75z",clipRule:"evenodd"})}),V.jsx("span",{children:"Input"})]}):null})]},s.name))})]})})]})},m3o=class extends Jr.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 p3o({graphics:t}){const e=t.points??[],n=t.lines??[],o=t.rects??[],i=t.circles??[],r=t.texts??[];let A=Number.POSITIVE_INFINITY,s=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,c=Number.NEGATIVE_INFINITY;const l=(p,m)=>{typeof p=="number"&&(p<A&&(A=p),p>a&&(a=p)),typeof m=="number"&&(m<s&&(s=m),m>c&&(c=m))};for(const p of e)l(p.x,p.y);for(const p of n){const m=p.points??[];for(const I of m)l(I.x,I.y)}for(const p of o){const m=p.x??0,I=p.y??0,C=p.width??0,f=p.height??0;l(m,I),l(m+C,I+f)}for(const p of i){const m=p.x??0,I=p.y??0,C=p.radius??1;l(m-C,I-C),l(m+C,I+C)}for(const p of r)l(p.x,p.y);(!isFinite(A)||!isFinite(s)||!isFinite(a)||!isFinite(c))&&(A=-20,s=-20,a=20,c=20);const g=10,u=A-g,d=s-g,h=Math.max(1,a-A+2*g),_=Math.max(1,c-s+2*g);return V.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${u} ${d} ${h} ${_}`,role:"img","aria-label":"Graphics fallback",children:[o.map((p,m)=>V.jsx("rect",{x:p.x??0,y:p.y??0,width:p.width??0,height:p.height??0,fill:"none",stroke:p.strokeColor??"black",strokeWidth:p.strokeWidth??1},`rect-${m}`)),n.map((p,m)=>V.jsx("polyline",{fill:"none",stroke:p.strokeColor??"black",strokeWidth:p.strokeWidth??1,points:(p.points??[]).map(I=>`${I.x??0},${I.y??0}`).join(" ")},`line-${m}`)),i.map((p,m)=>V.jsx("circle",{cx:p.x??0,cy:p.y??0,r:p.radius??1.5,fill:p.fillColor??"none",stroke:p.strokeColor??"black",strokeWidth:p.strokeWidth??1},`circle-${m}`)),e.map((p,m)=>V.jsx("circle",{cx:p.x??0,cy:p.y??0,r:p.radius??1.5,fill:p.color??"black"},`point-${m}`)),r.map((p,m)=>V.jsx("text",{x:p.x??0,y:p.y??0,fontSize:p.fontSize??10,fill:p.color??"black",children:p.text??""},`text-${m}`))]})}var I3o=({solver:t,animationSpeed:e=25,onSolverStarted:n,onSolverCompleted:o})=>{const[i,r]=j.useReducer(l=>l+1,0),A=j.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(l){return console.error("Visualization error:",l),{points:[],lines:[],rects:[],circles:[]}}},[t,i]),s=j.useMemo(()=>(A.rects?.length||0)===0&&(A.lines?.length||0)===0&&(A.points?.length||0)===0&&(A.circles?.length||0)===0,[A]);j.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const l=document.createElement("script");l.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(l)}},[]);const a=t.pipelineDef!==void 0,c=l=>{const g=t;if(!t.solved&&!t.failed){for(;!t.solved&&!t.failed&&g.currentPipelineStepIndex<=g.pipelineDef.findIndex(u=>u.solverName===l);)t.step();r()}};return V.jsxs("div",{children:[V.jsx(s3o,{solver:t,triggerRender:r,animationSpeed:e,onSolverStarted:n,onSolverCompleted:o}),s?V.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):V.jsx(m3o,{fallback:V.jsx(p3o,{graphics:A}),children:V.jsx(i3o,{graphics:A})}),a&&V.jsx(_3o,{solver:t,onStepUntilPhase:c})]})};const C3o=()=>{j.useEffect(()=>{const t="tailwind-cdn-script";if(document.getElementById(t)||window.tailwind)return;const e=document.createElement("div");e.className="hidden",document.body.appendChild(e);const n=window.getComputedStyle(e).display==="none";if(document.body.removeChild(e),n)return;const o=document.createElement("script");o.id=t,o.src="https://cdn.tailwindcss.com",document.head.appendChild(o)},[])},f3o=1e3,MQ=(t,e)=>{const{fileName:n,mimeType:o="text/plain"}=e,i=t instanceof Blob?t:new Blob([t],{type:o}),r=URL.createObjectURL(i),A=document.createElement("a");A.href=r,A.download=n,A.target="_blank",A.rel="noopener noreferrer",A.style.display="none",document.body.appendChild(A),A.click(),document.body.removeChild(A),setTimeout(()=>{URL.revokeObjectURL(r)},f3o)},b3t=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"},wQ="https://github.com/tscircuit/tscircuit-autorouter/issues/new",D3t="https://github.com/tscircuit/copper-pour-solver/issues/new",M3t="https://github.com/tscircuit/calculate-packing/issues/new",w3t="https://github.com/tscircuit/schematic-trace-solver/issues/new?template=json-bug-report.yml",y3o={PackSolver2:M3t,AutoroutingPipelineSolver:wQ,AssignableAutoroutingPipeline2:wQ,AssignableAutoroutingPipeline3:wQ,AutoroutingPipeline1_OriginalUnravel:wQ,AutoroutingPipelineSolver3_HgPortPointPathing:wQ,AutoroutingPipelineSolver4:wQ,AutoroutingPipelineSolver5:wQ,AutoroutingPipelineSolver7_MultiGraph:wQ,AutoroutingPipelineSolver8:wQ,CopperPourPipelineSolver:D3t,SchematicTracePipelineSolver:w3t},E3o=t=>t.toLowerCase().includes("pack")?qIo:t.toLowerCase().includes("rout")?eCo:TIo,P3t=t=>{const e=y3o[t];if(e)return e;const n=t.toLowerCase();return n.includes("autorout")?wQ:n.includes("schematic")&&n.includes("trace")?w3t:n.includes("copperpour")?D3t:n.includes("pack")?M3t:null},B3o=t=>`${b3t(`${t.componentName}-${t.solverName}`)}-solver-input.json`,v3t=t=>{MQ(JSON.stringify(t.solverParams,null,2),{fileName:B3o(t),mimeType:"application/json"})},x3o=({solverEvent:t})=>{const e=P3t(t.solverName);return V.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:[V.jsxs(Vs,{type:"button",variant:"outline",size:"sm",onClick:()=>v3t(t),children:[V.jsx(j4e,{className:"rf-w-4 rf-h-4"}),"Download"]}),e?V.jsx(Vs,{asChild:!0,variant:"outline",size:"sm",children:V.jsxs("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:[V.jsx(pee,{className:"rf-w-4 rf-h-4"}),"Report"]})}):V.jsxs(Vs,{type:"button",variant:"outline",size:"sm",disabled:!0,title:"No report link configured for this solver",children:[V.jsx(pee,{className:"rf-w-4 rf-h-4"}),"Report"]})]})},Q3o=({solverEvent:t})=>{const e=P3t(t.solverName);return e?V.jsx(Vs,{asChild:!0,variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8",children:V.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",title:"Report solver bug","aria-label":"Report solver bug",children:V.jsx(pee,{className:"rf-w-4 rf-h-4"})})}):V.jsx(Vs,{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:V.jsx(pee,{className:"rf-w-4 rf-h-4"})})},S3o=({solverEvents:t=[]})=>{const[e,n]=j.useState(null);C3o();const o=j.useMemo(()=>{const s=new Map;for(const a of t){const c=`${a.componentName}-${a.solverName}`;s.set(c,a)}return s},[t]),i=j.useMemo(()=>Array.from(o.keys()),[o]),r=e?o.get(e):null,A=j.useMemo(()=>{if(!r)return{instance:null,error:null,classFound:!1};const s=_me[r.solverName];if(!s)return{instance:null,error:`Solver class "${r.solverName}" not found in SOLVERS registry. Available: ${Object.keys(_me).join(", ")}`,classFound:!1};try{const a=r.solverParams,c=a?.input!==void 0?a.input:a;return{instance:new s(c),error:null,classFound:!0}}catch(a){const c=a instanceof Error?a.message:String(a);return console.error("Failed to reconstruct solver:",a),{instance:null,error:`Failed to instantiate solver: ${c}`,classFound:!0}}},[r]);return t.length===0?V.jsx("div",{className:"rf-p-4",children:V.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:V.jsxs("div",{className:"rf-p-4",children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),V.jsx("p",{className:"rf-text-sm rf-text-gray-600",children:"Solvers will appear here when the circuit runs. Solvers are used for tasks like component packing and autorouting."})]})})}):V.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[V.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[V.jsxs("div",{className:"rf-text-xs rf-font-semibold rf-text-gray-500 rf-px-3 rf-py-2 rf-bg-gray-50 rf-border-b rf-border-gray-200",children:[i.length," ",i.length===1?"Solver":"Solvers"]}),i.map(s=>{const a=o.get(s),c=e===s;return V.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${c?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>n(s),children:(()=>{const l=E3o(a.solverName);return V.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[V.jsx(l,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),V.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[V.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:a.componentName}),V.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:a.solverName})]})]})})()},s)})]}),V.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:r?A.instance?V.jsxs("div",{className:"rf-flex rf-h-full rf-flex-col rf-overflow-y-auto",children:[V.jsx(x3o,{solverEvent:r}),V.jsx("div",{className:"rf-min-h-0 rf-flex-1",children:V.jsx(y2,{fallback:V.jsx("div",{className:"rf-p-4",children:V.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),V.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",r.solverName]})]})}),children:V.jsx(I3o,{solver:A.instance})})})]}):V.jsxs("div",{className:"rf-p-4",children:[V.jsxs("div",{className:"rf-mb-4",children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:r.solverName}),V.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",r.componentName]})]}),A.error&&V.jsx("div",{className:`rf-rounded-md rf-border rf-p-4 rf-mb-4 ${A.classFound?"rf-bg-red-50 rf-border-red-200":"rf-bg-yellow-50 rf-border-yellow-200"}`,children:V.jsx("p",{className:`rf-text-sm ${A.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:A.error})}),V.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[V.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:[V.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"}),V.jsxs("div",{className:"rf-flex rf-items-center rf-gap-1",children:[V.jsx(Q3o,{solverEvent:r}),V.jsx(Vs,{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:()=>v3t(r),children:V.jsx(j4e,{className:"rf-w-4 rf-h-4"})})]})]}),V.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:V.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(r.solverParams,null,2)})})]})]}):V.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:V.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},N3t=({errorMessage:t,errorStack:e,circuitJsonErrors:n})=>{j.useEffect(()=>{if(t){const o=new Error(t);e&&(o.stack=e);try{b9.captureException(o)}catch{}}},[t,e]),j.useEffect(()=>{if(n&&n.length>0)for(const o of n){const i=new Error(o.message||"Circuit JSON Error");o.stack&&(i.stack=o.stack);try{b9.captureException(i,{error_type:o.type})}catch{}}},[n])},R3t=t=>{j.useEffect(()=>{try{Tkn(t)}catch{}},[t.source,t.component,t.isWebEmbedded,t.activeTab])},T3t="0.0.2251",b3o={version:T3t},ene=aAt()(cAt(t=>({lastRunEvalVersion:void 0,setLastRunEvalVersion:e=>{t({lastRunEvalVersion:e})}}),{name:"runframe-runner-store"})),D3o=t=>{const[e,n]=j.useState([]),[o,i]=j.useState(null),[r,A]=j.useState(""),[s,a]=r9("eval-version-selection",null),c=ene(d=>d.setLastRunEvalVersion),l=ene(d=>d.lastRunEvalVersion);return j.useEffect(()=>{t&&fetch("https://data.jsdelivr.com/v1/package/npm/@tscircuit/eval").then(d=>d.json()).then(d=>{if(Array.isArray(d?.versions)){let h=[...d.versions];d.tags?.latest&&(i(d.tags.latest),h=h.filter(_=>_!==d.tags.latest)),n(h)}}).catch(()=>{})},[t]),j.useEffect(()=>{t&&(s?(window.TSCIRCUIT_LATEST_EVAL_VERSION=s,c(s)):o&&(window.TSCIRCUIT_LATEST_EVAL_VERSION=o,c(o)))},[t,s,o]),{versions:j.useMemo(()=>e.filter(d=>d.includes(r)).slice(0,50),[e,r]),latestVersion:o,lastRunEvalVersion:l,search:r,setSearch:A,selectVersion:d=>{a(d),A("")}}},M3o=({snippetNames:t,onSelect:e,onCancel:n,isOpen:o})=>{const[i,r]=j.useState(""),[A,s]=j.useState("");if(!o)return null;const a=t.filter(g=>g.toLowerCase().includes(A.toLowerCase())),c=A&&!t.includes(A),l=g=>{g.key==="Enter"&&(a.length===1?r(a[0]):c&&r(A))};return V.jsx("div",{className:"rf-fixed rf-inset-0 rf-bg-black rf-bg-opacity-50 rf-flex rf-items-center rf-justify-center rf-z-[100]",children:V.jsxs("div",{className:"rf-bg-white rf-rounded-lg rf-p-6 rf-w-96",children:[V.jsx("h2",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Select Snippet"}),V.jsx("input",{type:"text",className:"rf-w-full rf-px-4 rf-py-2 rf-border rf-rounded rf-mb-4",placeholder:"Search snippets or new snippet name...",value:A,onChange:g=>s(g.target.value),onKeyDown:l}),V.jsxs("div",{className:"rf-h-60 rf-overflow-y-auto",children:[a.map(g=>V.jsx("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 ${i===g?"bg-blue-50":""}`,onClick:()=>r(g),children:g},g)),c&&V.jsxs("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 text-blue-500 ${i===A?"bg-blue-50":""}`,onClick:()=>r(A),children:['Create new "',A,'"']})]}),V.jsxs("div",{className:"rf-mt-4 rf-flex rf-justify-end rf-gap-2",children:[V.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-text-gray-600 rf-hover:text-gray-800",onClick:n,children:"Cancel"}),V.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-bg-blue-500 rf-text-white rf-rounded rf-hover:bg-blue-600 rf-disabled:opacity-50",onClick:()=>i&&e(i),disabled:!i,children:i===A?`Create "${i}"`:`Save to ${i}`})]})]})})},w3o=t=>{const e=j.useRef(null),n=w0(o=>o.recentEvents);j.useEffect(()=>{if(n.length===0)return;const o=n[0];o.event_id!==e.current&&(t(o),e.current=o.event_id)},[n,t])};var tne="Dialog",[k3t,F3t]=_B(tne),[P3o,OB]=k3t(tne),nne=t=>{const{__scopeDialog:e,children:n,open:o,defaultOpen:i,onOpenChange:r,modal:A=!0}=t,s=j.useRef(null),a=j.useRef(null),[c,l]=Lb({prop:o,defaultProp:i??!1,onChange:r,caller:tne});return V.jsx(P3o,{scope:e,triggerRef:s,contentRef:a,contentId:bp(),titleId:bp(),descriptionId:bp(),open:c,onOpenChange:l,onOpenToggle:j.useCallback(()=>l(g=>!g),[l]),modal:A,children:n})};nne.displayName=tne;var L3t="DialogTrigger",H3t=j.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,i=OB(L3t,n),r=mg(e,i.triggerRef);return V.jsx(Us.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":HMe(i.open),...o,ref:r,onClick:wr(t.onClick,i.onOpenToggle)})});H3t.displayName=L3t;var FMe="DialogPortal",[v3o,G3t]=k3t(FMe,{forceMount:void 0}),one=t=>{const{__scopeDialog:e,forceMount:n,children:o,container:i}=t,r=OB(FMe,e);return V.jsx(v3o,{scope:e,forceMount:n,children:j.Children.map(o,A=>V.jsx(Ry,{present:n||r.open,children:V.jsx(Nee,{asChild:!0,container:i,children:A})}))})};one.displayName=FMe;var ine="DialogOverlay",lO=j.forwardRef((t,e)=>{const n=G3t(ine,t.__scopeDialog),{forceMount:o=n.forceMount,...i}=t,r=OB(ine,t.__scopeDialog);return r.modal?V.jsx(Ry,{present:o||r.open,children:V.jsx(R3o,{...i,ref:e})}):null});lO.displayName=ine;var N3o=iP("DialogOverlay.RemoveScroll"),R3o=j.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,i=OB(ine,n),r=_Co(),A=mg(e,r);return V.jsx(Oee,{as:N3o,allowPinchZoom:!0,shards:[i.contentRef],children:V.jsx(Us.div,{"data-state":HMe(i.open),...o,ref:A,style:{pointerEvents:"auto",...o.style}})})}),wN="DialogContent",gO=j.forwardRef((t,e)=>{const n=G3t(wN,t.__scopeDialog),{forceMount:o=n.forceMount,...i}=t,r=OB(wN,t.__scopeDialog);return V.jsx(Ry,{present:o||r.open,children:r.modal?V.jsx(T3o,{...i,ref:e}):V.jsx(k3o,{...i,ref:e})})});gO.displayName=wN;var T3o=j.forwardRef((t,e)=>{const n=OB(wN,t.__scopeDialog),o=j.useRef(null),i=mg(e,n.contentRef,o);return j.useEffect(()=>{const r=o.current;if(r)return fbe(r)},[]),V.jsx(O3t,{...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 A=r.detail.originalEvent,s=A.button===0&&A.ctrlKey===!0;(A.button===2||s)&&r.preventDefault()}),onFocusOutside:wr(t.onFocusOutside,r=>r.preventDefault())})}),k3o=j.forwardRef((t,e)=>{const n=OB(wN,t.__scopeDialog),o=j.useRef(!1),i=j.useRef(!1);return V.jsx(O3t,{...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 A=r.target;n.triggerRef.current?.contains(A)&&r.preventDefault(),r.detail.originalEvent.type==="focusin"&&i.current&&r.preventDefault()}})}),O3t=j.forwardRef((t,e)=>{const{__scopeDialog:n,trapFocus:o,onOpenAutoFocus:i,onCloseAutoFocus:r,...A}=t,s=OB(wN,n);return ebe(),V.jsx(V.Fragment,{children:V.jsx(Cee,{asChild:!0,loop:!0,trapped:o,onMountAutoFocus:i,onUnmountAutoFocus:r,children:V.jsx(IG,{role:"dialog",id:s.contentId,"aria-describedby":s.descriptionId,"aria-labelledby":s.titleId,"data-state":HMe(s.open),...A,ref:e,deferPointerDownOutside:!0,onDismiss:()=>s.onOpenChange(!1)})})})}),K3t="DialogTitle",rne=j.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,i=OB(K3t,n);return V.jsx(Us.h2,{id:i.titleId,...o,ref:e})});rne.displayName=K3t;var U3t="DialogDescription",Ane=j.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,i=OB(U3t,n);return V.jsx(Us.p,{id:i.descriptionId,...o,ref:e})});Ane.displayName=U3t;var Y3t="DialogClose",LMe=j.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,i=OB(Y3t,n);return V.jsx(Us.button,{type:"button",...o,ref:e,onClick:wr(t.onClick,()=>i.onOpenChange(!1))})});LMe.displayName=Y3t;function HMe(t){return t?"open":"closed"}var V3t="AlertDialog",[F3o]=_B(V3t,[F3t]),B5=F3t(),z3t=t=>{const{__scopeAlertDialog:e,...n}=t,o=B5(e);return V.jsx(nne,{...o,...n,modal:!0})};z3t.displayName=V3t;var L3o="AlertDialogTrigger",H3o=j.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,i=B5(n);return V.jsx(H3t,{...i,...o,ref:e})});H3o.displayName=L3o;var G3o="AlertDialogPortal",J3t=t=>{const{__scopeAlertDialog:e,...n}=t,o=B5(e);return V.jsx(one,{...o,...n})};J3t.displayName=G3o;var O3o="AlertDialogOverlay",q3t=j.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,i=B5(n);return V.jsx(lO,{...i,...o,ref:e})});q3t.displayName=O3o;var W3t="AlertDialogContent",[K3o,U3o]=F3o(W3t),j3t=j.forwardRef((t,e)=>{const{__scopeAlertDialog:n,children:o,...i}=t,r=B5(n),A=j.useRef(null),s=mg(e,A),a=j.useRef(null);return V.jsx(K3o,{scope:n,cancelRef:a,children:V.jsx(gO,{role:"alertdialog",...r,...i,ref:s,onOpenAutoFocus:wr(i.onOpenAutoFocus,c=>{c.preventDefault(),a.current?.focus({preventScroll:!0})}),onPointerDownOutside:c=>c.preventDefault(),onInteractOutside:c=>c.preventDefault(),children:o})})});j3t.displayName=W3t;var Y3o="AlertDialogTitle",X3t=j.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,i=B5(n);return V.jsx(rne,{...i,...o,ref:e})});X3t.displayName=Y3o;var V3o="AlertDialogDescription",$3t=j.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,i=B5(n);return V.jsx(Ane,{...i,...o,ref:e})});$3t.displayName=V3o;var z3o="AlertDialogAction",Z3t=j.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,i=B5(n);return V.jsx(LMe,{...i,...o,ref:e})});Z3t.displayName=z3o;var evt="AlertDialogCancel",tvt=j.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,{cancelRef:i}=U3o(evt,n),r=B5(n),A=mg(e,i);return V.jsx(LMe,{...r,...o,ref:A})});tvt.displayName=evt;var J3o=z3t,q3o=J3t,nvt=q3t,ovt=j3t,ivt=Z3t,rvt=tvt,Avt=X3t,svt=$3t;const avt=J3o,W3o=q3o,cvt=j.forwardRef(({className:t,...e},n)=>V.jsx(nvt,{className:Ui("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}));cvt.displayName=nvt.displayName;const GMe=j.forwardRef(({className:t,...e},n)=>V.jsxs(W3o,{children:[V.jsx(cvt,{}),V.jsx(ovt,{ref:n,className:Ui("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})]}));GMe.displayName=ovt.displayName;const OMe=({className:t,...e})=>V.jsx("div",{className:Ui("rf-flex rf-flex-col rf-space-y-2 rf-text-center sm:rf-text-left",t),...e});OMe.displayName="AlertDialogHeader";const KMe=({className:t,...e})=>V.jsx("div",{className:Ui("rf-flex rf-flex-col-reverse sm:rf-flex-row sm:rf-justify-end sm:rf-space-x-2",t),...e});KMe.displayName="AlertDialogFooter";const UMe=j.forwardRef(({className:t,...e},n)=>V.jsx(Avt,{ref:n,className:Ui("rf-text-lg rf-font-semibold",t),...e}));UMe.displayName=Avt.displayName;const YMe=j.forwardRef(({className:t,...e},n)=>V.jsx(svt,{ref:n,className:Ui("rf-text-sm rf-text-zinc-500 dark:rf-text-zinc-400",t),...e}));YMe.displayName=svt.displayName;const j3o=j.forwardRef(({className:t,...e},n)=>V.jsx(ivt,{ref:n,className:Ui($7(),t),...e}));j3o.displayName=ivt.displayName;const VMe=j.forwardRef(({className:t,...e},n)=>V.jsx(rvt,{ref:n,className:Ui($7({variant:"outline"}),"rf-mt-2 sm:rf-mt-0",t),...e}));VMe.displayName=rvt.displayName;function X3o(t){const e=j.useRef({value:t,previous:t});return j.useMemo(()=>(e.current.value!==t&&(e.current.previous=e.current.value,e.current.value=t),e.current.previous),[t])}var sne="Checkbox",[$3o]=_B(sne),[Z3o,zMe]=$3o(sne);function evo(t){const{__scopeCheckbox:e,checked:n,children:o,defaultChecked:i,disabled:r,form:A,name:s,onCheckedChange:a,required:c,value:l="on",internal_do_not_use_render:g}=t,[u,d]=Lb({prop:n,defaultProp:i??!1,onChange:a,caller:sne}),[h,_]=j.useState(null),[p,m]=j.useState(null),I=j.useRef(!1),C=h?!!A||!!h.closest("form"):!0,f={checked:u,disabled:r,setChecked:d,control:h,setControl:_,name:s,form:A,value:l,hasConsumerStoppedPropagationRef:I,required:c,defaultChecked:YD(i)?!1:i,isFormControl:C,bubbleInput:p,setBubbleInput:m};return V.jsx(Z3o,{scope:e,...f,children:tvo(g)?g(f):o})}var lvt="CheckboxTrigger",gvt=j.forwardRef(({__scopeCheckbox:t,onKeyDown:e,onClick:n,...o},i)=>{const{control:r,value:A,disabled:s,checked:a,required:c,setControl:l,setChecked:g,hasConsumerStoppedPropagationRef:u,isFormControl:d,bubbleInput:h}=zMe(lvt,t),_=mg(i,l),p=j.useRef(a);return j.useEffect(()=>{const m=r?.form;if(m){const I=()=>g(p.current);return m.addEventListener("reset",I),()=>m.removeEventListener("reset",I)}},[r,g]),V.jsx(Us.button,{type:"button",role:"checkbox","aria-checked":YD(a)?"mixed":a,"aria-required":c,"data-state":mvt(a),"data-disabled":s?"":void 0,disabled:s,value:A,...o,ref:_,onKeyDown:wr(e,m=>{m.key==="Enter"&&m.preventDefault()}),onClick:wr(n,m=>{g(I=>YD(I)?!0:!I),h&&d&&(u.current=m.isPropagationStopped(),u.current||m.stopPropagation())})})});gvt.displayName=lvt;var JMe=j.forwardRef((t,e)=>{const{__scopeCheckbox:n,name:o,checked:i,defaultChecked:r,required:A,disabled:s,value:a,onCheckedChange:c,form:l,...g}=t;return V.jsx(evo,{__scopeCheckbox:n,checked:i,defaultChecked:r,disabled:s,required:A,onCheckedChange:c,name:o,form:l,value:a,internal_do_not_use_render:({isFormControl:u})=>V.jsxs(V.Fragment,{children:[V.jsx(gvt,{...g,ref:e,__scopeCheckbox:n}),u&&V.jsx(_vt,{__scopeCheckbox:n})]})})});JMe.displayName=sne;var uvt="CheckboxIndicator",hvt=j.forwardRef((t,e)=>{const{__scopeCheckbox:n,forceMount:o,...i}=t,r=zMe(uvt,n);return V.jsx(Ry,{present:o||YD(r.checked)||r.checked===!0,children:V.jsx(Us.span,{"data-state":mvt(r.checked),"data-disabled":r.disabled?"":void 0,...i,ref:e,style:{pointerEvents:"none",...t.style}})})});hvt.displayName=uvt;var dvt="CheckboxBubbleInput",_vt=j.forwardRef(({__scopeCheckbox:t,...e},n)=>{const{control:o,hasConsumerStoppedPropagationRef:i,checked:r,defaultChecked:A,required:s,disabled:a,name:c,value:l,form:g,bubbleInput:u,setBubbleInput:d}=zMe(dvt,t),h=mg(n,d),_=X3o(r),p=ASt(o);j.useEffect(()=>{const I=u;if(!I)return;const C=window.HTMLInputElement.prototype,y=Object.getOwnPropertyDescriptor(C,"checked").set,B=!i.current;if(_!==r&&y){const x=new Event("click",{bubbles:B});I.indeterminate=YD(r),y.call(I,YD(r)?!1:r),I.dispatchEvent(x)}},[u,_,r,i]);const m=j.useRef(YD(r)?!1:r);return V.jsx(Us.input,{type:"checkbox","aria-hidden":!0,defaultChecked:A??m.current,required:s,disabled:a,name:c,value:l,form:g,...e,tabIndex:-1,ref:h,style:{...e.style,...p,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});_vt.displayName=dvt;function tvo(t){return typeof t=="function"}function YD(t){return t==="indeterminate"}function mvt(t){return YD(t)?"indeterminate":t?"checked":"unchecked"}const uO=j.forwardRef(({className:t,...e},n)=>V.jsx(JMe,{ref:n,className:Ui("rf-peer rf-h-4 rf-w-4 rf-shrink-0 rf-rounded-sm rf-border rf-border-zinc-200 rf-border-zinc-900 rf-shadow focus-visible:rf-outline-none focus-visible:rf-ring-1 focus-visible:rf-ring-zinc-950 disabled:rf-cursor-not-allowed disabled:rf-opacity-50 data-[state=checked]:rf-bg-zinc-900 data-[state=checked]:rf-text-zinc-50 dark:rf-border-zinc-800 dark:rf-border-zinc-50 dark:focus-visible:rf-ring-zinc-300 dark:data-[state=checked]:rf-bg-zinc-50 dark:data-[state=checked]:rf-text-zinc-900",t),...e,children:V.jsx(hvt,{className:Ui("rf-flex rf-items-center rf-justify-center rf-text-current"),children:V.jsx(r3,{className:"rf-h-4 rf-w-4"})})}));uO.displayName=JMe.displayName;const PN=nne,nvo=one,pvt=j.forwardRef(({className:t,...e},n)=>V.jsx(lO,{className:Ui("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}));pvt.displayName=lO.displayName;const f3=j.forwardRef(({className:t,children:e,showOverlay:n=!0,...o},i)=>V.jsxs(nvo,{children:[V.jsx(pvt,{className:Ui(n?"":"rf-hidden")}),V.jsx(gO,{ref:i,className:Ui("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})]}));f3.displayName=gO.displayName;const y3=({className:t,...e})=>V.jsx("div",{className:Ui("rf-flex rf-flex-col rf-space-y-2 rf-text-center sm:rf-text-left",t),...e});y3.displayName="DialogHeader";const hO=({className:t,...e})=>V.jsx("div",{className:Ui("rf-flex rf-flex-col-reverse sm:rf-flex-row sm:rf-justify-end sm:rf-space-x-2",t),...e});hO.displayName="DialogFooter";const E3=j.forwardRef(({className:t,...e},n)=>V.jsx(rne,{ref:n,className:Ui("rf-text-lg rf-font-semibold",t),...e}));E3.displayName=rne.displayName;const vN=j.forwardRef(({className:t,...e},n)=>V.jsx(Ane,{ref:n,className:Ui("rf-text-sm rf-text-zinc-500 dark:rf-text-zinc-400",t),...e}));vN.displayName=Ane.displayName;const ane={"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"}},ovo="https://cdn.jsdelivr.net/npm/easyeda@latest/dist/browser/index.js";let qMe=null;const WMe=async()=>(qMe||(qMe=import(ovo)),qMe),ivo=t=>(e,n)=>{const o=new Headers(n?.headers),i={};return o.forEach((r,A)=>{i[A]=r}),fetch(`${t?.apiBase??zC}/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}})},rvo=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??[]},Avo=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}),Ivt=async(t,e)=>{const{fetchEasyEDAComponent:n}=await WMe();return n(t,{fetch:ivo(e),includeModelMetadata:e?.includeModelMetadata})},svo=async(t,e)=>{const{convertRawEasyToTsx:n}=await WMe(),o=await Ivt(t,e);return n({rawEasy:o})},avo=async(t,e)=>{const{EasyEdaJsonSchema:n,convertEasyEdaJsonToCircuitJson:o}=await WMe(),i=await Ivt(t,{...e,includeModelMetadata:!1}),r=n.parse(i);return o(r,{shouldRecenter:!0,showDesignator:!0,useModelCdn:!1})};function VD(t){return Array.isArray?Array.isArray(t):fvt(t)==="[object Array]"}function cvo(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 jMe(t){return t==null?"":cvo(t)}function ZI(t){return typeof t=="string"}function cne(t){return typeof t=="number"}function lvo(t){return t===!0||t===!1||gvo(t)&&fvt(t)=="[object Boolean]"}function Cvt(t){return typeof t=="object"}function gvo(t){return Cvt(t)&&t!==null}function eE(t){return t!=null}function lne(t){return!t.trim().length}function fvt(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const uvo="Incorrect 'index' type",XMe="Invalid doc index: must be a non-negative integer within the bounds of the docs array",hvo=t=>`Invalid value for key ${t}`,dvo=t=>`Pattern length exceeds max of ${t}.`,_vo=t=>`Missing ${t} property in key`,mvo=t=>`Property 'weight' in key '${t}' must be a positive integer`,pvo="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.",yvt=Object.prototype.hasOwnProperty;var Ivo=class{constructor(t){this._keys=[],this._keyMap={};let e=0;t.forEach(n=>{const o=Evt(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 Evt(t){let e=null,n=null,o=null,i=1,r=null;if(ZI(t)||VD(t))o=t,e=Bvt(t),n=gne(t);else{if(!yvt.call(t,"name"))throw new Error(_vo("name"));const A=t.name;if(o=A,yvt.call(t,"weight")&&t.weight!==void 0&&(i=t.weight,i<=0))throw new Error(mvo(gne(A)));e=Bvt(A),n=gne(A),r=t.getFn??null}return{path:e,id:n,weight:i,src:o,getFn:r}}function Bvt(t){return VD(t)?t:t.split(".")}function gne(t){return VD(t)?t.join("."):t}function Cvo(t,e){const n=[];let o=!1;const i=(r,A,s,a)=>{if(eE(r))if(!A[s])n.push(a!==void 0?{v:r,i:a}:r);else{const c=r[A[s]];if(!eE(c))return;if(s===A.length-1&&(ZI(c)||cne(c)||lvo(c)||typeof c=="bigint"))n.push(a!==void 0?{v:jMe(c),i:a}:jMe(c));else if(VD(c)){o=!0;for(let l=0,g=c.length;l<g;l+=1)i(c[l],A,s+1,l)}else A.length&&i(c,A,s+1,a)}};return i(t,ZI(e)?e.split("."):e,0),o?n:n[0]}const bA=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:Cvo,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1}});function fvo(t){return t>=9&&t<=13||t===32||t===160}function yvo(t=1,e=3){const n=new Map,o=Math.pow(10,e);return{get(i){let r=0,A=!1;for(let a=0;a<i.length;a++)fvo(i.charCodeAt(a))?A=!1:A||(r++,A=!0);if(r===0&&(r=1),n.has(r))return n.get(r);const s=Math.round(o/Math.pow(r,.5*t))/o;return n.set(r,s),s},clear(){n.clear()}}}var $Me=class{constructor({getFn:t=bA.getFn,fieldNormWeight:e=bA.fieldNormWeight}={}){this.norm=yvo(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(ZI(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(XMe);if(ZI(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(XMe);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 A=i+r>>>1;n[A]<o.i?i=A+1:r=A}o.i-=i}}getValueForItemAtKeyId(t,e){return t[this._keysMap[e]]}size(){return this.records.length}_createStringRecord(t,e){return!eE(t)||lne(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],A=r.getFn?r.getFn(t):this.getFn(t,r.path);if(eE(A)){if(VD(A)){const s=[];for(let a=0,c=A.length;a<c;a+=1){const l=A[a];if(eE(l)){if(ZI(l)){if(!lne(l)){const g={v:l,i:a,n:this.norm.get(l)};s.push(g)}}else if(eE(l.v)){const g=ZI(l.v)?l.v:jMe(l.v);if(!lne(g)){const u={v:g,i:l.i,n:this.norm.get(g)};s.push(u)}}}}n.$[o]=s}else if(ZI(A)&&!lne(A)){const s={v:A,n:this.norm.get(A)};n.$[o]=s}}}return n}toJSON(){return{keys:this.keys.map(({getFn:t,...e})=>e),records:this.records}}};function xvt(t,e,{getFn:n=bA.getFn,fieldNormWeight:o=bA.fieldNormWeight}={}){const i=new $Me({getFn:n,fieldNormWeight:o});return i.setKeys(t.map(Evt)),i.setSources(e),i.create(),i}function Evo(t,{getFn:e=bA.getFn,fieldNormWeight:n=bA.fieldNormWeight}={}){const{keys:o,records:i}=t,r=new $Me({getFn:e,fieldNormWeight:n});return r.setKeys(o),r.setIndexRecords(i),r}function Bvo(t=[],e=bA.minMatchCharLength){const n=[];let o=-1,i=-1,r=0;for(let A=t.length;r<A;r+=1){const s=t[r];s&&o===-1?o=r:!s&&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 xvo(t,e,n,{location:o=bA.location,distance:i=bA.distance,threshold:r=bA.threshold,findAllMatches:A=bA.findAllMatches,minMatchCharLength:s=bA.minMatchCharLength,includeMatches:a=bA.includeMatches,ignoreLocation:c=bA.ignoreLocation}={}){if(e.length>32)throw new Error(dvo(32));const l=e.length,g=t.length,u=Math.max(0,Math.min(o,g));let d=r,h=u;const _=(M,w)=>{const k=M/l;if(c)return k;const N=Math.abs(u-w);return i?k+N/i:N?1:k},p=s>1||a,m=p?Array(g):[];let I;for(;(I=t.indexOf(e,h))>-1;){const M=_(0,I);if(d=Math.min(M,d),h=I+l,p){let w=0;for(;w<l;)m[I+w]=1,w+=1}}h=-1;let C=[],f=1,y=0,B=l+g;const x=1<<l-1;for(let M=0;M<l;M+=1){let w=0,k=B;for(;w<k;)_(M,u+k)<=d?w=k:B=k,k=Math.floor((B-w)/2+w);B=k;let N=Math.max(1,u-k+1);const H=A?g:Math.min(u+k,g)+l,G=Array(H+2);G[H+1]=(1<<M)-1;for(let U=H;U>=N;U-=1){const J=U-1,W=n[t[J]];if(G[U]=(G[U+1]<<1|1)&W,M&&(G[U]|=(C[U+1]|C[U])<<1|1|C[U+1]),G[U]&x&&(f=_(M,J),f<=d)){if(d=f,h=J,y=M,h<=u)break;N=Math.max(1,2*u-h)}}if(_(M+1,u)>d)break;C=G}if(p&&h>=0){const M=Math.min(g-1,h+l-1+y);for(let w=h;w<=M;w+=1)n[t[w]]&&(m[w]=1)}const S={isMatch:h>=0,score:Math.max(.001,f)};if(p){const M=Bvo(m,s);M.length?a&&(S.indices=M):S.isMatch=!1}return S}function Qvo(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 ZMe(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 Qvt={ł:"l",Ł:"L",đ:"d",Đ:"D",ø:"o",Ø:"O",ħ:"h",Ħ:"H",ŧ:"t",Ŧ:"T",ı:"i",ß:"ss"},Svo=new RegExp("["+Object.keys(Qvt).join("")+"]","g"),dO=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(Svo,e=>Qvt[e]):t=>t;var ewe=class{constructor(t,{location:e=bA.location,threshold:n=bA.threshold,distance:o=bA.distance,includeMatches:i=bA.includeMatches,findAllMatches:r=bA.findAllMatches,minMatchCharLength:A=bA.minMatchCharLength,isCaseSensitive:s=bA.isCaseSensitive,ignoreDiacritics:a=bA.ignoreDiacritics,ignoreLocation:c=bA.ignoreLocation}={}){if(this.options={location:e,threshold:n,distance:o,includeMatches:i,findAllMatches:r,minMatchCharLength:A,isCaseSensitive:s,ignoreDiacritics:a,ignoreLocation:c},t=s?t:t.toLowerCase(),t=a?dO(t):t,this.pattern=t,this.chunks=[],!this.pattern.length)return;const l=(u,d)=>{this.chunks.push({pattern:u,alphabet:Qvo(u),startIndex:d})},g=this.pattern.length;if(g>32){let u=0;const d=g%32,h=g-d;for(;u<h;)l(this.pattern.substr(u,32),u),u+=32;if(d){const _=g-32;l(this.pattern.substr(_),_)}}else l(this.pattern,0)}searchIn(t){const{isCaseSensitive:e,ignoreDiacritics:n,includeMatches:o}=this.options;if(t=e?t:t.toLowerCase(),t=n?dO(t):t,this.pattern===t){if(t.length<this.options.minMatchCharLength)return{isMatch:!1,score:1};const h={isMatch:!0,score:0};return o&&(h.indices=[[0,t.length-1]]),h}const{location:i,distance:r,threshold:A,findAllMatches:s,minMatchCharLength:a,ignoreLocation:c}=this.options,l=[];let g=0,u=!1;this.chunks.forEach(({pattern:h,alphabet:_,startIndex:p})=>{const{isMatch:m,score:I,indices:C}=xvo(t,h,_,{location:i+p,distance:r,threshold:A,findAllMatches:s,minMatchCharLength:a,includeMatches:o,ignoreLocation:c});m&&(u=!0),g+=I,m&&C&&l.push(...C)});const d={isMatch:u,score:u?g/this.chunks.length:1};return u&&o&&(d.indices=ZMe(l)),d}};const bvo=new Set(["fuzzy","include"]);function Dvo(t){return t.startsWith("inverse")}const twe=[{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 A=!!i.length;return{isMatch:A,score:A?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 ewe(t,{location:e.location??bA.location,threshold:e.threshold??bA.threshold,distance:e.distance??bA.distance,includeMatches:e.includeMatches??bA.includeMatches,findAllMatches:e.findAllMatches??bA.findAllMatches,minMatchCharLength:e.minMatchCharLength??bA.minMatchCharLength,isCaseSensitive:e.isCaseSensitive??bA.isCaseSensitive,ignoreDiacritics:e.ignoreDiacritics??bA.ignoreDiacritics,ignoreLocation:e.ignoreLocation??bA.ignoreLocation});return{type:"fuzzy",search(o){return n.searchIn(o)}}}}],Svt=twe.length,Mvo="\0",wvo="|";function Pvo(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 bvt(t,e){const n=t.match(e);return n?n[1]:null}function vvo(t,e={}){return t.replace(/\\\|/g,Mvo).split(wvo).map(n=>{const o=Pvo(n.replace(/\u0000/g,"|").trim()).filter(r=>r&&!!r.trim()),i=[];for(let r=0,A=o.length;r<A;r+=1){const s=o[r];let a=!1,c=-1;for(;!a&&++c<Svt;){const l=twe[c],g=bvt(s,l.multiRegex);g&&(i.push(l.create(g,e)),a=!0)}if(!a)for(c=-1;++c<Svt;){const l=twe[c],g=bvt(s,l.singleRegex);if(g){i.push(l.create(g,e));break}}}return i})}var Nvo=class{constructor(t,{isCaseSensitive:e=bA.isCaseSensitive,ignoreDiacritics:n=bA.ignoreDiacritics,includeMatches:o=bA.includeMatches,minMatchCharLength:i=bA.minMatchCharLength,ignoreLocation:r=bA.ignoreLocation,findAllMatches:A=bA.findAllMatches,location:s=bA.location,threshold:a=bA.threshold,distance:c=bA.distance}={}){this.query=null,this.options={isCaseSensitive:e,ignoreDiacritics:n,includeMatches:o,minMatchCharLength:i,findAllMatches:A,ignoreLocation:r,location:s,threshold:a,distance:c},t=e?t:t.toLowerCase(),t=n?dO(t):t,this.pattern=t,this.query=vvo(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?dO(t):t;let r=0;const A=[];let s=0,a=!1;for(let c=0,l=e.length;c<l;c+=1){const g=e[c];A.length=0,r=0,a=!1;for(let u=0,d=g.length;u<d;u+=1){const h=g[u],{isMatch:_,indices:p,score:m}=h.search(t);if(_)r+=1,s+=m,Dvo(h.type)&&(a=!0),n&&(bvo.has(h.type)?A.push(...p):A.push(p));else{s=0,r=0,A.length=0,a=!1;break}}if(r){const u={isMatch:!0,score:s/r};return a&&(u.hasInverse=!0),n&&(u.indices=ZMe(A)),u}}return{isMatch:!1,score:1}}};const nwe=[];function owe(...t){nwe.push(...t)}function une(t,e){for(let n=0,o=nwe.length;n<o;n+=1){const i=nwe[n];if(i.condition(t,e))return new i(t,e)}return new ewe(t,e)}const hne={AND:"$and",OR:"$or"},iwe={PATH:"$path",PATTERN:"$val"},rwe=t=>!!(t[hne.AND]||t[hne.OR]),Rvo=t=>!!t[iwe.PATH],Tvo=t=>!VD(t)&&Cvt(t)&&!rwe(t),Dvt=t=>({[hne.AND]:Object.keys(t).map(e=>({[e]:t[e]}))});function Mvt(t,e,{auto:n=!0}={}){const o=i=>{if(ZI(i)){const a={keyId:null,pattern:i};return n&&(a.searcher=une(i,e)),a}const r=Object.keys(i),A=Rvo(i);if(!A&&r.length>1&&!rwe(i))return o(Dvt(i));if(Tvo(i)){const a=A?i[iwe.PATH]:r[0],c=A?i[iwe.PATTERN]:i[a];if(!ZI(c))throw new Error(hvo(a));const l={keyId:gne(a),pattern:c};return n&&(l.searcher=une(c,e)),l}const s={children:[],operator:r[0]};return r.forEach(a=>{const c=i[a];VD(c)&&c.forEach(l=>{s.children.push(o(l))})}),s};return rwe(t)||(t=Dvt(t)),o(t)}function Awe(t,{ignoreFieldNorm:e=bA.ignoreFieldNorm}){let n=1;return t.forEach(({key:o,norm:i,score:r})=>{const A=o?o.weight:null;n*=Math.pow(r===0&&A?Number.EPSILON:r,(A||1)*(e?1:i))}),n}function kvo(t,{ignoreFieldNorm:e=bA.ignoreFieldNorm}){t.forEach(n=>{n.score=Awe(n.matches,{ignoreFieldNorm:e})})}var Fvo=class{constructor(t,e){this.limit=t,this.heap=[],this.comparator=e}get size(){return this.heap.length}insert(t){this.size<this.limit?(this.heap.push(t),this._bubbleUp(this.size-1)):this.comparator(t,this.heap[0])<0&&(this.heap[0]=t,this._sinkDown(0))}extractSorted(){return this.heap.sort(this.comparator)}_bubbleUp(t){const e=this.heap;for(;t>0;){const n=t-1>>1;if(this.comparator(e[t],e[n])<=0)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&&this.comparator(e[i],e[o])>0&&(o=i),r<n&&this.comparator(e[r],e[o])>0&&(o=r),o!==t){const A=e[t];e[t]=e[o],e[o]=A}}while(o!==t)}};function Lvo(t){const e=[];return t.matches.forEach(n=>{if(!eE(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 Hvo(t,e,{includeMatches:n=bA.includeMatches,includeScore:o=bA.includeScore}={}){return t.map(i=>{const{idx:r}=i,A={item:e[r],refIndex:r};return n&&(A.matches=Lvo(i)),o&&(A.score=i.score),A})}const Gvo=/[\p{L}\p{M}\p{N}_]+/gu,wvt=new WeakSet;function Ovo(t){wvt.has(t)||(wvt.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 Kvo(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||Ovo(t),e=>e.match(t)||[]):e=>e.match(Gvo)||[]}function swe({isCaseSensitive:t=!1,ignoreDiacritics:e=!1,tokenize:n}={}){const o=Kvo(n);return{tokenize(i){return t||(i=i.toLowerCase()),e&&(i=dO(i)),o(i)}}}var Uvo=class{static condition(t,e){return e.useTokenSearch}constructor(t,e){this.options=e,this.analyzer=swe({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 ewe(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 A=o.get(r)||0,s=Math.log(1+(i-A+.5)/(A+.5));this.idfWeights.push(s)}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 A=this.combineAll&&!this.useMask?new Set:null;for(let c=0;c<this.termSearchers.length;c++){const l=this.termSearchers[c].searchIn(t),g=this.idfWeights[c];o+=g,l.isMatch&&(i++,n+=g*(1-l.score),l.indices&&e.push(...l.indices),this.combineAll&&(this.useMask?r|=1<<c:A.add(c)))}if(i===0)return{isMatch:!1,score:1};const s=o>0?1-n/o:0,a={isMatch:!0,score:Math.max(.001,s)};return this.options.includeMatches&&e.length&&(a.indices=ZMe(e)),this.combineAll&&(this.useMask?a.matchedMask=r:a.matchedTerms=A,a.termCount=this.numTerms),a}};function awe(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 A=t.docTermFieldHits.get(n);A||(A=new Map,t.docTermFieldHits.set(n,A));for(const s of r)A.set(s,(A.get(s)||0)+1),t.df.set(s,(t.df.get(s)||0)+1)}function Pvt(t,e,n,o){const{i,v:r,$:A}=e;if(r!==void 0){awe(t,r,i,o);return}if(A)for(let s=0;s<n;s++){const a=A[s];if(a)if(Array.isArray(a))for(const c of a)awe(t,c.v,i,o);else awe(t,a.v,i,o)}}function Yvo(t,e,n){const o={fieldCount:0,df:new Map,docFieldCount:new Map,docTermFieldHits:new Map};for(const i of t)Pvt(o,i,e,n);return o}function Vvo(t,e,n,o){Pvt(t,e,n,o)}function zvo(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 A=(t.df.get(i)||0)-r;A<=0?t.df.delete(i):t.df.set(i,A)}t.docTermFieldHits.delete(e)}}function vvt(t,e){if(e.length===0)return;const n=Array.from(new Set(e)).sort((s,a)=>s-a);for(const s of n)zvo(t,s);const o=s=>{let a=0,c=n.length;for(;a<c;){const l=a+c>>>1;n[l]<s?a=l+1:c=l}return s-a},i=n[0],r=new Map;for(const[s,a]of t.docFieldCount)r.set(s>i?o(s):s,a);t.docFieldCount=r;const A=new Map;for(const[s,a]of t.docTermFieldHits)A.set(s>i?o(s):s,a);t.docTermFieldHits=A}var zD=class{constructor(t,e,n){this.options={...bA,...e},this.options.useExtendedSearch,this.options.useTokenSearch,this._keyStore=new Ivo(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=une(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 $Me))throw new Error(uvo);if(this._myIndex=e||xvt(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight}),this.options.useTokenSearch){const n=swe({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});this._invertedIndex=Yvo(this._myIndex.records,this._myIndex.keys.length,n)}this._invalidateSearcherCache()}add(t){if(!eE(t))return;this._docs.push(t);const e=this._myIndex.add(t,this._docs.length-1);if(this._invertedIndex&&e){const n=swe({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});Vvo(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&&vvt(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(XMe);this._invertedIndex&&vvt(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}_normalizedKeys(){return this._myIndex.keys.map(t=>this._keyStore.get(t.id)||t)}search(t,e){const{limit:n=-1}=e||{},{includeMatches:o,includeScore:i,shouldSort:r,sortFn:A,ignoreFieldNorm:s}=this.options;if(ZI(t)&&!t.trim()){let u=this._docs.map((d,h)=>({item:d,refIndex:h}));return cne(n)&&n>-1&&(u=u.slice(0,n)),u}const a=r&&cne(n)&&n>0&&ZI(t),c=A,l=(u,d)=>c(u,d)||u.idx-d.idx;let g;if(a){const u=new Fvo(n,l);ZI(this._docs[0])?this._searchStringList(t,{heap:u,ignoreFieldNorm:s}):this._searchObjectList(t,{heap:u,ignoreFieldNorm:s}),g=u.extractSorted()}else g=ZI(t)?ZI(this._docs[0])?this._searchStringList(t):this._searchObjectList(t):this._searchLogical(t),kvo(g,{ignoreFieldNorm:s}),r&&g.sort(ZI(t)?l:c),cne(n)&&n>-1&&(g=g.slice(0,n));return Hvo(g,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,A=e?null:[];return r.forEach(({v:s,i:a,n:c})=>{if(!eE(s))return;const l=o.searchIn(s);if(l.isMatch){const g={score:l.score,value:s,norm:c,indices:l.indices};i&&(g.matchedMask=l.matchedMask,g.matchedTerms=l.matchedTerms,g.termCount=l.termCount);const u=[g];if(!i||this._coversAllTokens(u)){const d={item:s,idx:a,matches:u};e?(d.score=Awe(d.matches,{ignoreFieldNorm:n}),e.insert(d)):A.push(d)}}}),A}_searchLogical(t){const e=Mvt(t,this.options),n=this._normalizedKeys(),o=(s,a,c)=>{if(!("children"in s)){const{keyId:d,searcher:h}=s;let _;return d===null?(_=[],n.forEach((p,m)=>{_.push(...this._findMatches({key:p,value:a[m],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:g}=s,u=[];for(let d=0,h=l.length;d<h;d+=1){const _=l[d],p=o(_,a,c);if(p.length)u.push(...p);else if(g===hne.AND)return[]}return u},i=this._myIndex.records,r=new Map,A=[];return i.forEach(({$:s,i:a})=>{if(eE(s)){const c=o(e,s,a);c.length&&(r.has(a)||(r.set(a,{idx:a,item:s,matches:[]}),A.push(r.get(a))),c.forEach(({matches:l})=>{r.get(a).matches.push(...l)}))}}),A}_searchObjectList(t,{heap:e,ignoreFieldNorm:n}={}){const o=this._getSearcher(t),i=this.options.useTokenSearch&&this.options.tokenMatch==="all",{records:r}=this._myIndex,A=this._normalizedKeys(),s=e?null:[];return r.forEach(({$:a,i:c})=>{if(!eE(a))return;const l=[];let g=!1,u=!1;if(A.forEach((d,h)=>{const _=this._findMatches({key:d,value:a[h],searcher:o});_.length?(l.push(..._),_[0].hasInverse&&(u=!0)):g=!0}),!(u&&g)&&l.length&&(!i||this._coversAllTokens(l))){const d={idx:c,item:a,matches:l};e?(d.score=Awe(d.matches,{ignoreFieldNorm:n}),e.insert(d)):s.push(d)}}),s}_findMatches({key:t,value:e,searcher:n}){if(!eE(e))return[];const o=[];if(VD(e))e.forEach(({v:i,i:r,n:A})=>{if(!eE(i))return;const s=n.searchIn(i);if(s.isMatch){const a={score:s.score,key:t,value:i,idx:r,norm:A,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)}});else{const{v:i,n:r}=e,A=n.searchIn(i);if(A.isMatch){const s={score:A.score,key:t,value:i,norm:r,indices:A.indices,hasInverse:A.hasInverse};A.termCount!==void 0&&(s.matchedMask=A.matchedMask,s.matchedTerms=A.matchedTerms,s.termCount=A.termCount),o.push(s)}}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}};zD.version="7.5.0",zD.createIndex=xvt,zD.parseIndex=Evo,zD.config=bA,zD.match=function(t,e,n){if(n&&n.useTokenSearch)throw new Error(pvo);return une(t,{...bA,...n}).searchIn(e)},zD.parseQuery=Mvt,owe(Nvo),owe(Uvo),zD.use=function(...t){t.forEach(e=>owe(e))};var Jvo=zD;const qvo="https://kicad-mod-cache.tscircuit.com";let cwe=null,_O=null,lwe=null;const Wvo=async()=>cwe||_O||(_O=fetch("https://kicad-mod-cache.tscircuit.com/kicad_files.json").then(t=>t.json()).then(t=>(cwe=t,_O=null,t)),_O),jvo=async(t,e=20)=>{const n=await Wvo();return lwe||(lwe=new Jvo(n)),lwe.search(t).slice(0,e).map(o=>o.item)},Xvo=t=>{const e=t.replace(".pretty/","/").replace(".kicad_mod",""),n=`kicad:${e}`;return{path:t,qualifiedName:n,description:e}},$vo=t=>t.replace(/^\/+/,"").split("/").map(e=>encodeURIComponent(e)).join("/"),Zvo=async t=>{const e=await fetch(`${qvo}/${$vo(t)}`);if(!e.ok)throw new Error(`KiCad footprint fetch failed: ${e.status}`);const n=await e.text(),{KicadFootprintToCircuitJsonConverter:o}=await FB("kicad-to-circuit-json"),i=new o;return i.addFile(t.split("/").pop()??"selected-footprint.kicad_mod",n),i.runUntilFinished(),i.getOutput()},Nvt=t=>t?.source==="jlcpcb"||t?.source==="kicad",e6o=async(t,e)=>{if(t.source==="jlcpcb")return avo(t.component.partNumber,e?.jlcpcb);if(t.source==="kicad")return Zvo(t.footprint.path);throw new Error("Footprint preview is not available for this source")},t6o=({query:t,placeholder:e,isSearching:n,onQueryChange:o,onSubmit:i})=>{const r=j.useCallback(A=>{A.key==="Enter"&&(A.preventDefault(),i())},[i]);return V.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2 rf-mt-4",children:[V.jsxs("div",{className:"rf-relative rf-flex-grow",children:[V.jsx(X4e,{className:"rf-absolute rf-left-2 rf-top-2.5 rf-h-4 rf-w-4 rf-text-muted-foreground"}),V.jsx(_De,{placeholder:e,className:"rf-pl-8",spellCheck:!1,autoComplete:"off",value:t,onChange:A=>o(A.target.value),onKeyDown:r})]}),V.jsx(Vs,{onClick:i,disabled:n||t.trim().length<1,className:"sm:rf-px-4 rf-px-3",children:n?V.jsx(RB,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):V.jsxs(V.Fragment,{children:[V.jsx(X4e,{className:"rf-h-4 rf-w-4 sm:rf-hidden"}),V.jsx("span",{className:"rf-hidden sm:rf-inline",children:"Search"})]})})]})},n6o=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}),o6o=t=>n6o.format(t),Rvt=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"}},i6o=t=>{switch(t.source){case"tscircuit.com":return t.package.unscoped_name;case"jlcpcb":return t.component.isDirectLookup?t.component.partNumber:t.component.manufacturer;case"kicad":return t.footprint.qualifiedName}},r6o=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}},A6o=t=>{switch(t.source){case"tscircuit.com":return t.package.name;case"jlcpcb":return t.component.isDirectLookup?void 0:t.component.partNumber;case"kicad":return}},s6o=({results:t,selected:e,onSelect:n,onShowDetails:o})=>{const i=e?Rvt(e):null;return V.jsx("div",{className:"rf-divide-y rf-w-full rf-overflow-hidden",children:t.map(r=>{const A=Rvt(r),s=i===A,a=i6o(r),c=r6o(r),l=A6o(r),g=r.source==="jlcpcb"?r.component.stock:null,u=r.source==="jlcpcb"?r.component.price:null,d=r.source==="jlcpcb"?r.component.isBasic:null,h=r.source==="jlcpcb"?r.component.isDirectLookup:!1;return V.jsxs("div",{className:`rf-p-3 rf-flex rf-flex-col sm:rf-grid sm:rf-grid-cols-[minmax(0,1fr)_auto] rf-items-start sm:rf-items-center rf-cursor-pointer hover:rf-bg-zinc-100 rf-gap-2 rf-overflow-hidden ${s?"rf-bg-zinc-100":""}`,onClick:()=>n(r),children:[V.jsxs("div",{className:"rf-min-w-0 rf-overflow-hidden rf-w-full",children:[V.jsxs("div",{className:"rf-flex rf-items-start rf-gap-2 rf-min-w-0",children:[V.jsxs("div",{className:"rf-font-medium rf-text-sm rf-truncate rf-flex-1 rf-min-w-0 rf-flex rf-items-center rf-gap-1.5",children:[a,r.source==="jlcpcb"&&d!=null&&V.jsx("span",{className:`rf-text-xs rf-px-1.5 rf-py-0.5 rf-rounded rf-font-medium rf-flex-shrink-0 ${d?"rf-bg-green-100 rf-text-green-700":"rf-bg-orange-100 rf-text-orange-700"}`,children:d?"Basic":"Extended"}),h&&V.jsx("span",{className:"rf-text-xs rf-px-1.5 rf-py-0.5 rf-rounded rf-font-medium rf-flex-shrink-0 rf-bg-blue-100 rf-text-blue-700",children:"Direct lookup"}),r.source==="tscircuit.com"&&r.package.is_private&&V.jsx(jIo,{className:"rf-ml-1 rf-h-3 rf-w-3 rf-text-zinc-400 rf-flex-shrink-0"})]}),r.source==="jlcpcb"&&g!=null?V.jsxs("div",{className:"rf-text-xs rf-text-zinc-500 rf-font-medium rf-whitespace-nowrap rf-flex-shrink-0 sm:rf-hidden",children:[g.toLocaleString()," in stock"]}):null]}),V.jsxs("div",{className:"rf-text-xs rf-text-zinc-500 rf-truncate rf-w-full",children:[l?V.jsx("span",{className:"rf-mr-2",children:l}):null,c]})]}),V.jsxs("div",{children:[r.source==="tscircuit.com"&&o?V.jsx("div",{className:"rf-flex-shrink-0 rf-w-full sm:rf-w-auto",children:V.jsx(Vs,{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"&&g!=null?V.jsxs("div",{className:"rf-hidden sm:rf-block rf-text-xs rf-text-zinc-500 rf-font-medium rf-whitespace-nowrap rf-flex-shrink-0",children:[g.toLocaleString()," in stock"]}):null,u!=null&&V.jsx("div",{className:"rf-hidden sm:rf-block rf-text-xs rf-text-zinc-500 rf-font-medium rf-whitespace-nowrap rf-flex-shrink-0 rf-text-right",children:o6o(u)})]})]},A)})})},a6o=({circuitJson:t,error:e,isLoading:n,height:o})=>V.jsx("section",{className:"rf-flex rf-min-w-0 rf-items-center rf-justify-center",style:{height:o},children:n?V.jsxs("div",{className:"rf-flex rf-w-full rf-items-center rf-justify-center rf-gap-2 rf-bg-zinc-950 rf-text-sm rf-text-zinc-300",style:{height:o},children:[V.jsx(RB,{className:"rf-h-4 rf-w-4 rf-animate-spin"}),"Loading preview..."]}):e?V.jsx("div",{className:"rf-flex rf-w-full rf-items-center rf-justify-center rf-bg-zinc-950 rf-p-4",style:{height:o},children:V.jsxs("div",{className:"rf-flex rf-max-w-[320px] rf-items-start rf-gap-2 rf-text-sm rf-text-zinc-300",children:[V.jsx(SQt,{className:"rf-mt-0.5 rf-h-4 rf-w-4 rf-flex-shrink-0"}),V.jsx("span",{children:e})]})}):t?V.jsx("div",{className:"rf-w-full rf-min-w-0 rf-overflow-hidden",children:V.jsx(B3t,{circuitJson:t,height:o,allowEditing:!1,clickToInteractEnabled:!1,focusOnHover:!1,disablePcbGroups:!0})}):V.jsx("div",{className:"rf-flex rf-w-full rf-items-center rf-justify-center rf-bg-zinc-950 rf-text-sm rf-text-zinc-300",style:{height:o},children:"No preview"})}),Tvt={importComponentDialog:101,importComponentDetailsDialog:102},c6o=({packageResult:t,isOpen:e,onOpenChange:n,isLoading:o,details:i,previewTab:r,onPreviewTabChange:A,isSubmitting:s,onImport:a})=>{const c=t?.package??null,l=c?.latest_pcb_preview_image_url,g=c?.latest_sch_preview_image_url,u=c?.latest_cad_preview_image_url,d=c?.unscoped_name?.split("/").pop()??c?.unscoped_name,h=c?.org_owner_tscircuit_handle??void 0,_=h?`https://tscircuit.com/${h}`:void 0,p=h&&d?`https://tscircuit.com/${h}/${d}`:void 0;return V.jsx(PN,{open:e,onOpenChange:n,children:V.jsxs(f3,{showOverlay:!1,style:{width:"calc(100vw - 2rem)",zIndex:Tvt.importComponentDetailsDialog},className:"rf-max-w-5xl no-scrollbar !rf-overflow-y-auto rf-max-h-[90vh] rf-overflow-hidden rf-flex rf-flex-col rf-rounded-sm",children:[V.jsx(y3,{className:"rf-pb-4 rf-border-b",children:V.jsx("div",{className:"rf-flex rf-items-start rf-justify-between rf-gap-4",children:V.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[V.jsx(E3,{className:"rf-text-xl rf-font-semibold rf-truncate",children:d}),V.jsx(vN,{children:c?.description})]})})}),V.jsxs("div",{className:"rf-flex-1 rf-overflow-y-auto rf-py-4 rf-space-y-6",children:[h?V.jsxs("div",{children:[V.jsx("span",{className:"rf-text-xs rf-font-medium rf-text-gray-500 rf-uppercase rf-tracking-wide",children:"Created by"}),V.jsx("div",{className:"rf-mt-1 rf-text-sm rf-font-medium",children:_?V.jsx("a",{href:_,target:"_blank",rel:"noopener noreferrer",className:"rf-text-black hover:rf-underline",children:h}):h})]}):null,(u||l||g)&&V.jsx(V.Fragment,{children:V.jsxs("div",{children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Preview"}),V.jsxs(TIe,{value:r,onValueChange:m=>A(m),children:[V.jsxs(xX,{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:[l&&V.jsx(Zx,{value:"pcb",children:"PCB"}),g&&V.jsx(Zx,{value:"schematic",children:"Schematic"}),u&&V.jsx(Zx,{value:"3d",children:"3D"})]}),V.jsxs("div",{className:"rf-mt-4",children:[V.jsx(OI,{value:"pcb",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:l?V.jsx("img",{src:l,alt:`${d??"package"} PCB preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null}),V.jsx(OI,{value:"schematic",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:g?V.jsx("img",{src:g,alt:`${d??"package"} schematic preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null}),V.jsx(OI,{value:"3d",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:u?V.jsx("img",{src:u,alt:`${d??"package"} 3D preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null})]})]})]})}),i?.ai_description?V.jsxs("section",{children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-3",children:"AI Description"}),V.jsx("div",{className:"rf-bg-gray-50 rf-border rf-border-gray-200 rf-rounded-lg rf-p-4",children:V.jsx("p",{className:"rf-text-sm rf-text-gray-700 rf-leading-relaxed",children:i.ai_description})})]}):null,i?.ai_usage_instructions?V.jsxs("section",{children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-3",children:"Usage Instructions"}),V.jsx("div",{className:"rf-bg-gray-50 rf-border rf-border-gray-200 rf-rounded-lg rf-p-4",children:V.jsx("p",{className:"rf-text-sm rf-text-gray-700 rf-leading-relaxed rf-whitespace-pre-wrap",children:i.ai_usage_instructions})})]}):null,o?V.jsxs("div",{className:"rf-flex rf-justify-center rf-items-center rf-gap-2 rf-text-gray-500",children:[V.jsx(RB,{className:"rf-h-4 rf-w-4 rf-animate-spin"}),V.jsx("span",{className:"rf-text-sm",children:"Loading package details..."})]}):null]}),V.jsxs(hO,{className:"rf-pt-4 rf-border-t rf-flex rf-flex-col sm:rf-flex-row rf-justify-between rf-gap-2",children:[V.jsx("div",{className:"rf-flex-1",children:p?V.jsxs(Vs,{variant:"outline",size:"sm",className:"rf-gap-2 rf-w-full sm:rf-w-auto",onClick:()=>window.open(p,"_blank"),children:[V.jsx(UIo,{className:"rf-h-4 rf-w-4"}),"View on tscircuit.com"]}):null}),V.jsxs("div",{className:"rf-flex rf-flex-col sm:rf-flex-row rf-gap-2",children:[V.jsx(Vs,{variant:"outline",onClick:()=>n(!1),className:"rf-order-2 sm:rf-order-1",children:"Close"}),V.jsx(Vs,{onClick:a,disabled:s,className:"rf-bg-blue-600 hover:rf-bg-blue-700",children:s?V.jsx(RB,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):"Import Component"})]})]})]})})},l6o=()=>{const[t,e]=j.useState(null),[n,o]=j.useState(!1),i=j.useCallback(async(A,s)=>{o(!0);try{const a=await fetch(`https://api.tscircuit.com/packages/get?name=${encodeURIComponent(`${A}/${s}`)}`);if(!a.ok)throw new Error(`Failed to load package details: ${a.status}`);const c=await a.json();e(c.package??null)}catch(a){console.error("Failed to fetch package details",a),e(null)}finally{o(!1)}},[]),r=j.useCallback(()=>{e(null),o(!1)},[]);return{details:t,isLoading:n,fetchDetails:i,reset:r}},g6o=(t,e)=>{const[n,o]=j.useState({circuitJson:null,error:null,isLoading:!1});return j.useEffect(()=>{if(!t||!Nvt(t)){o({circuitJson:null,error:null,isLoading:!1});return}let i=!1;return o({circuitJson:null,error:null,isLoading:!0}),e6o(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},u6o=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??[]},h6o=({sessionToken:t})=>{const[e,n]=j.useState([]),[o,i]=j.useState(!1),[r,A]=j.useState(null),[s,a]=j.useState(!1),c=j.useCallback(async g=>{const u=g.trim();if(!u)return[];i(!0),A(null);try{const h=(await u6o(u,t)).map(_=>({source:"tscircuit.com",package:_}));return n(h),h}catch(d){return console.error("Error searching tscircuit packages",d),n([]),A(d instanceof Error?d.message:"Failed to search tscircuit packages"),[]}finally{i(!1),a(!0)}},[t]),l=j.useCallback(()=>{n([]),i(!1),A(null),a(!1)},[]);return{results:e,isSearching:o,error:r,hasSearched:s,search:c,reset:l}},d6o=t=>{const e=/^C(\d+)$/i.exec(t.trim());if(!e)return null;const n=Number(e[1]);if(!Number.isSafeInteger(n))return null;const o=`C${e[1]}`;return{source:"jlcpcb",component:{lcscId:n,manufacturer:o,partNumber:o,description:"Import directly from EasyEDA; stock and availability are unknown",package:"",isDirectLookup:!0}}},kvt=(t,e)=>{const n=d6o(t);return n?e.some(i=>i.component.partNumber.toUpperCase()===n.component.partNumber)?e:[n,...e]:e},_6o=t=>{const e=t.trim();return/^C\d+/i.test(e)?e.replace(/^C/i,""):e},m6o=()=>{const[t,e]=j.useState([]),[n,o]=j.useState(!1),[i,r]=j.useState(null),[A,s]=j.useState(!1),a=j.useCallback(async l=>{const g=_6o(l);if(!g)return[];o(!0),r(null);try{const u=await rvo(g,10),d=kvt(l,u.map(h=>({source:"jlcpcb",component:Avo(h)})));return e(d),d}catch(u){console.error("Error searching JLCPCB components",u);const d=kvt(l,[]);return e(d),r(d.length>0?null:u instanceof Error?u.message:"Failed to search JLCPCB components"),d}finally{o(!1),s(!0)}},[]),c=j.useCallback(()=>{e([]),o(!1),r(null),s(!1)},[]);return{results:t,isSearching:n,error:i,hasSearched:A,search:a,reset:c}},p6o=()=>{const[t,e]=j.useState([]),[n,o]=j.useState(!1),[i,r]=j.useState(null),[A,s]=j.useState(!1),a=j.useCallback(async l=>{const g=l.trim();if(!g)return[];o(!0),r(null);try{const d=(await jvo(g,20)).map(h=>({source:"kicad",footprint:Xvo(h)}));return e(d),d}catch(u){return console.error("Error searching KiCad footprints",u),e([]),r(u instanceof Error?u.message:"Failed to search KiCad footprints"),[]}finally{o(!1),s(!0)}},[]),c=j.useCallback(()=>{e([]),o(!1),r(null),s(!1)},[]);return{results:t,isSearching:n,error:i,hasSearched:A,search:a,reset:c}},I6o=({onTscircuitPackageSelected:t,onJlcpcbComponentTsxLoaded:e,onKicadStringSelected:n})=>{const o=[];return t&&o.push("tscircuit.com"),e&&o.push("jlcpcb"),n&&o.push("kicad"),o},C6o=({isOpen:t,onClose:e,jlcpcbProxyRequestHeaders:n,onKicadStringSelected:o,onTscircuitPackageSelected:i,onJlcpcbComponentTsxLoaded:r,jlcpcbProxyApiBase:A,tscircuitSessionToken:s})=>{Zte();const a=j.useMemo(()=>I6o({onKicadStringSelected:o,onTscircuitPackageSelected:i,onJlcpcbComponentTsxLoaded:r}),[o,i,r]),c=a.length>0,l=a.length===1,[g,u]=j.useState(a[0]??"tscircuit.com"),[d,h]=j.useState(""),[_,p]=j.useState(null),{results:m,isSearching:I,error:C,hasSearched:f,search:y,reset:B}=h6o({sessionToken:s}),{results:x,isSearching:S,error:M,hasSearched:w,search:k,reset:N}=m6o(),{results:H,isSearching:G,error:U,hasSearched:J,search:W,reset:X}=p6o(),{details:oe,isLoading:ce,fetchDetails:ee,reset:ie}=l6o(),[ae,re]=j.useState(null),[le,ye]=j.useState(!1),[xe,be]=j.useState("pcb"),[he,Se]=j.useState(null),[Ie,Ge]=j.useState(!1),Je=j.useMemo(()=>({jlcpcb:{headers:n,apiBase:A}}),[A,n]),{circuitJson:Ze,error:pe,isLoading:et}=g6o(_,Je),Le=Nvt(_);j.useEffect(()=>{Se(null)},[_]);const Pe=j.useCallback(()=>{B(),N(),X(),p(null)},[N,X,B]);j.useEffect(()=>{t||(Pe(),h(""),ye(!1),re(null),Se(null))},[t,Pe]),j.useEffect(()=>{h(""),p(null),g==="tscircuit.com"?B():g==="jlcpcb"?N():g==="kicad"&&X()},[g,N,X,B]);const Ue=ct=>{p(ct),re(ct),be("pcb"),ye(!0),ie();const ft=ct.package.org_owner_tscircuit_handle,Dt=ct.package.unscoped_name;if(ft&&Dt){const Ct=Dt.split("/").pop()??Dt;ee(ft,Ct)}},Ne=async()=>{d.trim()&&(p(null),g==="tscircuit.com"?await y(d):g==="jlcpcb"?await k(d):g==="kicad"&&await W(d))},Ee=async ct=>{try{if(Se(null),Ge(!0),ct.source==="kicad"){if(!o)throw new Error("KiCad handler not provided");await o({result:ct,footprint:ct.footprint.qualifiedName})}else if(ct.source==="jlcpcb"){if(!r)throw new Error("JLCPCB handler not provided");const ft=await svo(ct.component.partNumber,{headers:n,apiBase:A});await r({result:ct,tsx:ft})}else if(ct.source==="tscircuit.com"){if(!i)throw new Error("tscircuit package handler not provided");const ft=ct.package.org_owner_tscircuit_handle,Dt=ct.package.unscoped_name;if(!ft||!Dt)throw new Error("Missing package metadata");const Ct=Dt.split("/").pop()??Dt,Nt=`@tsci/${ft}.${Ct}`;await i({result:ct,fullPackageName:Nt})}return!0}catch(ft){return console.error("Failed to import component",ft),Se(ft instanceof Error?ft.message:"Failed to import component"),!1}finally{Ge(!1)}};let Oe=[],we=!1,Ve=null,je=!1;g==="tscircuit.com"?(Oe=m,we=I,Ve=C,je=f):g==="jlcpcb"?(Oe=x,we=S,Ve=M,je=w):g==="kicad"&&(Oe=H,we=G,Ve=U,je=J);const At=async()=>{if(!_)return;await Ee(_)&&(e(),Pe(),h(""))},at=ct=>{ct||e()},gt=ct=>{ye(ct),ct||re(null)};return V.jsxs(PN,{open:t,onOpenChange:at,children:[V.jsxs(f3,{style:{width:"calc(100vw - 2rem)",maxWidth:Le?"min(1120px, calc(100vw - 2rem))":"min(672px, calc(100vw - 2rem))",zIndex:Tvt.importComponentDialog},className:"rf-rounded-sm rf-max-h-[90vh] rf-overflow-y-auto rf-overflow-x-hidden rf-flex rf-flex-col",children:[V.jsxs(y3,{children:[V.jsxs(E3,{className:"rf-text-lg sm:rf-text-xl",children:["Import ",l?ane[g].label:""," ","Component"]}),V.jsx(vN,{className:"rf-text-sm",children:c?"Search for components from available sources.":"Import options are disabled because no handlers were provided."})]}),c?V.jsxs(TIe,{value:g,onValueChange:ct=>u(ct),className:"rf-min-w-0 rf-w-full",children:[!l&&V.jsx(xX,{className:"rf-flex rf-w-full rf-gap-2",children:a.map(ct=>V.jsx(Zx,{value:ct,className:"rf-flex-1 rf-text-xs sm:rf-text-sm",children:ane[ct].label},ct))}),V.jsxs("div",{className:"rf-min-w-0",style:Le?{display:"grid",gridTemplateColumns:"minmax(0, 1fr) minmax(360px, 0.95fr)",gap:"1.5rem",alignItems:"start"}:void 0,children:[V.jsxs("div",{className:"rf-min-w-0",children:[V.jsx(t6o,{query:d,placeholder:ane[g].placeholder,isSearching:we,onQueryChange:h,onSubmit:Ne}),V.jsx("div",{className:"no-scrollbar rf-mt-4 rf-flex-1 rf-min-h-[200px] !rf-max-h-[40vh] !rf-overflow-y-auto rf-overflow-x-hidden rf-border rf-rounded-md rf-min-w-0",children:we?V.jsxs("div",{className:"rf-p-8 rf-text-center rf-text-zinc-500",children:[V.jsx(RB,{className:"rf-h-8 rf-w-8 rf-animate-spin rf-mx-auto rf-mb-2"}),V.jsx("p",{children:"Searching..."})]}):Oe.length>0?V.jsx(s6o,{results:Oe,selected:_,onSelect:p,onShowDetails:g==="tscircuit.com"?Ue:void 0}):V.jsx("div",{className:"rf-p-8 rf-text-center rf-text-zinc-500",children:Ve?`Error: ${Ve}`:je?ane[g].emptyMessage:"Enter a search term to find components"})})]}),Le?V.jsx("div",{className:"rf-mt-4",children:V.jsx(a6o,{circuitJson:Ze,error:pe,isLoading:et,height:325})}):null]})]}):null,he?V.jsx("div",{className:"rf-text-sm rf-text-red-600 rf-mt-2",children:he}):null,V.jsxs(hO,{className:"rf-flex rf-flex-col sm:rf-flex-row rf-gap-2",children:[V.jsx(Vs,{variant:"outline",onClick:e,className:"rf-order-2 sm:rf-order-1",children:"Cancel"}),V.jsx(Vs,{onClick:At,disabled:!_||Ie,className:"rf-order-1 sm:rf-order-2",children:Ie?V.jsx(RB,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):"Import"})]})]}),V.jsx(c6o,{packageResult:ae,isOpen:le,onOpenChange:gt,isLoading:ce,details:oe,previewTab:xe,onPreviewTabChange:ct=>be(ct),isSubmitting:Ie,onImport:()=>{ae&&Ee(ae).then(ct=>{ct&&(ye(!1),e(),Pe(),h(""))})}})]})},f6o=t=>{const e=t.match(/export const (\w+) =/);if(!e)throw new Error("Could not determine component name from TSX contents");return e[1]},Fvt=t=>{const e=w0(A=>A.pushEvent),n=w0(A=>A.upsertFile),o=async({result:A,fullPackageName:s})=>{const c=A.package.unscoped_name??A.package.name;await GA.promise(e({event_type:"INSTALL_PACKAGE",full_package_name:s}),{loading:`Requesting install for "${c}"`,success:`Install requested for "${c}"`,error:l=>`Failed to request install: ${l instanceof Error?l.message:String(l)}`})},i=async({footprint:A})=>{await GA.promise(navigator.clipboard.writeText(A),{loading:`Copying "${A}"`,success:`Copied "${A}" to clipboard`,error:s=>`Failed to copy footprint: ${s instanceof Error?s.message:String(s)}`})},r=async({result:A,tsx:s})=>{const c=`imports/${f6o(s)}.tsx`;await GA.promise(n(c,s),{loading:`Importing ${A.component.partNumber}`,success:`Imported to "${c}"`,error:l=>`Failed to import component: ${l instanceof Error?l.message:String(l)}`})};return V.jsx(C6o,{...t,onTscircuitPackageSelected:o,onKicadStringSelected:i,onJlcpcbComponentTsxLoaded:r})};Fvt.displayName="ImportComponentDialogForCli";var gwe={exports:{}},Lvt;function y6o(){return Lvt||(Lvt=1,(function(t,e){var n={env:{},version:""};(function(o){t.exports=o()})(function(){return(function o(i,r,A){function s(l,g){if(!r[l]){if(!i[l]){var u=typeof y4=="function"&&y4;if(!g&&u)return u(l,!0);if(a)return a(l,!0);var d=new Error("Cannot find module '"+l+"'");throw d.code="MODULE_NOT_FOUND",d}var h=r[l]={exports:{}};i[l][0].call(h.exports,function(_){var p=i[l][1][_];return s(p||_)},h,h.exports,o,i,r,A)}return r[l].exports}for(var a=typeof y4=="function"&&y4,c=0;c<A.length;c++)s(A[c]);return s})({1:[function(o,i,r){var A=o("./utils"),s=o("./support"),a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";r.encode=function(c){for(var l,g,u,d,h,_,p,m=[],I=0,C=c.length,f=C,y=A.getTypeOf(c)!=="string";I<c.length;)f=C-I,u=y?(l=c[I++],g=I<C?c[I++]:0,I<C?c[I++]:0):(l=c.charCodeAt(I++),g=I<C?c.charCodeAt(I++):0,I<C?c.charCodeAt(I++):0),d=l>>2,h=(3&l)<<4|g>>4,_=1<f?(15&g)<<2|u>>6:64,p=2<f?63&u:64,m.push(a.charAt(d)+a.charAt(h)+a.charAt(_)+a.charAt(p));return m.join("")},r.decode=function(c){var l,g,u,d,h,_,p=0,m=0,I="data:";if(c.substr(0,I.length)===I)throw new Error("Invalid base64 input, it looks like a data url.");var C,f=3*(c=c.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(c.charAt(c.length-1)===a.charAt(64)&&f--,c.charAt(c.length-2)===a.charAt(64)&&f--,f%1!=0)throw new Error("Invalid base64 input, bad content length.");for(C=s.uint8array?new Uint8Array(0|f):new Array(0|f);p<c.length;)l=a.indexOf(c.charAt(p++))<<2|(d=a.indexOf(c.charAt(p++)))>>4,g=(15&d)<<4|(h=a.indexOf(c.charAt(p++)))>>2,u=(3&h)<<6|(_=a.indexOf(c.charAt(p++))),C[m++]=l,h!==64&&(C[m++]=g),_!==64&&(C[m++]=u);return C}},{"./support":30,"./utils":32}],2:[function(o,i,r){var A=o("./external"),s=o("./stream/DataWorker"),a=o("./stream/Crc32Probe"),c=o("./stream/DataLengthProbe");function l(g,u,d,h,_){this.compressedSize=g,this.uncompressedSize=u,this.crc32=d,this.compression=h,this.compressedContent=_}l.prototype={getContentWorker:function(){var g=new s(A.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new c("data_length")),u=this;return g.on("end",function(){if(this.streamInfo.data_length!==u.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),g},getCompressedWorker:function(){return new s(A.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},l.createWorkerFrom=function(g,u,d){return g.pipe(new a).pipe(new c("uncompressedSize")).pipe(u.compressWorker(d)).pipe(new c("compressedSize")).withStreamInfo("compression",u)},i.exports=l},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(o,i,r){var A=o("./stream/GenericWorker");r.STORE={magic:"\0\0",compressWorker:function(){return new A("STORE compression")},uncompressWorker:function(){return new A("STORE decompression")}},r.DEFLATE=o("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(o,i,r){var A=o("./utils"),s=(function(){for(var a,c=[],l=0;l<256;l++){a=l;for(var g=0;g<8;g++)a=1&a?3988292384^a>>>1:a>>>1;c[l]=a}return c})();i.exports=function(a,c){return a!==void 0&&a.length?A.getTypeOf(a)!=="string"?(function(l,g,u,d){var h=s,_=d+u;l^=-1;for(var p=d;p<_;p++)l=l>>>8^h[255&(l^g[p])];return-1^l})(0|c,a,a.length,0):(function(l,g,u,d){var h=s,_=d+u;l^=-1;for(var p=d;p<_;p++)l=l>>>8^h[255&(l^g.charCodeAt(p))];return-1^l})(0|c,a,a.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 A=null;A=typeof Promise<"u"?Promise:o("lie"),i.exports={Promise:A}},{lie:37}],7:[function(o,i,r){var A=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",s=o("pako"),a=o("./utils"),c=o("./stream/GenericWorker"),l=A?"uint8array":"array";function g(u,d){c.call(this,"FlateWorker/"+u),this._pako=null,this._pakoAction=u,this._pakoOptions=d,this.meta={}}r.magic="\b\0",a.inherits(g,c),g.prototype.processChunk=function(u){this.meta=u.meta,this._pako===null&&this._createPako(),this._pako.push(a.transformTo(l,u.data),!1)},g.prototype.flush=function(){c.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},g.prototype.cleanUp=function(){c.prototype.cleanUp.call(this),this._pako=null},g.prototype._createPako=function(){this._pako=new s[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var u=this;this._pako.onData=function(d){u.push({data:d,meta:u.meta})}},r.compressWorker=function(u){return new g("Deflate",u)},r.uncompressWorker=function(){return new g("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(o,i,r){function A(h,_){var p,m="";for(p=0;p<_;p++)m+=String.fromCharCode(255&h),h>>>=8;return m}function s(h,_,p,m,I,C){var f,y,B=h.file,x=h.compression,S=C!==l.utf8encode,M=a.transformTo("string",C(B.name)),w=a.transformTo("string",l.utf8encode(B.name)),k=B.comment,N=a.transformTo("string",C(k)),H=a.transformTo("string",l.utf8encode(k)),G=w.length!==B.name.length,U=H.length!==k.length,J="",W="",X="",oe=B.dir,ce=B.date,ee={crc32:0,compressedSize:0,uncompressedSize:0};_&&!p||(ee.crc32=h.crc32,ee.compressedSize=h.compressedSize,ee.uncompressedSize=h.uncompressedSize);var ie=0;_&&(ie|=8),S||!G&&!U||(ie|=2048);var ae=0,re=0;oe&&(ae|=16),I==="UNIX"?(re=798,ae|=(function(ye,xe){var be=ye;return ye||(be=xe?16893:33204),(65535&be)<<16})(B.unixPermissions,oe)):(re=20,ae|=(function(ye){return 63&(ye||0)})(B.dosPermissions)),f=ce.getUTCHours(),f<<=6,f|=ce.getUTCMinutes(),f<<=5,f|=ce.getUTCSeconds()/2,y=ce.getUTCFullYear()-1980,y<<=4,y|=ce.getUTCMonth()+1,y<<=5,y|=ce.getUTCDate(),G&&(W=A(1,1)+A(g(M),4)+w,J+="up"+A(W.length,2)+W),U&&(X=A(1,1)+A(g(N),4)+H,J+="uc"+A(X.length,2)+X);var le="";return le+=`
5787
5787
  \0`,le+=A(ie,2),le+=x.magic,le+=A(f,2),le+=A(y,2),le+=A(ee.crc32,4),le+=A(ee.compressedSize,4),le+=A(ee.uncompressedSize,4),le+=A(M.length,2),le+=A(J.length,2),{fileRecord:u.LOCAL_FILE_HEADER+le+M+J,dirRecord:u.CENTRAL_FILE_HEADER+A(re,2)+le+A(N.length,2)+"\0\0\0\0"+A(ae,4)+A(m,4)+M+J+N}}var a=o("../utils"),c=o("../stream/GenericWorker"),l=o("../utf8"),g=o("../crc32"),u=o("../signature");function d(h,_,p,m){c.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=_,this.zipPlatform=p,this.encodeFileName=m,this.streamFiles=h,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}a.inherits(d,c),d.prototype.push=function(h){var _=h.meta.percent||0,p=this.entriesCount,m=this._sources.length;this.accumulate?this.contentBuffer.push(h):(this.bytesWritten+=h.data.length,c.prototype.push.call(this,{data:h.data,meta:{currentFile:this.currentFile,percent:p?(_+100*(p-m-1))/p:100}}))},d.prototype.openedSource=function(h){this.currentSourceOffset=this.bytesWritten,this.currentFile=h.file.name;var _=this.streamFiles&&!h.file.dir;if(_){var p=s(h,_,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:p.fileRecord,meta:{percent:0}})}else this.accumulate=!0},d.prototype.closedSource=function(h){this.accumulate=!1;var _=this.streamFiles&&!h.file.dir,p=s(h,_,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(p.dirRecord),_)this.push({data:(function(m){return u.DATA_DESCRIPTOR+A(m.crc32,4)+A(m.compressedSize,4)+A(m.uncompressedSize,4)})(h),meta:{percent:100}});else for(this.push({data:p.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},d.prototype.flush=function(){for(var h=this.bytesWritten,_=0;_<this.dirRecords.length;_++)this.push({data:this.dirRecords[_],meta:{percent:100}});var p=this.bytesWritten-h,m=(function(I,C,f,y,B){var x=a.transformTo("string",B(y));return u.CENTRAL_DIRECTORY_END+"\0\0\0\0"+A(I,2)+A(I,2)+A(C,4)+A(f,4)+A(x.length,2)+x})(this.dirRecords.length,p,h,this.zipComment,this.encodeFileName);this.push({data:m,meta:{percent:100}})},d.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},d.prototype.registerPrevious=function(h){this._sources.push(h);var _=this;return h.on("data",function(p){_.processChunk(p)}),h.on("end",function(){_.closedSource(_.previous.streamInfo),_._sources.length?_.prepareNextSource():_.end()}),h.on("error",function(p){_.error(p)}),this},d.prototype.resume=function(){return!!c.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},d.prototype.error=function(h){var _=this._sources;if(!c.prototype.error.call(this,h))return!1;for(var p=0;p<_.length;p++)try{_[p].error(h)}catch{}return!0},d.prototype.lock=function(){c.prototype.lock.call(this);for(var h=this._sources,_=0;_<h.length;_++)h[_].lock()},i.exports=d},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(o,i,r){var A=o("../compressions"),s=o("./ZipFileWorker");r.generateWorker=function(a,c,l){var g=new s(c.streamFiles,l,c.platform,c.encodeFileName),u=0;try{a.forEach(function(d,h){u++;var _=(function(C,f){var y=C||f,B=A[y];if(!B)throw new Error(y+" is not a valid compression method !");return B})(h.options.compression,c.compression),p=h.options.compressionOptions||c.compressionOptions||{},m=h.dir,I=h.date;h._compressWorker(_,p).withStreamInfo("file",{name:d,dir:m,date:I,comment:h.comment||"",unixPermissions:h.unixPermissions,dosPermissions:h.dosPermissions}).pipe(g)}),g.entriesCount=u}catch(d){g.error(d)}return g}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(o,i,r){function A(){if(!(this instanceof A))return new A;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 s=new A;for(var a in this)typeof this[a]!="function"&&(s[a]=this[a]);return s}}(A.prototype=o("./object")).loadAsync=o("./load"),A.support=o("./support"),A.defaults=o("./defaults"),A.version="3.10.1",A.loadAsync=function(s,a){return new A().loadAsync(s,a)},A.external=o("./external"),i.exports=A},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(o,i,r){var A=o("./utils"),s=o("./external"),a=o("./utf8"),c=o("./zipEntries"),l=o("./stream/Crc32Probe"),g=o("./nodejsUtils");function u(d){return new s.Promise(function(h,_){var p=d.decompressed.getContentWorker().pipe(new l);p.on("error",function(m){_(m)}).on("end",function(){p.streamInfo.crc32!==d.decompressed.crc32?_(new Error("Corrupted zip : CRC32 mismatch")):h()}).resume()})}i.exports=function(d,h){var _=this;return h=A.extend(h||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:a.utf8decode}),g.isNode&&g.isStream(d)?s.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):A.prepareContent("the loaded zip file",d,!0,h.optimizedBinaryString,h.base64).then(function(p){var m=new c(h);return m.load(p),m}).then(function(p){var m=[s.Promise.resolve(p)],I=p.files;if(h.checkCRC32)for(var C=0;C<I.length;C++)m.push(u(I[C]));return s.Promise.all(m)}).then(function(p){for(var m=p.shift(),I=m.files,C=0;C<I.length;C++){var f=I[C],y=f.fileNameStr,B=A.resolve(f.fileNameStr);_.file(B,f.decompressed,{binary:!0,optimizedBinaryString:!0,date:f.date,dir:f.dir,comment:f.fileCommentStr.length?f.fileCommentStr:null,unixPermissions:f.unixPermissions,dosPermissions:f.dosPermissions,createFolders:h.createFolders}),f.dir||(_.file(B).unsafeOriginalName=y)}return m.zipComment.length&&(_.comment=m.zipComment),_})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(o,i,r){var A=o("../utils"),s=o("../stream/GenericWorker");function a(c,l){s.call(this,"Nodejs stream input adapter for "+c),this._upstreamEnded=!1,this._bindStream(l)}A.inherits(a,s),a.prototype._bindStream=function(c){var l=this;(this._stream=c).pause(),c.on("data",function(g){l.push({data:g,meta:{percent:0}})}).on("error",function(g){l.isPaused?this.generatedError=g:l.error(g)}).on("end",function(){l.isPaused?l._upstreamEnded=!0:l.end()})},a.prototype.pause=function(){return!!s.prototype.pause.call(this)&&(this._stream.pause(),!0)},a.prototype.resume=function(){return!!s.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},i.exports=a},{"../stream/GenericWorker":28,"../utils":32}],13:[function(o,i,r){var A=o("readable-stream").Readable;function s(a,c,l){A.call(this,c),this._helper=a;var g=this;a.on("data",function(u,d){g.push(u)||g._helper.pause(),l&&l(d)}).on("error",function(u){g.emit("error",u)}).on("end",function(){g.push(null)})}o("../utils").inherits(s,A),s.prototype._read=function(){this._helper.resume()},i.exports=s},{"../utils":32,"readable-stream":16}],14:[function(o,i,r){i.exports={isNode:typeof Buffer<"u",newBufferFrom:function(A,s){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(A,s);if(typeof A=="number")throw new Error('The "data" argument must not be a number');return new Buffer(A,s)},allocBuffer:function(A){if(Buffer.alloc)return Buffer.alloc(A);var s=new Buffer(A);return s.fill(0),s},isBuffer:function(A){return Buffer.isBuffer(A)},isStream:function(A){return A&&typeof A.on=="function"&&typeof A.pause=="function"&&typeof A.resume=="function"}}},{}],15:[function(o,i,r){function A(B,x,S){var M,w=a.getTypeOf(x),k=a.extend(S||{},g);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&&(B=I(B)),k.createFolders&&(M=m(B))&&C.call(this,M,!0);var N=w==="string"&&k.binary===!1&&k.base64===!1;S&&S.binary!==void 0||(k.binary=!N),(x instanceof u&&x.uncompressedSize===0||k.dir||!x||x.length===0)&&(k.base64=!1,k.binary=!0,x="",k.compression="STORE",w="string");var H=null;H=x instanceof u||x instanceof c?x:_.isNode&&_.isStream(x)?new p(B,x):a.prepareContent(B,x,k.binary,k.optimizedBinaryString,k.base64);var G=new d(B,H,k);this.files[B]=G}var s=o("./utf8"),a=o("./utils"),c=o("./stream/GenericWorker"),l=o("./stream/StreamHelper"),g=o("./defaults"),u=o("./compressedObject"),d=o("./zipObject"),h=o("./generate"),_=o("./nodejsUtils"),p=o("./nodejs/NodejsStreamInputAdapter"),m=function(B){B.slice(-1)==="/"&&(B=B.substring(0,B.length-1));var x=B.lastIndexOf("/");return 0<x?B.substring(0,x):""},I=function(B){return B.slice(-1)!=="/"&&(B+="/"),B},C=function(B,x){return x=x!==void 0?x:g.createFolders,B=I(B),this.files[B]||A.call(this,B,null,{dir:!0,createFolders:x}),this.files[B]};function f(B){return Object.prototype.toString.call(B)==="[object RegExp]"}var y={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(B){var x,S,M;for(x in this.files)M=this.files[x],(S=x.slice(this.root.length,x.length))&&x.slice(0,this.root.length)===this.root&&B(S,M)},filter:function(B){var x=[];return this.forEach(function(S,M){B(S,M)&&x.push(M)}),x},file:function(B,x,S){if(arguments.length!==1)return B=this.root+B,A.call(this,B,x,S),this;if(f(B)){var M=B;return this.filter(function(k,N){return!N.dir&&M.test(k)})}var w=this.files[this.root+B];return w&&!w.dir?w:null},folder:function(B){if(!B)return this;if(f(B))return this.filter(function(w,k){return k.dir&&B.test(w)});var x=this.root+B,S=C.call(this,x),M=this.clone();return M.root=S.name,M},remove:function(B){B=this.root+B;var x=this.files[B];if(x||(B.slice(-1)!=="/"&&(B+="/"),x=this.files[B]),x&&!x.dir)delete this.files[B];else for(var S=this.filter(function(w,k){return k.name.slice(0,B.length)===B}),M=0;M<S.length;M++)delete this.files[S[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(B){var x,S={};try{if((S=a.extend(B||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:s.utf8encode})).type=S.type.toLowerCase(),S.compression=S.compression.toUpperCase(),S.type==="binarystring"&&(S.type="string"),!S.type)throw new Error("No output type specified.");a.checkSupport(S.type),S.platform!=="darwin"&&S.platform!=="freebsd"&&S.platform!=="linux"&&S.platform!=="sunos"||(S.platform="UNIX"),S.platform==="win32"&&(S.platform="DOS");var M=S.comment||this.comment||"";x=h.generateWorker(this,S,M)}catch(w){(x=new c("error")).error(w)}return new l(x,S.type||"string",S.mimeType)},generateAsync:function(B,x){return this.generateInternalStream(B).accumulate(x)},generateNodeStream:function(B,x){return(B=B||{}).type||(B.type="nodebuffer"),this.generateInternalStream(B).toNodejsStream(x)}};i.exports=y},{"./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 A=o("./DataReader");function s(a){A.call(this,a);for(var c=0;c<this.data.length;c++)a[c]=255&a[c]}o("../utils").inherits(s,A),s.prototype.byteAt=function(a){return this.data[this.zero+a]},s.prototype.lastIndexOfSignature=function(a){for(var c=a.charCodeAt(0),l=a.charCodeAt(1),g=a.charCodeAt(2),u=a.charCodeAt(3),d=this.length-4;0<=d;--d)if(this.data[d]===c&&this.data[d+1]===l&&this.data[d+2]===g&&this.data[d+3]===u)return d-this.zero;return-1},s.prototype.readAndCheckSignature=function(a){var c=a.charCodeAt(0),l=a.charCodeAt(1),g=a.charCodeAt(2),u=a.charCodeAt(3),d=this.readData(4);return c===d[0]&&l===d[1]&&g===d[2]&&u===d[3]},s.prototype.readData=function(a){if(this.checkOffset(a),a===0)return[];var c=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,c},i.exports=s},{"../utils":32,"./DataReader":18}],18:[function(o,i,r){var A=o("../utils");function s(a){this.data=a,this.length=a.length,this.index=0,this.zero=0}s.prototype={checkOffset:function(a){this.checkIndex(this.index+a)},checkIndex:function(a){if(this.length<this.zero+a||a<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+a+"). Corrupted zip ?")},setIndex:function(a){this.checkIndex(a),this.index=a},skip:function(a){this.setIndex(this.index+a)},byteAt:function(){},readInt:function(a){var c,l=0;for(this.checkOffset(a),c=this.index+a-1;c>=this.index;c--)l=(l<<8)+this.byteAt(c);return this.index+=a,l},readString:function(a){return A.transformTo("string",this.readData(a))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var a=this.readInt(4);return new Date(Date.UTC(1980+(a>>25&127),(a>>21&15)-1,a>>16&31,a>>11&31,a>>5&63,(31&a)<<1))}},i.exports=s},{"../utils":32}],19:[function(o,i,r){var A=o("./Uint8ArrayReader");function s(a){A.call(this,a)}o("../utils").inherits(s,A),s.prototype.readData=function(a){this.checkOffset(a);var c=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,c},i.exports=s},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(o,i,r){var A=o("./DataReader");function s(a){A.call(this,a)}o("../utils").inherits(s,A),s.prototype.byteAt=function(a){return this.data.charCodeAt(this.zero+a)},s.prototype.lastIndexOfSignature=function(a){return this.data.lastIndexOf(a)-this.zero},s.prototype.readAndCheckSignature=function(a){return a===this.readData(4)},s.prototype.readData=function(a){this.checkOffset(a);var c=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,c},i.exports=s},{"../utils":32,"./DataReader":18}],21:[function(o,i,r){var A=o("./ArrayReader");function s(a){A.call(this,a)}o("../utils").inherits(s,A),s.prototype.readData=function(a){if(this.checkOffset(a),a===0)return new Uint8Array(0);var c=this.data.subarray(this.zero+this.index,this.zero+this.index+a);return this.index+=a,c},i.exports=s},{"../utils":32,"./ArrayReader":17}],22:[function(o,i,r){var A=o("../utils"),s=o("../support"),a=o("./ArrayReader"),c=o("./StringReader"),l=o("./NodeBufferReader"),g=o("./Uint8ArrayReader");i.exports=function(u){var d=A.getTypeOf(u);return A.checkSupport(d),d!=="string"||s.uint8array?d==="nodebuffer"?new l(u):s.uint8array?new g(A.transformTo("uint8array",u)):new a(A.transformTo("array",u)):new c(u)}},{"../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 A=o("./GenericWorker"),s=o("../utils");function a(c){A.call(this,"ConvertWorker to "+c),this.destType=c}s.inherits(a,A),a.prototype.processChunk=function(c){this.push({data:s.transformTo(this.destType,c.data),meta:c.meta})},i.exports=a},{"../utils":32,"./GenericWorker":28}],25:[function(o,i,r){var A=o("./GenericWorker"),s=o("../crc32");function a(){A.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}o("../utils").inherits(a,A),a.prototype.processChunk=function(c){this.streamInfo.crc32=s(c.data,this.streamInfo.crc32||0),this.push(c)},i.exports=a},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(o,i,r){var A=o("../utils"),s=o("./GenericWorker");function a(c){s.call(this,"DataLengthProbe for "+c),this.propName=c,this.withStreamInfo(c,0)}A.inherits(a,s),a.prototype.processChunk=function(c){if(c){var l=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=l+c.data.length}s.prototype.processChunk.call(this,c)},i.exports=a},{"../utils":32,"./GenericWorker":28}],27:[function(o,i,r){var A=o("../utils"),s=o("./GenericWorker");function a(c){s.call(this,"DataWorker");var l=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,c.then(function(g){l.dataIsReady=!0,l.data=g,l.max=g&&g.length||0,l.type=A.getTypeOf(g),l.isPaused||l._tickAndRepeat()},function(g){l.error(g)})}A.inherits(a,s),a.prototype.cleanUp=function(){s.prototype.cleanUp.call(this),this.data=null},a.prototype.resume=function(){return!!s.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,A.delay(this._tickAndRepeat,[],this)),!0)},a.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(A.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},a.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var c=null,l=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":c=this.data.substring(this.index,l);break;case"uint8array":c=this.data.subarray(this.index,l);break;case"array":case"nodebuffer":c=this.data.slice(this.index,l)}return this.index=l,this.push({data:c,meta:{percent:this.max?this.index/this.max*100:0}})},i.exports=a},{"../utils":32,"./GenericWorker":28}],28:[function(o,i,r){function A(s){this.name=s||"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}A.prototype={push:function(s){this.emit("data",s)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(s){this.emit("error",s)}return!0},error:function(s){return!this.isFinished&&(this.isPaused?this.generatedError=s:(this.isFinished=!0,this.emit("error",s),this.previous&&this.previous.error(s),this.cleanUp()),!0)},on:function(s,a){return this._listeners[s].push(a),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(s,a){if(this._listeners[s])for(var c=0;c<this._listeners[s].length;c++)this._listeners[s][c].call(this,a)},pipe:function(s){return s.registerPrevious(this)},registerPrevious:function(s){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=s.streamInfo,this.mergeStreamInfo(),this.previous=s;var a=this;return s.on("data",function(c){a.processChunk(c)}),s.on("end",function(){a.end()}),s.on("error",function(c){a.error(c)}),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 s=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),s=!0),this.previous&&this.previous.resume(),!s},flush:function(){},processChunk:function(s){this.push(s)},withStreamInfo:function(s,a){return this.extraStreamInfo[s]=a,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var s in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,s)&&(this.streamInfo[s]=this.extraStreamInfo[s])},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 s="Worker "+this.name;return this.previous?this.previous+" -> "+s:s}},i.exports=A},{}],29:[function(o,i,r){var A=o("../utils"),s=o("./ConvertWorker"),a=o("./GenericWorker"),c=o("../base64"),l=o("../support"),g=o("../external"),u=null;if(l.nodestream)try{u=o("../nodejs/NodejsStreamOutputAdapter")}catch{}function d(_,p){return new g.Promise(function(m,I){var C=[],f=_._internalType,y=_._outputType,B=_._mimeType;_.on("data",function(x,S){C.push(x),p&&p(S)}).on("error",function(x){C=[],I(x)}).on("end",function(){try{var x=(function(S,M,w){switch(S){case"blob":return A.newBlob(A.transformTo("arraybuffer",M),w);case"base64":return c.encode(M);default:return A.transformTo(S,M)}})(y,(function(S,M){var w,k=0,N=null,H=0;for(w=0;w<M.length;w++)H+=M[w].length;switch(S){case"string":return M.join("");case"array":return Array.prototype.concat.apply([],M);case"uint8array":for(N=new Uint8Array(H),w=0;w<M.length;w++)N.set(M[w],k),k+=M[w].length;return N;case"nodebuffer":return Buffer.concat(M);default:throw new Error("concat : unsupported type '"+S+"'")}})(f,C),B);m(x)}catch(S){I(S)}C=[]}).resume()})}function h(_,p,m){var I=p;switch(p){case"blob":case"arraybuffer":I="uint8array";break;case"base64":I="string"}try{this._internalType=I,this._outputType=p,this._mimeType=m,A.checkSupport(I),this._worker=_.pipe(new s(I)),_.lock()}catch(C){this._worker=new a("error"),this._worker.error(C)}}h.prototype={accumulate:function(_){return d(this,_)},on:function(_,p){var m=this;return _==="data"?this._worker.on(_,function(I){p.call(m,I.data,I.meta)}):this._worker.on(_,function(){A.delay(p,arguments,m)}),this},resume:function(){return A.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(_){if(A.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new u(this,{objectMode:this._outputType!=="nodebuffer"},_)}},i.exports=h},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(o,i,r){if(r.base64=!0,r.array=!0,r.string=!0,r.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",r.nodebuffer=typeof Buffer<"u",r.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")r.blob=!1;else{var A=new ArrayBuffer(0);try{r.blob=new Blob([A],{type:"application/zip"}).size===0}catch{try{var s=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);s.append(A),r.blob=s.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 A=o("./utils"),s=o("./support"),a=o("./nodejsUtils"),c=o("./stream/GenericWorker"),l=new Array(256),g=0;g<256;g++)l[g]=252<=g?6:248<=g?5:240<=g?4:224<=g?3:192<=g?2:1;l[254]=l[254]=1;function u(){c.call(this,"utf-8 decode"),this.leftOver=null}function d(){c.call(this,"utf-8 encode")}r.utf8encode=function(h){return s.nodebuffer?a.newBufferFrom(h,"utf-8"):(function(_){var p,m,I,C,f,y=_.length,B=0;for(C=0;C<y;C++)(64512&(m=_.charCodeAt(C)))==55296&&C+1<y&&(64512&(I=_.charCodeAt(C+1)))==56320&&(m=65536+(m-55296<<10)+(I-56320),C++),B+=m<128?1:m<2048?2:m<65536?3:4;for(p=s.uint8array?new Uint8Array(B):new Array(B),C=f=0;f<B;C++)(64512&(m=_.charCodeAt(C)))==55296&&C+1<y&&(64512&(I=_.charCodeAt(C+1)))==56320&&(m=65536+(m-55296<<10)+(I-56320),C++),m<128?p[f++]=m:(m<2048?p[f++]=192|m>>>6:(m<65536?p[f++]=224|m>>>12:(p[f++]=240|m>>>18,p[f++]=128|m>>>12&63),p[f++]=128|m>>>6&63),p[f++]=128|63&m);return p})(h)},r.utf8decode=function(h){return s.nodebuffer?A.transformTo("nodebuffer",h).toString("utf-8"):(function(_){var p,m,I,C,f=_.length,y=new Array(2*f);for(p=m=0;p<f;)if((I=_[p++])<128)y[m++]=I;else if(4<(C=l[I]))y[m++]=65533,p+=C-1;else{for(I&=C===2?31:C===3?15:7;1<C&&p<f;)I=I<<6|63&_[p++],C--;1<C?y[m++]=65533:I<65536?y[m++]=I:(I-=65536,y[m++]=55296|I>>10&1023,y[m++]=56320|1023&I)}return y.length!==m&&(y.subarray?y=y.subarray(0,m):y.length=m),A.applyFromCharCode(y)})(h=A.transformTo(s.uint8array?"uint8array":"array",h))},A.inherits(u,c),u.prototype.processChunk=function(h){var _=A.transformTo(s.uint8array?"uint8array":"array",h.data);if(this.leftOver&&this.leftOver.length){if(s.uint8array){var p=_;(_=new Uint8Array(p.length+this.leftOver.length)).set(this.leftOver,0),_.set(p,this.leftOver.length)}else _=this.leftOver.concat(_);this.leftOver=null}var m=(function(C,f){var y;for((f=f||C.length)>C.length&&(f=C.length),y=f-1;0<=y&&(192&C[y])==128;)y--;return y<0||y===0?f:y+l[C[y]]>f?y:f})(_),I=_;m!==_.length&&(s.uint8array?(I=_.subarray(0,m),this.leftOver=_.subarray(m,_.length)):(I=_.slice(0,m),this.leftOver=_.slice(m,_.length))),this.push({data:r.utf8decode(I),meta:h.meta})},u.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:r.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},r.Utf8DecodeWorker=u,A.inherits(d,c),d.prototype.processChunk=function(h){this.push({data:r.utf8encode(h.data),meta:h.meta})},r.Utf8EncodeWorker=d},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(o,i,r){var A=o("./support"),s=o("./base64"),a=o("./nodejsUtils"),c=o("./external");function l(p){return p}function g(p,m){for(var I=0;I<p.length;++I)m[I]=255&p.charCodeAt(I);return m}o("setimmediate"),r.newBlob=function(p,m){r.checkSupport("blob");try{return new Blob([p],{type:m})}catch{try{var I=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return I.append(p),I.getBlob(m)}catch{throw new Error("Bug : can't construct the Blob.")}}};var u={stringifyByChunk:function(p,m,I){var C=[],f=0,y=p.length;if(y<=I)return String.fromCharCode.apply(null,p);for(;f<y;)m==="array"||m==="nodebuffer"?C.push(String.fromCharCode.apply(null,p.slice(f,Math.min(f+I,y)))):C.push(String.fromCharCode.apply(null,p.subarray(f,Math.min(f+I,y)))),f+=I;return C.join("")},stringifyByChar:function(p){for(var m="",I=0;I<p.length;I++)m+=String.fromCharCode(p[I]);return m},applyCanBeUsed:{uint8array:(function(){try{return A.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}})(),nodebuffer:(function(){try{return A.nodebuffer&&String.fromCharCode.apply(null,a.allocBuffer(1)).length===1}catch{return!1}})()}};function d(p){var m=65536,I=r.getTypeOf(p),C=!0;if(I==="uint8array"?C=u.applyCanBeUsed.uint8array:I==="nodebuffer"&&(C=u.applyCanBeUsed.nodebuffer),C)for(;1<m;)try{return u.stringifyByChunk(p,I,m)}catch{m=Math.floor(m/2)}return u.stringifyByChar(p)}function h(p,m){for(var I=0;I<p.length;I++)m[I]=p[I];return m}r.applyFromCharCode=d;var _={};_.string={string:l,array:function(p){return g(p,new Array(p.length))},arraybuffer:function(p){return _.string.uint8array(p).buffer},uint8array:function(p){return g(p,new Uint8Array(p.length))},nodebuffer:function(p){return g(p,a.allocBuffer(p.length))}},_.array={string:d,array:l,arraybuffer:function(p){return new Uint8Array(p).buffer},uint8array:function(p){return new Uint8Array(p)},nodebuffer:function(p){return a.newBufferFrom(p)}},_.arraybuffer={string:function(p){return d(new Uint8Array(p))},array:function(p){return h(new Uint8Array(p),new Array(p.byteLength))},arraybuffer:l,uint8array:function(p){return new Uint8Array(p)},nodebuffer:function(p){return a.newBufferFrom(new Uint8Array(p))}},_.uint8array={string:d,array:function(p){return h(p,new Array(p.length))},arraybuffer:function(p){return p.buffer},uint8array:l,nodebuffer:function(p){return a.newBufferFrom(p)}},_.nodebuffer={string:d,array:function(p){return h(p,new Array(p.length))},arraybuffer:function(p){return _.nodebuffer.uint8array(p).buffer},uint8array:function(p){return h(p,new Uint8Array(p.length))},nodebuffer:l},r.transformTo=function(p,m){if(m=m||"",!p)return m;r.checkSupport(p);var I=r.getTypeOf(m);return _[I][p](m)},r.resolve=function(p){for(var m=p.split("/"),I=[],C=0;C<m.length;C++){var f=m[C];f==="."||f===""&&C!==0&&C!==m.length-1||(f===".."?I.pop():I.push(f))}return I.join("/")},r.getTypeOf=function(p){return typeof p=="string"?"string":Object.prototype.toString.call(p)==="[object Array]"?"array":A.nodebuffer&&a.isBuffer(p)?"nodebuffer":A.uint8array&&p instanceof Uint8Array?"uint8array":A.arraybuffer&&p instanceof ArrayBuffer?"arraybuffer":void 0},r.checkSupport=function(p){if(!A[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 m,I,C="";for(I=0;I<(p||"").length;I++)C+="\\x"+((m=p.charCodeAt(I))<16?"0":"")+m.toString(16).toUpperCase();return C},r.delay=function(p,m,I){setImmediate(function(){p.apply(I||null,m||[])})},r.inherits=function(p,m){function I(){}I.prototype=m.prototype,p.prototype=new I},r.extend=function(){var p,m,I={};for(p=0;p<arguments.length;p++)for(m in arguments[p])Object.prototype.hasOwnProperty.call(arguments[p],m)&&I[m]===void 0&&(I[m]=arguments[p][m]);return I},r.prepareContent=function(p,m,I,C,f){return c.Promise.resolve(m).then(function(y){return A.blob&&(y instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(y))!==-1)&&typeof FileReader<"u"?new c.Promise(function(B,x){var S=new FileReader;S.onload=function(M){B(M.target.result)},S.onerror=function(M){x(M.target.error)},S.readAsArrayBuffer(y)}):y}).then(function(y){var B=r.getTypeOf(y);return B?(B==="arraybuffer"?y=r.transformTo("uint8array",y):B==="string"&&(f?y=s.decode(y):I&&C!==!0&&(y=(function(x){return g(x,A.uint8array?new Uint8Array(x.length):new Array(x.length))})(y))),y):c.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 A=o("./reader/readerFor"),s=o("./utils"),a=o("./signature"),c=o("./zipEntry"),l=o("./support");function g(u){this.files=[],this.loadOptions=u}g.prototype={checkSignature:function(u){if(!this.reader.readAndCheckSignature(u)){this.reader.index-=4;var d=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+s.pretty(d)+", expected "+s.pretty(u)+")")}},isSignature:function(u,d){var h=this.reader.index;this.reader.setIndex(u);var _=this.reader.readString(4)===d;return this.reader.setIndex(h),_},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 u=this.reader.readData(this.zipCommentLength),d=l.uint8array?"uint8array":"array",h=s.transformTo(d,u);this.zipComment=this.loadOptions.decodeFileName(h)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var u,d,h,_=this.zip64EndOfCentralSize-44;0<_;)u=this.reader.readInt(2),d=this.reader.readInt(4),h=this.reader.readData(d),this.zip64ExtensibleData[u]={id:u,length:d,value:h}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var u,d;for(u=0;u<this.files.length;u++)d=this.files[u],this.reader.setIndex(d.localHeaderOffset),this.checkSignature(a.LOCAL_FILE_HEADER),d.readLocalPart(this.reader),d.handleUTF8(),d.processAttributes()},readCentralDir:function(){var u;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(a.CENTRAL_FILE_HEADER);)(u=new c({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(u);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 u=this.reader.lastIndexOfSignature(a.CENTRAL_DIRECTORY_END);if(u<0)throw this.isSignature(0,a.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(u);var d=u;if(this.checkSignature(a.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===s.MAX_VALUE_16BITS||this.diskWithCentralDirStart===s.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===s.MAX_VALUE_16BITS||this.centralDirRecords===s.MAX_VALUE_16BITS||this.centralDirSize===s.MAX_VALUE_32BITS||this.centralDirOffset===s.MAX_VALUE_32BITS){if(this.zip64=!0,(u=this.reader.lastIndexOfSignature(a.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(u),this.checkSignature(a.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,a.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(a.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(a.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var h=this.centralDirOffset+this.centralDirSize;this.zip64&&(h+=20,h+=12+this.zip64EndOfCentralSize);var _=d-h;if(0<_)this.isSignature(d,a.CENTRAL_FILE_HEADER)||(this.reader.zero=_);else if(_<0)throw new Error("Corrupted zip: missing "+Math.abs(_)+" bytes.")},prepareReader:function(u){this.reader=A(u)},load:function(u){this.prepareReader(u),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},i.exports=g},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(o,i,r){var A=o("./reader/readerFor"),s=o("./utils"),a=o("./compressedObject"),c=o("./crc32"),l=o("./utf8"),g=o("./compressions"),u=o("./support");function d(h,_){this.options=h,this.loadOptions=_}d.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(h){var _,p;if(h.skip(22),this.fileNameLength=h.readInt(2),p=h.readInt(2),this.fileName=h.readData(this.fileNameLength),h.skip(p),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((_=(function(m){for(var I in g)if(Object.prototype.hasOwnProperty.call(g,I)&&g[I].magic===m)return g[I];return null})(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+s.pretty(this.compressionMethod)+" unknown (inner file : "+s.transformTo("string",this.fileName)+")");this.decompressed=new a(this.compressedSize,this.uncompressedSize,this.crc32,_,h.readData(this.compressedSize))},readCentralPart:function(h){this.versionMadeBy=h.readInt(2),h.skip(2),this.bitFlag=h.readInt(2),this.compressionMethod=h.readString(2),this.date=h.readDate(),this.crc32=h.readInt(4),this.compressedSize=h.readInt(4),this.uncompressedSize=h.readInt(4);var _=h.readInt(2);if(this.extraFieldsLength=h.readInt(2),this.fileCommentLength=h.readInt(2),this.diskNumberStart=h.readInt(2),this.internalFileAttributes=h.readInt(2),this.externalFileAttributes=h.readInt(4),this.localHeaderOffset=h.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");h.skip(_),this.readExtraFields(h),this.parseZIP64ExtraField(h),this.fileComment=h.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var h=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),h==0&&(this.dosPermissions=63&this.externalFileAttributes),h==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var h=A(this.extraFields[1].value);this.uncompressedSize===s.MAX_VALUE_32BITS&&(this.uncompressedSize=h.readInt(8)),this.compressedSize===s.MAX_VALUE_32BITS&&(this.compressedSize=h.readInt(8)),this.localHeaderOffset===s.MAX_VALUE_32BITS&&(this.localHeaderOffset=h.readInt(8)),this.diskNumberStart===s.MAX_VALUE_32BITS&&(this.diskNumberStart=h.readInt(4))}},readExtraFields:function(h){var _,p,m,I=h.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});h.index+4<I;)_=h.readInt(2),p=h.readInt(2),m=h.readData(p),this.extraFields[_]={id:_,length:p,value:m};h.setIndex(I)},handleUTF8:function(){var h=u.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=l.utf8decode(this.fileName),this.fileCommentStr=l.utf8decode(this.fileComment);else{var _=this.findExtraFieldUnicodePath();if(_!==null)this.fileNameStr=_;else{var p=s.transformTo(h,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(p)}var m=this.findExtraFieldUnicodeComment();if(m!==null)this.fileCommentStr=m;else{var I=s.transformTo(h,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(I)}}},findExtraFieldUnicodePath:function(){var h=this.extraFields[28789];if(h){var _=A(h.value);return _.readInt(1)!==1||c(this.fileName)!==_.readInt(4)?null:l.utf8decode(_.readData(h.length-5))}return null},findExtraFieldUnicodeComment:function(){var h=this.extraFields[25461];if(h){var _=A(h.value);return _.readInt(1)!==1||c(this.fileComment)!==_.readInt(4)?null:l.utf8decode(_.readData(h.length-5))}return null}},i.exports=d},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(o,i,r){function A(_,p,m){this.name=_,this.dir=m.dir,this.date=m.date,this.comment=m.comment,this.unixPermissions=m.unixPermissions,this.dosPermissions=m.dosPermissions,this._data=p,this._dataBinary=m.binary,this.options={compression:m.compression,compressionOptions:m.compressionOptions}}var s=o("./stream/StreamHelper"),a=o("./stream/DataWorker"),c=o("./utf8"),l=o("./compressedObject"),g=o("./stream/GenericWorker");A.prototype={internalStream:function(_){var p=null,m="string";try{if(!_)throw new Error("No output type specified.");var I=(m=_.toLowerCase())==="string"||m==="text";m!=="binarystring"&&m!=="text"||(m="string"),p=this._decompressWorker();var C=!this._dataBinary;C&&!I&&(p=p.pipe(new c.Utf8EncodeWorker)),!C&&I&&(p=p.pipe(new c.Utf8DecodeWorker))}catch(f){(p=new g("error")).error(f)}return new s(p,m,"")},async:function(_,p){return this.internalStream(_).accumulate(p)},nodeStream:function(_,p){return this.internalStream(_||"nodebuffer").toNodejsStream(p)},_compressWorker:function(_,p){if(this._data instanceof l&&this._data.compression.magic===_.magic)return this._data.getCompressedWorker();var m=this._decompressWorker();return this._dataBinary||(m=m.pipe(new c.Utf8EncodeWorker)),l.createWorkerFrom(m,_,p)},_decompressWorker:function(){return this._data instanceof l?this._data.getContentWorker():this._data instanceof g?this._data:new a(this._data)}};for(var u=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],d=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},h=0;h<u.length;h++)A.prototype[u[h]]=d;i.exports=A},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(o,i,r){(function(A){var s,a,c=A.MutationObserver||A.WebKitMutationObserver;if(c){var l=0,g=new c(_),u=A.document.createTextNode("");g.observe(u,{characterData:!0}),s=function(){u.data=l=++l%2}}else if(A.setImmediate||A.MessageChannel===void 0)s="document"in A&&"onreadystatechange"in A.document.createElement("script")?function(){var p=A.document.createElement("script");p.onreadystatechange=function(){_(),p.onreadystatechange=null,p.parentNode.removeChild(p),p=null},A.document.documentElement.appendChild(p)}:function(){setTimeout(_,0)};else{var d=new A.MessageChannel;d.port1.onmessage=_,s=function(){d.port2.postMessage(0)}}var h=[];function _(){var p,m;a=!0;for(var I=h.length;I;){for(m=h,h=[],p=-1;++p<I;)m[p]();I=h.length}a=!1}i.exports=function(p){h.push(p)!==1||a||s()}}).call(this,typeof yK<"u"?yK:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(o,i,r){var A=o("immediate");function s(){}var a={},c=["REJECTED"],l=["FULFILLED"],g=["PENDING"];function u(I){if(typeof I!="function")throw new TypeError("resolver must be a function");this.state=g,this.queue=[],this.outcome=void 0,I!==s&&p(this,I)}function d(I,C,f){this.promise=I,typeof C=="function"&&(this.onFulfilled=C,this.callFulfilled=this.otherCallFulfilled),typeof f=="function"&&(this.onRejected=f,this.callRejected=this.otherCallRejected)}function h(I,C,f){A(function(){var y;try{y=C(f)}catch(B){return a.reject(I,B)}y===I?a.reject(I,new TypeError("Cannot resolve promise with itself")):a.resolve(I,y)})}function _(I){var C=I&&I.then;if(I&&(typeof I=="object"||typeof I=="function")&&typeof C=="function")return function(){C.apply(I,arguments)}}function p(I,C){var f=!1;function y(S){f||(f=!0,a.reject(I,S))}function B(S){f||(f=!0,a.resolve(I,S))}var x=m(function(){C(B,y)});x.status==="error"&&y(x.value)}function m(I,C){var f={};try{f.value=I(C),f.status="success"}catch(y){f.status="error",f.value=y}return f}(i.exports=u).prototype.finally=function(I){if(typeof I!="function")return this;var C=this.constructor;return this.then(function(f){return C.resolve(I()).then(function(){return f})},function(f){return C.resolve(I()).then(function(){throw f})})},u.prototype.catch=function(I){return this.then(null,I)},u.prototype.then=function(I,C){if(typeof I!="function"&&this.state===l||typeof C!="function"&&this.state===c)return this;var f=new this.constructor(s);return this.state!==g?h(f,this.state===l?I:C,this.outcome):this.queue.push(new d(f,I,C)),f},d.prototype.callFulfilled=function(I){a.resolve(this.promise,I)},d.prototype.otherCallFulfilled=function(I){h(this.promise,this.onFulfilled,I)},d.prototype.callRejected=function(I){a.reject(this.promise,I)},d.prototype.otherCallRejected=function(I){h(this.promise,this.onRejected,I)},a.resolve=function(I,C){var f=m(_,C);if(f.status==="error")return a.reject(I,f.value);var y=f.value;if(y)p(I,y);else{I.state=l,I.outcome=C;for(var B=-1,x=I.queue.length;++B<x;)I.queue[B].callFulfilled(C)}return I},a.reject=function(I,C){I.state=c,I.outcome=C;for(var f=-1,y=I.queue.length;++f<y;)I.queue[f].callRejected(C);return I},u.resolve=function(I){return I instanceof this?I:a.resolve(new this(s),I)},u.reject=function(I){var C=new this(s);return a.reject(C,I)},u.all=function(I){var C=this;if(Object.prototype.toString.call(I)!=="[object Array]")return this.reject(new TypeError("must be an array"));var f=I.length,y=!1;if(!f)return this.resolve([]);for(var B=new Array(f),x=0,S=-1,M=new this(s);++S<f;)w(I[S],S);return M;function w(k,N){C.resolve(k).then(function(H){B[N]=H,++x!==f||y||(y=!0,a.resolve(M,B))},function(H){y||(y=!0,a.reject(M,H))})}},u.race=function(I){var C=this;if(Object.prototype.toString.call(I)!=="[object Array]")return this.reject(new TypeError("must be an array"));var f=I.length,y=!1;if(!f)return this.resolve([]);for(var B=-1,x=new this(s);++B<f;)S=I[B],C.resolve(S).then(function(M){y||(y=!0,a.resolve(x,M))},function(M){y||(y=!0,a.reject(x,M))});var S;return x}},{immediate:36}],38:[function(o,i,r){var A={};(0,o("./lib/utils/common").assign)(A,o("./lib/deflate"),o("./lib/inflate"),o("./lib/zlib/constants")),i.exports=A},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(o,i,r){var A=o("./zlib/deflate"),s=o("./utils/common"),a=o("./utils/strings"),c=o("./zlib/messages"),l=o("./zlib/zstream"),g=Object.prototype.toString,u=0,d=-1,h=0,_=8;function p(I){if(!(this instanceof p))return new p(I);this.options=s.assign({level:d,method:_,chunkSize:16384,windowBits:15,memLevel:8,strategy:h,to:""},I||{});var C=this.options;C.raw&&0<C.windowBits?C.windowBits=-C.windowBits:C.gzip&&0<C.windowBits&&C.windowBits<16&&(C.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new l,this.strm.avail_out=0;var f=A.deflateInit2(this.strm,C.level,C.method,C.windowBits,C.memLevel,C.strategy);if(f!==u)throw new Error(c[f]);if(C.header&&A.deflateSetHeader(this.strm,C.header),C.dictionary){var y;if(y=typeof C.dictionary=="string"?a.string2buf(C.dictionary):g.call(C.dictionary)==="[object ArrayBuffer]"?new Uint8Array(C.dictionary):C.dictionary,(f=A.deflateSetDictionary(this.strm,y))!==u)throw new Error(c[f]);this._dict_set=!0}}function m(I,C){var f=new p(C);if(f.push(I,!0),f.err)throw f.msg||c[f.err];return f.result}p.prototype.push=function(I,C){var f,y,B=this.strm,x=this.options.chunkSize;if(this.ended)return!1;y=C===~~C?C:C===!0?4:0,typeof I=="string"?B.input=a.string2buf(I):g.call(I)==="[object ArrayBuffer]"?B.input=new Uint8Array(I):B.input=I,B.next_in=0,B.avail_in=B.input.length;do{if(B.avail_out===0&&(B.output=new s.Buf8(x),B.next_out=0,B.avail_out=x),(f=A.deflate(B,y))!==1&&f!==u)return this.onEnd(f),!(this.ended=!0);B.avail_out!==0&&(B.avail_in!==0||y!==4&&y!==2)||(this.options.to==="string"?this.onData(a.buf2binstring(s.shrinkBuf(B.output,B.next_out))):this.onData(s.shrinkBuf(B.output,B.next_out)))}while((0<B.avail_in||B.avail_out===0)&&f!==1);return y===4?(f=A.deflateEnd(this.strm),this.onEnd(f),this.ended=!0,f===u):y!==2||(this.onEnd(u),!(B.avail_out=0))},p.prototype.onData=function(I){this.chunks.push(I)},p.prototype.onEnd=function(I){I===u&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=s.flattenChunks(this.chunks)),this.chunks=[],this.err=I,this.msg=this.strm.msg},r.Deflate=p,r.deflate=m,r.deflateRaw=function(I,C){return(C=C||{}).raw=!0,m(I,C)},r.gzip=function(I,C){return(C=C||{}).gzip=!0,m(I,C)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(o,i,r){var A=o("./zlib/inflate"),s=o("./utils/common"),a=o("./utils/strings"),c=o("./zlib/constants"),l=o("./zlib/messages"),g=o("./zlib/zstream"),u=o("./zlib/gzheader"),d=Object.prototype.toString;function h(p){if(!(this instanceof h))return new h(p);this.options=s.assign({chunkSize:16384,windowBits:0,to:""},p||{});var m=this.options;m.raw&&0<=m.windowBits&&m.windowBits<16&&(m.windowBits=-m.windowBits,m.windowBits===0&&(m.windowBits=-15)),!(0<=m.windowBits&&m.windowBits<16)||p&&p.windowBits||(m.windowBits+=32),15<m.windowBits&&m.windowBits<48&&(15&m.windowBits)==0&&(m.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new g,this.strm.avail_out=0;var I=A.inflateInit2(this.strm,m.windowBits);if(I!==c.Z_OK)throw new Error(l[I]);this.header=new u,A.inflateGetHeader(this.strm,this.header)}function _(p,m){var I=new h(m);if(I.push(p,!0),I.err)throw I.msg||l[I.err];return I.result}h.prototype.push=function(p,m){var I,C,f,y,B,x,S=this.strm,M=this.options.chunkSize,w=this.options.dictionary,k=!1;if(this.ended)return!1;C=m===~~m?m:m===!0?c.Z_FINISH:c.Z_NO_FLUSH,typeof p=="string"?S.input=a.binstring2buf(p):d.call(p)==="[object ArrayBuffer]"?S.input=new Uint8Array(p):S.input=p,S.next_in=0,S.avail_in=S.input.length;do{if(S.avail_out===0&&(S.output=new s.Buf8(M),S.next_out=0,S.avail_out=M),(I=A.inflate(S,c.Z_NO_FLUSH))===c.Z_NEED_DICT&&w&&(x=typeof w=="string"?a.string2buf(w):d.call(w)==="[object ArrayBuffer]"?new Uint8Array(w):w,I=A.inflateSetDictionary(this.strm,x)),I===c.Z_BUF_ERROR&&k===!0&&(I=c.Z_OK,k=!1),I!==c.Z_STREAM_END&&I!==c.Z_OK)return this.onEnd(I),!(this.ended=!0);S.next_out&&(S.avail_out!==0&&I!==c.Z_STREAM_END&&(S.avail_in!==0||C!==c.Z_FINISH&&C!==c.Z_SYNC_FLUSH)||(this.options.to==="string"?(f=a.utf8border(S.output,S.next_out),y=S.next_out-f,B=a.buf2string(S.output,f),S.next_out=y,S.avail_out=M-y,y&&s.arraySet(S.output,S.output,f,y,0),this.onData(B)):this.onData(s.shrinkBuf(S.output,S.next_out)))),S.avail_in===0&&S.avail_out===0&&(k=!0)}while((0<S.avail_in||S.avail_out===0)&&I!==c.Z_STREAM_END);return I===c.Z_STREAM_END&&(C=c.Z_FINISH),C===c.Z_FINISH?(I=A.inflateEnd(this.strm),this.onEnd(I),this.ended=!0,I===c.Z_OK):C!==c.Z_SYNC_FLUSH||(this.onEnd(c.Z_OK),!(S.avail_out=0))},h.prototype.onData=function(p){this.chunks.push(p)},h.prototype.onEnd=function(p){p===c.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=s.flattenChunks(this.chunks)),this.chunks=[],this.err=p,this.msg=this.strm.msg},r.Inflate=h,r.inflate=_,r.inflateRaw=function(p,m){return(m=m||{}).raw=!0,_(p,m)},r.ungzip=_},{"./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 A=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";r.assign=function(c){for(var l=Array.prototype.slice.call(arguments,1);l.length;){var g=l.shift();if(g){if(typeof g!="object")throw new TypeError(g+"must be non-object");for(var u in g)g.hasOwnProperty(u)&&(c[u]=g[u])}}return c},r.shrinkBuf=function(c,l){return c.length===l?c:c.subarray?c.subarray(0,l):(c.length=l,c)};var s={arraySet:function(c,l,g,u,d){if(l.subarray&&c.subarray)c.set(l.subarray(g,g+u),d);else for(var h=0;h<u;h++)c[d+h]=l[g+h]},flattenChunks:function(c){var l,g,u,d,h,_;for(l=u=0,g=c.length;l<g;l++)u+=c[l].length;for(_=new Uint8Array(u),l=d=0,g=c.length;l<g;l++)h=c[l],_.set(h,d),d+=h.length;return _}},a={arraySet:function(c,l,g,u,d){for(var h=0;h<u;h++)c[d+h]=l[g+h]},flattenChunks:function(c){return[].concat.apply([],c)}};r.setTyped=function(c){c?(r.Buf8=Uint8Array,r.Buf16=Uint16Array,r.Buf32=Int32Array,r.assign(r,s)):(r.Buf8=Array,r.Buf16=Array,r.Buf32=Array,r.assign(r,a))},r.setTyped(A)},{}],42:[function(o,i,r){var A=o("./common"),s=!0,a=!0;try{String.fromCharCode.apply(null,[0])}catch{s=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{a=!1}for(var c=new A.Buf8(256),l=0;l<256;l++)c[l]=252<=l?6:248<=l?5:240<=l?4:224<=l?3:192<=l?2:1;function g(u,d){if(d<65537&&(u.subarray&&a||!u.subarray&&s))return String.fromCharCode.apply(null,A.shrinkBuf(u,d));for(var h="",_=0;_<d;_++)h+=String.fromCharCode(u[_]);return h}c[254]=c[254]=1,r.string2buf=function(u){var d,h,_,p,m,I=u.length,C=0;for(p=0;p<I;p++)(64512&(h=u.charCodeAt(p)))==55296&&p+1<I&&(64512&(_=u.charCodeAt(p+1)))==56320&&(h=65536+(h-55296<<10)+(_-56320),p++),C+=h<128?1:h<2048?2:h<65536?3:4;for(d=new A.Buf8(C),p=m=0;m<C;p++)(64512&(h=u.charCodeAt(p)))==55296&&p+1<I&&(64512&(_=u.charCodeAt(p+1)))==56320&&(h=65536+(h-55296<<10)+(_-56320),p++),h<128?d[m++]=h:(h<2048?d[m++]=192|h>>>6:(h<65536?d[m++]=224|h>>>12:(d[m++]=240|h>>>18,d[m++]=128|h>>>12&63),d[m++]=128|h>>>6&63),d[m++]=128|63&h);return d},r.buf2binstring=function(u){return g(u,u.length)},r.binstring2buf=function(u){for(var d=new A.Buf8(u.length),h=0,_=d.length;h<_;h++)d[h]=u.charCodeAt(h);return d},r.buf2string=function(u,d){var h,_,p,m,I=d||u.length,C=new Array(2*I);for(h=_=0;h<I;)if((p=u[h++])<128)C[_++]=p;else if(4<(m=c[p]))C[_++]=65533,h+=m-1;else{for(p&=m===2?31:m===3?15:7;1<m&&h<I;)p=p<<6|63&u[h++],m--;1<m?C[_++]=65533:p<65536?C[_++]=p:(p-=65536,C[_++]=55296|p>>10&1023,C[_++]=56320|1023&p)}return g(C,_)},r.utf8border=function(u,d){var h;for((d=d||u.length)>u.length&&(d=u.length),h=d-1;0<=h&&(192&u[h])==128;)h--;return h<0||h===0?d:h+c[u[h]]>d?h:d}},{"./common":41}],43:[function(o,i,r){i.exports=function(A,s,a,c){for(var l=65535&A|0,g=A>>>16&65535|0,u=0;a!==0;){for(a-=u=2e3<a?2e3:a;g=g+(l=l+s[c++]|0)|0,--u;);l%=65521,g%=65521}return l|g<<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 A=(function(){for(var s,a=[],c=0;c<256;c++){s=c;for(var l=0;l<8;l++)s=1&s?3988292384^s>>>1:s>>>1;a[c]=s}return a})();i.exports=function(s,a,c,l){var g=A,u=l+c;s^=-1;for(var d=l;d<u;d++)s=s>>>8^g[255&(s^a[d])];return-1^s}},{}],46:[function(o,i,r){var A,s=o("../utils/common"),a=o("./trees"),c=o("./adler32"),l=o("./crc32"),g=o("./messages"),u=0,d=4,h=0,_=-2,p=-1,m=4,I=2,C=8,f=9,y=286,B=30,x=19,S=2*y+1,M=15,w=3,k=258,N=k+w+1,H=42,G=113,U=1,J=2,W=3,X=4;function oe(pe,et){return pe.msg=g[et],et}function ce(pe){return(pe<<1)-(4<pe?9:0)}function ee(pe){for(var et=pe.length;0<=--et;)pe[et]=0}function ie(pe){var et=pe.state,Le=et.pending;Le>pe.avail_out&&(Le=pe.avail_out),Le!==0&&(s.arraySet(pe.output,et.pending_buf,et.pending_out,Le,pe.next_out),pe.next_out+=Le,et.pending_out+=Le,pe.total_out+=Le,pe.avail_out-=Le,et.pending-=Le,et.pending===0&&(et.pending_out=0))}function ae(pe,et){a._tr_flush_block(pe,0<=pe.block_start?pe.block_start:-1,pe.strstart-pe.block_start,et),pe.block_start=pe.strstart,ie(pe.strm)}function re(pe,et){pe.pending_buf[pe.pending++]=et}function le(pe,et){pe.pending_buf[pe.pending++]=et>>>8&255,pe.pending_buf[pe.pending++]=255&et}function ye(pe,et){var Le,Pe,Ue=pe.max_chain_length,Ne=pe.strstart,Ee=pe.prev_length,Oe=pe.nice_match,we=pe.strstart>pe.w_size-N?pe.strstart-(pe.w_size-N):0,Ve=pe.window,je=pe.w_mask,At=pe.prev,at=pe.strstart+k,gt=Ve[Ne+Ee-1],ct=Ve[Ne+Ee];pe.prev_length>=pe.good_match&&(Ue>>=2),Oe>pe.lookahead&&(Oe=pe.lookahead);do if(Ve[(Le=et)+Ee]===ct&&Ve[Le+Ee-1]===gt&&Ve[Le]===Ve[Ne]&&Ve[++Le]===Ve[Ne+1]){Ne+=2,Le++;do;while(Ve[++Ne]===Ve[++Le]&&Ve[++Ne]===Ve[++Le]&&Ve[++Ne]===Ve[++Le]&&Ve[++Ne]===Ve[++Le]&&Ve[++Ne]===Ve[++Le]&&Ve[++Ne]===Ve[++Le]&&Ve[++Ne]===Ve[++Le]&&Ve[++Ne]===Ve[++Le]&&Ne<at);if(Pe=k-(at-Ne),Ne=at-k,Ee<Pe){if(pe.match_start=et,Oe<=(Ee=Pe))break;gt=Ve[Ne+Ee-1],ct=Ve[Ne+Ee]}}while((et=At[et&je])>we&&--Ue!=0);return Ee<=pe.lookahead?Ee:pe.lookahead}function xe(pe){var et,Le,Pe,Ue,Ne,Ee,Oe,we,Ve,je,At=pe.w_size;do{if(Ue=pe.window_size-pe.lookahead-pe.strstart,pe.strstart>=At+(At-N)){for(s.arraySet(pe.window,pe.window,At,At,0),pe.match_start-=At,pe.strstart-=At,pe.block_start-=At,et=Le=pe.hash_size;Pe=pe.head[--et],pe.head[et]=At<=Pe?Pe-At:0,--Le;);for(et=Le=At;Pe=pe.prev[--et],pe.prev[et]=At<=Pe?Pe-At:0,--Le;);Ue+=At}if(pe.strm.avail_in===0)break;if(Ee=pe.strm,Oe=pe.window,we=pe.strstart+pe.lookahead,Ve=Ue,je=void 0,je=Ee.avail_in,Ve<je&&(je=Ve),Le=je===0?0:(Ee.avail_in-=je,s.arraySet(Oe,Ee.input,Ee.next_in,je,we),Ee.state.wrap===1?Ee.adler=c(Ee.adler,Oe,je,we):Ee.state.wrap===2&&(Ee.adler=l(Ee.adler,Oe,je,we)),Ee.next_in+=je,Ee.total_in+=je,je),pe.lookahead+=Le,pe.lookahead+pe.insert>=w)for(Ne=pe.strstart-pe.insert,pe.ins_h=pe.window[Ne],pe.ins_h=(pe.ins_h<<pe.hash_shift^pe.window[Ne+1])&pe.hash_mask;pe.insert&&(pe.ins_h=(pe.ins_h<<pe.hash_shift^pe.window[Ne+w-1])&pe.hash_mask,pe.prev[Ne&pe.w_mask]=pe.head[pe.ins_h],pe.head[pe.ins_h]=Ne,Ne++,pe.insert--,!(pe.lookahead+pe.insert<w)););}while(pe.lookahead<N&&pe.strm.avail_in!==0)}function be(pe,et){for(var Le,Pe;;){if(pe.lookahead<N){if(xe(pe),pe.lookahead<N&&et===u)return U;if(pe.lookahead===0)break}if(Le=0,pe.lookahead>=w&&(pe.ins_h=(pe.ins_h<<pe.hash_shift^pe.window[pe.strstart+w-1])&pe.hash_mask,Le=pe.prev[pe.strstart&pe.w_mask]=pe.head[pe.ins_h],pe.head[pe.ins_h]=pe.strstart),Le!==0&&pe.strstart-Le<=pe.w_size-N&&(pe.match_length=ye(pe,Le)),pe.match_length>=w)if(Pe=a._tr_tally(pe,pe.strstart-pe.match_start,pe.match_length-w),pe.lookahead-=pe.match_length,pe.match_length<=pe.max_lazy_match&&pe.lookahead>=w){for(pe.match_length--;pe.strstart++,pe.ins_h=(pe.ins_h<<pe.hash_shift^pe.window[pe.strstart+w-1])&pe.hash_mask,Le=pe.prev[pe.strstart&pe.w_mask]=pe.head[pe.ins_h],pe.head[pe.ins_h]=pe.strstart,--pe.match_length!=0;);pe.strstart++}else pe.strstart+=pe.match_length,pe.match_length=0,pe.ins_h=pe.window[pe.strstart],pe.ins_h=(pe.ins_h<<pe.hash_shift^pe.window[pe.strstart+1])&pe.hash_mask;else Pe=a._tr_tally(pe,0,pe.window[pe.strstart]),pe.lookahead--,pe.strstart++;if(Pe&&(ae(pe,!1),pe.strm.avail_out===0))return U}return pe.insert=pe.strstart<w-1?pe.strstart:w-1,et===d?(ae(pe,!0),pe.strm.avail_out===0?W:X):pe.last_lit&&(ae(pe,!1),pe.strm.avail_out===0)?U:J}function he(pe,et){for(var Le,Pe,Ue;;){if(pe.lookahead<N){if(xe(pe),pe.lookahead<N&&et===u)return U;if(pe.lookahead===0)break}if(Le=0,pe.lookahead>=w&&(pe.ins_h=(pe.ins_h<<pe.hash_shift^pe.window[pe.strstart+w-1])&pe.hash_mask,Le=pe.prev[pe.strstart&pe.w_mask]=pe.head[pe.ins_h],pe.head[pe.ins_h]=pe.strstart),pe.prev_length=pe.match_length,pe.prev_match=pe.match_start,pe.match_length=w-1,Le!==0&&pe.prev_length<pe.max_lazy_match&&pe.strstart-Le<=pe.w_size-N&&(pe.match_length=ye(pe,Le),pe.match_length<=5&&(pe.strategy===1||pe.match_length===w&&4096<pe.strstart-pe.match_start)&&(pe.match_length=w-1)),pe.prev_length>=w&&pe.match_length<=pe.prev_length){for(Ue=pe.strstart+pe.lookahead-w,Pe=a._tr_tally(pe,pe.strstart-1-pe.prev_match,pe.prev_length-w),pe.lookahead-=pe.prev_length-1,pe.prev_length-=2;++pe.strstart<=Ue&&(pe.ins_h=(pe.ins_h<<pe.hash_shift^pe.window[pe.strstart+w-1])&pe.hash_mask,Le=pe.prev[pe.strstart&pe.w_mask]=pe.head[pe.ins_h],pe.head[pe.ins_h]=pe.strstart),--pe.prev_length!=0;);if(pe.match_available=0,pe.match_length=w-1,pe.strstart++,Pe&&(ae(pe,!1),pe.strm.avail_out===0))return U}else if(pe.match_available){if((Pe=a._tr_tally(pe,0,pe.window[pe.strstart-1]))&&ae(pe,!1),pe.strstart++,pe.lookahead--,pe.strm.avail_out===0)return U}else pe.match_available=1,pe.strstart++,pe.lookahead--}return pe.match_available&&(Pe=a._tr_tally(pe,0,pe.window[pe.strstart-1]),pe.match_available=0),pe.insert=pe.strstart<w-1?pe.strstart:w-1,et===d?(ae(pe,!0),pe.strm.avail_out===0?W:X):pe.last_lit&&(ae(pe,!1),pe.strm.avail_out===0)?U:J}function Se(pe,et,Le,Pe,Ue){this.good_length=pe,this.max_lazy=et,this.nice_length=Le,this.max_chain=Pe,this.func=Ue}function Ie(){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=C,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 s.Buf16(2*S),this.dyn_dtree=new s.Buf16(2*(2*B+1)),this.bl_tree=new s.Buf16(2*(2*x+1)),ee(this.dyn_ltree),ee(this.dyn_dtree),ee(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new s.Buf16(M+1),this.heap=new s.Buf16(2*y+1),ee(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new s.Buf16(2*y+1),ee(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(pe){var et;return pe&&pe.state?(pe.total_in=pe.total_out=0,pe.data_type=I,(et=pe.state).pending=0,et.pending_out=0,et.wrap<0&&(et.wrap=-et.wrap),et.status=et.wrap?H:G,pe.adler=et.wrap===2?0:1,et.last_flush=u,a._tr_init(et),h):oe(pe,_)}function Je(pe){var et=Ge(pe);return et===h&&(function(Le){Le.window_size=2*Le.w_size,ee(Le.head),Le.max_lazy_match=A[Le.level].max_lazy,Le.good_match=A[Le.level].good_length,Le.nice_match=A[Le.level].nice_length,Le.max_chain_length=A[Le.level].max_chain,Le.strstart=0,Le.block_start=0,Le.lookahead=0,Le.insert=0,Le.match_length=Le.prev_length=w-1,Le.match_available=0,Le.ins_h=0})(pe.state),et}function Ze(pe,et,Le,Pe,Ue,Ne){if(!pe)return _;var Ee=1;if(et===p&&(et=6),Pe<0?(Ee=0,Pe=-Pe):15<Pe&&(Ee=2,Pe-=16),Ue<1||f<Ue||Le!==C||Pe<8||15<Pe||et<0||9<et||Ne<0||m<Ne)return oe(pe,_);Pe===8&&(Pe=9);var Oe=new Ie;return(pe.state=Oe).strm=pe,Oe.wrap=Ee,Oe.gzhead=null,Oe.w_bits=Pe,Oe.w_size=1<<Oe.w_bits,Oe.w_mask=Oe.w_size-1,Oe.hash_bits=Ue+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 s.Buf8(2*Oe.w_size),Oe.head=new s.Buf16(Oe.hash_size),Oe.prev=new s.Buf16(Oe.w_size),Oe.lit_bufsize=1<<Ue+6,Oe.pending_buf_size=4*Oe.lit_bufsize,Oe.pending_buf=new s.Buf8(Oe.pending_buf_size),Oe.d_buf=1*Oe.lit_bufsize,Oe.l_buf=3*Oe.lit_bufsize,Oe.level=et,Oe.strategy=Ne,Oe.method=Le,Je(pe)}A=[new Se(0,0,0,0,function(pe,et){var Le=65535;for(Le>pe.pending_buf_size-5&&(Le=pe.pending_buf_size-5);;){if(pe.lookahead<=1){if(xe(pe),pe.lookahead===0&&et===u)return U;if(pe.lookahead===0)break}pe.strstart+=pe.lookahead,pe.lookahead=0;var Pe=pe.block_start+Le;if((pe.strstart===0||pe.strstart>=Pe)&&(pe.lookahead=pe.strstart-Pe,pe.strstart=Pe,ae(pe,!1),pe.strm.avail_out===0)||pe.strstart-pe.block_start>=pe.w_size-N&&(ae(pe,!1),pe.strm.avail_out===0))return U}return pe.insert=0,et===d?(ae(pe,!0),pe.strm.avail_out===0?W:X):(pe.strstart>pe.block_start&&(ae(pe,!1),pe.strm.avail_out),U)}),new Se(4,4,8,4,be),new Se(4,5,16,8,be),new Se(4,6,32,32,be),new Se(4,4,16,16,he),new Se(8,16,32,32,he),new Se(8,16,128,128,he),new Se(8,32,128,256,he),new Se(32,128,258,1024,he),new Se(32,258,258,4096,he)],r.deflateInit=function(pe,et){return Ze(pe,et,C,15,8,0)},r.deflateInit2=Ze,r.deflateReset=Je,r.deflateResetKeep=Ge,r.deflateSetHeader=function(pe,et){return pe&&pe.state?pe.state.wrap!==2?_:(pe.state.gzhead=et,h):_},r.deflate=function(pe,et){var Le,Pe,Ue,Ne;if(!pe||!pe.state||5<et||et<0)return pe?oe(pe,_):_;if(Pe=pe.state,!pe.output||!pe.input&&pe.avail_in!==0||Pe.status===666&&et!==d)return oe(pe,pe.avail_out===0?-5:_);if(Pe.strm=pe,Le=Pe.last_flush,Pe.last_flush=et,Pe.status===H)if(Pe.wrap===2)pe.adler=0,re(Pe,31),re(Pe,139),re(Pe,8),Pe.gzhead?(re(Pe,(Pe.gzhead.text?1:0)+(Pe.gzhead.hcrc?2:0)+(Pe.gzhead.extra?4:0)+(Pe.gzhead.name?8:0)+(Pe.gzhead.comment?16:0)),re(Pe,255&Pe.gzhead.time),re(Pe,Pe.gzhead.time>>8&255),re(Pe,Pe.gzhead.time>>16&255),re(Pe,Pe.gzhead.time>>24&255),re(Pe,Pe.level===9?2:2<=Pe.strategy||Pe.level<2?4:0),re(Pe,255&Pe.gzhead.os),Pe.gzhead.extra&&Pe.gzhead.extra.length&&(re(Pe,255&Pe.gzhead.extra.length),re(Pe,Pe.gzhead.extra.length>>8&255)),Pe.gzhead.hcrc&&(pe.adler=l(pe.adler,Pe.pending_buf,Pe.pending,0)),Pe.gzindex=0,Pe.status=69):(re(Pe,0),re(Pe,0),re(Pe,0),re(Pe,0),re(Pe,0),re(Pe,Pe.level===9?2:2<=Pe.strategy||Pe.level<2?4:0),re(Pe,3),Pe.status=G);else{var Ee=C+(Pe.w_bits-8<<4)<<8;Ee|=(2<=Pe.strategy||Pe.level<2?0:Pe.level<6?1:Pe.level===6?2:3)<<6,Pe.strstart!==0&&(Ee|=32),Ee+=31-Ee%31,Pe.status=G,le(Pe,Ee),Pe.strstart!==0&&(le(Pe,pe.adler>>>16),le(Pe,65535&pe.adler)),pe.adler=1}if(Pe.status===69)if(Pe.gzhead.extra){for(Ue=Pe.pending;Pe.gzindex<(65535&Pe.gzhead.extra.length)&&(Pe.pending!==Pe.pending_buf_size||(Pe.gzhead.hcrc&&Pe.pending>Ue&&(pe.adler=l(pe.adler,Pe.pending_buf,Pe.pending-Ue,Ue)),ie(pe),Ue=Pe.pending,Pe.pending!==Pe.pending_buf_size));)re(Pe,255&Pe.gzhead.extra[Pe.gzindex]),Pe.gzindex++;Pe.gzhead.hcrc&&Pe.pending>Ue&&(pe.adler=l(pe.adler,Pe.pending_buf,Pe.pending-Ue,Ue)),Pe.gzindex===Pe.gzhead.extra.length&&(Pe.gzindex=0,Pe.status=73)}else Pe.status=73;if(Pe.status===73)if(Pe.gzhead.name){Ue=Pe.pending;do{if(Pe.pending===Pe.pending_buf_size&&(Pe.gzhead.hcrc&&Pe.pending>Ue&&(pe.adler=l(pe.adler,Pe.pending_buf,Pe.pending-Ue,Ue)),ie(pe),Ue=Pe.pending,Pe.pending===Pe.pending_buf_size)){Ne=1;break}Ne=Pe.gzindex<Pe.gzhead.name.length?255&Pe.gzhead.name.charCodeAt(Pe.gzindex++):0,re(Pe,Ne)}while(Ne!==0);Pe.gzhead.hcrc&&Pe.pending>Ue&&(pe.adler=l(pe.adler,Pe.pending_buf,Pe.pending-Ue,Ue)),Ne===0&&(Pe.gzindex=0,Pe.status=91)}else Pe.status=91;if(Pe.status===91)if(Pe.gzhead.comment){Ue=Pe.pending;do{if(Pe.pending===Pe.pending_buf_size&&(Pe.gzhead.hcrc&&Pe.pending>Ue&&(pe.adler=l(pe.adler,Pe.pending_buf,Pe.pending-Ue,Ue)),ie(pe),Ue=Pe.pending,Pe.pending===Pe.pending_buf_size)){Ne=1;break}Ne=Pe.gzindex<Pe.gzhead.comment.length?255&Pe.gzhead.comment.charCodeAt(Pe.gzindex++):0,re(Pe,Ne)}while(Ne!==0);Pe.gzhead.hcrc&&Pe.pending>Ue&&(pe.adler=l(pe.adler,Pe.pending_buf,Pe.pending-Ue,Ue)),Ne===0&&(Pe.status=103)}else Pe.status=103;if(Pe.status===103&&(Pe.gzhead.hcrc?(Pe.pending+2>Pe.pending_buf_size&&ie(pe),Pe.pending+2<=Pe.pending_buf_size&&(re(Pe,255&pe.adler),re(Pe,pe.adler>>8&255),pe.adler=0,Pe.status=G)):Pe.status=G),Pe.pending!==0){if(ie(pe),pe.avail_out===0)return Pe.last_flush=-1,h}else if(pe.avail_in===0&&ce(et)<=ce(Le)&&et!==d)return oe(pe,-5);if(Pe.status===666&&pe.avail_in!==0)return oe(pe,-5);if(pe.avail_in!==0||Pe.lookahead!==0||et!==u&&Pe.status!==666){var Oe=Pe.strategy===2?(function(we,Ve){for(var je;;){if(we.lookahead===0&&(xe(we),we.lookahead===0)){if(Ve===u)return U;break}if(we.match_length=0,je=a._tr_tally(we,0,we.window[we.strstart]),we.lookahead--,we.strstart++,je&&(ae(we,!1),we.strm.avail_out===0))return U}return we.insert=0,Ve===d?(ae(we,!0),we.strm.avail_out===0?W:X):we.last_lit&&(ae(we,!1),we.strm.avail_out===0)?U:J})(Pe,et):Pe.strategy===3?(function(we,Ve){for(var je,At,at,gt,ct=we.window;;){if(we.lookahead<=k){if(xe(we),we.lookahead<=k&&Ve===u)return U;if(we.lookahead===0)break}if(we.match_length=0,we.lookahead>=w&&0<we.strstart&&(At=ct[at=we.strstart-1])===ct[++at]&&At===ct[++at]&&At===ct[++at]){gt=we.strstart+k;do;while(At===ct[++at]&&At===ct[++at]&&At===ct[++at]&&At===ct[++at]&&At===ct[++at]&&At===ct[++at]&&At===ct[++at]&&At===ct[++at]&&at<gt);we.match_length=k-(gt-at),we.match_length>we.lookahead&&(we.match_length=we.lookahead)}if(we.match_length>=w?(je=a._tr_tally(we,1,we.match_length-w),we.lookahead-=we.match_length,we.strstart+=we.match_length,we.match_length=0):(je=a._tr_tally(we,0,we.window[we.strstart]),we.lookahead--,we.strstart++),je&&(ae(we,!1),we.strm.avail_out===0))return U}return we.insert=0,Ve===d?(ae(we,!0),we.strm.avail_out===0?W:X):we.last_lit&&(ae(we,!1),we.strm.avail_out===0)?U:J})(Pe,et):A[Pe.level].func(Pe,et);if(Oe!==W&&Oe!==X||(Pe.status=666),Oe===U||Oe===W)return pe.avail_out===0&&(Pe.last_flush=-1),h;if(Oe===J&&(et===1?a._tr_align(Pe):et!==5&&(a._tr_stored_block(Pe,0,0,!1),et===3&&(ee(Pe.head),Pe.lookahead===0&&(Pe.strstart=0,Pe.block_start=0,Pe.insert=0))),ie(pe),pe.avail_out===0))return Pe.last_flush=-1,h}return et!==d?h:Pe.wrap<=0?1:(Pe.wrap===2?(re(Pe,255&pe.adler),re(Pe,pe.adler>>8&255),re(Pe,pe.adler>>16&255),re(Pe,pe.adler>>24&255),re(Pe,255&pe.total_in),re(Pe,pe.total_in>>8&255),re(Pe,pe.total_in>>16&255),re(Pe,pe.total_in>>24&255)):(le(Pe,pe.adler>>>16),le(Pe,65535&pe.adler)),ie(pe),0<Pe.wrap&&(Pe.wrap=-Pe.wrap),Pe.pending!==0?h:1)},r.deflateEnd=function(pe){var et;return pe&&pe.state?(et=pe.state.status)!==H&&et!==69&&et!==73&&et!==91&&et!==103&&et!==G&&et!==666?oe(pe,_):(pe.state=null,et===G?oe(pe,-3):h):_},r.deflateSetDictionary=function(pe,et){var Le,Pe,Ue,Ne,Ee,Oe,we,Ve,je=et.length;if(!pe||!pe.state||(Ne=(Le=pe.state).wrap)===2||Ne===1&&Le.status!==H||Le.lookahead)return _;for(Ne===1&&(pe.adler=c(pe.adler,et,je,0)),Le.wrap=0,je>=Le.w_size&&(Ne===0&&(ee(Le.head),Le.strstart=0,Le.block_start=0,Le.insert=0),Ve=new s.Buf8(Le.w_size),s.arraySet(Ve,et,je-Le.w_size,Le.w_size,0),et=Ve,je=Le.w_size),Ee=pe.avail_in,Oe=pe.next_in,we=pe.input,pe.avail_in=je,pe.next_in=0,pe.input=et,xe(Le);Le.lookahead>=w;){for(Pe=Le.strstart,Ue=Le.lookahead-(w-1);Le.ins_h=(Le.ins_h<<Le.hash_shift^Le.window[Pe+w-1])&Le.hash_mask,Le.prev[Pe&Le.w_mask]=Le.head[Le.ins_h],Le.head[Le.ins_h]=Pe,Pe++,--Ue;);Le.strstart=Pe,Le.lookahead=w-1,xe(Le)}return Le.strstart+=Le.lookahead,Le.block_start=Le.strstart,Le.insert=Le.lookahead,Le.lookahead=0,Le.match_length=Le.prev_length=w-1,Le.match_available=0,pe.next_in=Oe,pe.input=we,pe.avail_in=Ee,Le.wrap=Ne,h},r.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(o,i,r){i.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(o,i,r){i.exports=function(A,s){var a,c,l,g,u,d,h,_,p,m,I,C,f,y,B,x,S,M,w,k,N,H,G,U,J;a=A.state,c=A.next_in,U=A.input,l=c+(A.avail_in-5),g=A.next_out,J=A.output,u=g-(s-A.avail_out),d=g+(A.avail_out-257),h=a.dmax,_=a.wsize,p=a.whave,m=a.wnext,I=a.window,C=a.hold,f=a.bits,y=a.lencode,B=a.distcode,x=(1<<a.lenbits)-1,S=(1<<a.distbits)-1;e:do{f<15&&(C+=U[c++]<<f,f+=8,C+=U[c++]<<f,f+=8),M=y[C&x];t:for(;;){if(C>>>=w=M>>>24,f-=w,(w=M>>>16&255)===0)J[g++]=65535&M;else{if(!(16&w)){if((64&w)==0){M=y[(65535&M)+(C&(1<<w)-1)];continue t}if(32&w){a.mode=12;break e}A.msg="invalid literal/length code",a.mode=30;break e}k=65535&M,(w&=15)&&(f<w&&(C+=U[c++]<<f,f+=8),k+=C&(1<<w)-1,C>>>=w,f-=w),f<15&&(C+=U[c++]<<f,f+=8,C+=U[c++]<<f,f+=8),M=B[C&S];n:for(;;){if(C>>>=w=M>>>24,f-=w,!(16&(w=M>>>16&255))){if((64&w)==0){M=B[(65535&M)+(C&(1<<w)-1)];continue n}A.msg="invalid distance code",a.mode=30;break e}if(N=65535&M,f<(w&=15)&&(C+=U[c++]<<f,(f+=8)<w&&(C+=U[c++]<<f,f+=8)),h<(N+=C&(1<<w)-1)){A.msg="invalid distance too far back",a.mode=30;break e}if(C>>>=w,f-=w,(w=g-u)<N){if(p<(w=N-w)&&a.sane){A.msg="invalid distance too far back",a.mode=30;break e}if(G=I,(H=0)===m){if(H+=_-w,w<k){for(k-=w;J[g++]=I[H++],--w;);H=g-N,G=J}}else if(m<w){if(H+=_+m-w,(w-=m)<k){for(k-=w;J[g++]=I[H++],--w;);if(H=0,m<k){for(k-=w=m;J[g++]=I[H++],--w;);H=g-N,G=J}}}else if(H+=m-w,w<k){for(k-=w;J[g++]=I[H++],--w;);H=g-N,G=J}for(;2<k;)J[g++]=G[H++],J[g++]=G[H++],J[g++]=G[H++],k-=3;k&&(J[g++]=G[H++],1<k&&(J[g++]=G[H++]))}else{for(H=g-N;J[g++]=J[H++],J[g++]=J[H++],J[g++]=J[H++],2<(k-=3););k&&(J[g++]=J[H++],1<k&&(J[g++]=J[H++]))}break}}break}}while(c<l&&g<d);c-=k=f>>3,C&=(1<<(f-=k<<3))-1,A.next_in=c,A.next_out=g,A.avail_in=c<l?l-c+5:5-(c-l),A.avail_out=g<d?d-g+257:257-(g-d),a.hold=C,a.bits=f}},{}],49:[function(o,i,r){var A=o("../utils/common"),s=o("./adler32"),a=o("./crc32"),c=o("./inffast"),l=o("./inftrees"),g=1,u=2,d=0,h=-2,_=1,p=852,m=592;function I(H){return(H>>>24&255)+(H>>>8&65280)+((65280&H)<<8)+((255&H)<<24)}function C(){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 A.Buf16(320),this.work=new A.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function f(H){var G;return H&&H.state?(G=H.state,H.total_in=H.total_out=G.total=0,H.msg="",G.wrap&&(H.adler=1&G.wrap),G.mode=_,G.last=0,G.havedict=0,G.dmax=32768,G.head=null,G.hold=0,G.bits=0,G.lencode=G.lendyn=new A.Buf32(p),G.distcode=G.distdyn=new A.Buf32(m),G.sane=1,G.back=-1,d):h}function y(H){var G;return H&&H.state?((G=H.state).wsize=0,G.whave=0,G.wnext=0,f(H)):h}function B(H,G){var U,J;return H&&H.state?(J=H.state,G<0?(U=0,G=-G):(U=1+(G>>4),G<48&&(G&=15)),G&&(G<8||15<G)?h:(J.window!==null&&J.wbits!==G&&(J.window=null),J.wrap=U,J.wbits=G,y(H))):h}function x(H,G){var U,J;return H?(J=new C,(H.state=J).window=null,(U=B(H,G))!==d&&(H.state=null),U):h}var S,M,w=!0;function k(H){if(w){var G;for(S=new A.Buf32(512),M=new A.Buf32(32),G=0;G<144;)H.lens[G++]=8;for(;G<256;)H.lens[G++]=9;for(;G<280;)H.lens[G++]=7;for(;G<288;)H.lens[G++]=8;for(l(g,H.lens,0,288,S,0,H.work,{bits:9}),G=0;G<32;)H.lens[G++]=5;l(u,H.lens,0,32,M,0,H.work,{bits:5}),w=!1}H.lencode=S,H.lenbits=9,H.distcode=M,H.distbits=5}function N(H,G,U,J){var W,X=H.state;return X.window===null&&(X.wsize=1<<X.wbits,X.wnext=0,X.whave=0,X.window=new A.Buf8(X.wsize)),J>=X.wsize?(A.arraySet(X.window,G,U-X.wsize,X.wsize,0),X.wnext=0,X.whave=X.wsize):(J<(W=X.wsize-X.wnext)&&(W=J),A.arraySet(X.window,G,U-J,W,X.wnext),(J-=W)?(A.arraySet(X.window,G,U-J,J,0),X.wnext=J,X.whave=X.wsize):(X.wnext+=W,X.wnext===X.wsize&&(X.wnext=0),X.whave<X.wsize&&(X.whave+=W))),0}r.inflateReset=y,r.inflateReset2=B,r.inflateResetKeep=f,r.inflateInit=function(H){return x(H,15)},r.inflateInit2=x,r.inflate=function(H,G){var U,J,W,X,oe,ce,ee,ie,ae,re,le,ye,xe,be,he,Se,Ie,Ge,Je,Ze,pe,et,Le,Pe,Ue=0,Ne=new A.Buf8(4),Ee=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!H||!H.state||!H.output||!H.input&&H.avail_in!==0)return h;(U=H.state).mode===12&&(U.mode=13),oe=H.next_out,W=H.output,ee=H.avail_out,X=H.next_in,J=H.input,ce=H.avail_in,ie=U.hold,ae=U.bits,re=ce,le=ee,et=d;e:for(;;)switch(U.mode){case _:if(U.wrap===0){U.mode=13;break}for(;ae<16;){if(ce===0)break e;ce--,ie+=J[X++]<<ae,ae+=8}if(2&U.wrap&&ie===35615){Ne[U.check=0]=255&ie,Ne[1]=ie>>>8&255,U.check=a(U.check,Ne,2,0),ae=ie=0,U.mode=2;break}if(U.flags=0,U.head&&(U.head.done=!1),!(1&U.wrap)||(((255&ie)<<8)+(ie>>8))%31){H.msg="incorrect header check",U.mode=30;break}if((15&ie)!=8){H.msg="unknown compression method",U.mode=30;break}if(ae-=4,pe=8+(15&(ie>>>=4)),U.wbits===0)U.wbits=pe;else if(pe>U.wbits){H.msg="invalid window size",U.mode=30;break}U.dmax=1<<pe,H.adler=U.check=1,U.mode=512&ie?10:12,ae=ie=0;break;case 2:for(;ae<16;){if(ce===0)break e;ce--,ie+=J[X++]<<ae,ae+=8}if(U.flags=ie,(255&U.flags)!=8){H.msg="unknown compression method",U.mode=30;break}if(57344&U.flags){H.msg="unknown header flags set",U.mode=30;break}U.head&&(U.head.text=ie>>8&1),512&U.flags&&(Ne[0]=255&ie,Ne[1]=ie>>>8&255,U.check=a(U.check,Ne,2,0)),ae=ie=0,U.mode=3;case 3:for(;ae<32;){if(ce===0)break e;ce--,ie+=J[X++]<<ae,ae+=8}U.head&&(U.head.time=ie),512&U.flags&&(Ne[0]=255&ie,Ne[1]=ie>>>8&255,Ne[2]=ie>>>16&255,Ne[3]=ie>>>24&255,U.check=a(U.check,Ne,4,0)),ae=ie=0,U.mode=4;case 4:for(;ae<16;){if(ce===0)break e;ce--,ie+=J[X++]<<ae,ae+=8}U.head&&(U.head.xflags=255&ie,U.head.os=ie>>8),512&U.flags&&(Ne[0]=255&ie,Ne[1]=ie>>>8&255,U.check=a(U.check,Ne,2,0)),ae=ie=0,U.mode=5;case 5:if(1024&U.flags){for(;ae<16;){if(ce===0)break e;ce--,ie+=J[X++]<<ae,ae+=8}U.length=ie,U.head&&(U.head.extra_len=ie),512&U.flags&&(Ne[0]=255&ie,Ne[1]=ie>>>8&255,U.check=a(U.check,Ne,2,0)),ae=ie=0}else U.head&&(U.head.extra=null);U.mode=6;case 6:if(1024&U.flags&&(ce<(ye=U.length)&&(ye=ce),ye&&(U.head&&(pe=U.head.extra_len-U.length,U.head.extra||(U.head.extra=new Array(U.head.extra_len)),A.arraySet(U.head.extra,J,X,ye,pe)),512&U.flags&&(U.check=a(U.check,J,ye,X)),ce-=ye,X+=ye,U.length-=ye),U.length))break e;U.length=0,U.mode=7;case 7:if(2048&U.flags){if(ce===0)break e;for(ye=0;pe=J[X+ye++],U.head&&pe&&U.length<65536&&(U.head.name+=String.fromCharCode(pe)),pe&&ye<ce;);if(512&U.flags&&(U.check=a(U.check,J,ye,X)),ce-=ye,X+=ye,pe)break e}else U.head&&(U.head.name=null);U.length=0,U.mode=8;case 8:if(4096&U.flags){if(ce===0)break e;for(ye=0;pe=J[X+ye++],U.head&&pe&&U.length<65536&&(U.head.comment+=String.fromCharCode(pe)),pe&&ye<ce;);if(512&U.flags&&(U.check=a(U.check,J,ye,X)),ce-=ye,X+=ye,pe)break e}else U.head&&(U.head.comment=null);U.mode=9;case 9:if(512&U.flags){for(;ae<16;){if(ce===0)break e;ce--,ie+=J[X++]<<ae,ae+=8}if(ie!==(65535&U.check)){H.msg="header crc mismatch",U.mode=30;break}ae=ie=0}U.head&&(U.head.hcrc=U.flags>>9&1,U.head.done=!0),H.adler=U.check=0,U.mode=12;break;case 10:for(;ae<32;){if(ce===0)break e;ce--,ie+=J[X++]<<ae,ae+=8}H.adler=U.check=I(ie),ae=ie=0,U.mode=11;case 11:if(U.havedict===0)return H.next_out=oe,H.avail_out=ee,H.next_in=X,H.avail_in=ce,U.hold=ie,U.bits=ae,2;H.adler=U.check=1,U.mode=12;case 12:if(G===5||G===6)break e;case 13:if(U.last){ie>>>=7&ae,ae-=7&ae,U.mode=27;break}for(;ae<3;){if(ce===0)break e;ce--,ie+=J[X++]<<ae,ae+=8}switch(U.last=1&ie,ae-=1,3&(ie>>>=1)){case 0:U.mode=14;break;case 1:if(k(U),U.mode=20,G!==6)break;ie>>>=2,ae-=2;break e;case 2:U.mode=17;break;case 3:H.msg="invalid block type",U.mode=30}ie>>>=2,ae-=2;break;case 14:for(ie>>>=7&ae,ae-=7&ae;ae<32;){if(ce===0)break e;ce--,ie+=J[X++]<<ae,ae+=8}if((65535&ie)!=(ie>>>16^65535)){H.msg="invalid stored block lengths",U.mode=30;break}if(U.length=65535&ie,ae=ie=0,U.mode=15,G===6)break e;case 15:U.mode=16;case 16:if(ye=U.length){if(ce<ye&&(ye=ce),ee<ye&&(ye=ee),ye===0)break e;A.arraySet(W,J,X,ye,oe),ce-=ye,X+=ye,ee-=ye,oe+=ye,U.length-=ye;break}U.mode=12;break;case 17:for(;ae<14;){if(ce===0)break e;ce--,ie+=J[X++]<<ae,ae+=8}if(U.nlen=257+(31&ie),ie>>>=5,ae-=5,U.ndist=1+(31&ie),ie>>>=5,ae-=5,U.ncode=4+(15&ie),ie>>>=4,ae-=4,286<U.nlen||30<U.ndist){H.msg="too many length or distance symbols",U.mode=30;break}U.have=0,U.mode=18;case 18:for(;U.have<U.ncode;){for(;ae<3;){if(ce===0)break e;ce--,ie+=J[X++]<<ae,ae+=8}U.lens[Ee[U.have++]]=7&ie,ie>>>=3,ae-=3}for(;U.have<19;)U.lens[Ee[U.have++]]=0;if(U.lencode=U.lendyn,U.lenbits=7,Le={bits:U.lenbits},et=l(0,U.lens,0,19,U.lencode,0,U.work,Le),U.lenbits=Le.bits,et){H.msg="invalid code lengths set",U.mode=30;break}U.have=0,U.mode=19;case 19:for(;U.have<U.nlen+U.ndist;){for(;Se=(Ue=U.lencode[ie&(1<<U.lenbits)-1])>>>16&255,Ie=65535&Ue,!((he=Ue>>>24)<=ae);){if(ce===0)break e;ce--,ie+=J[X++]<<ae,ae+=8}if(Ie<16)ie>>>=he,ae-=he,U.lens[U.have++]=Ie;else{if(Ie===16){for(Pe=he+2;ae<Pe;){if(ce===0)break e;ce--,ie+=J[X++]<<ae,ae+=8}if(ie>>>=he,ae-=he,U.have===0){H.msg="invalid bit length repeat",U.mode=30;break}pe=U.lens[U.have-1],ye=3+(3&ie),ie>>>=2,ae-=2}else if(Ie===17){for(Pe=he+3;ae<Pe;){if(ce===0)break e;ce--,ie+=J[X++]<<ae,ae+=8}ae-=he,pe=0,ye=3+(7&(ie>>>=he)),ie>>>=3,ae-=3}else{for(Pe=he+7;ae<Pe;){if(ce===0)break e;ce--,ie+=J[X++]<<ae,ae+=8}ae-=he,pe=0,ye=11+(127&(ie>>>=he)),ie>>>=7,ae-=7}if(U.have+ye>U.nlen+U.ndist){H.msg="invalid bit length repeat",U.mode=30;break}for(;ye--;)U.lens[U.have++]=pe}}if(U.mode===30)break;if(U.lens[256]===0){H.msg="invalid code -- missing end-of-block",U.mode=30;break}if(U.lenbits=9,Le={bits:U.lenbits},et=l(g,U.lens,0,U.nlen,U.lencode,0,U.work,Le),U.lenbits=Le.bits,et){H.msg="invalid literal/lengths set",U.mode=30;break}if(U.distbits=6,U.distcode=U.distdyn,Le={bits:U.distbits},et=l(u,U.lens,U.nlen,U.ndist,U.distcode,0,U.work,Le),U.distbits=Le.bits,et){H.msg="invalid distances set",U.mode=30;break}if(U.mode=20,G===6)break e;case 20:U.mode=21;case 21:if(6<=ce&&258<=ee){H.next_out=oe,H.avail_out=ee,H.next_in=X,H.avail_in=ce,U.hold=ie,U.bits=ae,c(H,le),oe=H.next_out,W=H.output,ee=H.avail_out,X=H.next_in,J=H.input,ce=H.avail_in,ie=U.hold,ae=U.bits,U.mode===12&&(U.back=-1);break}for(U.back=0;Se=(Ue=U.lencode[ie&(1<<U.lenbits)-1])>>>16&255,Ie=65535&Ue,!((he=Ue>>>24)<=ae);){if(ce===0)break e;ce--,ie+=J[X++]<<ae,ae+=8}if(Se&&(240&Se)==0){for(Ge=he,Je=Se,Ze=Ie;Se=(Ue=U.lencode[Ze+((ie&(1<<Ge+Je)-1)>>Ge)])>>>16&255,Ie=65535&Ue,!(Ge+(he=Ue>>>24)<=ae);){if(ce===0)break e;ce--,ie+=J[X++]<<ae,ae+=8}ie>>>=Ge,ae-=Ge,U.back+=Ge}if(ie>>>=he,ae-=he,U.back+=he,U.length=Ie,Se===0){U.mode=26;break}if(32&Se){U.back=-1,U.mode=12;break}if(64&Se){H.msg="invalid literal/length code",U.mode=30;break}U.extra=15&Se,U.mode=22;case 22:if(U.extra){for(Pe=U.extra;ae<Pe;){if(ce===0)break e;ce--,ie+=J[X++]<<ae,ae+=8}U.length+=ie&(1<<U.extra)-1,ie>>>=U.extra,ae-=U.extra,U.back+=U.extra}U.was=U.length,U.mode=23;case 23:for(;Se=(Ue=U.distcode[ie&(1<<U.distbits)-1])>>>16&255,Ie=65535&Ue,!((he=Ue>>>24)<=ae);){if(ce===0)break e;ce--,ie+=J[X++]<<ae,ae+=8}if((240&Se)==0){for(Ge=he,Je=Se,Ze=Ie;Se=(Ue=U.distcode[Ze+((ie&(1<<Ge+Je)-1)>>Ge)])>>>16&255,Ie=65535&Ue,!(Ge+(he=Ue>>>24)<=ae);){if(ce===0)break e;ce--,ie+=J[X++]<<ae,ae+=8}ie>>>=Ge,ae-=Ge,U.back+=Ge}if(ie>>>=he,ae-=he,U.back+=he,64&Se){H.msg="invalid distance code",U.mode=30;break}U.offset=Ie,U.extra=15&Se,U.mode=24;case 24:if(U.extra){for(Pe=U.extra;ae<Pe;){if(ce===0)break e;ce--,ie+=J[X++]<<ae,ae+=8}U.offset+=ie&(1<<U.extra)-1,ie>>>=U.extra,ae-=U.extra,U.back+=U.extra}if(U.offset>U.dmax){H.msg="invalid distance too far back",U.mode=30;break}U.mode=25;case 25:if(ee===0)break e;if(ye=le-ee,U.offset>ye){if((ye=U.offset-ye)>U.whave&&U.sane){H.msg="invalid distance too far back",U.mode=30;break}xe=ye>U.wnext?(ye-=U.wnext,U.wsize-ye):U.wnext-ye,ye>U.length&&(ye=U.length),be=U.window}else be=W,xe=oe-U.offset,ye=U.length;for(ee<ye&&(ye=ee),ee-=ye,U.length-=ye;W[oe++]=be[xe++],--ye;);U.length===0&&(U.mode=21);break;case 26:if(ee===0)break e;W[oe++]=U.length,ee--,U.mode=21;break;case 27:if(U.wrap){for(;ae<32;){if(ce===0)break e;ce--,ie|=J[X++]<<ae,ae+=8}if(le-=ee,H.total_out+=le,U.total+=le,le&&(H.adler=U.check=U.flags?a(U.check,W,le,oe-le):s(U.check,W,le,oe-le)),le=ee,(U.flags?ie:I(ie))!==U.check){H.msg="incorrect data check",U.mode=30;break}ae=ie=0}U.mode=28;case 28:if(U.wrap&&U.flags){for(;ae<32;){if(ce===0)break e;ce--,ie+=J[X++]<<ae,ae+=8}if(ie!==(4294967295&U.total)){H.msg="incorrect length check",U.mode=30;break}ae=ie=0}U.mode=29;case 29:et=1;break e;case 30:et=-3;break e;case 31:return-4;default:return h}return H.next_out=oe,H.avail_out=ee,H.next_in=X,H.avail_in=ce,U.hold=ie,U.bits=ae,(U.wsize||le!==H.avail_out&&U.mode<30&&(U.mode<27||G!==4))&&N(H,H.output,H.next_out,le-H.avail_out)?(U.mode=31,-4):(re-=H.avail_in,le-=H.avail_out,H.total_in+=re,H.total_out+=le,U.total+=le,U.wrap&&le&&(H.adler=U.check=U.flags?a(U.check,W,le,H.next_out-le):s(U.check,W,le,H.next_out-le)),H.data_type=U.bits+(U.last?64:0)+(U.mode===12?128:0)+(U.mode===20||U.mode===15?256:0),(re==0&&le===0||G===4)&&et===d&&(et=-5),et)},r.inflateEnd=function(H){if(!H||!H.state)return h;var G=H.state;return G.window&&(G.window=null),H.state=null,d},r.inflateGetHeader=function(H,G){var U;return H&&H.state?(2&(U=H.state).wrap)==0?h:((U.head=G).done=!1,d):h},r.inflateSetDictionary=function(H,G){var U,J=G.length;return H&&H.state?(U=H.state).wrap!==0&&U.mode!==11?h:U.mode===11&&s(1,G,J,0)!==U.check?-3:N(H,G,J,J)?(U.mode=31,-4):(U.havedict=1,d):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 A=o("../utils/common"),s=[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],a=[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],c=[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],l=[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(g,u,d,h,_,p,m,I){var C,f,y,B,x,S,M,w,k,N=I.bits,H=0,G=0,U=0,J=0,W=0,X=0,oe=0,ce=0,ee=0,ie=0,ae=null,re=0,le=new A.Buf16(16),ye=new A.Buf16(16),xe=null,be=0;for(H=0;H<=15;H++)le[H]=0;for(G=0;G<h;G++)le[u[d+G]]++;for(W=N,J=15;1<=J&&le[J]===0;J--);if(J<W&&(W=J),J===0)return _[p++]=20971520,_[p++]=20971520,I.bits=1,0;for(U=1;U<J&&le[U]===0;U++);for(W<U&&(W=U),H=ce=1;H<=15;H++)if(ce<<=1,(ce-=le[H])<0)return-1;if(0<ce&&(g===0||J!==1))return-1;for(ye[1]=0,H=1;H<15;H++)ye[H+1]=ye[H]+le[H];for(G=0;G<h;G++)u[d+G]!==0&&(m[ye[u[d+G]]++]=G);if(S=g===0?(ae=xe=m,19):g===1?(ae=s,re-=257,xe=a,be-=257,256):(ae=c,xe=l,-1),H=U,x=p,oe=G=ie=0,y=-1,B=(ee=1<<(X=W))-1,g===1&&852<ee||g===2&&592<ee)return 1;for(;;){for(M=H-oe,k=m[G]<S?(w=0,m[G]):m[G]>S?(w=xe[be+m[G]],ae[re+m[G]]):(w=96,0),C=1<<H-oe,U=f=1<<X;_[x+(ie>>oe)+(f-=C)]=M<<24|w<<16|k|0,f!==0;);for(C=1<<H-1;ie&C;)C>>=1;if(C!==0?(ie&=C-1,ie+=C):ie=0,G++,--le[H]==0){if(H===J)break;H=u[d+m[G]]}if(W<H&&(ie&B)!==y){for(oe===0&&(oe=W),x+=U,ce=1<<(X=H-oe);X+oe<J&&!((ce-=le[X+oe])<=0);)X++,ce<<=1;if(ee+=1<<X,g===1&&852<ee||g===2&&592<ee)return 1;_[y=ie&B]=W<<24|X<<16|x-p|0}}return ie!==0&&(_[x+ie]=H-oe<<24|64<<16|0),I.bits=W,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 A=o("../utils/common"),s=0,a=1;function c(Ue){for(var Ne=Ue.length;0<=--Ne;)Ue[Ne]=0}var l=0,g=29,u=256,d=u+1+g,h=30,_=19,p=2*d+1,m=15,I=16,C=7,f=256,y=16,B=17,x=18,S=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],M=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],w=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],k=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],N=new Array(2*(d+2));c(N);var H=new Array(2*h);c(H);var G=new Array(512);c(G);var U=new Array(256);c(U);var J=new Array(g);c(J);var W,X,oe,ce=new Array(h);function ee(Ue,Ne,Ee,Oe,we){this.static_tree=Ue,this.extra_bits=Ne,this.extra_base=Ee,this.elems=Oe,this.max_length=we,this.has_stree=Ue&&Ue.length}function ie(Ue,Ne){this.dyn_tree=Ue,this.max_code=0,this.stat_desc=Ne}function ae(Ue){return Ue<256?G[Ue]:G[256+(Ue>>>7)]}function re(Ue,Ne){Ue.pending_buf[Ue.pending++]=255&Ne,Ue.pending_buf[Ue.pending++]=Ne>>>8&255}function le(Ue,Ne,Ee){Ue.bi_valid>I-Ee?(Ue.bi_buf|=Ne<<Ue.bi_valid&65535,re(Ue,Ue.bi_buf),Ue.bi_buf=Ne>>I-Ue.bi_valid,Ue.bi_valid+=Ee-I):(Ue.bi_buf|=Ne<<Ue.bi_valid&65535,Ue.bi_valid+=Ee)}function ye(Ue,Ne,Ee){le(Ue,Ee[2*Ne],Ee[2*Ne+1])}function xe(Ue,Ne){for(var Ee=0;Ee|=1&Ue,Ue>>>=1,Ee<<=1,0<--Ne;);return Ee>>>1}function be(Ue,Ne,Ee){var Oe,we,Ve=new Array(m+1),je=0;for(Oe=1;Oe<=m;Oe++)Ve[Oe]=je=je+Ee[Oe-1]<<1;for(we=0;we<=Ne;we++){var At=Ue[2*we+1];At!==0&&(Ue[2*we]=xe(Ve[At]++,At))}}function he(Ue){var Ne;for(Ne=0;Ne<d;Ne++)Ue.dyn_ltree[2*Ne]=0;for(Ne=0;Ne<h;Ne++)Ue.dyn_dtree[2*Ne]=0;for(Ne=0;Ne<_;Ne++)Ue.bl_tree[2*Ne]=0;Ue.dyn_ltree[2*f]=1,Ue.opt_len=Ue.static_len=0,Ue.last_lit=Ue.matches=0}function Se(Ue){8<Ue.bi_valid?re(Ue,Ue.bi_buf):0<Ue.bi_valid&&(Ue.pending_buf[Ue.pending++]=Ue.bi_buf),Ue.bi_buf=0,Ue.bi_valid=0}function Ie(Ue,Ne,Ee,Oe){var we=2*Ne,Ve=2*Ee;return Ue[we]<Ue[Ve]||Ue[we]===Ue[Ve]&&Oe[Ne]<=Oe[Ee]}function Ge(Ue,Ne,Ee){for(var Oe=Ue.heap[Ee],we=Ee<<1;we<=Ue.heap_len&&(we<Ue.heap_len&&Ie(Ne,Ue.heap[we+1],Ue.heap[we],Ue.depth)&&we++,!Ie(Ne,Oe,Ue.heap[we],Ue.depth));)Ue.heap[Ee]=Ue.heap[we],Ee=we,we<<=1;Ue.heap[Ee]=Oe}function Je(Ue,Ne,Ee){var Oe,we,Ve,je,At=0;if(Ue.last_lit!==0)for(;Oe=Ue.pending_buf[Ue.d_buf+2*At]<<8|Ue.pending_buf[Ue.d_buf+2*At+1],we=Ue.pending_buf[Ue.l_buf+At],At++,Oe===0?ye(Ue,we,Ne):(ye(Ue,(Ve=U[we])+u+1,Ne),(je=S[Ve])!==0&&le(Ue,we-=J[Ve],je),ye(Ue,Ve=ae(--Oe),Ee),(je=M[Ve])!==0&&le(Ue,Oe-=ce[Ve],je)),At<Ue.last_lit;);ye(Ue,f,Ne)}function Ze(Ue,Ne){var Ee,Oe,we,Ve=Ne.dyn_tree,je=Ne.stat_desc.static_tree,At=Ne.stat_desc.has_stree,at=Ne.stat_desc.elems,gt=-1;for(Ue.heap_len=0,Ue.heap_max=p,Ee=0;Ee<at;Ee++)Ve[2*Ee]!==0?(Ue.heap[++Ue.heap_len]=gt=Ee,Ue.depth[Ee]=0):Ve[2*Ee+1]=0;for(;Ue.heap_len<2;)Ve[2*(we=Ue.heap[++Ue.heap_len]=gt<2?++gt:0)]=1,Ue.depth[we]=0,Ue.opt_len--,At&&(Ue.static_len-=je[2*we+1]);for(Ne.max_code=gt,Ee=Ue.heap_len>>1;1<=Ee;Ee--)Ge(Ue,Ve,Ee);for(we=at;Ee=Ue.heap[1],Ue.heap[1]=Ue.heap[Ue.heap_len--],Ge(Ue,Ve,1),Oe=Ue.heap[1],Ue.heap[--Ue.heap_max]=Ee,Ue.heap[--Ue.heap_max]=Oe,Ve[2*we]=Ve[2*Ee]+Ve[2*Oe],Ue.depth[we]=(Ue.depth[Ee]>=Ue.depth[Oe]?Ue.depth[Ee]:Ue.depth[Oe])+1,Ve[2*Ee+1]=Ve[2*Oe+1]=we,Ue.heap[1]=we++,Ge(Ue,Ve,1),2<=Ue.heap_len;);Ue.heap[--Ue.heap_max]=Ue.heap[1],(function(ct,ft){var Dt,Ct,Nt,Lt,ln,un,Vt=ft.dyn_tree,Ce=ft.max_code,rt=ft.stat_desc.static_tree,ut=ft.stat_desc.has_stree,ht=ft.stat_desc.extra_bits,Ft=ft.stat_desc.extra_base,Kt=ft.stat_desc.max_length,gn=0;for(Lt=0;Lt<=m;Lt++)ct.bl_count[Lt]=0;for(Vt[2*ct.heap[ct.heap_max]+1]=0,Dt=ct.heap_max+1;Dt<p;Dt++)Kt<(Lt=Vt[2*Vt[2*(Ct=ct.heap[Dt])+1]+1]+1)&&(Lt=Kt,gn++),Vt[2*Ct+1]=Lt,Ce<Ct||(ct.bl_count[Lt]++,ln=0,Ft<=Ct&&(ln=ht[Ct-Ft]),un=Vt[2*Ct],ct.opt_len+=un*(Lt+ln),ut&&(ct.static_len+=un*(rt[2*Ct+1]+ln)));if(gn!==0){do{for(Lt=Kt-1;ct.bl_count[Lt]===0;)Lt--;ct.bl_count[Lt]--,ct.bl_count[Lt+1]+=2,ct.bl_count[Kt]--,gn-=2}while(0<gn);for(Lt=Kt;Lt!==0;Lt--)for(Ct=ct.bl_count[Lt];Ct!==0;)Ce<(Nt=ct.heap[--Dt])||(Vt[2*Nt+1]!==Lt&&(ct.opt_len+=(Lt-Vt[2*Nt+1])*Vt[2*Nt],Vt[2*Nt+1]=Lt),Ct--)}})(Ue,Ne),be(Ve,gt,Ue.bl_count)}function pe(Ue,Ne,Ee){var Oe,we,Ve=-1,je=Ne[1],At=0,at=7,gt=4;for(je===0&&(at=138,gt=3),Ne[2*(Ee+1)+1]=65535,Oe=0;Oe<=Ee;Oe++)we=je,je=Ne[2*(Oe+1)+1],++At<at&&we===je||(At<gt?Ue.bl_tree[2*we]+=At:we!==0?(we!==Ve&&Ue.bl_tree[2*we]++,Ue.bl_tree[2*y]++):At<=10?Ue.bl_tree[2*B]++:Ue.bl_tree[2*x]++,Ve=we,gt=(At=0)===je?(at=138,3):we===je?(at=6,3):(at=7,4))}function et(Ue,Ne,Ee){var Oe,we,Ve=-1,je=Ne[1],At=0,at=7,gt=4;for(je===0&&(at=138,gt=3),Oe=0;Oe<=Ee;Oe++)if(we=je,je=Ne[2*(Oe+1)+1],!(++At<at&&we===je)){if(At<gt)for(;ye(Ue,we,Ue.bl_tree),--At!=0;);else we!==0?(we!==Ve&&(ye(Ue,we,Ue.bl_tree),At--),ye(Ue,y,Ue.bl_tree),le(Ue,At-3,2)):At<=10?(ye(Ue,B,Ue.bl_tree),le(Ue,At-3,3)):(ye(Ue,x,Ue.bl_tree),le(Ue,At-11,7));Ve=we,gt=(At=0)===je?(at=138,3):we===je?(at=6,3):(at=7,4)}}c(ce);var Le=!1;function Pe(Ue,Ne,Ee,Oe){le(Ue,(l<<1)+(Oe?1:0),3),(function(we,Ve,je,At){Se(we),re(we,je),re(we,~je),A.arraySet(we.pending_buf,we.window,Ve,je,we.pending),we.pending+=je})(Ue,Ne,Ee)}r._tr_init=function(Ue){Le||((function(){var Ne,Ee,Oe,we,Ve,je=new Array(m+1);for(we=Oe=0;we<g-1;we++)for(J[we]=Oe,Ne=0;Ne<1<<S[we];Ne++)U[Oe++]=we;for(U[Oe-1]=we,we=Ve=0;we<16;we++)for(ce[we]=Ve,Ne=0;Ne<1<<M[we];Ne++)G[Ve++]=we;for(Ve>>=7;we<h;we++)for(ce[we]=Ve<<7,Ne=0;Ne<1<<M[we]-7;Ne++)G[256+Ve++]=we;for(Ee=0;Ee<=m;Ee++)je[Ee]=0;for(Ne=0;Ne<=143;)N[2*Ne+1]=8,Ne++,je[8]++;for(;Ne<=255;)N[2*Ne+1]=9,Ne++,je[9]++;for(;Ne<=279;)N[2*Ne+1]=7,Ne++,je[7]++;for(;Ne<=287;)N[2*Ne+1]=8,Ne++,je[8]++;for(be(N,d+1,je),Ne=0;Ne<h;Ne++)H[2*Ne+1]=5,H[2*Ne]=xe(Ne,5);W=new ee(N,S,u+1,d,m),X=new ee(H,M,0,h,m),oe=new ee(new Array(0),w,0,_,C)})(),Le=!0),Ue.l_desc=new ie(Ue.dyn_ltree,W),Ue.d_desc=new ie(Ue.dyn_dtree,X),Ue.bl_desc=new ie(Ue.bl_tree,oe),Ue.bi_buf=0,Ue.bi_valid=0,he(Ue)},r._tr_stored_block=Pe,r._tr_flush_block=function(Ue,Ne,Ee,Oe){var we,Ve,je=0;0<Ue.level?(Ue.strm.data_type===2&&(Ue.strm.data_type=(function(At){var at,gt=4093624447;for(at=0;at<=31;at++,gt>>>=1)if(1&gt&&At.dyn_ltree[2*at]!==0)return s;if(At.dyn_ltree[18]!==0||At.dyn_ltree[20]!==0||At.dyn_ltree[26]!==0)return a;for(at=32;at<u;at++)if(At.dyn_ltree[2*at]!==0)return a;return s})(Ue)),Ze(Ue,Ue.l_desc),Ze(Ue,Ue.d_desc),je=(function(At){var at;for(pe(At,At.dyn_ltree,At.l_desc.max_code),pe(At,At.dyn_dtree,At.d_desc.max_code),Ze(At,At.bl_desc),at=_-1;3<=at&&At.bl_tree[2*k[at]+1]===0;at--);return At.opt_len+=3*(at+1)+5+5+4,at})(Ue),we=Ue.opt_len+3+7>>>3,(Ve=Ue.static_len+3+7>>>3)<=we&&(we=Ve)):we=Ve=Ee+5,Ee+4<=we&&Ne!==-1?Pe(Ue,Ne,Ee,Oe):Ue.strategy===4||Ve===we?(le(Ue,2+(Oe?1:0),3),Je(Ue,N,H)):(le(Ue,4+(Oe?1:0),3),(function(At,at,gt,ct){var ft;for(le(At,at-257,5),le(At,gt-1,5),le(At,ct-4,4),ft=0;ft<ct;ft++)le(At,At.bl_tree[2*k[ft]+1],3);et(At,At.dyn_ltree,at-1),et(At,At.dyn_dtree,gt-1)})(Ue,Ue.l_desc.max_code+1,Ue.d_desc.max_code+1,je+1),Je(Ue,Ue.dyn_ltree,Ue.dyn_dtree)),he(Ue),Oe&&Se(Ue)},r._tr_tally=function(Ue,Ne,Ee){return Ue.pending_buf[Ue.d_buf+2*Ue.last_lit]=Ne>>>8&255,Ue.pending_buf[Ue.d_buf+2*Ue.last_lit+1]=255&Ne,Ue.pending_buf[Ue.l_buf+Ue.last_lit]=255&Ee,Ue.last_lit++,Ne===0?Ue.dyn_ltree[2*Ee]++:(Ue.matches++,Ne--,Ue.dyn_ltree[2*(U[Ee]+u+1)]++,Ue.dyn_dtree[2*ae(Ne)]++),Ue.last_lit===Ue.lit_bufsize-1},r._tr_align=function(Ue){le(Ue,2,3),ye(Ue,f,N),(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)})(Ue)}},{"../utils/common":41}],53:[function(o,i,r){i.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(o,i,r){(function(A){(function(s,a){if(!s.setImmediate){var c,l,g,u,d=1,h={},_=!1,p=s.document,m=Object.getPrototypeOf&&Object.getPrototypeOf(s);m=m&&m.setTimeout?m:s,c={}.toString.call(s.process)==="[object process]"?function(y){n.nextTick(function(){C(y)})}:(function(){if(s.postMessage&&!s.importScripts){var y=!0,B=s.onmessage;return s.onmessage=function(){y=!1},s.postMessage("","*"),s.onmessage=B,y}})()?(u="setImmediate$"+Math.random()+"$",s.addEventListener?s.addEventListener("message",f,!1):s.attachEvent("onmessage",f),function(y){s.postMessage(u+y,"*")}):s.MessageChannel?((g=new MessageChannel).port1.onmessage=function(y){C(y.data)},function(y){g.port2.postMessage(y)}):p&&"onreadystatechange"in p.createElement("script")?(l=p.documentElement,function(y){var B=p.createElement("script");B.onreadystatechange=function(){C(y),B.onreadystatechange=null,l.removeChild(B),B=null},l.appendChild(B)}):function(y){setTimeout(C,0,y)},m.setImmediate=function(y){typeof y!="function"&&(y=new Function(""+y));for(var B=new Array(arguments.length-1),x=0;x<B.length;x++)B[x]=arguments[x+1];var S={callback:y,args:B};return h[d]=S,c(d),d++},m.clearImmediate=I}function I(y){delete h[y]}function C(y){if(_)setTimeout(C,0,y);else{var B=h[y];if(B){_=!0;try{(function(x){var S=x.callback,M=x.args;switch(M.length){case 0:S();break;case 1:S(M[0]);break;case 2:S(M[0],M[1]);break;case 3:S(M[0],M[1],M[2]);break;default:S.apply(a,M)}})(B)}finally{I(y),_=!1}}}}function f(y){y.source===s&&typeof y.data=="string"&&y.data.indexOf(u)===0&&C(+y.data.slice(u.length))}})(typeof self>"u"?A===void 0?this:A:self)}).call(this,typeof yK<"u"?yK:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(gwe)),gwe.exports}var E6o=y6o();const uwe=V2(E6o),B6o=async({circuitJson:t,projectName:e})=>{await GA.promise((async()=>{const n=new uwe,[{stringifyGerberCommandLayers:o,convertSoupToGerberCommands:i,convertSoupToExcellonDrillCommands:r,stringifyExcellonDrill:A},{convertCircuitJsonToBomRows:s,convertBomRowsToCsv:a},{convertCircuitJsonToPickAndPlaceCsv:c}]=await Promise.all([FB("circuit-json-to-gerber"),FB("circuit-json-to-bom-csv"),FB("circuit-json-to-pnp-csv")]),l=t.filter(C=>!("error_type"in C)&&!("warning_type"in C)),g=i(l,{flip_y_axis:!1}),u=o(g);for(const[C,f]of Object.entries(u))n.file(`gerber/${C}.gbr`,f);const d=r({circuitJson:l,is_plated:!0,flip_y_axis:!1}),h=A(d);n.file("gerber/drill.drl",h);const _=await s({circuitJson:t}),p=await a(_);n.file("bom.csv",p);const m=await c(t);n.file("pick_and_place.csv",m);const I=await n.generateAsync({type:"blob"});MQ(I,{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)}`})},x6o=async({circuitJson:t,projectName:e})=>{let n;try{const{convertCircuitJsonToGltf:o}=await FB("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}MQ(n,{fileName:`${e}.glb`})},Q6o=async({circuitJson:t,libraryName:e})=>{const{CircuitJsonToKicadLibraryConverter:n}=await FB("circuit-json-to-kicad"),o=new n(t,{libraryName:e,footprintLibraryName:e});o.runUntilFinished();const i=o.getOutput(),r=new uwe;r.file(`${e}.kicad_sym`,i.kicadSymString);for(const A of i.footprints){const s=r.folder(`${e}.pretty`);s&&s.file(`${A.footprintName}.kicad_mod`,`${A.kicadModString}
5788
5788
  `)}if(i.model3dSourcePaths.length>0){const A=r.folder(`${e}.3dshapes`);if(A)for(const s of i.model3dSourcePaths)try{const a=s.split("/").pop()||s,c=await fetch(s);if(c.ok){const l=await c.arrayBuffer();A.file(a,l)}}catch{}}return r.file("fp-lib-table",i.fpLibTableString),r.file("sym-lib-table",i.symLibTableString),r},S6o=async({circuitJson:t,projectName:e})=>{await GA.promise((async()=>{const o=await(await Q6o({circuitJson:t,libraryName:e})).generateAsync({type:"blob"});MQ(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)}`})},b6o=async({circuitJson:t,projectName:e})=>{const{CircuitJsonToKicadPcbConverter:n,CircuitJsonToKicadSchConverter:o,CircuitJsonToKicadProConverter:i,resolveAndLoadKicad3dModelFiles:r}=await FB("circuit-json-to-kicad"),A=new o(t);A.runUntilFinished();const s=A.getOutputString(),a=new n(t,{includeBuiltin3dModels:!0,projectName:e});a.runUntilFinished();const c=a.getOutputString(),l=new i(t,{projectName:e,schematicFilename:`${e}.kicad_sch`,pcbFilename:`${e}.kicad_pcb`});l.runUntilFinished();const g=l.getOutputString(),u=new uwe;return u.file(`${e}.kicad_sch`,s),u.file(`${e}.kicad_pcb`,c),u.file(`${e}.kicad_pro`,g),await r({projectName:e,model3dSourcePaths:a.getModel3dSourcePaths(),fetch,onModelFile:({outputPath:d,content:h})=>{u.file(d,h)},onError:({sourcePath:d})=>{console.warn(`Failed to load 3D model from ${d}`)}}),u},D6o=async({circuitJson:t,projectName:e})=>{await GA.promise((async()=>{const o=await(await b6o({circuitJson:t,projectName:e})).generateAsync({type:"blob"});MQ(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)}`})},Hvt=async({circuitJson:t,projectName:e,options:n={}})=>{try{const{convertCircuitJsonToLbrn:o}=await FB("circuit-json-to-lbrn"),r=(await o(t,{includeSilkscreen:n.includeSilkscreen??!1,includeOxidationCleaningLayer:n.includeOxidationCleaningLayer??!0})).toXml(),A=new Blob([r],{type:"application/lbrn"});MQ(A,{fileName:`${e}.lbrn2`})}catch(o){const i=o instanceof Error?o.message:"Unknown error";GA.error(`Failed to export to LBRN format: ${i}`)}},M6o=async({circuitJson:t,projectName:e})=>{const{convertCircuitJsonToPinoutSvg:n}=await FB("circuit-to-svg"),o=n(t);MQ(o,{fileName:`${e}-pinout.svg`,mimeType:"image/svg+xml"})},w6o=async({circuitJson:t,projectName:e})=>{const{circuitJsonToStep:n}=await FB("circuit-json-to-step"),o=t.find(c=>c.type==="pcb_board"),i=o&&"width"in o?o.width:void 0,r=o&&"height"in o?o.height:void 0,A=o&&"thickness"in o?o.thickness:void 0;if(i===void 0||r===void 0||A===void 0){GA.error("Board dimensions not found. Please add a pcb_board with width, height, and thickness to your circuit.");return}let s;try{s=await n(t,{boardWidth:i,boardHeight:r,boardThickness:A,productName:e,includeComponents:!0,includeExternalMeshes:!0})}catch(c){const l=c instanceof Error?c.message:"Unknown error";GA.error(`Failed to convert circuit to STEP format: ${l}`);return}const a=new Blob([s],{type:"application/step"});try{MQ(a,{fileName:`${e}.step`})}catch(c){const l=c instanceof Error?c.message:"Unknown error";GA.error(`Failed to download STEP file: ${l}`)}},P6o=[{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"}],v6o=async({exportName:t,circuitJson:e,simpleRouteJson:n,projectName:o})=>{const i=b3t(o);if(t==="Fabrication Files"){await B6o({circuitJson:e,projectName:i});return}if(t==="KiCad Project"){await D6o({circuitJson:e,projectName:i});return}if(t==="KiCad Library"){await S6o({circuitJson:e,projectName:i});return}if(t==="Circuit JSON"){MQ(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");MQ(JSON.stringify(n,null,2),{fileName:`${i}.simple-route.json`,mimeType:"application/json"});return}if(t==="GLB (Binary GLTF)"){await x6o({circuitJson:e,projectName:i});return}if(t==="Pinout SVG"){M6o({circuitJson:e,projectName:i});return}if(t==="STEP"){await w6o({circuitJson:e,projectName:i});return}if(t==="LightBurn"){await Hvt({circuitJson:e,projectName:i});return}throw new Error(`Unsupported export type: "${t}"`)},N6o=({packageName:t,onSelectReview:e})=>{const n=w0(g=>g.fsMap),o=w0(g=>g.circuitJson),[i,r]=j.useState([]),[A,s]=j.useState(!1),[a,c]=j.useState(!1);j.useEffect(()=>{!t||!BX()||(s(!0),vL.get("ai_reviews/list",{searchParams:{package_name:t}}).json().then(g=>r(g.ai_reviews)).catch(g=>{console.error("Failed to load AI reviews",g),GA.error("Failed to load AI reviews")}).finally(()=>s(!1)))},[t]);const l=async()=>{if(!o){GA.error("Need Circuit JSON to Request AI Review");return}if(!BX()){GA.error("Missing registry token");return}c(!0);try{const{ai_review:g}=await vL.post("ai_reviews/create",{json:{package_name:t??"unknown",fs_map:Object.fromEntries(n),circuit_json:o}}).json();r(u=>[g,...u]),e(g),GA.success("AI review requested")}catch(g){console.error("Failed to create AI review",g),GA.error("Failed to request AI review")}finally{c(!1)}};return V.jsxs(V.Fragment,{children:[V.jsxs(y3,{children:[V.jsx(E3,{children:"AI Review"}),V.jsx(vN,{children:"Select an AI review or request a new one."})]}),V.jsx("div",{className:"rf-flex rf-gap-4 rf-mt-4",children:V.jsx("div",{className:"rf-w-48 rf-h-64 rf-overflow-y-auto rf-border rf-rounded rf-p-2 rf-flex-shrink-0",children:A?V.jsx("div",{className:"rf-text-sm",children:"Loading..."}):i.length>0?i.map(g=>V.jsx("div",{className:"rf-text-sm rf-p-2 rf-cursor-pointer rf-rounded hover:rf-bg-zinc-100",onClick:()=>e(g),children:new Date(g.created_at||"").toLocaleString()},g.ai_review_id)):V.jsx("div",{className:"rf-text-sm rf-text-muted-foreground",children:"No AI reviews found."})})}),V.jsx(hO,{className:"rf-mt-4",children:V.jsx(Vs,{onClick:l,disabled:a,children:a?"Requesting...":"Review my Board"})})]})};function hwe(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var B3=hwe();function Gvt(t){B3=t}var mO={exec:()=>null};function ol(t,e=""){let n=typeof t=="string"?t:t.source;const o={replace:(i,r)=>{let A=typeof r=="string"?r:r.source;return A=A.replace(af.caret,"$1"),n=n.replace(i,A),o},getRegex:()=>new RegExp(n,e)};return o}var af={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")},R6o=/^(?:[ \t]*(?:\n|$))+/,T6o=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,k6o=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,pO=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,F6o=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,dwe=/(?:[*+-]|\d{1,9}[.)])/,Ovt=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Kvt=ol(Ovt).replace(/bull/g,dwe).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(),L6o=ol(Ovt).replace(/bull/g,dwe).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(),_we=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,H6o=/^[^\n]+/,mwe=/(?!\s*\])(?:\\.|[^\[\]\\])+/,G6o=ol(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",mwe).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),O6o=ol(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,dwe).getRegex(),dne="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",pwe=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,K6o=ol("^ {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",pwe).replace("tag",dne).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Uvt=ol(_we).replace("hr",pO).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",dne).getRegex(),U6o=ol(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Uvt).getRegex(),Iwe={blockquote:U6o,code:T6o,def:G6o,fences:k6o,heading:F6o,hr:pO,html:K6o,lheading:Kvt,list:O6o,newline:R6o,paragraph:Uvt,table:mO,text:H6o},Yvt=ol("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",pO).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",dne).getRegex(),Y6o={...Iwe,lheading:L6o,table:Yvt,paragraph:ol(_we).replace("hr",pO).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Yvt).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",dne).getRegex()},V6o={...Iwe,html:ol(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",pwe).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:mO,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:ol(_we).replace("hr",pO).replace("heading",` *#{1,6} *[^
5789
5789
  ]`).replace("lheading",Kvt).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},z6o=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,J6o=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Vvt=/^( {2,}|\\)\n(?!\s*$)/,q6o=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,_ne=/[\p{P}\p{S}]/u,Cwe=/[\s\p{P}\p{S}]/u,zvt=/[^\s\p{P}\p{S}]/u,W6o=ol(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Cwe).getRegex(),Jvt=/(?!~)[\p{P}\p{S}]/u,j6o=/(?!~)[\s\p{P}\p{S}]/u,X6o=/(?:[^\s\p{P}\p{S}]|~)/u,$6o=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,qvt=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,Z6o=ol(qvt,"u").replace(/punct/g,_ne).getRegex(),e8o=ol(qvt,"u").replace(/punct/g,Jvt).getRegex(),Wvt="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",t8o=ol(Wvt,"gu").replace(/notPunctSpace/g,zvt).replace(/punctSpace/g,Cwe).replace(/punct/g,_ne).getRegex(),n8o=ol(Wvt,"gu").replace(/notPunctSpace/g,X6o).replace(/punctSpace/g,j6o).replace(/punct/g,Jvt).getRegex(),o8o=ol("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,zvt).replace(/punctSpace/g,Cwe).replace(/punct/g,_ne).getRegex(),i8o=ol(/\\(punct)/,"gu").replace(/punct/g,_ne).getRegex(),r8o=ol(/^<(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(),A8o=ol(pwe).replace("(?:-->|$)","-->").getRegex(),s8o=ol("^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",A8o).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),mne=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,a8o=ol(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",mne).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),jvt=ol(/^!?\[(label)\]\[(ref)\]/).replace("label",mne).replace("ref",mwe).getRegex(),Xvt=ol(/^!?\[(ref)\](?:\[\])?/).replace("ref",mwe).getRegex(),c8o=ol("reflink|nolink(?!\\()","g").replace("reflink",jvt).replace("nolink",Xvt).getRegex(),fwe={_backpedal:mO,anyPunctuation:i8o,autolink:r8o,blockSkip:$6o,br:Vvt,code:J6o,del:mO,emStrongLDelim:Z6o,emStrongRDelimAst:t8o,emStrongRDelimUnd:o8o,escape:z6o,link:a8o,nolink:Xvt,punctuation:W6o,reflink:jvt,reflinkSearch:c8o,tag:s8o,text:q6o,url:mO},l8o={...fwe,link:ol(/^!?\[(label)\]\((.*?)\)/).replace("label",mne).getRegex(),reflink:ol(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",mne).getRegex()},ywe={...fwe,emStrongRDelimAst:n8o,emStrongLDelim:e8o,url:ol(/^((?: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.!#$%&'*+\/=?_`{\|}~-]+@)))/},g8o={...ywe,br:ol(Vvt).replace("{2,}","*").getRegex(),text:ol(ywe.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},pne={normal:Iwe,gfm:Y6o,pedantic:V6o},IO={normal:fwe,gfm:ywe,breaks:g8o,pedantic:l8o},u8o={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},$vt=t=>u8o[t];function PQ(t,e){if(e){if(af.escapeTest.test(t))return t.replace(af.escapeReplace,$vt)}else if(af.escapeTestNoEncode.test(t))return t.replace(af.escapeReplaceNoEncode,$vt);return t}function Zvt(t){try{t=encodeURI(t).replace(af.percentDecode,"%")}catch{return null}return t}function e6t(t,e){const n=t.replace(af.findPipe,(r,A,s)=>{let a=!1,c=A;for(;--c>=0&&s[c]==="\\";)a=!a;return a?"|":" |"}),o=n.split(af.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(af.slashPipe,"|");return o}function CO(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 h8o(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 t6t(t,e,n,o,i){const r=e.href,A=e.title||null,s=t[1].replace(i.other.outputLinkReplace,"$1");o.state.inLink=!0;const a={type:t[0].charAt(0)==="!"?"image":"link",raw:n,href:r,title:A,text:s,tokens:o.inlineTokens(s)};return o.state.inLink=!1,a}function d8o(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.2251",
5
+ "version": "0.0.2253",
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.1039",
116
+ "@tscircuit/eval": "^0.0.1041",
117
117
  "@tscircuit/solver-utils": "^0.0.7"
118
118
  }
119
119
  }