@tscircuit/runframe 0.0.1887 → 0.0.1889

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.
@@ -5691,7 +5691,7 @@ test("${l} should solve problem correctly", () => {
5691
5691
  // Add more specific assertions based on expected output
5692
5692
  // expect(solver.netLabelPlacementSolver!.netLabelPlacements).toMatchInlineSnapshot()
5693
5693
  })
5694
- `,_=new Blob([u],{type:"text/plain"}),d=URL.createObjectURL(_),m=document.createElement("a");m.href=d,m.download=`${l}.test.ts`,m.click(),URL.revokeObjectURL(d)}catch(c){alert(`Error generating test.ts for ${t.constructor.name}: ${c instanceof Error?c.message:String(c)}`)}o(!1)};return G.jsxs("div",{className:`relative ${e}`,ref:r,children:[G.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&&G.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:[G.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:i,children:"Download JSON"}),G.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),G.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:a,children:"Download test.ts"})]})]})},d_t=t=>t.activeSubSolver?[t,...d_t(t.activeSubSolver)]:[t],vGn=({solver:t})=>{const e=d_t(t);return G.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:e.map((n,o)=>G.jsxs("div",{className:"flex items-center",children:[o>0&&G.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),G.jsx(PGn,{solver:n})]},n.constructor.name))})},SGn=({solver:t,triggerRender:e,animationSpeed:n=25,onSolverStarted:o,onSolverCompleted:r})=>{const[i,s]=te.useReducer(p=>!p,!1),a=te.useRef(void 0),c=()=>{!t.solved&&!t.failed&&(t.step(),e())},l=()=>{!t.solved&&!t.failed&&(o&&o(t),t.solve(),e(),r&&r(t))},u=()=>{i?(a.current&&(clearInterval(a.current),a.current=void 0),s()):(s(),a.current=setInterval(()=>{if(t.solved||t.failed){a.current&&(clearInterval(a.current),a.current=void 0),s(),e(),r&&t.solved&&r(t);return}t.step(),e()},n))},_=()=>{const p=t;if(p.getCurrentPhase&&!t.solved&&!t.failed){const x=p.getCurrentPhase();for(;p.getCurrentPhase()===x&&!t.solved&&!t.failed;)t.step();e()}},d=()=>{if(t.solved||t.failed||i)return;const p=window.prompt("Step until which iteration?",`${t.iterations}`);if(p===null)return;const x=Number(p);if(!Number.isFinite(x)){window.alert("Please enter a valid number for the iteration");return}for(;t.iterations<x&&!t.solved&&!t.failed;)t.step();e(),t.solved&&r&&r(t)};te.useEffect(()=>()=>{a.current&&clearInterval(a.current)},[]),te.useEffect(()=>{(t.solved||t.failed)&&i&&(a.current&&(clearInterval(a.current),a.current=void 0),s())},[t.solved,t.failed,i]);const m=t.getCurrentPhase!==void 0,h=m?t.getCurrentPhase():null;return G.jsxs("div",{className:"space-y-2 p-2 border-b",children:[G.jsx("div",{className:"flex items-center",children:G.jsx(vGn,{solver:t})}),G.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[G.jsx("button",{onClick:c,disabled:t.solved||t.failed||i,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),G.jsx("button",{onClick:l,disabled:t.solved||t.failed||i,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),G.jsx("button",{onClick:u,disabled:t.solved||t.failed,className:`px-3 py-1 rounded text-white text-sm ${i?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:i?"Stop":"Animate"}),G.jsx("button",{onClick:d,disabled:t.solved||t.failed||i,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"}),m&&G.jsx("button",{onClick:_,disabled:t.solved||t.failed||i,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),G.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&G.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),h&&G.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",G.jsx("span",{className:"font-medium",children:h})]}),t.solved&&G.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&G.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&G.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},CGn=(t,e,n)=>{const o=t.currentPipelineStepIndex;return e<o?"Completed":e===o&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},MGn=(t,e)=>{const o=t.pipelineDef[e].solverName,r=CGn(t,e),i=t[o],s=t.firstIterationOfPhase?.[o]??null,a=t.iterations;let c=0;if(r==="Completed"){const d=t.pipelineDef[e+1],m=d?t.firstIterationOfPhase?.[d.solverName]:void 0;m!==void 0&&s!==null?c=m-s:s!==null&&(c=a-s)}else r==="In Progress"&&s!==null&&(c=a-s);const l=t.timeSpentOnPhase?.[o]??0;let u=0;r==="Completed"?u=1:r==="In Progress"&&i&&(u=i.progress??0);const _=i?.stats??null;return{index:e,name:o,status:r,firstIteration:s,iterations:c,progress:u,timeSpent:l,stats:_&&Object.keys(_).length>0?_:null,solverInstance:i??null}},TGn=({status:t})=>{const e={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return G.jsx("span",{className:`font-medium ${e[t]}`,children:t})},wGn=({progress:t})=>{if(t===0)return null;const e=Math.round(t*100);return G.jsxs("div",{className:"flex items-center gap-2",children:[G.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:G.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${e}%`}})}),G.jsxs("span",{className:"text-xs text-gray-500",children:[e,"%"]})]})},EGn=t=>Object.entries(t).map(([e,n])=>`${e}: ${n}`).join(", "),DGn=({stats:t})=>{if(!t||Object.keys(t).length===0)return G.jsx("span",{children:"-"});const e=Object.entries(t),n=EGn(t);return G.jsxs("details",{className:"cursor-pointer",children:[G.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:n}),G.jsx("div",{className:"mt-1 text-xs",children:e.map(([o,r])=>G.jsxs("div",{children:[o,": ",String(r)]},o))})]})},Sge=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(Sge);const e={};for(const[n,o]of Object.entries(t))n.startsWith("_")||(e[n]=Sge(o));return e},AGn=(t,e)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${e}`);return}const n=Sge(t.getConstructorParams()),o=new Blob([JSON.stringify(n,null,2)],{type:"application/json"}),r=URL.createObjectURL(o),i=document.createElement("a");i.href=r,i.download=`${e}_input.json`,i.click(),URL.revokeObjectURL(r)}catch(n){alert(`Error downloading input for ${e}: ${n instanceof Error?n.message:String(n)}`)}},RGn=({solver:t,onStepUntilPhase:e,onDownloadInput:n})=>{const o=t.pipelineDef.map((a,c)=>MGn(t,c)),r=a=>{e?.(a)},i=a=>{a.solverInstance&&(n?n(a.solverInstance,a.name):AGn(a.solverInstance,a.name))},s=a=>`${(a/1e3).toFixed(2)}s`;return G.jsxs("div",{className:"border-t border-gray-200",children:[G.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:G.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),G.jsx("div",{className:"overflow-x-auto",children:G.jsxs("table",{className:"w-full text-sm",children:[G.jsx("thead",{children:G.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),G.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",G.jsx("sub",{children:"0"})]}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),G.jsx("tbody",{children:o.map(a=>G.jsxs("tr",{className:`border-b border-gray-100 ${a.status==="In Progress"?"bg-yellow-50":""}`,children:[G.jsx("td",{className:"px-4 py-2",children:G.jsxs("div",{className:"flex items-center gap-2",children:[G.jsx("span",{className:"text-gray-400 w-6",children:String(a.index+1).padStart(2,"0")}),G.jsx("button",{onClick:()=>r(a.name),disabled:a.status==="Completed"||t.solved||t.failed,className:"text-blue-500 hover:text-blue-700 disabled:text-gray-300 disabled:cursor-not-allowed",title:`Step until ${a.name} completes`,children:G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:G.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"})})}),G.jsx("span",{className:"font-medium text-gray-900",children:a.name})]})}),G.jsx("td",{className:"px-4 py-2",children:G.jsx(TGn,{status:a.status})}),G.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:a.firstIteration!==null?a.firstIteration:""}),G.jsx("td",{className:"px-4 py-2 text-gray-600",children:a.iterations}),G.jsx("td",{className:"px-4 py-2",children:G.jsx(wGn,{progress:a.progress})}),G.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(a.timeSpent)}),G.jsx("td",{className:"px-4 py-2 text-gray-500",children:G.jsx(DGn,{stats:a.stats})}),G.jsx("td",{className:"px-4 py-2",children:a.solverInstance?G.jsxs("button",{onClick:()=>i(a),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${a.name}`,children:[G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:G.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"})}),G.jsx("span",{children:"Input"})]}):null})]},a.name))})]})})]})},kGn=class extends ar.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 NGn({graphics:t}){const e=t.points??[],n=t.lines??[],o=t.rects??[],r=t.circles??[],i=t.texts??[];let s=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY,l=Number.NEGATIVE_INFINITY;const u=(x,f)=>{typeof x=="number"&&(x<s&&(s=x),x>c&&(c=x)),typeof f=="number"&&(f<a&&(a=f),f>l&&(l=f))};for(const x of e)u(x.x,x.y);for(const x of n){const f=x.points??[];for(const g of f)u(g.x,g.y)}for(const x of o){const f=x.x??0,g=x.y??0,y=x.width??0,b=x.height??0;u(f,g),u(f+y,g+b)}for(const x of r){const f=x.x??0,g=x.y??0,y=x.radius??1;u(f-y,g-y),u(f+y,g+y)}for(const x of i)u(x.x,x.y);(!isFinite(s)||!isFinite(a)||!isFinite(c)||!isFinite(l))&&(s=-20,a=-20,c=20,l=20);const _=10,d=s-_,m=a-_,h=Math.max(1,c-s+2*_),p=Math.max(1,l-a+2*_);return G.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${d} ${m} ${h} ${p}`,role:"img","aria-label":"Graphics fallback",children:[o.map((x,f)=>G.jsx("rect",{x:x.x??0,y:x.y??0,width:x.width??0,height:x.height??0,fill:"none",stroke:x.strokeColor??"black",strokeWidth:x.strokeWidth??1},`rect-${f}`)),n.map((x,f)=>G.jsx("polyline",{fill:"none",stroke:x.strokeColor??"black",strokeWidth:x.strokeWidth??1,points:(x.points??[]).map(g=>`${g.x??0},${g.y??0}`).join(" ")},`line-${f}`)),r.map((x,f)=>G.jsx("circle",{cx:x.x??0,cy:x.y??0,r:x.radius??1.5,fill:x.fillColor??"none",stroke:x.strokeColor??"black",strokeWidth:x.strokeWidth??1},`circle-${f}`)),e.map((x,f)=>G.jsx("circle",{cx:x.x??0,cy:x.y??0,r:x.radius??1.5,fill:x.color??"black"},`point-${f}`)),i.map((x,f)=>G.jsx("text",{x:x.x??0,y:x.y??0,fontSize:x.fontSize??10,fill:x.color??"black",children:x.text??""},`text-${f}`))]})}var HGn=({solver:t,animationSpeed:e=25,onSolverStarted:n,onSolverCompleted:o})=>{const[r,i]=te.useReducer(u=>u+1,0),s=te.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(u){return console.error("Visualization error:",u),{points:[],lines:[],rects:[],circles:[]}}},[t,r]),a=te.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);te.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const u=document.createElement("script");u.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(u)}},[]);const c=t.pipelineDef!==void 0,l=u=>{const _=t;if(!t.solved&&!t.failed){for(;!t.solved&&!t.failed&&_.currentPipelineStepIndex<=_.pipelineDef.findIndex(d=>d.solverName===u);)t.step();i()}};return G.jsxs("div",{children:[G.jsx(SGn,{solver:t,triggerRender:i,animationSpeed:e,onSolverStarted:n,onSolverCompleted:o}),a?G.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):G.jsx(kGn,{fallback:G.jsx(NGn,{graphics:s}),children:G.jsx(bGn,{graphics:s})}),c&&G.jsx(RGn,{solver:t,onStepUntilPhase:l})]})};const IGn=()=>{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)},[])},LGn=t=>t.toLowerCase().includes("pack")?ETn:t.toLowerCase().includes("rout")?HTn:yTn,OGn=({solverEvents:t=[]})=>{const[e,n]=te.useState(null);IGn();const o=te.useMemo(()=>{const a=new Map;for(const c of t){const l=`${c.componentName}-${c.solverName}`;a.set(l,c)}return a},[t]),r=te.useMemo(()=>Array.from(o.keys()),[o]),i=e?o.get(e):null,s=te.useMemo(()=>{if(!i)return{instance:null,error:null,classFound:!1};const a=Vae[i.solverName];if(!a)return{instance:null,error:`Solver class "${i.solverName}" not found in SOLVERS registry. Available: ${Object.keys(Vae).join(", ")}`,classFound:!1};try{const c=i.solverParams,l=c?.input!==void 0?c.input:c;return{instance:new a(l),error:null,classFound:!0}}catch(c){const l=c instanceof Error?c.message:String(c);return console.error("Failed to reconstruct solver:",c),{instance:null,error:`Failed to instantiate solver: ${l}`,classFound:!0}}},[i]);return t.length===0?G.jsx("div",{className:"rf-p-4",children:G.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:G.jsxs("div",{className:"rf-p-4",children:[G.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),G.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."})]})})}):G.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[G.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[G.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:[r.length," ",r.length===1?"Solver":"Solvers"]}),r.map(a=>{const c=o.get(a),l=e===a;return G.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${l?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>n(a),children:(()=>{const u=LGn(c.solverName);return G.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[G.jsx(u,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),G.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[G.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:c.componentName}),G.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:c.solverName})]})]})})()},a)})]}),G.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:i?s.instance?G.jsx(q6,{fallback:G.jsx("div",{className:"rf-p-4",children:G.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[G.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),G.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",i.solverName]})]})}),children:G.jsx(HGn,{solver:s.instance})}):G.jsxs("div",{className:"rf-p-4",children:[G.jsxs("div",{className:"rf-mb-4",children:[G.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:i.solverName}),G.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",i.componentName]})]}),s.error&&G.jsx("div",{className:`rf-rounded-md rf-border rf-p-4 rf-mb-4 ${s.classFound?"rf-bg-red-50 rf-border-red-200":"rf-bg-yellow-50 rf-border-yellow-200"}`,children:G.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),G.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[G.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:G.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),G.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:G.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(i.solverParams,null,2)})})]})]}):G.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:G.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},h_t=({errorMessage:t,errorStack:e,circuitJsonErrors:n})=>{te.useEffect(()=>{if(t){const o=new Error(t);e&&(o.stack=e);try{yL.captureException(o)}catch{}}},[t,e]),te.useEffect(()=>{if(n&&n.length>0)for(const o of n){const r=new Error(o.message||"Circuit JSON Error");o.stack&&(r.stack=o.stack);try{yL.captureException(r,{error_type:o.type})}catch{}}},[n])},m_t="0.0.1885",FGn={version:m_t},Cge={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},Mge=new Map,kG=t=>{const e=Mge.get(t);return e?Object.fromEntries(Object.entries(e.stores).map(([n,o])=>[n,o.getState()])):{}},BGn=(t,e,n)=>{if(t===void 0)return{type:"untracked",connection:e.connect(n)};const o=Mge.get(n.name);if(o)return{type:"tracked",store:t,...o};const r={connection:e.connect(n),stores:{}};return Mge.set(n.name,r),{type:"tracked",store:t,...r}},p_t=(t,e={})=>(n,o,r)=>{const{enabled:i,anonymousActionType:s,store:a,...c}=e;let l;try{l=(i??(Cge?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!l)return(Cge?"production":void 0)!=="production"&&i&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),t(n,o,r);const{connection:u,..._}=BGn(a,l,c);let d=!0;r.setState=(p,x,f)=>{const g=n(p,x);if(!d)return g;const y=f===void 0?{type:s||"anonymous"}:typeof f=="string"?{type:f}:f;return a===void 0?(u?.send(y,o()),g):(u?.send({...y,type:`${a}/${y.type}`},{...kG(c.name),[a]:r.getState()}),g)};const m=(...p)=>{const x=d;d=!1,n(...p),d=x},h=t(r.setState,o,r);if(_.type==="untracked"?u?.init(h):(_.stores[_.store]=r,u?.init(Object.fromEntries(Object.entries(_.stores).map(([p,x])=>[p,p===_.store?h:x.getState()])))),r.dispatchFromDevtools&&typeof r.dispatch=="function"){let p=!1;const x=r.dispatch;r.dispatch=(...f)=>{(Cge?"production":void 0)!=="production"&&f[0].type==="__setState"&&!p&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),p=!0),x(...f)}}return u.subscribe(p=>{var x;switch(p.type){case"ACTION":if(typeof p.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return Tge(p.payload,f=>{if(f.type==="__setState"){if(a===void 0){m(f.state);return}Object.keys(f.state).length!==1&&console.error(`
5694
+ `,_=new Blob([u],{type:"text/plain"}),d=URL.createObjectURL(_),m=document.createElement("a");m.href=d,m.download=`${l}.test.ts`,m.click(),URL.revokeObjectURL(d)}catch(c){alert(`Error generating test.ts for ${t.constructor.name}: ${c instanceof Error?c.message:String(c)}`)}o(!1)};return G.jsxs("div",{className:`relative ${e}`,ref:r,children:[G.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&&G.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:[G.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:i,children:"Download JSON"}),G.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),G.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:a,children:"Download test.ts"})]})]})},d_t=t=>t.activeSubSolver?[t,...d_t(t.activeSubSolver)]:[t],vGn=({solver:t})=>{const e=d_t(t);return G.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:e.map((n,o)=>G.jsxs("div",{className:"flex items-center",children:[o>0&&G.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),G.jsx(PGn,{solver:n})]},n.constructor.name))})},SGn=({solver:t,triggerRender:e,animationSpeed:n=25,onSolverStarted:o,onSolverCompleted:r})=>{const[i,s]=te.useReducer(p=>!p,!1),a=te.useRef(void 0),c=()=>{!t.solved&&!t.failed&&(t.step(),e())},l=()=>{!t.solved&&!t.failed&&(o&&o(t),t.solve(),e(),r&&r(t))},u=()=>{i?(a.current&&(clearInterval(a.current),a.current=void 0),s()):(s(),a.current=setInterval(()=>{if(t.solved||t.failed){a.current&&(clearInterval(a.current),a.current=void 0),s(),e(),r&&t.solved&&r(t);return}t.step(),e()},n))},_=()=>{const p=t;if(p.getCurrentPhase&&!t.solved&&!t.failed){const x=p.getCurrentPhase();for(;p.getCurrentPhase()===x&&!t.solved&&!t.failed;)t.step();e()}},d=()=>{if(t.solved||t.failed||i)return;const p=window.prompt("Step until which iteration?",`${t.iterations}`);if(p===null)return;const x=Number(p);if(!Number.isFinite(x)){window.alert("Please enter a valid number for the iteration");return}for(;t.iterations<x&&!t.solved&&!t.failed;)t.step();e(),t.solved&&r&&r(t)};te.useEffect(()=>()=>{a.current&&clearInterval(a.current)},[]),te.useEffect(()=>{(t.solved||t.failed)&&i&&(a.current&&(clearInterval(a.current),a.current=void 0),s())},[t.solved,t.failed,i]);const m=t.getCurrentPhase!==void 0,h=m?t.getCurrentPhase():null;return G.jsxs("div",{className:"space-y-2 p-2 border-b",children:[G.jsx("div",{className:"flex items-center",children:G.jsx(vGn,{solver:t})}),G.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[G.jsx("button",{onClick:c,disabled:t.solved||t.failed||i,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),G.jsx("button",{onClick:l,disabled:t.solved||t.failed||i,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),G.jsx("button",{onClick:u,disabled:t.solved||t.failed,className:`px-3 py-1 rounded text-white text-sm ${i?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:i?"Stop":"Animate"}),G.jsx("button",{onClick:d,disabled:t.solved||t.failed||i,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"}),m&&G.jsx("button",{onClick:_,disabled:t.solved||t.failed||i,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),G.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&G.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),h&&G.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",G.jsx("span",{className:"font-medium",children:h})]}),t.solved&&G.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&G.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&G.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},CGn=(t,e,n)=>{const o=t.currentPipelineStepIndex;return e<o?"Completed":e===o&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},MGn=(t,e)=>{const o=t.pipelineDef[e].solverName,r=CGn(t,e),i=t[o],s=t.firstIterationOfPhase?.[o]??null,a=t.iterations;let c=0;if(r==="Completed"){const d=t.pipelineDef[e+1],m=d?t.firstIterationOfPhase?.[d.solverName]:void 0;m!==void 0&&s!==null?c=m-s:s!==null&&(c=a-s)}else r==="In Progress"&&s!==null&&(c=a-s);const l=t.timeSpentOnPhase?.[o]??0;let u=0;r==="Completed"?u=1:r==="In Progress"&&i&&(u=i.progress??0);const _=i?.stats??null;return{index:e,name:o,status:r,firstIteration:s,iterations:c,progress:u,timeSpent:l,stats:_&&Object.keys(_).length>0?_:null,solverInstance:i??null}},TGn=({status:t})=>{const e={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return G.jsx("span",{className:`font-medium ${e[t]}`,children:t})},wGn=({progress:t})=>{if(t===0)return null;const e=Math.round(t*100);return G.jsxs("div",{className:"flex items-center gap-2",children:[G.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:G.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${e}%`}})}),G.jsxs("span",{className:"text-xs text-gray-500",children:[e,"%"]})]})},EGn=t=>Object.entries(t).map(([e,n])=>`${e}: ${n}`).join(", "),DGn=({stats:t})=>{if(!t||Object.keys(t).length===0)return G.jsx("span",{children:"-"});const e=Object.entries(t),n=EGn(t);return G.jsxs("details",{className:"cursor-pointer",children:[G.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:n}),G.jsx("div",{className:"mt-1 text-xs",children:e.map(([o,r])=>G.jsxs("div",{children:[o,": ",String(r)]},o))})]})},Sge=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(Sge);const e={};for(const[n,o]of Object.entries(t))n.startsWith("_")||(e[n]=Sge(o));return e},AGn=(t,e)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${e}`);return}const n=Sge(t.getConstructorParams()),o=new Blob([JSON.stringify(n,null,2)],{type:"application/json"}),r=URL.createObjectURL(o),i=document.createElement("a");i.href=r,i.download=`${e}_input.json`,i.click(),URL.revokeObjectURL(r)}catch(n){alert(`Error downloading input for ${e}: ${n instanceof Error?n.message:String(n)}`)}},RGn=({solver:t,onStepUntilPhase:e,onDownloadInput:n})=>{const o=t.pipelineDef.map((a,c)=>MGn(t,c)),r=a=>{e?.(a)},i=a=>{a.solverInstance&&(n?n(a.solverInstance,a.name):AGn(a.solverInstance,a.name))},s=a=>`${(a/1e3).toFixed(2)}s`;return G.jsxs("div",{className:"border-t border-gray-200",children:[G.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:G.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),G.jsx("div",{className:"overflow-x-auto",children:G.jsxs("table",{className:"w-full text-sm",children:[G.jsx("thead",{children:G.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),G.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",G.jsx("sub",{children:"0"})]}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),G.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),G.jsx("tbody",{children:o.map(a=>G.jsxs("tr",{className:`border-b border-gray-100 ${a.status==="In Progress"?"bg-yellow-50":""}`,children:[G.jsx("td",{className:"px-4 py-2",children:G.jsxs("div",{className:"flex items-center gap-2",children:[G.jsx("span",{className:"text-gray-400 w-6",children:String(a.index+1).padStart(2,"0")}),G.jsx("button",{onClick:()=>r(a.name),disabled:a.status==="Completed"||t.solved||t.failed,className:"text-blue-500 hover:text-blue-700 disabled:text-gray-300 disabled:cursor-not-allowed",title:`Step until ${a.name} completes`,children:G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:G.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"})})}),G.jsx("span",{className:"font-medium text-gray-900",children:a.name})]})}),G.jsx("td",{className:"px-4 py-2",children:G.jsx(TGn,{status:a.status})}),G.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:a.firstIteration!==null?a.firstIteration:""}),G.jsx("td",{className:"px-4 py-2 text-gray-600",children:a.iterations}),G.jsx("td",{className:"px-4 py-2",children:G.jsx(wGn,{progress:a.progress})}),G.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(a.timeSpent)}),G.jsx("td",{className:"px-4 py-2 text-gray-500",children:G.jsx(DGn,{stats:a.stats})}),G.jsx("td",{className:"px-4 py-2",children:a.solverInstance?G.jsxs("button",{onClick:()=>i(a),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${a.name}`,children:[G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:G.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"})}),G.jsx("span",{children:"Input"})]}):null})]},a.name))})]})})]})},kGn=class extends ar.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 NGn({graphics:t}){const e=t.points??[],n=t.lines??[],o=t.rects??[],r=t.circles??[],i=t.texts??[];let s=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY,l=Number.NEGATIVE_INFINITY;const u=(x,f)=>{typeof x=="number"&&(x<s&&(s=x),x>c&&(c=x)),typeof f=="number"&&(f<a&&(a=f),f>l&&(l=f))};for(const x of e)u(x.x,x.y);for(const x of n){const f=x.points??[];for(const g of f)u(g.x,g.y)}for(const x of o){const f=x.x??0,g=x.y??0,y=x.width??0,b=x.height??0;u(f,g),u(f+y,g+b)}for(const x of r){const f=x.x??0,g=x.y??0,y=x.radius??1;u(f-y,g-y),u(f+y,g+y)}for(const x of i)u(x.x,x.y);(!isFinite(s)||!isFinite(a)||!isFinite(c)||!isFinite(l))&&(s=-20,a=-20,c=20,l=20);const _=10,d=s-_,m=a-_,h=Math.max(1,c-s+2*_),p=Math.max(1,l-a+2*_);return G.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${d} ${m} ${h} ${p}`,role:"img","aria-label":"Graphics fallback",children:[o.map((x,f)=>G.jsx("rect",{x:x.x??0,y:x.y??0,width:x.width??0,height:x.height??0,fill:"none",stroke:x.strokeColor??"black",strokeWidth:x.strokeWidth??1},`rect-${f}`)),n.map((x,f)=>G.jsx("polyline",{fill:"none",stroke:x.strokeColor??"black",strokeWidth:x.strokeWidth??1,points:(x.points??[]).map(g=>`${g.x??0},${g.y??0}`).join(" ")},`line-${f}`)),r.map((x,f)=>G.jsx("circle",{cx:x.x??0,cy:x.y??0,r:x.radius??1.5,fill:x.fillColor??"none",stroke:x.strokeColor??"black",strokeWidth:x.strokeWidth??1},`circle-${f}`)),e.map((x,f)=>G.jsx("circle",{cx:x.x??0,cy:x.y??0,r:x.radius??1.5,fill:x.color??"black"},`point-${f}`)),i.map((x,f)=>G.jsx("text",{x:x.x??0,y:x.y??0,fontSize:x.fontSize??10,fill:x.color??"black",children:x.text??""},`text-${f}`))]})}var HGn=({solver:t,animationSpeed:e=25,onSolverStarted:n,onSolverCompleted:o})=>{const[r,i]=te.useReducer(u=>u+1,0),s=te.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(u){return console.error("Visualization error:",u),{points:[],lines:[],rects:[],circles:[]}}},[t,r]),a=te.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);te.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const u=document.createElement("script");u.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(u)}},[]);const c=t.pipelineDef!==void 0,l=u=>{const _=t;if(!t.solved&&!t.failed){for(;!t.solved&&!t.failed&&_.currentPipelineStepIndex<=_.pipelineDef.findIndex(d=>d.solverName===u);)t.step();i()}};return G.jsxs("div",{children:[G.jsx(SGn,{solver:t,triggerRender:i,animationSpeed:e,onSolverStarted:n,onSolverCompleted:o}),a?G.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):G.jsx(kGn,{fallback:G.jsx(NGn,{graphics:s}),children:G.jsx(bGn,{graphics:s})}),c&&G.jsx(RGn,{solver:t,onStepUntilPhase:l})]})};const IGn=()=>{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)},[])},LGn=t=>t.toLowerCase().includes("pack")?ETn:t.toLowerCase().includes("rout")?HTn:yTn,OGn=({solverEvents:t=[]})=>{const[e,n]=te.useState(null);IGn();const o=te.useMemo(()=>{const a=new Map;for(const c of t){const l=`${c.componentName}-${c.solverName}`;a.set(l,c)}return a},[t]),r=te.useMemo(()=>Array.from(o.keys()),[o]),i=e?o.get(e):null,s=te.useMemo(()=>{if(!i)return{instance:null,error:null,classFound:!1};const a=Vae[i.solverName];if(!a)return{instance:null,error:`Solver class "${i.solverName}" not found in SOLVERS registry. Available: ${Object.keys(Vae).join(", ")}`,classFound:!1};try{const c=i.solverParams,l=c?.input!==void 0?c.input:c;return{instance:new a(l),error:null,classFound:!0}}catch(c){const l=c instanceof Error?c.message:String(c);return console.error("Failed to reconstruct solver:",c),{instance:null,error:`Failed to instantiate solver: ${l}`,classFound:!0}}},[i]);return t.length===0?G.jsx("div",{className:"rf-p-4",children:G.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:G.jsxs("div",{className:"rf-p-4",children:[G.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),G.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."})]})})}):G.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[G.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[G.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:[r.length," ",r.length===1?"Solver":"Solvers"]}),r.map(a=>{const c=o.get(a),l=e===a;return G.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${l?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>n(a),children:(()=>{const u=LGn(c.solverName);return G.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[G.jsx(u,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),G.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[G.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:c.componentName}),G.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:c.solverName})]})]})})()},a)})]}),G.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:i?s.instance?G.jsx(q6,{fallback:G.jsx("div",{className:"rf-p-4",children:G.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[G.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),G.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",i.solverName]})]})}),children:G.jsx(HGn,{solver:s.instance})}):G.jsxs("div",{className:"rf-p-4",children:[G.jsxs("div",{className:"rf-mb-4",children:[G.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:i.solverName}),G.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",i.componentName]})]}),s.error&&G.jsx("div",{className:`rf-rounded-md rf-border rf-p-4 rf-mb-4 ${s.classFound?"rf-bg-red-50 rf-border-red-200":"rf-bg-yellow-50 rf-border-yellow-200"}`,children:G.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),G.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[G.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:G.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),G.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:G.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(i.solverParams,null,2)})})]})]}):G.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:G.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},h_t=({errorMessage:t,errorStack:e,circuitJsonErrors:n})=>{te.useEffect(()=>{if(t){const o=new Error(t);e&&(o.stack=e);try{yL.captureException(o)}catch{}}},[t,e]),te.useEffect(()=>{if(n&&n.length>0)for(const o of n){const r=new Error(o.message||"Circuit JSON Error");o.stack&&(r.stack=o.stack);try{yL.captureException(r,{error_type:o.type})}catch{}}},[n])},m_t="0.0.1888",FGn={version:m_t},Cge={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},Mge=new Map,kG=t=>{const e=Mge.get(t);return e?Object.fromEntries(Object.entries(e.stores).map(([n,o])=>[n,o.getState()])):{}},BGn=(t,e,n)=>{if(t===void 0)return{type:"untracked",connection:e.connect(n)};const o=Mge.get(n.name);if(o)return{type:"tracked",store:t,...o};const r={connection:e.connect(n),stores:{}};return Mge.set(n.name,r),{type:"tracked",store:t,...r}},p_t=(t,e={})=>(n,o,r)=>{const{enabled:i,anonymousActionType:s,store:a,...c}=e;let l;try{l=(i??(Cge?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!l)return(Cge?"production":void 0)!=="production"&&i&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),t(n,o,r);const{connection:u,..._}=BGn(a,l,c);let d=!0;r.setState=(p,x,f)=>{const g=n(p,x);if(!d)return g;const y=f===void 0?{type:s||"anonymous"}:typeof f=="string"?{type:f}:f;return a===void 0?(u?.send(y,o()),g):(u?.send({...y,type:`${a}/${y.type}`},{...kG(c.name),[a]:r.getState()}),g)};const m=(...p)=>{const x=d;d=!1,n(...p),d=x},h=t(r.setState,o,r);if(_.type==="untracked"?u?.init(h):(_.stores[_.store]=r,u?.init(Object.fromEntries(Object.entries(_.stores).map(([p,x])=>[p,p===_.store?h:x.getState()])))),r.dispatchFromDevtools&&typeof r.dispatch=="function"){let p=!1;const x=r.dispatch;r.dispatch=(...f)=>{(Cge?"production":void 0)!=="production"&&f[0].type==="__setState"&&!p&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),p=!0),x(...f)}}return u.subscribe(p=>{var x;switch(p.type){case"ACTION":if(typeof p.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return Tge(p.payload,f=>{if(f.type==="__setState"){if(a===void 0){m(f.state);return}Object.keys(f.state).length!==1&&console.error(`
5695
5695
  [zustand devtools middleware] Unsupported __setState action format.
5696
5696
  When using 'store' option in devtools(), the 'state' should have only one key, which is a value of 'store' that was passed in devtools(),
5697
5697
  and value of this only key should be a state object. Example: { "type": "__setState", "state": { "abc123Store": { "foo": "bar" } } }
@@ -5707,7 +5707,7 @@ Alternatively, you can use your own component as a description by assigning it a
5707
5707
 
5708
5708
  For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return te.useEffect(()=>{document.getElementById(t.current?.getAttribute("aria-describedby"))||console.warn(e)},[e,t]),null},vYn=B_t,SYn=z_t,J_t=V_t,K_t=$_t,Q_t=G_t,Z_t=q_t,edt=U_t,tdt=j_t;const ndt=vYn,CYn=SYn,odt=te.forwardRef(({className:t,...e},n)=>G.jsx(J_t,{className:gi("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}));odt.displayName=J_t.displayName;const Lge=te.forwardRef(({className:t,...e},n)=>G.jsxs(CYn,{children:[G.jsx(odt,{}),G.jsx(K_t,{ref:n,className:gi("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})]}));Lge.displayName=K_t.displayName;const Oge=({className:t,...e})=>G.jsx("div",{className:gi("rf-flex rf-flex-col rf-space-y-2 rf-text-center sm:rf-text-left",t),...e});Oge.displayName="AlertDialogHeader";const Fge=({className:t,...e})=>G.jsx("div",{className:gi("rf-flex rf-flex-col-reverse sm:rf-flex-row sm:rf-justify-end sm:rf-space-x-2",t),...e});Fge.displayName="AlertDialogFooter";const Bge=te.forwardRef(({className:t,...e},n)=>G.jsx(edt,{ref:n,className:gi("rf-text-lg rf-font-semibold",t),...e}));Bge.displayName=edt.displayName;const zge=te.forwardRef(({className:t,...e},n)=>G.jsx(tdt,{ref:n,className:gi("rf-text-sm rf-text-zinc-500 dark:rf-text-zinc-400",t),...e}));zge.displayName=tdt.displayName;const MYn=te.forwardRef(({className:t,...e},n)=>G.jsx(Q_t,{ref:n,className:gi(tE(),t),...e}));MYn.displayName=Q_t.displayName;const Vge=te.forwardRef(({className:t,...e},n)=>G.jsx(Z_t,{ref:n,className:gi(tE({variant:"outline"}),"rf-mt-2 sm:rf-mt-0",t),...e}));Vge.displayName=Z_t.displayName;function TYn(t){const e=te.useRef({value:t,previous:t});return te.useMemo(()=>(e.current.value!==t&&(e.current.previous=e.current.value,e.current.value=t),e.current.previous),[t])}var IG="Checkbox",[wYn]=R3(IG),[EYn,$ge]=wYn(IG);function DYn(t){const{__scopeCheckbox:e,checked:n,children:o,defaultChecked:r,disabled:i,form:s,name:a,onCheckedChange:c,required:l,value:u="on",internal_do_not_use_render:_}=t,[d,m]=yC({prop:n,defaultProp:r??!1,onChange:c,caller:IG}),[h,p]=te.useState(null),[x,f]=te.useState(null),g=te.useRef(!1),y=h?!!s||!!h.closest("form"):!0,b={checked:d,disabled:i,setChecked:m,control:h,setControl:p,name:a,form:s,value:u,hasConsumerStoppedPropagationRef:g,required:l,defaultChecked:Hv(r)?!1:r,isFormControl:y,bubbleInput:x,setBubbleInput:f};return G.jsx(EYn,{scope:e,...b,children:AYn(_)?_(b):o})}var rdt="CheckboxTrigger",idt=te.forwardRef(({__scopeCheckbox:t,onKeyDown:e,onClick:n,...o},r)=>{const{control:i,value:s,disabled:a,checked:c,required:l,setControl:u,setChecked:_,hasConsumerStoppedPropagationRef:d,isFormControl:m,bubbleInput:h}=$ge(rdt,t),p=bd(r,u),x=te.useRef(c);return te.useEffect(()=>{const f=i?.form;if(f){const g=()=>_(x.current);return f.addEventListener("reset",g),()=>f.removeEventListener("reset",g)}},[i,_]),G.jsx($l.button,{type:"button",role:"checkbox","aria-checked":Hv(c)?"mixed":c,"aria-required":l,"data-state":udt(c),"data-disabled":a?"":void 0,disabled:a,value:s,...o,ref:p,onKeyDown:Zi(e,f=>{f.key==="Enter"&&f.preventDefault()}),onClick:Zi(n,f=>{_(g=>Hv(g)?!0:!g),h&&m&&(d.current=f.isPropagationStopped(),d.current||f.stopPropagation())})})});idt.displayName=rdt;var Wge=te.forwardRef((t,e)=>{const{__scopeCheckbox:n,name:o,checked:r,defaultChecked:i,required:s,disabled:a,value:c,onCheckedChange:l,form:u,..._}=t;return G.jsx(DYn,{__scopeCheckbox:n,checked:r,defaultChecked:i,disabled:a,required:s,onCheckedChange:l,name:o,form:u,value:c,internal_do_not_use_render:({isFormControl:d})=>G.jsxs(G.Fragment,{children:[G.jsx(idt,{..._,ref:e,__scopeCheckbox:n}),d&&G.jsx(ldt,{__scopeCheckbox:n})]})})});Wge.displayName=IG;var sdt="CheckboxIndicator",adt=te.forwardRef((t,e)=>{const{__scopeCheckbox:n,forceMount:o,...r}=t,i=$ge(sdt,n);return G.jsx(j4,{present:o||Hv(i.checked)||i.checked===!0,children:G.jsx($l.span,{"data-state":udt(i.checked),"data-disabled":i.disabled?"":void 0,...r,ref:e,style:{pointerEvents:"none",...t.style}})})});adt.displayName=sdt;var cdt="CheckboxBubbleInput",ldt=te.forwardRef(({__scopeCheckbox:t,...e},n)=>{const{control:o,hasConsumerStoppedPropagationRef:r,checked:i,defaultChecked:s,required:a,disabled:c,name:l,value:u,form:_,bubbleInput:d,setBubbleInput:m}=$ge(cdt,t),h=bd(n,m),p=TYn(i),x=ent(o);te.useEffect(()=>{const g=d;if(!g)return;const y=window.HTMLInputElement.prototype,v=Object.getOwnPropertyDescriptor(y,"checked").set,S=!r.current;if(p!==i&&v){const M=new Event("click",{bubbles:S});g.indeterminate=Hv(i),v.call(g,Hv(i)?!1:i),g.dispatchEvent(M)}},[d,p,i,r]);const f=te.useRef(Hv(i)?!1:i);return G.jsx($l.input,{type:"checkbox","aria-hidden":!0,defaultChecked:s??f.current,required:a,disabled:c,name:l,value:u,form:_,...e,tabIndex:-1,ref:h,style:{...e.style,...x,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});ldt.displayName=cdt;function AYn(t){return typeof t=="function"}function Hv(t){return t==="indeterminate"}function udt(t){return Hv(t)?"indeterminate":t?"checked":"unchecked"}const VH=te.forwardRef(({className:t,...e},n)=>G.jsx(Wge,{ref:n,className:gi("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:G.jsx(adt,{className:gi("rf-flex rf-items-center rf-justify-center rf-text-current"),children:G.jsx(p1e,{className:"rf-h-4 rf-w-4"})})}));VH.displayName=Wge.displayName;const $H=I_t,RYn=L_t,_dt=te.forwardRef(({className:t,...e},n)=>G.jsx(kge,{className:gi("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}));_dt.displayName=kge.displayName;const IE=te.forwardRef(({className:t,children:e,showOverlay:n=!0,...o},r)=>G.jsxs(RYn,{children:[G.jsx(_dt,{className:gi(n?"":"rf-hidden")}),G.jsx(Nge,{ref:r,className:gi("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})]}));IE.displayName=Nge.displayName;const LE=({className:t,...e})=>G.jsx("div",{className:gi("rf-flex rf-flex-col rf-space-y-2 rf-text-center sm:rf-text-left",t),...e});LE.displayName="DialogHeader";const WH=({className:t,...e})=>G.jsx("div",{className:gi("rf-flex rf-flex-col-reverse sm:rf-flex-row sm:rf-justify-end sm:rf-space-x-2",t),...e});WH.displayName="DialogFooter";const OE=te.forwardRef(({className:t,...e},n)=>G.jsx(Hge,{ref:n,className:gi("rf-text-lg rf-font-semibold",t),...e}));OE.displayName=Hge.displayName;const UH=te.forwardRef(({className:t,...e},n)=>G.jsx(Ige,{ref:n,className:gi("rf-text-sm rf-text-zinc-500 dark:rf-text-zinc-400",t),...e}));UH.displayName=Ige.displayName;const LG={"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"}},kYn="https://cdn.jsdelivr.net/npm/easyeda@latest/dist/browser/index.js";let Uge=null;const NYn=async()=>(Uge||(Uge=import(kYn)),Uge),HYn=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??[]},IYn=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}),LYn=async(t,e)=>{const{fetchEasyEDAComponent:n,convertRawEasyToTsx:o}=await NYn(),r=await n(t,{fetch:(i,s)=>fetch(`${e?.apiBase??j9}/proxy`,{...s,headers:{...s?.headers,"X-Target-Url":i.toString(),"X-Sender-Origin":s?.headers?.origin??"","X-Sender-Host":s?.headers?.host??"https://easyeda.com","X-Sender-Referer":s?.headers?.referer??"","X-Sender-User-Agent":s?.headers?.userAgent??"","X-Sender-Cookie":s?.headers?.cookie??"",authority:s?.headers?.authority??"","content-type":s?.headers?.["content-type"]??"",...e?.headers}})});return o({rawEasy:r})},OYn=({query:t,placeholder:e,isSearching:n,onQueryChange:o,onSubmit:r})=>{const i=te.useCallback(s=>{s.key==="Enter"&&(s.preventDefault(),r())},[r]);return G.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2 rf-mt-4",children:[G.jsxs("div",{className:"rf-relative rf-flex-grow",children:[G.jsx(ytt,{className:"rf-absolute rf-left-2 rf-top-2.5 rf-h-4 rf-w-4 rf-text-muted-foreground"}),G.jsx(J2e,{placeholder:e,className:"rf-pl-8",spellCheck:!1,autoComplete:"off",value:t,onChange:s=>o(s.target.value),onKeyDown:i})]}),G.jsx(w0,{onClick:r,disabled:n||t.trim().length<1,className:"sm:rf-px-4 rf-px-3",children:n?G.jsx(uv,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):G.jsxs(G.Fragment,{children:[G.jsx(ytt,{className:"rf-h-4 rf-w-4 sm:rf-hidden"}),G.jsx("span",{className:"rf-hidden sm:rf-inline",children:"Search"})]})})]})},FYn=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}),BYn=t=>FYn.format(t),ddt=t=>{switch(t.source){case"tscircuit.com":{const e=t.package;return`tscircuit-${e.package_id??`${e.org_owner_tscircuit_handle??"unknown"}-${e.unscoped_name??e.name??"package"}`}`}case"jlcpcb":return`jlc-${t.component.lcscId}`;case"kicad":return`kicad-${t.footprint.path}`;default:return"unknown"}},zYn=t=>{switch(t.source){case"tscircuit.com":return t.package.unscoped_name;case"jlcpcb":return t.component.manufacturer;case"kicad":return t.footprint.qualifiedName}},VYn=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}},$Yn=t=>{switch(t.source){case"tscircuit.com":return t.package.name;case"jlcpcb":return t.component.partNumber;case"kicad":return}},WYn=({results:t,selected:e,onSelect:n,onShowDetails:o})=>{const r=e?ddt(e):null;return G.jsx("div",{className:"rf-divide-y rf-w-full rf-overflow-hidden",children:t.map(i=>{const s=ddt(i),a=r===s,c=zYn(i),l=VYn(i),u=$Yn(i),_=i.source==="jlcpcb"?i.component.stock:null,d=i.source==="jlcpcb"?i.component.price:null,m=i.source==="jlcpcb"?i.component.isBasic:null;return G.jsxs("div",{className:`rf-p-3 rf-flex rf-flex-col sm:rf-grid sm:rf-grid-cols-[minmax(0,1fr)_auto] rf-items-start sm:rf-items-center rf-cursor-pointer hover:rf-bg-zinc-100 rf-gap-2 rf-overflow-hidden ${a?"rf-bg-zinc-100":""}`,onClick:()=>n(i),children:[G.jsxs("div",{className:"rf-min-w-0 rf-overflow-hidden rf-w-full",children:[G.jsxs("div",{className:"rf-flex rf-items-start rf-gap-2 rf-min-w-0",children:[G.jsxs("div",{className:"rf-font-medium rf-text-sm rf-truncate rf-flex-1 rf-min-w-0 rf-flex rf-items-center rf-gap-1.5",children:[c,i.source==="jlcpcb"&&m!=null&&G.jsx("span",{className:`rf-text-xs rf-px-1.5 rf-py-0.5 rf-rounded rf-font-medium rf-flex-shrink-0 ${m?"rf-bg-green-100 rf-text-green-700":"rf-bg-orange-100 rf-text-orange-700"}`,children:m?"Basic":"Extended"}),i.source==="tscircuit.com"&&i.package.is_private&&G.jsx(ATn,{className:"rf-ml-1 rf-h-3 rf-w-3 rf-text-zinc-400 rf-flex-shrink-0"})]}),i.source==="jlcpcb"&&_!=null?G.jsxs("div",{className:"rf-text-xs rf-text-zinc-500 rf-font-medium rf-whitespace-nowrap rf-flex-shrink-0 sm:rf-hidden",children:[_.toLocaleString()," in stock"]}):null]}),G.jsxs("div",{className:"rf-text-xs rf-text-zinc-500 rf-truncate rf-w-full",children:[u?G.jsx("span",{className:"rf-mr-2",children:u}):null,l]})]}),G.jsxs("div",{children:[i.source==="tscircuit.com"&&o?G.jsx("div",{className:"rf-flex-shrink-0 rf-w-full sm:rf-w-auto",children:G.jsx(w0,{variant:"outline",size:"sm",className:"rf-text-xs rf-w-full sm:rf-w-auto",onClick:h=>{h.stopPropagation(),o(i)},children:"See Details"})}):i.source==="jlcpcb"&&_!=null?G.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:[_.toLocaleString()," in stock"]}):null,d!=null&&G.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:BYn(d)})]})]},s)})})},hdt={importComponentDialog:101,importComponentDetailsDialog:102},UYn=({packageResult:t,isOpen:e,onOpenChange:n,isLoading:o,details:r,previewTab:i,onPreviewTabChange:s,isSubmitting:a,onImport:c})=>{const l=t?.package??null,u=l?.latest_pcb_preview_image_url,_=l?.latest_sch_preview_image_url,d=l?.latest_cad_preview_image_url,m=l?.unscoped_name?.split("/").pop()??l?.unscoped_name,h=l?.org_owner_tscircuit_handle??void 0,p=h?`https://tscircuit.com/${h}`:void 0,x=h&&m?`https://tscircuit.com/${h}/${m}`:void 0;return G.jsx($H,{open:e,onOpenChange:n,children:G.jsxs(IE,{showOverlay:!1,style:{width:"calc(100vw - 2rem)",zIndex:hdt.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:[G.jsx(LE,{className:"rf-pb-4 rf-border-b",children:G.jsx("div",{className:"rf-flex rf-items-start rf-justify-between rf-gap-4",children:G.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[G.jsx(OE,{className:"rf-text-xl rf-font-semibold rf-truncate",children:m}),G.jsx(UH,{children:l?.description})]})})}),G.jsxs("div",{className:"rf-flex-1 rf-overflow-y-auto rf-py-4 rf-space-y-6",children:[h?G.jsxs("div",{children:[G.jsx("span",{className:"rf-text-xs rf-font-medium rf-text-gray-500 rf-uppercase rf-tracking-wide",children:"Created by"}),G.jsx("div",{className:"rf-mt-1 rf-text-sm rf-font-medium",children:p?G.jsx("a",{href:p,target:"_blank",rel:"noopener noreferrer",className:"rf-text-black hover:rf-underline",children:h}):h})]}):null,(d||u||_)&&G.jsx(G.Fragment,{children:G.jsxs("div",{children:[G.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Preview"}),G.jsxs(uJ,{value:i,onValueChange:f=>s(f),children:[G.jsxs(PL,{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:[u&&G.jsx(q4,{value:"pcb",children:"PCB"}),_&&G.jsx(q4,{value:"schematic",children:"Schematic"}),d&&G.jsx(q4,{value:"3d",children:"3D"})]}),G.jsxs("div",{className:"rf-mt-4",children:[G.jsx(Zf,{value:"pcb",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:u?G.jsx("img",{src:u,alt:`${m??"package"} PCB preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null}),G.jsx(Zf,{value:"schematic",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:_?G.jsx("img",{src:_,alt:`${m??"package"} schematic preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null}),G.jsx(Zf,{value:"3d",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:d?G.jsx("img",{src:d,alt:`${m??"package"} 3D preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null})]})]})]})}),r?.ai_description?G.jsxs("section",{children:[G.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-3",children:"AI Description"}),G.jsx("div",{className:"rf-bg-gray-50 rf-border rf-border-gray-200 rf-rounded-lg rf-p-4",children:G.jsx("p",{className:"rf-text-sm rf-text-gray-700 rf-leading-relaxed",children:r.ai_description})})]}):null,r?.ai_usage_instructions?G.jsxs("section",{children:[G.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-3",children:"Usage Instructions"}),G.jsx("div",{className:"rf-bg-gray-50 rf-border rf-border-gray-200 rf-rounded-lg rf-p-4",children:G.jsx("p",{className:"rf-text-sm rf-text-gray-700 rf-leading-relaxed rf-whitespace-pre-wrap",children:r.ai_usage_instructions})})]}):null,o?G.jsxs("div",{className:"rf-flex rf-justify-center rf-items-center rf-gap-2 rf-text-gray-500",children:[G.jsx(uv,{className:"rf-h-4 rf-w-4 rf-animate-spin"}),G.jsx("span",{className:"rf-text-sm",children:"Loading package details..."})]}):null]}),G.jsxs(WH,{className:"rf-pt-4 rf-border-t rf-flex rf-flex-col sm:rf-flex-row rf-justify-between rf-gap-2",children:[G.jsx("div",{className:"rf-flex-1",children:x?G.jsxs(w0,{variant:"outline",size:"sm",className:"rf-gap-2 rf-w-full sm:rf-w-auto",onClick:()=>window.open(x,"_blank"),children:[G.jsx(TTn,{className:"rf-h-4 rf-w-4"}),"View on tscircuit.com"]}):null}),G.jsxs("div",{className:"rf-flex rf-flex-col sm:rf-flex-row rf-gap-2",children:[G.jsx(w0,{variant:"outline",onClick:()=>n(!1),className:"rf-order-2 sm:rf-order-1",children:"Close"}),G.jsx(w0,{onClick:c,disabled:a,className:"rf-bg-blue-600 hover:rf-bg-blue-700",children:a?G.jsx(uv,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):"Import Component"})]})]})]})})},XYn=()=>{const[t,e]=te.useState(null),[n,o]=te.useState(!1),r=te.useCallback(async(s,a)=>{o(!0);try{const c=await fetch(`https://api.tscircuit.com/packages/get?name=${encodeURIComponent(`${s}/${a}`)}`);if(!c.ok)throw new Error(`Failed to load package details: ${c.status}`);const l=await c.json();e(l.package??null)}catch(c){console.error("Failed to fetch package details",c),e(null)}finally{o(!1)}},[]),i=te.useCallback(()=>{e(null),o(!1)},[]);return{details:t,isLoading:n,fetchDetails:r,reset:i}},jYn=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??[]},GYn=({sessionToken:t})=>{const[e,n]=te.useState([]),[o,r]=te.useState(!1),[i,s]=te.useState(null),[a,c]=te.useState(!1),l=te.useCallback(async _=>{const d=_.trim();if(!d)return[];r(!0),s(null);try{const h=(await jYn(d,t)).map(p=>({source:"tscircuit.com",package:p}));return n(h),h}catch(m){return console.error("Error searching tscircuit packages",m),n([]),s(m instanceof Error?m.message:"Failed to search tscircuit packages"),[]}finally{r(!1),c(!0)}},[t]),u=te.useCallback(()=>{n([]),r(!1),s(null),c(!1)},[]);return{results:e,isSearching:o,error:i,hasSearched:a,search:l,reset:u}},YYn=t=>{const e=t.trim();return/^C\d+/i.test(e)?e.replace(/^C/i,""):e},qYn=()=>{const[t,e]=te.useState([]),[n,o]=te.useState(!1),[r,i]=te.useState(null),[s,a]=te.useState(!1),c=te.useCallback(async u=>{const _=YYn(u);if(!_)return[];o(!0),i(null);try{const m=(await HYn(_,10)).map(h=>({source:"jlcpcb",component:IYn(h)}));return e(m),m}catch(d){return console.error("Error searching JLCPCB components",d),e([]),i(d instanceof Error?d.message:"Failed to search JLCPCB components"),[]}finally{o(!1),a(!0)}},[]),l=te.useCallback(()=>{e([]),o(!1),i(null),a(!1)},[]);return{results:t,isSearching:n,error:r,hasSearched:s,search:c,reset:l}};function Y9(t){return Array.isArray?Array.isArray(t):fdt(t)==="[object Array]"}function JYn(t){if(typeof t=="string")return t;let e=t+"";return e=="0"&&1/t==-1/0?"-0":e}function KYn(t){return t==null?"":JYn(t)}function p3(t){return typeof t=="string"}function mdt(t){return typeof t=="number"}function QYn(t){return t===!0||t===!1||ZYn(t)&&fdt(t)=="[object Boolean]"}function pdt(t){return typeof t=="object"}function ZYn(t){return pdt(t)&&t!==null}function Kg(t){return t!=null}function Xge(t){return!t.trim().length}function fdt(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const eqn="Incorrect 'index' type",tqn=t=>`Invalid value for key ${t}`,nqn=t=>`Pattern length exceeds max of ${t}.`,oqn=t=>`Missing ${t} property in key`,rqn=t=>`Property 'weight' in key '${t}' must be a positive integer`,xdt=Object.prototype.hasOwnProperty;class iqn{constructor(e){this._keys=[],this._keyMap={};let n=0;e.forEach(o=>{let r=gdt(o);this._keys.push(r),this._keyMap[r.id]=r,n+=r.weight}),this._keys.forEach(o=>{o.weight/=n})}get(e){return this._keyMap[e]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function gdt(t){let e=null,n=null,o=null,r=1,i=null;if(p3(t)||Y9(t))o=t,e=ydt(t),n=jge(t);else{if(!xdt.call(t,"name"))throw new Error(oqn("name"));const s=t.name;if(o=s,xdt.call(t,"weight")&&(r=t.weight,r<=0))throw new Error(rqn(s));e=ydt(s),n=jge(s),i=t.getFn}return{path:e,id:n,weight:r,src:o,getFn:i}}function ydt(t){return Y9(t)?t:t.split(".")}function jge(t){return Y9(t)?t.join("."):t}function sqn(t,e){let n=[],o=!1;const r=(i,s,a)=>{if(Kg(i))if(!s[a])n.push(i);else{let c=s[a];const l=i[c];if(!Kg(l))return;if(a===s.length-1&&(p3(l)||mdt(l)||QYn(l)))n.push(KYn(l));else if(Y9(l)){o=!0;for(let u=0,_=l.length;u<_;u+=1)r(l[u],s,a+1)}else s.length&&r(l,s,a+1)}};return r(t,p3(e)?e.split("."):e,0),o?n:n[0]}var Li={...{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,getFn:sqn,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1}};const aqn=/[^ ]+/g;function cqn(t=1,e=3){const n=new Map,o=Math.pow(10,e);return{get(r){const i=r.match(aqn).length;if(n.has(i))return n.get(i);const s=1/Math.pow(i,.5*t),a=parseFloat(Math.round(s*o)/o);return n.set(i,a),a},clear(){n.clear()}}}class Gge{constructor({getFn:e=Li.getFn,fieldNormWeight:n=Li.fieldNormWeight}={}){this.norm=cqn(n,3),this.getFn=e,this.isCreated=!1,this.setIndexRecords()}setSources(e=[]){this.docs=e}setIndexRecords(e=[]){this.records=e}setKeys(e=[]){this.keys=e,this._keysMap={},e.forEach((n,o)=>{this._keysMap[n.id]=o})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,p3(this.docs[0])?this.docs.forEach((e,n)=>{this._addString(e,n)}):this.docs.forEach((e,n)=>{this._addObject(e,n)}),this.norm.clear())}add(e){const n=this.size();p3(e)?this._addString(e,n):this._addObject(e,n)}removeAt(e){this.records.splice(e,1);for(let n=e,o=this.size();n<o;n+=1)this.records[n].i-=1}getValueForItemAtKeyId(e,n){return e[this._keysMap[n]]}size(){return this.records.length}_addString(e,n){if(!Kg(e)||Xge(e))return;let o={v:e,i:n,n:this.norm.get(e)};this.records.push(o)}_addObject(e,n){let o={i:n,$:{}};this.keys.forEach((r,i)=>{let s=r.getFn?r.getFn(e):this.getFn(e,r.path);if(Kg(s)){if(Y9(s)){let a=[];const c=[{nestedArrIndex:-1,value:s}];for(;c.length;){const{nestedArrIndex:l,value:u}=c.pop();if(Kg(u))if(p3(u)&&!Xge(u)){let _={v:u,i:l,n:this.norm.get(u)};a.push(_)}else Y9(u)&&u.forEach((_,d)=>{c.push({nestedArrIndex:d,value:_})})}o.$[i]=a}else if(p3(s)&&!Xge(s)){let a={v:s,n:this.norm.get(s)};o.$[i]=a}}}),this.records.push(o)}toJSON(){return{keys:this.keys,records:this.records}}}function bdt(t,e,{getFn:n=Li.getFn,fieldNormWeight:o=Li.fieldNormWeight}={}){const r=new Gge({getFn:n,fieldNormWeight:o});return r.setKeys(t.map(gdt)),r.setSources(e),r.create(),r}function lqn(t,{getFn:e=Li.getFn,fieldNormWeight:n=Li.fieldNormWeight}={}){const{keys:o,records:r}=t,i=new Gge({getFn:e,fieldNormWeight:n});return i.setKeys(o),i.setIndexRecords(r),i}function OG(t,{errors:e=0,currentLocation:n=0,expectedLocation:o=0,distance:r=Li.distance,ignoreLocation:i=Li.ignoreLocation}={}){const s=e/t.length;if(i)return s;const a=Math.abs(o-n);return r?s+a/r:a?1:s}function uqn(t=[],e=Li.minMatchCharLength){let n=[],o=-1,r=-1,i=0;for(let s=t.length;i<s;i+=1){let a=t[i];a&&o===-1?o=i:!a&&o!==-1&&(r=i-1,r-o+1>=e&&n.push([o,r]),o=-1)}return t[i-1]&&i-o>=e&&n.push([o,i-1]),n}const VS=32;function _qn(t,e,n,{location:o=Li.location,distance:r=Li.distance,threshold:i=Li.threshold,findAllMatches:s=Li.findAllMatches,minMatchCharLength:a=Li.minMatchCharLength,includeMatches:c=Li.includeMatches,ignoreLocation:l=Li.ignoreLocation}={}){if(e.length>VS)throw new Error(nqn(VS));const u=e.length,_=t.length,d=Math.max(0,Math.min(o,_));let m=i,h=d;const p=a>1||c,x=p?Array(_):[];let f;for(;(f=t.indexOf(e,h))>-1;){let M=OG(e,{currentLocation:f,expectedLocation:d,distance:r,ignoreLocation:l});if(m=Math.min(M,m),h=f+u,p){let w=0;for(;w<u;)x[f+w]=1,w+=1}}h=-1;let g=[],y=1,b=u+_;const v=1<<u-1;for(let M=0;M<u;M+=1){let w=0,A=b;for(;w<A;)OG(e,{errors:M,currentLocation:d+A,expectedLocation:d,distance:r,ignoreLocation:l})<=m?w=A:b=A,A=Math.floor((b-w)/2+w);b=A;let D=Math.max(1,d-A+1),I=s?_:Math.min(d+A,_)+u,H=Array(I+2);H[I+1]=(1<<M)-1;for(let z=I;z>=D;z-=1){let V=z-1,j=n[t.charAt(V)];if(p&&(x[V]=+!!j),H[z]=(H[z+1]<<1|1)&j,M&&(H[z]|=(g[z+1]|g[z])<<1|1|g[z+1]),H[z]&v&&(y=OG(e,{errors:M,currentLocation:V,expectedLocation:d,distance:r,ignoreLocation:l}),y<=m)){if(m=y,h=V,h<=d)break;D=Math.max(1,2*d-h)}}if(OG(e,{errors:M+1,currentLocation:d,expectedLocation:d,distance:r,ignoreLocation:l})>m)break;g=H}const S={isMatch:h>=0,score:Math.max(.001,y)};if(p){const M=uqn(x,a);M.length?c&&(S.indices=M):S.isMatch=!1}return S}function dqn(t){let e={};for(let n=0,o=t.length;n<o;n+=1){const r=t.charAt(n);e[r]=(e[r]||0)|1<<o-n-1}return e}const FG=String.prototype.normalize?(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,"")):(t=>t);class Pdt{constructor(e,{location:n=Li.location,threshold:o=Li.threshold,distance:r=Li.distance,includeMatches:i=Li.includeMatches,findAllMatches:s=Li.findAllMatches,minMatchCharLength:a=Li.minMatchCharLength,isCaseSensitive:c=Li.isCaseSensitive,ignoreDiacritics:l=Li.ignoreDiacritics,ignoreLocation:u=Li.ignoreLocation}={}){if(this.options={location:n,threshold:o,distance:r,includeMatches:i,findAllMatches:s,minMatchCharLength:a,isCaseSensitive:c,ignoreDiacritics:l,ignoreLocation:u},e=c?e:e.toLowerCase(),e=l?FG(e):e,this.pattern=e,this.chunks=[],!this.pattern.length)return;const _=(m,h)=>{this.chunks.push({pattern:m,alphabet:dqn(m),startIndex:h})},d=this.pattern.length;if(d>VS){let m=0;const h=d%VS,p=d-h;for(;m<p;)_(this.pattern.substr(m,VS),m),m+=VS;if(h){const x=d-VS;_(this.pattern.substr(x),x)}}else _(this.pattern,0)}searchIn(e){const{isCaseSensitive:n,ignoreDiacritics:o,includeMatches:r}=this.options;if(e=n?e:e.toLowerCase(),e=o?FG(e):e,this.pattern===e){let p={isMatch:!0,score:0};return r&&(p.indices=[[0,e.length-1]]),p}const{location:i,distance:s,threshold:a,findAllMatches:c,minMatchCharLength:l,ignoreLocation:u}=this.options;let _=[],d=0,m=!1;this.chunks.forEach(({pattern:p,alphabet:x,startIndex:f})=>{const{isMatch:g,score:y,indices:b}=_qn(e,p,x,{location:i+f,distance:s,threshold:a,findAllMatches:c,minMatchCharLength:l,includeMatches:r,ignoreLocation:u});g&&(m=!0),d+=y,g&&b&&(_=[..._,...b])});let h={isMatch:m,score:m?d/this.chunks.length:1};return m&&r&&(h.indices=_),h}}class Iv{constructor(e){this.pattern=e}static isMultiMatch(e){return vdt(e,this.multiRegex)}static isSingleMatch(e){return vdt(e,this.singleRegex)}search(){}}function vdt(t,e){const n=t.match(e);return n?n[1]:null}class hqn extends Iv{constructor(e){super(e)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(e){const n=e===this.pattern;return{isMatch:n,score:n?0:1,indices:[0,this.pattern.length-1]}}}class mqn extends Iv{constructor(e){super(e)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(e){const o=e.indexOf(this.pattern)===-1;return{isMatch:o,score:o?0:1,indices:[0,e.length-1]}}}class pqn extends Iv{constructor(e){super(e)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(e){const n=e.startsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[0,this.pattern.length-1]}}}class fqn extends Iv{constructor(e){super(e)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(e){const n=!e.startsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}}class xqn extends Iv{constructor(e){super(e)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(e){const n=e.endsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[e.length-this.pattern.length,e.length-1]}}}class gqn extends Iv{constructor(e){super(e)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(e){const n=!e.endsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}}class Sdt extends Iv{constructor(e,{location:n=Li.location,threshold:o=Li.threshold,distance:r=Li.distance,includeMatches:i=Li.includeMatches,findAllMatches:s=Li.findAllMatches,minMatchCharLength:a=Li.minMatchCharLength,isCaseSensitive:c=Li.isCaseSensitive,ignoreDiacritics:l=Li.ignoreDiacritics,ignoreLocation:u=Li.ignoreLocation}={}){super(e),this._bitapSearch=new Pdt(e,{location:n,threshold:o,distance:r,includeMatches:i,findAllMatches:s,minMatchCharLength:a,isCaseSensitive:c,ignoreDiacritics:l,ignoreLocation:u})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(e){return this._bitapSearch.searchIn(e)}}class Cdt extends Iv{constructor(e){super(e)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(e){let n=0,o;const r=[],i=this.pattern.length;for(;(o=e.indexOf(this.pattern,n))>-1;)n=o+i,r.push([o,n-1]);const s=!!r.length;return{isMatch:s,score:s?0:1,indices:r}}}const Yge=[hqn,Cdt,pqn,fqn,gqn,xqn,mqn,Sdt],Mdt=Yge.length,yqn=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,bqn="|";function Pqn(t,e={}){return t.split(bqn).map(n=>{let o=n.trim().split(yqn).filter(i=>i&&!!i.trim()),r=[];for(let i=0,s=o.length;i<s;i+=1){const a=o[i];let c=!1,l=-1;for(;!c&&++l<Mdt;){const u=Yge[l];let _=u.isMultiMatch(a);_&&(r.push(new u(_,e)),c=!0)}if(!c)for(l=-1;++l<Mdt;){const u=Yge[l];let _=u.isSingleMatch(a);if(_){r.push(new u(_,e));break}}}return r})}const vqn=new Set([Sdt.type,Cdt.type]);class Sqn{constructor(e,{isCaseSensitive:n=Li.isCaseSensitive,ignoreDiacritics:o=Li.ignoreDiacritics,includeMatches:r=Li.includeMatches,minMatchCharLength:i=Li.minMatchCharLength,ignoreLocation:s=Li.ignoreLocation,findAllMatches:a=Li.findAllMatches,location:c=Li.location,threshold:l=Li.threshold,distance:u=Li.distance}={}){this.query=null,this.options={isCaseSensitive:n,ignoreDiacritics:o,includeMatches:r,minMatchCharLength:i,findAllMatches:a,ignoreLocation:s,location:c,threshold:l,distance:u},e=n?e:e.toLowerCase(),e=o?FG(e):e,this.pattern=e,this.query=Pqn(this.pattern,this.options)}static condition(e,n){return n.useExtendedSearch}searchIn(e){const n=this.query;if(!n)return{isMatch:!1,score:1};const{includeMatches:o,isCaseSensitive:r,ignoreDiacritics:i}=this.options;e=r?e:e.toLowerCase(),e=i?FG(e):e;let s=0,a=[],c=0;for(let l=0,u=n.length;l<u;l+=1){const _=n[l];a.length=0,s=0;for(let d=0,m=_.length;d<m;d+=1){const h=_[d],{isMatch:p,indices:x,score:f}=h.search(e);if(p){if(s+=1,c+=f,o){const g=h.constructor.type;vqn.has(g)?a=[...a,...x]:a.push(x)}}else{c=0,s=0,a.length=0;break}}if(s){let d={isMatch:!0,score:c/s};return o&&(d.indices=a),d}}return{isMatch:!1,score:1}}}const qge=[];function Cqn(...t){qge.push(...t)}function Jge(t,e){for(let n=0,o=qge.length;n<o;n+=1){let r=qge[n];if(r.condition(t,e))return new r(t,e)}return new Pdt(t,e)}const BG={AND:"$and",OR:"$or"},Kge={PATH:"$path",PATTERN:"$val"},Qge=t=>!!(t[BG.AND]||t[BG.OR]),Mqn=t=>!!t[Kge.PATH],Tqn=t=>!Y9(t)&&pdt(t)&&!Qge(t),Tdt=t=>({[BG.AND]:Object.keys(t).map(e=>({[e]:t[e]}))});function wdt(t,e,{auto:n=!0}={}){const o=r=>{let i=Object.keys(r);const s=Mqn(r);if(!s&&i.length>1&&!Qge(r))return o(Tdt(r));if(Tqn(r)){const c=s?r[Kge.PATH]:i[0],l=s?r[Kge.PATTERN]:r[c];if(!p3(l))throw new Error(tqn(c));const u={keyId:jge(c),pattern:l};return n&&(u.searcher=Jge(l,e)),u}let a={children:[],operator:i[0]};return i.forEach(c=>{const l=r[c];Y9(l)&&l.forEach(u=>{a.children.push(o(u))})}),a};return Qge(t)||(t=Tdt(t)),o(t)}function wqn(t,{ignoreFieldNorm:e=Li.ignoreFieldNorm}){t.forEach(n=>{let o=1;n.matches.forEach(({key:r,norm:i,score:s})=>{const a=r?r.weight:null;o*=Math.pow(s===0&&a?Number.EPSILON:s,(a||1)*(e?1:i))}),n.score=o})}function Eqn(t,e){const n=t.matches;e.matches=[],Kg(n)&&n.forEach(o=>{if(!Kg(o.indices)||!o.indices.length)return;const{indices:r,value:i}=o;let s={indices:r,value:i};o.key&&(s.key=o.key.src),o.idx>-1&&(s.refIndex=o.idx),e.matches.push(s)})}function Dqn(t,e){e.score=t.score}function Aqn(t,e,{includeMatches:n=Li.includeMatches,includeScore:o=Li.includeScore}={}){const r=[];return n&&r.push(Eqn),o&&r.push(Dqn),t.map(i=>{const{idx:s}=i,a={item:e[s],refIndex:s};return r.length&&r.forEach(c=>{c(i,a)}),a})}class FE{constructor(e,n={},o){this.options={...Li,...n},this.options.useExtendedSearch,this._keyStore=new iqn(this.options.keys),this.setCollection(e,o)}setCollection(e,n){if(this._docs=e,n&&!(n instanceof Gge))throw new Error(eqn);this._myIndex=n||bdt(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(e){Kg(e)&&(this._docs.push(e),this._myIndex.add(e))}remove(e=()=>!1){const n=[];for(let o=0,r=this._docs.length;o<r;o+=1){const i=this._docs[o];e(i,o)&&(this.removeAt(o),o-=1,r-=1,n.push(i))}return n}removeAt(e){this._docs.splice(e,1),this._myIndex.removeAt(e)}getIndex(){return this._myIndex}search(e,{limit:n=-1}={}){const{includeMatches:o,includeScore:r,shouldSort:i,sortFn:s,ignoreFieldNorm:a}=this.options;let c=p3(e)?p3(this._docs[0])?this._searchStringList(e):this._searchObjectList(e):this._searchLogical(e);return wqn(c,{ignoreFieldNorm:a}),i&&c.sort(s),mdt(n)&&n>-1&&(c=c.slice(0,n)),Aqn(c,this._docs,{includeMatches:o,includeScore:r})}_searchStringList(e){const n=Jge(e,this.options),{records:o}=this._myIndex,r=[];return o.forEach(({v:i,i:s,n:a})=>{if(!Kg(i))return;const{isMatch:c,score:l,indices:u}=n.searchIn(i);c&&r.push({item:i,idx:s,matches:[{score:l,value:i,norm:a,indices:u}]})}),r}_searchLogical(e){const n=wdt(e,this.options),o=(a,c,l)=>{if(!a.children){const{keyId:_,searcher:d}=a,m=this._findMatches({key:this._keyStore.get(_),value:this._myIndex.getValueForItemAtKeyId(c,_),searcher:d});return m&&m.length?[{idx:l,item:c,matches:m}]:[]}const u=[];for(let _=0,d=a.children.length;_<d;_+=1){const m=a.children[_],h=o(m,c,l);if(h.length)u.push(...h);else if(a.operator===BG.AND)return[]}return u},r=this._myIndex.records,i={},s=[];return r.forEach(({$:a,i:c})=>{if(Kg(a)){let l=o(n,a,c);l.length&&(i[c]||(i[c]={idx:c,item:a,matches:[]},s.push(i[c])),l.forEach(({matches:u})=>{i[c].matches.push(...u)}))}}),s}_searchObjectList(e){const n=Jge(e,this.options),{keys:o,records:r}=this._myIndex,i=[];return r.forEach(({$:s,i:a})=>{if(!Kg(s))return;let c=[];o.forEach((l,u)=>{c.push(...this._findMatches({key:l,value:s[u],searcher:n}))}),c.length&&i.push({idx:a,item:s,matches:c})}),i}_findMatches({key:e,value:n,searcher:o}){if(!Kg(n))return[];let r=[];if(Y9(n))n.forEach(({v:i,i:s,n:a})=>{if(!Kg(i))return;const{isMatch:c,score:l,indices:u}=o.searchIn(i);c&&r.push({score:l,key:e,value:i,idx:s,norm:a,indices:u})});else{const{v:i,n:s}=n,{isMatch:a,score:c,indices:l}=o.searchIn(i);a&&r.push({score:c,key:e,value:i,norm:s,indices:l})}return r}}FE.version="7.1.0",FE.createIndex=bdt,FE.parseIndex=lqn,FE.config=Li,FE.parseQuery=wdt,Cqn(Sqn);let Zge=null,XH=null,eye=null;const Rqn=async()=>Zge||XH||(XH=fetch("https://kicad-mod-cache.tscircuit.com/kicad_files.json").then(t=>t.json()).then(t=>(Zge=t,XH=null,t)),XH),kqn=async(t,e=20)=>{const n=await Rqn();return eye||(eye=new FE(n)),eye.search(t).slice(0,e).map(o=>o.item)},Nqn=t=>{const e=t.replace(".pretty/","/").replace(".kicad_mod",""),n=`kicad:${e}`;return{path:t,qualifiedName:n,description:e}},Hqn=()=>{const[t,e]=te.useState([]),[n,o]=te.useState(!1),[r,i]=te.useState(null),[s,a]=te.useState(!1),c=te.useCallback(async u=>{const _=u.trim();if(!_)return[];o(!0),i(null);try{const m=(await kqn(_,20)).map(h=>({source:"kicad",footprint:Nqn(h)}));return e(m),m}catch(d){return console.error("Error searching KiCad footprints",d),e([]),i(d instanceof Error?d.message:"Failed to search KiCad footprints"),[]}finally{o(!1),a(!0)}},[]),l=te.useCallback(()=>{e([]),o(!1),i(null),a(!1)},[]);return{results:t,isSearching:n,error:r,hasSearched:s,search:c,reset:l}},Iqn=({onTscircuitPackageSelected:t,onJlcpcbComponentTsxLoaded:e,onKicadStringSelected:n})=>{const o=[];return t&&o.push("tscircuit.com"),e&&o.push("jlcpcb"),n&&o.push("kicad"),o},Lqn=({isOpen:t,onClose:e,jlcpcbProxyRequestHeaders:n,onKicadStringSelected:o,onTscircuitPackageSelected:r,onJlcpcbComponentTsxLoaded:i,jlcpcbProxyApiBase:s,tscircuitSessionToken:a})=>{n_t();const c=te.useMemo(()=>Iqn({onKicadStringSelected:o,onTscircuitPackageSelected:r,onJlcpcbComponentTsxLoaded:i}),[o,r,i]),l=c.length>0,u=c.length===1,[_,d]=te.useState(c[0]??"tscircuit.com"),[m,h]=te.useState(""),[p,x]=te.useState(null),{results:f,isSearching:g,error:y,hasSearched:b,search:v,reset:S}=GYn({sessionToken:a}),{results:M,isSearching:w,error:A,hasSearched:D,search:I,reset:H}=qYn(),{results:B,isSearching:z,error:V,hasSearched:j,search:Y,reset:J}=Hqn(),{details:ne,isLoading:ae,fetchDetails:Z,reset:oe}=XYn(),[se,le]=te.useState(null),[pe,Se]=te.useState(!1),[we,De]=te.useState("pcb"),[ge,Me]=te.useState(null),[fe,We]=te.useState(!1);te.useEffect(()=>{Me(null)},[p]);const je=te.useCallback(()=>{S(),H(),J(),x(null)},[H,J,S]);te.useEffect(()=>{t||(je(),h(""),Se(!1),le(null),Me(null))},[t,je]),te.useEffect(()=>{h(""),x(null),_==="tscircuit.com"?S():_==="jlcpcb"?H():_==="kicad"&&J()},[_,H,J,S]);const Ke=ze=>{x(ze),le(ze),De("pcb"),Se(!0),oe();const Ue=ze.package.org_owner_tscircuit_handle,et=ze.package.unscoped_name;if(Ue&&et){const ot=et.split("/").pop()??et;Z(Ue,ot)}},me=async()=>{m.trim()&&(x(null),_==="tscircuit.com"?await v(m):_==="jlcpcb"?await I(m):_==="kicad"&&await Y(m))},qe=async ze=>{try{if(Me(null),We(!0),ze.source==="kicad"){if(!o)throw new Error("KiCad handler not provided");await o({result:ze,footprint:ze.footprint.qualifiedName})}else if(ze.source==="jlcpcb"){if(!i)throw new Error("JLCPCB handler not provided");const Ue=await LYn(ze.component.partNumber,{headers:n,apiBase:s});await i({result:ze,tsx:Ue})}else if(ze.source==="tscircuit.com"){if(!r)throw new Error("tscircuit package handler not provided");const Ue=ze.package.org_owner_tscircuit_handle,et=ze.package.unscoped_name;if(!Ue||!et)throw new Error("Missing package metadata");const ot=et.split("/").pop()??et,at=`@tsci/${Ue}.${ot}`;await r({result:ze,fullPackageName:at})}return!0}catch(Ue){return console.error("Failed to import component",Ue),Me(Ue instanceof Error?Ue.message:"Failed to import component"),!1}finally{We(!1)}};let Fe=[],Ne=!1,$e=null,ke=!1;_==="tscircuit.com"?(Fe=f,Ne=g,$e=y,ke=b):_==="jlcpcb"?(Fe=M,Ne=w,$e=A,ke=D):_==="kicad"&&(Fe=B,Ne=z,$e=V,ke=j);const ve=async()=>{if(!p)return;await qe(p)&&(e(),je(),h(""))},Ee=ze=>{ze||e()},Te=ze=>{Se(ze),ze||le(null)};return G.jsxs($H,{open:t,onOpenChange:Ee,children:[G.jsxs(IE,{style:{width:"calc(100vw - 2rem)",zIndex:hdt.importComponentDialog},className:"rf-rounded-sm rf-max-h-[90vh] rf-overflow-y-auto rf-overflow-x-hidden rf-flex rf-flex-col",children:[G.jsxs(LE,{children:[G.jsxs(OE,{className:"rf-text-lg sm:rf-text-xl",children:["Import ",u?LG[_].label:""," ","Component"]}),G.jsx(UH,{className:"rf-text-sm",children:l?"Search for components from available sources.":"Import options are disabled because no handlers were provided."})]}),l?G.jsxs(uJ,{value:_,onValueChange:ze=>d(ze),className:"rf-min-w-0 rf-w-full",children:[!u&&G.jsx(PL,{className:"rf-flex rf-w-full rf-gap-2",children:c.map(ze=>G.jsx(q4,{value:ze,className:"rf-flex-1 rf-text-xs sm:rf-text-sm",children:LG[ze].label},ze))}),G.jsx(OYn,{query:m,placeholder:LG[_].placeholder,isSearching:Ne,onQueryChange:h,onSubmit:me}),G.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:Ne?G.jsxs("div",{className:"rf-p-8 rf-text-center rf-text-zinc-500",children:[G.jsx(uv,{className:"rf-h-8 rf-w-8 rf-animate-spin rf-mx-auto rf-mb-2"}),G.jsx("p",{children:"Searching..."})]}):Fe.length>0?G.jsx(WYn,{results:Fe,selected:p,onSelect:x,onShowDetails:_==="tscircuit.com"?Ke:void 0}):G.jsx("div",{className:"rf-p-8 rf-text-center rf-text-zinc-500",children:$e?`Error: ${$e}`:ke?LG[_].emptyMessage:"Enter a search term to find components"})})]}):null,ge?G.jsx("div",{className:"rf-text-sm rf-text-red-600 rf-mt-2",children:ge}):null,G.jsxs(WH,{className:"rf-flex rf-flex-col sm:rf-flex-row rf-gap-2",children:[G.jsx(w0,{variant:"outline",onClick:e,className:"rf-order-2 sm:rf-order-1",children:"Cancel"}),G.jsx(w0,{onClick:ve,disabled:!p||fe,className:"rf-order-1 sm:rf-order-2",children:fe?G.jsx(uv,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):"Import"})]})]}),G.jsx(UYn,{packageResult:se,isOpen:pe,onOpenChange:Te,isLoading:ae,details:ne,previewTab:we,onPreviewTabChange:ze=>De(ze),isSubmitting:fe,onImport:()=>{se&&qe(se).then(ze=>{ze&&(Se(!1),e(),je(),h(""))})}})]})},Oqn=t=>{const e=t.match(/export const (\w+) =/);if(!e)throw new Error("Could not determine component name from TSX contents");return e[1]},Edt=t=>{const e=m3(s=>s.pushEvent),n=m3(s=>s.upsertFile),o=async({result:s,fullPackageName:a})=>{const l=s.package.unscoped_name??s.package.name;await Es.promise(e({event_type:"INSTALL_PACKAGE",full_package_name:a}),{loading:`Requesting install for "${l}"`,success:`Install requested for "${l}"`,error:u=>`Failed to request install: ${u instanceof Error?u.message:String(u)}`})},r=async({footprint:s})=>{await Es.promise(navigator.clipboard.writeText(s),{loading:`Copying "${s}"`,success:`Copied "${s}" to clipboard`,error:a=>`Failed to copy footprint: ${a instanceof Error?a.message:String(a)}`})},i=async({result:s,tsx:a})=>{const l=`imports/${Oqn(a)}.tsx`;await Es.promise(n(l,a),{loading:`Importing ${s.component.partNumber}`,success:`Imported to "${l}"`,error:u=>`Failed to import component: ${u instanceof Error?u.message:String(u)}`})};return G.jsx(Lqn,{...t,onTscircuitPackageSelected:o,onKicadStringSelected:r,onJlcpcbComponentTsxLoaded:i})};Edt.displayName="ImportComponentDialogForCli";var tye={exports:{}},Ddt;function Fqn(){return Ddt||(Ddt=1,(function(t,e){var n={env:{},version:""};(function(o){t.exports=o()})(function(){return(function o(r,i,s){function a(u,_){if(!i[u]){if(!r[u]){var d=typeof uP=="function"&&uP;if(!_&&d)return d(u,!0);if(c)return c(u,!0);var m=new Error("Cannot find module '"+u+"'");throw m.code="MODULE_NOT_FOUND",m}var h=i[u]={exports:{}};r[u][0].call(h.exports,function(p){var x=r[u][1][p];return a(x||p)},h,h.exports,o,r,i,s)}return i[u].exports}for(var c=typeof uP=="function"&&uP,l=0;l<s.length;l++)a(s[l]);return a})({1:[function(o,r,i){var s=o("./utils"),a=o("./support"),c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";i.encode=function(l){for(var u,_,d,m,h,p,x,f=[],g=0,y=l.length,b=y,v=s.getTypeOf(l)!=="string";g<l.length;)b=y-g,d=v?(u=l[g++],_=g<y?l[g++]:0,g<y?l[g++]:0):(u=l.charCodeAt(g++),_=g<y?l.charCodeAt(g++):0,g<y?l.charCodeAt(g++):0),m=u>>2,h=(3&u)<<4|_>>4,p=1<b?(15&_)<<2|d>>6:64,x=2<b?63&d:64,f.push(c.charAt(m)+c.charAt(h)+c.charAt(p)+c.charAt(x));return f.join("")},i.decode=function(l){var u,_,d,m,h,p,x=0,f=0,g="data:";if(l.substr(0,g.length)===g)throw new Error("Invalid base64 input, it looks like a data url.");var y,b=3*(l=l.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(l.charAt(l.length-1)===c.charAt(64)&&b--,l.charAt(l.length-2)===c.charAt(64)&&b--,b%1!=0)throw new Error("Invalid base64 input, bad content length.");for(y=a.uint8array?new Uint8Array(0|b):new Array(0|b);x<l.length;)u=c.indexOf(l.charAt(x++))<<2|(m=c.indexOf(l.charAt(x++)))>>4,_=(15&m)<<4|(h=c.indexOf(l.charAt(x++)))>>2,d=(3&h)<<6|(p=c.indexOf(l.charAt(x++))),y[f++]=u,h!==64&&(y[f++]=_),p!==64&&(y[f++]=d);return y}},{"./support":30,"./utils":32}],2:[function(o,r,i){var s=o("./external"),a=o("./stream/DataWorker"),c=o("./stream/Crc32Probe"),l=o("./stream/DataLengthProbe");function u(_,d,m,h,p){this.compressedSize=_,this.uncompressedSize=d,this.crc32=m,this.compression=h,this.compressedContent=p}u.prototype={getContentWorker:function(){var _=new a(s.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new l("data_length")),d=this;return _.on("end",function(){if(this.streamInfo.data_length!==d.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),_},getCompressedWorker:function(){return new a(s.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},u.createWorkerFrom=function(_,d,m){return _.pipe(new c).pipe(new l("uncompressedSize")).pipe(d.compressWorker(m)).pipe(new l("compressedSize")).withStreamInfo("compression",d)},r.exports=u},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(o,r,i){var s=o("./stream/GenericWorker");i.STORE={magic:"\0\0",compressWorker:function(){return new s("STORE compression")},uncompressWorker:function(){return new s("STORE decompression")}},i.DEFLATE=o("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(o,r,i){var s=o("./utils"),a=(function(){for(var c,l=[],u=0;u<256;u++){c=u;for(var _=0;_<8;_++)c=1&c?3988292384^c>>>1:c>>>1;l[u]=c}return l})();r.exports=function(c,l){return c!==void 0&&c.length?s.getTypeOf(c)!=="string"?(function(u,_,d,m){var h=a,p=m+d;u^=-1;for(var x=m;x<p;x++)u=u>>>8^h[255&(u^_[x])];return-1^u})(0|l,c,c.length,0):(function(u,_,d,m){var h=a,p=m+d;u^=-1;for(var x=m;x<p;x++)u=u>>>8^h[255&(u^_.charCodeAt(x))];return-1^u})(0|l,c,c.length,0):0}},{"./utils":32}],5:[function(o,r,i){i.base64=!1,i.binary=!1,i.dir=!1,i.createFolders=!0,i.date=null,i.compression=null,i.compressionOptions=null,i.comment=null,i.unixPermissions=null,i.dosPermissions=null},{}],6:[function(o,r,i){var s=null;s=typeof Promise<"u"?Promise:o("lie"),r.exports={Promise:s}},{lie:37}],7:[function(o,r,i){var s=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",a=o("pako"),c=o("./utils"),l=o("./stream/GenericWorker"),u=s?"uint8array":"array";function _(d,m){l.call(this,"FlateWorker/"+d),this._pako=null,this._pakoAction=d,this._pakoOptions=m,this.meta={}}i.magic="\b\0",c.inherits(_,l),_.prototype.processChunk=function(d){this.meta=d.meta,this._pako===null&&this._createPako(),this._pako.push(c.transformTo(u,d.data),!1)},_.prototype.flush=function(){l.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},_.prototype.cleanUp=function(){l.prototype.cleanUp.call(this),this._pako=null},_.prototype._createPako=function(){this._pako=new a[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var d=this;this._pako.onData=function(m){d.push({data:m,meta:d.meta})}},i.compressWorker=function(d){return new _("Deflate",d)},i.uncompressWorker=function(){return new _("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(o,r,i){function s(h,p){var x,f="";for(x=0;x<p;x++)f+=String.fromCharCode(255&h),h>>>=8;return f}function a(h,p,x,f,g,y){var b,v,S=h.file,M=h.compression,w=y!==u.utf8encode,A=c.transformTo("string",y(S.name)),D=c.transformTo("string",u.utf8encode(S.name)),I=S.comment,H=c.transformTo("string",y(I)),B=c.transformTo("string",u.utf8encode(I)),z=D.length!==S.name.length,V=B.length!==I.length,j="",Y="",J="",ne=S.dir,ae=S.date,Z={crc32:0,compressedSize:0,uncompressedSize:0};p&&!x||(Z.crc32=h.crc32,Z.compressedSize=h.compressedSize,Z.uncompressedSize=h.uncompressedSize);var oe=0;p&&(oe|=8),w||!z&&!V||(oe|=2048);var se=0,le=0;ne&&(se|=16),g==="UNIX"?(le=798,se|=(function(Se,we){var De=Se;return Se||(De=we?16893:33204),(65535&De)<<16})(S.unixPermissions,ne)):(le=20,se|=(function(Se){return 63&(Se||0)})(S.dosPermissions)),b=ae.getUTCHours(),b<<=6,b|=ae.getUTCMinutes(),b<<=5,b|=ae.getUTCSeconds()/2,v=ae.getUTCFullYear()-1980,v<<=4,v|=ae.getUTCMonth()+1,v<<=5,v|=ae.getUTCDate(),z&&(Y=s(1,1)+s(_(A),4)+D,j+="up"+s(Y.length,2)+Y),V&&(J=s(1,1)+s(_(H),4)+B,j+="uc"+s(J.length,2)+J);var pe="";return pe+=`
5709
5709
  \0`,pe+=s(oe,2),pe+=M.magic,pe+=s(b,2),pe+=s(v,2),pe+=s(Z.crc32,4),pe+=s(Z.compressedSize,4),pe+=s(Z.uncompressedSize,4),pe+=s(A.length,2),pe+=s(j.length,2),{fileRecord:d.LOCAL_FILE_HEADER+pe+A+j,dirRecord:d.CENTRAL_FILE_HEADER+s(le,2)+pe+s(H.length,2)+"\0\0\0\0"+s(se,4)+s(f,4)+A+j+H}}var c=o("../utils"),l=o("../stream/GenericWorker"),u=o("../utf8"),_=o("../crc32"),d=o("../signature");function m(h,p,x,f){l.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=p,this.zipPlatform=x,this.encodeFileName=f,this.streamFiles=h,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}c.inherits(m,l),m.prototype.push=function(h){var p=h.meta.percent||0,x=this.entriesCount,f=this._sources.length;this.accumulate?this.contentBuffer.push(h):(this.bytesWritten+=h.data.length,l.prototype.push.call(this,{data:h.data,meta:{currentFile:this.currentFile,percent:x?(p+100*(x-f-1))/x:100}}))},m.prototype.openedSource=function(h){this.currentSourceOffset=this.bytesWritten,this.currentFile=h.file.name;var p=this.streamFiles&&!h.file.dir;if(p){var x=a(h,p,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:x.fileRecord,meta:{percent:0}})}else this.accumulate=!0},m.prototype.closedSource=function(h){this.accumulate=!1;var p=this.streamFiles&&!h.file.dir,x=a(h,p,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(x.dirRecord),p)this.push({data:(function(f){return d.DATA_DESCRIPTOR+s(f.crc32,4)+s(f.compressedSize,4)+s(f.uncompressedSize,4)})(h),meta:{percent:100}});else for(this.push({data:x.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},m.prototype.flush=function(){for(var h=this.bytesWritten,p=0;p<this.dirRecords.length;p++)this.push({data:this.dirRecords[p],meta:{percent:100}});var x=this.bytesWritten-h,f=(function(g,y,b,v,S){var M=c.transformTo("string",S(v));return d.CENTRAL_DIRECTORY_END+"\0\0\0\0"+s(g,2)+s(g,2)+s(y,4)+s(b,4)+s(M.length,2)+M})(this.dirRecords.length,x,h,this.zipComment,this.encodeFileName);this.push({data:f,meta:{percent:100}})},m.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},m.prototype.registerPrevious=function(h){this._sources.push(h);var p=this;return h.on("data",function(x){p.processChunk(x)}),h.on("end",function(){p.closedSource(p.previous.streamInfo),p._sources.length?p.prepareNextSource():p.end()}),h.on("error",function(x){p.error(x)}),this},m.prototype.resume=function(){return!!l.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},m.prototype.error=function(h){var p=this._sources;if(!l.prototype.error.call(this,h))return!1;for(var x=0;x<p.length;x++)try{p[x].error(h)}catch{}return!0},m.prototype.lock=function(){l.prototype.lock.call(this);for(var h=this._sources,p=0;p<h.length;p++)h[p].lock()},r.exports=m},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(o,r,i){var s=o("../compressions"),a=o("./ZipFileWorker");i.generateWorker=function(c,l,u){var _=new a(l.streamFiles,u,l.platform,l.encodeFileName),d=0;try{c.forEach(function(m,h){d++;var p=(function(y,b){var v=y||b,S=s[v];if(!S)throw new Error(v+" is not a valid compression method !");return S})(h.options.compression,l.compression),x=h.options.compressionOptions||l.compressionOptions||{},f=h.dir,g=h.date;h._compressWorker(p,x).withStreamInfo("file",{name:m,dir:f,date:g,comment:h.comment||"",unixPermissions:h.unixPermissions,dosPermissions:h.dosPermissions}).pipe(_)}),_.entriesCount=d}catch(m){_.error(m)}return _}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(o,r,i){function s(){if(!(this instanceof s))return new s;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var a=new s;for(var c in this)typeof this[c]!="function"&&(a[c]=this[c]);return a}}(s.prototype=o("./object")).loadAsync=o("./load"),s.support=o("./support"),s.defaults=o("./defaults"),s.version="3.10.1",s.loadAsync=function(a,c){return new s().loadAsync(a,c)},s.external=o("./external"),r.exports=s},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(o,r,i){var s=o("./utils"),a=o("./external"),c=o("./utf8"),l=o("./zipEntries"),u=o("./stream/Crc32Probe"),_=o("./nodejsUtils");function d(m){return new a.Promise(function(h,p){var x=m.decompressed.getContentWorker().pipe(new u);x.on("error",function(f){p(f)}).on("end",function(){x.streamInfo.crc32!==m.decompressed.crc32?p(new Error("Corrupted zip : CRC32 mismatch")):h()}).resume()})}r.exports=function(m,h){var p=this;return h=s.extend(h||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:c.utf8decode}),_.isNode&&_.isStream(m)?a.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):s.prepareContent("the loaded zip file",m,!0,h.optimizedBinaryString,h.base64).then(function(x){var f=new l(h);return f.load(x),f}).then(function(x){var f=[a.Promise.resolve(x)],g=x.files;if(h.checkCRC32)for(var y=0;y<g.length;y++)f.push(d(g[y]));return a.Promise.all(f)}).then(function(x){for(var f=x.shift(),g=f.files,y=0;y<g.length;y++){var b=g[y],v=b.fileNameStr,S=s.resolve(b.fileNameStr);p.file(S,b.decompressed,{binary:!0,optimizedBinaryString:!0,date:b.date,dir:b.dir,comment:b.fileCommentStr.length?b.fileCommentStr:null,unixPermissions:b.unixPermissions,dosPermissions:b.dosPermissions,createFolders:h.createFolders}),b.dir||(p.file(S).unsafeOriginalName=v)}return f.zipComment.length&&(p.comment=f.zipComment),p})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(o,r,i){var s=o("../utils"),a=o("../stream/GenericWorker");function c(l,u){a.call(this,"Nodejs stream input adapter for "+l),this._upstreamEnded=!1,this._bindStream(u)}s.inherits(c,a),c.prototype._bindStream=function(l){var u=this;(this._stream=l).pause(),l.on("data",function(_){u.push({data:_,meta:{percent:0}})}).on("error",function(_){u.isPaused?this.generatedError=_:u.error(_)}).on("end",function(){u.isPaused?u._upstreamEnded=!0:u.end()})},c.prototype.pause=function(){return!!a.prototype.pause.call(this)&&(this._stream.pause(),!0)},c.prototype.resume=function(){return!!a.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},r.exports=c},{"../stream/GenericWorker":28,"../utils":32}],13:[function(o,r,i){var s=o("readable-stream").Readable;function a(c,l,u){s.call(this,l),this._helper=c;var _=this;c.on("data",function(d,m){_.push(d)||_._helper.pause(),u&&u(m)}).on("error",function(d){_.emit("error",d)}).on("end",function(){_.push(null)})}o("../utils").inherits(a,s),a.prototype._read=function(){this._helper.resume()},r.exports=a},{"../utils":32,"readable-stream":16}],14:[function(o,r,i){r.exports={isNode:typeof Buffer<"u",newBufferFrom:function(s,a){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(s,a);if(typeof s=="number")throw new Error('The "data" argument must not be a number');return new Buffer(s,a)},allocBuffer:function(s){if(Buffer.alloc)return Buffer.alloc(s);var a=new Buffer(s);return a.fill(0),a},isBuffer:function(s){return Buffer.isBuffer(s)},isStream:function(s){return s&&typeof s.on=="function"&&typeof s.pause=="function"&&typeof s.resume=="function"}}},{}],15:[function(o,r,i){function s(S,M,w){var A,D=c.getTypeOf(M),I=c.extend(w||{},_);I.date=I.date||new Date,I.compression!==null&&(I.compression=I.compression.toUpperCase()),typeof I.unixPermissions=="string"&&(I.unixPermissions=parseInt(I.unixPermissions,8)),I.unixPermissions&&16384&I.unixPermissions&&(I.dir=!0),I.dosPermissions&&16&I.dosPermissions&&(I.dir=!0),I.dir&&(S=g(S)),I.createFolders&&(A=f(S))&&y.call(this,A,!0);var H=D==="string"&&I.binary===!1&&I.base64===!1;w&&w.binary!==void 0||(I.binary=!H),(M instanceof d&&M.uncompressedSize===0||I.dir||!M||M.length===0)&&(I.base64=!1,I.binary=!0,M="",I.compression="STORE",D="string");var B=null;B=M instanceof d||M instanceof l?M:p.isNode&&p.isStream(M)?new x(S,M):c.prepareContent(S,M,I.binary,I.optimizedBinaryString,I.base64);var z=new m(S,B,I);this.files[S]=z}var a=o("./utf8"),c=o("./utils"),l=o("./stream/GenericWorker"),u=o("./stream/StreamHelper"),_=o("./defaults"),d=o("./compressedObject"),m=o("./zipObject"),h=o("./generate"),p=o("./nodejsUtils"),x=o("./nodejs/NodejsStreamInputAdapter"),f=function(S){S.slice(-1)==="/"&&(S=S.substring(0,S.length-1));var M=S.lastIndexOf("/");return 0<M?S.substring(0,M):""},g=function(S){return S.slice(-1)!=="/"&&(S+="/"),S},y=function(S,M){return M=M!==void 0?M:_.createFolders,S=g(S),this.files[S]||s.call(this,S,null,{dir:!0,createFolders:M}),this.files[S]};function b(S){return Object.prototype.toString.call(S)==="[object RegExp]"}var v={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(S){var M,w,A;for(M in this.files)A=this.files[M],(w=M.slice(this.root.length,M.length))&&M.slice(0,this.root.length)===this.root&&S(w,A)},filter:function(S){var M=[];return this.forEach(function(w,A){S(w,A)&&M.push(A)}),M},file:function(S,M,w){if(arguments.length!==1)return S=this.root+S,s.call(this,S,M,w),this;if(b(S)){var A=S;return this.filter(function(I,H){return!H.dir&&A.test(I)})}var D=this.files[this.root+S];return D&&!D.dir?D:null},folder:function(S){if(!S)return this;if(b(S))return this.filter(function(D,I){return I.dir&&S.test(D)});var M=this.root+S,w=y.call(this,M),A=this.clone();return A.root=w.name,A},remove:function(S){S=this.root+S;var M=this.files[S];if(M||(S.slice(-1)!=="/"&&(S+="/"),M=this.files[S]),M&&!M.dir)delete this.files[S];else for(var w=this.filter(function(D,I){return I.name.slice(0,S.length)===S}),A=0;A<w.length;A++)delete this.files[w[A].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(S){var M,w={};try{if((w=c.extend(S||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:a.utf8encode})).type=w.type.toLowerCase(),w.compression=w.compression.toUpperCase(),w.type==="binarystring"&&(w.type="string"),!w.type)throw new Error("No output type specified.");c.checkSupport(w.type),w.platform!=="darwin"&&w.platform!=="freebsd"&&w.platform!=="linux"&&w.platform!=="sunos"||(w.platform="UNIX"),w.platform==="win32"&&(w.platform="DOS");var A=w.comment||this.comment||"";M=h.generateWorker(this,w,A)}catch(D){(M=new l("error")).error(D)}return new u(M,w.type||"string",w.mimeType)},generateAsync:function(S,M){return this.generateInternalStream(S).accumulate(M)},generateNodeStream:function(S,M){return(S=S||{}).type||(S.type="nodebuffer"),this.generateInternalStream(S).toNodejsStream(M)}};r.exports=v},{"./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,r,i){r.exports=o("stream")},{stream:void 0}],17:[function(o,r,i){var s=o("./DataReader");function a(c){s.call(this,c);for(var l=0;l<this.data.length;l++)c[l]=255&c[l]}o("../utils").inherits(a,s),a.prototype.byteAt=function(c){return this.data[this.zero+c]},a.prototype.lastIndexOfSignature=function(c){for(var l=c.charCodeAt(0),u=c.charCodeAt(1),_=c.charCodeAt(2),d=c.charCodeAt(3),m=this.length-4;0<=m;--m)if(this.data[m]===l&&this.data[m+1]===u&&this.data[m+2]===_&&this.data[m+3]===d)return m-this.zero;return-1},a.prototype.readAndCheckSignature=function(c){var l=c.charCodeAt(0),u=c.charCodeAt(1),_=c.charCodeAt(2),d=c.charCodeAt(3),m=this.readData(4);return l===m[0]&&u===m[1]&&_===m[2]&&d===m[3]},a.prototype.readData=function(c){if(this.checkOffset(c),c===0)return[];var l=this.data.slice(this.zero+this.index,this.zero+this.index+c);return this.index+=c,l},r.exports=a},{"../utils":32,"./DataReader":18}],18:[function(o,r,i){var s=o("../utils");function a(c){this.data=c,this.length=c.length,this.index=0,this.zero=0}a.prototype={checkOffset:function(c){this.checkIndex(this.index+c)},checkIndex:function(c){if(this.length<this.zero+c||c<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+c+"). Corrupted zip ?")},setIndex:function(c){this.checkIndex(c),this.index=c},skip:function(c){this.setIndex(this.index+c)},byteAt:function(){},readInt:function(c){var l,u=0;for(this.checkOffset(c),l=this.index+c-1;l>=this.index;l--)u=(u<<8)+this.byteAt(l);return this.index+=c,u},readString:function(c){return s.transformTo("string",this.readData(c))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var c=this.readInt(4);return new Date(Date.UTC(1980+(c>>25&127),(c>>21&15)-1,c>>16&31,c>>11&31,c>>5&63,(31&c)<<1))}},r.exports=a},{"../utils":32}],19:[function(o,r,i){var s=o("./Uint8ArrayReader");function a(c){s.call(this,c)}o("../utils").inherits(a,s),a.prototype.readData=function(c){this.checkOffset(c);var l=this.data.slice(this.zero+this.index,this.zero+this.index+c);return this.index+=c,l},r.exports=a},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(o,r,i){var s=o("./DataReader");function a(c){s.call(this,c)}o("../utils").inherits(a,s),a.prototype.byteAt=function(c){return this.data.charCodeAt(this.zero+c)},a.prototype.lastIndexOfSignature=function(c){return this.data.lastIndexOf(c)-this.zero},a.prototype.readAndCheckSignature=function(c){return c===this.readData(4)},a.prototype.readData=function(c){this.checkOffset(c);var l=this.data.slice(this.zero+this.index,this.zero+this.index+c);return this.index+=c,l},r.exports=a},{"../utils":32,"./DataReader":18}],21:[function(o,r,i){var s=o("./ArrayReader");function a(c){s.call(this,c)}o("../utils").inherits(a,s),a.prototype.readData=function(c){if(this.checkOffset(c),c===0)return new Uint8Array(0);var l=this.data.subarray(this.zero+this.index,this.zero+this.index+c);return this.index+=c,l},r.exports=a},{"../utils":32,"./ArrayReader":17}],22:[function(o,r,i){var s=o("../utils"),a=o("../support"),c=o("./ArrayReader"),l=o("./StringReader"),u=o("./NodeBufferReader"),_=o("./Uint8ArrayReader");r.exports=function(d){var m=s.getTypeOf(d);return s.checkSupport(m),m!=="string"||a.uint8array?m==="nodebuffer"?new u(d):a.uint8array?new _(s.transformTo("uint8array",d)):new c(s.transformTo("array",d)):new l(d)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(o,r,i){i.LOCAL_FILE_HEADER="PK",i.CENTRAL_FILE_HEADER="PK",i.CENTRAL_DIRECTORY_END="PK",i.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",i.ZIP64_CENTRAL_DIRECTORY_END="PK",i.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(o,r,i){var s=o("./GenericWorker"),a=o("../utils");function c(l){s.call(this,"ConvertWorker to "+l),this.destType=l}a.inherits(c,s),c.prototype.processChunk=function(l){this.push({data:a.transformTo(this.destType,l.data),meta:l.meta})},r.exports=c},{"../utils":32,"./GenericWorker":28}],25:[function(o,r,i){var s=o("./GenericWorker"),a=o("../crc32");function c(){s.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}o("../utils").inherits(c,s),c.prototype.processChunk=function(l){this.streamInfo.crc32=a(l.data,this.streamInfo.crc32||0),this.push(l)},r.exports=c},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(o,r,i){var s=o("../utils"),a=o("./GenericWorker");function c(l){a.call(this,"DataLengthProbe for "+l),this.propName=l,this.withStreamInfo(l,0)}s.inherits(c,a),c.prototype.processChunk=function(l){if(l){var u=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=u+l.data.length}a.prototype.processChunk.call(this,l)},r.exports=c},{"../utils":32,"./GenericWorker":28}],27:[function(o,r,i){var s=o("../utils"),a=o("./GenericWorker");function c(l){a.call(this,"DataWorker");var u=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,l.then(function(_){u.dataIsReady=!0,u.data=_,u.max=_&&_.length||0,u.type=s.getTypeOf(_),u.isPaused||u._tickAndRepeat()},function(_){u.error(_)})}s.inherits(c,a),c.prototype.cleanUp=function(){a.prototype.cleanUp.call(this),this.data=null},c.prototype.resume=function(){return!!a.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,s.delay(this._tickAndRepeat,[],this)),!0)},c.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(s.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},c.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var l=null,u=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":l=this.data.substring(this.index,u);break;case"uint8array":l=this.data.subarray(this.index,u);break;case"array":case"nodebuffer":l=this.data.slice(this.index,u)}return this.index=u,this.push({data:l,meta:{percent:this.max?this.index/this.max*100:0}})},r.exports=c},{"../utils":32,"./GenericWorker":28}],28:[function(o,r,i){function s(a){this.name=a||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}s.prototype={push:function(a){this.emit("data",a)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(a){this.emit("error",a)}return!0},error:function(a){return!this.isFinished&&(this.isPaused?this.generatedError=a:(this.isFinished=!0,this.emit("error",a),this.previous&&this.previous.error(a),this.cleanUp()),!0)},on:function(a,c){return this._listeners[a].push(c),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(a,c){if(this._listeners[a])for(var l=0;l<this._listeners[a].length;l++)this._listeners[a][l].call(this,c)},pipe:function(a){return a.registerPrevious(this)},registerPrevious:function(a){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=a.streamInfo,this.mergeStreamInfo(),this.previous=a;var c=this;return a.on("data",function(l){c.processChunk(l)}),a.on("end",function(){c.end()}),a.on("error",function(l){c.error(l)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var a=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),a=!0),this.previous&&this.previous.resume(),!a},flush:function(){},processChunk:function(a){this.push(a)},withStreamInfo:function(a,c){return this.extraStreamInfo[a]=c,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var a in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,a)&&(this.streamInfo[a]=this.extraStreamInfo[a])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var a="Worker "+this.name;return this.previous?this.previous+" -> "+a:a}},r.exports=s},{}],29:[function(o,r,i){var s=o("../utils"),a=o("./ConvertWorker"),c=o("./GenericWorker"),l=o("../base64"),u=o("../support"),_=o("../external"),d=null;if(u.nodestream)try{d=o("../nodejs/NodejsStreamOutputAdapter")}catch{}function m(p,x){return new _.Promise(function(f,g){var y=[],b=p._internalType,v=p._outputType,S=p._mimeType;p.on("data",function(M,w){y.push(M),x&&x(w)}).on("error",function(M){y=[],g(M)}).on("end",function(){try{var M=(function(w,A,D){switch(w){case"blob":return s.newBlob(s.transformTo("arraybuffer",A),D);case"base64":return l.encode(A);default:return s.transformTo(w,A)}})(v,(function(w,A){var D,I=0,H=null,B=0;for(D=0;D<A.length;D++)B+=A[D].length;switch(w){case"string":return A.join("");case"array":return Array.prototype.concat.apply([],A);case"uint8array":for(H=new Uint8Array(B),D=0;D<A.length;D++)H.set(A[D],I),I+=A[D].length;return H;case"nodebuffer":return Buffer.concat(A);default:throw new Error("concat : unsupported type '"+w+"'")}})(b,y),S);f(M)}catch(w){g(w)}y=[]}).resume()})}function h(p,x,f){var g=x;switch(x){case"blob":case"arraybuffer":g="uint8array";break;case"base64":g="string"}try{this._internalType=g,this._outputType=x,this._mimeType=f,s.checkSupport(g),this._worker=p.pipe(new a(g)),p.lock()}catch(y){this._worker=new c("error"),this._worker.error(y)}}h.prototype={accumulate:function(p){return m(this,p)},on:function(p,x){var f=this;return p==="data"?this._worker.on(p,function(g){x.call(f,g.data,g.meta)}):this._worker.on(p,function(){s.delay(x,arguments,f)}),this},resume:function(){return s.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(p){if(s.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new d(this,{objectMode:this._outputType!=="nodebuffer"},p)}},r.exports=h},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(o,r,i){if(i.base64=!0,i.array=!0,i.string=!0,i.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",i.nodebuffer=typeof Buffer<"u",i.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")i.blob=!1;else{var s=new ArrayBuffer(0);try{i.blob=new Blob([s],{type:"application/zip"}).size===0}catch{try{var a=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);a.append(s),i.blob=a.getBlob("application/zip").size===0}catch{i.blob=!1}}}try{i.nodestream=!!o("readable-stream").Readable}catch{i.nodestream=!1}},{"readable-stream":16}],31:[function(o,r,i){for(var s=o("./utils"),a=o("./support"),c=o("./nodejsUtils"),l=o("./stream/GenericWorker"),u=new Array(256),_=0;_<256;_++)u[_]=252<=_?6:248<=_?5:240<=_?4:224<=_?3:192<=_?2:1;u[254]=u[254]=1;function d(){l.call(this,"utf-8 decode"),this.leftOver=null}function m(){l.call(this,"utf-8 encode")}i.utf8encode=function(h){return a.nodebuffer?c.newBufferFrom(h,"utf-8"):(function(p){var x,f,g,y,b,v=p.length,S=0;for(y=0;y<v;y++)(64512&(f=p.charCodeAt(y)))==55296&&y+1<v&&(64512&(g=p.charCodeAt(y+1)))==56320&&(f=65536+(f-55296<<10)+(g-56320),y++),S+=f<128?1:f<2048?2:f<65536?3:4;for(x=a.uint8array?new Uint8Array(S):new Array(S),y=b=0;b<S;y++)(64512&(f=p.charCodeAt(y)))==55296&&y+1<v&&(64512&(g=p.charCodeAt(y+1)))==56320&&(f=65536+(f-55296<<10)+(g-56320),y++),f<128?x[b++]=f:(f<2048?x[b++]=192|f>>>6:(f<65536?x[b++]=224|f>>>12:(x[b++]=240|f>>>18,x[b++]=128|f>>>12&63),x[b++]=128|f>>>6&63),x[b++]=128|63&f);return x})(h)},i.utf8decode=function(h){return a.nodebuffer?s.transformTo("nodebuffer",h).toString("utf-8"):(function(p){var x,f,g,y,b=p.length,v=new Array(2*b);for(x=f=0;x<b;)if((g=p[x++])<128)v[f++]=g;else if(4<(y=u[g]))v[f++]=65533,x+=y-1;else{for(g&=y===2?31:y===3?15:7;1<y&&x<b;)g=g<<6|63&p[x++],y--;1<y?v[f++]=65533:g<65536?v[f++]=g:(g-=65536,v[f++]=55296|g>>10&1023,v[f++]=56320|1023&g)}return v.length!==f&&(v.subarray?v=v.subarray(0,f):v.length=f),s.applyFromCharCode(v)})(h=s.transformTo(a.uint8array?"uint8array":"array",h))},s.inherits(d,l),d.prototype.processChunk=function(h){var p=s.transformTo(a.uint8array?"uint8array":"array",h.data);if(this.leftOver&&this.leftOver.length){if(a.uint8array){var x=p;(p=new Uint8Array(x.length+this.leftOver.length)).set(this.leftOver,0),p.set(x,this.leftOver.length)}else p=this.leftOver.concat(p);this.leftOver=null}var f=(function(y,b){var v;for((b=b||y.length)>y.length&&(b=y.length),v=b-1;0<=v&&(192&y[v])==128;)v--;return v<0||v===0?b:v+u[y[v]]>b?v:b})(p),g=p;f!==p.length&&(a.uint8array?(g=p.subarray(0,f),this.leftOver=p.subarray(f,p.length)):(g=p.slice(0,f),this.leftOver=p.slice(f,p.length))),this.push({data:i.utf8decode(g),meta:h.meta})},d.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:i.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},i.Utf8DecodeWorker=d,s.inherits(m,l),m.prototype.processChunk=function(h){this.push({data:i.utf8encode(h.data),meta:h.meta})},i.Utf8EncodeWorker=m},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(o,r,i){var s=o("./support"),a=o("./base64"),c=o("./nodejsUtils"),l=o("./external");function u(x){return x}function _(x,f){for(var g=0;g<x.length;++g)f[g]=255&x.charCodeAt(g);return f}o("setimmediate"),i.newBlob=function(x,f){i.checkSupport("blob");try{return new Blob([x],{type:f})}catch{try{var g=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return g.append(x),g.getBlob(f)}catch{throw new Error("Bug : can't construct the Blob.")}}};var d={stringifyByChunk:function(x,f,g){var y=[],b=0,v=x.length;if(v<=g)return String.fromCharCode.apply(null,x);for(;b<v;)f==="array"||f==="nodebuffer"?y.push(String.fromCharCode.apply(null,x.slice(b,Math.min(b+g,v)))):y.push(String.fromCharCode.apply(null,x.subarray(b,Math.min(b+g,v)))),b+=g;return y.join("")},stringifyByChar:function(x){for(var f="",g=0;g<x.length;g++)f+=String.fromCharCode(x[g]);return f},applyCanBeUsed:{uint8array:(function(){try{return s.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}})(),nodebuffer:(function(){try{return s.nodebuffer&&String.fromCharCode.apply(null,c.allocBuffer(1)).length===1}catch{return!1}})()}};function m(x){var f=65536,g=i.getTypeOf(x),y=!0;if(g==="uint8array"?y=d.applyCanBeUsed.uint8array:g==="nodebuffer"&&(y=d.applyCanBeUsed.nodebuffer),y)for(;1<f;)try{return d.stringifyByChunk(x,g,f)}catch{f=Math.floor(f/2)}return d.stringifyByChar(x)}function h(x,f){for(var g=0;g<x.length;g++)f[g]=x[g];return f}i.applyFromCharCode=m;var p={};p.string={string:u,array:function(x){return _(x,new Array(x.length))},arraybuffer:function(x){return p.string.uint8array(x).buffer},uint8array:function(x){return _(x,new Uint8Array(x.length))},nodebuffer:function(x){return _(x,c.allocBuffer(x.length))}},p.array={string:m,array:u,arraybuffer:function(x){return new Uint8Array(x).buffer},uint8array:function(x){return new Uint8Array(x)},nodebuffer:function(x){return c.newBufferFrom(x)}},p.arraybuffer={string:function(x){return m(new Uint8Array(x))},array:function(x){return h(new Uint8Array(x),new Array(x.byteLength))},arraybuffer:u,uint8array:function(x){return new Uint8Array(x)},nodebuffer:function(x){return c.newBufferFrom(new Uint8Array(x))}},p.uint8array={string:m,array:function(x){return h(x,new Array(x.length))},arraybuffer:function(x){return x.buffer},uint8array:u,nodebuffer:function(x){return c.newBufferFrom(x)}},p.nodebuffer={string:m,array:function(x){return h(x,new Array(x.length))},arraybuffer:function(x){return p.nodebuffer.uint8array(x).buffer},uint8array:function(x){return h(x,new Uint8Array(x.length))},nodebuffer:u},i.transformTo=function(x,f){if(f=f||"",!x)return f;i.checkSupport(x);var g=i.getTypeOf(f);return p[g][x](f)},i.resolve=function(x){for(var f=x.split("/"),g=[],y=0;y<f.length;y++){var b=f[y];b==="."||b===""&&y!==0&&y!==f.length-1||(b===".."?g.pop():g.push(b))}return g.join("/")},i.getTypeOf=function(x){return typeof x=="string"?"string":Object.prototype.toString.call(x)==="[object Array]"?"array":s.nodebuffer&&c.isBuffer(x)?"nodebuffer":s.uint8array&&x instanceof Uint8Array?"uint8array":s.arraybuffer&&x instanceof ArrayBuffer?"arraybuffer":void 0},i.checkSupport=function(x){if(!s[x.toLowerCase()])throw new Error(x+" is not supported by this platform")},i.MAX_VALUE_16BITS=65535,i.MAX_VALUE_32BITS=-1,i.pretty=function(x){var f,g,y="";for(g=0;g<(x||"").length;g++)y+="\\x"+((f=x.charCodeAt(g))<16?"0":"")+f.toString(16).toUpperCase();return y},i.delay=function(x,f,g){setImmediate(function(){x.apply(g||null,f||[])})},i.inherits=function(x,f){function g(){}g.prototype=f.prototype,x.prototype=new g},i.extend=function(){var x,f,g={};for(x=0;x<arguments.length;x++)for(f in arguments[x])Object.prototype.hasOwnProperty.call(arguments[x],f)&&g[f]===void 0&&(g[f]=arguments[x][f]);return g},i.prepareContent=function(x,f,g,y,b){return l.Promise.resolve(f).then(function(v){return s.blob&&(v instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(v))!==-1)&&typeof FileReader<"u"?new l.Promise(function(S,M){var w=new FileReader;w.onload=function(A){S(A.target.result)},w.onerror=function(A){M(A.target.error)},w.readAsArrayBuffer(v)}):v}).then(function(v){var S=i.getTypeOf(v);return S?(S==="arraybuffer"?v=i.transformTo("uint8array",v):S==="string"&&(b?v=a.decode(v):g&&y!==!0&&(v=(function(M){return _(M,s.uint8array?new Uint8Array(M.length):new Array(M.length))})(v))),v):l.Promise.reject(new Error("Can't read the data of '"+x+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(o,r,i){var s=o("./reader/readerFor"),a=o("./utils"),c=o("./signature"),l=o("./zipEntry"),u=o("./support");function _(d){this.files=[],this.loadOptions=d}_.prototype={checkSignature:function(d){if(!this.reader.readAndCheckSignature(d)){this.reader.index-=4;var m=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+a.pretty(m)+", expected "+a.pretty(d)+")")}},isSignature:function(d,m){var h=this.reader.index;this.reader.setIndex(d);var p=this.reader.readString(4)===m;return this.reader.setIndex(h),p},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var d=this.reader.readData(this.zipCommentLength),m=u.uint8array?"uint8array":"array",h=a.transformTo(m,d);this.zipComment=this.loadOptions.decodeFileName(h)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var d,m,h,p=this.zip64EndOfCentralSize-44;0<p;)d=this.reader.readInt(2),m=this.reader.readInt(4),h=this.reader.readData(m),this.zip64ExtensibleData[d]={id:d,length:m,value:h}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var d,m;for(d=0;d<this.files.length;d++)m=this.files[d],this.reader.setIndex(m.localHeaderOffset),this.checkSignature(c.LOCAL_FILE_HEADER),m.readLocalPart(this.reader),m.handleUTF8(),m.processAttributes()},readCentralDir:function(){var d;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(c.CENTRAL_FILE_HEADER);)(d=new l({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(d);if(this.centralDirRecords!==this.files.length&&this.centralDirRecords!==0&&this.files.length===0)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var d=this.reader.lastIndexOfSignature(c.CENTRAL_DIRECTORY_END);if(d<0)throw this.isSignature(0,c.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(d);var m=d;if(this.checkSignature(c.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===a.MAX_VALUE_16BITS||this.diskWithCentralDirStart===a.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===a.MAX_VALUE_16BITS||this.centralDirRecords===a.MAX_VALUE_16BITS||this.centralDirSize===a.MAX_VALUE_32BITS||this.centralDirOffset===a.MAX_VALUE_32BITS){if(this.zip64=!0,(d=this.reader.lastIndexOfSignature(c.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(d),this.checkSignature(c.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,c.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(c.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(c.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var h=this.centralDirOffset+this.centralDirSize;this.zip64&&(h+=20,h+=12+this.zip64EndOfCentralSize);var p=m-h;if(0<p)this.isSignature(m,c.CENTRAL_FILE_HEADER)||(this.reader.zero=p);else if(p<0)throw new Error("Corrupted zip: missing "+Math.abs(p)+" bytes.")},prepareReader:function(d){this.reader=s(d)},load:function(d){this.prepareReader(d),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},r.exports=_},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(o,r,i){var s=o("./reader/readerFor"),a=o("./utils"),c=o("./compressedObject"),l=o("./crc32"),u=o("./utf8"),_=o("./compressions"),d=o("./support");function m(h,p){this.options=h,this.loadOptions=p}m.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(h){var p,x;if(h.skip(22),this.fileNameLength=h.readInt(2),x=h.readInt(2),this.fileName=h.readData(this.fileNameLength),h.skip(x),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((p=(function(f){for(var g in _)if(Object.prototype.hasOwnProperty.call(_,g)&&_[g].magic===f)return _[g];return null})(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+a.pretty(this.compressionMethod)+" unknown (inner file : "+a.transformTo("string",this.fileName)+")");this.decompressed=new c(this.compressedSize,this.uncompressedSize,this.crc32,p,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 p=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(p),this.readExtraFields(h),this.parseZIP64ExtraField(h),this.fileComment=h.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var h=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),h==0&&(this.dosPermissions=63&this.externalFileAttributes),h==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var h=s(this.extraFields[1].value);this.uncompressedSize===a.MAX_VALUE_32BITS&&(this.uncompressedSize=h.readInt(8)),this.compressedSize===a.MAX_VALUE_32BITS&&(this.compressedSize=h.readInt(8)),this.localHeaderOffset===a.MAX_VALUE_32BITS&&(this.localHeaderOffset=h.readInt(8)),this.diskNumberStart===a.MAX_VALUE_32BITS&&(this.diskNumberStart=h.readInt(4))}},readExtraFields:function(h){var p,x,f,g=h.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});h.index+4<g;)p=h.readInt(2),x=h.readInt(2),f=h.readData(x),this.extraFields[p]={id:p,length:x,value:f};h.setIndex(g)},handleUTF8:function(){var h=d.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=u.utf8decode(this.fileName),this.fileCommentStr=u.utf8decode(this.fileComment);else{var p=this.findExtraFieldUnicodePath();if(p!==null)this.fileNameStr=p;else{var x=a.transformTo(h,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(x)}var f=this.findExtraFieldUnicodeComment();if(f!==null)this.fileCommentStr=f;else{var g=a.transformTo(h,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(g)}}},findExtraFieldUnicodePath:function(){var h=this.extraFields[28789];if(h){var p=s(h.value);return p.readInt(1)!==1||l(this.fileName)!==p.readInt(4)?null:u.utf8decode(p.readData(h.length-5))}return null},findExtraFieldUnicodeComment:function(){var h=this.extraFields[25461];if(h){var p=s(h.value);return p.readInt(1)!==1||l(this.fileComment)!==p.readInt(4)?null:u.utf8decode(p.readData(h.length-5))}return null}},r.exports=m},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(o,r,i){function s(p,x,f){this.name=p,this.dir=f.dir,this.date=f.date,this.comment=f.comment,this.unixPermissions=f.unixPermissions,this.dosPermissions=f.dosPermissions,this._data=x,this._dataBinary=f.binary,this.options={compression:f.compression,compressionOptions:f.compressionOptions}}var a=o("./stream/StreamHelper"),c=o("./stream/DataWorker"),l=o("./utf8"),u=o("./compressedObject"),_=o("./stream/GenericWorker");s.prototype={internalStream:function(p){var x=null,f="string";try{if(!p)throw new Error("No output type specified.");var g=(f=p.toLowerCase())==="string"||f==="text";f!=="binarystring"&&f!=="text"||(f="string"),x=this._decompressWorker();var y=!this._dataBinary;y&&!g&&(x=x.pipe(new l.Utf8EncodeWorker)),!y&&g&&(x=x.pipe(new l.Utf8DecodeWorker))}catch(b){(x=new _("error")).error(b)}return new a(x,f,"")},async:function(p,x){return this.internalStream(p).accumulate(x)},nodeStream:function(p,x){return this.internalStream(p||"nodebuffer").toNodejsStream(x)},_compressWorker:function(p,x){if(this._data instanceof u&&this._data.compression.magic===p.magic)return this._data.getCompressedWorker();var f=this._decompressWorker();return this._dataBinary||(f=f.pipe(new l.Utf8EncodeWorker)),u.createWorkerFrom(f,p,x)},_decompressWorker:function(){return this._data instanceof u?this._data.getContentWorker():this._data instanceof _?this._data:new c(this._data)}};for(var d=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],m=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},h=0;h<d.length;h++)s.prototype[d[h]]=m;r.exports=s},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(o,r,i){(function(s){var a,c,l=s.MutationObserver||s.WebKitMutationObserver;if(l){var u=0,_=new l(p),d=s.document.createTextNode("");_.observe(d,{characterData:!0}),a=function(){d.data=u=++u%2}}else if(s.setImmediate||s.MessageChannel===void 0)a="document"in s&&"onreadystatechange"in s.document.createElement("script")?function(){var x=s.document.createElement("script");x.onreadystatechange=function(){p(),x.onreadystatechange=null,x.parentNode.removeChild(x),x=null},s.document.documentElement.appendChild(x)}:function(){setTimeout(p,0)};else{var m=new s.MessageChannel;m.port1.onmessage=p,a=function(){m.port2.postMessage(0)}}var h=[];function p(){var x,f;c=!0;for(var g=h.length;g;){for(f=h,h=[],x=-1;++x<g;)f[x]();g=h.length}c=!1}r.exports=function(x){h.push(x)!==1||c||a()}}).call(this,typeof FI<"u"?FI:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(o,r,i){var s=o("immediate");function a(){}var c={},l=["REJECTED"],u=["FULFILLED"],_=["PENDING"];function d(g){if(typeof g!="function")throw new TypeError("resolver must be a function");this.state=_,this.queue=[],this.outcome=void 0,g!==a&&x(this,g)}function m(g,y,b){this.promise=g,typeof y=="function"&&(this.onFulfilled=y,this.callFulfilled=this.otherCallFulfilled),typeof b=="function"&&(this.onRejected=b,this.callRejected=this.otherCallRejected)}function h(g,y,b){s(function(){var v;try{v=y(b)}catch(S){return c.reject(g,S)}v===g?c.reject(g,new TypeError("Cannot resolve promise with itself")):c.resolve(g,v)})}function p(g){var y=g&&g.then;if(g&&(typeof g=="object"||typeof g=="function")&&typeof y=="function")return function(){y.apply(g,arguments)}}function x(g,y){var b=!1;function v(w){b||(b=!0,c.reject(g,w))}function S(w){b||(b=!0,c.resolve(g,w))}var M=f(function(){y(S,v)});M.status==="error"&&v(M.value)}function f(g,y){var b={};try{b.value=g(y),b.status="success"}catch(v){b.status="error",b.value=v}return b}(r.exports=d).prototype.finally=function(g){if(typeof g!="function")return this;var y=this.constructor;return this.then(function(b){return y.resolve(g()).then(function(){return b})},function(b){return y.resolve(g()).then(function(){throw b})})},d.prototype.catch=function(g){return this.then(null,g)},d.prototype.then=function(g,y){if(typeof g!="function"&&this.state===u||typeof y!="function"&&this.state===l)return this;var b=new this.constructor(a);return this.state!==_?h(b,this.state===u?g:y,this.outcome):this.queue.push(new m(b,g,y)),b},m.prototype.callFulfilled=function(g){c.resolve(this.promise,g)},m.prototype.otherCallFulfilled=function(g){h(this.promise,this.onFulfilled,g)},m.prototype.callRejected=function(g){c.reject(this.promise,g)},m.prototype.otherCallRejected=function(g){h(this.promise,this.onRejected,g)},c.resolve=function(g,y){var b=f(p,y);if(b.status==="error")return c.reject(g,b.value);var v=b.value;if(v)x(g,v);else{g.state=u,g.outcome=y;for(var S=-1,M=g.queue.length;++S<M;)g.queue[S].callFulfilled(y)}return g},c.reject=function(g,y){g.state=l,g.outcome=y;for(var b=-1,v=g.queue.length;++b<v;)g.queue[b].callRejected(y);return g},d.resolve=function(g){return g instanceof this?g:c.resolve(new this(a),g)},d.reject=function(g){var y=new this(a);return c.reject(y,g)},d.all=function(g){var y=this;if(Object.prototype.toString.call(g)!=="[object Array]")return this.reject(new TypeError("must be an array"));var b=g.length,v=!1;if(!b)return this.resolve([]);for(var S=new Array(b),M=0,w=-1,A=new this(a);++w<b;)D(g[w],w);return A;function D(I,H){y.resolve(I).then(function(B){S[H]=B,++M!==b||v||(v=!0,c.resolve(A,S))},function(B){v||(v=!0,c.reject(A,B))})}},d.race=function(g){var y=this;if(Object.prototype.toString.call(g)!=="[object Array]")return this.reject(new TypeError("must be an array"));var b=g.length,v=!1;if(!b)return this.resolve([]);for(var S=-1,M=new this(a);++S<b;)w=g[S],y.resolve(w).then(function(A){v||(v=!0,c.resolve(M,A))},function(A){v||(v=!0,c.reject(M,A))});var w;return M}},{immediate:36}],38:[function(o,r,i){var s={};(0,o("./lib/utils/common").assign)(s,o("./lib/deflate"),o("./lib/inflate"),o("./lib/zlib/constants")),r.exports=s},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(o,r,i){var s=o("./zlib/deflate"),a=o("./utils/common"),c=o("./utils/strings"),l=o("./zlib/messages"),u=o("./zlib/zstream"),_=Object.prototype.toString,d=0,m=-1,h=0,p=8;function x(g){if(!(this instanceof x))return new x(g);this.options=a.assign({level:m,method:p,chunkSize:16384,windowBits:15,memLevel:8,strategy:h,to:""},g||{});var y=this.options;y.raw&&0<y.windowBits?y.windowBits=-y.windowBits:y.gzip&&0<y.windowBits&&y.windowBits<16&&(y.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new u,this.strm.avail_out=0;var b=s.deflateInit2(this.strm,y.level,y.method,y.windowBits,y.memLevel,y.strategy);if(b!==d)throw new Error(l[b]);if(y.header&&s.deflateSetHeader(this.strm,y.header),y.dictionary){var v;if(v=typeof y.dictionary=="string"?c.string2buf(y.dictionary):_.call(y.dictionary)==="[object ArrayBuffer]"?new Uint8Array(y.dictionary):y.dictionary,(b=s.deflateSetDictionary(this.strm,v))!==d)throw new Error(l[b]);this._dict_set=!0}}function f(g,y){var b=new x(y);if(b.push(g,!0),b.err)throw b.msg||l[b.err];return b.result}x.prototype.push=function(g,y){var b,v,S=this.strm,M=this.options.chunkSize;if(this.ended)return!1;v=y===~~y?y:y===!0?4:0,typeof g=="string"?S.input=c.string2buf(g):_.call(g)==="[object ArrayBuffer]"?S.input=new Uint8Array(g):S.input=g,S.next_in=0,S.avail_in=S.input.length;do{if(S.avail_out===0&&(S.output=new a.Buf8(M),S.next_out=0,S.avail_out=M),(b=s.deflate(S,v))!==1&&b!==d)return this.onEnd(b),!(this.ended=!0);S.avail_out!==0&&(S.avail_in!==0||v!==4&&v!==2)||(this.options.to==="string"?this.onData(c.buf2binstring(a.shrinkBuf(S.output,S.next_out))):this.onData(a.shrinkBuf(S.output,S.next_out)))}while((0<S.avail_in||S.avail_out===0)&&b!==1);return v===4?(b=s.deflateEnd(this.strm),this.onEnd(b),this.ended=!0,b===d):v!==2||(this.onEnd(d),!(S.avail_out=0))},x.prototype.onData=function(g){this.chunks.push(g)},x.prototype.onEnd=function(g){g===d&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=a.flattenChunks(this.chunks)),this.chunks=[],this.err=g,this.msg=this.strm.msg},i.Deflate=x,i.deflate=f,i.deflateRaw=function(g,y){return(y=y||{}).raw=!0,f(g,y)},i.gzip=function(g,y){return(y=y||{}).gzip=!0,f(g,y)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(o,r,i){var s=o("./zlib/inflate"),a=o("./utils/common"),c=o("./utils/strings"),l=o("./zlib/constants"),u=o("./zlib/messages"),_=o("./zlib/zstream"),d=o("./zlib/gzheader"),m=Object.prototype.toString;function h(x){if(!(this instanceof h))return new h(x);this.options=a.assign({chunkSize:16384,windowBits:0,to:""},x||{});var f=this.options;f.raw&&0<=f.windowBits&&f.windowBits<16&&(f.windowBits=-f.windowBits,f.windowBits===0&&(f.windowBits=-15)),!(0<=f.windowBits&&f.windowBits<16)||x&&x.windowBits||(f.windowBits+=32),15<f.windowBits&&f.windowBits<48&&(15&f.windowBits)==0&&(f.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new _,this.strm.avail_out=0;var g=s.inflateInit2(this.strm,f.windowBits);if(g!==l.Z_OK)throw new Error(u[g]);this.header=new d,s.inflateGetHeader(this.strm,this.header)}function p(x,f){var g=new h(f);if(g.push(x,!0),g.err)throw g.msg||u[g.err];return g.result}h.prototype.push=function(x,f){var g,y,b,v,S,M,w=this.strm,A=this.options.chunkSize,D=this.options.dictionary,I=!1;if(this.ended)return!1;y=f===~~f?f:f===!0?l.Z_FINISH:l.Z_NO_FLUSH,typeof x=="string"?w.input=c.binstring2buf(x):m.call(x)==="[object ArrayBuffer]"?w.input=new Uint8Array(x):w.input=x,w.next_in=0,w.avail_in=w.input.length;do{if(w.avail_out===0&&(w.output=new a.Buf8(A),w.next_out=0,w.avail_out=A),(g=s.inflate(w,l.Z_NO_FLUSH))===l.Z_NEED_DICT&&D&&(M=typeof D=="string"?c.string2buf(D):m.call(D)==="[object ArrayBuffer]"?new Uint8Array(D):D,g=s.inflateSetDictionary(this.strm,M)),g===l.Z_BUF_ERROR&&I===!0&&(g=l.Z_OK,I=!1),g!==l.Z_STREAM_END&&g!==l.Z_OK)return this.onEnd(g),!(this.ended=!0);w.next_out&&(w.avail_out!==0&&g!==l.Z_STREAM_END&&(w.avail_in!==0||y!==l.Z_FINISH&&y!==l.Z_SYNC_FLUSH)||(this.options.to==="string"?(b=c.utf8border(w.output,w.next_out),v=w.next_out-b,S=c.buf2string(w.output,b),w.next_out=v,w.avail_out=A-v,v&&a.arraySet(w.output,w.output,b,v,0),this.onData(S)):this.onData(a.shrinkBuf(w.output,w.next_out)))),w.avail_in===0&&w.avail_out===0&&(I=!0)}while((0<w.avail_in||w.avail_out===0)&&g!==l.Z_STREAM_END);return g===l.Z_STREAM_END&&(y=l.Z_FINISH),y===l.Z_FINISH?(g=s.inflateEnd(this.strm),this.onEnd(g),this.ended=!0,g===l.Z_OK):y!==l.Z_SYNC_FLUSH||(this.onEnd(l.Z_OK),!(w.avail_out=0))},h.prototype.onData=function(x){this.chunks.push(x)},h.prototype.onEnd=function(x){x===l.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=a.flattenChunks(this.chunks)),this.chunks=[],this.err=x,this.msg=this.strm.msg},i.Inflate=h,i.inflate=p,i.inflateRaw=function(x,f){return(f=f||{}).raw=!0,p(x,f)},i.ungzip=p},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(o,r,i){var s=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";i.assign=function(l){for(var u=Array.prototype.slice.call(arguments,1);u.length;){var _=u.shift();if(_){if(typeof _!="object")throw new TypeError(_+"must be non-object");for(var d in _)_.hasOwnProperty(d)&&(l[d]=_[d])}}return l},i.shrinkBuf=function(l,u){return l.length===u?l:l.subarray?l.subarray(0,u):(l.length=u,l)};var a={arraySet:function(l,u,_,d,m){if(u.subarray&&l.subarray)l.set(u.subarray(_,_+d),m);else for(var h=0;h<d;h++)l[m+h]=u[_+h]},flattenChunks:function(l){var u,_,d,m,h,p;for(u=d=0,_=l.length;u<_;u++)d+=l[u].length;for(p=new Uint8Array(d),u=m=0,_=l.length;u<_;u++)h=l[u],p.set(h,m),m+=h.length;return p}},c={arraySet:function(l,u,_,d,m){for(var h=0;h<d;h++)l[m+h]=u[_+h]},flattenChunks:function(l){return[].concat.apply([],l)}};i.setTyped=function(l){l?(i.Buf8=Uint8Array,i.Buf16=Uint16Array,i.Buf32=Int32Array,i.assign(i,a)):(i.Buf8=Array,i.Buf16=Array,i.Buf32=Array,i.assign(i,c))},i.setTyped(s)},{}],42:[function(o,r,i){var s=o("./common"),a=!0,c=!0;try{String.fromCharCode.apply(null,[0])}catch{a=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{c=!1}for(var l=new s.Buf8(256),u=0;u<256;u++)l[u]=252<=u?6:248<=u?5:240<=u?4:224<=u?3:192<=u?2:1;function _(d,m){if(m<65537&&(d.subarray&&c||!d.subarray&&a))return String.fromCharCode.apply(null,s.shrinkBuf(d,m));for(var h="",p=0;p<m;p++)h+=String.fromCharCode(d[p]);return h}l[254]=l[254]=1,i.string2buf=function(d){var m,h,p,x,f,g=d.length,y=0;for(x=0;x<g;x++)(64512&(h=d.charCodeAt(x)))==55296&&x+1<g&&(64512&(p=d.charCodeAt(x+1)))==56320&&(h=65536+(h-55296<<10)+(p-56320),x++),y+=h<128?1:h<2048?2:h<65536?3:4;for(m=new s.Buf8(y),x=f=0;f<y;x++)(64512&(h=d.charCodeAt(x)))==55296&&x+1<g&&(64512&(p=d.charCodeAt(x+1)))==56320&&(h=65536+(h-55296<<10)+(p-56320),x++),h<128?m[f++]=h:(h<2048?m[f++]=192|h>>>6:(h<65536?m[f++]=224|h>>>12:(m[f++]=240|h>>>18,m[f++]=128|h>>>12&63),m[f++]=128|h>>>6&63),m[f++]=128|63&h);return m},i.buf2binstring=function(d){return _(d,d.length)},i.binstring2buf=function(d){for(var m=new s.Buf8(d.length),h=0,p=m.length;h<p;h++)m[h]=d.charCodeAt(h);return m},i.buf2string=function(d,m){var h,p,x,f,g=m||d.length,y=new Array(2*g);for(h=p=0;h<g;)if((x=d[h++])<128)y[p++]=x;else if(4<(f=l[x]))y[p++]=65533,h+=f-1;else{for(x&=f===2?31:f===3?15:7;1<f&&h<g;)x=x<<6|63&d[h++],f--;1<f?y[p++]=65533:x<65536?y[p++]=x:(x-=65536,y[p++]=55296|x>>10&1023,y[p++]=56320|1023&x)}return _(y,p)},i.utf8border=function(d,m){var h;for((m=m||d.length)>d.length&&(m=d.length),h=m-1;0<=h&&(192&d[h])==128;)h--;return h<0||h===0?m:h+l[d[h]]>m?h:m}},{"./common":41}],43:[function(o,r,i){r.exports=function(s,a,c,l){for(var u=65535&s|0,_=s>>>16&65535|0,d=0;c!==0;){for(c-=d=2e3<c?2e3:c;_=_+(u=u+a[l++]|0)|0,--d;);u%=65521,_%=65521}return u|_<<16|0}},{}],44:[function(o,r,i){r.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,r,i){var s=(function(){for(var a,c=[],l=0;l<256;l++){a=l;for(var u=0;u<8;u++)a=1&a?3988292384^a>>>1:a>>>1;c[l]=a}return c})();r.exports=function(a,c,l,u){var _=s,d=u+l;a^=-1;for(var m=u;m<d;m++)a=a>>>8^_[255&(a^c[m])];return-1^a}},{}],46:[function(o,r,i){var s,a=o("../utils/common"),c=o("./trees"),l=o("./adler32"),u=o("./crc32"),_=o("./messages"),d=0,m=4,h=0,p=-2,x=-1,f=4,g=2,y=8,b=9,v=286,S=30,M=19,w=2*v+1,A=15,D=3,I=258,H=I+D+1,B=42,z=113,V=1,j=2,Y=3,J=4;function ne(me,qe){return me.msg=_[qe],qe}function ae(me){return(me<<1)-(4<me?9:0)}function Z(me){for(var qe=me.length;0<=--qe;)me[qe]=0}function oe(me){var qe=me.state,Fe=qe.pending;Fe>me.avail_out&&(Fe=me.avail_out),Fe!==0&&(a.arraySet(me.output,qe.pending_buf,qe.pending_out,Fe,me.next_out),me.next_out+=Fe,qe.pending_out+=Fe,me.total_out+=Fe,me.avail_out-=Fe,qe.pending-=Fe,qe.pending===0&&(qe.pending_out=0))}function se(me,qe){c._tr_flush_block(me,0<=me.block_start?me.block_start:-1,me.strstart-me.block_start,qe),me.block_start=me.strstart,oe(me.strm)}function le(me,qe){me.pending_buf[me.pending++]=qe}function pe(me,qe){me.pending_buf[me.pending++]=qe>>>8&255,me.pending_buf[me.pending++]=255&qe}function Se(me,qe){var Fe,Ne,$e=me.max_chain_length,ke=me.strstart,ve=me.prev_length,Ee=me.nice_match,Te=me.strstart>me.w_size-H?me.strstart-(me.w_size-H):0,ze=me.window,Ue=me.w_mask,et=me.prev,ot=me.strstart+I,at=ze[ke+ve-1],lt=ze[ke+ve];me.prev_length>=me.good_match&&($e>>=2),Ee>me.lookahead&&(Ee=me.lookahead);do if(ze[(Fe=qe)+ve]===lt&&ze[Fe+ve-1]===at&&ze[Fe]===ze[ke]&&ze[++Fe]===ze[ke+1]){ke+=2,Fe++;do;while(ze[++ke]===ze[++Fe]&&ze[++ke]===ze[++Fe]&&ze[++ke]===ze[++Fe]&&ze[++ke]===ze[++Fe]&&ze[++ke]===ze[++Fe]&&ze[++ke]===ze[++Fe]&&ze[++ke]===ze[++Fe]&&ze[++ke]===ze[++Fe]&&ke<ot);if(Ne=I-(ot-ke),ke=ot-I,ve<Ne){if(me.match_start=qe,Ee<=(ve=Ne))break;at=ze[ke+ve-1],lt=ze[ke+ve]}}while((qe=et[qe&Ue])>Te&&--$e!=0);return ve<=me.lookahead?ve:me.lookahead}function we(me){var qe,Fe,Ne,$e,ke,ve,Ee,Te,ze,Ue,et=me.w_size;do{if($e=me.window_size-me.lookahead-me.strstart,me.strstart>=et+(et-H)){for(a.arraySet(me.window,me.window,et,et,0),me.match_start-=et,me.strstart-=et,me.block_start-=et,qe=Fe=me.hash_size;Ne=me.head[--qe],me.head[qe]=et<=Ne?Ne-et:0,--Fe;);for(qe=Fe=et;Ne=me.prev[--qe],me.prev[qe]=et<=Ne?Ne-et:0,--Fe;);$e+=et}if(me.strm.avail_in===0)break;if(ve=me.strm,Ee=me.window,Te=me.strstart+me.lookahead,ze=$e,Ue=void 0,Ue=ve.avail_in,ze<Ue&&(Ue=ze),Fe=Ue===0?0:(ve.avail_in-=Ue,a.arraySet(Ee,ve.input,ve.next_in,Ue,Te),ve.state.wrap===1?ve.adler=l(ve.adler,Ee,Ue,Te):ve.state.wrap===2&&(ve.adler=u(ve.adler,Ee,Ue,Te)),ve.next_in+=Ue,ve.total_in+=Ue,Ue),me.lookahead+=Fe,me.lookahead+me.insert>=D)for(ke=me.strstart-me.insert,me.ins_h=me.window[ke],me.ins_h=(me.ins_h<<me.hash_shift^me.window[ke+1])&me.hash_mask;me.insert&&(me.ins_h=(me.ins_h<<me.hash_shift^me.window[ke+D-1])&me.hash_mask,me.prev[ke&me.w_mask]=me.head[me.ins_h],me.head[me.ins_h]=ke,ke++,me.insert--,!(me.lookahead+me.insert<D)););}while(me.lookahead<H&&me.strm.avail_in!==0)}function De(me,qe){for(var Fe,Ne;;){if(me.lookahead<H){if(we(me),me.lookahead<H&&qe===d)return V;if(me.lookahead===0)break}if(Fe=0,me.lookahead>=D&&(me.ins_h=(me.ins_h<<me.hash_shift^me.window[me.strstart+D-1])&me.hash_mask,Fe=me.prev[me.strstart&me.w_mask]=me.head[me.ins_h],me.head[me.ins_h]=me.strstart),Fe!==0&&me.strstart-Fe<=me.w_size-H&&(me.match_length=Se(me,Fe)),me.match_length>=D)if(Ne=c._tr_tally(me,me.strstart-me.match_start,me.match_length-D),me.lookahead-=me.match_length,me.match_length<=me.max_lazy_match&&me.lookahead>=D){for(me.match_length--;me.strstart++,me.ins_h=(me.ins_h<<me.hash_shift^me.window[me.strstart+D-1])&me.hash_mask,Fe=me.prev[me.strstart&me.w_mask]=me.head[me.ins_h],me.head[me.ins_h]=me.strstart,--me.match_length!=0;);me.strstart++}else me.strstart+=me.match_length,me.match_length=0,me.ins_h=me.window[me.strstart],me.ins_h=(me.ins_h<<me.hash_shift^me.window[me.strstart+1])&me.hash_mask;else Ne=c._tr_tally(me,0,me.window[me.strstart]),me.lookahead--,me.strstart++;if(Ne&&(se(me,!1),me.strm.avail_out===0))return V}return me.insert=me.strstart<D-1?me.strstart:D-1,qe===m?(se(me,!0),me.strm.avail_out===0?Y:J):me.last_lit&&(se(me,!1),me.strm.avail_out===0)?V:j}function ge(me,qe){for(var Fe,Ne,$e;;){if(me.lookahead<H){if(we(me),me.lookahead<H&&qe===d)return V;if(me.lookahead===0)break}if(Fe=0,me.lookahead>=D&&(me.ins_h=(me.ins_h<<me.hash_shift^me.window[me.strstart+D-1])&me.hash_mask,Fe=me.prev[me.strstart&me.w_mask]=me.head[me.ins_h],me.head[me.ins_h]=me.strstart),me.prev_length=me.match_length,me.prev_match=me.match_start,me.match_length=D-1,Fe!==0&&me.prev_length<me.max_lazy_match&&me.strstart-Fe<=me.w_size-H&&(me.match_length=Se(me,Fe),me.match_length<=5&&(me.strategy===1||me.match_length===D&&4096<me.strstart-me.match_start)&&(me.match_length=D-1)),me.prev_length>=D&&me.match_length<=me.prev_length){for($e=me.strstart+me.lookahead-D,Ne=c._tr_tally(me,me.strstart-1-me.prev_match,me.prev_length-D),me.lookahead-=me.prev_length-1,me.prev_length-=2;++me.strstart<=$e&&(me.ins_h=(me.ins_h<<me.hash_shift^me.window[me.strstart+D-1])&me.hash_mask,Fe=me.prev[me.strstart&me.w_mask]=me.head[me.ins_h],me.head[me.ins_h]=me.strstart),--me.prev_length!=0;);if(me.match_available=0,me.match_length=D-1,me.strstart++,Ne&&(se(me,!1),me.strm.avail_out===0))return V}else if(me.match_available){if((Ne=c._tr_tally(me,0,me.window[me.strstart-1]))&&se(me,!1),me.strstart++,me.lookahead--,me.strm.avail_out===0)return V}else me.match_available=1,me.strstart++,me.lookahead--}return me.match_available&&(Ne=c._tr_tally(me,0,me.window[me.strstart-1]),me.match_available=0),me.insert=me.strstart<D-1?me.strstart:D-1,qe===m?(se(me,!0),me.strm.avail_out===0?Y:J):me.last_lit&&(se(me,!1),me.strm.avail_out===0)?V:j}function Me(me,qe,Fe,Ne,$e){this.good_length=me,this.max_lazy=qe,this.nice_length=Fe,this.max_chain=Ne,this.func=$e}function fe(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=y,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new a.Buf16(2*w),this.dyn_dtree=new a.Buf16(2*(2*S+1)),this.bl_tree=new a.Buf16(2*(2*M+1)),Z(this.dyn_ltree),Z(this.dyn_dtree),Z(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new a.Buf16(A+1),this.heap=new a.Buf16(2*v+1),Z(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new a.Buf16(2*v+1),Z(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 We(me){var qe;return me&&me.state?(me.total_in=me.total_out=0,me.data_type=g,(qe=me.state).pending=0,qe.pending_out=0,qe.wrap<0&&(qe.wrap=-qe.wrap),qe.status=qe.wrap?B:z,me.adler=qe.wrap===2?0:1,qe.last_flush=d,c._tr_init(qe),h):ne(me,p)}function je(me){var qe=We(me);return qe===h&&(function(Fe){Fe.window_size=2*Fe.w_size,Z(Fe.head),Fe.max_lazy_match=s[Fe.level].max_lazy,Fe.good_match=s[Fe.level].good_length,Fe.nice_match=s[Fe.level].nice_length,Fe.max_chain_length=s[Fe.level].max_chain,Fe.strstart=0,Fe.block_start=0,Fe.lookahead=0,Fe.insert=0,Fe.match_length=Fe.prev_length=D-1,Fe.match_available=0,Fe.ins_h=0})(me.state),qe}function Ke(me,qe,Fe,Ne,$e,ke){if(!me)return p;var ve=1;if(qe===x&&(qe=6),Ne<0?(ve=0,Ne=-Ne):15<Ne&&(ve=2,Ne-=16),$e<1||b<$e||Fe!==y||Ne<8||15<Ne||qe<0||9<qe||ke<0||f<ke)return ne(me,p);Ne===8&&(Ne=9);var Ee=new fe;return(me.state=Ee).strm=me,Ee.wrap=ve,Ee.gzhead=null,Ee.w_bits=Ne,Ee.w_size=1<<Ee.w_bits,Ee.w_mask=Ee.w_size-1,Ee.hash_bits=$e+7,Ee.hash_size=1<<Ee.hash_bits,Ee.hash_mask=Ee.hash_size-1,Ee.hash_shift=~~((Ee.hash_bits+D-1)/D),Ee.window=new a.Buf8(2*Ee.w_size),Ee.head=new a.Buf16(Ee.hash_size),Ee.prev=new a.Buf16(Ee.w_size),Ee.lit_bufsize=1<<$e+6,Ee.pending_buf_size=4*Ee.lit_bufsize,Ee.pending_buf=new a.Buf8(Ee.pending_buf_size),Ee.d_buf=1*Ee.lit_bufsize,Ee.l_buf=3*Ee.lit_bufsize,Ee.level=qe,Ee.strategy=ke,Ee.method=Fe,je(me)}s=[new Me(0,0,0,0,function(me,qe){var Fe=65535;for(Fe>me.pending_buf_size-5&&(Fe=me.pending_buf_size-5);;){if(me.lookahead<=1){if(we(me),me.lookahead===0&&qe===d)return V;if(me.lookahead===0)break}me.strstart+=me.lookahead,me.lookahead=0;var Ne=me.block_start+Fe;if((me.strstart===0||me.strstart>=Ne)&&(me.lookahead=me.strstart-Ne,me.strstart=Ne,se(me,!1),me.strm.avail_out===0)||me.strstart-me.block_start>=me.w_size-H&&(se(me,!1),me.strm.avail_out===0))return V}return me.insert=0,qe===m?(se(me,!0),me.strm.avail_out===0?Y:J):(me.strstart>me.block_start&&(se(me,!1),me.strm.avail_out),V)}),new Me(4,4,8,4,De),new Me(4,5,16,8,De),new Me(4,6,32,32,De),new Me(4,4,16,16,ge),new Me(8,16,32,32,ge),new Me(8,16,128,128,ge),new Me(8,32,128,256,ge),new Me(32,128,258,1024,ge),new Me(32,258,258,4096,ge)],i.deflateInit=function(me,qe){return Ke(me,qe,y,15,8,0)},i.deflateInit2=Ke,i.deflateReset=je,i.deflateResetKeep=We,i.deflateSetHeader=function(me,qe){return me&&me.state?me.state.wrap!==2?p:(me.state.gzhead=qe,h):p},i.deflate=function(me,qe){var Fe,Ne,$e,ke;if(!me||!me.state||5<qe||qe<0)return me?ne(me,p):p;if(Ne=me.state,!me.output||!me.input&&me.avail_in!==0||Ne.status===666&&qe!==m)return ne(me,me.avail_out===0?-5:p);if(Ne.strm=me,Fe=Ne.last_flush,Ne.last_flush=qe,Ne.status===B)if(Ne.wrap===2)me.adler=0,le(Ne,31),le(Ne,139),le(Ne,8),Ne.gzhead?(le(Ne,(Ne.gzhead.text?1:0)+(Ne.gzhead.hcrc?2:0)+(Ne.gzhead.extra?4:0)+(Ne.gzhead.name?8:0)+(Ne.gzhead.comment?16:0)),le(Ne,255&Ne.gzhead.time),le(Ne,Ne.gzhead.time>>8&255),le(Ne,Ne.gzhead.time>>16&255),le(Ne,Ne.gzhead.time>>24&255),le(Ne,Ne.level===9?2:2<=Ne.strategy||Ne.level<2?4:0),le(Ne,255&Ne.gzhead.os),Ne.gzhead.extra&&Ne.gzhead.extra.length&&(le(Ne,255&Ne.gzhead.extra.length),le(Ne,Ne.gzhead.extra.length>>8&255)),Ne.gzhead.hcrc&&(me.adler=u(me.adler,Ne.pending_buf,Ne.pending,0)),Ne.gzindex=0,Ne.status=69):(le(Ne,0),le(Ne,0),le(Ne,0),le(Ne,0),le(Ne,0),le(Ne,Ne.level===9?2:2<=Ne.strategy||Ne.level<2?4:0),le(Ne,3),Ne.status=z);else{var ve=y+(Ne.w_bits-8<<4)<<8;ve|=(2<=Ne.strategy||Ne.level<2?0:Ne.level<6?1:Ne.level===6?2:3)<<6,Ne.strstart!==0&&(ve|=32),ve+=31-ve%31,Ne.status=z,pe(Ne,ve),Ne.strstart!==0&&(pe(Ne,me.adler>>>16),pe(Ne,65535&me.adler)),me.adler=1}if(Ne.status===69)if(Ne.gzhead.extra){for($e=Ne.pending;Ne.gzindex<(65535&Ne.gzhead.extra.length)&&(Ne.pending!==Ne.pending_buf_size||(Ne.gzhead.hcrc&&Ne.pending>$e&&(me.adler=u(me.adler,Ne.pending_buf,Ne.pending-$e,$e)),oe(me),$e=Ne.pending,Ne.pending!==Ne.pending_buf_size));)le(Ne,255&Ne.gzhead.extra[Ne.gzindex]),Ne.gzindex++;Ne.gzhead.hcrc&&Ne.pending>$e&&(me.adler=u(me.adler,Ne.pending_buf,Ne.pending-$e,$e)),Ne.gzindex===Ne.gzhead.extra.length&&(Ne.gzindex=0,Ne.status=73)}else Ne.status=73;if(Ne.status===73)if(Ne.gzhead.name){$e=Ne.pending;do{if(Ne.pending===Ne.pending_buf_size&&(Ne.gzhead.hcrc&&Ne.pending>$e&&(me.adler=u(me.adler,Ne.pending_buf,Ne.pending-$e,$e)),oe(me),$e=Ne.pending,Ne.pending===Ne.pending_buf_size)){ke=1;break}ke=Ne.gzindex<Ne.gzhead.name.length?255&Ne.gzhead.name.charCodeAt(Ne.gzindex++):0,le(Ne,ke)}while(ke!==0);Ne.gzhead.hcrc&&Ne.pending>$e&&(me.adler=u(me.adler,Ne.pending_buf,Ne.pending-$e,$e)),ke===0&&(Ne.gzindex=0,Ne.status=91)}else Ne.status=91;if(Ne.status===91)if(Ne.gzhead.comment){$e=Ne.pending;do{if(Ne.pending===Ne.pending_buf_size&&(Ne.gzhead.hcrc&&Ne.pending>$e&&(me.adler=u(me.adler,Ne.pending_buf,Ne.pending-$e,$e)),oe(me),$e=Ne.pending,Ne.pending===Ne.pending_buf_size)){ke=1;break}ke=Ne.gzindex<Ne.gzhead.comment.length?255&Ne.gzhead.comment.charCodeAt(Ne.gzindex++):0,le(Ne,ke)}while(ke!==0);Ne.gzhead.hcrc&&Ne.pending>$e&&(me.adler=u(me.adler,Ne.pending_buf,Ne.pending-$e,$e)),ke===0&&(Ne.status=103)}else Ne.status=103;if(Ne.status===103&&(Ne.gzhead.hcrc?(Ne.pending+2>Ne.pending_buf_size&&oe(me),Ne.pending+2<=Ne.pending_buf_size&&(le(Ne,255&me.adler),le(Ne,me.adler>>8&255),me.adler=0,Ne.status=z)):Ne.status=z),Ne.pending!==0){if(oe(me),me.avail_out===0)return Ne.last_flush=-1,h}else if(me.avail_in===0&&ae(qe)<=ae(Fe)&&qe!==m)return ne(me,-5);if(Ne.status===666&&me.avail_in!==0)return ne(me,-5);if(me.avail_in!==0||Ne.lookahead!==0||qe!==d&&Ne.status!==666){var Ee=Ne.strategy===2?(function(Te,ze){for(var Ue;;){if(Te.lookahead===0&&(we(Te),Te.lookahead===0)){if(ze===d)return V;break}if(Te.match_length=0,Ue=c._tr_tally(Te,0,Te.window[Te.strstart]),Te.lookahead--,Te.strstart++,Ue&&(se(Te,!1),Te.strm.avail_out===0))return V}return Te.insert=0,ze===m?(se(Te,!0),Te.strm.avail_out===0?Y:J):Te.last_lit&&(se(Te,!1),Te.strm.avail_out===0)?V:j})(Ne,qe):Ne.strategy===3?(function(Te,ze){for(var Ue,et,ot,at,lt=Te.window;;){if(Te.lookahead<=I){if(we(Te),Te.lookahead<=I&&ze===d)return V;if(Te.lookahead===0)break}if(Te.match_length=0,Te.lookahead>=D&&0<Te.strstart&&(et=lt[ot=Te.strstart-1])===lt[++ot]&&et===lt[++ot]&&et===lt[++ot]){at=Te.strstart+I;do;while(et===lt[++ot]&&et===lt[++ot]&&et===lt[++ot]&&et===lt[++ot]&&et===lt[++ot]&&et===lt[++ot]&&et===lt[++ot]&&et===lt[++ot]&&ot<at);Te.match_length=I-(at-ot),Te.match_length>Te.lookahead&&(Te.match_length=Te.lookahead)}if(Te.match_length>=D?(Ue=c._tr_tally(Te,1,Te.match_length-D),Te.lookahead-=Te.match_length,Te.strstart+=Te.match_length,Te.match_length=0):(Ue=c._tr_tally(Te,0,Te.window[Te.strstart]),Te.lookahead--,Te.strstart++),Ue&&(se(Te,!1),Te.strm.avail_out===0))return V}return Te.insert=0,ze===m?(se(Te,!0),Te.strm.avail_out===0?Y:J):Te.last_lit&&(se(Te,!1),Te.strm.avail_out===0)?V:j})(Ne,qe):s[Ne.level].func(Ne,qe);if(Ee!==Y&&Ee!==J||(Ne.status=666),Ee===V||Ee===Y)return me.avail_out===0&&(Ne.last_flush=-1),h;if(Ee===j&&(qe===1?c._tr_align(Ne):qe!==5&&(c._tr_stored_block(Ne,0,0,!1),qe===3&&(Z(Ne.head),Ne.lookahead===0&&(Ne.strstart=0,Ne.block_start=0,Ne.insert=0))),oe(me),me.avail_out===0))return Ne.last_flush=-1,h}return qe!==m?h:Ne.wrap<=0?1:(Ne.wrap===2?(le(Ne,255&me.adler),le(Ne,me.adler>>8&255),le(Ne,me.adler>>16&255),le(Ne,me.adler>>24&255),le(Ne,255&me.total_in),le(Ne,me.total_in>>8&255),le(Ne,me.total_in>>16&255),le(Ne,me.total_in>>24&255)):(pe(Ne,me.adler>>>16),pe(Ne,65535&me.adler)),oe(me),0<Ne.wrap&&(Ne.wrap=-Ne.wrap),Ne.pending!==0?h:1)},i.deflateEnd=function(me){var qe;return me&&me.state?(qe=me.state.status)!==B&&qe!==69&&qe!==73&&qe!==91&&qe!==103&&qe!==z&&qe!==666?ne(me,p):(me.state=null,qe===z?ne(me,-3):h):p},i.deflateSetDictionary=function(me,qe){var Fe,Ne,$e,ke,ve,Ee,Te,ze,Ue=qe.length;if(!me||!me.state||(ke=(Fe=me.state).wrap)===2||ke===1&&Fe.status!==B||Fe.lookahead)return p;for(ke===1&&(me.adler=l(me.adler,qe,Ue,0)),Fe.wrap=0,Ue>=Fe.w_size&&(ke===0&&(Z(Fe.head),Fe.strstart=0,Fe.block_start=0,Fe.insert=0),ze=new a.Buf8(Fe.w_size),a.arraySet(ze,qe,Ue-Fe.w_size,Fe.w_size,0),qe=ze,Ue=Fe.w_size),ve=me.avail_in,Ee=me.next_in,Te=me.input,me.avail_in=Ue,me.next_in=0,me.input=qe,we(Fe);Fe.lookahead>=D;){for(Ne=Fe.strstart,$e=Fe.lookahead-(D-1);Fe.ins_h=(Fe.ins_h<<Fe.hash_shift^Fe.window[Ne+D-1])&Fe.hash_mask,Fe.prev[Ne&Fe.w_mask]=Fe.head[Fe.ins_h],Fe.head[Fe.ins_h]=Ne,Ne++,--$e;);Fe.strstart=Ne,Fe.lookahead=D-1,we(Fe)}return Fe.strstart+=Fe.lookahead,Fe.block_start=Fe.strstart,Fe.insert=Fe.lookahead,Fe.lookahead=0,Fe.match_length=Fe.prev_length=D-1,Fe.match_available=0,me.next_in=Ee,me.input=Te,me.avail_in=ve,Fe.wrap=ke,h},i.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(o,r,i){r.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,r,i){r.exports=function(s,a){var c,l,u,_,d,m,h,p,x,f,g,y,b,v,S,M,w,A,D,I,H,B,z,V,j;c=s.state,l=s.next_in,V=s.input,u=l+(s.avail_in-5),_=s.next_out,j=s.output,d=_-(a-s.avail_out),m=_+(s.avail_out-257),h=c.dmax,p=c.wsize,x=c.whave,f=c.wnext,g=c.window,y=c.hold,b=c.bits,v=c.lencode,S=c.distcode,M=(1<<c.lenbits)-1,w=(1<<c.distbits)-1;e:do{b<15&&(y+=V[l++]<<b,b+=8,y+=V[l++]<<b,b+=8),A=v[y&M];t:for(;;){if(y>>>=D=A>>>24,b-=D,(D=A>>>16&255)===0)j[_++]=65535&A;else{if(!(16&D)){if((64&D)==0){A=v[(65535&A)+(y&(1<<D)-1)];continue t}if(32&D){c.mode=12;break e}s.msg="invalid literal/length code",c.mode=30;break e}I=65535&A,(D&=15)&&(b<D&&(y+=V[l++]<<b,b+=8),I+=y&(1<<D)-1,y>>>=D,b-=D),b<15&&(y+=V[l++]<<b,b+=8,y+=V[l++]<<b,b+=8),A=S[y&w];n:for(;;){if(y>>>=D=A>>>24,b-=D,!(16&(D=A>>>16&255))){if((64&D)==0){A=S[(65535&A)+(y&(1<<D)-1)];continue n}s.msg="invalid distance code",c.mode=30;break e}if(H=65535&A,b<(D&=15)&&(y+=V[l++]<<b,(b+=8)<D&&(y+=V[l++]<<b,b+=8)),h<(H+=y&(1<<D)-1)){s.msg="invalid distance too far back",c.mode=30;break e}if(y>>>=D,b-=D,(D=_-d)<H){if(x<(D=H-D)&&c.sane){s.msg="invalid distance too far back",c.mode=30;break e}if(z=g,(B=0)===f){if(B+=p-D,D<I){for(I-=D;j[_++]=g[B++],--D;);B=_-H,z=j}}else if(f<D){if(B+=p+f-D,(D-=f)<I){for(I-=D;j[_++]=g[B++],--D;);if(B=0,f<I){for(I-=D=f;j[_++]=g[B++],--D;);B=_-H,z=j}}}else if(B+=f-D,D<I){for(I-=D;j[_++]=g[B++],--D;);B=_-H,z=j}for(;2<I;)j[_++]=z[B++],j[_++]=z[B++],j[_++]=z[B++],I-=3;I&&(j[_++]=z[B++],1<I&&(j[_++]=z[B++]))}else{for(B=_-H;j[_++]=j[B++],j[_++]=j[B++],j[_++]=j[B++],2<(I-=3););I&&(j[_++]=j[B++],1<I&&(j[_++]=j[B++]))}break}}break}}while(l<u&&_<m);l-=I=b>>3,y&=(1<<(b-=I<<3))-1,s.next_in=l,s.next_out=_,s.avail_in=l<u?u-l+5:5-(l-u),s.avail_out=_<m?m-_+257:257-(_-m),c.hold=y,c.bits=b}},{}],49:[function(o,r,i){var s=o("../utils/common"),a=o("./adler32"),c=o("./crc32"),l=o("./inffast"),u=o("./inftrees"),_=1,d=2,m=0,h=-2,p=1,x=852,f=592;function g(B){return(B>>>24&255)+(B>>>8&65280)+((65280&B)<<8)+((255&B)<<24)}function y(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new s.Buf16(320),this.work=new s.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function b(B){var z;return B&&B.state?(z=B.state,B.total_in=B.total_out=z.total=0,B.msg="",z.wrap&&(B.adler=1&z.wrap),z.mode=p,z.last=0,z.havedict=0,z.dmax=32768,z.head=null,z.hold=0,z.bits=0,z.lencode=z.lendyn=new s.Buf32(x),z.distcode=z.distdyn=new s.Buf32(f),z.sane=1,z.back=-1,m):h}function v(B){var z;return B&&B.state?((z=B.state).wsize=0,z.whave=0,z.wnext=0,b(B)):h}function S(B,z){var V,j;return B&&B.state?(j=B.state,z<0?(V=0,z=-z):(V=1+(z>>4),z<48&&(z&=15)),z&&(z<8||15<z)?h:(j.window!==null&&j.wbits!==z&&(j.window=null),j.wrap=V,j.wbits=z,v(B))):h}function M(B,z){var V,j;return B?(j=new y,(B.state=j).window=null,(V=S(B,z))!==m&&(B.state=null),V):h}var w,A,D=!0;function I(B){if(D){var z;for(w=new s.Buf32(512),A=new s.Buf32(32),z=0;z<144;)B.lens[z++]=8;for(;z<256;)B.lens[z++]=9;for(;z<280;)B.lens[z++]=7;for(;z<288;)B.lens[z++]=8;for(u(_,B.lens,0,288,w,0,B.work,{bits:9}),z=0;z<32;)B.lens[z++]=5;u(d,B.lens,0,32,A,0,B.work,{bits:5}),D=!1}B.lencode=w,B.lenbits=9,B.distcode=A,B.distbits=5}function H(B,z,V,j){var Y,J=B.state;return J.window===null&&(J.wsize=1<<J.wbits,J.wnext=0,J.whave=0,J.window=new s.Buf8(J.wsize)),j>=J.wsize?(s.arraySet(J.window,z,V-J.wsize,J.wsize,0),J.wnext=0,J.whave=J.wsize):(j<(Y=J.wsize-J.wnext)&&(Y=j),s.arraySet(J.window,z,V-j,Y,J.wnext),(j-=Y)?(s.arraySet(J.window,z,V-j,j,0),J.wnext=j,J.whave=J.wsize):(J.wnext+=Y,J.wnext===J.wsize&&(J.wnext=0),J.whave<J.wsize&&(J.whave+=Y))),0}i.inflateReset=v,i.inflateReset2=S,i.inflateResetKeep=b,i.inflateInit=function(B){return M(B,15)},i.inflateInit2=M,i.inflate=function(B,z){var V,j,Y,J,ne,ae,Z,oe,se,le,pe,Se,we,De,ge,Me,fe,We,je,Ke,me,qe,Fe,Ne,$e=0,ke=new s.Buf8(4),ve=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!B||!B.state||!B.output||!B.input&&B.avail_in!==0)return h;(V=B.state).mode===12&&(V.mode=13),ne=B.next_out,Y=B.output,Z=B.avail_out,J=B.next_in,j=B.input,ae=B.avail_in,oe=V.hold,se=V.bits,le=ae,pe=Z,qe=m;e:for(;;)switch(V.mode){case p:if(V.wrap===0){V.mode=13;break}for(;se<16;){if(ae===0)break e;ae--,oe+=j[J++]<<se,se+=8}if(2&V.wrap&&oe===35615){ke[V.check=0]=255&oe,ke[1]=oe>>>8&255,V.check=c(V.check,ke,2,0),se=oe=0,V.mode=2;break}if(V.flags=0,V.head&&(V.head.done=!1),!(1&V.wrap)||(((255&oe)<<8)+(oe>>8))%31){B.msg="incorrect header check",V.mode=30;break}if((15&oe)!=8){B.msg="unknown compression method",V.mode=30;break}if(se-=4,me=8+(15&(oe>>>=4)),V.wbits===0)V.wbits=me;else if(me>V.wbits){B.msg="invalid window size",V.mode=30;break}V.dmax=1<<me,B.adler=V.check=1,V.mode=512&oe?10:12,se=oe=0;break;case 2:for(;se<16;){if(ae===0)break e;ae--,oe+=j[J++]<<se,se+=8}if(V.flags=oe,(255&V.flags)!=8){B.msg="unknown compression method",V.mode=30;break}if(57344&V.flags){B.msg="unknown header flags set",V.mode=30;break}V.head&&(V.head.text=oe>>8&1),512&V.flags&&(ke[0]=255&oe,ke[1]=oe>>>8&255,V.check=c(V.check,ke,2,0)),se=oe=0,V.mode=3;case 3:for(;se<32;){if(ae===0)break e;ae--,oe+=j[J++]<<se,se+=8}V.head&&(V.head.time=oe),512&V.flags&&(ke[0]=255&oe,ke[1]=oe>>>8&255,ke[2]=oe>>>16&255,ke[3]=oe>>>24&255,V.check=c(V.check,ke,4,0)),se=oe=0,V.mode=4;case 4:for(;se<16;){if(ae===0)break e;ae--,oe+=j[J++]<<se,se+=8}V.head&&(V.head.xflags=255&oe,V.head.os=oe>>8),512&V.flags&&(ke[0]=255&oe,ke[1]=oe>>>8&255,V.check=c(V.check,ke,2,0)),se=oe=0,V.mode=5;case 5:if(1024&V.flags){for(;se<16;){if(ae===0)break e;ae--,oe+=j[J++]<<se,se+=8}V.length=oe,V.head&&(V.head.extra_len=oe),512&V.flags&&(ke[0]=255&oe,ke[1]=oe>>>8&255,V.check=c(V.check,ke,2,0)),se=oe=0}else V.head&&(V.head.extra=null);V.mode=6;case 6:if(1024&V.flags&&(ae<(Se=V.length)&&(Se=ae),Se&&(V.head&&(me=V.head.extra_len-V.length,V.head.extra||(V.head.extra=new Array(V.head.extra_len)),s.arraySet(V.head.extra,j,J,Se,me)),512&V.flags&&(V.check=c(V.check,j,Se,J)),ae-=Se,J+=Se,V.length-=Se),V.length))break e;V.length=0,V.mode=7;case 7:if(2048&V.flags){if(ae===0)break e;for(Se=0;me=j[J+Se++],V.head&&me&&V.length<65536&&(V.head.name+=String.fromCharCode(me)),me&&Se<ae;);if(512&V.flags&&(V.check=c(V.check,j,Se,J)),ae-=Se,J+=Se,me)break e}else V.head&&(V.head.name=null);V.length=0,V.mode=8;case 8:if(4096&V.flags){if(ae===0)break e;for(Se=0;me=j[J+Se++],V.head&&me&&V.length<65536&&(V.head.comment+=String.fromCharCode(me)),me&&Se<ae;);if(512&V.flags&&(V.check=c(V.check,j,Se,J)),ae-=Se,J+=Se,me)break e}else V.head&&(V.head.comment=null);V.mode=9;case 9:if(512&V.flags){for(;se<16;){if(ae===0)break e;ae--,oe+=j[J++]<<se,se+=8}if(oe!==(65535&V.check)){B.msg="header crc mismatch",V.mode=30;break}se=oe=0}V.head&&(V.head.hcrc=V.flags>>9&1,V.head.done=!0),B.adler=V.check=0,V.mode=12;break;case 10:for(;se<32;){if(ae===0)break e;ae--,oe+=j[J++]<<se,se+=8}B.adler=V.check=g(oe),se=oe=0,V.mode=11;case 11:if(V.havedict===0)return B.next_out=ne,B.avail_out=Z,B.next_in=J,B.avail_in=ae,V.hold=oe,V.bits=se,2;B.adler=V.check=1,V.mode=12;case 12:if(z===5||z===6)break e;case 13:if(V.last){oe>>>=7&se,se-=7&se,V.mode=27;break}for(;se<3;){if(ae===0)break e;ae--,oe+=j[J++]<<se,se+=8}switch(V.last=1&oe,se-=1,3&(oe>>>=1)){case 0:V.mode=14;break;case 1:if(I(V),V.mode=20,z!==6)break;oe>>>=2,se-=2;break e;case 2:V.mode=17;break;case 3:B.msg="invalid block type",V.mode=30}oe>>>=2,se-=2;break;case 14:for(oe>>>=7&se,se-=7&se;se<32;){if(ae===0)break e;ae--,oe+=j[J++]<<se,se+=8}if((65535&oe)!=(oe>>>16^65535)){B.msg="invalid stored block lengths",V.mode=30;break}if(V.length=65535&oe,se=oe=0,V.mode=15,z===6)break e;case 15:V.mode=16;case 16:if(Se=V.length){if(ae<Se&&(Se=ae),Z<Se&&(Se=Z),Se===0)break e;s.arraySet(Y,j,J,Se,ne),ae-=Se,J+=Se,Z-=Se,ne+=Se,V.length-=Se;break}V.mode=12;break;case 17:for(;se<14;){if(ae===0)break e;ae--,oe+=j[J++]<<se,se+=8}if(V.nlen=257+(31&oe),oe>>>=5,se-=5,V.ndist=1+(31&oe),oe>>>=5,se-=5,V.ncode=4+(15&oe),oe>>>=4,se-=4,286<V.nlen||30<V.ndist){B.msg="too many length or distance symbols",V.mode=30;break}V.have=0,V.mode=18;case 18:for(;V.have<V.ncode;){for(;se<3;){if(ae===0)break e;ae--,oe+=j[J++]<<se,se+=8}V.lens[ve[V.have++]]=7&oe,oe>>>=3,se-=3}for(;V.have<19;)V.lens[ve[V.have++]]=0;if(V.lencode=V.lendyn,V.lenbits=7,Fe={bits:V.lenbits},qe=u(0,V.lens,0,19,V.lencode,0,V.work,Fe),V.lenbits=Fe.bits,qe){B.msg="invalid code lengths set",V.mode=30;break}V.have=0,V.mode=19;case 19:for(;V.have<V.nlen+V.ndist;){for(;Me=($e=V.lencode[oe&(1<<V.lenbits)-1])>>>16&255,fe=65535&$e,!((ge=$e>>>24)<=se);){if(ae===0)break e;ae--,oe+=j[J++]<<se,se+=8}if(fe<16)oe>>>=ge,se-=ge,V.lens[V.have++]=fe;else{if(fe===16){for(Ne=ge+2;se<Ne;){if(ae===0)break e;ae--,oe+=j[J++]<<se,se+=8}if(oe>>>=ge,se-=ge,V.have===0){B.msg="invalid bit length repeat",V.mode=30;break}me=V.lens[V.have-1],Se=3+(3&oe),oe>>>=2,se-=2}else if(fe===17){for(Ne=ge+3;se<Ne;){if(ae===0)break e;ae--,oe+=j[J++]<<se,se+=8}se-=ge,me=0,Se=3+(7&(oe>>>=ge)),oe>>>=3,se-=3}else{for(Ne=ge+7;se<Ne;){if(ae===0)break e;ae--,oe+=j[J++]<<se,se+=8}se-=ge,me=0,Se=11+(127&(oe>>>=ge)),oe>>>=7,se-=7}if(V.have+Se>V.nlen+V.ndist){B.msg="invalid bit length repeat",V.mode=30;break}for(;Se--;)V.lens[V.have++]=me}}if(V.mode===30)break;if(V.lens[256]===0){B.msg="invalid code -- missing end-of-block",V.mode=30;break}if(V.lenbits=9,Fe={bits:V.lenbits},qe=u(_,V.lens,0,V.nlen,V.lencode,0,V.work,Fe),V.lenbits=Fe.bits,qe){B.msg="invalid literal/lengths set",V.mode=30;break}if(V.distbits=6,V.distcode=V.distdyn,Fe={bits:V.distbits},qe=u(d,V.lens,V.nlen,V.ndist,V.distcode,0,V.work,Fe),V.distbits=Fe.bits,qe){B.msg="invalid distances set",V.mode=30;break}if(V.mode=20,z===6)break e;case 20:V.mode=21;case 21:if(6<=ae&&258<=Z){B.next_out=ne,B.avail_out=Z,B.next_in=J,B.avail_in=ae,V.hold=oe,V.bits=se,l(B,pe),ne=B.next_out,Y=B.output,Z=B.avail_out,J=B.next_in,j=B.input,ae=B.avail_in,oe=V.hold,se=V.bits,V.mode===12&&(V.back=-1);break}for(V.back=0;Me=($e=V.lencode[oe&(1<<V.lenbits)-1])>>>16&255,fe=65535&$e,!((ge=$e>>>24)<=se);){if(ae===0)break e;ae--,oe+=j[J++]<<se,se+=8}if(Me&&(240&Me)==0){for(We=ge,je=Me,Ke=fe;Me=($e=V.lencode[Ke+((oe&(1<<We+je)-1)>>We)])>>>16&255,fe=65535&$e,!(We+(ge=$e>>>24)<=se);){if(ae===0)break e;ae--,oe+=j[J++]<<se,se+=8}oe>>>=We,se-=We,V.back+=We}if(oe>>>=ge,se-=ge,V.back+=ge,V.length=fe,Me===0){V.mode=26;break}if(32&Me){V.back=-1,V.mode=12;break}if(64&Me){B.msg="invalid literal/length code",V.mode=30;break}V.extra=15&Me,V.mode=22;case 22:if(V.extra){for(Ne=V.extra;se<Ne;){if(ae===0)break e;ae--,oe+=j[J++]<<se,se+=8}V.length+=oe&(1<<V.extra)-1,oe>>>=V.extra,se-=V.extra,V.back+=V.extra}V.was=V.length,V.mode=23;case 23:for(;Me=($e=V.distcode[oe&(1<<V.distbits)-1])>>>16&255,fe=65535&$e,!((ge=$e>>>24)<=se);){if(ae===0)break e;ae--,oe+=j[J++]<<se,se+=8}if((240&Me)==0){for(We=ge,je=Me,Ke=fe;Me=($e=V.distcode[Ke+((oe&(1<<We+je)-1)>>We)])>>>16&255,fe=65535&$e,!(We+(ge=$e>>>24)<=se);){if(ae===0)break e;ae--,oe+=j[J++]<<se,se+=8}oe>>>=We,se-=We,V.back+=We}if(oe>>>=ge,se-=ge,V.back+=ge,64&Me){B.msg="invalid distance code",V.mode=30;break}V.offset=fe,V.extra=15&Me,V.mode=24;case 24:if(V.extra){for(Ne=V.extra;se<Ne;){if(ae===0)break e;ae--,oe+=j[J++]<<se,se+=8}V.offset+=oe&(1<<V.extra)-1,oe>>>=V.extra,se-=V.extra,V.back+=V.extra}if(V.offset>V.dmax){B.msg="invalid distance too far back",V.mode=30;break}V.mode=25;case 25:if(Z===0)break e;if(Se=pe-Z,V.offset>Se){if((Se=V.offset-Se)>V.whave&&V.sane){B.msg="invalid distance too far back",V.mode=30;break}we=Se>V.wnext?(Se-=V.wnext,V.wsize-Se):V.wnext-Se,Se>V.length&&(Se=V.length),De=V.window}else De=Y,we=ne-V.offset,Se=V.length;for(Z<Se&&(Se=Z),Z-=Se,V.length-=Se;Y[ne++]=De[we++],--Se;);V.length===0&&(V.mode=21);break;case 26:if(Z===0)break e;Y[ne++]=V.length,Z--,V.mode=21;break;case 27:if(V.wrap){for(;se<32;){if(ae===0)break e;ae--,oe|=j[J++]<<se,se+=8}if(pe-=Z,B.total_out+=pe,V.total+=pe,pe&&(B.adler=V.check=V.flags?c(V.check,Y,pe,ne-pe):a(V.check,Y,pe,ne-pe)),pe=Z,(V.flags?oe:g(oe))!==V.check){B.msg="incorrect data check",V.mode=30;break}se=oe=0}V.mode=28;case 28:if(V.wrap&&V.flags){for(;se<32;){if(ae===0)break e;ae--,oe+=j[J++]<<se,se+=8}if(oe!==(4294967295&V.total)){B.msg="incorrect length check",V.mode=30;break}se=oe=0}V.mode=29;case 29:qe=1;break e;case 30:qe=-3;break e;case 31:return-4;default:return h}return B.next_out=ne,B.avail_out=Z,B.next_in=J,B.avail_in=ae,V.hold=oe,V.bits=se,(V.wsize||pe!==B.avail_out&&V.mode<30&&(V.mode<27||z!==4))&&H(B,B.output,B.next_out,pe-B.avail_out)?(V.mode=31,-4):(le-=B.avail_in,pe-=B.avail_out,B.total_in+=le,B.total_out+=pe,V.total+=pe,V.wrap&&pe&&(B.adler=V.check=V.flags?c(V.check,Y,pe,B.next_out-pe):a(V.check,Y,pe,B.next_out-pe)),B.data_type=V.bits+(V.last?64:0)+(V.mode===12?128:0)+(V.mode===20||V.mode===15?256:0),(le==0&&pe===0||z===4)&&qe===m&&(qe=-5),qe)},i.inflateEnd=function(B){if(!B||!B.state)return h;var z=B.state;return z.window&&(z.window=null),B.state=null,m},i.inflateGetHeader=function(B,z){var V;return B&&B.state?(2&(V=B.state).wrap)==0?h:((V.head=z).done=!1,m):h},i.inflateSetDictionary=function(B,z){var V,j=z.length;return B&&B.state?(V=B.state).wrap!==0&&V.mode!==11?h:V.mode===11&&a(1,z,j,0)!==V.check?-3:H(B,z,j,j)?(V.mode=31,-4):(V.havedict=1,m):h},i.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(o,r,i){var s=o("../utils/common"),a=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],c=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],l=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],u=[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];r.exports=function(_,d,m,h,p,x,f,g){var y,b,v,S,M,w,A,D,I,H=g.bits,B=0,z=0,V=0,j=0,Y=0,J=0,ne=0,ae=0,Z=0,oe=0,se=null,le=0,pe=new s.Buf16(16),Se=new s.Buf16(16),we=null,De=0;for(B=0;B<=15;B++)pe[B]=0;for(z=0;z<h;z++)pe[d[m+z]]++;for(Y=H,j=15;1<=j&&pe[j]===0;j--);if(j<Y&&(Y=j),j===0)return p[x++]=20971520,p[x++]=20971520,g.bits=1,0;for(V=1;V<j&&pe[V]===0;V++);for(Y<V&&(Y=V),B=ae=1;B<=15;B++)if(ae<<=1,(ae-=pe[B])<0)return-1;if(0<ae&&(_===0||j!==1))return-1;for(Se[1]=0,B=1;B<15;B++)Se[B+1]=Se[B]+pe[B];for(z=0;z<h;z++)d[m+z]!==0&&(f[Se[d[m+z]]++]=z);if(w=_===0?(se=we=f,19):_===1?(se=a,le-=257,we=c,De-=257,256):(se=l,we=u,-1),B=V,M=x,ne=z=oe=0,v=-1,S=(Z=1<<(J=Y))-1,_===1&&852<Z||_===2&&592<Z)return 1;for(;;){for(A=B-ne,I=f[z]<w?(D=0,f[z]):f[z]>w?(D=we[De+f[z]],se[le+f[z]]):(D=96,0),y=1<<B-ne,V=b=1<<J;p[M+(oe>>ne)+(b-=y)]=A<<24|D<<16|I|0,b!==0;);for(y=1<<B-1;oe&y;)y>>=1;if(y!==0?(oe&=y-1,oe+=y):oe=0,z++,--pe[B]==0){if(B===j)break;B=d[m+f[z]]}if(Y<B&&(oe&S)!==v){for(ne===0&&(ne=Y),M+=V,ae=1<<(J=B-ne);J+ne<j&&!((ae-=pe[J+ne])<=0);)J++,ae<<=1;if(Z+=1<<J,_===1&&852<Z||_===2&&592<Z)return 1;p[v=oe&S]=Y<<24|J<<16|M-x|0}}return oe!==0&&(p[M+oe]=B-ne<<24|64<<16|0),g.bits=Y,0}},{"../utils/common":41}],51:[function(o,r,i){r.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,r,i){var s=o("../utils/common"),a=0,c=1;function l($e){for(var ke=$e.length;0<=--ke;)$e[ke]=0}var u=0,_=29,d=256,m=d+1+_,h=30,p=19,x=2*m+1,f=15,g=16,y=7,b=256,v=16,S=17,M=18,w=[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],A=[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],D=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],I=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],H=new Array(2*(m+2));l(H);var B=new Array(2*h);l(B);var z=new Array(512);l(z);var V=new Array(256);l(V);var j=new Array(_);l(j);var Y,J,ne,ae=new Array(h);function Z($e,ke,ve,Ee,Te){this.static_tree=$e,this.extra_bits=ke,this.extra_base=ve,this.elems=Ee,this.max_length=Te,this.has_stree=$e&&$e.length}function oe($e,ke){this.dyn_tree=$e,this.max_code=0,this.stat_desc=ke}function se($e){return $e<256?z[$e]:z[256+($e>>>7)]}function le($e,ke){$e.pending_buf[$e.pending++]=255&ke,$e.pending_buf[$e.pending++]=ke>>>8&255}function pe($e,ke,ve){$e.bi_valid>g-ve?($e.bi_buf|=ke<<$e.bi_valid&65535,le($e,$e.bi_buf),$e.bi_buf=ke>>g-$e.bi_valid,$e.bi_valid+=ve-g):($e.bi_buf|=ke<<$e.bi_valid&65535,$e.bi_valid+=ve)}function Se($e,ke,ve){pe($e,ve[2*ke],ve[2*ke+1])}function we($e,ke){for(var ve=0;ve|=1&$e,$e>>>=1,ve<<=1,0<--ke;);return ve>>>1}function De($e,ke,ve){var Ee,Te,ze=new Array(f+1),Ue=0;for(Ee=1;Ee<=f;Ee++)ze[Ee]=Ue=Ue+ve[Ee-1]<<1;for(Te=0;Te<=ke;Te++){var et=$e[2*Te+1];et!==0&&($e[2*Te]=we(ze[et]++,et))}}function ge($e){var ke;for(ke=0;ke<m;ke++)$e.dyn_ltree[2*ke]=0;for(ke=0;ke<h;ke++)$e.dyn_dtree[2*ke]=0;for(ke=0;ke<p;ke++)$e.bl_tree[2*ke]=0;$e.dyn_ltree[2*b]=1,$e.opt_len=$e.static_len=0,$e.last_lit=$e.matches=0}function Me($e){8<$e.bi_valid?le($e,$e.bi_buf):0<$e.bi_valid&&($e.pending_buf[$e.pending++]=$e.bi_buf),$e.bi_buf=0,$e.bi_valid=0}function fe($e,ke,ve,Ee){var Te=2*ke,ze=2*ve;return $e[Te]<$e[ze]||$e[Te]===$e[ze]&&Ee[ke]<=Ee[ve]}function We($e,ke,ve){for(var Ee=$e.heap[ve],Te=ve<<1;Te<=$e.heap_len&&(Te<$e.heap_len&&fe(ke,$e.heap[Te+1],$e.heap[Te],$e.depth)&&Te++,!fe(ke,Ee,$e.heap[Te],$e.depth));)$e.heap[ve]=$e.heap[Te],ve=Te,Te<<=1;$e.heap[ve]=Ee}function je($e,ke,ve){var Ee,Te,ze,Ue,et=0;if($e.last_lit!==0)for(;Ee=$e.pending_buf[$e.d_buf+2*et]<<8|$e.pending_buf[$e.d_buf+2*et+1],Te=$e.pending_buf[$e.l_buf+et],et++,Ee===0?Se($e,Te,ke):(Se($e,(ze=V[Te])+d+1,ke),(Ue=w[ze])!==0&&pe($e,Te-=j[ze],Ue),Se($e,ze=se(--Ee),ve),(Ue=A[ze])!==0&&pe($e,Ee-=ae[ze],Ue)),et<$e.last_lit;);Se($e,b,ke)}function Ke($e,ke){var ve,Ee,Te,ze=ke.dyn_tree,Ue=ke.stat_desc.static_tree,et=ke.stat_desc.has_stree,ot=ke.stat_desc.elems,at=-1;for($e.heap_len=0,$e.heap_max=x,ve=0;ve<ot;ve++)ze[2*ve]!==0?($e.heap[++$e.heap_len]=at=ve,$e.depth[ve]=0):ze[2*ve+1]=0;for(;$e.heap_len<2;)ze[2*(Te=$e.heap[++$e.heap_len]=at<2?++at:0)]=1,$e.depth[Te]=0,$e.opt_len--,et&&($e.static_len-=Ue[2*Te+1]);for(ke.max_code=at,ve=$e.heap_len>>1;1<=ve;ve--)We($e,ze,ve);for(Te=ot;ve=$e.heap[1],$e.heap[1]=$e.heap[$e.heap_len--],We($e,ze,1),Ee=$e.heap[1],$e.heap[--$e.heap_max]=ve,$e.heap[--$e.heap_max]=Ee,ze[2*Te]=ze[2*ve]+ze[2*Ee],$e.depth[Te]=($e.depth[ve]>=$e.depth[Ee]?$e.depth[ve]:$e.depth[Ee])+1,ze[2*ve+1]=ze[2*Ee+1]=Te,$e.heap[1]=Te++,We($e,ze,1),2<=$e.heap_len;);$e.heap[--$e.heap_max]=$e.heap[1],(function(lt,xt){var Ct,Lt,$t,Ot,Dt,Wt,Cn=xt.dyn_tree,xe=xt.max_code,tt=xt.stat_desc.static_tree,ct=xt.stat_desc.has_stree,gt=xt.stat_desc.extra_bits,kt=xt.stat_desc.extra_base,Bt=xt.stat_desc.max_length,nn=0;for(Ot=0;Ot<=f;Ot++)lt.bl_count[Ot]=0;for(Cn[2*lt.heap[lt.heap_max]+1]=0,Ct=lt.heap_max+1;Ct<x;Ct++)Bt<(Ot=Cn[2*Cn[2*(Lt=lt.heap[Ct])+1]+1]+1)&&(Ot=Bt,nn++),Cn[2*Lt+1]=Ot,xe<Lt||(lt.bl_count[Ot]++,Dt=0,kt<=Lt&&(Dt=gt[Lt-kt]),Wt=Cn[2*Lt],lt.opt_len+=Wt*(Ot+Dt),ct&&(lt.static_len+=Wt*(tt[2*Lt+1]+Dt)));if(nn!==0){do{for(Ot=Bt-1;lt.bl_count[Ot]===0;)Ot--;lt.bl_count[Ot]--,lt.bl_count[Ot+1]+=2,lt.bl_count[Bt]--,nn-=2}while(0<nn);for(Ot=Bt;Ot!==0;Ot--)for(Lt=lt.bl_count[Ot];Lt!==0;)xe<($t=lt.heap[--Ct])||(Cn[2*$t+1]!==Ot&&(lt.opt_len+=(Ot-Cn[2*$t+1])*Cn[2*$t],Cn[2*$t+1]=Ot),Lt--)}})($e,ke),De(ze,at,$e.bl_count)}function me($e,ke,ve){var Ee,Te,ze=-1,Ue=ke[1],et=0,ot=7,at=4;for(Ue===0&&(ot=138,at=3),ke[2*(ve+1)+1]=65535,Ee=0;Ee<=ve;Ee++)Te=Ue,Ue=ke[2*(Ee+1)+1],++et<ot&&Te===Ue||(et<at?$e.bl_tree[2*Te]+=et:Te!==0?(Te!==ze&&$e.bl_tree[2*Te]++,$e.bl_tree[2*v]++):et<=10?$e.bl_tree[2*S]++:$e.bl_tree[2*M]++,ze=Te,at=(et=0)===Ue?(ot=138,3):Te===Ue?(ot=6,3):(ot=7,4))}function qe($e,ke,ve){var Ee,Te,ze=-1,Ue=ke[1],et=0,ot=7,at=4;for(Ue===0&&(ot=138,at=3),Ee=0;Ee<=ve;Ee++)if(Te=Ue,Ue=ke[2*(Ee+1)+1],!(++et<ot&&Te===Ue)){if(et<at)for(;Se($e,Te,$e.bl_tree),--et!=0;);else Te!==0?(Te!==ze&&(Se($e,Te,$e.bl_tree),et--),Se($e,v,$e.bl_tree),pe($e,et-3,2)):et<=10?(Se($e,S,$e.bl_tree),pe($e,et-3,3)):(Se($e,M,$e.bl_tree),pe($e,et-11,7));ze=Te,at=(et=0)===Ue?(ot=138,3):Te===Ue?(ot=6,3):(ot=7,4)}}l(ae);var Fe=!1;function Ne($e,ke,ve,Ee){pe($e,(u<<1)+(Ee?1:0),3),(function(Te,ze,Ue,et){Me(Te),le(Te,Ue),le(Te,~Ue),s.arraySet(Te.pending_buf,Te.window,ze,Ue,Te.pending),Te.pending+=Ue})($e,ke,ve)}i._tr_init=function($e){Fe||((function(){var ke,ve,Ee,Te,ze,Ue=new Array(f+1);for(Te=Ee=0;Te<_-1;Te++)for(j[Te]=Ee,ke=0;ke<1<<w[Te];ke++)V[Ee++]=Te;for(V[Ee-1]=Te,Te=ze=0;Te<16;Te++)for(ae[Te]=ze,ke=0;ke<1<<A[Te];ke++)z[ze++]=Te;for(ze>>=7;Te<h;Te++)for(ae[Te]=ze<<7,ke=0;ke<1<<A[Te]-7;ke++)z[256+ze++]=Te;for(ve=0;ve<=f;ve++)Ue[ve]=0;for(ke=0;ke<=143;)H[2*ke+1]=8,ke++,Ue[8]++;for(;ke<=255;)H[2*ke+1]=9,ke++,Ue[9]++;for(;ke<=279;)H[2*ke+1]=7,ke++,Ue[7]++;for(;ke<=287;)H[2*ke+1]=8,ke++,Ue[8]++;for(De(H,m+1,Ue),ke=0;ke<h;ke++)B[2*ke+1]=5,B[2*ke]=we(ke,5);Y=new Z(H,w,d+1,m,f),J=new Z(B,A,0,h,f),ne=new Z(new Array(0),D,0,p,y)})(),Fe=!0),$e.l_desc=new oe($e.dyn_ltree,Y),$e.d_desc=new oe($e.dyn_dtree,J),$e.bl_desc=new oe($e.bl_tree,ne),$e.bi_buf=0,$e.bi_valid=0,ge($e)},i._tr_stored_block=Ne,i._tr_flush_block=function($e,ke,ve,Ee){var Te,ze,Ue=0;0<$e.level?($e.strm.data_type===2&&($e.strm.data_type=(function(et){var ot,at=4093624447;for(ot=0;ot<=31;ot++,at>>>=1)if(1&at&&et.dyn_ltree[2*ot]!==0)return a;if(et.dyn_ltree[18]!==0||et.dyn_ltree[20]!==0||et.dyn_ltree[26]!==0)return c;for(ot=32;ot<d;ot++)if(et.dyn_ltree[2*ot]!==0)return c;return a})($e)),Ke($e,$e.l_desc),Ke($e,$e.d_desc),Ue=(function(et){var ot;for(me(et,et.dyn_ltree,et.l_desc.max_code),me(et,et.dyn_dtree,et.d_desc.max_code),Ke(et,et.bl_desc),ot=p-1;3<=ot&&et.bl_tree[2*I[ot]+1]===0;ot--);return et.opt_len+=3*(ot+1)+5+5+4,ot})($e),Te=$e.opt_len+3+7>>>3,(ze=$e.static_len+3+7>>>3)<=Te&&(Te=ze)):Te=ze=ve+5,ve+4<=Te&&ke!==-1?Ne($e,ke,ve,Ee):$e.strategy===4||ze===Te?(pe($e,2+(Ee?1:0),3),je($e,H,B)):(pe($e,4+(Ee?1:0),3),(function(et,ot,at,lt){var xt;for(pe(et,ot-257,5),pe(et,at-1,5),pe(et,lt-4,4),xt=0;xt<lt;xt++)pe(et,et.bl_tree[2*I[xt]+1],3);qe(et,et.dyn_ltree,ot-1),qe(et,et.dyn_dtree,at-1)})($e,$e.l_desc.max_code+1,$e.d_desc.max_code+1,Ue+1),je($e,$e.dyn_ltree,$e.dyn_dtree)),ge($e),Ee&&Me($e)},i._tr_tally=function($e,ke,ve){return $e.pending_buf[$e.d_buf+2*$e.last_lit]=ke>>>8&255,$e.pending_buf[$e.d_buf+2*$e.last_lit+1]=255&ke,$e.pending_buf[$e.l_buf+$e.last_lit]=255&ve,$e.last_lit++,ke===0?$e.dyn_ltree[2*ve]++:($e.matches++,ke--,$e.dyn_ltree[2*(V[ve]+d+1)]++,$e.dyn_dtree[2*se(ke)]++),$e.last_lit===$e.lit_bufsize-1},i._tr_align=function($e){pe($e,2,3),Se($e,b,H),(function(ke){ke.bi_valid===16?(le(ke,ke.bi_buf),ke.bi_buf=0,ke.bi_valid=0):8<=ke.bi_valid&&(ke.pending_buf[ke.pending++]=255&ke.bi_buf,ke.bi_buf>>=8,ke.bi_valid-=8)})($e)}},{"../utils/common":41}],53:[function(o,r,i){r.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,r,i){(function(s){(function(a,c){if(!a.setImmediate){var l,u,_,d,m=1,h={},p=!1,x=a.document,f=Object.getPrototypeOf&&Object.getPrototypeOf(a);f=f&&f.setTimeout?f:a,l={}.toString.call(a.process)==="[object process]"?function(v){n.nextTick(function(){y(v)})}:(function(){if(a.postMessage&&!a.importScripts){var v=!0,S=a.onmessage;return a.onmessage=function(){v=!1},a.postMessage("","*"),a.onmessage=S,v}})()?(d="setImmediate$"+Math.random()+"$",a.addEventListener?a.addEventListener("message",b,!1):a.attachEvent("onmessage",b),function(v){a.postMessage(d+v,"*")}):a.MessageChannel?((_=new MessageChannel).port1.onmessage=function(v){y(v.data)},function(v){_.port2.postMessage(v)}):x&&"onreadystatechange"in x.createElement("script")?(u=x.documentElement,function(v){var S=x.createElement("script");S.onreadystatechange=function(){y(v),S.onreadystatechange=null,u.removeChild(S),S=null},u.appendChild(S)}):function(v){setTimeout(y,0,v)},f.setImmediate=function(v){typeof v!="function"&&(v=new Function(""+v));for(var S=new Array(arguments.length-1),M=0;M<S.length;M++)S[M]=arguments[M+1];var w={callback:v,args:S};return h[m]=w,l(m),m++},f.clearImmediate=g}function g(v){delete h[v]}function y(v){if(p)setTimeout(y,0,v);else{var S=h[v];if(S){p=!0;try{(function(M){var w=M.callback,A=M.args;switch(A.length){case 0:w();break;case 1:w(A[0]);break;case 2:w(A[0],A[1]);break;case 3:w(A[0],A[1],A[2]);break;default:w.apply(c,A)}})(S)}finally{g(v),p=!1}}}}function b(v){v.source===a&&typeof v.data=="string"&&v.data.indexOf(d)===0&&y(+v.data.slice(d.length))}})(typeof self>"u"?s===void 0?this:s:self)}).call(this,typeof FI<"u"?FI:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(tye)),tye.exports}var Bqn=Fqn();const nye=Ly(Bqn);var zqn=["circuit-json-to-bom-csv","circuit-json-to-bpc","circuit-json-to-connectivity-map","circuit-json-to-gerber","circuit-json-to-gltf","circuit-json-to-kicad","circuit-json-to-lbrn","circuit-json-to-pnp-csv","circuit-json-to-readable-netlist","circuit-json-to-simple-3d","circuit-json-to-spice","circuit-json-to-step","circuit-json-to-tscircuit","circuit-to-canvas","circuit-to-svg"],Vqn=new Set(zqn),$qn=t=>{const e=t.indexOf("@");return e===-1?t:t.slice(0,e)},Wqn=t=>{const e=$qn(t);if(!Vqn.has(e))throw new Error(`Unsupported module: ${t}`);return`https://esm.run/${t}`};async function Uqn(t){return import(Wqn(t))}var $S=Uqn,Adt=3,Xqn=(t,e={})=>{e.flip_y_axis??=!1;const n=[];for(const o of t)if(o.type==="pcb_component"){const r=Qp(t).source_component.get(o.source_component_id);n.push({designator:r?.name??o.pcb_component_id,mid_x:o.center.x,mid_y:o.center.y*(e.flip_y_axis?-1:1),layer:o.layer,rotation:o.rotation})}return n},jqn=t=>Ist.unparse(Xqn(t).map(e=>({Designator:e.designator,"Mid X":e.mid_x.toFixed(Adt),"Mid Y":e.mid_y.toFixed(Adt),Layer:e.layer,Rotation:e.rotation})));const Lv=(t,e)=>{const{fileName:n,mimeType:o="text/plain"}=e,r=t instanceof Blob?t:new Blob([t],{type:o}),i=URL.createObjectURL(r),s=document.createElement("a");s.href=i,s.download=n,document.body.appendChild(s),s.click(),setTimeout(()=>{document.body.removeChild(s),URL.revokeObjectURL(i)},0)},Gqn=async({circuitJson:t,projectName:e})=>{const n=new nye,{stringifyGerberCommandLayers:o,convertSoupToGerberCommands:r,convertSoupToExcellonDrillCommands:i,stringifyExcellonDrill:s}=await $S("circuit-json-to-gerber"),a=t.filter(x=>!("error_type"in x)&&!("warning_type"in x)),c=r(a,{flip_y_axis:!1}),l=o(c);for(const[x,f]of Object.entries(l))n.file(`gerber/${x}.gbr`,f);const u=i({circuitJson:a,is_plated:!0,flip_y_axis:!1}),_=s(u);n.file("gerber/drill.drl",_);const d=await Lst({circuitJson:t}),m=await KFn(d);n.file("bom.csv",m);const h=await jqn(t);n.file("pick_and_place.csv",h);const p=await n.generateAsync({type:"blob"});Lv(p,{fileName:`${e}_fabrication_files.zip`})},Yqn=async({circuitJson:t,projectName:e})=>{let n;try{const{convertCircuitJsonToGltf:o}=await $S("circuit-json-to-gltf");console.log("convertCircuitJsonToGltf",o);const r=await o(t,{format:"glb",boardTextureResolution:1024});if(!r||!(r instanceof ArrayBuffer))throw new Error("Invalid GLB data returned from converter");n=new Blob([r],{type:"model/gltf-binary"})}catch(o){console.error("GLB Export Error:",o);return}Lv(n,{fileName:`${e}.glb`})},qqn=async({circuitJson:t,projectName:e})=>{const{convertCircuitJsonToPinoutSvg:n}=await $S("circuit-to-svg"),o=n(t);Lv(o,{fileName:`${e}-pinout.svg`,mimeType:"image/svg+xml"})},Jqn=async({circuitJson:t,projectName:e})=>{const{CircuitJsonToKicadPcbConverter:n,CircuitJsonToKicadSchConverter:o,CircuitJsonToKicadProConverter:r}=await $S("circuit-json-to-kicad"),i=new o(t);i.runUntilFinished();const s=i.getOutputString(),a=new n(t);a.runUntilFinished();const c=a.getOutputString(),l=new r(t,{projectName:e,schematicFilename:`${e}.kicad_sch`,pcbFilename:`${e}.kicad_pcb`});l.runUntilFinished();const u=l.getOutputString(),_=new nye;return _.file(`${e}.kicad_sch`,s),_.file(`${e}.kicad_pcb`,c),_.file(`${e}.kicad_pro`,u),_},Kqn=async({circuitJson:t,projectName:e})=>{const o=await(await Jqn({circuitJson:t,projectName:e})).generateAsync({type:"blob"});Lv(o,{fileName:`${e}_kicad_project.zip`})},Qqn=async({circuitJson:t,libraryName:e})=>{const{CircuitJsonToKicadLibraryConverter:n}=await $S("circuit-json-to-kicad"),o=new n(t,{libraryName:e,footprintLibraryName:e});o.runUntilFinished();const r=o.getOutput(),i=new nye;i.file(`${e}.kicad_sym`,r.kicadSymString);for(const s of r.footprints){const a=i.folder(`${e}.pretty`);a&&a.file(`${s.footprintName}.kicad_mod`,`${s.kicadModString}
5710
- `)}if(r.model3dSourcePaths.length>0){const s=i.folder(`${e}.3dshapes`);if(s)for(const a of r.model3dSourcePaths)try{const c=a.split("/").pop()||a,l=await fetch(a);if(l.ok){const u=await l.arrayBuffer();s.file(c,u)}}catch{}}return i.file("fp-lib-table",r.fpLibTableString),i.file("sym-lib-table",r.symLibTableString),i},Zqn=async({circuitJson:t,projectName:e})=>{const o=await(await Qqn({circuitJson:t,libraryName:e})).generateAsync({type:"blob"});Lv(o,{fileName:`${e}_kicad_library.zip`})},eJn=async({circuitJson:t,projectName:e})=>{const{circuitJsonToStep:n}=await $S("circuit-json-to-step"),o=t.find(l=>l.type==="pcb_board"),r=o&&"width"in o?o.width:void 0,i=o&&"height"in o?o.height:void 0,s=o&&"thickness"in o?o.thickness:void 0;if(r===void 0||i===void 0||s===void 0){Es.error("Board dimensions not found. Please add a pcb_board with width, height, and thickness to your circuit.");return}let a;try{a=await n(t,{boardWidth:r,boardHeight:i,boardThickness:s,productName:e,includeComponents:!0,includeExternalMeshes:!0})}catch(l){const u=l instanceof Error?l.message:"Unknown error";Es.error(`Failed to convert circuit to STEP format: ${u}`);return}const c=new Blob([a],{type:"application/step"});try{Lv(c,{fileName:`${e}.step`})}catch(l){const u=l instanceof Error?l.message:"Unknown error";Es.error(`Failed to download STEP file: ${u}`)}},Rdt=async({circuitJson:t,projectName:e,options:n={}})=>{try{const{convertCircuitJsonToLbrn:o}=await $S("circuit-json-to-lbrn"),i=(await o(t,{includeSilkscreen:n.includeSilkscreen??!1})).toXml(),s=new Blob([i],{type:"application/lbrn"});Lv(s,{fileName:`${e}.lbrn2`})}catch(o){const r=o instanceof Error?o.message:"Unknown error";Es.error(`Failed to export to LBRN format: ${r}`)}},tJn=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"},nJn=[{extension:"json",name:"Circuit 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"}],oJn=async({exportName:t,circuitJson:e,projectName:n})=>{const o=tJn(n);if(t==="Fabrication Files"){Gqn({circuitJson:e,projectName:o});return}if(t==="KiCad Project"){await Kqn({circuitJson:e,projectName:o});return}if(t==="KiCad Library"){await Zqn({circuitJson:e,projectName:o});return}if(t==="Circuit JSON"){Lv(JSON.stringify(e,null,2),{fileName:`${o}.circuit.json`,mimeType:"application/json"});return}if(t==="GLB (Binary GLTF)"){await Yqn({circuitJson:e,projectName:o});return}if(t==="Pinout SVG"){qqn({circuitJson:e,projectName:o});return}if(t==="STEP"){await eJn({circuitJson:e,projectName:o});return}if(t==="LightBurn"){await Rdt({circuitJson:e,projectName:o});return}throw new Error(`Unsupported export type: "${t}"`)};class WS extends Error{response;request;options;constructor(e,n,o){const r=e.status||e.status===0?e.status:"",i=e.statusText??"",s=`${r} ${i}`.trim(),a=s?`status code ${s}`:"an unknown error";super(`Request failed with ${a}: ${n.method} ${n.url}`),this.name="HTTPError",this.response=e,this.request=n,this.options=o}}class kdt extends Error{name="NonError";value;constructor(e){let n="Non-error value was thrown";try{typeof e=="string"?n=e:e&&typeof e=="object"&&"message"in e&&typeof e.message=="string"&&(n=e.message)}catch{}super(n),this.value=e}}class oye extends Error{name="ForceRetryError";customDelay;code;customRequest;constructor(e){const n=e?.cause?e.cause instanceof Error?e.cause:new kdt(e.cause):void 0;super(e?.code?`Forced retry: ${e.code}`:"Forced retry",n?{cause:n}:void 0),this.customDelay=e?.delay,this.code=e?.code,this.customRequest=e?.request}}const Ndt=(()=>{let t=!1,e=!1;const n=typeof globalThis.ReadableStream=="function",o=typeof globalThis.Request=="function";if(n&&o)try{e=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return t=!0,"half"}}).headers.has("Content-Type")}catch(r){if(r instanceof Error&&r.message==="unsupported BodyInit type")return!1;throw r}return t&&!e})(),rJn=typeof globalThis.AbortController=="function",Hdt=typeof globalThis.AbortSignal=="function"&&typeof globalThis.AbortSignal.any=="function",iJn=typeof globalThis.ReadableStream=="function",sJn=typeof globalThis.FormData=="function",Idt=["get","post","put","patch","head","delete"],aJn={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},rye=2147483647,cJn=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,Ldt=Symbol("stop");class Odt{options;constructor(e){this.options=e}}const lJn=t=>new Odt(t),uJn={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0,context:!0},_Jn={next:!0},dJn={method:!0,headers:!0,body:!0,mode:!0,credentials:!0,cache:!0,redirect:!0,referrer:!0,referrerPolicy:!0,integrity:!0,keepalive:!0,signal:!0,window:!0,duplex:!0},hJn=t=>{if(!t)return 0;if(t instanceof FormData){let e=0;for(const[n,o]of t)e+=cJn,e+=new TextEncoder().encode(`Content-Disposition: form-data; name="${n}"`).length,e+=typeof o=="string"?new TextEncoder().encode(o).length:o.size;return e}if(t instanceof Blob)return t.size;if(t instanceof ArrayBuffer)return t.byteLength;if(typeof t=="string")return new TextEncoder().encode(t).length;if(t instanceof URLSearchParams)return new TextEncoder().encode(t.toString()).length;if("byteLength"in t)return t.byteLength;if(typeof t=="object"&&t!==null)try{const e=JSON.stringify(t);return new TextEncoder().encode(e).length}catch{return 0}return 0},Fdt=(t,e,n)=>{let o,r=0;return t.pipeThrough(new TransformStream({transform(i,s){if(s.enqueue(i),o){r+=o.byteLength;let a=e===0?0:r/e;a>=1&&(a=1-Number.EPSILON),n?.({percent:a,totalBytes:Math.max(e,r),transferredBytes:r},o)}o=i},flush(){o&&(r+=o.byteLength,n?.({percent:1,totalBytes:Math.max(e,r),transferredBytes:r},o))}}))},mJn=(t,e)=>{if(!t.body)return t;if(t.status===204)return new Response(null,{status:t.status,statusText:t.statusText,headers:t.headers});const n=Math.max(0,Number(t.headers.get("content-length"))||0);return new Response(Fdt(t.body,n,e),{status:t.status,statusText:t.statusText,headers:t.headers})},pJn=(t,e,n)=>{if(!t.body)return t;const o=hJn(n??t.body);return new Request(t,{duplex:"half",body:Fdt(t.body,o,e)})},US=t=>t!==null&&typeof t=="object",zG=(...t)=>{for(const e of t)if((!US(e)||Array.isArray(e))&&e!==void 0)throw new TypeError("The `options` argument must be an object");return iye({},...t)},Bdt=(t={},e={})=>{const n=new globalThis.Headers(t),o=e instanceof globalThis.Headers,r=new globalThis.Headers(e);for(const[i,s]of r.entries())o&&s==="undefined"||s===void 0?n.delete(i):n.set(i,s);return n};function VG(t,e,n){return Object.hasOwn(e,n)&&e[n]===void 0?[]:iye(t[n]??[],e[n]??[])}const zdt=(t={},e={})=>({beforeRequest:VG(t,e,"beforeRequest"),beforeRetry:VG(t,e,"beforeRetry"),afterResponse:VG(t,e,"afterResponse"),beforeError:VG(t,e,"beforeError")}),fJn=(t,e)=>{const n=new URLSearchParams;for(const o of[t,e])if(o!==void 0)if(o instanceof URLSearchParams)for(const[r,i]of o.entries())n.append(r,i);else if(Array.isArray(o))for(const r of o){if(!Array.isArray(r)||r.length!==2)throw new TypeError("Array search parameters must be provided in [[key, value], ...] format");n.append(String(r[0]),String(r[1]))}else if(US(o))for(const[r,i]of Object.entries(o))i!==void 0&&n.append(r,String(i));else{const r=new URLSearchParams(o);for(const[i,s]of r.entries())n.append(i,s)}return n},iye=(...t)=>{let e={},n={},o={},r;const i=[];for(const s of t)if(Array.isArray(s))Array.isArray(e)||(e=[]),e=[...e,...s];else if(US(s)){for(let[a,c]of Object.entries(s)){if(a==="signal"&&c instanceof globalThis.AbortSignal){i.push(c);continue}if(a==="context"){if(c!=null&&(!US(c)||Array.isArray(c)))throw new TypeError("The `context` option must be an object");e={...e,context:c==null?{}:{...e.context,...c}};continue}if(a==="searchParams"){c==null?r=void 0:r=r===void 0?c:fJn(r,c);continue}US(c)&&a in e&&(c=iye(e[a],c)),e={...e,[a]:c}}US(s.hooks)&&(o=zdt(o,s.hooks),e.hooks=o),US(s.headers)&&(n=Bdt(n,s.headers),e.headers=n)}return r!==void 0&&(e.searchParams=r),i.length>0&&(i.length===1?e.signal=i[0]:Hdt?e.signal=AbortSignal.any(i):e.signal=i.at(-1)),e},xJn=t=>Idt.includes(t)?t.toUpperCase():t,Vdt={limit:2,methods:["get","put","head","delete","options","trace"],statusCodes:[408,413,429,500,502,503,504],afterStatusCodes:[413,429,503],maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:t=>.3*2**(t-1)*1e3,jitter:void 0,retryOnTimeout:!1},gJn=(t={})=>{if(typeof t=="number")return{...Vdt,limit:t};if(t.methods&&!Array.isArray(t.methods))throw new Error("retry.methods must be an array");if(t.methods&&=t.methods.map(n=>n.toLowerCase()),t.statusCodes&&!Array.isArray(t.statusCodes))throw new Error("retry.statusCodes must be an array");const e=Object.fromEntries(Object.entries(t).filter(([,n])=>n!==void 0));return{...Vdt,...e}};class sye extends Error{request;constructor(e){super(`Request timed out: ${e.method} ${e.url}`),this.name="TimeoutError",this.request=e}}async function yJn(t,e,n,o){return new Promise((r,i)=>{const s=setTimeout(()=>{n&&n.abort(),i(new sye(t))},o.timeout);o.fetch(t,e).then(r).catch(i).then(()=>{clearTimeout(s)})})}async function bJn(t,{signal:e}){return new Promise((n,o)=>{e&&(e.throwIfAborted(),e.addEventListener("abort",r,{once:!0}));function r(){clearTimeout(i),o(e.reason)}const i=setTimeout(()=>{e?.removeEventListener("abort",r),n()},t)})}const PJn=(t,e)=>{const n={};for(const o in e)Object.hasOwn(e,o)&&!(o in dJn)&&!(o in uJn)&&(!(o in t)||o in _Jn)&&(n[o]=e[o]);return n},vJn=t=>t===void 0?!1:Array.isArray(t)?t.length>0:t instanceof URLSearchParams?t.size>0:typeof t=="object"?Object.keys(t).length>0:typeof t=="string"?t.trim().length>0:!!t;function SJn(t){return t instanceof WS||t?.name===WS.name}function CJn(t){return t instanceof sye||t?.name===sye.name}class jH{static create(e,n){const o=new jH(e,n),r=async()=>{if(typeof o.#e.timeout=="number"&&o.#e.timeout>rye)throw new RangeError(`The \`timeout\` option cannot be greater than ${rye}`);await Promise.resolve();let s=await o.#x();for(const a of o.#e.hooks.afterResponse){const c=o.#d(s.clone());let l;try{l=await a(o.request,o.#c(),c,{retryCount:o.#n})}catch(_){throw o.#i(c),o.#i(s),_}if(l instanceof Odt)throw o.#i(c),o.#i(s),new oye(l.options);const u=l instanceof globalThis.Response?l:s;c!==u&&o.#i(c),s!==u&&o.#i(s),s=u}if(o.#d(s),!s.ok&&(typeof o.#e.throwHttpErrors=="function"?o.#e.throwHttpErrors(s.status):o.#e.throwHttpErrors)){let a=new WS(s,o.request,o.#c());for(const c of o.#e.hooks.beforeError)a=await c(a,{retryCount:o.#n});throw a}if(o.#e.onDownloadProgress){if(typeof o.#e.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!iJn)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");const a=s.clone();return o.#i(s),mJn(a,o.#e.onDownloadProgress)}return s},i=o.#h(r).finally(()=>{const s=o.#s;o.#u(s?.body??void 0),o.#u(o.request.body??void 0)});for(const[s,a]of Object.entries(aJn))s==="bytes"&&typeof globalThis.Response?.prototype?.bytes!="function"||(i[s]=async()=>{o.request.headers.set("accept",o.request.headers.get("accept")||a);const c=await i;if(s==="json"){if(c.status===204)return"";const l=await c.text();return l===""?"":n.parseJson?n.parseJson(l):JSON.parse(l)}return c[s]()});return i}static#p(e){return e&&typeof e=="object"&&!Array.isArray(e)&&!(e instanceof URLSearchParams)?Object.fromEntries(Object.entries(e).filter(([,n])=>n!==void 0)):e}request;#o;#n=0;#t;#e;#s;#r;#a;constructor(e,n={}){if(this.#t=e,this.#e={...n,headers:Bdt(this.#t.headers,n.headers),hooks:zdt({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},n.hooks),method:xJn(n.method??this.#t.method??"GET"),prefixUrl:String(n.prefixUrl||""),retry:gJn(n.retry),throwHttpErrors:n.throwHttpErrors??!0,timeout:n.timeout??1e4,fetch:n.fetch??globalThis.fetch.bind(globalThis),context:n.context??{}},typeof this.#t!="string"&&!(this.#t instanceof URL||this.#t instanceof globalThis.Request))throw new TypeError("`input` must be a string, URL, or Request");if(this.#e.prefixUrl&&typeof this.#t=="string"){if(this.#t.startsWith("/"))throw new Error("`input` must not begin with a slash when using `prefixUrl`");this.#e.prefixUrl.endsWith("/")||(this.#e.prefixUrl+="/"),this.#t=this.#e.prefixUrl+this.#t}rJn&&Hdt&&(this.#r=this.#e.signal??this.#t.signal,this.#o=new globalThis.AbortController,this.#e.signal=this.#r?AbortSignal.any([this.#r,this.#o.signal]):this.#o.signal),Ndt&&(this.#e.duplex="half"),this.#e.json!==void 0&&(this.#e.body=this.#e.stringifyJson?.(this.#e.json)??JSON.stringify(this.#e.json),this.#e.headers.set("content-type",this.#e.headers.get("content-type")??"application/json"));const o=n.headers&&new globalThis.Headers(n.headers).has("content-type");if(this.#t instanceof globalThis.Request&&(sJn&&this.#e.body instanceof globalThis.FormData||this.#e.body instanceof URLSearchParams)&&!o&&this.#e.headers.delete("content-type"),this.request=new globalThis.Request(this.#t,this.#e),vJn(this.#e.searchParams)){const i="?"+(typeof this.#e.searchParams=="string"?this.#e.searchParams.replace(/^\?/,""):new URLSearchParams(jH.#p(this.#e.searchParams)).toString()),s=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,i);this.request=new globalThis.Request(s,this.#e)}if(this.#e.onUploadProgress){if(typeof this.#e.onUploadProgress!="function")throw new TypeError("The `onUploadProgress` option must be a function");if(!Ndt)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request=this.#m(this.request,this.#e.body??void 0)}}#l(){const e=this.#e.retry.delay(this.#n);let n=e;this.#e.retry.jitter===!0?n=Math.random()*e:typeof this.#e.retry.jitter=="function"&&(n=this.#e.retry.jitter(e),(!Number.isFinite(n)||n<0)&&(n=e));const o=this.#e.retry.backoffLimit??Number.POSITIVE_INFINITY;return Math.min(o,n)}async#f(e){if(this.#n++,this.#n>this.#e.retry.limit)throw e;const n=e instanceof Error?e:new kdt(e);if(n instanceof oye)return n.customDelay??this.#l();if(!this.#e.retry.methods.includes(this.request.method.toLowerCase()))throw e;if(this.#e.retry.shouldRetry!==void 0){const o=await this.#e.retry.shouldRetry({error:n,retryCount:this.#n});if(o===!1)throw e;if(o===!0)return this.#l()}if(CJn(e)&&!this.#e.retry.retryOnTimeout)throw e;if(SJn(e)){if(!this.#e.retry.statusCodes.includes(e.response.status))throw e;const o=e.response.headers.get("Retry-After")??e.response.headers.get("RateLimit-Reset")??e.response.headers.get("X-RateLimit-Retry-After")??e.response.headers.get("X-RateLimit-Reset")??e.response.headers.get("X-Rate-Limit-Reset");if(o&&this.#e.retry.afterStatusCodes.includes(e.response.status)){let r=Number(o)*1e3;Number.isNaN(r)?r=Date.parse(o)-Date.now():r>=Date.parse("2024-01-01")&&(r-=Date.now());const i=this.#e.retry.maxRetryAfter??r;return r<i?r:i}if(e.response.status===413)throw e}return this.#l()}#d(e){return this.#e.parseJson&&(e.json=async()=>this.#e.parseJson(await e.text())),e}#u(e){e&&e.cancel().catch(()=>{})}#i(e){this.#u(e.body??void 0)}async#h(e){try{return await e()}catch(n){const o=Math.min(await this.#f(n),rye);if(this.#n<1)throw n;if(await bJn(o,this.#r?{signal:this.#r}:{}),n instanceof oye&&n.customRequest){const r=this.#e.signal?new globalThis.Request(n.customRequest,{signal:this.#e.signal}):new globalThis.Request(n.customRequest);this.#_(r)}for(const r of this.#e.hooks.beforeRetry){const i=await r({request:this.request,options:this.#c(),error:n,retryCount:this.#n});if(i instanceof globalThis.Request){this.#_(i);break}if(i instanceof globalThis.Response)return i;if(i===Ldt)return}return this.#h(e)}}async#x(){this.#o?.signal.aborted&&(this.#o=new globalThis.AbortController,this.#e.signal=this.#r?AbortSignal.any([this.#r,this.#o.signal]):this.#o.signal,this.request=new globalThis.Request(this.request,{signal:this.#e.signal}));for(const n of this.#e.hooks.beforeRequest){const o=await n(this.request,this.#c(),{retryCount:this.#n});if(o instanceof Response)return o;if(o instanceof globalThis.Request){this.#_(o);break}}const e=PJn(this.request,this.#e);return this.#s=this.request,this.request=this.#s.clone(),this.#e.timeout===!1?this.#e.fetch(this.#s,e):yJn(this.#s,e,this.#o,this.#e)}#c(){if(!this.#a){const{hooks:e,...n}=this.#e;this.#a=Object.freeze(n)}return this.#a}#_(e){this.#a=void 0,this.request=this.#m(e)}#m(e,n){return!this.#e.onUploadProgress||!e.body?e:pJn(e,this.#e.onUploadProgress,n??this.#e.body??void 0)}}const aye=t=>{const e=(n,o)=>jH.create(n,zG(t,o));for(const n of Idt)e[n]=(o,r)=>jH.create(o,zG(t,r,{method:n}));return e.create=n=>aye(zG(n)),e.extend=n=>(typeof n=="function"&&(n=n(t??{})),aye(zG(t,n))),e.stop=Ldt,e.retry=lJn,e},MJn=aye();class TJn extends WS{constructor(e,n,o,r){super(e,n,o),this.name="RegistryHTTPError",this.message=r}}function $G(t){return typeof window<"u"?window[t]:null}function XS(){const t=$G("TSCIRCUIT_REGISTRY_API_BASE_URL")||void 0||"https://registry-api.tscircuit.com",e=$G("TSCIRCUIT_REGISTRY_TOKEN");return MJn.create({prefixUrl:t,headers:{Authorization:`Bearer ${e}`},timeout:3e4,hooks:{afterResponse:[async(n,o,r)=>{if(r.ok)return r;let i=null;try{i=await r.clone().json()}catch(_){console.error("Failed to parse registry error response",_)}const s=i?.error?.message??i?.error?.error_message??i?.message,a=i?.error?.error_code??i?.error_code,c=new URL(r.url),u=[`Registry request failed for ${`${c.pathname}${c.search}`} (${r.status})`];throw s&&u.push(`Server message: ${s}`),a&&u.push(`Error code: ${a}`),new TJn(r,n,o,u.join(" | "))}]}})}function WG(){return!!$G("TSCIRCUIT_REGISTRY_TOKEN")}const UG={get:(t,e)=>XS().get(t,e),post:(t,e)=>XS().post(t,e),put:(t,e)=>XS().put(t,e),delete:(t,e)=>XS().delete(t,e),patch:(t,e)=>XS().patch(t,e)},wJn=({packageName:t,onSelectReview:e})=>{const n=m3(_=>_.fsMap),o=m3(_=>_.circuitJson),[r,i]=te.useState([]),[s,a]=te.useState(!1),[c,l]=te.useState(!1);te.useEffect(()=>{!t||!WG()||(a(!0),UG.get("ai_reviews/list",{searchParams:{package_name:t}}).json().then(_=>i(_.ai_reviews)).catch(_=>{console.error("Failed to load AI reviews",_),Es.error("Failed to load AI reviews")}).finally(()=>a(!1)))},[t]);const u=async()=>{if(!o){Es.error("Need Circuit JSON to Request AI Review");return}if(!WG()){Es.error("Missing registry token");return}l(!0);try{const{ai_review:_}=await UG.post("ai_reviews/create",{json:{package_name:t??"unknown",fs_map:Object.fromEntries(n),circuit_json:o}}).json();i(d=>[_,...d]),e(_),Es.success("AI review requested")}catch(_){console.error("Failed to create AI review",_),Es.error("Failed to request AI review")}finally{l(!1)}};return G.jsxs(G.Fragment,{children:[G.jsxs(LE,{children:[G.jsx(OE,{children:"AI Review"}),G.jsx(UH,{children:"Select an AI review or request a new one."})]}),G.jsx("div",{className:"rf-flex rf-gap-4 rf-mt-4",children:G.jsx("div",{className:"rf-w-48 rf-h-64 rf-overflow-y-auto rf-border rf-rounded rf-p-2 rf-flex-shrink-0",children:s?G.jsx("div",{className:"rf-text-sm",children:"Loading..."}):r.length>0?r.map(_=>G.jsx("div",{className:"rf-text-sm rf-p-2 rf-cursor-pointer rf-rounded hover:rf-bg-zinc-100",onClick:()=>e(_),children:new Date(_.created_at||"").toLocaleString()},_.ai_review_id)):G.jsx("div",{className:"rf-text-sm rf-text-muted-foreground",children:"No AI reviews found."})})}),G.jsx(WH,{className:"rf-mt-4",children:G.jsx(w0,{onClick:u,disabled:c,children:c?"Requesting...":"Review my Board"})})]})};function cye(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var jS=cye();function $dt(t){jS=t}var GH={exec:()=>null};function Oc(t,e=""){let n=typeof t=="string"?t:t.source;const o={replace:(r,i)=>{let s=typeof i=="string"?i:i.source;return s=s.replace(h2.caret,"$1"),n=n.replace(r,s),o},getRegex:()=>new RegExp(n,e)};return o}var h2={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:t=>new RegExp(`^( {0,3}${t})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}#`),htmlBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}<(?:[a-z].*>|!--)`,"i")},EJn=/^(?:[ \t]*(?:\n|$))+/,DJn=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,AJn=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,YH=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,RJn=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,lye=/(?:[*+-]|\d{1,9}[.)])/,Wdt=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Udt=Oc(Wdt).replace(/bull/g,lye).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(),kJn=Oc(Wdt).replace(/bull/g,lye).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(),uye=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,NJn=/^[^\n]+/,_ye=/(?!\s*\])(?:\\.|[^\[\]\\])+/,HJn=Oc(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",_ye).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),IJn=Oc(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,lye).getRegex(),XG="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",dye=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,LJn=Oc("^ {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",dye).replace("tag",XG).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Xdt=Oc(uye).replace("hr",YH).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",XG).getRegex(),OJn=Oc(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Xdt).getRegex(),hye={blockquote:OJn,code:DJn,def:HJn,fences:AJn,heading:RJn,hr:YH,html:LJn,lheading:Udt,list:IJn,newline:EJn,paragraph:Xdt,table:GH,text:NJn},jdt=Oc("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",YH).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",XG).getRegex(),FJn={...hye,lheading:kJn,table:jdt,paragraph:Oc(uye).replace("hr",YH).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",jdt).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",XG).getRegex()},BJn={...hye,html:Oc(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",dye).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:GH,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Oc(uye).replace("hr",YH).replace("heading",` *#{1,6} *[^
5710
+ `)}if(r.model3dSourcePaths.length>0){const s=i.folder(`${e}.3dshapes`);if(s)for(const a of r.model3dSourcePaths)try{const c=a.split("/").pop()||a,l=await fetch(a);if(l.ok){const u=await l.arrayBuffer();s.file(c,u)}}catch{}}return i.file("fp-lib-table",r.fpLibTableString),i.file("sym-lib-table",r.symLibTableString),i},Zqn=async({circuitJson:t,projectName:e})=>{const o=await(await Qqn({circuitJson:t,libraryName:e})).generateAsync({type:"blob"});Lv(o,{fileName:`${e}_kicad_library.zip`})},eJn=async({circuitJson:t,projectName:e})=>{const{circuitJsonToStep:n}=await $S("circuit-json-to-step"),o=t.find(l=>l.type==="pcb_board"),r=o&&"width"in o?o.width:void 0,i=o&&"height"in o?o.height:void 0,s=o&&"thickness"in o?o.thickness:void 0;if(r===void 0||i===void 0||s===void 0){Es.error("Board dimensions not found. Please add a pcb_board with width, height, and thickness to your circuit.");return}let a;try{a=await n(t,{boardWidth:r,boardHeight:i,boardThickness:s,productName:e,includeComponents:!0,includeExternalMeshes:!0})}catch(l){const u=l instanceof Error?l.message:"Unknown error";Es.error(`Failed to convert circuit to STEP format: ${u}`);return}const c=new Blob([a],{type:"application/step"});try{Lv(c,{fileName:`${e}.step`})}catch(l){const u=l instanceof Error?l.message:"Unknown error";Es.error(`Failed to download STEP file: ${u}`)}},Rdt=async({circuitJson:t,projectName:e,options:n={}})=>{try{const{convertCircuitJsonToLbrn:o}=await $S("circuit-json-to-lbrn"),i=(await o(t,{includeSilkscreen:n.includeSilkscreen??!1,includeOxidationCleaningLayer:n.includeOxidationCleaningLayer??!0})).toXml(),s=new Blob([i],{type:"application/lbrn"});Lv(s,{fileName:`${e}.lbrn2`})}catch(o){const r=o instanceof Error?o.message:"Unknown error";Es.error(`Failed to export to LBRN format: ${r}`)}},tJn=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"},nJn=[{extension:"json",name:"Circuit 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"}],oJn=async({exportName:t,circuitJson:e,projectName:n})=>{const o=tJn(n);if(t==="Fabrication Files"){Gqn({circuitJson:e,projectName:o});return}if(t==="KiCad Project"){await Kqn({circuitJson:e,projectName:o});return}if(t==="KiCad Library"){await Zqn({circuitJson:e,projectName:o});return}if(t==="Circuit JSON"){Lv(JSON.stringify(e,null,2),{fileName:`${o}.circuit.json`,mimeType:"application/json"});return}if(t==="GLB (Binary GLTF)"){await Yqn({circuitJson:e,projectName:o});return}if(t==="Pinout SVG"){qqn({circuitJson:e,projectName:o});return}if(t==="STEP"){await eJn({circuitJson:e,projectName:o});return}if(t==="LightBurn"){await Rdt({circuitJson:e,projectName:o});return}throw new Error(`Unsupported export type: "${t}"`)};class WS extends Error{response;request;options;constructor(e,n,o){const r=e.status||e.status===0?e.status:"",i=e.statusText??"",s=`${r} ${i}`.trim(),a=s?`status code ${s}`:"an unknown error";super(`Request failed with ${a}: ${n.method} ${n.url}`),this.name="HTTPError",this.response=e,this.request=n,this.options=o}}class kdt extends Error{name="NonError";value;constructor(e){let n="Non-error value was thrown";try{typeof e=="string"?n=e:e&&typeof e=="object"&&"message"in e&&typeof e.message=="string"&&(n=e.message)}catch{}super(n),this.value=e}}class oye extends Error{name="ForceRetryError";customDelay;code;customRequest;constructor(e){const n=e?.cause?e.cause instanceof Error?e.cause:new kdt(e.cause):void 0;super(e?.code?`Forced retry: ${e.code}`:"Forced retry",n?{cause:n}:void 0),this.customDelay=e?.delay,this.code=e?.code,this.customRequest=e?.request}}const Ndt=(()=>{let t=!1,e=!1;const n=typeof globalThis.ReadableStream=="function",o=typeof globalThis.Request=="function";if(n&&o)try{e=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return t=!0,"half"}}).headers.has("Content-Type")}catch(r){if(r instanceof Error&&r.message==="unsupported BodyInit type")return!1;throw r}return t&&!e})(),rJn=typeof globalThis.AbortController=="function",Hdt=typeof globalThis.AbortSignal=="function"&&typeof globalThis.AbortSignal.any=="function",iJn=typeof globalThis.ReadableStream=="function",sJn=typeof globalThis.FormData=="function",Idt=["get","post","put","patch","head","delete"],aJn={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},rye=2147483647,cJn=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,Ldt=Symbol("stop");class Odt{options;constructor(e){this.options=e}}const lJn=t=>new Odt(t),uJn={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0,context:!0},_Jn={next:!0},dJn={method:!0,headers:!0,body:!0,mode:!0,credentials:!0,cache:!0,redirect:!0,referrer:!0,referrerPolicy:!0,integrity:!0,keepalive:!0,signal:!0,window:!0,duplex:!0},hJn=t=>{if(!t)return 0;if(t instanceof FormData){let e=0;for(const[n,o]of t)e+=cJn,e+=new TextEncoder().encode(`Content-Disposition: form-data; name="${n}"`).length,e+=typeof o=="string"?new TextEncoder().encode(o).length:o.size;return e}if(t instanceof Blob)return t.size;if(t instanceof ArrayBuffer)return t.byteLength;if(typeof t=="string")return new TextEncoder().encode(t).length;if(t instanceof URLSearchParams)return new TextEncoder().encode(t.toString()).length;if("byteLength"in t)return t.byteLength;if(typeof t=="object"&&t!==null)try{const e=JSON.stringify(t);return new TextEncoder().encode(e).length}catch{return 0}return 0},Fdt=(t,e,n)=>{let o,r=0;return t.pipeThrough(new TransformStream({transform(i,s){if(s.enqueue(i),o){r+=o.byteLength;let a=e===0?0:r/e;a>=1&&(a=1-Number.EPSILON),n?.({percent:a,totalBytes:Math.max(e,r),transferredBytes:r},o)}o=i},flush(){o&&(r+=o.byteLength,n?.({percent:1,totalBytes:Math.max(e,r),transferredBytes:r},o))}}))},mJn=(t,e)=>{if(!t.body)return t;if(t.status===204)return new Response(null,{status:t.status,statusText:t.statusText,headers:t.headers});const n=Math.max(0,Number(t.headers.get("content-length"))||0);return new Response(Fdt(t.body,n,e),{status:t.status,statusText:t.statusText,headers:t.headers})},pJn=(t,e,n)=>{if(!t.body)return t;const o=hJn(n??t.body);return new Request(t,{duplex:"half",body:Fdt(t.body,o,e)})},US=t=>t!==null&&typeof t=="object",zG=(...t)=>{for(const e of t)if((!US(e)||Array.isArray(e))&&e!==void 0)throw new TypeError("The `options` argument must be an object");return iye({},...t)},Bdt=(t={},e={})=>{const n=new globalThis.Headers(t),o=e instanceof globalThis.Headers,r=new globalThis.Headers(e);for(const[i,s]of r.entries())o&&s==="undefined"||s===void 0?n.delete(i):n.set(i,s);return n};function VG(t,e,n){return Object.hasOwn(e,n)&&e[n]===void 0?[]:iye(t[n]??[],e[n]??[])}const zdt=(t={},e={})=>({beforeRequest:VG(t,e,"beforeRequest"),beforeRetry:VG(t,e,"beforeRetry"),afterResponse:VG(t,e,"afterResponse"),beforeError:VG(t,e,"beforeError")}),fJn=(t,e)=>{const n=new URLSearchParams;for(const o of[t,e])if(o!==void 0)if(o instanceof URLSearchParams)for(const[r,i]of o.entries())n.append(r,i);else if(Array.isArray(o))for(const r of o){if(!Array.isArray(r)||r.length!==2)throw new TypeError("Array search parameters must be provided in [[key, value], ...] format");n.append(String(r[0]),String(r[1]))}else if(US(o))for(const[r,i]of Object.entries(o))i!==void 0&&n.append(r,String(i));else{const r=new URLSearchParams(o);for(const[i,s]of r.entries())n.append(i,s)}return n},iye=(...t)=>{let e={},n={},o={},r;const i=[];for(const s of t)if(Array.isArray(s))Array.isArray(e)||(e=[]),e=[...e,...s];else if(US(s)){for(let[a,c]of Object.entries(s)){if(a==="signal"&&c instanceof globalThis.AbortSignal){i.push(c);continue}if(a==="context"){if(c!=null&&(!US(c)||Array.isArray(c)))throw new TypeError("The `context` option must be an object");e={...e,context:c==null?{}:{...e.context,...c}};continue}if(a==="searchParams"){c==null?r=void 0:r=r===void 0?c:fJn(r,c);continue}US(c)&&a in e&&(c=iye(e[a],c)),e={...e,[a]:c}}US(s.hooks)&&(o=zdt(o,s.hooks),e.hooks=o),US(s.headers)&&(n=Bdt(n,s.headers),e.headers=n)}return r!==void 0&&(e.searchParams=r),i.length>0&&(i.length===1?e.signal=i[0]:Hdt?e.signal=AbortSignal.any(i):e.signal=i.at(-1)),e},xJn=t=>Idt.includes(t)?t.toUpperCase():t,Vdt={limit:2,methods:["get","put","head","delete","options","trace"],statusCodes:[408,413,429,500,502,503,504],afterStatusCodes:[413,429,503],maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:t=>.3*2**(t-1)*1e3,jitter:void 0,retryOnTimeout:!1},gJn=(t={})=>{if(typeof t=="number")return{...Vdt,limit:t};if(t.methods&&!Array.isArray(t.methods))throw new Error("retry.methods must be an array");if(t.methods&&=t.methods.map(n=>n.toLowerCase()),t.statusCodes&&!Array.isArray(t.statusCodes))throw new Error("retry.statusCodes must be an array");const e=Object.fromEntries(Object.entries(t).filter(([,n])=>n!==void 0));return{...Vdt,...e}};class sye extends Error{request;constructor(e){super(`Request timed out: ${e.method} ${e.url}`),this.name="TimeoutError",this.request=e}}async function yJn(t,e,n,o){return new Promise((r,i)=>{const s=setTimeout(()=>{n&&n.abort(),i(new sye(t))},o.timeout);o.fetch(t,e).then(r).catch(i).then(()=>{clearTimeout(s)})})}async function bJn(t,{signal:e}){return new Promise((n,o)=>{e&&(e.throwIfAborted(),e.addEventListener("abort",r,{once:!0}));function r(){clearTimeout(i),o(e.reason)}const i=setTimeout(()=>{e?.removeEventListener("abort",r),n()},t)})}const PJn=(t,e)=>{const n={};for(const o in e)Object.hasOwn(e,o)&&!(o in dJn)&&!(o in uJn)&&(!(o in t)||o in _Jn)&&(n[o]=e[o]);return n},vJn=t=>t===void 0?!1:Array.isArray(t)?t.length>0:t instanceof URLSearchParams?t.size>0:typeof t=="object"?Object.keys(t).length>0:typeof t=="string"?t.trim().length>0:!!t;function SJn(t){return t instanceof WS||t?.name===WS.name}function CJn(t){return t instanceof sye||t?.name===sye.name}class jH{static create(e,n){const o=new jH(e,n),r=async()=>{if(typeof o.#e.timeout=="number"&&o.#e.timeout>rye)throw new RangeError(`The \`timeout\` option cannot be greater than ${rye}`);await Promise.resolve();let s=await o.#x();for(const a of o.#e.hooks.afterResponse){const c=o.#d(s.clone());let l;try{l=await a(o.request,o.#c(),c,{retryCount:o.#n})}catch(_){throw o.#i(c),o.#i(s),_}if(l instanceof Odt)throw o.#i(c),o.#i(s),new oye(l.options);const u=l instanceof globalThis.Response?l:s;c!==u&&o.#i(c),s!==u&&o.#i(s),s=u}if(o.#d(s),!s.ok&&(typeof o.#e.throwHttpErrors=="function"?o.#e.throwHttpErrors(s.status):o.#e.throwHttpErrors)){let a=new WS(s,o.request,o.#c());for(const c of o.#e.hooks.beforeError)a=await c(a,{retryCount:o.#n});throw a}if(o.#e.onDownloadProgress){if(typeof o.#e.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!iJn)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");const a=s.clone();return o.#i(s),mJn(a,o.#e.onDownloadProgress)}return s},i=o.#h(r).finally(()=>{const s=o.#s;o.#u(s?.body??void 0),o.#u(o.request.body??void 0)});for(const[s,a]of Object.entries(aJn))s==="bytes"&&typeof globalThis.Response?.prototype?.bytes!="function"||(i[s]=async()=>{o.request.headers.set("accept",o.request.headers.get("accept")||a);const c=await i;if(s==="json"){if(c.status===204)return"";const l=await c.text();return l===""?"":n.parseJson?n.parseJson(l):JSON.parse(l)}return c[s]()});return i}static#p(e){return e&&typeof e=="object"&&!Array.isArray(e)&&!(e instanceof URLSearchParams)?Object.fromEntries(Object.entries(e).filter(([,n])=>n!==void 0)):e}request;#o;#n=0;#t;#e;#s;#r;#a;constructor(e,n={}){if(this.#t=e,this.#e={...n,headers:Bdt(this.#t.headers,n.headers),hooks:zdt({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},n.hooks),method:xJn(n.method??this.#t.method??"GET"),prefixUrl:String(n.prefixUrl||""),retry:gJn(n.retry),throwHttpErrors:n.throwHttpErrors??!0,timeout:n.timeout??1e4,fetch:n.fetch??globalThis.fetch.bind(globalThis),context:n.context??{}},typeof this.#t!="string"&&!(this.#t instanceof URL||this.#t instanceof globalThis.Request))throw new TypeError("`input` must be a string, URL, or Request");if(this.#e.prefixUrl&&typeof this.#t=="string"){if(this.#t.startsWith("/"))throw new Error("`input` must not begin with a slash when using `prefixUrl`");this.#e.prefixUrl.endsWith("/")||(this.#e.prefixUrl+="/"),this.#t=this.#e.prefixUrl+this.#t}rJn&&Hdt&&(this.#r=this.#e.signal??this.#t.signal,this.#o=new globalThis.AbortController,this.#e.signal=this.#r?AbortSignal.any([this.#r,this.#o.signal]):this.#o.signal),Ndt&&(this.#e.duplex="half"),this.#e.json!==void 0&&(this.#e.body=this.#e.stringifyJson?.(this.#e.json)??JSON.stringify(this.#e.json),this.#e.headers.set("content-type",this.#e.headers.get("content-type")??"application/json"));const o=n.headers&&new globalThis.Headers(n.headers).has("content-type");if(this.#t instanceof globalThis.Request&&(sJn&&this.#e.body instanceof globalThis.FormData||this.#e.body instanceof URLSearchParams)&&!o&&this.#e.headers.delete("content-type"),this.request=new globalThis.Request(this.#t,this.#e),vJn(this.#e.searchParams)){const i="?"+(typeof this.#e.searchParams=="string"?this.#e.searchParams.replace(/^\?/,""):new URLSearchParams(jH.#p(this.#e.searchParams)).toString()),s=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,i);this.request=new globalThis.Request(s,this.#e)}if(this.#e.onUploadProgress){if(typeof this.#e.onUploadProgress!="function")throw new TypeError("The `onUploadProgress` option must be a function");if(!Ndt)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request=this.#m(this.request,this.#e.body??void 0)}}#l(){const e=this.#e.retry.delay(this.#n);let n=e;this.#e.retry.jitter===!0?n=Math.random()*e:typeof this.#e.retry.jitter=="function"&&(n=this.#e.retry.jitter(e),(!Number.isFinite(n)||n<0)&&(n=e));const o=this.#e.retry.backoffLimit??Number.POSITIVE_INFINITY;return Math.min(o,n)}async#f(e){if(this.#n++,this.#n>this.#e.retry.limit)throw e;const n=e instanceof Error?e:new kdt(e);if(n instanceof oye)return n.customDelay??this.#l();if(!this.#e.retry.methods.includes(this.request.method.toLowerCase()))throw e;if(this.#e.retry.shouldRetry!==void 0){const o=await this.#e.retry.shouldRetry({error:n,retryCount:this.#n});if(o===!1)throw e;if(o===!0)return this.#l()}if(CJn(e)&&!this.#e.retry.retryOnTimeout)throw e;if(SJn(e)){if(!this.#e.retry.statusCodes.includes(e.response.status))throw e;const o=e.response.headers.get("Retry-After")??e.response.headers.get("RateLimit-Reset")??e.response.headers.get("X-RateLimit-Retry-After")??e.response.headers.get("X-RateLimit-Reset")??e.response.headers.get("X-Rate-Limit-Reset");if(o&&this.#e.retry.afterStatusCodes.includes(e.response.status)){let r=Number(o)*1e3;Number.isNaN(r)?r=Date.parse(o)-Date.now():r>=Date.parse("2024-01-01")&&(r-=Date.now());const i=this.#e.retry.maxRetryAfter??r;return r<i?r:i}if(e.response.status===413)throw e}return this.#l()}#d(e){return this.#e.parseJson&&(e.json=async()=>this.#e.parseJson(await e.text())),e}#u(e){e&&e.cancel().catch(()=>{})}#i(e){this.#u(e.body??void 0)}async#h(e){try{return await e()}catch(n){const o=Math.min(await this.#f(n),rye);if(this.#n<1)throw n;if(await bJn(o,this.#r?{signal:this.#r}:{}),n instanceof oye&&n.customRequest){const r=this.#e.signal?new globalThis.Request(n.customRequest,{signal:this.#e.signal}):new globalThis.Request(n.customRequest);this.#_(r)}for(const r of this.#e.hooks.beforeRetry){const i=await r({request:this.request,options:this.#c(),error:n,retryCount:this.#n});if(i instanceof globalThis.Request){this.#_(i);break}if(i instanceof globalThis.Response)return i;if(i===Ldt)return}return this.#h(e)}}async#x(){this.#o?.signal.aborted&&(this.#o=new globalThis.AbortController,this.#e.signal=this.#r?AbortSignal.any([this.#r,this.#o.signal]):this.#o.signal,this.request=new globalThis.Request(this.request,{signal:this.#e.signal}));for(const n of this.#e.hooks.beforeRequest){const o=await n(this.request,this.#c(),{retryCount:this.#n});if(o instanceof Response)return o;if(o instanceof globalThis.Request){this.#_(o);break}}const e=PJn(this.request,this.#e);return this.#s=this.request,this.request=this.#s.clone(),this.#e.timeout===!1?this.#e.fetch(this.#s,e):yJn(this.#s,e,this.#o,this.#e)}#c(){if(!this.#a){const{hooks:e,...n}=this.#e;this.#a=Object.freeze(n)}return this.#a}#_(e){this.#a=void 0,this.request=this.#m(e)}#m(e,n){return!this.#e.onUploadProgress||!e.body?e:pJn(e,this.#e.onUploadProgress,n??this.#e.body??void 0)}}const aye=t=>{const e=(n,o)=>jH.create(n,zG(t,o));for(const n of Idt)e[n]=(o,r)=>jH.create(o,zG(t,r,{method:n}));return e.create=n=>aye(zG(n)),e.extend=n=>(typeof n=="function"&&(n=n(t??{})),aye(zG(t,n))),e.stop=Ldt,e.retry=lJn,e},MJn=aye();class TJn extends WS{constructor(e,n,o,r){super(e,n,o),this.name="RegistryHTTPError",this.message=r}}function $G(t){return typeof window<"u"?window[t]:null}function XS(){const t=$G("TSCIRCUIT_REGISTRY_API_BASE_URL")||void 0||"https://registry-api.tscircuit.com",e=$G("TSCIRCUIT_REGISTRY_TOKEN");return MJn.create({prefixUrl:t,headers:{Authorization:`Bearer ${e}`},timeout:3e4,hooks:{afterResponse:[async(n,o,r)=>{if(r.ok)return r;let i=null;try{i=await r.clone().json()}catch(_){console.error("Failed to parse registry error response",_)}const s=i?.error?.message??i?.error?.error_message??i?.message,a=i?.error?.error_code??i?.error_code,c=new URL(r.url),u=[`Registry request failed for ${`${c.pathname}${c.search}`} (${r.status})`];throw s&&u.push(`Server message: ${s}`),a&&u.push(`Error code: ${a}`),new TJn(r,n,o,u.join(" | "))}]}})}function WG(){return!!$G("TSCIRCUIT_REGISTRY_TOKEN")}const UG={get:(t,e)=>XS().get(t,e),post:(t,e)=>XS().post(t,e),put:(t,e)=>XS().put(t,e),delete:(t,e)=>XS().delete(t,e),patch:(t,e)=>XS().patch(t,e)},wJn=({packageName:t,onSelectReview:e})=>{const n=m3(_=>_.fsMap),o=m3(_=>_.circuitJson),[r,i]=te.useState([]),[s,a]=te.useState(!1),[c,l]=te.useState(!1);te.useEffect(()=>{!t||!WG()||(a(!0),UG.get("ai_reviews/list",{searchParams:{package_name:t}}).json().then(_=>i(_.ai_reviews)).catch(_=>{console.error("Failed to load AI reviews",_),Es.error("Failed to load AI reviews")}).finally(()=>a(!1)))},[t]);const u=async()=>{if(!o){Es.error("Need Circuit JSON to Request AI Review");return}if(!WG()){Es.error("Missing registry token");return}l(!0);try{const{ai_review:_}=await UG.post("ai_reviews/create",{json:{package_name:t??"unknown",fs_map:Object.fromEntries(n),circuit_json:o}}).json();i(d=>[_,...d]),e(_),Es.success("AI review requested")}catch(_){console.error("Failed to create AI review",_),Es.error("Failed to request AI review")}finally{l(!1)}};return G.jsxs(G.Fragment,{children:[G.jsxs(LE,{children:[G.jsx(OE,{children:"AI Review"}),G.jsx(UH,{children:"Select an AI review or request a new one."})]}),G.jsx("div",{className:"rf-flex rf-gap-4 rf-mt-4",children:G.jsx("div",{className:"rf-w-48 rf-h-64 rf-overflow-y-auto rf-border rf-rounded rf-p-2 rf-flex-shrink-0",children:s?G.jsx("div",{className:"rf-text-sm",children:"Loading..."}):r.length>0?r.map(_=>G.jsx("div",{className:"rf-text-sm rf-p-2 rf-cursor-pointer rf-rounded hover:rf-bg-zinc-100",onClick:()=>e(_),children:new Date(_.created_at||"").toLocaleString()},_.ai_review_id)):G.jsx("div",{className:"rf-text-sm rf-text-muted-foreground",children:"No AI reviews found."})})}),G.jsx(WH,{className:"rf-mt-4",children:G.jsx(w0,{onClick:u,disabled:c,children:c?"Requesting...":"Review my Board"})})]})};function cye(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var jS=cye();function $dt(t){jS=t}var GH={exec:()=>null};function Oc(t,e=""){let n=typeof t=="string"?t:t.source;const o={replace:(r,i)=>{let s=typeof i=="string"?i:i.source;return s=s.replace(h2.caret,"$1"),n=n.replace(r,s),o},getRegex:()=>new RegExp(n,e)};return o}var h2={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:t=>new RegExp(`^( {0,3}${t})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}#`),htmlBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}<(?:[a-z].*>|!--)`,"i")},EJn=/^(?:[ \t]*(?:\n|$))+/,DJn=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,AJn=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,YH=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,RJn=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,lye=/(?:[*+-]|\d{1,9}[.)])/,Wdt=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Udt=Oc(Wdt).replace(/bull/g,lye).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(),kJn=Oc(Wdt).replace(/bull/g,lye).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(),uye=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,NJn=/^[^\n]+/,_ye=/(?!\s*\])(?:\\.|[^\[\]\\])+/,HJn=Oc(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",_ye).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),IJn=Oc(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,lye).getRegex(),XG="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",dye=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,LJn=Oc("^ {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",dye).replace("tag",XG).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Xdt=Oc(uye).replace("hr",YH).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",XG).getRegex(),OJn=Oc(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Xdt).getRegex(),hye={blockquote:OJn,code:DJn,def:HJn,fences:AJn,heading:RJn,hr:YH,html:LJn,lheading:Udt,list:IJn,newline:EJn,paragraph:Xdt,table:GH,text:NJn},jdt=Oc("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",YH).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",XG).getRegex(),FJn={...hye,lheading:kJn,table:jdt,paragraph:Oc(uye).replace("hr",YH).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",jdt).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",XG).getRegex()},BJn={...hye,html:Oc(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",dye).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:GH,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Oc(uye).replace("hr",YH).replace("heading",` *#{1,6} *[^
5711
5711
  ]`).replace("lheading",Udt).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},zJn=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,VJn=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Gdt=/^( {2,}|\\)\n(?!\s*$)/,$Jn=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,jG=/[\p{P}\p{S}]/u,mye=/[\s\p{P}\p{S}]/u,Ydt=/[^\s\p{P}\p{S}]/u,WJn=Oc(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,mye).getRegex(),qdt=/(?!~)[\p{P}\p{S}]/u,UJn=/(?!~)[\s\p{P}\p{S}]/u,XJn=/(?:[^\s\p{P}\p{S}]|~)/u,jJn=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,Jdt=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,GJn=Oc(Jdt,"u").replace(/punct/g,jG).getRegex(),YJn=Oc(Jdt,"u").replace(/punct/g,qdt).getRegex(),Kdt="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",qJn=Oc(Kdt,"gu").replace(/notPunctSpace/g,Ydt).replace(/punctSpace/g,mye).replace(/punct/g,jG).getRegex(),JJn=Oc(Kdt,"gu").replace(/notPunctSpace/g,XJn).replace(/punctSpace/g,UJn).replace(/punct/g,qdt).getRegex(),KJn=Oc("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Ydt).replace(/punctSpace/g,mye).replace(/punct/g,jG).getRegex(),QJn=Oc(/\\(punct)/,"gu").replace(/punct/g,jG).getRegex(),ZJn=Oc(/^<(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(),eKn=Oc(dye).replace("(?:-->|$)","-->").getRegex(),tKn=Oc("^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",eKn).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),GG=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,nKn=Oc(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",GG).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Qdt=Oc(/^!?\[(label)\]\[(ref)\]/).replace("label",GG).replace("ref",_ye).getRegex(),Zdt=Oc(/^!?\[(ref)\](?:\[\])?/).replace("ref",_ye).getRegex(),oKn=Oc("reflink|nolink(?!\\()","g").replace("reflink",Qdt).replace("nolink",Zdt).getRegex(),pye={_backpedal:GH,anyPunctuation:QJn,autolink:ZJn,blockSkip:jJn,br:Gdt,code:VJn,del:GH,emStrongLDelim:GJn,emStrongRDelimAst:qJn,emStrongRDelimUnd:KJn,escape:zJn,link:nKn,nolink:Zdt,punctuation:WJn,reflink:Qdt,reflinkSearch:oKn,tag:tKn,text:$Jn,url:GH},rKn={...pye,link:Oc(/^!?\[(label)\]\((.*?)\)/).replace("label",GG).getRegex(),reflink:Oc(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",GG).getRegex()},fye={...pye,emStrongRDelimAst:JJn,emStrongLDelim:YJn,url:Oc(/^((?: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.!#$%&'*+\/=?_`{\|}~-]+@)))/},iKn={...fye,br:Oc(Gdt).replace("{2,}","*").getRegex(),text:Oc(fye.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},YG={normal:hye,gfm:FJn,pedantic:BJn},qH={normal:pye,gfm:fye,breaks:iKn,pedantic:rKn},sKn={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},eht=t=>sKn[t];function f3(t,e){if(e){if(h2.escapeTest.test(t))return t.replace(h2.escapeReplace,eht)}else if(h2.escapeTestNoEncode.test(t))return t.replace(h2.escapeReplaceNoEncode,eht);return t}function tht(t){try{t=encodeURI(t).replace(h2.percentDecode,"%")}catch{return null}return t}function nht(t,e){const n=t.replace(h2.findPipe,(i,s,a)=>{let c=!1,l=s;for(;--l>=0&&a[l]==="\\";)c=!c;return c?"|":" |"}),o=n.split(h2.splitPipe);let r=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(;r<o.length;r++)o[r]=o[r].trim().replace(h2.slashPipe,"|");return o}function JH(t,e,n){const o=t.length;if(o===0)return"";let r=0;for(;r<o&&t.charAt(o-r-1)===e;)r++;return t.slice(0,o-r)}function aKn(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 oht(t,e,n,o,r){const i=e.href,s=e.title||null,a=t[1].replace(r.other.outputLinkReplace,"$1");o.state.inLink=!0;const c={type:t[0].charAt(0)==="!"?"image":"link",raw:n,href:i,title:s,text:a,tokens:o.inlineTokens(a)};return o.state.inLink=!1,c}function cKn(t,e,n){const o=t.match(n.other.indentCodeCompensation);if(o===null)return e;const r=o[1];return e.split(`
5712
5712
  `).map(i=>{const s=i.match(n.other.beginningSpace);if(s===null)return i;const[a]=s;return a.length>=r.length?i.slice(r.length):i}).join(`
5713
5713
  `)}var qG=class{options;rules;lexer;constructor(t){this.options=t||jS}space(t){const e=this.rules.block.newline.exec(t);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(t){const e=this.rules.block.code.exec(t);if(e){const n=e[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:e[0],codeBlockStyle:"indented",text:this.options.pedantic?n:JH(n,`