@tscircuit/runframe 0.0.2406 → 0.0.2408

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.
@@ -997,10 +997,10 @@ orientation: ${n.orientation}
997
997
  moving: ${e}`}),t.points.push({x:n.anchor.x,y:n.anchor.y,color:o,label:`candidate anchor
998
998
  ${n.status}`})}return t}},yx=.2,mee=1e-9,oHn="GND",S3=(t,e)=>Math.abs(t.x-e.x)<=mee&&Math.abs(t.y-e.y)<=mee,LN=t=>{const e=[];for(const n of t){const o=e.at(-1);(!o||!S3(o,n))&&e.push(n)}return e},Iee=t=>{let e=0;for(let n=0;n<t.length-1;n++){const o=t[n],i=t[n+1];e+=Math.abs(i.x-o.x)+Math.abs(i.y-o.y)}return e},U1e=({pin:t,facingDirection:e})=>{const n={x:t.x,y:t.y};return e==="x+"&&(n.x+=yx),e==="x-"&&(n.x-=yx),e==="y+"&&(n.y+=yx),e==="y-"&&(n.y-=yx),n},Adt=t=>({minX:Math.min(...t.map(e=>e.minX)),minY:Math.min(...t.map(e=>e.minY)),maxX:Math.max(...t.map(e=>e.maxX)),maxY:Math.max(...t.map(e=>e.maxY))}),iHn=({connectionPair:t,obstacles:e})=>{const[n,o]=t.pins,i=U1e({pin:n,facingDirection:n._facingDirection}),r=U1e({pin:o,facingDirection:o._facingDirection}),s=Adt(e),a=[s.minY-yx,s.maxY+yx],A=[s.minX-yx,s.maxX+yx],c=[];for(const l of a)c.push(LN([n,i,{x:i.x,y:l},{x:r.x,y:l},r,o]));for(const l of A)c.push(LN([n,i,{x:l,y:i.y},{x:l,y:r.y},r,o]));return c.sort((l,g)=>Iee(l)-Iee(g))},rHn=(t,e)=>({x:(t.x+e.x)/2,y:(t.y+e.y)/2}),sHn=t=>{const e=[];for(const n of t){for(let i=0;i<n.tracePath.length-1;i++){const r=n.tracePath[i],s=n.tracePath[i+1];e.push(r),e.push(rHn(r,s))}const o=n.tracePath.at(-1);o&&e.push(o)}return e},aHn=({connectionPair:t,sameNetTraces:e})=>{const n=new Set(e.flatMap(o=>o.pinIds));return t.pins.filter(o=>!n.has(o.pinId))},AHn=({connectionPair:t,sameNetTraces:e,obstacles:n,maxConnectionDistance:o})=>{const i=Adt(n),r=[i.minY-yx,i.maxY+yx],s=[i.minX-yx,i.maxX+yx],a=[],A=sHn(e),c=aHn({connectionPair:t,sameNetTraces:e});for(const l of c){const g=U1e({pin:l,facingDirection:l._facingDirection});for(const u of A)if(!(Vl(l,u)>o)){a.push(LN([l,g,{x:g.x,y:u.y},u])),a.push(LN([l,g,{x:u.x,y:g.y},u]));for(const h of r)a.push(LN([l,g,{x:g.x,y:h},{x:u.x,y:h},u]));for(const h of s)a.push(LN([l,g,{x:h,y:g.y},{x:h,y:u.y},u]))}}return a.sort((l,g)=>Iee(l)-Iee(g))},cHn=({path:t,obstacles:e,connectionPair:n,rejectComponentBoundaryTravel:o})=>{const i=t[0],r=t.at(-1),s=n.pins.find(u=>S3(u,i)),a=n.pins.find(u=>S3(u,r)),A=s!==void 0&&a!==void 0,c=e.find(u=>u.kind==="chip"&&u.chipId===s?.chipId),l=e.find(u=>u.kind==="chip"&&u.chipId===a?.chipId);return o&&c&&f1e(t[0],t[1],c)||o&&l&&f1e(t[t.length-2],t[t.length-1],l)?!0:hO(t,e,{excludeRectsForSegment:u=>{const h=new Set;return u===0&&c&&h.add(c),A&&u===t.length-2&&l&&h.add(l),h}})!==null},lHn=({connectionPair:t,failedConnectionPairs:e})=>{const n=new Set(t.pins.map(o=>o.chipId));return e.some(o=>o.mspPairId===t.mspPairId?!1:o.pins.every(i=>n.has(i.chipId)))},gHn=({firstStart:t,firstEnd:e,secondStart:n,secondEnd:o})=>vp(t,e)&&vp(n,o)?Math.min(Math.max(t.x,e.x),Math.max(n.x,o.x))-Math.max(Math.min(t.x,e.x),Math.min(n.x,o.x))>mee:Dm(t,e)&&Dm(n,o)?Math.min(Math.max(t.y,e.y),Math.max(n.y,o.y))-Math.max(Math.min(t.y,e.y),Math.min(n.y,o.y))>mee:!1,uHn=({connectionPair:t,existingTrace:e})=>{const n=new Set(e.pinIds);return t.pins.filter(o=>n.has(o.pinId))},dHn=({path:t,connectionPair:e,existingTraces:n})=>{for(const o of n){if(o.globalConnNetId===e.globalConnNetId)continue;const i=uHn({connectionPair:e,existingTrace:o});for(let r=0;r<t.length-1;r++){const s=t[r],a=t[r+1];for(let A=0;A<o.tracePath.length-1;A++){const c=o.tracePath[A],l=o.tracePath[A+1];if(!(!OC(s,a,c,l)||i.some(u=>(S3(s,u)||S3(a,u))&&(S3(c,u)||S3(l,u)))&&!gHn({firstStart:s,firstEnd:a,secondStart:c,secondEnd:l})))return!0}}}return!1},hHn=class extends ed{constructor(t){super(),this.params=t,this.inputProblem=t.inputProblem,this.alreadySolvedTraces=t.alreadySolvedTraces,this.failedConnectionPairs=t.failedConnectionPairs,this.queuedConnectionPairs=[...t.failedConnectionPairs],this.maxConnectionDistance=this.inputProblem.maxMspPairDistance??Kgt;const{netConnMap:e}=JZ(this.inputProblem);this.groundGlobalConnNetId=e.getNetConnectedToId(oHn)??void 0}params;inputProblem;alreadySolvedTraces;failedConnectionPairs;queuedConnectionPairs;maxConnectionDistance;groundGlobalConnNetId;solvedUnroutedTraces=[];getConstructorParams(){return this.params}_step(){const t=this.queuedConnectionPairs.shift();if(!t){this.solved=!0;return}if(t.globalConnNetId===this.groundGlobalConnNetId||Vl(t.pins[0],t.pins[1])>this.maxConnectionDistance)return;const e=px(this.inputProblem),n=[...this.alreadySolvedTraces,...this.solvedUnroutedTraces],o=n.filter(A=>A.globalConnNetId===t.globalConnNetId),i=AHn({connectionPair:t,sameNetTraces:o,obstacles:e,maxConnectionDistance:this.maxConnectionDistance}),r=iHn({connectionPair:t,obstacles:e}),s=[...i,...r],a=lHn({connectionPair:t,failedConnectionPairs:this.failedConnectionPairs});for(const A of s)if(!cHn({path:A,obstacles:e,connectionPair:t,rejectComponentBoundaryTravel:a})&&!dHn({path:A,connectionPair:t,existingTraces:n})){this.solvedUnroutedTraces.push({...t,tracePath:A,mspConnectionPairIds:[t.mspPairId],pinIds:t.pins.map(c=>c.pinId)});return}}getOutput(){return{newTraces:this.solvedUnroutedTraces,allTracesMerged:[...this.alreadySolvedTraces,...this.solvedUnroutedTraces]}}visualize(){const t=y0(this.inputProblem);for(const e of this.solvedUnroutedTraces)t.lines.push({points:e.tracePath,strokeColor:"blue"});return t}},fee=1e-6,cdt=({path:t,netLabelPlacements:e})=>{for(const n of e){const o=nl(n.center,n.width,n.height);for(let i=0;i<t.length-1;i++)if(D4(t[i],t[i+1],o))return!0}return!1},_Hn=({path:t,netLabelPlacements:e})=>{for(const n of e){const o=nl(n.center,n.width,n.height),i={minX:o.minX+fee,minY:o.minY+fee,maxX:o.maxX-fee,maxY:o.maxY-fee};for(let r=0;r<t.length-1;r++)if(D4(t[r],t[r+1],i))return!0}return!1},pHn=.2,mHn=.2,IHn=({donorTrace:t,branchTrace:e})=>{const n=new Set(e.pins.map(o=>o.pinId));return t.pins.find(o=>n.has(o.pinId))??null},ldt=({trace:t,sharedPin:e})=>t.pins.find(n=>n.pinId!==e.pinId)??null,Cee=t=>{let e=null;for(let n=0;n<t.tracePath.length-1;n++){const o=t.tracePath[n],i=t.tracePath[n+1];S1e(o,i)&&(!e||Math.abs(i.x-o.x)>Math.abs(e.end.x-e.start.x))&&(e={start:o,end:i})}return e},fHn=({segment:t,sharedPin:e})=>{const n=Math.abs(t.start.x-e.x),o=Math.abs(t.end.x-e.x);return n<=o?t.start:t.end},CHn=({railY:t,pin:e})=>e._facingDirection==="y+"?t>e.y:!1,yHn=({donorTrace:t,branchTrace:e})=>{const n=IHn({donorTrace:t,branchTrace:e});if(!n)return null;const o=ldt({trace:t,sharedPin:n});if(!o)return null;const i=ldt({trace:e,sharedPin:n});if(!i||Math.abs(n.y-i.y)>pHn)return null;const r=Cee(t);if(!r)return null;const s=Cee(e);if(s&&Ix(s.start.y,r.start.y)||!CHn({railY:r.start.y,pin:i}))return null;const a=fHn({segment:r,sharedPin:n});if(!(o.x<a.x&&i.x>a.x||o.x>a.x&&i.x<a.x))return null;const c=T_([{x:n.x,y:n.y},{x:a.x,y:n.y},{x:a.x,y:a.y},{x:i.x,y:a.y},{x:i.x,y:i.y}]);return e.pins[0].pinId===n.pinId?c:[...c].reverse()},EHn=({candidateTrace:t,originalTrace:e,traces:n,inputProblem:o,netLabelPlacements:i})=>{const r=px(o);if(_O(t.tracePath,r))return!1;const s=n.filter(g=>g.globalConnNetId!==t.globalConnNetId);if(eee(t.tracePath,s))return!1;const a=i.filter(g=>g.globalConnNetId!==t.globalConnNetId);if(cdt({path:t.tracePath,netLabelPlacements:a}))return!1;const A=i.filter(g=>g.globalConnNetId===t.globalConnNetId);if(!cdt({path:t.tracePath,netLabelPlacements:A}))return!0;if(_Hn({path:t.tracePath,netLabelPlacements:A}))return!1;const c=Cee(e),l=Cee(t);return!c||!l?!1:Math.abs(c.start.y-l.start.y)<=mHn},xHn=({inputProblem:t,traces:e,netLabelPlacements:n})=>{let o=[...e];const i=new Set;let r=0;for(const s of e.map(a=>a.mspPairId)){const a=o.find(A=>A.mspPairId===s);for(const A of o){if(i.has(A.mspPairId)||a.mspPairId===A.mspPairId||a.globalConnNetId!==A.globalConnNetId)continue;const c=yHn({donorTrace:a,branchTrace:A});if(!c)continue;const l={...A,tracePath:c},g=[a,A],u=[a,l],h=b1e(u)<b1e(g),d=kN(u)<kN(g)&&!Ix(kN(u),kN(g));!h&&!d||EHn({candidateTrace:l,originalTrace:A,traces:o,inputProblem:t,netLabelPlacements:n})&&(o=o.map(_=>_.mspPairId===A.mspPairId?l:_),i.add(A.mspPairId),r++)}}return{traces:o,alignedJunctionCount:r}},BHn=class extends ed{input;outputTraces;constructor(t){super(),this.input=t,this.outputTraces=t.traces}_step(){const t=xHn(this.input);this.outputTraces=t.traces,this.stats.alignedJunctionCount=t.alignedJunctionCount,this.solved=!0}getOutput(){return{traces:this.outputTraces,netLabelPlacements:this.input.netLabelPlacements}}visualize(){const t=y0(this.input.inputProblem);t.lines??=[],t.rects??=[],t.points??=[];for(const e of this.outputTraces)t.lines.push({points:e.tracePath,strokeColor:"purple"});for(const e of this.input.netLabelPlacements){const n={center:e.center,width:e.width,height:e.height,fill:DA(e.globalConnNetId,.35),strokeColor:DA(e.globalConnNetId,.9),label:`netId: ${e.netId}
999
999
  globalConnNetId: ${e.globalConnNetId}`};t.rects.push(n),t.points.push({x:e.anchorPoint.x,y:e.anchorPoint.y,color:DA(e.globalConnNetId,.9),label:`anchorPoint
1000
- orientation: ${e.orientation}`})}return t}},gdt=t=>{const e=T_(t);if(e.length!==6)return!1;const n=e.slice(0,-1).map((o,i)=>vp(o,e[i+1]));return n.every((o,i)=>i===0||o!==n[i-1])},QHn=({trace:t,label:e,paddingBuffer:n,detourCount:o})=>{if(t.globalConnNetId===e.globalConnNetId)return[];const i=T_(t.tracePath);if(!gdt(i))return[];const r=nl(e.center,e.width,e.height),s=n+o*n,a={minX:r.minX-s,maxX:r.maxX+s,minY:r.minY-s,maxY:r.maxY+s},A=[];for(let c=1;c<i.length-2;c++){const l=i[c],g=i[c+1];if(!bS(l,g,r))continue;const u=vp(l,g),h=Dm(l,g);if(!u&&!h)continue;const d=u?"y":"x",_=u?[a.minY,a.maxY]:[a.minX,a.maxX];for(const p of _){const m=C1e(i,c,d,p);m&&A.push(m)}}return A},SHn=({trace:t,label:e,paddingBuffer:n,detourCount:o})=>{const i=T_(t.tracePath);if(!gdt(i))return[];const r=nl(e.center,e.width,e.height),s=n+o*n,a={minX:r.minX-s,maxX:r.maxX+s,minY:r.minY-s,maxY:r.maxY+s},A=i[0],c=i[i.length-1],l=2,g=[];for(let u=0;u<i.length-1;u++){const h=i[u],d=i[u+1];if(!bS(h,d,r)||Math.abs(u-l)!==1)continue;const _=vp(h,d),p=Dm(h,d);if(!_&&!p)continue;const m=_?"x":"y",I=_?a.minX:a.minY,f=_?a.maxX:a.maxY,C=_?A.x:A.y,y=_?c.x:c.y,E=[];C<I?E.push((C+I)/2):C>f&&E.push((C+f)/2),y<I?E.push((y+I)/2):y>f&&E.push((y+f)/2);for(const B of new Set(E)){const Q=C1e(i,l,m,B);Q&&g.push(Q)}}return g},bHn=({trace:t,label:e,netLabelPlacements:n,paddingBuffer:o,detourCount:i})=>SHn({trace:t,label:e,paddingBuffer:o,detourCount:i}).flatMap(s=>{const a={...t,tracePath:s};return eh({traces:[a],netLabels:n}).flatMap(({label:c})=>QHn({trace:a,label:c,paddingBuffer:o,detourCount:i}))}),udt=1e-9,HN=t=>t.slice(1).reduce((e,n,o)=>{const i=t[o];return e+Math.abs(n.x-i.x)+Math.abs(n.y-i.y)},0),Y1e=class extends ed{input;outputTraces;traceIdQueue;obstacles;constructor(t){super(),this.input=t,this.outputTraces=[...t.traces];const e=new Set(t.completedReroutes.map(n=>n.initialTrace.mspPairId));this.traceIdQueue=t.traces.map(n=>n.mspPairId).filter(n=>e.has(n)),this.obstacles=px(t.inputProblem)}_step(){const t=this.traceIdQueue.shift();if(!t){this.solved=!0;return}const e=this.outputTraces.findIndex(h=>h.mspPairId===t),n=this.outputTraces[e],o=T_(n.tracePath),i=eh({traces:[{...n,tracePath:o}],netLabels:this.input.netLabelPlacements}),r=this.outputTraces.filter(h=>h.mspPairId!==n.mspPairId&&h.globalConnNetId!==n.globalConnNetId),s=new Map,a=this.input.completedReroutes.filter(h=>h.initialTrace.mspPairId===n.mspPairId);for(const h of a){const d=T_(h.initialTrace.tracePath),_=T_(h.reroutedTracePath),p=eh({traces:[{...h.initialTrace,tracePath:d}],netLabels:this.input.netLabelPlacements}).length,m=bHn({trace:h.initialTrace,label:h.label,netLabelPlacements:this.input.netLabelPlacements,paddingBuffer:this.input.paddingBuffer,detourCount:h.detourCount});for(const I of m){const f=T_(I),C={...h.initialTrace,tracePath:f};eh({traces:[C],netLabels:this.input.netLabelPlacements}).length<p&&Math.abs(HN(f)-HN(_))<udt&&f.length<_.length&&w1e(this.input.netLabelPlacements,[h.initialTrace],[C])&&s.set(f.map(B=>`${B.x},${B.y}`).join(";"),f)}}const A=new Set(i.map(({label:h})=>`${h.globalConnNetId}:${h.netId}`)),c=HN(o),l=[...s.values()].filter(h=>{const d={...n,tracePath:h},_=eh({traces:[d],netLabels:this.input.netLabelPlacements}),p=_.every(({label:f})=>A.has(`${f.globalConnNetId}:${f.netId}`)),m=_.length<i.length,I=_.length===i.length&&HN(h)<=c+udt&&h.length<o.length;return p&&(m||I)&&w1e(this.input.netLabelPlacements,[n],[d])&&!_O(h,this.obstacles)&&!eee(h,r)}),g=h=>eh({traces:[{...n,tracePath:h}],netLabels:this.input.netLabelPlacements}).length;l.sort((h,d)=>{const _=g(h)-g(d);return _!==0?_:HN(h)-HN(d)||h.length-d.length});const u=l[0];u&&(this.outputTraces[e]={...n,tracePath:u},this.stats.simplifiedTraceCount=(this.stats.simplifiedTraceCount??0)+1)}getOutput(){return{traces:this.outputTraces,netLabelPlacements:this.input.netLabelPlacements}}visualize(){const t=y0(this.input.inputProblem);t.lines??=[];for(const e of this.outputTraces)t.lines.push({points:e.tracePath,strokeColor:"purple"});return t}},DHn=(t,e=1e-6)=>{const n=[];let o=null,i=null,r=0;const s=a=>{if(o&&i){const A=Math.abs(i==="x"?a.x-o.x:a.y-o.y);A>e&&n.push({start:o,end:a,axis:i,length:A})}o=null,i=null,r=0};for(let a=0;a<t.length-1;a++){const A=t[a],c=t[a+1],l=c.x-A.x,g=c.y-A.y;if(Math.abs(l)<=e&&Math.abs(g)<=e)continue;const u=Math.abs(g)<=e?"x":Math.abs(l)<=e?"y":null;if(!u){s(A);continue}const h=Math.sign(u==="x"?l:g);o&&i===u&&r===h||(s(A),o=A,i=u,r=h)}return t.length>=2&&s(t[t.length-1]),n.sort((a,A)=>A.length-a.length)},ddt=.18,vHn=.05,PHn=.5,hdt=t=>[...t].sort().join("::"),wHn=class extends ed{inputProblem;traces;inputNetLabelPlacements;inlineNetLabelPlacements=[];queuedDirectConnections;tracesByPinPairKey;constructor(t){super(),this.inputProblem=t.inputProblem,this.traces=t.traces,this.inputNetLabelPlacements=t.netLabelPlacements,this.queuedDirectConnections=this.inputProblem.directConnections.filter(e=>e.allowInlineNetLabel&&e.netId),this.tracesByPinPairKey=new Map;for(const e of this.traces){const n=hdt(e.pins.map(i=>i.pinId)),o=this.tracesByPinPairKey.get(n);o?o.push(e):this.tracesByPinPairKey.set(n,[e])}}getConstructorParams(){return[{inputProblem:this.inputProblem,traces:this.traces,netLabelPlacements:this.inputNetLabelPlacements}]}_step(){const t=this.queuedDirectConnections.shift();if(!t){this.solved=!0,this.stats.inlineNetLabelCount=this.inlineNetLabelPlacements.length;return}const e=this.computeInlinePlacement(t);e&&this.inlineNetLabelPlacements.push(e)}computeInlinePlacement(t){const e=this.tracesByPinPairKey.get(hdt(t.pinIds))??[];if(e.length===0)return null;const n=e[0],o=DHn(n.tracePath);if(o.length===0)return null;const i=t.inlineNetLabelHeight??ddt,r=t.inlineNetLabelWidth??t.netLabelWidth??MHn(t.netId,i),s=i/2+vHn,a=o.filter(A=>A.length>=r*PHn).sort((A,c)=>{const l=A.length>=r,g=c.length>=r;return l!==g?l?-1:1:c.length-A.length});for(const A of a){const c=A.axis==="x"?["y+","y-"]:["x-","x+"];for(const l of c)for(const g of NHn(A,r)){const u=l==="y+"?{x:g.x,y:g.y+s}:l==="y-"?{x:g.x,y:g.y-s}:l==="x-"?{x:g.x-s,y:g.y}:{x:g.x+s,y:g.y},h=r/2,d=i/2,_=A.axis==="x"?{minX:u.x-h,maxX:u.x+h,minY:u.y-d,maxY:u.y+d}:{minX:u.x-d,maxX:u.x+d,minY:u.y-h,maxY:u.y+h};if(!this.isObstructed(_,n))return{globalConnNetId:n.globalConnNetId,netId:t.netId,mspPairId:n.mspPairId,pinIds:[...t.pinIds],axis:A.axis,anchorPoint:g,center:u,width:r,height:i,side:l}}}return null}isObstructed(t,e){for(const n of this.inputProblem.chips){const o={minX:n.center.x-n.width/2,maxX:n.center.x+n.width/2,minY:n.center.y-n.height/2,maxY:n.center.y+n.height/2};if(WZ(t,o))return!0}for(const n of this.inputProblem.textBoxes??[])if(WZ(t,qZ(n)))return!0;for(const n of this.traces)if(n.mspPairId!==e.mspPairId&&n.globalConnNetId!==e.globalConnNetId&&RHn(n.tracePath,t))return!0;return!1}getSupersededNetLabelKeys(){const t=new Set;for(const e of this.inlineNetLabelPlacements)t.add(e.globalConnNetId);return t}getOutput(){const t=this.getSupersededNetLabelKeys();return{traces:this.traces,netLabelPlacements:this.inputNetLabelPlacements.filter(e=>!t.has(e.globalConnNetId)),inlineNetLabelPlacements:this.inlineNetLabelPlacements}}visualize(){const t=y0(this.inputProblem);t.lines??=[],t.rects??=[],t.points??=[],t.texts??=[];for(const n of this.traces)t.lines.push({points:n.tracePath,strokeColor:"purple"});const{netLabelPlacements:e}=this.getOutput();for(const n of e)t.rects.push({center:n.center,width:n.width,height:n.height,fill:DA(n.globalConnNetId,.35),strokeColor:DA(n.globalConnNetId,.9),label:`netId: ${n.netId}
1000
+ orientation: ${e.orientation}`})}return t}},gdt=t=>{const e=T_(t);if(e.length!==6)return!1;const n=e.slice(0,-1).map((o,i)=>vp(o,e[i+1]));return n.every((o,i)=>i===0||o!==n[i-1])},QHn=({trace:t,label:e,paddingBuffer:n,detourCount:o})=>{if(t.globalConnNetId===e.globalConnNetId)return[];const i=T_(t.tracePath);if(!gdt(i))return[];const r=nl(e.center,e.width,e.height),s=n+o*n,a={minX:r.minX-s,maxX:r.maxX+s,minY:r.minY-s,maxY:r.maxY+s},A=[];for(let c=1;c<i.length-2;c++){const l=i[c],g=i[c+1];if(!bS(l,g,r))continue;const u=vp(l,g),h=Dm(l,g);if(!u&&!h)continue;const d=u?"y":"x",_=u?[a.minY,a.maxY]:[a.minX,a.maxX];for(const p of _){const m=C1e(i,c,d,p);m&&A.push(m)}}return A},SHn=({trace:t,label:e,paddingBuffer:n,detourCount:o})=>{const i=T_(t.tracePath);if(!gdt(i))return[];const r=nl(e.center,e.width,e.height),s=n+o*n,a={minX:r.minX-s,maxX:r.maxX+s,minY:r.minY-s,maxY:r.maxY+s},A=i[0],c=i[i.length-1],l=2,g=[];for(let u=0;u<i.length-1;u++){const h=i[u],d=i[u+1];if(!bS(h,d,r)||Math.abs(u-l)!==1)continue;const _=vp(h,d),p=Dm(h,d);if(!_&&!p)continue;const m=_?"x":"y",I=_?a.minX:a.minY,f=_?a.maxX:a.maxY,C=_?A.x:A.y,y=_?c.x:c.y,E=[];C<I?E.push((C+I)/2):C>f&&E.push((C+f)/2),y<I?E.push((y+I)/2):y>f&&E.push((y+f)/2);for(const B of new Set(E)){const Q=C1e(i,l,m,B);Q&&g.push(Q)}}return g},bHn=({trace:t,label:e,netLabelPlacements:n,paddingBuffer:o,detourCount:i})=>SHn({trace:t,label:e,paddingBuffer:o,detourCount:i}).flatMap(s=>{const a={...t,tracePath:s};return eh({traces:[a],netLabels:n}).flatMap(({label:c})=>QHn({trace:a,label:c,paddingBuffer:o,detourCount:i}))}),udt=1e-9,HN=t=>t.slice(1).reduce((e,n,o)=>{const i=t[o];return e+Math.abs(n.x-i.x)+Math.abs(n.y-i.y)},0),Y1e=class extends ed{input;outputTraces;traceIdQueue;obstacles;constructor(t){super(),this.input=t,this.outputTraces=[...t.traces];const e=new Set(t.completedReroutes.map(n=>n.initialTrace.mspPairId));this.traceIdQueue=t.traces.map(n=>n.mspPairId).filter(n=>e.has(n)),this.obstacles=px(t.inputProblem)}_step(){const t=this.traceIdQueue.shift();if(!t){this.solved=!0;return}const e=this.outputTraces.findIndex(h=>h.mspPairId===t),n=this.outputTraces[e],o=T_(n.tracePath),i=eh({traces:[{...n,tracePath:o}],netLabels:this.input.netLabelPlacements}),r=this.outputTraces.filter(h=>h.mspPairId!==n.mspPairId&&h.globalConnNetId!==n.globalConnNetId),s=new Map,a=this.input.completedReroutes.filter(h=>h.initialTrace.mspPairId===n.mspPairId);for(const h of a){const d=T_(h.initialTrace.tracePath),_=T_(h.reroutedTracePath),p=eh({traces:[{...h.initialTrace,tracePath:d}],netLabels:this.input.netLabelPlacements}).length,m=bHn({trace:h.initialTrace,label:h.label,netLabelPlacements:this.input.netLabelPlacements,paddingBuffer:this.input.paddingBuffer,detourCount:h.detourCount});for(const I of m){const f=T_(I),C={...h.initialTrace,tracePath:f};eh({traces:[C],netLabels:this.input.netLabelPlacements}).length<p&&Math.abs(HN(f)-HN(_))<udt&&f.length<_.length&&w1e(this.input.netLabelPlacements,[h.initialTrace],[C])&&s.set(f.map(B=>`${B.x},${B.y}`).join(";"),f)}}const A=new Set(i.map(({label:h})=>`${h.globalConnNetId}:${h.netId}`)),c=HN(o),l=[...s.values()].filter(h=>{const d={...n,tracePath:h},_=eh({traces:[d],netLabels:this.input.netLabelPlacements}),p=_.every(({label:f})=>A.has(`${f.globalConnNetId}:${f.netId}`)),m=_.length<i.length,I=_.length===i.length&&HN(h)<=c+udt&&h.length<o.length;return p&&(m||I)&&w1e(this.input.netLabelPlacements,[n],[d])&&!_O(h,this.obstacles)&&!eee(h,r)}),g=h=>eh({traces:[{...n,tracePath:h}],netLabels:this.input.netLabelPlacements}).length;l.sort((h,d)=>{const _=g(h)-g(d);return _!==0?_:HN(h)-HN(d)||h.length-d.length});const u=l[0];u&&(this.outputTraces[e]={...n,tracePath:u},this.stats.simplifiedTraceCount=(this.stats.simplifiedTraceCount??0)+1)}getOutput(){return{traces:this.outputTraces,netLabelPlacements:this.input.netLabelPlacements}}visualize(){const t=y0(this.input.inputProblem);t.lines??=[];for(const e of this.outputTraces)t.lines.push({points:e.tracePath,strokeColor:"purple"});return t}},DHn=(t,e=1e-6)=>{const n=[];let o=null,i=null,r=0;const s=a=>{if(o&&i){const A=Math.abs(i==="x"?a.x-o.x:a.y-o.y);A>e&&n.push({start:o,end:a,axis:i,length:A})}o=null,i=null,r=0};for(let a=0;a<t.length-1;a++){const A=t[a],c=t[a+1],l=c.x-A.x,g=c.y-A.y;if(Math.abs(l)<=e&&Math.abs(g)<=e)continue;const u=Math.abs(g)<=e?"x":Math.abs(l)<=e?"y":null;if(!u){s(A);continue}const h=Math.sign(u==="x"?l:g);o&&i===u&&r===h||(s(A),o=A,i=u,r=h)}return t.length>=2&&s(t[t.length-1]),n.sort((a,A)=>A.length-a.length)},ddt=.18,vHn=.05,PHn=.4,hdt=t=>[...t].sort().join("::"),wHn=class extends ed{inputProblem;traces;inputNetLabelPlacements;inlineNetLabelPlacements=[];queuedDirectConnections;tracesByPinPairKey;constructor(t){super(),this.inputProblem=t.inputProblem,this.traces=t.traces,this.inputNetLabelPlacements=t.netLabelPlacements,this.queuedDirectConnections=this.inputProblem.directConnections.filter(e=>e.allowInlineNetLabel&&e.netId),this.tracesByPinPairKey=new Map;for(const e of this.traces){const n=hdt(e.pins.map(i=>i.pinId)),o=this.tracesByPinPairKey.get(n);o?o.push(e):this.tracesByPinPairKey.set(n,[e])}}getConstructorParams(){return[{inputProblem:this.inputProblem,traces:this.traces,netLabelPlacements:this.inputNetLabelPlacements}]}_step(){const t=this.queuedDirectConnections.shift();if(!t){this.solved=!0,this.stats.inlineNetLabelCount=this.inlineNetLabelPlacements.length;return}const e=this.computeInlinePlacement(t);e&&this.inlineNetLabelPlacements.push(e)}computeInlinePlacement(t){const e=this.tracesByPinPairKey.get(hdt(t.pinIds))??[];if(e.length===0)return null;const n=e[0],o=DHn(n.tracePath);if(o.length===0)return null;const i=t.inlineNetLabelHeight??ddt,r=t.inlineNetLabelWidth??t.netLabelWidth??MHn(t.netId,i),s=i/2+vHn,a=o.filter(c=>c.length>=r).sort((c,l)=>l.length-c.length);for(const c of a){const l=c.axis==="x"?["y+","y-"]:["x-","x+"];for(const g of l)for(const u of NHn(c,r)){const h=g==="y+"?{x:u.x,y:u.y+s}:g==="y-"?{x:u.x,y:u.y-s}:g==="x-"?{x:u.x-s,y:u.y}:{x:u.x+s,y:u.y},d=r/2,_=i/2,p=c.axis==="x"?{minX:h.x-d,maxX:h.x+d,minY:h.y-_,maxY:h.y+_}:{minX:h.x-_,maxX:h.x+_,minY:h.y-d,maxY:h.y+d};if(!this.isObstructed(p,n))return{globalConnNetId:n.globalConnNetId,netId:t.netId,mspPairId:n.mspPairId,pinIds:[...t.pinIds],axis:c.axis,anchorPoint:u,center:h,width:r,height:i,side:g}}}const A=this.computeSpanPlacement({trace:n,directConnection:t,width:r,height:i,offset:s});return A||null}computeSpanPlacement({trace:t,directConnection:e,width:n,height:o,offset:i}){const r=t.tracePath;if(r.length<2)return null;let s=1/0,a=-1/0,A=1/0,c=-1/0;for(const y of r)s=Math.min(s,y.x),a=Math.max(a,y.x),A=Math.min(A,y.y),c=Math.max(c,y.y);const l=a-s,g=c-A,u=l>=g?"x":"y",h=u==="x"?l:g;if((u==="x"?g:l)>PHn||h<n)return null;const m=((u==="x"?s:A)+(u==="x"?a:c))/2,I=(h-n)/2,f=[0];for(let y=.1;y<=I+1e-9;y+=.1)f.push(y,-y);f.push(I,-I);const C=u==="x"?["y+","y-"]:["x-","x+"];for(const y of C)for(const E of f){const B=m+E,Q=y==="y+"?{x:B,y:c+i}:y==="y-"?{x:B,y:A-i}:y==="x-"?{x:s-i,y:B}:{x:a+i,y:B},b=n/2,D=o/2,T=u==="x"?{minX:Q.x-b,maxX:Q.x+b,minY:Q.y-D,maxY:Q.y+D}:{minX:Q.x-D,maxX:Q.x+D,minY:Q.y-b,maxY:Q.y+b};if(this.isObstructed(T,t))continue;const N=u==="x"?{x:B,y:y==="y+"?c:A}:{x:y==="x-"?s:a,y:B};return{globalConnNetId:t.globalConnNetId,netId:e.netId,mspPairId:t.mspPairId,pinIds:[...e.pinIds],axis:u,anchorPoint:N,center:Q,width:n,height:o,side:y}}return null}isObstructed(t,e){for(const n of this.inputProblem.chips){const o={minX:n.center.x-n.width/2,maxX:n.center.x+n.width/2,minY:n.center.y-n.height/2,maxY:n.center.y+n.height/2};if(WZ(t,o))return!0}for(const n of this.inputProblem.textBoxes??[])if(WZ(t,qZ(n)))return!0;for(const n of this.traces)if(n.mspPairId!==e.mspPairId&&n.globalConnNetId!==e.globalConnNetId&&RHn(n.tracePath,t))return!0;return!1}getSupersededNetLabelKeys(){const t=new Set;for(const e of this.inlineNetLabelPlacements)t.add(e.globalConnNetId);return t}getOutput(){const t=this.getSupersededNetLabelKeys();return{traces:this.traces,netLabelPlacements:this.inputNetLabelPlacements.filter(e=>!t.has(e.globalConnNetId)),inlineNetLabelPlacements:this.inlineNetLabelPlacements}}visualize(){const t=y0(this.inputProblem);t.lines??=[],t.rects??=[],t.points??=[],t.texts??=[];for(const n of this.traces)t.lines.push({points:n.tracePath,strokeColor:"purple"});const{netLabelPlacements:e}=this.getOutput();for(const n of e)t.rects.push({center:n.center,width:n.width,height:n.height,fill:DA(n.globalConnNetId,.35),strokeColor:DA(n.globalConnNetId,.9),label:`netId: ${n.netId}
1001
1001
  globalConnNetId: ${n.globalConnNetId}`}),t.points.push({x:n.anchorPoint.x,y:n.anchorPoint.y,color:DA(n.globalConnNetId,.9),label:`anchorPoint
1002
1002
  orientation: ${n.orientation}`});for(const n of this.inlineNetLabelPlacements){const o=n.axis==="x";t.rects.push({center:n.center,width:o?n.width:n.height,height:o?n.height:n.width,fill:DA(n.globalConnNetId,.35),strokeColor:"green",label:[`INLINE netId: ${n.netId}`,`axis: ${n.axis}`,`side: ${n.side}`].join(`
1003
- `)}),t.texts.push({x:n.center.x,y:n.center.y,text:n.netId??"",color:"green",fontSize:n.height,anchorSide:"center"}),t.points.push({x:n.anchorPoint.x,y:n.anchorPoint.y,color:"green",label:`inline anchor
1003
+ `)}),t.texts.push({x:n.center.x,y:n.center.y,text:n.netId??"",color:"green",fontSize:n.height,anchorSide:"center",rotation:n.axis==="y"?90:void 0}),t.points.push({x:n.anchorPoint.x,y:n.anchorPoint.y,color:"green",label:`inline anchor
1004
1004
  ${n.netId}`})}return t}},MHn=(t,e=ddt)=>{const n=e/.18;return t.length*.12*n+.12*n},NHn=(t,e,n=.1)=>{const o=t.axis==="x"?"x":"y",i=t.start[o],r=t.end[o],s=(i+r)/2,a=Math.sign(r-i)||1,A=g=>t.axis==="x"?{x:g,y:t.start.y}:{x:t.start.x,y:t.start.y+(g-i)},c=t.length-e;if(c<=0)return[A(s)];const l=[0];for(let g=n;g<=c/2+1e-9;g+=n)l.push(g,-g);return l.push(c/2,-c/2),l.map(g=>A(s+g*a))},RHn=(t,e)=>{for(let n=0;n<t.length-1;n++){const o=t[n],i=t[n+1],r={minX:Math.min(o.x,i.x),maxX:Math.max(o.x,i.x),minY:Math.min(o.y,i.y),maxY:Math.max(o.y,i.y)};if(WZ(r,e))return!0}return!1};function E0(t,e,n,o={}){return{solverName:t,solverClass:e,getConstructorParams:n,onSolved:o.onSolved,shouldSkip:o.shouldSkip}}var _dt=class extends ed{mspConnectionPairSolver;schematicTraceLinesSolver;longDistancePairSolver;unroutedTraceRecoverySolver;traceOverlapShiftSolver;netLabelPlacementSolver;labelMergingSolver;traceLabelOverlapAvoidanceSolver;traceCleanupSolver;example28Solver;availableNetOrientationSolver;postLabelTraceOverlapShiftSolver;railNetLabelCornerPlacementSolver;traceAnchoredNetLabelOverlapSolver;preAlignmentNetLabelTraceCollisionSolver;netLabelTraceCollisionSolver;traceCleanupSolver2;netLabelNetLabelCollisionSolver;traceElbowTransitionSimplificationSolver;preAlignmentTraceElbowTransitionSimplificationSolver;finalTraceElbowTransitionSimplificationSolver;sameNetJunctionAlignmentSolver;inlineNetLabelSolver;startTimeOfPhase;endTimeOfPhase;timeSpentOnPhase;firstIterationOfPhase;inputProblem;hideRatsNet;pipelineDef=[E0("mspConnectionPairSolver",QTn,()=>[{inputProblem:this.inputProblem}],{onSolved:t=>{}}),E0("schematicTraceLinesSolver",HTn,()=>[{mspConnectionPairs:this.mspConnectionPairSolver.mspConnectionPairs,dcConnMap:this.mspConnectionPairSolver.dcConnMap,globalConnMap:this.mspConnectionPairSolver.globalConnMap,inputProblem:this.inputProblem,chipMap:this.mspConnectionPairSolver.chipMap}]),E0("longDistancePairSolver",pkn,t=>[{inputProblem:t.inputProblem,primaryMspConnectionPairs:t.mspConnectionPairSolver.mspConnectionPairs,alreadySolvedTraces:t.schematicTraceLinesSolver.solvedTracePaths,failedConnectionPairs:t.schematicTraceLinesSolver.failedConnectionPairs}],{onSolved:t=>{}}),E0("unroutedTraceRecoverySolver",hHn,t=>[{inputProblem:t.inputProblem,failedConnectionPairs:t.schematicTraceLinesSolver.failedConnectionPairs,alreadySolvedTraces:t.longDistancePairSolver.getOutput().allTracesMerged}]),E0("traceOverlapShiftSolver",eut,()=>[{inputProblem:this.inputProblem,inputTracePaths:this.unroutedTraceRecoverySolver?.getOutput().allTracesMerged,globalConnMap:this.mspConnectionPairSolver.globalConnMap}],{onSolved:t=>{}}),E0("netLabelPlacementSolver",iut,()=>[{inputProblem:this.inputProblem,inputTraceMap:this.traceOverlapShiftSolver?.correctedTraceMap??Object.fromEntries(this.unroutedTraceRecoverySolver.getOutput().allTracesMerged.map(t=>[t.mspPairId,t]))}],{onSolved:t=>{}}),E0("traceLabelOverlapAvoidanceSolver",lkn,t=>{const e=t.traceOverlapShiftSolver?.correctedTraceMap??Object.fromEntries(t.unroutedTraceRecoverySolver.getOutput().allTracesMerged.map(i=>[i.mspPairId,i])),n=Object.values(e),o=t.netLabelPlacementSolver.netLabelPlacements;return[{inputProblem:t.inputProblem,traces:n,netLabelPlacements:o}]}),E0("traceElbowTransitionSimplificationSolver",Y1e,t=>{const e=t.traceLabelOverlapAvoidanceSolver.getOutput();return[{inputProblem:t.inputProblem,traces:e.traces,completedReroutes:e.completedReroutes,netLabelPlacements:t.traceLabelOverlapAvoidanceSolver.netLabelPlacements,paddingBuffer:.1}]}),E0("traceCleanupSolver",Nut,t=>{const n=t.traceElbowTransitionSimplificationSolver.getOutput().traces,o=t.traceLabelOverlapAvoidanceSolver.labelMergingSolver.getOutput();return[{inputProblem:t.inputProblem,allTraces:n,allLabelPlacements:o.netLabelPlacements,mergedLabelNetIdMap:o.mergedLabelNetIdMap,paddingBuffer:.1}]}),E0("netLabelPlacementSolver",iut,t=>{const e=t.traceCleanupSolver?.getOutput().traces??t.traceLabelOverlapAvoidanceSolver.getOutput().traces;return[{inputProblem:t.inputProblem,inputTraceMap:Object.fromEntries(e.map(n=>[n.mspPairId,n]))}]}),E0("example28Solver",LFn,t=>{const e=t.traceCleanupSolver?.getOutput().traces??t.traceLabelOverlapAvoidanceSolver.getOutput().traces;return[{inputProblem:t.inputProblem,traces:e,netLabelPlacements:t.netLabelPlacementSolver.netLabelPlacements}]}),E0("availableNetOrientationSolver",$Fn,t=>[{inputProblem:t.inputProblem,traces:t.example28Solver.outputTraces,netLabelPlacements:t.example28Solver.outputNetLabelPlacements}]),E0("postLabelTraceOverlapShiftSolver",eut,t=>[{inputProblem:t.inputProblem,inputTracePaths:t.availableNetOrientationSolver.traces,globalConnMap:t.mspConnectionPairSolver.globalConnMap,traceIdsToShift:new Set(t.availableNetOrientationSolver.traces.filter(e=>e.mspPairId.startsWith("available-net-orientation-")).map(e=>e.mspPairId))}]),E0("railNetLabelCornerPlacementSolver",sLn,t=>[{inputProblem:t.inputProblem,traces:Object.values(t.postLabelTraceOverlapShiftSolver.correctedTraceMap),netLabelPlacements:t.availableNetOrientationSolver.outputNetLabelPlacements}]),E0("traceAnchoredNetLabelOverlapSolver",YLn,t=>[{inputProblem:t.inputProblem,traces:t.railNetLabelCornerPlacementSolver.getOutput().traces,netLabelPlacements:t.railNetLabelCornerPlacementSolver.outputNetLabelPlacements}]),E0("preAlignmentNetLabelTraceCollisionSolver",idt,t=>[{inputProblem:t.inputProblem,traces:t.railNetLabelCornerPlacementSolver.getOutput().traces,netLabelPlacements:t.traceAnchoredNetLabelOverlapSolver.outputNetLabelPlacements}]),E0("preAlignmentTraceElbowTransitionSimplificationSolver",Y1e,t=>{const e=t.preAlignmentNetLabelTraceCollisionSolver.getOutput();return[{inputProblem:t.inputProblem,traces:e.traces,completedReroutes:e.completedReroutes,netLabelPlacements:e.netLabelPlacements,paddingBuffer:.1}]}),E0("traceCleanupSolver2",Nut,t=>{const e=t.preAlignmentTraceElbowTransitionSimplificationSolver.getOutput(),n=t.traceLabelOverlapAvoidanceSolver.labelMergingSolver.getOutput();return[{inputProblem:t.inputProblem,allTraces:e.traces,allLabelPlacements:e.netLabelPlacements,mergedLabelNetIdMap:n.mergedLabelNetIdMap,paddingBuffer:.1,operations:["aligning_same_net_rails"],eligibleTraceIds:new Set(t.traceCleanupSolver.getOutput().traces.map(o=>o.mspPairId))}]}),E0("netLabelTraceCollisionSolver",idt,t=>{const e=t.preAlignmentNetLabelTraceCollisionSolver.getOutput(),n=t.traceCleanupSolver2.getOutput(),o=new Map(e.traces.map(r=>[r.mspPairId,r]));let i=e.netLabelPlacements;for(const r of n.traces){const s=o.get(r.mspPairId);if(!s||s.tracePath===r.tracePath)continue;const a=i;i=F1e({trace:s,originalTracePath:s.tracePath,reroutedTracePath:r.tracePath,netLabelPlacements:a}).map((c,l)=>{const g=a[l];return g.orientation==="y+"||g.orientation==="y-"?c:g})}return[{inputProblem:t.inputProblem,traces:n.traces,netLabelPlacements:i}]}),E0("finalTraceElbowTransitionSimplificationSolver",Y1e,t=>{const e=t.netLabelTraceCollisionSolver.getOutput();return[{inputProblem:t.inputProblem,traces:e.traces,completedReroutes:e.completedReroutes,netLabelPlacements:e.netLabelPlacements,paddingBuffer:.1}]}),E0("netLabelNetLabelCollisionSolver",nHn,t=>{const e=t.finalTraceElbowTransitionSimplificationSolver.getOutput();return[{inputProblem:t.inputProblem,traces:e.traces,netLabelPlacements:e.netLabelPlacements}]}),E0("sameNetJunctionAlignmentSolver",BHn,t=>{const e=t.netLabelNetLabelCollisionSolver.getOutput();return[{inputProblem:t.inputProblem,traces:t.netLabelNetLabelCollisionSolver.traces,netLabelPlacements:e.netLabelPlacements}]}),E0("inlineNetLabelSolver",wHn,t=>{const e=t.sameNetJunctionAlignmentSolver.getOutput();return[{inputProblem:t.inputProblem,traces:e.traces,netLabelPlacements:e.netLabelPlacements}]})];constructor(t,e){super(),this.hideRatsNet=e?.hideRatsNet??!1,this.inputProblem=this.cloneAndCorrectInputProblem(t),this.MAX_ITERATIONS=1e6,this.startTimeOfPhase={},this.endTimeOfPhase={},this.timeSpentOnPhase={},this.firstIterationOfPhase={}}getConstructorParams(){return[this.inputProblem,{hideRatsNet:this.hideRatsNet}]}currentPipelineStepIndex=0;cloneAndCorrectInputProblem(t){const e=structuredClone({...t,_chipObstacleSpatialIndex:void 0,_hideRatsNet:this.hideRatsNet});return ukn(e),gkn(e),e}_step(){const t=this.pipelineDef[this.currentPipelineStepIndex];if(!t){this.solved=!0;return}if(this.activeSubSolver){this.activeSubSolver.step(),this.activeSubSolver.solved?(this.endTimeOfPhase[t.solverName]=performance.now(),this.timeSpentOnPhase[t.solverName]=this.endTimeOfPhase[t.solverName]-this.startTimeOfPhase[t.solverName],t.onSolved?.(this),this.activeSubSolver=null,this.currentPipelineStepIndex++):this.activeSubSolver.failed&&(this.error=this.activeSubSolver?.error,this.failed=!0,this.activeSubSolver=null);return}const e=t.getConstructorParams(this);this.activeSubSolver=new t.solverClass(...e),this[t.solverName]=this.activeSubSolver,this.timeSpentOnPhase[t.solverName]=0,this.startTimeOfPhase[t.solverName]=performance.now(),this.firstIterationOfPhase[t.solverName]=this.iterations}solveUntilPhase(t){for(;this.getCurrentPhase().toLowerCase()!==t.toLowerCase();)this.step()}getCurrentPhase(){return this.pipelineDef[this.currentPipelineStepIndex]?.solverName??"none"}visualize(){if(!this.solved&&this.activeSubSolver)return this.activeSubSolver.visualize();const t=[y0(this.inputProblem,{hideRatsNet:this.hideRatsNet}),...this.pipelineDef.map(n=>this[n.solverName]?.visualize()).filter(Boolean).map((n,o)=>{for(const i of n.rects??[])i.step=o;for(const i of n.points??[])i.step=o;for(const i of n.circles??[])i.step=o;for(const i of n.texts??[])i.step=o;for(const i of n.lines??[])i.step=o;return n})];if(t.length===1)return t[0];const e={points:t.flatMap(n=>n.points||[]),rects:t.flatMap(n=>n.rects||[]),lines:t.flatMap(n=>n.lines||[]),circles:t.flatMap(n=>n.circles||[]),texts:t.flatMap(n=>n.texts||[])};return qTn(e,this.inputProblem),e}preview(){return this.activeSubSolver?this.activeSubSolver.preview():super.preview()}},pdt={flexGrow:0,flexShrink:1,flexBasis:0,alignSelf:"auto",width:void 0,height:void 0},mdt=class{id;metadata;size={width:0,height:0};position={x:0,y:0};style;constructor(t={}){this.style={...pdt,...t},this.id=t.id,this.metadata=t.metadata}},THn=class extends mdt{build(){}},Idt=class FRe extends mdt{children=[];direction="row";columnGap=0;rowGap=0;justifyContent="flex-start";alignItems="stretch";constructor(e,n,o={}){super({}),this.size.width=e,this.size.height=n,this.id=o.id,Object.assign(this,o)}addChild(e,n){if(e instanceof FRe){const i=e;return n&&(i.style={...pdt,...n}),this.children.push(i),i}const o=new THn(e);return this.children.push(o),o}build(){const e=this.direction.startsWith("row"),n=e?"width":"height",o=e?"height":"width",i=e?this.columnGap:this.rowGap;e?this.rowGap:this.columnGap;const r=i*Math.max(0,this.children.length-1),s=this.size[n],a=this.size[o];let A=0,c=0,l=0;for(const C of this.children)A+=C.style.flexBasis,c+=C.style.flexGrow,l+=C.style.flexShrink;const g=s-A-r;for(const C of this.children){let y=C.style.flexBasis;g>0&&c>0?y+=g*C.style.flexGrow/c:g<0&&l>0&&(y+=g*C.style.flexShrink/l,y<0&&(y=0)),C.size[n]=y;const E=C.style.alignSelf!=="auto"?C.style.alignSelf:this.alignItems,B=e?C.style.height:C.style.width;B!==void 0?C.size[o]=B:E==="stretch"&&(C.size[o]=a)}const u=this.children.reduce((C,y)=>C+y.size[n],0)+r,h=s-u;let d=0,_=i;const p=this.children.length;switch(this.justifyContent){case"flex-start":break;case"flex-end":d=h;break;case"center":d=h/2;break;case"space-between":_=p>1?i+h/(p-1):0;break;case"space-around":_=i+h/p,d=_/2;break;case"space-evenly":_=i+h/(p+1),d=_;break}const m=this.direction.endsWith("reverse")?[...this.children].reverse():this.children;let I=d;for(const C of m)e?(C.position.x=this.direction==="row"?I:s-I-C.size.width,C.position.y=f(C,o,a,this.alignItems)):(C.position.y=this.direction==="column"?I:s-I-C.size.height,C.position.x=f(C,o,a,this.alignItems)),I+=C.size[n]+_;for(const C of this.children)C instanceof FRe&&C.build();function f(C,y,E,B){switch(C.style.alignSelf!=="auto"?C.style.alignSelf:B){case"flex-start":return 0;case"flex-end":return E-C.size[y];case"center":return(E-C.size[y])/2;default:return 0}}}},fdt=class extends Idt{constructor(t,e,n={}){super(t,e,n)}getLayout(){this.build();const t={};return this._collectLayout(this,t),t}_collectLayout(t,e,n={counter:0}){for(const o of t.children){const i=o.id??`_$$${n.counter++}`;e[i]={position:o.position,size:o.size},o instanceof Idt&&this._collectLayout(o,e,n)}}},Cdt=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20].map(t=>`hsl(${t*360/21}deg, 100%, 50%)`),kHn=t=>{let e=0;for(let n=0;n<t.length;n++)e=(e<<5)-e+t.charCodeAt(n);return e},ydt=t=>Cdt[Math.abs(kHn(t))%Cdt.length],FHn=t=>{const e=d=>d?typeof d=="string"?d:d.join(" "):void 0,n=["display:grid","background-color:gray"],{gridTemplateRows:o,gridTemplateColumns:i,gap:r,justifyItems:s,alignItems:a,containerWidth:A,containerHeight:c}=t.opts,l=e(o);l&&n.push(`grid-template-rows:${l}`);const g=e(i);if(g&&n.push(`grid-template-columns:${g}`),r!==void 0)if(typeof r=="number")n.push(`gap:${r}px`);else{const[d,_]=r;n.push(`row-gap:${d}px`,`column-gap:${_}px`)}s&&n.push(`justify-items:${s}`),a&&n.push(`align-items:${a}`),A!=null&&n.push(`width:${A}px`),c!=null&&n.push(`height:${c}px`);const u=n.join(";"),h=t.opts.children.map(d=>{const _=["display:flex",`background-color:${ydt(d.key)}`];if(d.area)_.push(`grid-area:${d.area}`);else{if(typeof d.row=="string"&&d.row.includes("/"))_.push(`grid-row:${d.row}`);else{const f=d.rowStart??d.row,C=d.rowEnd,y=d.rowSpan;f!==void 0||C!==void 0?f!==void 0&&C!==void 0?_.push(`grid-row:${f} / ${C}`):f!==void 0?y!==void 0?_.push(`grid-row:${f} / span ${y}`):_.push(`grid-row-start:${f}`):_.push(`grid-row-end:${C}`):y!==void 0&&_.push(`grid-row:auto / span ${y}`)}if(typeof d.column=="string"&&d.column.includes("/"))_.push(`grid-column:${d.column}`);else{const f=d.columnStart??d.column,C=d.columnEnd,y=d.columnSpan;f!==void 0||C!==void 0?f!==void 0&&C!==void 0?_.push(`grid-column:${f} / ${C}`):f!==void 0?y!==void 0?_.push(`grid-column:${f} / span ${y}`):_.push(`grid-column-start:${f}`):_.push(`grid-column-end:${C}`):y!==void 0&&_.push(`grid-column:auto / span ${y}`)}}const p=_.join(";"),m=["font-size: 7px"];if(d.contentWidth!==void 0){const f=typeof d.contentWidth=="string"?d.contentWidth:`${d.contentWidth}px`;m.push(`width:${f}`)}else m.push(`width:${d.key.length*5}px`);if(d.contentHeight!==void 0){const f=typeof d.contentHeight=="string"?d.contentHeight:`${d.contentHeight}px`;m.push(`height:${f}`)}const I=m.join(";");return` <div id="${d.key}" style="${p}"><div style="${I}">${d.key}</div></div>`});return`<div style="${u}">
1005
1005
  ${h.join(`
1006
1006
  `)}
@@ -5795,7 +5795,7 @@ test("${c} should solve problem correctly", () => {
5795
5795
  // Add more specific assertions based on expected output
5796
5796
  // expect(solver.netLabelPlacementSolver!.netLabelPlacements).toMatchInlineSnapshot()
5797
5797
  })
5798
- `,g=new Blob([l],{type:"text/plain"}),u=URL.createObjectURL(g),h=document.createElement("a");h.href=u,h.download=`${c}.test.ts`,h.click(),URL.revokeObjectURL(u)}catch(A){alert(`Error generating test.ts for ${t.constructor.name}: ${A instanceof Error?A.message:String(A)}`)}o(!1)};return V.jsxs("div",{className:`relative ${e}`,ref:i,children:[V.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>o(!n),title:`Download options for ${t.constructor.name}`,children:t.constructor.name}),n&&V.jsxs("div",{className:"absolute top-full left-0 mt-1 bg-white border border-gray-300 rounded shadow-lg z-10 min-w-[150px]",children:[V.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download JSON"}),V.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),V.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:a,children:"Download test.ts"})]})]})},JGt=t=>t.activeSubSolver?[t,...JGt(t.activeSubSolver)]:[t],v$o=({solver:t})=>{const e=JGt(t);return V.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:e.map((n,o)=>V.jsxs("div",{className:"flex items-center",children:[o>0&&V.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),V.jsx(D$o,{solver:n})]},n.constructor.name))})},P$o=({solver:t,triggerRender:e,animationSpeed:n=25,onSolverStarted:o,onSolverCompleted:i})=>{const[r,s]=$.useReducer(_=>!_,!1),a=$.useRef(void 0),A=()=>{!t.solved&&!t.failed&&(t.step(),e())},c=()=>{!t.solved&&!t.failed&&(o&&o(t),t.solve(),e(),i&&i(t))},l=()=>{r?(a.current&&(clearInterval(a.current),a.current=void 0),s()):(s(),a.current=setInterval(()=>{if(t.solved||t.failed){a.current&&(clearInterval(a.current),a.current=void 0),s(),e(),i&&t.solved&&i(t);return}t.step(),e()},n))},g=()=>{const _=t;if(_.getCurrentPhase&&!t.solved&&!t.failed){const p=_.getCurrentPhase();for(;_.getCurrentPhase()===p&&!t.solved&&!t.failed;)t.step();e()}},u=()=>{if(t.solved||t.failed||r)return;const _=window.prompt("Step until which iteration?",`${t.iterations}`);if(_===null)return;const p=Number(_);if(!Number.isFinite(p)){window.alert("Please enter a valid number for the iteration");return}for(;t.iterations<p&&!t.solved&&!t.failed;)t.step();e(),t.solved&&i&&i(t)};$.useEffect(()=>()=>{a.current&&clearInterval(a.current)},[]),$.useEffect(()=>{(t.solved||t.failed)&&r&&(a.current&&(clearInterval(a.current),a.current=void 0),s())},[t.solved,t.failed,r]);const h=t.getCurrentPhase!==void 0,d=h?t.getCurrentPhase():null;return V.jsxs("div",{className:"space-y-2 p-2 border-b",children:[V.jsx("div",{className:"flex items-center",children:V.jsx(v$o,{solver:t})}),V.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[V.jsx("button",{onClick:A,disabled:t.solved||t.failed||r,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),V.jsx("button",{onClick:c,disabled:t.solved||t.failed||r,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),V.jsx("button",{onClick:l,disabled:t.solved||t.failed,className:`px-3 py-1 rounded text-white text-sm ${r?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:r?"Stop":"Animate"}),V.jsx("button",{onClick:u,disabled:t.solved||t.failed||r,className:"bg-orange-500 hover:bg-orange-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step Until Iteration"}),h&&V.jsx("button",{onClick:g,disabled:t.solved||t.failed||r,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),V.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&V.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),d&&V.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",V.jsx("span",{className:"font-medium",children:d})]}),t.solved&&V.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&V.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&V.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},w$o=(t,e,n)=>{const o=t.currentPipelineStepIndex;return e<o?"Completed":e===o&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},M$o=(t,e)=>{const o=t.pipelineDef[e].solverName,i=w$o(t,e),r=t[o],s=t.firstIterationOfPhase?.[o]??null,a=t.iterations;let A=0;if(i==="Completed"){const u=t.pipelineDef[e+1],h=u?t.firstIterationOfPhase?.[u.solverName]:void 0;h!==void 0&&s!==null?A=h-s:s!==null&&(A=a-s)}else i==="In Progress"&&s!==null&&(A=a-s);const c=t.timeSpentOnPhase?.[o]??0;let l=0;i==="Completed"?l=1:i==="In Progress"&&r&&(l=r.progress??0);const g=r?.stats??null;return{index:e,name:o,status:i,firstIteration:s,iterations:A,progress:l,timeSpent:c,stats:g&&Object.keys(g).length>0?g:null,solverInstance:r??null}},N$o=({status:t})=>{const e={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return V.jsx("span",{className:`font-medium ${e[t]}`,children:t})},R$o=({progress:t})=>{if(t===0)return null;const e=Math.round(t*100);return V.jsxs("div",{className:"flex items-center gap-2",children:[V.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:V.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${e}%`}})}),V.jsxs("span",{className:"text-xs text-gray-500",children:[e,"%"]})]})},T$o=t=>Object.entries(t).map(([e,n])=>`${e}: ${n}`).join(", "),k$o=({stats:t})=>{if(!t||Object.keys(t).length===0)return V.jsx("span",{children:"-"});const e=Object.entries(t),n=T$o(t);return V.jsxs("details",{className:"cursor-pointer",children:[V.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:n}),V.jsx("div",{className:"mt-1 text-xs",children:e.map(([o,i])=>V.jsxs("div",{children:[o,": ",String(i)]},o))})]})},_7e=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(_7e);const e={};for(const[n,o]of Object.entries(t))n.startsWith("_")||(e[n]=_7e(o));return e},F$o=(t,e)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${e}`);return}const n=_7e(t.getConstructorParams()),o=new Blob([JSON.stringify(n,null,2)],{type:"application/json"}),i=URL.createObjectURL(o),r=document.createElement("a");r.href=i,r.download=`${e}_input.json`,r.click(),URL.revokeObjectURL(i)}catch(n){alert(`Error downloading input for ${e}: ${n instanceof Error?n.message:String(n)}`)}},L$o=({solver:t,onStepUntilPhase:e,onDownloadInput:n})=>{const o=t.pipelineDef.map((a,A)=>M$o(t,A)),i=a=>{e?.(a)},r=a=>{a.solverInstance&&(n?n(a.solverInstance,a.name):F$o(a.solverInstance,a.name))},s=a=>`${(a/1e3).toFixed(2)}s`;return V.jsxs("div",{className:"border-t border-gray-200",children:[V.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:V.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),V.jsx("div",{className:"overflow-x-auto",children:V.jsxs("table",{className:"w-full text-sm",children:[V.jsx("thead",{children:V.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),V.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",V.jsx("sub",{children:"0"})]}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),V.jsx("tbody",{children:o.map(a=>V.jsxs("tr",{className:`border-b border-gray-100 ${a.status==="In Progress"?"bg-yellow-50":""}`,children:[V.jsx("td",{className:"px-4 py-2",children:V.jsxs("div",{className:"flex items-center gap-2",children:[V.jsx("span",{className:"text-gray-400 w-6",children:String(a.index+1).padStart(2,"0")}),V.jsx("button",{onClick:()=>i(a.name),disabled:a.status==="Completed"||t.solved||t.failed,className:"text-blue-500 hover:text-blue-700 disabled:text-gray-300 disabled:cursor-not-allowed",title:`Step until ${a.name} completes`,children:V.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:V.jsx("path",{fillRule:"evenodd",d:"M4.5 5.653c0-1.426 1.529-2.33 2.779-1.643l11.54 6.348c1.295.712 1.295 2.573 0 3.285L7.28 19.991c-1.25.687-2.779-.217-2.779-1.643V5.653z",clipRule:"evenodd"})})}),V.jsx("span",{className:"font-medium text-gray-900",children:a.name})]})}),V.jsx("td",{className:"px-4 py-2",children:V.jsx(N$o,{status:a.status})}),V.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:a.firstIteration!==null?a.firstIteration:""}),V.jsx("td",{className:"px-4 py-2 text-gray-600",children:a.iterations}),V.jsx("td",{className:"px-4 py-2",children:V.jsx(R$o,{progress:a.progress})}),V.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(a.timeSpent)}),V.jsx("td",{className:"px-4 py-2 text-gray-500",children:V.jsx(k$o,{stats:a.stats})}),V.jsx("td",{className:"px-4 py-2",children:a.solverInstance?V.jsxs("button",{onClick:()=>r(a),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${a.name}`,children:[V.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:V.jsx("path",{fillRule:"evenodd",d:"M12 2.25a.75.75 0 01.75.75v11.69l3.22-3.22a.75.75 0 111.06 1.06l-4.5 4.5a.75.75 0 01-1.06 0l-4.5-4.5a.75.75 0 111.06-1.06l3.22 3.22V3a.75.75 0 01.75-.75zm-9 13.5a.75.75 0 01.75.75v2.25a1.5 1.5 0 001.5 1.5h13.5a1.5 1.5 0 001.5-1.5V16.5a.75.75 0 011.5 0v2.25a3 3 0 01-3 3H5.25a3 3 0 01-3-3V16.5a.75.75 0 01.75-.75z",clipRule:"evenodd"})}),V.jsx("span",{children:"Input"})]}):null})]},a.name))})]})})]})},H$o=class extends ts.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 G$o({graphics:t}){const e=t.points??[],n=t.lines??[],o=t.rects??[],i=t.circles??[],r=t.texts??[];let s=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,A=Number.NEGATIVE_INFINITY,c=Number.NEGATIVE_INFINITY;const l=(p,m)=>{typeof p=="number"&&(p<s&&(s=p),p>A&&(A=p)),typeof m=="number"&&(m<a&&(a=m),m>c&&(c=m))};for(const p of e)l(p.x,p.y);for(const p of n){const m=p.points??[];for(const I of m)l(I.x,I.y)}for(const p of o){const m=p.x??0,I=p.y??0,f=p.width??0,C=p.height??0;l(m,I),l(m+f,I+C)}for(const p of i){const m=p.x??0,I=p.y??0,f=p.radius??1;l(m-f,I-f),l(m+f,I+f)}for(const p of r)l(p.x,p.y);(!isFinite(s)||!isFinite(a)||!isFinite(A)||!isFinite(c))&&(s=-20,a=-20,A=20,c=20);const g=10,u=s-g,h=a-g,d=Math.max(1,A-s+2*g),_=Math.max(1,c-a+2*g);return V.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${u} ${h} ${d} ${_}`,role:"img","aria-label":"Graphics fallback",children:[o.map((p,m)=>V.jsx("rect",{x:p.x??0,y:p.y??0,width:p.width??0,height:p.height??0,fill:"none",stroke:p.strokeColor??"black",strokeWidth:p.strokeWidth??1},`rect-${m}`)),n.map((p,m)=>V.jsx("polyline",{fill:"none",stroke:p.strokeColor??"black",strokeWidth:p.strokeWidth??1,points:(p.points??[]).map(I=>`${I.x??0},${I.y??0}`).join(" ")},`line-${m}`)),i.map((p,m)=>V.jsx("circle",{cx:p.x??0,cy:p.y??0,r:p.radius??1.5,fill:p.fillColor??"none",stroke:p.strokeColor??"black",strokeWidth:p.strokeWidth??1},`circle-${m}`)),e.map((p,m)=>V.jsx("circle",{cx:p.x??0,cy:p.y??0,r:p.radius??1.5,fill:p.color??"black"},`point-${m}`)),r.map((p,m)=>V.jsx("text",{x:p.x??0,y:p.y??0,fontSize:p.fontSize??10,fill:p.color??"black",children:p.text??""},`text-${m}`))]})}var O$o=({solver:t,animationSpeed:e=25,onSolverStarted:n,onSolverCompleted:o})=>{const[i,r]=$.useReducer(l=>l+1,0),s=$.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(l){return console.error("Visualization error:",l),{points:[],lines:[],rects:[],circles:[]}}},[t,i]),a=$.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);$.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const l=document.createElement("script");l.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(l)}},[]);const A=t.pipelineDef!==void 0,c=l=>{const g=t;if(!t.solved&&!t.failed){for(;!t.solved&&!t.failed&&g.currentPipelineStepIndex<=g.pipelineDef.findIndex(u=>u.solverName===l);)t.step();r()}};return V.jsxs("div",{children:[V.jsx(P$o,{solver:t,triggerRender:r,animationSpeed:e,onSolverStarted:n,onSolverCompleted:o}),a?V.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):V.jsx(H$o,{fallback:V.jsx(G$o,{graphics:s}),children:V.jsx(b$o,{graphics:s})}),A&&V.jsx(L$o,{solver:t,onStepUntilPhase:c})]})};const K$o=()=>{$.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)},[])},U$o=1e3,Cb=(t,e)=>{const{fileName:n,mimeType:o="text/plain"}=e,i=t instanceof Blob?t:new Blob([t],{type:o}),r=URL.createObjectURL(i),s=document.createElement("a");s.href=r,s.download=n,s.target="_blank",s.rel="noopener noreferrer",s.style.display="none",document.body.appendChild(s),s.click(),document.body.removeChild(s),setTimeout(()=>{URL.revokeObjectURL(r)},U$o)},qGt=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"},yb="https://github.com/tscircuit/tscircuit-autorouter/issues/new",WGt="https://github.com/tscircuit/copper-pour-solver/issues/new",jGt="https://github.com/tscircuit/calculate-packing/issues/new",Y$o="https://github.com/tscircuit/matchpack/issues/new",XGt="https://github.com/tscircuit/schematic-trace-solver/issues/new?template=json-bug-report.yml",z$o={PackSolver2:jGt,LayoutPipelineSolver:Y$o,AutoroutingPipelineSolver:yb,AssignableAutoroutingPipeline2:yb,AssignableAutoroutingPipeline3:yb,AutoroutingPipeline1_OriginalUnravel:yb,AutoroutingPipelineSolver3_HgPortPointPathing:yb,AutoroutingPipelineSolver4:yb,AutoroutingPipelineSolver5:yb,AutoroutingPipelineSolver7_MultiGraph:yb,AutoroutingPipelineSolver8:yb,CopperPourPipelineSolver:WGt,SchematicTracePipelineSolver:XGt},V$o=t=>t.toLowerCase().includes("pack")?POo:t.toLowerCase().includes("rout")?kOo:mOo,$Gt=t=>{const e=z$o[t];if(e)return e;const n=t.toLowerCase();return n.includes("autorout")?yb:n.includes("schematic")&&n.includes("trace")?XGt:n.includes("copperpour")?WGt:n.includes("pack")?jGt:null},J$o=t=>`${qGt(`${t.componentName}-${t.solverName}`)}-solver-input.json`,ZGt=t=>{Cb(JSON.stringify(t.solverParams,null,2),{fileName:J$o(t),mimeType:"application/json"})},q$o=({solverEvent:t})=>{const e=$Gt(t.solverName);return V.jsxs("div",{className:"rf-flex rf-items-center rf-justify-end rf-gap-2 rf-border-b rf-border-gray-200 rf-bg-gray-50 rf-px-4 rf-py-2",children:[V.jsxs(cA,{type:"button",variant:"outline",size:"sm",onClick:()=>ZGt(t),children:[V.jsx(i8e,{className:"rf-w-4 rf-h-4"}),"Download"]}),e?V.jsx(cA,{asChild:!0,variant:"outline",size:"sm",children:V.jsxs("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:[V.jsx(rse,{className:"rf-w-4 rf-h-4"}),"Report"]})}):V.jsxs(cA,{type:"button",variant:"outline",size:"sm",disabled:!0,title:"No report link configured for this solver",children:[V.jsx(rse,{className:"rf-w-4 rf-h-4"}),"Report"]})]})},W$o=({solverEvent:t})=>{const e=$Gt(t.solverName);return e?V.jsx(cA,{asChild:!0,variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8",children:V.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",title:"Report solver bug","aria-label":"Report solver bug",children:V.jsx(rse,{className:"rf-w-4 rf-h-4"})})}):V.jsx(cA,{type:"button",variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8",disabled:!0,title:"No report link configured for this solver","aria-label":"Report solver bug",children:V.jsx(rse,{className:"rf-w-4 rf-h-4"})})},j$o=({solverEvents:t=[]})=>{const[e,n]=$.useState(null);K$o();const o=$.useMemo(()=>{const a=new Map;for(const A of t){const c=`${A.componentName}-${A.solverName}`;a.set(c,A)}return a},[t]),i=$.useMemo(()=>Array.from(o.keys()),[o]),r=e?o.get(e):null,s=$.useMemo(()=>{if(!r)return{instance:null,error:null,classFound:!1};const a=zye[r.solverName];if(!a)return{instance:null,error:`Solver class "${r.solverName}" not found in SOLVERS registry. Available: ${Object.keys(zye).join(", ")}`,classFound:!1};try{const A=r.solverParams,c=A?.input!==void 0?A.input:A;return{instance:new a(c),error:null,classFound:!0}}catch(A){const c=A instanceof Error?A.message:String(A);return console.error("Failed to reconstruct solver:",A),{instance:null,error:`Failed to instantiate solver: ${c}`,classFound:!0}}},[r]);return t.length===0?V.jsx("div",{className:"rf-p-4",children:V.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:V.jsxs("div",{className:"rf-p-4",children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),V.jsx("p",{className:"rf-text-sm rf-text-gray-600",children:"Solvers will appear here when the circuit runs. Solvers are used for tasks like component packing and autorouting."})]})})}):V.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[V.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[V.jsxs("div",{className:"rf-text-xs rf-font-semibold rf-text-gray-500 rf-px-3 rf-py-2 rf-bg-gray-50 rf-border-b rf-border-gray-200",children:[i.length," ",i.length===1?"Solver":"Solvers"]}),i.map(a=>{const A=o.get(a),c=e===a;return V.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${c?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>n(a),children:(()=>{const l=V$o(A.solverName);return V.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[V.jsx(l,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),V.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[V.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:A.componentName}),V.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:A.solverName})]})]})})()},a)})]}),V.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:r?s.instance?V.jsxs("div",{className:"rf-flex rf-h-full rf-flex-col rf-overflow-y-auto",children:[V.jsx(q$o,{solverEvent:r}),V.jsx("div",{className:"rf-min-h-0 rf-flex-1",children:V.jsx(Gx,{fallback:V.jsx("div",{className:"rf-p-4",children:V.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),V.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",r.solverName]})]})}),children:V.jsx(O$o,{solver:s.instance})})})]}):V.jsxs("div",{className:"rf-p-4",children:[V.jsxs("div",{className:"rf-mb-4",children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:r.solverName}),V.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",r.componentName]})]}),s.error&&V.jsx("div",{className:`rf-rounded-md rf-border rf-p-4 rf-mb-4 ${s.classFound?"rf-bg-red-50 rf-border-red-200":"rf-bg-yellow-50 rf-border-yellow-200"}`,children:V.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),V.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[V.jsxs("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50 rf-flex rf-items-center rf-justify-between rf-gap-2",children:[V.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"}),V.jsxs("div",{className:"rf-flex rf-items-center rf-gap-1",children:[V.jsx(W$o,{solverEvent:r}),V.jsx(cA,{type:"button",variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8","aria-label":"Download solver input JSON",title:"Download solver input JSON",onClick:()=>ZGt(r),children:V.jsx(i8e,{className:"rf-w-4 rf-h-4"})})]})]}),V.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:V.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(r.solverParams,null,2)})})]})]}):V.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:V.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},eOt=({errorMessage:t,errorStack:e,circuitJsonErrors:n})=>{$.useEffect(()=>{if(t){const o=new Error(t);e&&(o.stack=e);try{RR.captureException(o)}catch{}}},[t,e]),$.useEffect(()=>{if(n&&n.length>0)for(const o of n){const i=new Error(o.message||"Circuit JSON Error");o.stack&&(i.stack=o.stack);try{RR.captureException(i,{error_type:o.type})}catch{}}},[n])},tOt=t=>{$.useEffect(()=>{try{wro(t)}catch{}},[t.source,t.component,t.isWebEmbedded,t.activeTab])},nOt="0.0.2405",X$o={version:nOt},fae=nIt()(oIt(t=>({lastRunEvalVersion:void 0,setLastRunEvalVersion:e=>{t({lastRunEvalVersion:e})}}),{name:"runframe-runner-store"})),$$o=t=>{const[e,n]=$.useState([]),[o,i]=$.useState(null),[r,s]=$.useState(""),[a,A]=lR("eval-version-selection",null),c=fae(h=>h.setLastRunEvalVersion),l=fae(h=>h.lastRunEvalVersion);return $.useEffect(()=>{t&&fetch("https://data.jsdelivr.com/v1/package/npm/@tscircuit/eval").then(h=>h.json()).then(h=>{if(Array.isArray(h?.versions)){let d=[...h.versions];h.tags?.latest&&(i(h.tags.latest),d=d.filter(_=>_!==h.tags.latest)),n(d)}}).catch(()=>{})},[t]),$.useEffect(()=>{t&&(a?(window.TSCIRCUIT_LATEST_EVAL_VERSION=a,c(a)):o&&(window.TSCIRCUIT_LATEST_EVAL_VERSION=o,c(o)))},[t,a,o]),{versions:$.useMemo(()=>e.filter(h=>h.includes(r)).slice(0,50),[e,r]),latestVersion:o,lastRunEvalVersion:l,search:r,setSearch:s,selectVersion:h=>{A(h),s("")}}},Z$o=({snippetNames:t,onSelect:e,onCancel:n,isOpen:o})=>{const[i,r]=$.useState(""),[s,a]=$.useState("");if(!o)return null;const A=t.filter(g=>g.toLowerCase().includes(s.toLowerCase())),c=s&&!t.includes(s),l=g=>{g.key==="Enter"&&(A.length===1?r(A[0]):c&&r(s))};return V.jsx("div",{className:"rf-fixed rf-inset-0 rf-bg-black rf-bg-opacity-50 rf-flex rf-items-center rf-justify-center rf-z-[100]",children:V.jsxs("div",{className:"rf-bg-white rf-rounded-lg rf-p-6 rf-w-96",children:[V.jsx("h2",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Select Snippet"}),V.jsx("input",{type:"text",className:"rf-w-full rf-px-4 rf-py-2 rf-border rf-rounded rf-mb-4",placeholder:"Search snippets or new snippet name...",value:s,onChange:g=>a(g.target.value),onKeyDown:l}),V.jsxs("div",{className:"rf-h-60 rf-overflow-y-auto",children:[A.map(g=>V.jsx("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 ${i===g?"bg-blue-50":""}`,onClick:()=>r(g),children:g},g)),c&&V.jsxs("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 text-blue-500 ${i===s?"bg-blue-50":""}`,onClick:()=>r(s),children:['Create new "',s,'"']})]}),V.jsxs("div",{className:"rf-mt-4 rf-flex rf-justify-end rf-gap-2",children:[V.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-text-gray-600 rf-hover:text-gray-800",onClick:n,children:"Cancel"}),V.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-bg-blue-500 rf-text-white rf-rounded rf-hover:bg-blue-600 rf-disabled:opacity-50",onClick:()=>i&&e(i),disabled:!i,children:i===s?`Create "${i}"`:`Save to ${i}`})]})]})})},eZo=t=>{const e=$.useRef(null),n=od(o=>o.recentEvents);$.useEffect(()=>{if(n.length===0)return;const o=n[0];o.event_id!==e.current&&(t(o),e.current=o.event_id)},[n,t])};var tZo=Object.defineProperty,dE=(t,e)=>tZo(t,"name",{value:e,configurable:!0}),p7e="Dialog",[oOt,iOt]=J2(p7e),[nZo,cQ]=oOt(p7e),m7e=dE(t=>{const{__scopeDialog:e,children:n,open:o,defaultOpen:i,onOpenChange:r,modal:s=!0}=t,a=$.useRef(null),A=$.useRef(null),[c,l]=G4({prop:o,defaultProp:i??!1,onChange:r,caller:p7e}),[g,u]=$.useState(0),[h,d]=$.useState(0);return V.jsx(nZo,{scope:e,triggerRef:a,contentRef:A,contentId:Pm(),titleId:Pm(),descriptionId:Pm(),titlePresent:g>0,descriptionPresent:h>0,setTitleCount:u,setDescriptionCount:d,open:c,onOpenChange:l,onOpenToggle:$.useCallback(()=>l(_=>!_),[l]),modal:s,children:n})},"Dialog"),oZo="DialogTrigger",iZo=$.forwardRef(dE(function(e,n){const{__scopeDialog:o,...i}=e,r=cQ(oZo,o),s=Bl(n,r.triggerRef);return V.jsx($A.button,{type:"button","aria-haspopup":"dialog","aria-expanded":r.open,"aria-controls":r.open?r.contentId:void 0,"data-state":Eae(r.open),...i,ref:s,onClick:Nr(e.onClick,r.onOpenToggle)})},"DialogTrigger")),rOt="DialogPortal",[rZo,sOt]=oOt(rOt,{forceMount:void 0}),I7e=dE(t=>{const{__scopeDialog:e,forceMount:n,children:o,container:i}=t,r=cQ(rOt,e);return V.jsx(rZo,{scope:e,forceMount:n,children:$.Children.map(o,s=>V.jsx(Dx,{present:n||r.open,children:V.jsx(w8e,{asChild:!0,container:i,children:s})}))})},"DialogPortal"),f7e="DialogOverlay",Cae=$.forwardRef(dE(function(e,n){const o=sOt(f7e,e.__scopeDialog),{forceMount:i=o.forceMount,...r}=e,s=cQ(f7e,e.__scopeDialog);return s.modal?V.jsx(Dx,{present:i||s.open,children:V.jsx(aZo,{...r,ref:n})}):null},"DialogOverlay")),sZo=HS("DialogOverlay.RemoveScroll"),aZo=$.forwardRef(dE(function(e,n){const{__scopeDialog:o,...i}=e,r=cQ(f7e,o),s=nRt(),a=Bl(n,s);return V.jsx(Dse,{as:sZo,allowPinchZoom:!0,shards:[r.contentRef],children:V.jsx($A.div,{"data-state":Eae(r.open),...i,ref:a,style:{pointerEvents:"auto",...i.style}})})},"DialogOverlayImpl")),qY="DialogContent",yae=$.forwardRef(dE(function(e,n){const o=sOt(qY,e.__scopeDialog),{forceMount:i=o.forceMount,...r}=e,s=cQ(qY,e.__scopeDialog);return V.jsx(Dx,{present:i||s.open,children:s.modal?V.jsx(AZo,{...r,ref:n}):V.jsx(cZo,{...r,ref:n})})},"DialogContent")),AZo=$.forwardRef(dE(function(e,n){const o=cQ(qY,e.__scopeDialog),i=$.useRef(null),r=Bl(n,o.contentRef,i);return $.useEffect(()=>{const s=i.current;if(s)return N8e(s)},[]),V.jsx(aOt,{...e,ref:r,trapFocus:o.open,disableOutsidePointerEvents:o.open,onCloseAutoFocus:Nr(e.onCloseAutoFocus,s=>{s.preventDefault(),o.triggerRef.current?.focus()}),onPointerDownOutside:Nr(e.onPointerDownOutside,s=>{const a=s.detail.originalEvent,A=a.button===0&&a.ctrlKey===!0;(a.button===2||A)&&s.preventDefault()}),onFocusOutside:Nr(e.onFocusOutside,s=>s.preventDefault())})},"DialogContentModal")),cZo=$.forwardRef(dE(function(e,n){const o=cQ(qY,e.__scopeDialog),i=$.useRef(!1),r=$.useRef(!1);return V.jsx(aOt,{...e,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{e.onCloseAutoFocus?.(s),s.defaultPrevented||(i.current||o.triggerRef.current?.focus(),s.preventDefault()),i.current=!1,r.current=!1},onInteractOutside:s=>{e.onInteractOutside?.(s),s.defaultPrevented||(i.current=!0,s.detail.originalEvent.type==="pointerdown"&&(r.current=!0));const a=s.target;o.triggerRef.current?.contains(a)&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&r.current&&s.preventDefault()}})},"DialogContentNonModal")),aOt=$.forwardRef(dE(function(e,n){const{__scopeDialog:o,trapFocus:i,onOpenAutoFocus:r,onCloseAutoFocus:s,...a}=e,A=cQ(qY,o);return BY(),V.jsx(V.Fragment,{children:V.jsx(d8e,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:r,onUnmountAutoFocus:s,children:V.jsx(sse,{role:"dialog",id:A.contentId,"aria-describedby":A.descriptionPresent?A.descriptionId:void 0,"aria-labelledby":A.titlePresent?A.titleId:void 0,"data-state":Eae(A.open),...a,ref:n,deferPointerDownOutside:!0,onDismiss:()=>A.onOpenChange(!1)})})})},"DialogContentImpl")),lZo="DialogTitle",C7e=$.forwardRef(dE(function(e,n){const{__scopeDialog:o,...i}=e,r=cQ(lZo,o),{setTitleCount:s}=r;return Sy(()=>(s(a=>a+1),()=>s(a=>a-1)),[s]),V.jsx($A.h2,{id:r.titleId,...i,ref:n})},"DialogTitle")),gZo="DialogDescription",y7e=$.forwardRef(dE(function(e,n){const{__scopeDialog:o,...i}=e,r=cQ(gZo,o),{setDescriptionCount:s}=r;return Sy(()=>(s(a=>a+1),()=>s(a=>a-1)),[s]),V.jsx($A.p,{id:r.descriptionId,...i,ref:n})},"DialogDescription")),uZo="DialogClose",AOt=$.forwardRef(dE(function(e,n){const{__scopeDialog:o,...i}=e,r=cQ(uZo,o);return V.jsx($A.button,{type:"button",...i,ref:n,onClick:Nr(e.onClick,()=>r.onOpenChange(!1))})},"DialogClose"));function Eae(t){return t?"open":"closed"}dE(Eae,"getState");var dZo=Object.defineProperty,N5=(t,e)=>dZo(t,"name",{value:e,configurable:!0}),hZo="AlertDialog",[_Zo,Lci]=J2(hZo,[iOt]),R5=iOt(),pZo=N5(t=>{const{__scopeAlertDialog:e,...n}=t,o=R5(e);return V.jsx(m7e,{...o,...n,modal:!0})},"AlertDialog");$.forwardRef(N5(function(e,n){const{__scopeAlertDialog:o,...i}=e,r=R5(o);return V.jsx(iZo,{...r,...i,ref:n})},"AlertDialogTrigger"));var mZo=N5(t=>{const{__scopeAlertDialog:e,...n}=t,o=R5(e);return V.jsx(I7e,{...o,...n})},"AlertDialogPortal"),IZo=$.forwardRef(N5(function(e,n){const{__scopeAlertDialog:o,...i}=e,r=R5(o);return V.jsx(Cae,{...r,...i,ref:n})},"AlertDialogOverlay")),fZo="AlertDialogContent",[CZo,yZo]=_Zo(fZo),EZo=$.forwardRef(N5(function(e,n){const{__scopeAlertDialog:o,children:i,...r}=e,s=R5(o),a=$.useRef(null),A=Bl(n,a),c=$.useRef(null);return V.jsx(CZo,{scope:o,cancelRef:c,children:V.jsx(yae,{role:"alertdialog",...s,...r,ref:A,onOpenAutoFocus:Nr(r.onOpenAutoFocus,l=>{l.preventDefault(),c.current?.focus({preventScroll:!0})}),onPointerDownOutside:l=>l.preventDefault(),onInteractOutside:l=>l.preventDefault(),children:i})})},"AlertDialogContent")),xZo=$.forwardRef(N5(function(e,n){const{__scopeAlertDialog:o,...i}=e,r=R5(o);return V.jsx(C7e,{...r,...i,ref:n})},"AlertDialogTitle")),BZo=$.forwardRef(N5(function(e,n){const{__scopeAlertDialog:o,...i}=e,r=R5(o);return V.jsx(y7e,{...r,...i,ref:n})},"AlertDialogDescription")),QZo=$.forwardRef(N5(function(e,n){const{__scopeAlertDialog:o,...i}=e,r=R5(o);return V.jsx(AOt,{...r,...i,ref:n})},"AlertDialogAction")),SZo="AlertDialogCancel",bZo=$.forwardRef(N5(function(e,n){const{__scopeAlertDialog:o,...i}=e,{cancelRef:r}=yZo(SZo,o),s=R5(o),a=Bl(n,r);return V.jsx(AOt,{...s,...i,ref:a})},"AlertDialogCancel")),DZo=pZo,vZo=mZo,cOt=IZo,lOt=EZo,gOt=QZo,uOt=bZo,dOt=xZo,hOt=BZo;const _Ot=DZo,PZo=vZo,pOt=$.forwardRef(({className:t,...e},n)=>V.jsx(cOt,{className:Zi("rf-fixed rf-inset-0 rf-z-50 rf-bg-black/80 data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0",t),...e,ref:n}));pOt.displayName=cOt.displayName;const E7e=$.forwardRef(({className:t,...e},n)=>V.jsxs(PZo,{children:[V.jsx(pOt,{}),V.jsx(lOt,{ref:n,className:Zi("rf-fixed rf-left-[50%] rf-top-[50%] rf-z-50 rf-grid rf-w-full rf-max-w-lg rf-translate-x-[-50%] rf-translate-y-[-50%] rf-gap-4 rf-border rf-border-zinc-200 rf-bg-white rf-p-6 rf-shadow-lg rf-duration-200 data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0 data-[state=closed]:rf-zoom-out-95 data-[state=open]:rf-zoom-in-95 data-[state=closed]:rf-slide-out-to-left-1/2 data-[state=closed]:rf-slide-out-to-top-[48%] data-[state=open]:rf-slide-in-from-left-1/2 data-[state=open]:rf-slide-in-from-top-[48%] sm:rf-rounded-lg dark:rf-border-zinc-800 dark:rf-bg-zinc-950",t),...e})]}));E7e.displayName=lOt.displayName;const x7e=({className:t,...e})=>V.jsx("div",{className:Zi("rf-flex rf-flex-col rf-space-y-2 rf-text-center sm:rf-text-left",t),...e});x7e.displayName="AlertDialogHeader";const B7e=({className:t,...e})=>V.jsx("div",{className:Zi("rf-flex rf-flex-col-reverse sm:rf-flex-row sm:rf-justify-end sm:rf-space-x-2",t),...e});B7e.displayName="AlertDialogFooter";const Q7e=$.forwardRef(({className:t,...e},n)=>V.jsx(dOt,{ref:n,className:Zi("rf-text-lg rf-font-semibold",t),...e}));Q7e.displayName=dOt.displayName;const S7e=$.forwardRef(({className:t,...e},n)=>V.jsx(hOt,{ref:n,className:Zi("rf-text-sm rf-text-zinc-500 dark:rf-text-zinc-400",t),...e}));S7e.displayName=hOt.displayName;const wZo=$.forwardRef(({className:t,...e},n)=>V.jsx(gOt,{ref:n,className:Zi(Sk(),t),...e}));wZo.displayName=gOt.displayName;const b7e=$.forwardRef(({className:t,...e},n)=>V.jsx(uOt,{ref:n,className:Zi(Sk({variant:"outline"}),"rf-mt-2 sm:rf-mt-0",t),...e}));b7e.displayName=uOt.displayName;var MZo=Object.defineProperty,T5=(t,e)=>MZo(t,"name",{value:e,configurable:!0}),D7e="Checkbox",[NZo,Hci]=J2(D7e),[RZo,v7e]=NZo(D7e);function mOt(t){const{__scopeCheckbox:e,checked:n,children:o,defaultChecked:i,disabled:r,form:s,name:a,onCheckedChange:A,required:c,value:l="on",internal_do_not_use_render:g}=t,[u,h]=G4({prop:n,defaultProp:i??!1,onChange:A,caller:D7e}),[d,_]=$.useState(null),[p,m]=$.useState(null),I=$.useRef(!1),[f,C]=$.useReducer(B=>B+1,0),y=d?!!s||!!d.closest("form"):!0,E={checked:u,disabled:r,setChecked:h,control:d,setControl:_,name:a,form:s,value:l,hasConsumerStoppedPropagationRef:I,userInteractionCount:f,onUserInteraction:C,required:c,defaultChecked:k5(i)?!1:i,isFormControl:y,bubbleInput:p,setBubbleInput:m};return V.jsx(RZo,{scope:e,...E,children:fOt(g)?g(E):o})}T5(mOt,"CheckboxProvider");var TZo="CheckboxTrigger",kZo=$.forwardRef(T5(function({__scopeCheckbox:e,onKeyDown:n,onClick:o,...i},r){const{control:s,value:a,disabled:A,checked:c,required:l,setControl:g,setChecked:u,hasConsumerStoppedPropagationRef:h,onUserInteraction:d,isFormControl:_,bubbleInput:p}=v7e(TZo,e),m=Bl(r,g),I=$.useRef(c);return $.useEffect(()=>{const f=s?.form;if(f){const C=T5(()=>u(I.current),"reset");return f.addEventListener("reset",C),()=>f.removeEventListener("reset",C)}},[s,u]),V.jsx($A.button,{type:"button",role:"checkbox","aria-checked":k5(c)?"mixed":c,"aria-required":l,"data-state":P7e(c),"data-disabled":A?"":void 0,disabled:A,value:a,...i,ref:m,onKeyDown:Nr(n,f=>{f.key==="Enter"&&f.preventDefault()}),onClick:Nr(o,f=>{d(),u(C=>k5(C)?!0:!C),p&&_&&(h.current=f.isPropagationStopped(),h.current||f.stopPropagation())})})},"CheckboxTrigger")),IOt=$.forwardRef(T5(function(e,n){const{__scopeCheckbox:o,name:i,checked:r,defaultChecked:s,required:a,disabled:A,value:c,onCheckedChange:l,form:g,...u}=e;return V.jsx(mOt,{__scopeCheckbox:o,checked:r,defaultChecked:s,disabled:A,required:a,onCheckedChange:l,name:i,form:g,value:c,internal_do_not_use_render:({isFormControl:h})=>V.jsxs(V.Fragment,{children:[V.jsx(kZo,{...u,ref:n,__scopeCheckbox:o}),h&&V.jsx(GZo,{__scopeCheckbox:o})]})})},"Checkbox")),FZo="CheckboxIndicator",LZo=$.forwardRef(T5(function(e,n){const{__scopeCheckbox:o,forceMount:i,...r}=e,s=v7e(FZo,o);return V.jsx(Dx,{present:i||k5(s.checked)||s.checked===!0,children:V.jsx($A.span,{"data-state":P7e(s.checked),"data-disabled":s.disabled?"":void 0,...r,ref:n,style:{pointerEvents:"none",...e.style}})})},"CheckboxIndicator")),HZo="CheckboxBubbleInput",GZo=$.forwardRef(T5(function({__scopeCheckbox:e,onClick:n,...o},i){const{control:r,hasConsumerStoppedPropagationRef:s,userInteractionCount:a,checked:A,defaultChecked:c,required:l,disabled:g,name:u,value:h,form:d,bubbleInput:_,setBubbleInput:p}=v7e(HZo,e),m=Bl(i,p),I=D8e(r),f=$.useRef(!1),C=$.useRef(A),y=$.useRef(a);$.useEffect(()=>{const B=_;if(!B)return;const Q=window.HTMLInputElement.prototype,D=Object.getOwnPropertyDescriptor(Q,"checked").set,T=a!==y.current;y.current=a;const N=C.current!==A;C.current=A;const H=!(T&&s.current);if(N&&D){f.current=!T;const G=new Event("click",{bubbles:H});B.indeterminate=k5(A),D.call(B,k5(A)?!1:A),B.dispatchEvent(G),f.current=!1}},[_,A,s,a]);const E=$.useRef(k5(A)?!1:A);return V.jsx($A.input,{type:"checkbox","aria-hidden":!0,defaultChecked:c??E.current,required:l,disabled:g,name:u,value:h,form:d,...o,tabIndex:-1,ref:m,onClick:Nr(n,B=>{f.current&&B.stopPropagation()}),style:{...o.style,...I,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})},"CheckboxBubbleInput"));function fOt(t){return typeof t=="function"}T5(fOt,"isFunction");function k5(t){return t==="indeterminate"}T5(k5,"isIndeterminate");function P7e(t){return k5(t)?"indeterminate":t?"checked":"unchecked"}T5(P7e,"getState");const WY=$.forwardRef(({className:t,...e},n)=>V.jsx(IOt,{ref:n,className:Zi("rf-peer rf-h-4 rf-w-4 rf-shrink-0 rf-rounded-sm rf-border rf-border-zinc-200 rf-border-zinc-900 rf-shadow focus-visible:rf-outline-none focus-visible:rf-ring-1 focus-visible:rf-ring-zinc-950 disabled:rf-cursor-not-allowed disabled:rf-opacity-50 data-[state=checked]:rf-bg-zinc-900 data-[state=checked]:rf-text-zinc-50 dark:rf-border-zinc-800 dark:rf-border-zinc-50 dark:focus-visible:rf-ring-zinc-300 dark:data-[state=checked]:rf-bg-zinc-50 dark:data-[state=checked]:rf-text-zinc-900",t),...e,children:V.jsx(LZo,{className:Zi("rf-flex rf-items-center rf-justify-center rf-text-current"),children:V.jsx(V6,{className:"rf-h-4 rf-w-4"})})}));WY.displayName=IOt.displayName;const qk=m7e,OZo=I7e,COt=$.forwardRef(({className:t,...e},n)=>V.jsx(Cae,{className:Zi("rf-fixed rf-inset-0 rf-z-50 rf-bg-black/80 data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0",t),...e,ref:n}));COt.displayName=Cae.displayName;const i8=$.forwardRef(({className:t,children:e,showOverlay:n=!0,...o},i)=>V.jsxs(OZo,{children:[V.jsx(COt,{className:Zi(n?"":"rf-hidden")}),V.jsx(yae,{ref:i,className:Zi("rf-fixed rf-left-[50%] rf-top-[50%] rf-z-50 rf-grid rf-w-full rf-max-w-lg rf-translate-x-[-50%] rf-translate-y-[-50%] rf-gap-4 rf-border rf-border-zinc-200 rf-bg-white rf-p-6 rf-shadow-lg rf-duration-200 data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0 data-[state=closed]:rf-zoom-out-95 data-[state=open]:rf-zoom-in-95 data-[state=closed]:rf-slide-out-to-left-1/2 data-[state=closed]:rf-slide-out-to-top-[48%] data-[state=open]:rf-slide-in-from-left-1/2 data-[state=open]:rf-slide-in-from-top-[48%] sm:rf-rounded-lg dark:rf-border-zinc-800 dark:rf-bg-zinc-950",t),...o,children:e})]}));i8.displayName=yae.displayName;const r8=({className:t,...e})=>V.jsx("div",{className:Zi("rf-flex rf-flex-col rf-space-y-2 rf-text-center sm:rf-text-left",t),...e});r8.displayName="DialogHeader";const jY=({className:t,...e})=>V.jsx("div",{className:Zi("rf-flex rf-flex-col-reverse sm:rf-flex-row sm:rf-justify-end sm:rf-space-x-2",t),...e});jY.displayName="DialogFooter";const s8=$.forwardRef(({className:t,...e},n)=>V.jsx(C7e,{ref:n,className:Zi("rf-text-lg rf-font-semibold",t),...e}));s8.displayName=C7e.displayName;const Wk=$.forwardRef(({className:t,...e},n)=>V.jsx(y7e,{ref:n,className:Zi("rf-text-sm rf-text-zinc-500 dark:rf-text-zinc-400",t),...e}));Wk.displayName=y7e.displayName;const xae={"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"}},KZo="https://cdn.jsdelivr.net/npm/easyeda@latest/dist/browser/index.js";let w7e=null;const M7e=async()=>(w7e||(w7e=import(KZo)),w7e),UZo=t=>(e,n)=>{const o=new Headers(n?.headers),i={};return o.forEach((r,s)=>{i[s]=r}),fetch(`${t?.apiBase??Uf}/proxy`,{...n,headers:{...i,"X-Target-Url":e.toString(),"X-Sender-Origin":i.origin??"","X-Sender-Host":i.host??"https://easyeda.com","X-Sender-Referer":i.referer??"","X-Sender-User-Agent":i["user-agent"]??"","X-Sender-Cookie":i.cookie??"",authority:i.authority??"","content-type":i["content-type"]??"",...t?.headers}})},YZo=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??[]},zZo=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}),yOt=async(t,e)=>{const{fetchEasyEDAComponent:n}=await M7e();return n(t,{fetch:UZo(e),includeModelMetadata:e?.includeModelMetadata})},VZo=async(t,e)=>{const{convertRawEasyToTsx:n}=await M7e(),o=await yOt(t,e);return n({rawEasy:o})},JZo=async(t,e)=>{const{EasyEdaJsonSchema:n,convertEasyEdaJsonToCircuitJson:o}=await M7e(),i=await yOt(t,{...e,includeModelMetadata:!1}),r=n.parse(i);return o(r,{shouldRecenter:!0,showDesignator:!0,useModelCdn:!1})};function aw(t){return Array.isArray?Array.isArray(t):xOt(t)==="[object Array]"}function qZo(t){if(typeof t=="string")return t;if(typeof t=="bigint")return t.toString();const e=t+"";return e=="0"&&1/t==-1/0?"-0":e}function N7e(t){return t==null?"":qZo(t)}function nC(t){return typeof t=="string"}function Bae(t){return typeof t=="number"}function WZo(t){return t===!0||t===!1||jZo(t)&&xOt(t)=="[object Boolean]"}function EOt(t){return typeof t=="object"}function jZo(t){return EOt(t)&&t!==null}function hE(t){return t!=null}function Qae(t){return!t.trim().length}function xOt(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const XZo="Incorrect 'index' type",R7e="Invalid doc index: must be a non-negative integer within the bounds of the docs array",$Zo=t=>`Invalid value for key ${t}`,ZZo=t=>`Pattern length exceeds max of ${t}.`,eei=t=>`Missing ${t} property in key`,tei=t=>`Property 'weight' in key '${t}' must be a positive integer`,nei="Fuse.match does not support useTokenSearch: token search requires corpus-level statistics (df, fieldCount) that a one-off string comparison does not have. Use new Fuse(...).search(...) instead.",BOt=Object.prototype.hasOwnProperty;var oei=class{constructor(t){this._keys=[],this._keyMap={};let e=0;t.forEach(n=>{const o=QOt(n);this._keys.push(o),this._keyMap[o.id]=o,e+=o.weight}),this._keys.forEach(n=>{n.weight/=e})}get(t){return this._keyMap[t]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}};function QOt(t){let e=null,n=null,o=null,i=1,r=null;if(nC(t)||aw(t))o=t,e=SOt(t),n=Sae(t);else{if(!BOt.call(t,"name"))throw new Error(eei("name"));const s=t.name;if(o=s,BOt.call(t,"weight")&&t.weight!==void 0&&(i=t.weight,i<=0))throw new Error(tei(Sae(s)));e=SOt(s),n=Sae(s),r=t.getFn??null}return{path:e,id:n,weight:i,src:o,getFn:r}}function SOt(t){return aw(t)?t:t.split(".")}function Sae(t){return aw(t)?t.join("."):t}function iei(t,e){const n=[];let o=!1;const i=(r,s,a,A)=>{if(hE(r))if(!s[a])n.push(A!==void 0?{v:r,i:A}:r);else{const c=r[s[a]];if(!hE(c))return;if(a===s.length-1&&(nC(c)||Bae(c)||WZo(c)||typeof c=="bigint"))n.push(A!==void 0?{v:N7e(c),i:A}:N7e(c));else if(aw(c)){o=!0;for(let l=0,g=c.length;l<g;l+=1)i(c[l],s,a+1,l)}else s.length&&i(c,s,a+1,A)}};return i(t,nC(e)?e.split("."):e,0),o?n:n[0]}const Ls=Object.freeze({...{isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(t,e)=>t.score===e.score?t.idx<e.idx?-1:1:t.score<e.score?-1:1},...{includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},...{location:0,threshold:.6,distance:100},...{useExtendedSearch:!1,useTokenSearch:!1,tokenize:void 0,tokenMatch:"any",getFn:iei,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1}});function rei(t){return t>=9&&t<=13||t===32||t===160}function sei(t=1,e=3){const n=new Map,o=Math.pow(10,e);return{get(i){let r=0,s=!1;for(let A=0;A<i.length;A++)rei(i.charCodeAt(A))?s=!1:s||(r++,s=!0);if(r===0&&(r=1),n.has(r))return n.get(r);const a=Math.round(o/Math.pow(r,.5*t))/o;return n.set(r,a),a},clear(){n.clear()}}}var T7e=class{constructor({getFn:t=Ls.getFn,fieldNormWeight:e=Ls.fieldNormWeight}={}){this.norm=sei(e,3),this.getFn=t,this.isCreated=!1,this.docs=[],this.keys=[],this._keysMap={},this.setIndexRecords()}setSources(t=[]){this.docs=t}setIndexRecords(t=[]){this.records=t}setKeys(t=[]){this.keys=t,this._keysMap={},t.forEach((e,n)=>{this._keysMap[e.id]=n})}create(){if(this.isCreated||!this.docs.length)return;this.isCreated=!0;const t=this.docs.length;this.records=new Array(t);let e=0;if(nC(this.docs[0]))for(let n=0;n<t;n++){const o=this._createStringRecord(this.docs[n],n);o&&(this.records[e++]=o)}else for(let n=0;n<t;n++)this.records[e++]=this._createObjectRecord(this.docs[n],n);this.records.length=e,this.norm.clear()}add(t,e){if(!Number.isInteger(e)||e<0)throw new Error(R7e);if(nC(t)){const o=this._createStringRecord(t,e);return o&&this.records.push(o),o}const n=this._createObjectRecord(t,e);return this.records.push(n),n}removeAt(t){if(!Number.isInteger(t)||t<0)throw new Error(R7e);for(let e=0,n=this.records.length;e<n;e+=1)if(this.records[e].i===t){this.records.splice(e,1);break}for(let e=0,n=this.records.length;e<n;e+=1)this.records[e].i>t&&(this.records[e].i-=1)}removeAll(t){const e=new Set;for(const o of t)Number.isInteger(o)&&o>=0&&e.add(o);if(e.size===0)return;this.records=this.records.filter(o=>!e.has(o.i));const n=Array.from(e).sort((o,i)=>o-i);for(const o of this.records){let i=0,r=n.length;for(;i<r;){const s=i+r>>>1;n[s]<o.i?i=s+1:r=s}o.i-=i}}getValueForItemAtKeyId(t,e){return t[this._keysMap[e]]}size(){return this.records.length}_createStringRecord(t,e){return!hE(t)||Qae(t)?null:{v:t,i:e,n:this.norm.get(t)}}_createObjectRecord(t,e){const n={i:e,$:{}};for(let o=0,i=this.keys.length;o<i;o++){const r=this.keys[o],s=r.getFn?r.getFn(t):this.getFn(t,r.path);if(hE(s)){if(aw(s)){const a=[];for(let A=0,c=s.length;A<c;A+=1){const l=s[A];if(hE(l)){if(nC(l)){if(!Qae(l)){const g={v:l,i:A,n:this.norm.get(l)};a.push(g)}}else if(hE(l.v)){const g=nC(l.v)?l.v:N7e(l.v);if(!Qae(g)){const u={v:g,i:l.i,n:this.norm.get(g)};a.push(u)}}}}n.$[o]=a}else if(nC(s)&&!Qae(s)){const a={v:s,n:this.norm.get(s)};n.$[o]=a}}}return n}toJSON(){return{keys:this.keys.map(({getFn:t,...e})=>e),records:this.records}}};function bOt(t,e,{getFn:n=Ls.getFn,fieldNormWeight:o=Ls.fieldNormWeight}={}){const i=new T7e({getFn:n,fieldNormWeight:o});return i.setKeys(t.map(QOt)),i.setSources(e),i.create(),i}function aei(t,{getFn:e=Ls.getFn,fieldNormWeight:n=Ls.fieldNormWeight}={}){const{keys:o,records:i}=t,r=new T7e({getFn:e,fieldNormWeight:n});return r.setKeys(o),r.setIndexRecords(i),r}function Aei(t=[],e=Ls.minMatchCharLength){const n=[];let o=-1,i=-1,r=0;for(let s=t.length;r<s;r+=1){const a=t[r];a&&o===-1?o=r:!a&&o!==-1&&(i=r-1,i-o+1>=e&&n.push([o,i]),o=-1)}return t[r-1]&&r-o>=e&&n.push([o,r-1]),n}function cei(t,e,n,{location:o=Ls.location,distance:i=Ls.distance,threshold:r=Ls.threshold,findAllMatches:s=Ls.findAllMatches,minMatchCharLength:a=Ls.minMatchCharLength,includeMatches:A=Ls.includeMatches,ignoreLocation:c=Ls.ignoreLocation}={}){if(e.length>32)throw new Error(ZZo(32));const l=e.length,g=t.length,u=Math.max(0,Math.min(o,g));let h=r,d=u;const _=(b,D)=>{const T=b/l;if(c)return T;const N=Math.abs(u-D);return i?T+N/i:N?1:T},p=a>1||A,m=p?Array(g):[];let I;for(;(I=t.indexOf(e,d))>-1;){const b=_(0,I);if(h=Math.min(b,h),d=I+l,p){let D=0;for(;D<l;)m[I+D]=1,D+=1}}d=-1;let f=[],C=1,y=0,E=l+g;const B=1<<l-1;for(let b=0;b<l;b+=1){let D=0,T=E;for(;D<T;)_(b,u+T)<=h?D=T:E=T,T=Math.floor((E-D)/2+D);E=T;let N=Math.max(1,u-T+1);const H=s?g:Math.min(u+T,g)+l,G=Array(H+2);G[H+1]=(1<<b)-1;for(let O=H;O>=N;O-=1){const U=O-1,W=n[t[U]];if(G[O]=(G[O+1]<<1|1)&W,b&&(G[O]|=(f[O+1]|f[O])<<1|1|f[O+1]),G[O]&B&&(C=_(b,U),C<=h)){if(h=C,d=U,y=b,d<=u)break;N=Math.max(1,2*u-d)}}if(_(b+1,u)>h)break;f=G}if(p&&d>=0){const b=Math.min(g-1,d+l-1+y);for(let D=d;D<=b;D+=1)n[t[D]]&&(m[D]=1)}const Q={isMatch:d>=0,score:Math.max(.001,C)};if(p){const b=Aei(m,a);b.length?A&&(Q.indices=b):Q.isMatch=!1}return Q}function lei(t){const e={};for(let n=0,o=t.length;n<o;n+=1){const i=t.charAt(n);e[i]=(e[i]||0)|1<<o-n-1}return e}function k7e(t){if(t.length<=1)return t;t.sort((n,o)=>n[0]-o[0]||n[1]-o[1]);const e=[t[0]];for(let n=1,o=t.length;n<o;n+=1){const i=e[e.length-1],r=t[n];r[0]<=i[1]+1?i[1]=Math.max(i[1],r[1]):e.push(r)}return e}const DOt={ł:"l",Ł:"L",đ:"d",Đ:"D",ø:"o",Ø:"O",ħ:"h",Ħ:"H",ŧ:"t",Ŧ:"T",ı:"i",ß:"ss"},gei=new RegExp("["+Object.keys(DOt).join("")+"]","g"),XY=typeof String.prototype.normalize=="function"?t=>t.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,"").replace(gei,e=>DOt[e]):t=>t;var F7e=class{constructor(t,{location:e=Ls.location,threshold:n=Ls.threshold,distance:o=Ls.distance,includeMatches:i=Ls.includeMatches,findAllMatches:r=Ls.findAllMatches,minMatchCharLength:s=Ls.minMatchCharLength,isCaseSensitive:a=Ls.isCaseSensitive,ignoreDiacritics:A=Ls.ignoreDiacritics,ignoreLocation:c=Ls.ignoreLocation}={}){if(this.options={location:e,threshold:n,distance:o,includeMatches:i,findAllMatches:r,minMatchCharLength:s,isCaseSensitive:a,ignoreDiacritics:A,ignoreLocation:c},t=a?t:t.toLowerCase(),t=A?XY(t):t,this.pattern=t,this.chunks=[],!this.pattern.length)return;const l=(u,h)=>{this.chunks.push({pattern:u,alphabet:lei(u),startIndex:h})},g=this.pattern.length;if(g>32){let u=0;const h=g%32,d=g-h;for(;u<d;)l(this.pattern.substr(u,32),u),u+=32;if(h){const _=g-32;l(this.pattern.substr(_),_)}}else l(this.pattern,0)}searchIn(t){const{isCaseSensitive:e,ignoreDiacritics:n,includeMatches:o}=this.options;if(t=e?t:t.toLowerCase(),t=n?XY(t):t,this.pattern===t){if(t.length<this.options.minMatchCharLength)return{isMatch:!1,score:1};const d={isMatch:!0,score:0};return o&&(d.indices=[[0,t.length-1]]),d}const{location:i,distance:r,threshold:s,findAllMatches:a,minMatchCharLength:A,ignoreLocation:c}=this.options,l=[];let g=0,u=!1;this.chunks.forEach(({pattern:d,alphabet:_,startIndex:p})=>{const{isMatch:m,score:I,indices:f}=cei(t,d,_,{location:i+p,distance:r,threshold:s,findAllMatches:a,minMatchCharLength:A,includeMatches:o,ignoreLocation:c});m&&(u=!0),g+=I,m&&f&&l.push(...f)});const h={isMatch:u,score:u?g/this.chunks.length:1};return u&&o&&(h.indices=k7e(l)),h}};const uei=new Set(["fuzzy","include"]);function dei(t){return t.startsWith("inverse")}const L7e=[{type:"exact",multiRegex:/^="(.*)"$/,singleRegex:/^=(.*)$/,create:t=>({type:"exact",search(e){const n=e===t;return{isMatch:n,score:n?0:1,indices:[0,t.length-1]}}})},{type:"include",multiRegex:/^'"(.*)"$/,singleRegex:/^'(.*)$/,create:t=>({type:"include",search(e){let n=0,o;const i=[],r=t.length;for(;(o=e.indexOf(t,n))>-1;)n=o+r,i.push([o,n-1]);const s=!!i.length;return{isMatch:s,score:s?0:1,indices:i}}})},{type:"prefix-exact",multiRegex:/^\^"(.*)"$/,singleRegex:/^\^(.*)$/,create:t=>({type:"prefix-exact",search(e){const n=e.startsWith(t);return{isMatch:n,score:n?0:1,indices:[0,t.length-1]}}})},{type:"inverse-prefix-exact",multiRegex:/^!\^"(.*)"$/,singleRegex:/^!\^(.*)$/,create:t=>({type:"inverse-prefix-exact",search(e){const n=!e.startsWith(t);return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}})},{type:"inverse-suffix-exact",multiRegex:/^!"(.*)"\$$/,singleRegex:/^!(.*)\$$/,create:t=>({type:"inverse-suffix-exact",search(e){const n=!e.endsWith(t);return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}})},{type:"suffix-exact",multiRegex:/^"(.*)"\$$/,singleRegex:/^(.*)\$$/,create:t=>({type:"suffix-exact",search(e){const n=e.endsWith(t);return{isMatch:n,score:n?0:1,indices:[e.length-t.length,e.length-1]}}})},{type:"inverse-exact",multiRegex:/^!"(.*)"$/,singleRegex:/^!(.*)$/,create:t=>({type:"inverse-exact",search(e){const n=e.indexOf(t)===-1;return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}})},{type:"fuzzy",multiRegex:/^"(.*)"$/,singleRegex:/^(.*)$/,create:(t,e={})=>{const n=new F7e(t,{location:e.location??Ls.location,threshold:e.threshold??Ls.threshold,distance:e.distance??Ls.distance,includeMatches:e.includeMatches??Ls.includeMatches,findAllMatches:e.findAllMatches??Ls.findAllMatches,minMatchCharLength:e.minMatchCharLength??Ls.minMatchCharLength,isCaseSensitive:e.isCaseSensitive??Ls.isCaseSensitive,ignoreDiacritics:e.ignoreDiacritics??Ls.ignoreDiacritics,ignoreLocation:e.ignoreLocation??Ls.ignoreLocation});return{type:"fuzzy",search(o){return n.searchIn(o)}}}}],vOt=L7e.length,hei="\0",_ei="|";function pei(t){const e=[],n=t.length;let o=0;for(;o<n;){for(;o<n&&t[o]===" ";)o++;if(o>=n)break;let i=o;for(;i<n&&t[i]!==" "&&t[i]!=='"';)i++;if(i<n&&t[i]==='"'){for(i++;i<n;){if(t[i]==='"'){const r=i+1;if(r>=n||t[r]===" "){i++;break}if(t[r]==="$"&&(r+1>=n||t[r+1]===" ")){i+=2;break}}i++}e.push(t.substring(o,i)),o=i}else{for(;i<n&&t[i]!==" ";)i++;e.push(t.substring(o,i)),o=i}}return e}function POt(t,e){const n=t.match(e);return n?n[1]:null}function mei(t,e={}){return t.replace(/\\\|/g,hei).split(_ei).map(n=>{const o=pei(n.replace(/\u0000/g,"|").trim()).filter(r=>r&&!!r.trim()),i=[];for(let r=0,s=o.length;r<s;r+=1){const a=o[r];let A=!1,c=-1;for(;!A&&++c<vOt;){const l=L7e[c],g=POt(a,l.multiRegex);g&&(i.push(l.create(g,e)),A=!0)}if(!A)for(c=-1;++c<vOt;){const l=L7e[c],g=POt(a,l.singleRegex);if(g){i.push(l.create(g,e));break}}}return i})}var Iei=class{constructor(t,{isCaseSensitive:e=Ls.isCaseSensitive,ignoreDiacritics:n=Ls.ignoreDiacritics,includeMatches:o=Ls.includeMatches,minMatchCharLength:i=Ls.minMatchCharLength,ignoreLocation:r=Ls.ignoreLocation,findAllMatches:s=Ls.findAllMatches,location:a=Ls.location,threshold:A=Ls.threshold,distance:c=Ls.distance}={}){this.query=null,this.options={isCaseSensitive:e,ignoreDiacritics:n,includeMatches:o,minMatchCharLength:i,findAllMatches:s,ignoreLocation:r,location:a,threshold:A,distance:c},t=e?t:t.toLowerCase(),t=n?XY(t):t,this.pattern=t,this.query=mei(this.pattern,this.options)}static condition(t,e){return e.useExtendedSearch}searchIn(t){const e=this.query;if(!e)return{isMatch:!1,score:1};const{includeMatches:n,isCaseSensitive:o,ignoreDiacritics:i}=this.options;t=o?t:t.toLowerCase(),t=i?XY(t):t;let r=0;const s=[];let a=0,A=!1;for(let c=0,l=e.length;c<l;c+=1){const g=e[c];s.length=0,r=0,A=!1;for(let u=0,h=g.length;u<h;u+=1){const d=g[u],{isMatch:_,indices:p,score:m}=d.search(t);if(_)r+=1,a+=m,dei(d.type)&&(A=!0),n&&(uei.has(d.type)?s.push(...p):s.push(p));else{a=0,r=0,s.length=0,A=!1;break}}if(r){const u={isMatch:!0,score:a/r};return A&&(u.hasInverse=!0),n&&(u.indices=k7e(s)),u}}return{isMatch:!1,score:1}}};const H7e=[];function G7e(...t){H7e.push(...t)}function bae(t,e){for(let n=0,o=H7e.length;n<o;n+=1){const i=H7e[n];if(i.condition(t,e))return new i(t,e)}return new F7e(t,e)}const Dae={AND:"$and",OR:"$or"},O7e={PATH:"$path",PATTERN:"$val"},K7e=t=>!!(t[Dae.AND]||t[Dae.OR]),fei=t=>!!t[O7e.PATH],Cei=t=>!aw(t)&&EOt(t)&&!K7e(t),wOt=t=>({[Dae.AND]:Object.keys(t).map(e=>({[e]:t[e]}))});function MOt(t,e,{auto:n=!0}={}){const o=i=>{if(nC(i)){const A={keyId:null,pattern:i};return n&&(A.searcher=bae(i,e)),A}const r=Object.keys(i),s=fei(i);if(!s&&r.length>1&&!K7e(i))return o(wOt(i));if(Cei(i)){const A=s?i[O7e.PATH]:r[0],c=s?i[O7e.PATTERN]:i[A];if(!nC(c))throw new Error($Zo(A));const l={keyId:Sae(A),pattern:c};return n&&(l.searcher=bae(c,e)),l}const a={children:[],operator:r[0]};return r.forEach(A=>{const c=i[A];aw(c)&&c.forEach(l=>{a.children.push(o(l))})}),a};return K7e(t)||(t=wOt(t)),o(t)}function U7e(t,{ignoreFieldNorm:e=Ls.ignoreFieldNorm}){let n=1;return t.forEach(({key:o,norm:i,score:r})=>{const s=o?o.weight:null;n*=Math.pow(r===0&&s?Number.EPSILON:r,(s||1)*(e?1:i))}),n}function yei(t,{ignoreFieldNorm:e=Ls.ignoreFieldNorm}){t.forEach(n=>{n.score=U7e(n.matches,{ignoreFieldNorm:e})})}var Eei=class{constructor(t,e){this.limit=t,this.heap=[],this.comparator=e}get size(){return this.heap.length}insert(t){this.size<this.limit?(this.heap.push(t),this._bubbleUp(this.size-1)):this.comparator(t,this.heap[0])<0&&(this.heap[0]=t,this._sinkDown(0))}extractSorted(){return this.heap.sort(this.comparator)}_bubbleUp(t){const e=this.heap;for(;t>0;){const n=t-1>>1;if(this.comparator(e[t],e[n])<=0)break;const o=e[t];e[t]=e[n],e[n]=o,t=n}}_sinkDown(t){const e=this.heap,n=e.length;let o=t;do{t=o;const i=2*t+1,r=2*t+2;if(i<n&&this.comparator(e[i],e[o])>0&&(o=i),r<n&&this.comparator(e[r],e[o])>0&&(o=r),o!==t){const s=e[t];e[t]=e[o],e[o]=s}}while(o!==t)}};function xei(t){const e=[];return t.matches.forEach(n=>{if(!hE(n.indices)||!n.indices.length)return;const o={indices:n.indices,value:n.value};n.key&&(o.key=n.key.id),n.idx>-1&&(o.refIndex=n.idx),e.push(o)}),e}function Bei(t,e,{includeMatches:n=Ls.includeMatches,includeScore:o=Ls.includeScore}={}){return t.map(i=>{const{idx:r}=i,s={item:e[r],refIndex:r};return n&&(s.matches=xei(i)),o&&(s.score=i.score),s})}const Qei=/[\p{L}\p{M}\p{N}_]+/gu,NOt=new WeakSet;function Sei(t){NOt.has(t)||(NOt.add(t),console.warn(`[Fuse] tokenize regex ${t} lacks the global flag; only the first match per text will be returned. Add the 'g' flag.`))}function bei(t){if(typeof t=="function"){let e=!1;return n=>{const o=t(n);if(!e&&(e=!0,!Array.isArray(o)||o.some(i=>typeof i!="string")))throw new Error(`[Fuse] tokenize function must return string[]; received ${Array.isArray(o)?"array containing non-strings":typeof o}.`);return o}}return t instanceof RegExp?(t.global||Sei(t),e=>e.match(t)||[]):e=>e.match(Qei)||[]}function Y7e({isCaseSensitive:t=!1,ignoreDiacritics:e=!1,tokenize:n}={}){const o=bei(n);return{tokenize(i){return t||(i=i.toLowerCase()),e&&(i=XY(i)),o(i)}}}var Dei=class{static condition(t,e){return e.useTokenSearch}constructor(t,e){this.options=e,this.analyzer=Y7e({isCaseSensitive:e.isCaseSensitive,ignoreDiacritics:e.ignoreDiacritics,tokenize:e.tokenize});const n=this.analyzer.tokenize(t),{df:o,fieldCount:i}=e._invertedIndex;this.termSearchers=[],this.idfWeights=[];for(const r of n){this.termSearchers.push(new F7e(r,{location:e.location,threshold:e.threshold,distance:e.distance,includeMatches:e.includeMatches,findAllMatches:e.findAllMatches,minMatchCharLength:e.minMatchCharLength,isCaseSensitive:e.isCaseSensitive,ignoreDiacritics:e.ignoreDiacritics,ignoreLocation:!0}));const s=o.get(r)||0,a=Math.log(1+(i-s+.5)/(s+.5));this.idfWeights.push(a)}this.combineAll=e.tokenMatch==="all",this.numTerms=this.termSearchers.length,this.useMask=this.numTerms<=31}searchIn(t){if(!this.termSearchers.length)return{isMatch:!1,score:1};const e=[];let n=0,o=0,i=0,r=0;const s=this.combineAll&&!this.useMask?new Set:null;for(let c=0;c<this.termSearchers.length;c++){const l=this.termSearchers[c].searchIn(t),g=this.idfWeights[c];o+=g,l.isMatch&&(i++,n+=g*(1-l.score),l.indices&&e.push(...l.indices),this.combineAll&&(this.useMask?r|=1<<c:s.add(c)))}if(i===0)return{isMatch:!1,score:1};const a=o>0?1-n/o:0,A={isMatch:!0,score:Math.max(.001,a)};return this.options.includeMatches&&e.length&&(A.indices=k7e(e)),this.combineAll&&(this.useMask?A.matchedMask=r:A.matchedTerms=s,A.termCount=this.numTerms),A}};function z7e(t,e,n,o){const i=o.tokenize(e);if(!i.length)return;t.fieldCount++,t.docFieldCount.set(n,(t.docFieldCount.get(n)||0)+1);const r=new Set(i);let s=t.docTermFieldHits.get(n);s||(s=new Map,t.docTermFieldHits.set(n,s));for(const a of r)s.set(a,(s.get(a)||0)+1),t.df.set(a,(t.df.get(a)||0)+1)}function ROt(t,e,n,o){const{i,v:r,$:s}=e;if(r!==void 0){z7e(t,r,i,o);return}if(s)for(let a=0;a<n;a++){const A=s[a];if(A)if(Array.isArray(A))for(const c of A)z7e(t,c.v,i,o);else z7e(t,A.v,i,o)}}function vei(t,e,n){const o={fieldCount:0,df:new Map,docFieldCount:new Map,docTermFieldHits:new Map};for(const i of t)ROt(o,i,e,n);return o}function Pei(t,e,n,o){ROt(t,e,n,o)}function wei(t,e){const n=t.docFieldCount.get(e);if(n===void 0)return;t.fieldCount-=n,t.docFieldCount.delete(e);const o=t.docTermFieldHits.get(e);if(o){for(const[i,r]of o){const s=(t.df.get(i)||0)-r;s<=0?t.df.delete(i):t.df.set(i,s)}t.docTermFieldHits.delete(e)}}function TOt(t,e){if(e.length===0)return;const n=Array.from(new Set(e)).sort((a,A)=>a-A);for(const a of n)wei(t,a);const o=a=>{let A=0,c=n.length;for(;A<c;){const l=A+c>>>1;n[l]<a?A=l+1:c=l}return a-A},i=n[0],r=new Map;for(const[a,A]of t.docFieldCount)r.set(a>i?o(a):a,A);t.docFieldCount=r;const s=new Map;for(const[a,A]of t.docTermFieldHits)s.set(a>i?o(a):a,A);t.docTermFieldHits=s}var Aw=class{constructor(t,e,n){this.options={...Ls,...e},this.options.useExtendedSearch,this.options.useTokenSearch,this._keyStore=new oei(this.options.keys),this._docs=t,this._myIndex=null,this._invertedIndex=null,this.setCollection(t,n),this._lastQuery=null,this._lastSearcher=null}_getSearcher(t){if(this._lastQuery===t)return this._lastSearcher;const e=bae(t,this._invertedIndex?{...this.options,_invertedIndex:this._invertedIndex}:this.options);return this._lastQuery=t,this._lastSearcher=e,e}setCollection(t,e){if(this._docs=t,e&&!(e instanceof T7e))throw new Error(XZo);if(this._myIndex=e||bOt(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight}),this.options.useTokenSearch){const n=Y7e({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});this._invertedIndex=vei(this._myIndex.records,this._myIndex.keys.length,n)}this._invalidateSearcherCache()}add(t){if(!hE(t))return;this._docs.push(t);const e=this._myIndex.add(t,this._docs.length-1);if(this._invertedIndex&&e){const n=Y7e({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});Pei(this._invertedIndex,e,this._myIndex.keys.length,n)}this._invalidateSearcherCache()}remove(t=()=>!1){const e=[],n=[];for(let o=0,i=this._docs.length;o<i;o+=1)t(this._docs[o],o)&&(e.push(this._docs[o]),n.push(o));if(n.length){this._invertedIndex&&TOt(this._invertedIndex,n);const o=new Set(n);this._docs=this._docs.filter((i,r)=>!o.has(r)),this._myIndex.removeAll(n),this._invalidateSearcherCache()}return e}removeAt(t){if(!Number.isInteger(t)||t<0||t>=this._docs.length)throw new Error(R7e);this._invertedIndex&&TOt(this._invertedIndex,[t]);const e=this._docs.splice(t,1)[0];return this._myIndex.removeAt(t),this._invalidateSearcherCache(),e}_invalidateSearcherCache(){this._lastQuery=null,this._lastSearcher=null}getIndex(){return this._myIndex}_normalizedKeys(){return this._myIndex.keys.map(t=>this._keyStore.get(t.id)||t)}search(t,e){const{limit:n=-1}=e||{},{includeMatches:o,includeScore:i,shouldSort:r,sortFn:s,ignoreFieldNorm:a}=this.options;if(nC(t)&&!t.trim()){let u=this._docs.map((h,d)=>({item:h,refIndex:d}));return Bae(n)&&n>-1&&(u=u.slice(0,n)),u}const A=r&&Bae(n)&&n>0&&nC(t),c=s,l=(u,h)=>c(u,h)||u.idx-h.idx;let g;if(A){const u=new Eei(n,l);nC(this._docs[0])?this._searchStringList(t,{heap:u,ignoreFieldNorm:a}):this._searchObjectList(t,{heap:u,ignoreFieldNorm:a}),g=u.extractSorted()}else g=nC(t)?nC(this._docs[0])?this._searchStringList(t):this._searchObjectList(t):this._searchLogical(t),yei(g,{ignoreFieldNorm:a}),r&&g.sort(nC(t)?l:c),Bae(n)&&n>-1&&(g=g.slice(0,n));return Bei(g,this._docs,{includeMatches:o,includeScore:i})}_searchStringList(t,{heap:e,ignoreFieldNorm:n}={}){const o=this._getSearcher(t),i=this.options.useTokenSearch&&this.options.tokenMatch==="all",{records:r}=this._myIndex,s=e?null:[];return r.forEach(({v:a,i:A,n:c})=>{if(!hE(a))return;const l=o.searchIn(a);if(l.isMatch){const g={score:l.score,value:a,norm:c,indices:l.indices};i&&(g.matchedMask=l.matchedMask,g.matchedTerms=l.matchedTerms,g.termCount=l.termCount);const u=[g];if(!i||this._coversAllTokens(u)){const h={item:a,idx:A,matches:u};e?(h.score=U7e(h.matches,{ignoreFieldNorm:n}),e.insert(h)):s.push(h)}}}),s}_searchLogical(t){const e=MOt(t,this.options),n=this._normalizedKeys(),o=(a,A,c)=>{if(!("children"in a)){const{keyId:h,searcher:d}=a;let _;return h===null?(_=[],n.forEach((p,m)=>{_.push(...this._findMatches({key:p,value:A[m],searcher:d}))})):_=this._findMatches({key:this._keyStore.get(h),value:this._myIndex.getValueForItemAtKeyId(A,h),searcher:d}),_&&_.length?[{idx:c,item:A,matches:_}]:[]}const{children:l,operator:g}=a,u=[];for(let h=0,d=l.length;h<d;h+=1){const _=l[h],p=o(_,A,c);if(p.length)u.push(...p);else if(g===Dae.AND)return[]}return u},i=this._myIndex.records,r=new Map,s=[];return i.forEach(({$:a,i:A})=>{if(hE(a)){const c=o(e,a,A);c.length&&(r.has(A)||(r.set(A,{idx:A,item:a,matches:[]}),s.push(r.get(A))),c.forEach(({matches:l})=>{r.get(A).matches.push(...l)}))}}),s}_searchObjectList(t,{heap:e,ignoreFieldNorm:n}={}){const o=this._getSearcher(t),i=this.options.useTokenSearch&&this.options.tokenMatch==="all",{records:r}=this._myIndex,s=this._normalizedKeys(),a=e?null:[];return r.forEach(({$:A,i:c})=>{if(!hE(A))return;const l=[];let g=!1,u=!1;if(s.forEach((h,d)=>{const _=this._findMatches({key:h,value:A[d],searcher:o});_.length?(l.push(..._),_[0].hasInverse&&(u=!0)):g=!0}),!(u&&g)&&l.length&&(!i||this._coversAllTokens(l))){const h={idx:c,item:A,matches:l};e?(h.score=U7e(h.matches,{ignoreFieldNorm:n}),e.insert(h)):a.push(h)}}),a}_findMatches({key:t,value:e,searcher:n}){if(!hE(e))return[];const o=[];if(aw(e))e.forEach(({v:i,i:r,n:s})=>{if(!hE(i))return;const a=n.searchIn(i);if(a.isMatch){const A={score:a.score,key:t,value:i,idx:r,norm:s,indices:a.indices,hasInverse:a.hasInverse};a.termCount!==void 0&&(A.matchedMask=a.matchedMask,A.matchedTerms=a.matchedTerms,A.termCount=a.termCount),o.push(A)}});else{const{v:i,n:r}=e,s=n.searchIn(i);if(s.isMatch){const a={score:s.score,key:t,value:i,norm:r,indices:s.indices,hasInverse:s.hasInverse};s.termCount!==void 0&&(a.matchedMask=s.matchedMask,a.matchedTerms=s.matchedTerms,a.termCount=s.termCount),o.push(a)}}return o}_coversAllTokens(t){const e=t.length?t[0].termCount:void 0;if(e===void 0)return!0;if(e<=31){let o=0;for(let i=0;i<t.length;i++)o|=t[i].matchedMask||0;return o===2**e-1}const n=new Set;for(let o=0;o<t.length;o++){const i=t[o].matchedTerms;if(i)for(const r of i)n.add(r)}return n.size===e}};Aw.version="7.5.0",Aw.createIndex=bOt,Aw.parseIndex=aei,Aw.config=Ls,Aw.match=function(t,e,n){if(n&&n.useTokenSearch)throw new Error(nei);return bae(t,{...Ls,...n}).searchIn(e)},Aw.parseQuery=MOt,G7e(Iei),G7e(Dei),Aw.use=function(...t){t.forEach(e=>G7e(e))};var Mei=Aw;const Nei="https://kicad-mod-cache.tscircuit.com";let V7e=null,$Y=null,J7e=null;const Rei=async()=>V7e||$Y||($Y=fetch("https://kicad-mod-cache.tscircuit.com/kicad_files.json").then(t=>t.json()).then(t=>(V7e=t,$Y=null,t)),$Y),Tei=async(t,e=20)=>{const n=await Rei();return J7e||(J7e=new Mei(n)),J7e.search(t).slice(0,e).map(o=>o.item)},kei=t=>{const e=t.replace(".pretty/","/").replace(".kicad_mod",""),n=`kicad:${e}`;return{path:t,qualifiedName:n,description:e}},Fei=t=>t.replace(/^\/+/,"").split("/").map(e=>encodeURIComponent(e)).join("/"),Lei=async t=>{const e=await fetch(`${Nei}/${Fei(t)}`);if(!e.ok)throw new Error(`KiCad footprint fetch failed: ${e.status}`);const n=await e.text(),{KicadFootprintToCircuitJsonConverter:o}=await sQ("kicad-to-circuit-json"),i=new o;return i.addFile(t.split("/").pop()??"selected-footprint.kicad_mod",n),i.runUntilFinished(),i.getOutput()},kOt=t=>t?.source==="jlcpcb"||t?.source==="kicad",Hei=async(t,e)=>{if(t.source==="jlcpcb")return JZo(t.component.partNumber,e?.jlcpcb);if(t.source==="kicad")return Lei(t.footprint.path);throw new Error("Footprint preview is not available for this source")},Gei=({query:t,placeholder:e,isSearching:n,onQueryChange:o,onSubmit:i})=>{const r=$.useCallback(s=>{s.key==="Enter"&&(s.preventDefault(),i())},[i]);return V.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2 rf-mt-4",children:[V.jsxs("div",{className:"rf-relative rf-flex-grow",children:[V.jsx(r8e,{className:"rf-absolute rf-left-2 rf-top-2.5 rf-h-4 rf-w-4 rf-text-muted-foreground"}),V.jsx(e9e,{placeholder:e,className:"rf-pl-8",spellCheck:!1,autoComplete:"off",value:t,onChange:s=>o(s.target.value),onKeyDown:r})]}),V.jsx(cA,{onClick:i,disabled:n||t.trim().length<1,className:"sm:rf-px-4 rf-px-3",children:n?V.jsx(iQ,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):V.jsxs(V.Fragment,{children:[V.jsx(r8e,{className:"rf-h-4 rf-w-4 sm:rf-hidden"}),V.jsx("span",{className:"rf-hidden sm:rf-inline",children:"Search"})]})})]})},Oei=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}),Kei=t=>Oei.format(t),FOt=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"}},Uei=t=>{switch(t.source){case"tscircuit.com":return t.package.unscoped_name;case"jlcpcb":return t.component.isDirectLookup?t.component.partNumber:t.component.manufacturer;case"kicad":return t.footprint.qualifiedName}},Yei=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}},zei=t=>{switch(t.source){case"tscircuit.com":return t.package.name;case"jlcpcb":return t.component.isDirectLookup?void 0:t.component.partNumber;case"kicad":return}},Vei=({results:t,selected:e,onSelect:n,onShowDetails:o})=>{const i=e?FOt(e):null;return V.jsx("div",{className:"rf-divide-y rf-w-full rf-overflow-hidden",children:t.map(r=>{const s=FOt(r),a=i===s,A=Uei(r),c=Yei(r),l=zei(r),g=r.source==="jlcpcb"?r.component.stock:null,u=r.source==="jlcpcb"?r.component.price:null,h=r.source==="jlcpcb"?r.component.isBasic:null,d=r.source==="jlcpcb"?r.component.isDirectLookup:!1;return V.jsxs("div",{className:`rf-p-3 rf-flex rf-flex-col sm:rf-grid sm:rf-grid-cols-[minmax(0,1fr)_auto] rf-items-start sm:rf-items-center rf-cursor-pointer hover:rf-bg-zinc-100 rf-gap-2 rf-overflow-hidden ${a?"rf-bg-zinc-100":""}`,onClick:()=>n(r),children:[V.jsxs("div",{className:"rf-min-w-0 rf-overflow-hidden rf-w-full",children:[V.jsxs("div",{className:"rf-flex rf-items-start rf-gap-2 rf-min-w-0",children:[V.jsxs("div",{className:"rf-font-medium rf-text-sm rf-truncate rf-flex-1 rf-min-w-0 rf-flex rf-items-center rf-gap-1.5",children:[A,r.source==="jlcpcb"&&h!=null&&V.jsx("span",{className:`rf-text-xs rf-px-1.5 rf-py-0.5 rf-rounded rf-font-medium rf-flex-shrink-0 ${h?"rf-bg-green-100 rf-text-green-700":"rf-bg-orange-100 rf-text-orange-700"}`,children:h?"Basic":"Extended"}),d&&V.jsx("span",{className:"rf-text-xs rf-px-1.5 rf-py-0.5 rf-rounded rf-font-medium rf-flex-shrink-0 rf-bg-blue-100 rf-text-blue-700",children:"Direct lookup"}),r.source==="tscircuit.com"&&r.package.is_private&&V.jsx(MOo,{className:"rf-ml-1 rf-h-3 rf-w-3 rf-text-zinc-400 rf-flex-shrink-0"})]}),r.source==="jlcpcb"&&g!=null?V.jsxs("div",{className:"rf-text-xs rf-text-zinc-500 rf-font-medium rf-whitespace-nowrap rf-flex-shrink-0 sm:rf-hidden",children:[g.toLocaleString()," in stock"]}):null]}),V.jsxs("div",{className:"rf-text-xs rf-text-zinc-500 rf-truncate rf-w-full",children:[l?V.jsx("span",{className:"rf-mr-2",children:l}):null,c]})]}),V.jsxs("div",{children:[r.source==="tscircuit.com"&&o?V.jsx("div",{className:"rf-flex-shrink-0 rf-w-full sm:rf-w-auto",children:V.jsx(cA,{variant:"outline",size:"sm",className:"rf-text-xs rf-w-full sm:rf-w-auto",onClick:_=>{_.stopPropagation(),o(r)},children:"See Details"})}):r.source==="jlcpcb"&&g!=null?V.jsxs("div",{className:"rf-hidden sm:rf-block rf-text-xs rf-text-zinc-500 rf-font-medium rf-whitespace-nowrap rf-flex-shrink-0",children:[g.toLocaleString()," in stock"]}):null,u!=null&&V.jsx("div",{className:"rf-hidden sm:rf-block rf-text-xs rf-text-zinc-500 rf-font-medium rf-whitespace-nowrap rf-flex-shrink-0 rf-text-right",children:Kei(u)})]})]},s)})})},Jei=({circuitJson:t,error:e,isLoading:n,height:o})=>V.jsx("section",{className:"rf-flex rf-min-w-0 rf-items-center rf-justify-center",style:{height:o},children:n?V.jsxs("div",{className:"rf-flex rf-w-full rf-items-center rf-justify-center rf-gap-2 rf-bg-zinc-950 rf-text-sm rf-text-zinc-300",style:{height:o},children:[V.jsx(iQ,{className:"rf-h-4 rf-w-4 rf-animate-spin"}),"Loading preview..."]}):e?V.jsx("div",{className:"rf-flex rf-w-full rf-items-center rf-justify-center rf-bg-zinc-950 rf-p-4",style:{height:o},children:V.jsxs("div",{className:"rf-flex rf-max-w-[320px] rf-items-start rf-gap-2 rf-text-sm rf-text-zinc-300",children:[V.jsx(XNt,{className:"rf-mt-0.5 rf-h-4 rf-w-4 rf-flex-shrink-0"}),V.jsx("span",{children:e})]})}):t?V.jsx("div",{className:"rf-w-full rf-min-w-0 rf-overflow-hidden",children:V.jsx(YGt,{circuitJson:t,height:o,allowEditing:!1,clickToInteractEnabled:!1,focusOnHover:!1,disablePcbGroups:!0})}):V.jsx("div",{className:"rf-flex rf-w-full rf-items-center rf-justify-center rf-bg-zinc-950 rf-text-sm rf-text-zinc-300",style:{height:o},children:"No preview"})}),LOt={importComponentDialog:101,importComponentDetailsDialog:102},qei=({packageResult:t,isOpen:e,onOpenChange:n,isLoading:o,details:i,previewTab:r,onPreviewTabChange:s,isSubmitting:a,onImport:A})=>{const c=t?.package??null,l=c?.latest_pcb_preview_image_url,g=c?.latest_sch_preview_image_url,u=c?.latest_cad_preview_image_url,h=c?.unscoped_name?.split("/").pop()??c?.unscoped_name,d=c?.org_owner_tscircuit_handle??void 0,_=d?`https://tscircuit.com/${d}`:void 0,p=d&&h?`https://tscircuit.com/${d}/${h}`:void 0;return V.jsx(qk,{open:e,onOpenChange:n,children:V.jsxs(i8,{showOverlay:!1,style:{width:"calc(100vw - 2rem)",zIndex:LOt.importComponentDetailsDialog},className:"rf-max-w-5xl no-scrollbar !rf-overflow-y-auto rf-max-h-[90vh] rf-overflow-hidden rf-flex rf-flex-col rf-rounded-sm",children:[V.jsx(r8,{className:"rf-pb-4 rf-border-b",children:V.jsx("div",{className:"rf-flex rf-items-start rf-justify-between rf-gap-4",children:V.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[V.jsx(s8,{className:"rf-text-xl rf-font-semibold rf-truncate",children:h}),V.jsx(Wk,{children:c?.description})]})})}),V.jsxs("div",{className:"rf-flex-1 rf-overflow-y-auto rf-py-4 rf-space-y-6",children:[d?V.jsxs("div",{children:[V.jsx("span",{className:"rf-text-xs rf-font-medium rf-text-gray-500 rf-uppercase rf-tracking-wide",children:"Created by"}),V.jsx("div",{className:"rf-mt-1 rf-text-sm rf-font-medium",children:_?V.jsx("a",{href:_,target:"_blank",rel:"noopener noreferrer",className:"rf-text-black hover:rf-underline",children:d}):d})]}):null,(u||l||g)&&V.jsx(V.Fragment,{children:V.jsxs("div",{children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Preview"}),V.jsxs(Nxe,{value:r,onValueChange:m=>s(m),children:[V.jsxs(Hne,{className:"rf-inline-flex rf-h-9 rf-items-center rf-justify-center rf-rounded-lg rf-bg-zinc-100 rf-p-1 rf-text-zinc-500 dark:rf-bg-zinc-800 dark:rf-text-zinc-400",children:[l&&V.jsx(US,{value:"pcb",children:"PCB"}),g&&V.jsx(US,{value:"schematic",children:"Schematic"}),u&&V.jsx(US,{value:"3d",children:"3D"})]}),V.jsxs("div",{className:"rf-mt-4",children:[V.jsx(Vf,{value:"pcb",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:l?V.jsx("img",{src:l,alt:`${h??"package"} PCB preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null}),V.jsx(Vf,{value:"schematic",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:g?V.jsx("img",{src:g,alt:`${h??"package"} schematic preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null}),V.jsx(Vf,{value:"3d",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:u?V.jsx("img",{src:u,alt:`${h??"package"} 3D preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null})]})]})]})}),i?.ai_description?V.jsxs("section",{children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-3",children:"AI Description"}),V.jsx("div",{className:"rf-bg-gray-50 rf-border rf-border-gray-200 rf-rounded-lg rf-p-4",children:V.jsx("p",{className:"rf-text-sm rf-text-gray-700 rf-leading-relaxed",children:i.ai_description})})]}):null,i?.ai_usage_instructions?V.jsxs("section",{children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-3",children:"Usage Instructions"}),V.jsx("div",{className:"rf-bg-gray-50 rf-border rf-border-gray-200 rf-rounded-lg rf-p-4",children:V.jsx("p",{className:"rf-text-sm rf-text-gray-700 rf-leading-relaxed rf-whitespace-pre-wrap",children:i.ai_usage_instructions})})]}):null,o?V.jsxs("div",{className:"rf-flex rf-justify-center rf-items-center rf-gap-2 rf-text-gray-500",children:[V.jsx(iQ,{className:"rf-h-4 rf-w-4 rf-animate-spin"}),V.jsx("span",{className:"rf-text-sm",children:"Loading package details..."})]}):null]}),V.jsxs(jY,{className:"rf-pt-4 rf-border-t rf-flex rf-flex-col sm:rf-flex-row rf-justify-between rf-gap-2",children:[V.jsx("div",{className:"rf-flex-1",children:p?V.jsxs(cA,{variant:"outline",size:"sm",className:"rf-gap-2 rf-w-full sm:rf-w-auto",onClick:()=>window.open(p,"_blank"),children:[V.jsx(QOo,{className:"rf-h-4 rf-w-4"}),"View on tscircuit.com"]}):null}),V.jsxs("div",{className:"rf-flex rf-flex-col sm:rf-flex-row rf-gap-2",children:[V.jsx(cA,{variant:"outline",onClick:()=>n(!1),className:"rf-order-2 sm:rf-order-1",children:"Close"}),V.jsx(cA,{onClick:A,disabled:a,className:"rf-bg-blue-600 hover:rf-bg-blue-700",children:a?V.jsx(iQ,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):"Import Component"})]})]})]})})},Wei=()=>{const[t,e]=$.useState(null),[n,o]=$.useState(!1),i=$.useCallback(async(s,a)=>{o(!0);try{const A=await fetch(`https://api.tscircuit.com/packages/get?name=${encodeURIComponent(`${s}/${a}`)}`);if(!A.ok)throw new Error(`Failed to load package details: ${A.status}`);const c=await A.json();e(c.package??null)}catch(A){console.error("Failed to fetch package details",A),e(null)}finally{o(!1)}},[]),r=$.useCallback(()=>{e(null),o(!1)},[]);return{details:t,isLoading:n,fetchDetails:i,reset:r}},jei=(t,e)=>{const[n,o]=$.useState({circuitJson:null,error:null,isLoading:!1});return $.useEffect(()=>{if(!t||!kOt(t)){o({circuitJson:null,error:null,isLoading:!1});return}let i=!1;return o({circuitJson:null,error:null,isLoading:!0}),Hei(t,e).then(r=>{i||o({circuitJson:r,error:null,isLoading:!1})}).catch(r=>{i||o({circuitJson:null,error:r instanceof Error?r.message:"Failed to load footprint preview",isLoading:!1})}),()=>{i=!0}},[t,e]),n},Xei=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??[]},$ei=({sessionToken:t})=>{const[e,n]=$.useState([]),[o,i]=$.useState(!1),[r,s]=$.useState(null),[a,A]=$.useState(!1),c=$.useCallback(async g=>{const u=g.trim();if(!u)return[];i(!0),s(null);try{const d=(await Xei(u,t)).map(_=>({source:"tscircuit.com",package:_}));return n(d),d}catch(h){return console.error("Error searching tscircuit packages",h),n([]),s(h instanceof Error?h.message:"Failed to search tscircuit packages"),[]}finally{i(!1),A(!0)}},[t]),l=$.useCallback(()=>{n([]),i(!1),s(null),A(!1)},[]);return{results:e,isSearching:o,error:r,hasSearched:a,search:c,reset:l}},Zei=t=>{const e=/^C(\d+)$/i.exec(t.trim());if(!e)return null;const n=Number(e[1]);if(!Number.isSafeInteger(n))return null;const o=`C${e[1]}`;return{source:"jlcpcb",component:{lcscId:n,manufacturer:o,partNumber:o,description:"Import directly from EasyEDA; stock and availability are unknown",package:"",isDirectLookup:!0}}},HOt=(t,e)=>{const n=Zei(t);return n?e.some(i=>i.component.partNumber.toUpperCase()===n.component.partNumber)?e:[n,...e]:e},eti=t=>{const e=t.trim();return/^C\d+/i.test(e)?e.replace(/^C/i,""):e},tti=()=>{const[t,e]=$.useState([]),[n,o]=$.useState(!1),[i,r]=$.useState(null),[s,a]=$.useState(!1),A=$.useCallback(async l=>{const g=eti(l);if(!g)return[];o(!0),r(null);try{const u=await YZo(g,10),h=HOt(l,u.map(d=>({source:"jlcpcb",component:zZo(d)})));return e(h),h}catch(u){console.error("Error searching JLCPCB components",u);const h=HOt(l,[]);return e(h),r(h.length>0?null:u instanceof Error?u.message:"Failed to search JLCPCB components"),h}finally{o(!1),a(!0)}},[]),c=$.useCallback(()=>{e([]),o(!1),r(null),a(!1)},[]);return{results:t,isSearching:n,error:i,hasSearched:s,search:A,reset:c}},nti=()=>{const[t,e]=$.useState([]),[n,o]=$.useState(!1),[i,r]=$.useState(null),[s,a]=$.useState(!1),A=$.useCallback(async l=>{const g=l.trim();if(!g)return[];o(!0),r(null);try{const h=(await Tei(g,20)).map(d=>({source:"kicad",footprint:kei(d)}));return e(h),h}catch(u){return console.error("Error searching KiCad footprints",u),e([]),r(u instanceof Error?u.message:"Failed to search KiCad footprints"),[]}finally{o(!1),a(!0)}},[]),c=$.useCallback(()=>{e([]),o(!1),r(null),a(!1)},[]);return{results:t,isSearching:n,error:i,hasSearched:s,search:A,reset:c}},oti=({onTscircuitPackageSelected:t,onJlcpcbComponentTsxLoaded:e,onKicadStringSelected:n})=>{const o=[];return t&&o.push("tscircuit.com"),e&&o.push("jlcpcb"),n&&o.push("kicad"),o},iti=({isOpen:t,onClose:e,jlcpcbProxyRequestHeaders:n,onKicadStringSelected:o,onTscircuitPackageSelected:i,onJlcpcbComponentTsxLoaded:r,jlcpcbProxyApiBase:s,tscircuitSessionToken:a})=>{Iae();const A=$.useMemo(()=>oti({onKicadStringSelected:o,onTscircuitPackageSelected:i,onJlcpcbComponentTsxLoaded:r}),[o,i,r]),c=A.length>0,l=A.length===1,[g,u]=$.useState(A[0]??"tscircuit.com"),[h,d]=$.useState(""),[_,p]=$.useState(null),{results:m,isSearching:I,error:f,hasSearched:C,search:y,reset:E}=$ei({sessionToken:a}),{results:B,isSearching:Q,error:b,hasSearched:D,search:T,reset:N}=tti(),{results:H,isSearching:G,error:O,hasSearched:U,search:W,reset:j}=nti(),{details:ne,isLoading:re,fetchDetails:X,reset:Z}=Wei(),[se,ae]=$.useState(null),[le,fe]=$.useState(!1),[Ce,Ee]=$.useState("pcb"),[de,xe]=$.useState(null),[_e,Ne]=$.useState(!1),Oe=$.useMemo(()=>({jlcpcb:{headers:n,apiBase:s}}),[s,n]),{circuitJson:Je,error:Ie,isLoading:ze}=jei(_,Oe),Re=kOt(_);$.useEffect(()=>{xe(null)},[_]);const Le=$.useCallback(()=>{E(),N(),j(),p(null)},[N,j,E]);$.useEffect(()=>{t||(Le(),d(""),fe(!1),ae(null),xe(null))},[t,Le]),$.useEffect(()=>{d(""),p(null),g==="tscircuit.com"?E():g==="jlcpcb"?N():g==="kicad"&&j()},[g,N,j,E]);const Ve=dt=>{p(dt),ae(dt),Ee("pcb"),fe(!0),Z();const ot=dt.package.org_owner_tscircuit_handle,Qt=dt.package.unscoped_name;if(ot&&Qt){const It=Qt.split("/").pop()??Qt;X(ot,It)}},ke=async()=>{h.trim()&&(p(null),g==="tscircuit.com"?await y(h):g==="jlcpcb"?await T(h):g==="kicad"&&await W(h))},De=async dt=>{try{if(xe(null),Ne(!0),dt.source==="kicad"){if(!o)throw new Error("KiCad handler not provided");await o({result:dt,footprint:dt.footprint.qualifiedName})}else if(dt.source==="jlcpcb"){if(!r)throw new Error("JLCPCB handler not provided");const ot=await VZo(dt.component.partNumber,{headers:n,apiBase:s});await r({result:dt,tsx:ot})}else if(dt.source==="tscircuit.com"){if(!i)throw new Error("tscircuit package handler not provided");const ot=dt.package.org_owner_tscircuit_handle,Qt=dt.package.unscoped_name;if(!ot||!Qt)throw new Error("Missing package metadata");const It=Qt.split("/").pop()??Qt,Pt=`@tsci/${ot}.${It}`;await i({result:dt,fullPackageName:Pt})}return!0}catch(ot){return console.error("Failed to import component",ot),xe(ot instanceof Error?ot.message:"Failed to import component"),!1}finally{Ne(!1)}};let Ue=[],Pe=!1,We=null,et=!1;g==="tscircuit.com"?(Ue=m,Pe=I,We=f,et=C):g==="jlcpcb"?(Ue=B,Pe=Q,We=b,et=D):g==="kicad"&&(Ue=H,Pe=G,We=O,et=U);const At=async()=>{if(!_)return;await De(_)&&(e(),Le(),d(""))},gt=dt=>{dt||e()},_t=dt=>{fe(dt),dt||ae(null)};return V.jsxs(qk,{open:t,onOpenChange:gt,children:[V.jsxs(i8,{style:{width:"calc(100vw - 2rem)",maxWidth:Re?"min(1120px, calc(100vw - 2rem))":"min(672px, calc(100vw - 2rem))",zIndex:LOt.importComponentDialog},className:"rf-rounded-sm rf-max-h-[90vh] rf-overflow-y-auto rf-overflow-x-hidden rf-flex rf-flex-col",children:[V.jsxs(r8,{children:[V.jsxs(s8,{className:"rf-text-lg sm:rf-text-xl",children:["Import ",l?xae[g].label:""," ","Component"]}),V.jsx(Wk,{className:"rf-text-sm",children:c?"Search for components from available sources.":"Import options are disabled because no handlers were provided."})]}),c?V.jsxs(Nxe,{value:g,onValueChange:dt=>u(dt),className:"rf-min-w-0 rf-w-full",children:[!l&&V.jsx(Hne,{className:"rf-flex rf-w-full rf-gap-2",children:A.map(dt=>V.jsx(US,{value:dt,className:"rf-flex-1 rf-text-xs sm:rf-text-sm",children:xae[dt].label},dt))}),V.jsxs("div",{className:"rf-min-w-0",style:Re?{display:"grid",gridTemplateColumns:"minmax(0, 1fr) minmax(360px, 0.95fr)",gap:"1.5rem",alignItems:"start"}:void 0,children:[V.jsxs("div",{className:"rf-min-w-0",children:[V.jsx(Gei,{query:h,placeholder:xae[g].placeholder,isSearching:Pe,onQueryChange:d,onSubmit:ke}),V.jsx("div",{className:"no-scrollbar rf-mt-4 rf-flex-1 rf-min-h-[200px] !rf-max-h-[40vh] !rf-overflow-y-auto rf-overflow-x-hidden rf-border rf-rounded-md rf-min-w-0",children:Pe?V.jsxs("div",{className:"rf-p-8 rf-text-center rf-text-zinc-500",children:[V.jsx(iQ,{className:"rf-h-8 rf-w-8 rf-animate-spin rf-mx-auto rf-mb-2"}),V.jsx("p",{children:"Searching..."})]}):Ue.length>0?V.jsx(Vei,{results:Ue,selected:_,onSelect:p,onShowDetails:g==="tscircuit.com"?Ve:void 0}):V.jsx("div",{className:"rf-p-8 rf-text-center rf-text-zinc-500",children:We?`Error: ${We}`:et?xae[g].emptyMessage:"Enter a search term to find components"})})]}),Re?V.jsx("div",{className:"rf-mt-4",children:V.jsx(Jei,{circuitJson:Je,error:Ie,isLoading:ze,height:325})}):null]})]}):null,de?V.jsx("div",{className:"rf-text-sm rf-text-red-600 rf-mt-2",children:de}):null,V.jsxs(jY,{className:"rf-flex rf-flex-col sm:rf-flex-row rf-gap-2",children:[V.jsx(cA,{variant:"outline",onClick:e,className:"rf-order-2 sm:rf-order-1",children:"Cancel"}),V.jsx(cA,{onClick:At,disabled:!_||_e,className:"rf-order-1 sm:rf-order-2",children:_e?V.jsx(iQ,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):"Import"})]})]}),V.jsx(qei,{packageResult:se,isOpen:le,onOpenChange:_t,isLoading:re,details:ne,previewTab:Ce,onPreviewTabChange:dt=>Ee(dt),isSubmitting:_e,onImport:()=>{se&&De(se).then(dt=>{dt&&(fe(!1),e(),Le(),d(""))})}})]})},rti=t=>{const e=t.match(/export const (\w+) =/);if(!e)throw new Error("Could not determine component name from TSX contents");return e[1]},GOt=t=>{const e=od(s=>s.pushEvent),n=od(s=>s.upsertFile),o=async({result:s,fullPackageName:a})=>{const c=s.package.unscoped_name??s.package.name;await Ws.promise(e({event_type:"INSTALL_PACKAGE",full_package_name:a}),{loading:`Requesting install for "${c}"`,success:`Install requested for "${c}"`,error:l=>`Failed to request install: ${l instanceof Error?l.message:String(l)}`})},i=async({footprint:s})=>{await Ws.promise(navigator.clipboard.writeText(s),{loading:`Copying "${s}"`,success:`Copied "${s}" to clipboard`,error:a=>`Failed to copy footprint: ${a instanceof Error?a.message:String(a)}`})},r=async({result:s,tsx:a})=>{const c=`imports/${rti(a)}.tsx`;await Ws.promise(n(c,a),{loading:`Importing ${s.component.partNumber}`,success:`Imported to "${c}"`,error:l=>`Failed to import component: ${l instanceof Error?l.message:String(l)}`})};return V.jsx(iti,{...t,onTscircuitPackageSelected:o,onKicadStringSelected:i,onJlcpcbComponentTsxLoaded:r})};GOt.displayName="ImportComponentDialogForCli";var q7e={exports:{}},OOt;function sti(){return OOt||(OOt=1,(function(t,e){var n={env:{},version:""};(function(o){t.exports=o()})(function(){return(function o(i,r,s){function a(l,g){if(!r[l]){if(!i[l]){var u=typeof ND=="function"&&ND;if(!g&&u)return u(l,!0);if(A)return A(l,!0);var h=new Error("Cannot find module '"+l+"'");throw h.code="MODULE_NOT_FOUND",h}var d=r[l]={exports:{}};i[l][0].call(d.exports,function(_){var p=i[l][1][_];return a(p||_)},d,d.exports,o,i,r,s)}return r[l].exports}for(var A=typeof ND=="function"&&ND,c=0;c<s.length;c++)a(s[c]);return a})({1:[function(o,i,r){var s=o("./utils"),a=o("./support"),A="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";r.encode=function(c){for(var l,g,u,h,d,_,p,m=[],I=0,f=c.length,C=f,y=s.getTypeOf(c)!=="string";I<c.length;)C=f-I,u=y?(l=c[I++],g=I<f?c[I++]:0,I<f?c[I++]:0):(l=c.charCodeAt(I++),g=I<f?c.charCodeAt(I++):0,I<f?c.charCodeAt(I++):0),h=l>>2,d=(3&l)<<4|g>>4,_=1<C?(15&g)<<2|u>>6:64,p=2<C?63&u:64,m.push(A.charAt(h)+A.charAt(d)+A.charAt(_)+A.charAt(p));return m.join("")},r.decode=function(c){var l,g,u,h,d,_,p=0,m=0,I="data:";if(c.substr(0,I.length)===I)throw new Error("Invalid base64 input, it looks like a data url.");var f,C=3*(c=c.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(c.charAt(c.length-1)===A.charAt(64)&&C--,c.charAt(c.length-2)===A.charAt(64)&&C--,C%1!=0)throw new Error("Invalid base64 input, bad content length.");for(f=a.uint8array?new Uint8Array(0|C):new Array(0|C);p<c.length;)l=A.indexOf(c.charAt(p++))<<2|(h=A.indexOf(c.charAt(p++)))>>4,g=(15&h)<<4|(d=A.indexOf(c.charAt(p++)))>>2,u=(3&d)<<6|(_=A.indexOf(c.charAt(p++))),f[m++]=l,d!==64&&(f[m++]=g),_!==64&&(f[m++]=u);return f}},{"./support":30,"./utils":32}],2:[function(o,i,r){var s=o("./external"),a=o("./stream/DataWorker"),A=o("./stream/Crc32Probe"),c=o("./stream/DataLengthProbe");function l(g,u,h,d,_){this.compressedSize=g,this.uncompressedSize=u,this.crc32=h,this.compression=d,this.compressedContent=_}l.prototype={getContentWorker:function(){var g=new a(s.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new c("data_length")),u=this;return g.on("end",function(){if(this.streamInfo.data_length!==u.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),g},getCompressedWorker:function(){return new a(s.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},l.createWorkerFrom=function(g,u,h){return g.pipe(new A).pipe(new c("uncompressedSize")).pipe(u.compressWorker(h)).pipe(new c("compressedSize")).withStreamInfo("compression",u)},i.exports=l},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(o,i,r){var s=o("./stream/GenericWorker");r.STORE={magic:"\0\0",compressWorker:function(){return new s("STORE compression")},uncompressWorker:function(){return new s("STORE decompression")}},r.DEFLATE=o("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(o,i,r){var s=o("./utils"),a=(function(){for(var A,c=[],l=0;l<256;l++){A=l;for(var g=0;g<8;g++)A=1&A?3988292384^A>>>1:A>>>1;c[l]=A}return c})();i.exports=function(A,c){return A!==void 0&&A.length?s.getTypeOf(A)!=="string"?(function(l,g,u,h){var d=a,_=h+u;l^=-1;for(var p=h;p<_;p++)l=l>>>8^d[255&(l^g[p])];return-1^l})(0|c,A,A.length,0):(function(l,g,u,h){var d=a,_=h+u;l^=-1;for(var p=h;p<_;p++)l=l>>>8^d[255&(l^g.charCodeAt(p))];return-1^l})(0|c,A,A.length,0):0}},{"./utils":32}],5:[function(o,i,r){r.base64=!1,r.binary=!1,r.dir=!1,r.createFolders=!0,r.date=null,r.compression=null,r.compressionOptions=null,r.comment=null,r.unixPermissions=null,r.dosPermissions=null},{}],6:[function(o,i,r){var s=null;s=typeof Promise<"u"?Promise:o("lie"),i.exports={Promise:s}},{lie:37}],7:[function(o,i,r){var s=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",a=o("pako"),A=o("./utils"),c=o("./stream/GenericWorker"),l=s?"uint8array":"array";function g(u,h){c.call(this,"FlateWorker/"+u),this._pako=null,this._pakoAction=u,this._pakoOptions=h,this.meta={}}r.magic="\b\0",A.inherits(g,c),g.prototype.processChunk=function(u){this.meta=u.meta,this._pako===null&&this._createPako(),this._pako.push(A.transformTo(l,u.data),!1)},g.prototype.flush=function(){c.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},g.prototype.cleanUp=function(){c.prototype.cleanUp.call(this),this._pako=null},g.prototype._createPako=function(){this._pako=new a[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var u=this;this._pako.onData=function(h){u.push({data:h,meta:u.meta})}},r.compressWorker=function(u){return new g("Deflate",u)},r.uncompressWorker=function(){return new g("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(o,i,r){function s(d,_){var p,m="";for(p=0;p<_;p++)m+=String.fromCharCode(255&d),d>>>=8;return m}function a(d,_,p,m,I,f){var C,y,E=d.file,B=d.compression,Q=f!==l.utf8encode,b=A.transformTo("string",f(E.name)),D=A.transformTo("string",l.utf8encode(E.name)),T=E.comment,N=A.transformTo("string",f(T)),H=A.transformTo("string",l.utf8encode(T)),G=D.length!==E.name.length,O=H.length!==T.length,U="",W="",j="",ne=E.dir,re=E.date,X={crc32:0,compressedSize:0,uncompressedSize:0};_&&!p||(X.crc32=d.crc32,X.compressedSize=d.compressedSize,X.uncompressedSize=d.uncompressedSize);var Z=0;_&&(Z|=8),Q||!G&&!O||(Z|=2048);var se=0,ae=0;ne&&(se|=16),I==="UNIX"?(ae=798,se|=(function(fe,Ce){var Ee=fe;return fe||(Ee=Ce?16893:33204),(65535&Ee)<<16})(E.unixPermissions,ne)):(ae=20,se|=(function(fe){return 63&(fe||0)})(E.dosPermissions)),C=re.getUTCHours(),C<<=6,C|=re.getUTCMinutes(),C<<=5,C|=re.getUTCSeconds()/2,y=re.getUTCFullYear()-1980,y<<=4,y|=re.getUTCMonth()+1,y<<=5,y|=re.getUTCDate(),G&&(W=s(1,1)+s(g(b),4)+D,U+="up"+s(W.length,2)+W),O&&(j=s(1,1)+s(g(N),4)+H,U+="uc"+s(j.length,2)+j);var le="";return le+=`
5798
+ `,g=new Blob([l],{type:"text/plain"}),u=URL.createObjectURL(g),h=document.createElement("a");h.href=u,h.download=`${c}.test.ts`,h.click(),URL.revokeObjectURL(u)}catch(A){alert(`Error generating test.ts for ${t.constructor.name}: ${A instanceof Error?A.message:String(A)}`)}o(!1)};return V.jsxs("div",{className:`relative ${e}`,ref:i,children:[V.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>o(!n),title:`Download options for ${t.constructor.name}`,children:t.constructor.name}),n&&V.jsxs("div",{className:"absolute top-full left-0 mt-1 bg-white border border-gray-300 rounded shadow-lg z-10 min-w-[150px]",children:[V.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download JSON"}),V.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),V.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:a,children:"Download test.ts"})]})]})},JGt=t=>t.activeSubSolver?[t,...JGt(t.activeSubSolver)]:[t],v$o=({solver:t})=>{const e=JGt(t);return V.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:e.map((n,o)=>V.jsxs("div",{className:"flex items-center",children:[o>0&&V.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),V.jsx(D$o,{solver:n})]},n.constructor.name))})},P$o=({solver:t,triggerRender:e,animationSpeed:n=25,onSolverStarted:o,onSolverCompleted:i})=>{const[r,s]=$.useReducer(_=>!_,!1),a=$.useRef(void 0),A=()=>{!t.solved&&!t.failed&&(t.step(),e())},c=()=>{!t.solved&&!t.failed&&(o&&o(t),t.solve(),e(),i&&i(t))},l=()=>{r?(a.current&&(clearInterval(a.current),a.current=void 0),s()):(s(),a.current=setInterval(()=>{if(t.solved||t.failed){a.current&&(clearInterval(a.current),a.current=void 0),s(),e(),i&&t.solved&&i(t);return}t.step(),e()},n))},g=()=>{const _=t;if(_.getCurrentPhase&&!t.solved&&!t.failed){const p=_.getCurrentPhase();for(;_.getCurrentPhase()===p&&!t.solved&&!t.failed;)t.step();e()}},u=()=>{if(t.solved||t.failed||r)return;const _=window.prompt("Step until which iteration?",`${t.iterations}`);if(_===null)return;const p=Number(_);if(!Number.isFinite(p)){window.alert("Please enter a valid number for the iteration");return}for(;t.iterations<p&&!t.solved&&!t.failed;)t.step();e(),t.solved&&i&&i(t)};$.useEffect(()=>()=>{a.current&&clearInterval(a.current)},[]),$.useEffect(()=>{(t.solved||t.failed)&&r&&(a.current&&(clearInterval(a.current),a.current=void 0),s())},[t.solved,t.failed,r]);const h=t.getCurrentPhase!==void 0,d=h?t.getCurrentPhase():null;return V.jsxs("div",{className:"space-y-2 p-2 border-b",children:[V.jsx("div",{className:"flex items-center",children:V.jsx(v$o,{solver:t})}),V.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[V.jsx("button",{onClick:A,disabled:t.solved||t.failed||r,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),V.jsx("button",{onClick:c,disabled:t.solved||t.failed||r,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),V.jsx("button",{onClick:l,disabled:t.solved||t.failed,className:`px-3 py-1 rounded text-white text-sm ${r?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:r?"Stop":"Animate"}),V.jsx("button",{onClick:u,disabled:t.solved||t.failed||r,className:"bg-orange-500 hover:bg-orange-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step Until Iteration"}),h&&V.jsx("button",{onClick:g,disabled:t.solved||t.failed||r,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),V.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&V.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),d&&V.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",V.jsx("span",{className:"font-medium",children:d})]}),t.solved&&V.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&V.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&V.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},w$o=(t,e,n)=>{const o=t.currentPipelineStepIndex;return e<o?"Completed":e===o&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},M$o=(t,e)=>{const o=t.pipelineDef[e].solverName,i=w$o(t,e),r=t[o],s=t.firstIterationOfPhase?.[o]??null,a=t.iterations;let A=0;if(i==="Completed"){const u=t.pipelineDef[e+1],h=u?t.firstIterationOfPhase?.[u.solverName]:void 0;h!==void 0&&s!==null?A=h-s:s!==null&&(A=a-s)}else i==="In Progress"&&s!==null&&(A=a-s);const c=t.timeSpentOnPhase?.[o]??0;let l=0;i==="Completed"?l=1:i==="In Progress"&&r&&(l=r.progress??0);const g=r?.stats??null;return{index:e,name:o,status:i,firstIteration:s,iterations:A,progress:l,timeSpent:c,stats:g&&Object.keys(g).length>0?g:null,solverInstance:r??null}},N$o=({status:t})=>{const e={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return V.jsx("span",{className:`font-medium ${e[t]}`,children:t})},R$o=({progress:t})=>{if(t===0)return null;const e=Math.round(t*100);return V.jsxs("div",{className:"flex items-center gap-2",children:[V.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:V.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${e}%`}})}),V.jsxs("span",{className:"text-xs text-gray-500",children:[e,"%"]})]})},T$o=t=>Object.entries(t).map(([e,n])=>`${e}: ${n}`).join(", "),k$o=({stats:t})=>{if(!t||Object.keys(t).length===0)return V.jsx("span",{children:"-"});const e=Object.entries(t),n=T$o(t);return V.jsxs("details",{className:"cursor-pointer",children:[V.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:n}),V.jsx("div",{className:"mt-1 text-xs",children:e.map(([o,i])=>V.jsxs("div",{children:[o,": ",String(i)]},o))})]})},_7e=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(_7e);const e={};for(const[n,o]of Object.entries(t))n.startsWith("_")||(e[n]=_7e(o));return e},F$o=(t,e)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${e}`);return}const n=_7e(t.getConstructorParams()),o=new Blob([JSON.stringify(n,null,2)],{type:"application/json"}),i=URL.createObjectURL(o),r=document.createElement("a");r.href=i,r.download=`${e}_input.json`,r.click(),URL.revokeObjectURL(i)}catch(n){alert(`Error downloading input for ${e}: ${n instanceof Error?n.message:String(n)}`)}},L$o=({solver:t,onStepUntilPhase:e,onDownloadInput:n})=>{const o=t.pipelineDef.map((a,A)=>M$o(t,A)),i=a=>{e?.(a)},r=a=>{a.solverInstance&&(n?n(a.solverInstance,a.name):F$o(a.solverInstance,a.name))},s=a=>`${(a/1e3).toFixed(2)}s`;return V.jsxs("div",{className:"border-t border-gray-200",children:[V.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:V.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),V.jsx("div",{className:"overflow-x-auto",children:V.jsxs("table",{className:"w-full text-sm",children:[V.jsx("thead",{children:V.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),V.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",V.jsx("sub",{children:"0"})]}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),V.jsx("tbody",{children:o.map(a=>V.jsxs("tr",{className:`border-b border-gray-100 ${a.status==="In Progress"?"bg-yellow-50":""}`,children:[V.jsx("td",{className:"px-4 py-2",children:V.jsxs("div",{className:"flex items-center gap-2",children:[V.jsx("span",{className:"text-gray-400 w-6",children:String(a.index+1).padStart(2,"0")}),V.jsx("button",{onClick:()=>i(a.name),disabled:a.status==="Completed"||t.solved||t.failed,className:"text-blue-500 hover:text-blue-700 disabled:text-gray-300 disabled:cursor-not-allowed",title:`Step until ${a.name} completes`,children:V.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:V.jsx("path",{fillRule:"evenodd",d:"M4.5 5.653c0-1.426 1.529-2.33 2.779-1.643l11.54 6.348c1.295.712 1.295 2.573 0 3.285L7.28 19.991c-1.25.687-2.779-.217-2.779-1.643V5.653z",clipRule:"evenodd"})})}),V.jsx("span",{className:"font-medium text-gray-900",children:a.name})]})}),V.jsx("td",{className:"px-4 py-2",children:V.jsx(N$o,{status:a.status})}),V.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:a.firstIteration!==null?a.firstIteration:""}),V.jsx("td",{className:"px-4 py-2 text-gray-600",children:a.iterations}),V.jsx("td",{className:"px-4 py-2",children:V.jsx(R$o,{progress:a.progress})}),V.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(a.timeSpent)}),V.jsx("td",{className:"px-4 py-2 text-gray-500",children:V.jsx(k$o,{stats:a.stats})}),V.jsx("td",{className:"px-4 py-2",children:a.solverInstance?V.jsxs("button",{onClick:()=>r(a),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${a.name}`,children:[V.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:V.jsx("path",{fillRule:"evenodd",d:"M12 2.25a.75.75 0 01.75.75v11.69l3.22-3.22a.75.75 0 111.06 1.06l-4.5 4.5a.75.75 0 01-1.06 0l-4.5-4.5a.75.75 0 111.06-1.06l3.22 3.22V3a.75.75 0 01.75-.75zm-9 13.5a.75.75 0 01.75.75v2.25a1.5 1.5 0 001.5 1.5h13.5a1.5 1.5 0 001.5-1.5V16.5a.75.75 0 011.5 0v2.25a3 3 0 01-3 3H5.25a3 3 0 01-3-3V16.5a.75.75 0 01.75-.75z",clipRule:"evenodd"})}),V.jsx("span",{children:"Input"})]}):null})]},a.name))})]})})]})},H$o=class extends ts.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 G$o({graphics:t}){const e=t.points??[],n=t.lines??[],o=t.rects??[],i=t.circles??[],r=t.texts??[];let s=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,A=Number.NEGATIVE_INFINITY,c=Number.NEGATIVE_INFINITY;const l=(p,m)=>{typeof p=="number"&&(p<s&&(s=p),p>A&&(A=p)),typeof m=="number"&&(m<a&&(a=m),m>c&&(c=m))};for(const p of e)l(p.x,p.y);for(const p of n){const m=p.points??[];for(const I of m)l(I.x,I.y)}for(const p of o){const m=p.x??0,I=p.y??0,f=p.width??0,C=p.height??0;l(m,I),l(m+f,I+C)}for(const p of i){const m=p.x??0,I=p.y??0,f=p.radius??1;l(m-f,I-f),l(m+f,I+f)}for(const p of r)l(p.x,p.y);(!isFinite(s)||!isFinite(a)||!isFinite(A)||!isFinite(c))&&(s=-20,a=-20,A=20,c=20);const g=10,u=s-g,h=a-g,d=Math.max(1,A-s+2*g),_=Math.max(1,c-a+2*g);return V.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${u} ${h} ${d} ${_}`,role:"img","aria-label":"Graphics fallback",children:[o.map((p,m)=>V.jsx("rect",{x:p.x??0,y:p.y??0,width:p.width??0,height:p.height??0,fill:"none",stroke:p.strokeColor??"black",strokeWidth:p.strokeWidth??1},`rect-${m}`)),n.map((p,m)=>V.jsx("polyline",{fill:"none",stroke:p.strokeColor??"black",strokeWidth:p.strokeWidth??1,points:(p.points??[]).map(I=>`${I.x??0},${I.y??0}`).join(" ")},`line-${m}`)),i.map((p,m)=>V.jsx("circle",{cx:p.x??0,cy:p.y??0,r:p.radius??1.5,fill:p.fillColor??"none",stroke:p.strokeColor??"black",strokeWidth:p.strokeWidth??1},`circle-${m}`)),e.map((p,m)=>V.jsx("circle",{cx:p.x??0,cy:p.y??0,r:p.radius??1.5,fill:p.color??"black"},`point-${m}`)),r.map((p,m)=>V.jsx("text",{x:p.x??0,y:p.y??0,fontSize:p.fontSize??10,fill:p.color??"black",children:p.text??""},`text-${m}`))]})}var O$o=({solver:t,animationSpeed:e=25,onSolverStarted:n,onSolverCompleted:o})=>{const[i,r]=$.useReducer(l=>l+1,0),s=$.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(l){return console.error("Visualization error:",l),{points:[],lines:[],rects:[],circles:[]}}},[t,i]),a=$.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);$.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const l=document.createElement("script");l.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(l)}},[]);const A=t.pipelineDef!==void 0,c=l=>{const g=t;if(!t.solved&&!t.failed){for(;!t.solved&&!t.failed&&g.currentPipelineStepIndex<=g.pipelineDef.findIndex(u=>u.solverName===l);)t.step();r()}};return V.jsxs("div",{children:[V.jsx(P$o,{solver:t,triggerRender:r,animationSpeed:e,onSolverStarted:n,onSolverCompleted:o}),a?V.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):V.jsx(H$o,{fallback:V.jsx(G$o,{graphics:s}),children:V.jsx(b$o,{graphics:s})}),A&&V.jsx(L$o,{solver:t,onStepUntilPhase:c})]})};const K$o=()=>{$.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)},[])},U$o=1e3,Cb=(t,e)=>{const{fileName:n,mimeType:o="text/plain"}=e,i=t instanceof Blob?t:new Blob([t],{type:o}),r=URL.createObjectURL(i),s=document.createElement("a");s.href=r,s.download=n,s.target="_blank",s.rel="noopener noreferrer",s.style.display="none",document.body.appendChild(s),s.click(),document.body.removeChild(s),setTimeout(()=>{URL.revokeObjectURL(r)},U$o)},qGt=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"},yb="https://github.com/tscircuit/tscircuit-autorouter/issues/new",WGt="https://github.com/tscircuit/copper-pour-solver/issues/new",jGt="https://github.com/tscircuit/calculate-packing/issues/new",Y$o="https://github.com/tscircuit/matchpack/issues/new",XGt="https://github.com/tscircuit/schematic-trace-solver/issues/new?template=json-bug-report.yml",z$o={PackSolver2:jGt,LayoutPipelineSolver:Y$o,AutoroutingPipelineSolver:yb,AssignableAutoroutingPipeline2:yb,AssignableAutoroutingPipeline3:yb,AutoroutingPipeline1_OriginalUnravel:yb,AutoroutingPipelineSolver3_HgPortPointPathing:yb,AutoroutingPipelineSolver4:yb,AutoroutingPipelineSolver5:yb,AutoroutingPipelineSolver7_MultiGraph:yb,AutoroutingPipelineSolver8:yb,CopperPourPipelineSolver:WGt,SchematicTracePipelineSolver:XGt},V$o=t=>t.toLowerCase().includes("pack")?POo:t.toLowerCase().includes("rout")?kOo:mOo,$Gt=t=>{const e=z$o[t];if(e)return e;const n=t.toLowerCase();return n.includes("autorout")?yb:n.includes("schematic")&&n.includes("trace")?XGt:n.includes("copperpour")?WGt:n.includes("pack")?jGt:null},J$o=t=>`${qGt(`${t.componentName}-${t.solverName}`)}-solver-input.json`,ZGt=t=>{Cb(JSON.stringify(t.solverParams,null,2),{fileName:J$o(t),mimeType:"application/json"})},q$o=({solverEvent:t})=>{const e=$Gt(t.solverName);return V.jsxs("div",{className:"rf-flex rf-items-center rf-justify-end rf-gap-2 rf-border-b rf-border-gray-200 rf-bg-gray-50 rf-px-4 rf-py-2",children:[V.jsxs(cA,{type:"button",variant:"outline",size:"sm",onClick:()=>ZGt(t),children:[V.jsx(i8e,{className:"rf-w-4 rf-h-4"}),"Download"]}),e?V.jsx(cA,{asChild:!0,variant:"outline",size:"sm",children:V.jsxs("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:[V.jsx(rse,{className:"rf-w-4 rf-h-4"}),"Report"]})}):V.jsxs(cA,{type:"button",variant:"outline",size:"sm",disabled:!0,title:"No report link configured for this solver",children:[V.jsx(rse,{className:"rf-w-4 rf-h-4"}),"Report"]})]})},W$o=({solverEvent:t})=>{const e=$Gt(t.solverName);return e?V.jsx(cA,{asChild:!0,variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8",children:V.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",title:"Report solver bug","aria-label":"Report solver bug",children:V.jsx(rse,{className:"rf-w-4 rf-h-4"})})}):V.jsx(cA,{type:"button",variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8",disabled:!0,title:"No report link configured for this solver","aria-label":"Report solver bug",children:V.jsx(rse,{className:"rf-w-4 rf-h-4"})})},j$o=({solverEvents:t=[]})=>{const[e,n]=$.useState(null);K$o();const o=$.useMemo(()=>{const a=new Map;for(const A of t){const c=`${A.componentName}-${A.solverName}`;a.set(c,A)}return a},[t]),i=$.useMemo(()=>Array.from(o.keys()),[o]),r=e?o.get(e):null,s=$.useMemo(()=>{if(!r)return{instance:null,error:null,classFound:!1};const a=zye[r.solverName];if(!a)return{instance:null,error:`Solver class "${r.solverName}" not found in SOLVERS registry. Available: ${Object.keys(zye).join(", ")}`,classFound:!1};try{const A=r.solverParams,c=A?.input!==void 0?A.input:A;return{instance:new a(c),error:null,classFound:!0}}catch(A){const c=A instanceof Error?A.message:String(A);return console.error("Failed to reconstruct solver:",A),{instance:null,error:`Failed to instantiate solver: ${c}`,classFound:!0}}},[r]);return t.length===0?V.jsx("div",{className:"rf-p-4",children:V.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:V.jsxs("div",{className:"rf-p-4",children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),V.jsx("p",{className:"rf-text-sm rf-text-gray-600",children:"Solvers will appear here when the circuit runs. Solvers are used for tasks like component packing and autorouting."})]})})}):V.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[V.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[V.jsxs("div",{className:"rf-text-xs rf-font-semibold rf-text-gray-500 rf-px-3 rf-py-2 rf-bg-gray-50 rf-border-b rf-border-gray-200",children:[i.length," ",i.length===1?"Solver":"Solvers"]}),i.map(a=>{const A=o.get(a),c=e===a;return V.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${c?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>n(a),children:(()=>{const l=V$o(A.solverName);return V.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[V.jsx(l,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),V.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[V.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:A.componentName}),V.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:A.solverName})]})]})})()},a)})]}),V.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:r?s.instance?V.jsxs("div",{className:"rf-flex rf-h-full rf-flex-col rf-overflow-y-auto",children:[V.jsx(q$o,{solverEvent:r}),V.jsx("div",{className:"rf-min-h-0 rf-flex-1",children:V.jsx(Gx,{fallback:V.jsx("div",{className:"rf-p-4",children:V.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),V.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",r.solverName]})]})}),children:V.jsx(O$o,{solver:s.instance})})})]}):V.jsxs("div",{className:"rf-p-4",children:[V.jsxs("div",{className:"rf-mb-4",children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:r.solverName}),V.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",r.componentName]})]}),s.error&&V.jsx("div",{className:`rf-rounded-md rf-border rf-p-4 rf-mb-4 ${s.classFound?"rf-bg-red-50 rf-border-red-200":"rf-bg-yellow-50 rf-border-yellow-200"}`,children:V.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),V.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[V.jsxs("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50 rf-flex rf-items-center rf-justify-between rf-gap-2",children:[V.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"}),V.jsxs("div",{className:"rf-flex rf-items-center rf-gap-1",children:[V.jsx(W$o,{solverEvent:r}),V.jsx(cA,{type:"button",variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8","aria-label":"Download solver input JSON",title:"Download solver input JSON",onClick:()=>ZGt(r),children:V.jsx(i8e,{className:"rf-w-4 rf-h-4"})})]})]}),V.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:V.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(r.solverParams,null,2)})})]})]}):V.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:V.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},eOt=({errorMessage:t,errorStack:e,circuitJsonErrors:n})=>{$.useEffect(()=>{if(t){const o=new Error(t);e&&(o.stack=e);try{RR.captureException(o)}catch{}}},[t,e]),$.useEffect(()=>{if(n&&n.length>0)for(const o of n){const i=new Error(o.message||"Circuit JSON Error");o.stack&&(i.stack=o.stack);try{RR.captureException(i,{error_type:o.type})}catch{}}},[n])},tOt=t=>{$.useEffect(()=>{try{wro(t)}catch{}},[t.source,t.component,t.isWebEmbedded,t.activeTab])},nOt="0.0.2407",X$o={version:nOt},fae=nIt()(oIt(t=>({lastRunEvalVersion:void 0,setLastRunEvalVersion:e=>{t({lastRunEvalVersion:e})}}),{name:"runframe-runner-store"})),$$o=t=>{const[e,n]=$.useState([]),[o,i]=$.useState(null),[r,s]=$.useState(""),[a,A]=lR("eval-version-selection",null),c=fae(h=>h.setLastRunEvalVersion),l=fae(h=>h.lastRunEvalVersion);return $.useEffect(()=>{t&&fetch("https://data.jsdelivr.com/v1/package/npm/@tscircuit/eval").then(h=>h.json()).then(h=>{if(Array.isArray(h?.versions)){let d=[...h.versions];h.tags?.latest&&(i(h.tags.latest),d=d.filter(_=>_!==h.tags.latest)),n(d)}}).catch(()=>{})},[t]),$.useEffect(()=>{t&&(a?(window.TSCIRCUIT_LATEST_EVAL_VERSION=a,c(a)):o&&(window.TSCIRCUIT_LATEST_EVAL_VERSION=o,c(o)))},[t,a,o]),{versions:$.useMemo(()=>e.filter(h=>h.includes(r)).slice(0,50),[e,r]),latestVersion:o,lastRunEvalVersion:l,search:r,setSearch:s,selectVersion:h=>{A(h),s("")}}},Z$o=({snippetNames:t,onSelect:e,onCancel:n,isOpen:o})=>{const[i,r]=$.useState(""),[s,a]=$.useState("");if(!o)return null;const A=t.filter(g=>g.toLowerCase().includes(s.toLowerCase())),c=s&&!t.includes(s),l=g=>{g.key==="Enter"&&(A.length===1?r(A[0]):c&&r(s))};return V.jsx("div",{className:"rf-fixed rf-inset-0 rf-bg-black rf-bg-opacity-50 rf-flex rf-items-center rf-justify-center rf-z-[100]",children:V.jsxs("div",{className:"rf-bg-white rf-rounded-lg rf-p-6 rf-w-96",children:[V.jsx("h2",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Select Snippet"}),V.jsx("input",{type:"text",className:"rf-w-full rf-px-4 rf-py-2 rf-border rf-rounded rf-mb-4",placeholder:"Search snippets or new snippet name...",value:s,onChange:g=>a(g.target.value),onKeyDown:l}),V.jsxs("div",{className:"rf-h-60 rf-overflow-y-auto",children:[A.map(g=>V.jsx("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 ${i===g?"bg-blue-50":""}`,onClick:()=>r(g),children:g},g)),c&&V.jsxs("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 text-blue-500 ${i===s?"bg-blue-50":""}`,onClick:()=>r(s),children:['Create new "',s,'"']})]}),V.jsxs("div",{className:"rf-mt-4 rf-flex rf-justify-end rf-gap-2",children:[V.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-text-gray-600 rf-hover:text-gray-800",onClick:n,children:"Cancel"}),V.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-bg-blue-500 rf-text-white rf-rounded rf-hover:bg-blue-600 rf-disabled:opacity-50",onClick:()=>i&&e(i),disabled:!i,children:i===s?`Create "${i}"`:`Save to ${i}`})]})]})})},eZo=t=>{const e=$.useRef(null),n=od(o=>o.recentEvents);$.useEffect(()=>{if(n.length===0)return;const o=n[0];o.event_id!==e.current&&(t(o),e.current=o.event_id)},[n,t])};var tZo=Object.defineProperty,dE=(t,e)=>tZo(t,"name",{value:e,configurable:!0}),p7e="Dialog",[oOt,iOt]=J2(p7e),[nZo,cQ]=oOt(p7e),m7e=dE(t=>{const{__scopeDialog:e,children:n,open:o,defaultOpen:i,onOpenChange:r,modal:s=!0}=t,a=$.useRef(null),A=$.useRef(null),[c,l]=G4({prop:o,defaultProp:i??!1,onChange:r,caller:p7e}),[g,u]=$.useState(0),[h,d]=$.useState(0);return V.jsx(nZo,{scope:e,triggerRef:a,contentRef:A,contentId:Pm(),titleId:Pm(),descriptionId:Pm(),titlePresent:g>0,descriptionPresent:h>0,setTitleCount:u,setDescriptionCount:d,open:c,onOpenChange:l,onOpenToggle:$.useCallback(()=>l(_=>!_),[l]),modal:s,children:n})},"Dialog"),oZo="DialogTrigger",iZo=$.forwardRef(dE(function(e,n){const{__scopeDialog:o,...i}=e,r=cQ(oZo,o),s=Bl(n,r.triggerRef);return V.jsx($A.button,{type:"button","aria-haspopup":"dialog","aria-expanded":r.open,"aria-controls":r.open?r.contentId:void 0,"data-state":Eae(r.open),...i,ref:s,onClick:Nr(e.onClick,r.onOpenToggle)})},"DialogTrigger")),rOt="DialogPortal",[rZo,sOt]=oOt(rOt,{forceMount:void 0}),I7e=dE(t=>{const{__scopeDialog:e,forceMount:n,children:o,container:i}=t,r=cQ(rOt,e);return V.jsx(rZo,{scope:e,forceMount:n,children:$.Children.map(o,s=>V.jsx(Dx,{present:n||r.open,children:V.jsx(w8e,{asChild:!0,container:i,children:s})}))})},"DialogPortal"),f7e="DialogOverlay",Cae=$.forwardRef(dE(function(e,n){const o=sOt(f7e,e.__scopeDialog),{forceMount:i=o.forceMount,...r}=e,s=cQ(f7e,e.__scopeDialog);return s.modal?V.jsx(Dx,{present:i||s.open,children:V.jsx(aZo,{...r,ref:n})}):null},"DialogOverlay")),sZo=HS("DialogOverlay.RemoveScroll"),aZo=$.forwardRef(dE(function(e,n){const{__scopeDialog:o,...i}=e,r=cQ(f7e,o),s=nRt(),a=Bl(n,s);return V.jsx(Dse,{as:sZo,allowPinchZoom:!0,shards:[r.contentRef],children:V.jsx($A.div,{"data-state":Eae(r.open),...i,ref:a,style:{pointerEvents:"auto",...i.style}})})},"DialogOverlayImpl")),qY="DialogContent",yae=$.forwardRef(dE(function(e,n){const o=sOt(qY,e.__scopeDialog),{forceMount:i=o.forceMount,...r}=e,s=cQ(qY,e.__scopeDialog);return V.jsx(Dx,{present:i||s.open,children:s.modal?V.jsx(AZo,{...r,ref:n}):V.jsx(cZo,{...r,ref:n})})},"DialogContent")),AZo=$.forwardRef(dE(function(e,n){const o=cQ(qY,e.__scopeDialog),i=$.useRef(null),r=Bl(n,o.contentRef,i);return $.useEffect(()=>{const s=i.current;if(s)return N8e(s)},[]),V.jsx(aOt,{...e,ref:r,trapFocus:o.open,disableOutsidePointerEvents:o.open,onCloseAutoFocus:Nr(e.onCloseAutoFocus,s=>{s.preventDefault(),o.triggerRef.current?.focus()}),onPointerDownOutside:Nr(e.onPointerDownOutside,s=>{const a=s.detail.originalEvent,A=a.button===0&&a.ctrlKey===!0;(a.button===2||A)&&s.preventDefault()}),onFocusOutside:Nr(e.onFocusOutside,s=>s.preventDefault())})},"DialogContentModal")),cZo=$.forwardRef(dE(function(e,n){const o=cQ(qY,e.__scopeDialog),i=$.useRef(!1),r=$.useRef(!1);return V.jsx(aOt,{...e,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{e.onCloseAutoFocus?.(s),s.defaultPrevented||(i.current||o.triggerRef.current?.focus(),s.preventDefault()),i.current=!1,r.current=!1},onInteractOutside:s=>{e.onInteractOutside?.(s),s.defaultPrevented||(i.current=!0,s.detail.originalEvent.type==="pointerdown"&&(r.current=!0));const a=s.target;o.triggerRef.current?.contains(a)&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&r.current&&s.preventDefault()}})},"DialogContentNonModal")),aOt=$.forwardRef(dE(function(e,n){const{__scopeDialog:o,trapFocus:i,onOpenAutoFocus:r,onCloseAutoFocus:s,...a}=e,A=cQ(qY,o);return BY(),V.jsx(V.Fragment,{children:V.jsx(d8e,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:r,onUnmountAutoFocus:s,children:V.jsx(sse,{role:"dialog",id:A.contentId,"aria-describedby":A.descriptionPresent?A.descriptionId:void 0,"aria-labelledby":A.titlePresent?A.titleId:void 0,"data-state":Eae(A.open),...a,ref:n,deferPointerDownOutside:!0,onDismiss:()=>A.onOpenChange(!1)})})})},"DialogContentImpl")),lZo="DialogTitle",C7e=$.forwardRef(dE(function(e,n){const{__scopeDialog:o,...i}=e,r=cQ(lZo,o),{setTitleCount:s}=r;return Sy(()=>(s(a=>a+1),()=>s(a=>a-1)),[s]),V.jsx($A.h2,{id:r.titleId,...i,ref:n})},"DialogTitle")),gZo="DialogDescription",y7e=$.forwardRef(dE(function(e,n){const{__scopeDialog:o,...i}=e,r=cQ(gZo,o),{setDescriptionCount:s}=r;return Sy(()=>(s(a=>a+1),()=>s(a=>a-1)),[s]),V.jsx($A.p,{id:r.descriptionId,...i,ref:n})},"DialogDescription")),uZo="DialogClose",AOt=$.forwardRef(dE(function(e,n){const{__scopeDialog:o,...i}=e,r=cQ(uZo,o);return V.jsx($A.button,{type:"button",...i,ref:n,onClick:Nr(e.onClick,()=>r.onOpenChange(!1))})},"DialogClose"));function Eae(t){return t?"open":"closed"}dE(Eae,"getState");var dZo=Object.defineProperty,N5=(t,e)=>dZo(t,"name",{value:e,configurable:!0}),hZo="AlertDialog",[_Zo,Lci]=J2(hZo,[iOt]),R5=iOt(),pZo=N5(t=>{const{__scopeAlertDialog:e,...n}=t,o=R5(e);return V.jsx(m7e,{...o,...n,modal:!0})},"AlertDialog");$.forwardRef(N5(function(e,n){const{__scopeAlertDialog:o,...i}=e,r=R5(o);return V.jsx(iZo,{...r,...i,ref:n})},"AlertDialogTrigger"));var mZo=N5(t=>{const{__scopeAlertDialog:e,...n}=t,o=R5(e);return V.jsx(I7e,{...o,...n})},"AlertDialogPortal"),IZo=$.forwardRef(N5(function(e,n){const{__scopeAlertDialog:o,...i}=e,r=R5(o);return V.jsx(Cae,{...r,...i,ref:n})},"AlertDialogOverlay")),fZo="AlertDialogContent",[CZo,yZo]=_Zo(fZo),EZo=$.forwardRef(N5(function(e,n){const{__scopeAlertDialog:o,children:i,...r}=e,s=R5(o),a=$.useRef(null),A=Bl(n,a),c=$.useRef(null);return V.jsx(CZo,{scope:o,cancelRef:c,children:V.jsx(yae,{role:"alertdialog",...s,...r,ref:A,onOpenAutoFocus:Nr(r.onOpenAutoFocus,l=>{l.preventDefault(),c.current?.focus({preventScroll:!0})}),onPointerDownOutside:l=>l.preventDefault(),onInteractOutside:l=>l.preventDefault(),children:i})})},"AlertDialogContent")),xZo=$.forwardRef(N5(function(e,n){const{__scopeAlertDialog:o,...i}=e,r=R5(o);return V.jsx(C7e,{...r,...i,ref:n})},"AlertDialogTitle")),BZo=$.forwardRef(N5(function(e,n){const{__scopeAlertDialog:o,...i}=e,r=R5(o);return V.jsx(y7e,{...r,...i,ref:n})},"AlertDialogDescription")),QZo=$.forwardRef(N5(function(e,n){const{__scopeAlertDialog:o,...i}=e,r=R5(o);return V.jsx(AOt,{...r,...i,ref:n})},"AlertDialogAction")),SZo="AlertDialogCancel",bZo=$.forwardRef(N5(function(e,n){const{__scopeAlertDialog:o,...i}=e,{cancelRef:r}=yZo(SZo,o),s=R5(o),a=Bl(n,r);return V.jsx(AOt,{...s,...i,ref:a})},"AlertDialogCancel")),DZo=pZo,vZo=mZo,cOt=IZo,lOt=EZo,gOt=QZo,uOt=bZo,dOt=xZo,hOt=BZo;const _Ot=DZo,PZo=vZo,pOt=$.forwardRef(({className:t,...e},n)=>V.jsx(cOt,{className:Zi("rf-fixed rf-inset-0 rf-z-50 rf-bg-black/80 data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0",t),...e,ref:n}));pOt.displayName=cOt.displayName;const E7e=$.forwardRef(({className:t,...e},n)=>V.jsxs(PZo,{children:[V.jsx(pOt,{}),V.jsx(lOt,{ref:n,className:Zi("rf-fixed rf-left-[50%] rf-top-[50%] rf-z-50 rf-grid rf-w-full rf-max-w-lg rf-translate-x-[-50%] rf-translate-y-[-50%] rf-gap-4 rf-border rf-border-zinc-200 rf-bg-white rf-p-6 rf-shadow-lg rf-duration-200 data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0 data-[state=closed]:rf-zoom-out-95 data-[state=open]:rf-zoom-in-95 data-[state=closed]:rf-slide-out-to-left-1/2 data-[state=closed]:rf-slide-out-to-top-[48%] data-[state=open]:rf-slide-in-from-left-1/2 data-[state=open]:rf-slide-in-from-top-[48%] sm:rf-rounded-lg dark:rf-border-zinc-800 dark:rf-bg-zinc-950",t),...e})]}));E7e.displayName=lOt.displayName;const x7e=({className:t,...e})=>V.jsx("div",{className:Zi("rf-flex rf-flex-col rf-space-y-2 rf-text-center sm:rf-text-left",t),...e});x7e.displayName="AlertDialogHeader";const B7e=({className:t,...e})=>V.jsx("div",{className:Zi("rf-flex rf-flex-col-reverse sm:rf-flex-row sm:rf-justify-end sm:rf-space-x-2",t),...e});B7e.displayName="AlertDialogFooter";const Q7e=$.forwardRef(({className:t,...e},n)=>V.jsx(dOt,{ref:n,className:Zi("rf-text-lg rf-font-semibold",t),...e}));Q7e.displayName=dOt.displayName;const S7e=$.forwardRef(({className:t,...e},n)=>V.jsx(hOt,{ref:n,className:Zi("rf-text-sm rf-text-zinc-500 dark:rf-text-zinc-400",t),...e}));S7e.displayName=hOt.displayName;const wZo=$.forwardRef(({className:t,...e},n)=>V.jsx(gOt,{ref:n,className:Zi(Sk(),t),...e}));wZo.displayName=gOt.displayName;const b7e=$.forwardRef(({className:t,...e},n)=>V.jsx(uOt,{ref:n,className:Zi(Sk({variant:"outline"}),"rf-mt-2 sm:rf-mt-0",t),...e}));b7e.displayName=uOt.displayName;var MZo=Object.defineProperty,T5=(t,e)=>MZo(t,"name",{value:e,configurable:!0}),D7e="Checkbox",[NZo,Hci]=J2(D7e),[RZo,v7e]=NZo(D7e);function mOt(t){const{__scopeCheckbox:e,checked:n,children:o,defaultChecked:i,disabled:r,form:s,name:a,onCheckedChange:A,required:c,value:l="on",internal_do_not_use_render:g}=t,[u,h]=G4({prop:n,defaultProp:i??!1,onChange:A,caller:D7e}),[d,_]=$.useState(null),[p,m]=$.useState(null),I=$.useRef(!1),[f,C]=$.useReducer(B=>B+1,0),y=d?!!s||!!d.closest("form"):!0,E={checked:u,disabled:r,setChecked:h,control:d,setControl:_,name:a,form:s,value:l,hasConsumerStoppedPropagationRef:I,userInteractionCount:f,onUserInteraction:C,required:c,defaultChecked:k5(i)?!1:i,isFormControl:y,bubbleInput:p,setBubbleInput:m};return V.jsx(RZo,{scope:e,...E,children:fOt(g)?g(E):o})}T5(mOt,"CheckboxProvider");var TZo="CheckboxTrigger",kZo=$.forwardRef(T5(function({__scopeCheckbox:e,onKeyDown:n,onClick:o,...i},r){const{control:s,value:a,disabled:A,checked:c,required:l,setControl:g,setChecked:u,hasConsumerStoppedPropagationRef:h,onUserInteraction:d,isFormControl:_,bubbleInput:p}=v7e(TZo,e),m=Bl(r,g),I=$.useRef(c);return $.useEffect(()=>{const f=s?.form;if(f){const C=T5(()=>u(I.current),"reset");return f.addEventListener("reset",C),()=>f.removeEventListener("reset",C)}},[s,u]),V.jsx($A.button,{type:"button",role:"checkbox","aria-checked":k5(c)?"mixed":c,"aria-required":l,"data-state":P7e(c),"data-disabled":A?"":void 0,disabled:A,value:a,...i,ref:m,onKeyDown:Nr(n,f=>{f.key==="Enter"&&f.preventDefault()}),onClick:Nr(o,f=>{d(),u(C=>k5(C)?!0:!C),p&&_&&(h.current=f.isPropagationStopped(),h.current||f.stopPropagation())})})},"CheckboxTrigger")),IOt=$.forwardRef(T5(function(e,n){const{__scopeCheckbox:o,name:i,checked:r,defaultChecked:s,required:a,disabled:A,value:c,onCheckedChange:l,form:g,...u}=e;return V.jsx(mOt,{__scopeCheckbox:o,checked:r,defaultChecked:s,disabled:A,required:a,onCheckedChange:l,name:i,form:g,value:c,internal_do_not_use_render:({isFormControl:h})=>V.jsxs(V.Fragment,{children:[V.jsx(kZo,{...u,ref:n,__scopeCheckbox:o}),h&&V.jsx(GZo,{__scopeCheckbox:o})]})})},"Checkbox")),FZo="CheckboxIndicator",LZo=$.forwardRef(T5(function(e,n){const{__scopeCheckbox:o,forceMount:i,...r}=e,s=v7e(FZo,o);return V.jsx(Dx,{present:i||k5(s.checked)||s.checked===!0,children:V.jsx($A.span,{"data-state":P7e(s.checked),"data-disabled":s.disabled?"":void 0,...r,ref:n,style:{pointerEvents:"none",...e.style}})})},"CheckboxIndicator")),HZo="CheckboxBubbleInput",GZo=$.forwardRef(T5(function({__scopeCheckbox:e,onClick:n,...o},i){const{control:r,hasConsumerStoppedPropagationRef:s,userInteractionCount:a,checked:A,defaultChecked:c,required:l,disabled:g,name:u,value:h,form:d,bubbleInput:_,setBubbleInput:p}=v7e(HZo,e),m=Bl(i,p),I=D8e(r),f=$.useRef(!1),C=$.useRef(A),y=$.useRef(a);$.useEffect(()=>{const B=_;if(!B)return;const Q=window.HTMLInputElement.prototype,D=Object.getOwnPropertyDescriptor(Q,"checked").set,T=a!==y.current;y.current=a;const N=C.current!==A;C.current=A;const H=!(T&&s.current);if(N&&D){f.current=!T;const G=new Event("click",{bubbles:H});B.indeterminate=k5(A),D.call(B,k5(A)?!1:A),B.dispatchEvent(G),f.current=!1}},[_,A,s,a]);const E=$.useRef(k5(A)?!1:A);return V.jsx($A.input,{type:"checkbox","aria-hidden":!0,defaultChecked:c??E.current,required:l,disabled:g,name:u,value:h,form:d,...o,tabIndex:-1,ref:m,onClick:Nr(n,B=>{f.current&&B.stopPropagation()}),style:{...o.style,...I,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})},"CheckboxBubbleInput"));function fOt(t){return typeof t=="function"}T5(fOt,"isFunction");function k5(t){return t==="indeterminate"}T5(k5,"isIndeterminate");function P7e(t){return k5(t)?"indeterminate":t?"checked":"unchecked"}T5(P7e,"getState");const WY=$.forwardRef(({className:t,...e},n)=>V.jsx(IOt,{ref:n,className:Zi("rf-peer rf-h-4 rf-w-4 rf-shrink-0 rf-rounded-sm rf-border rf-border-zinc-200 rf-border-zinc-900 rf-shadow focus-visible:rf-outline-none focus-visible:rf-ring-1 focus-visible:rf-ring-zinc-950 disabled:rf-cursor-not-allowed disabled:rf-opacity-50 data-[state=checked]:rf-bg-zinc-900 data-[state=checked]:rf-text-zinc-50 dark:rf-border-zinc-800 dark:rf-border-zinc-50 dark:focus-visible:rf-ring-zinc-300 dark:data-[state=checked]:rf-bg-zinc-50 dark:data-[state=checked]:rf-text-zinc-900",t),...e,children:V.jsx(LZo,{className:Zi("rf-flex rf-items-center rf-justify-center rf-text-current"),children:V.jsx(V6,{className:"rf-h-4 rf-w-4"})})}));WY.displayName=IOt.displayName;const qk=m7e,OZo=I7e,COt=$.forwardRef(({className:t,...e},n)=>V.jsx(Cae,{className:Zi("rf-fixed rf-inset-0 rf-z-50 rf-bg-black/80 data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0",t),...e,ref:n}));COt.displayName=Cae.displayName;const i8=$.forwardRef(({className:t,children:e,showOverlay:n=!0,...o},i)=>V.jsxs(OZo,{children:[V.jsx(COt,{className:Zi(n?"":"rf-hidden")}),V.jsx(yae,{ref:i,className:Zi("rf-fixed rf-left-[50%] rf-top-[50%] rf-z-50 rf-grid rf-w-full rf-max-w-lg rf-translate-x-[-50%] rf-translate-y-[-50%] rf-gap-4 rf-border rf-border-zinc-200 rf-bg-white rf-p-6 rf-shadow-lg rf-duration-200 data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0 data-[state=closed]:rf-zoom-out-95 data-[state=open]:rf-zoom-in-95 data-[state=closed]:rf-slide-out-to-left-1/2 data-[state=closed]:rf-slide-out-to-top-[48%] data-[state=open]:rf-slide-in-from-left-1/2 data-[state=open]:rf-slide-in-from-top-[48%] sm:rf-rounded-lg dark:rf-border-zinc-800 dark:rf-bg-zinc-950",t),...o,children:e})]}));i8.displayName=yae.displayName;const r8=({className:t,...e})=>V.jsx("div",{className:Zi("rf-flex rf-flex-col rf-space-y-2 rf-text-center sm:rf-text-left",t),...e});r8.displayName="DialogHeader";const jY=({className:t,...e})=>V.jsx("div",{className:Zi("rf-flex rf-flex-col-reverse sm:rf-flex-row sm:rf-justify-end sm:rf-space-x-2",t),...e});jY.displayName="DialogFooter";const s8=$.forwardRef(({className:t,...e},n)=>V.jsx(C7e,{ref:n,className:Zi("rf-text-lg rf-font-semibold",t),...e}));s8.displayName=C7e.displayName;const Wk=$.forwardRef(({className:t,...e},n)=>V.jsx(y7e,{ref:n,className:Zi("rf-text-sm rf-text-zinc-500 dark:rf-text-zinc-400",t),...e}));Wk.displayName=y7e.displayName;const xae={"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"}},KZo="https://cdn.jsdelivr.net/npm/easyeda@latest/dist/browser/index.js";let w7e=null;const M7e=async()=>(w7e||(w7e=import(KZo)),w7e),UZo=t=>(e,n)=>{const o=new Headers(n?.headers),i={};return o.forEach((r,s)=>{i[s]=r}),fetch(`${t?.apiBase??Uf}/proxy`,{...n,headers:{...i,"X-Target-Url":e.toString(),"X-Sender-Origin":i.origin??"","X-Sender-Host":i.host??"https://easyeda.com","X-Sender-Referer":i.referer??"","X-Sender-User-Agent":i["user-agent"]??"","X-Sender-Cookie":i.cookie??"",authority:i.authority??"","content-type":i["content-type"]??"",...t?.headers}})},YZo=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??[]},zZo=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}),yOt=async(t,e)=>{const{fetchEasyEDAComponent:n}=await M7e();return n(t,{fetch:UZo(e),includeModelMetadata:e?.includeModelMetadata})},VZo=async(t,e)=>{const{convertRawEasyToTsx:n}=await M7e(),o=await yOt(t,e);return n({rawEasy:o})},JZo=async(t,e)=>{const{EasyEdaJsonSchema:n,convertEasyEdaJsonToCircuitJson:o}=await M7e(),i=await yOt(t,{...e,includeModelMetadata:!1}),r=n.parse(i);return o(r,{shouldRecenter:!0,showDesignator:!0,useModelCdn:!1})};function aw(t){return Array.isArray?Array.isArray(t):xOt(t)==="[object Array]"}function qZo(t){if(typeof t=="string")return t;if(typeof t=="bigint")return t.toString();const e=t+"";return e=="0"&&1/t==-1/0?"-0":e}function N7e(t){return t==null?"":qZo(t)}function nC(t){return typeof t=="string"}function Bae(t){return typeof t=="number"}function WZo(t){return t===!0||t===!1||jZo(t)&&xOt(t)=="[object Boolean]"}function EOt(t){return typeof t=="object"}function jZo(t){return EOt(t)&&t!==null}function hE(t){return t!=null}function Qae(t){return!t.trim().length}function xOt(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const XZo="Incorrect 'index' type",R7e="Invalid doc index: must be a non-negative integer within the bounds of the docs array",$Zo=t=>`Invalid value for key ${t}`,ZZo=t=>`Pattern length exceeds max of ${t}.`,eei=t=>`Missing ${t} property in key`,tei=t=>`Property 'weight' in key '${t}' must be a positive integer`,nei="Fuse.match does not support useTokenSearch: token search requires corpus-level statistics (df, fieldCount) that a one-off string comparison does not have. Use new Fuse(...).search(...) instead.",BOt=Object.prototype.hasOwnProperty;var oei=class{constructor(t){this._keys=[],this._keyMap={};let e=0;t.forEach(n=>{const o=QOt(n);this._keys.push(o),this._keyMap[o.id]=o,e+=o.weight}),this._keys.forEach(n=>{n.weight/=e})}get(t){return this._keyMap[t]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}};function QOt(t){let e=null,n=null,o=null,i=1,r=null;if(nC(t)||aw(t))o=t,e=SOt(t),n=Sae(t);else{if(!BOt.call(t,"name"))throw new Error(eei("name"));const s=t.name;if(o=s,BOt.call(t,"weight")&&t.weight!==void 0&&(i=t.weight,i<=0))throw new Error(tei(Sae(s)));e=SOt(s),n=Sae(s),r=t.getFn??null}return{path:e,id:n,weight:i,src:o,getFn:r}}function SOt(t){return aw(t)?t:t.split(".")}function Sae(t){return aw(t)?t.join("."):t}function iei(t,e){const n=[];let o=!1;const i=(r,s,a,A)=>{if(hE(r))if(!s[a])n.push(A!==void 0?{v:r,i:A}:r);else{const c=r[s[a]];if(!hE(c))return;if(a===s.length-1&&(nC(c)||Bae(c)||WZo(c)||typeof c=="bigint"))n.push(A!==void 0?{v:N7e(c),i:A}:N7e(c));else if(aw(c)){o=!0;for(let l=0,g=c.length;l<g;l+=1)i(c[l],s,a+1,l)}else s.length&&i(c,s,a+1,A)}};return i(t,nC(e)?e.split("."):e,0),o?n:n[0]}const Ls=Object.freeze({...{isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(t,e)=>t.score===e.score?t.idx<e.idx?-1:1:t.score<e.score?-1:1},...{includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},...{location:0,threshold:.6,distance:100},...{useExtendedSearch:!1,useTokenSearch:!1,tokenize:void 0,tokenMatch:"any",getFn:iei,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1}});function rei(t){return t>=9&&t<=13||t===32||t===160}function sei(t=1,e=3){const n=new Map,o=Math.pow(10,e);return{get(i){let r=0,s=!1;for(let A=0;A<i.length;A++)rei(i.charCodeAt(A))?s=!1:s||(r++,s=!0);if(r===0&&(r=1),n.has(r))return n.get(r);const a=Math.round(o/Math.pow(r,.5*t))/o;return n.set(r,a),a},clear(){n.clear()}}}var T7e=class{constructor({getFn:t=Ls.getFn,fieldNormWeight:e=Ls.fieldNormWeight}={}){this.norm=sei(e,3),this.getFn=t,this.isCreated=!1,this.docs=[],this.keys=[],this._keysMap={},this.setIndexRecords()}setSources(t=[]){this.docs=t}setIndexRecords(t=[]){this.records=t}setKeys(t=[]){this.keys=t,this._keysMap={},t.forEach((e,n)=>{this._keysMap[e.id]=n})}create(){if(this.isCreated||!this.docs.length)return;this.isCreated=!0;const t=this.docs.length;this.records=new Array(t);let e=0;if(nC(this.docs[0]))for(let n=0;n<t;n++){const o=this._createStringRecord(this.docs[n],n);o&&(this.records[e++]=o)}else for(let n=0;n<t;n++)this.records[e++]=this._createObjectRecord(this.docs[n],n);this.records.length=e,this.norm.clear()}add(t,e){if(!Number.isInteger(e)||e<0)throw new Error(R7e);if(nC(t)){const o=this._createStringRecord(t,e);return o&&this.records.push(o),o}const n=this._createObjectRecord(t,e);return this.records.push(n),n}removeAt(t){if(!Number.isInteger(t)||t<0)throw new Error(R7e);for(let e=0,n=this.records.length;e<n;e+=1)if(this.records[e].i===t){this.records.splice(e,1);break}for(let e=0,n=this.records.length;e<n;e+=1)this.records[e].i>t&&(this.records[e].i-=1)}removeAll(t){const e=new Set;for(const o of t)Number.isInteger(o)&&o>=0&&e.add(o);if(e.size===0)return;this.records=this.records.filter(o=>!e.has(o.i));const n=Array.from(e).sort((o,i)=>o-i);for(const o of this.records){let i=0,r=n.length;for(;i<r;){const s=i+r>>>1;n[s]<o.i?i=s+1:r=s}o.i-=i}}getValueForItemAtKeyId(t,e){return t[this._keysMap[e]]}size(){return this.records.length}_createStringRecord(t,e){return!hE(t)||Qae(t)?null:{v:t,i:e,n:this.norm.get(t)}}_createObjectRecord(t,e){const n={i:e,$:{}};for(let o=0,i=this.keys.length;o<i;o++){const r=this.keys[o],s=r.getFn?r.getFn(t):this.getFn(t,r.path);if(hE(s)){if(aw(s)){const a=[];for(let A=0,c=s.length;A<c;A+=1){const l=s[A];if(hE(l)){if(nC(l)){if(!Qae(l)){const g={v:l,i:A,n:this.norm.get(l)};a.push(g)}}else if(hE(l.v)){const g=nC(l.v)?l.v:N7e(l.v);if(!Qae(g)){const u={v:g,i:l.i,n:this.norm.get(g)};a.push(u)}}}}n.$[o]=a}else if(nC(s)&&!Qae(s)){const a={v:s,n:this.norm.get(s)};n.$[o]=a}}}return n}toJSON(){return{keys:this.keys.map(({getFn:t,...e})=>e),records:this.records}}};function bOt(t,e,{getFn:n=Ls.getFn,fieldNormWeight:o=Ls.fieldNormWeight}={}){const i=new T7e({getFn:n,fieldNormWeight:o});return i.setKeys(t.map(QOt)),i.setSources(e),i.create(),i}function aei(t,{getFn:e=Ls.getFn,fieldNormWeight:n=Ls.fieldNormWeight}={}){const{keys:o,records:i}=t,r=new T7e({getFn:e,fieldNormWeight:n});return r.setKeys(o),r.setIndexRecords(i),r}function Aei(t=[],e=Ls.minMatchCharLength){const n=[];let o=-1,i=-1,r=0;for(let s=t.length;r<s;r+=1){const a=t[r];a&&o===-1?o=r:!a&&o!==-1&&(i=r-1,i-o+1>=e&&n.push([o,i]),o=-1)}return t[r-1]&&r-o>=e&&n.push([o,r-1]),n}function cei(t,e,n,{location:o=Ls.location,distance:i=Ls.distance,threshold:r=Ls.threshold,findAllMatches:s=Ls.findAllMatches,minMatchCharLength:a=Ls.minMatchCharLength,includeMatches:A=Ls.includeMatches,ignoreLocation:c=Ls.ignoreLocation}={}){if(e.length>32)throw new Error(ZZo(32));const l=e.length,g=t.length,u=Math.max(0,Math.min(o,g));let h=r,d=u;const _=(b,D)=>{const T=b/l;if(c)return T;const N=Math.abs(u-D);return i?T+N/i:N?1:T},p=a>1||A,m=p?Array(g):[];let I;for(;(I=t.indexOf(e,d))>-1;){const b=_(0,I);if(h=Math.min(b,h),d=I+l,p){let D=0;for(;D<l;)m[I+D]=1,D+=1}}d=-1;let f=[],C=1,y=0,E=l+g;const B=1<<l-1;for(let b=0;b<l;b+=1){let D=0,T=E;for(;D<T;)_(b,u+T)<=h?D=T:E=T,T=Math.floor((E-D)/2+D);E=T;let N=Math.max(1,u-T+1);const H=s?g:Math.min(u+T,g)+l,G=Array(H+2);G[H+1]=(1<<b)-1;for(let O=H;O>=N;O-=1){const U=O-1,W=n[t[U]];if(G[O]=(G[O+1]<<1|1)&W,b&&(G[O]|=(f[O+1]|f[O])<<1|1|f[O+1]),G[O]&B&&(C=_(b,U),C<=h)){if(h=C,d=U,y=b,d<=u)break;N=Math.max(1,2*u-d)}}if(_(b+1,u)>h)break;f=G}if(p&&d>=0){const b=Math.min(g-1,d+l-1+y);for(let D=d;D<=b;D+=1)n[t[D]]&&(m[D]=1)}const Q={isMatch:d>=0,score:Math.max(.001,C)};if(p){const b=Aei(m,a);b.length?A&&(Q.indices=b):Q.isMatch=!1}return Q}function lei(t){const e={};for(let n=0,o=t.length;n<o;n+=1){const i=t.charAt(n);e[i]=(e[i]||0)|1<<o-n-1}return e}function k7e(t){if(t.length<=1)return t;t.sort((n,o)=>n[0]-o[0]||n[1]-o[1]);const e=[t[0]];for(let n=1,o=t.length;n<o;n+=1){const i=e[e.length-1],r=t[n];r[0]<=i[1]+1?i[1]=Math.max(i[1],r[1]):e.push(r)}return e}const DOt={ł:"l",Ł:"L",đ:"d",Đ:"D",ø:"o",Ø:"O",ħ:"h",Ħ:"H",ŧ:"t",Ŧ:"T",ı:"i",ß:"ss"},gei=new RegExp("["+Object.keys(DOt).join("")+"]","g"),XY=typeof String.prototype.normalize=="function"?t=>t.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,"").replace(gei,e=>DOt[e]):t=>t;var F7e=class{constructor(t,{location:e=Ls.location,threshold:n=Ls.threshold,distance:o=Ls.distance,includeMatches:i=Ls.includeMatches,findAllMatches:r=Ls.findAllMatches,minMatchCharLength:s=Ls.minMatchCharLength,isCaseSensitive:a=Ls.isCaseSensitive,ignoreDiacritics:A=Ls.ignoreDiacritics,ignoreLocation:c=Ls.ignoreLocation}={}){if(this.options={location:e,threshold:n,distance:o,includeMatches:i,findAllMatches:r,minMatchCharLength:s,isCaseSensitive:a,ignoreDiacritics:A,ignoreLocation:c},t=a?t:t.toLowerCase(),t=A?XY(t):t,this.pattern=t,this.chunks=[],!this.pattern.length)return;const l=(u,h)=>{this.chunks.push({pattern:u,alphabet:lei(u),startIndex:h})},g=this.pattern.length;if(g>32){let u=0;const h=g%32,d=g-h;for(;u<d;)l(this.pattern.substr(u,32),u),u+=32;if(h){const _=g-32;l(this.pattern.substr(_),_)}}else l(this.pattern,0)}searchIn(t){const{isCaseSensitive:e,ignoreDiacritics:n,includeMatches:o}=this.options;if(t=e?t:t.toLowerCase(),t=n?XY(t):t,this.pattern===t){if(t.length<this.options.minMatchCharLength)return{isMatch:!1,score:1};const d={isMatch:!0,score:0};return o&&(d.indices=[[0,t.length-1]]),d}const{location:i,distance:r,threshold:s,findAllMatches:a,minMatchCharLength:A,ignoreLocation:c}=this.options,l=[];let g=0,u=!1;this.chunks.forEach(({pattern:d,alphabet:_,startIndex:p})=>{const{isMatch:m,score:I,indices:f}=cei(t,d,_,{location:i+p,distance:r,threshold:s,findAllMatches:a,minMatchCharLength:A,includeMatches:o,ignoreLocation:c});m&&(u=!0),g+=I,m&&f&&l.push(...f)});const h={isMatch:u,score:u?g/this.chunks.length:1};return u&&o&&(h.indices=k7e(l)),h}};const uei=new Set(["fuzzy","include"]);function dei(t){return t.startsWith("inverse")}const L7e=[{type:"exact",multiRegex:/^="(.*)"$/,singleRegex:/^=(.*)$/,create:t=>({type:"exact",search(e){const n=e===t;return{isMatch:n,score:n?0:1,indices:[0,t.length-1]}}})},{type:"include",multiRegex:/^'"(.*)"$/,singleRegex:/^'(.*)$/,create:t=>({type:"include",search(e){let n=0,o;const i=[],r=t.length;for(;(o=e.indexOf(t,n))>-1;)n=o+r,i.push([o,n-1]);const s=!!i.length;return{isMatch:s,score:s?0:1,indices:i}}})},{type:"prefix-exact",multiRegex:/^\^"(.*)"$/,singleRegex:/^\^(.*)$/,create:t=>({type:"prefix-exact",search(e){const n=e.startsWith(t);return{isMatch:n,score:n?0:1,indices:[0,t.length-1]}}})},{type:"inverse-prefix-exact",multiRegex:/^!\^"(.*)"$/,singleRegex:/^!\^(.*)$/,create:t=>({type:"inverse-prefix-exact",search(e){const n=!e.startsWith(t);return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}})},{type:"inverse-suffix-exact",multiRegex:/^!"(.*)"\$$/,singleRegex:/^!(.*)\$$/,create:t=>({type:"inverse-suffix-exact",search(e){const n=!e.endsWith(t);return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}})},{type:"suffix-exact",multiRegex:/^"(.*)"\$$/,singleRegex:/^(.*)\$$/,create:t=>({type:"suffix-exact",search(e){const n=e.endsWith(t);return{isMatch:n,score:n?0:1,indices:[e.length-t.length,e.length-1]}}})},{type:"inverse-exact",multiRegex:/^!"(.*)"$/,singleRegex:/^!(.*)$/,create:t=>({type:"inverse-exact",search(e){const n=e.indexOf(t)===-1;return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}})},{type:"fuzzy",multiRegex:/^"(.*)"$/,singleRegex:/^(.*)$/,create:(t,e={})=>{const n=new F7e(t,{location:e.location??Ls.location,threshold:e.threshold??Ls.threshold,distance:e.distance??Ls.distance,includeMatches:e.includeMatches??Ls.includeMatches,findAllMatches:e.findAllMatches??Ls.findAllMatches,minMatchCharLength:e.minMatchCharLength??Ls.minMatchCharLength,isCaseSensitive:e.isCaseSensitive??Ls.isCaseSensitive,ignoreDiacritics:e.ignoreDiacritics??Ls.ignoreDiacritics,ignoreLocation:e.ignoreLocation??Ls.ignoreLocation});return{type:"fuzzy",search(o){return n.searchIn(o)}}}}],vOt=L7e.length,hei="\0",_ei="|";function pei(t){const e=[],n=t.length;let o=0;for(;o<n;){for(;o<n&&t[o]===" ";)o++;if(o>=n)break;let i=o;for(;i<n&&t[i]!==" "&&t[i]!=='"';)i++;if(i<n&&t[i]==='"'){for(i++;i<n;){if(t[i]==='"'){const r=i+1;if(r>=n||t[r]===" "){i++;break}if(t[r]==="$"&&(r+1>=n||t[r+1]===" ")){i+=2;break}}i++}e.push(t.substring(o,i)),o=i}else{for(;i<n&&t[i]!==" ";)i++;e.push(t.substring(o,i)),o=i}}return e}function POt(t,e){const n=t.match(e);return n?n[1]:null}function mei(t,e={}){return t.replace(/\\\|/g,hei).split(_ei).map(n=>{const o=pei(n.replace(/\u0000/g,"|").trim()).filter(r=>r&&!!r.trim()),i=[];for(let r=0,s=o.length;r<s;r+=1){const a=o[r];let A=!1,c=-1;for(;!A&&++c<vOt;){const l=L7e[c],g=POt(a,l.multiRegex);g&&(i.push(l.create(g,e)),A=!0)}if(!A)for(c=-1;++c<vOt;){const l=L7e[c],g=POt(a,l.singleRegex);if(g){i.push(l.create(g,e));break}}}return i})}var Iei=class{constructor(t,{isCaseSensitive:e=Ls.isCaseSensitive,ignoreDiacritics:n=Ls.ignoreDiacritics,includeMatches:o=Ls.includeMatches,minMatchCharLength:i=Ls.minMatchCharLength,ignoreLocation:r=Ls.ignoreLocation,findAllMatches:s=Ls.findAllMatches,location:a=Ls.location,threshold:A=Ls.threshold,distance:c=Ls.distance}={}){this.query=null,this.options={isCaseSensitive:e,ignoreDiacritics:n,includeMatches:o,minMatchCharLength:i,findAllMatches:s,ignoreLocation:r,location:a,threshold:A,distance:c},t=e?t:t.toLowerCase(),t=n?XY(t):t,this.pattern=t,this.query=mei(this.pattern,this.options)}static condition(t,e){return e.useExtendedSearch}searchIn(t){const e=this.query;if(!e)return{isMatch:!1,score:1};const{includeMatches:n,isCaseSensitive:o,ignoreDiacritics:i}=this.options;t=o?t:t.toLowerCase(),t=i?XY(t):t;let r=0;const s=[];let a=0,A=!1;for(let c=0,l=e.length;c<l;c+=1){const g=e[c];s.length=0,r=0,A=!1;for(let u=0,h=g.length;u<h;u+=1){const d=g[u],{isMatch:_,indices:p,score:m}=d.search(t);if(_)r+=1,a+=m,dei(d.type)&&(A=!0),n&&(uei.has(d.type)?s.push(...p):s.push(p));else{a=0,r=0,s.length=0,A=!1;break}}if(r){const u={isMatch:!0,score:a/r};return A&&(u.hasInverse=!0),n&&(u.indices=k7e(s)),u}}return{isMatch:!1,score:1}}};const H7e=[];function G7e(...t){H7e.push(...t)}function bae(t,e){for(let n=0,o=H7e.length;n<o;n+=1){const i=H7e[n];if(i.condition(t,e))return new i(t,e)}return new F7e(t,e)}const Dae={AND:"$and",OR:"$or"},O7e={PATH:"$path",PATTERN:"$val"},K7e=t=>!!(t[Dae.AND]||t[Dae.OR]),fei=t=>!!t[O7e.PATH],Cei=t=>!aw(t)&&EOt(t)&&!K7e(t),wOt=t=>({[Dae.AND]:Object.keys(t).map(e=>({[e]:t[e]}))});function MOt(t,e,{auto:n=!0}={}){const o=i=>{if(nC(i)){const A={keyId:null,pattern:i};return n&&(A.searcher=bae(i,e)),A}const r=Object.keys(i),s=fei(i);if(!s&&r.length>1&&!K7e(i))return o(wOt(i));if(Cei(i)){const A=s?i[O7e.PATH]:r[0],c=s?i[O7e.PATTERN]:i[A];if(!nC(c))throw new Error($Zo(A));const l={keyId:Sae(A),pattern:c};return n&&(l.searcher=bae(c,e)),l}const a={children:[],operator:r[0]};return r.forEach(A=>{const c=i[A];aw(c)&&c.forEach(l=>{a.children.push(o(l))})}),a};return K7e(t)||(t=wOt(t)),o(t)}function U7e(t,{ignoreFieldNorm:e=Ls.ignoreFieldNorm}){let n=1;return t.forEach(({key:o,norm:i,score:r})=>{const s=o?o.weight:null;n*=Math.pow(r===0&&s?Number.EPSILON:r,(s||1)*(e?1:i))}),n}function yei(t,{ignoreFieldNorm:e=Ls.ignoreFieldNorm}){t.forEach(n=>{n.score=U7e(n.matches,{ignoreFieldNorm:e})})}var Eei=class{constructor(t,e){this.limit=t,this.heap=[],this.comparator=e}get size(){return this.heap.length}insert(t){this.size<this.limit?(this.heap.push(t),this._bubbleUp(this.size-1)):this.comparator(t,this.heap[0])<0&&(this.heap[0]=t,this._sinkDown(0))}extractSorted(){return this.heap.sort(this.comparator)}_bubbleUp(t){const e=this.heap;for(;t>0;){const n=t-1>>1;if(this.comparator(e[t],e[n])<=0)break;const o=e[t];e[t]=e[n],e[n]=o,t=n}}_sinkDown(t){const e=this.heap,n=e.length;let o=t;do{t=o;const i=2*t+1,r=2*t+2;if(i<n&&this.comparator(e[i],e[o])>0&&(o=i),r<n&&this.comparator(e[r],e[o])>0&&(o=r),o!==t){const s=e[t];e[t]=e[o],e[o]=s}}while(o!==t)}};function xei(t){const e=[];return t.matches.forEach(n=>{if(!hE(n.indices)||!n.indices.length)return;const o={indices:n.indices,value:n.value};n.key&&(o.key=n.key.id),n.idx>-1&&(o.refIndex=n.idx),e.push(o)}),e}function Bei(t,e,{includeMatches:n=Ls.includeMatches,includeScore:o=Ls.includeScore}={}){return t.map(i=>{const{idx:r}=i,s={item:e[r],refIndex:r};return n&&(s.matches=xei(i)),o&&(s.score=i.score),s})}const Qei=/[\p{L}\p{M}\p{N}_]+/gu,NOt=new WeakSet;function Sei(t){NOt.has(t)||(NOt.add(t),console.warn(`[Fuse] tokenize regex ${t} lacks the global flag; only the first match per text will be returned. Add the 'g' flag.`))}function bei(t){if(typeof t=="function"){let e=!1;return n=>{const o=t(n);if(!e&&(e=!0,!Array.isArray(o)||o.some(i=>typeof i!="string")))throw new Error(`[Fuse] tokenize function must return string[]; received ${Array.isArray(o)?"array containing non-strings":typeof o}.`);return o}}return t instanceof RegExp?(t.global||Sei(t),e=>e.match(t)||[]):e=>e.match(Qei)||[]}function Y7e({isCaseSensitive:t=!1,ignoreDiacritics:e=!1,tokenize:n}={}){const o=bei(n);return{tokenize(i){return t||(i=i.toLowerCase()),e&&(i=XY(i)),o(i)}}}var Dei=class{static condition(t,e){return e.useTokenSearch}constructor(t,e){this.options=e,this.analyzer=Y7e({isCaseSensitive:e.isCaseSensitive,ignoreDiacritics:e.ignoreDiacritics,tokenize:e.tokenize});const n=this.analyzer.tokenize(t),{df:o,fieldCount:i}=e._invertedIndex;this.termSearchers=[],this.idfWeights=[];for(const r of n){this.termSearchers.push(new F7e(r,{location:e.location,threshold:e.threshold,distance:e.distance,includeMatches:e.includeMatches,findAllMatches:e.findAllMatches,minMatchCharLength:e.minMatchCharLength,isCaseSensitive:e.isCaseSensitive,ignoreDiacritics:e.ignoreDiacritics,ignoreLocation:!0}));const s=o.get(r)||0,a=Math.log(1+(i-s+.5)/(s+.5));this.idfWeights.push(a)}this.combineAll=e.tokenMatch==="all",this.numTerms=this.termSearchers.length,this.useMask=this.numTerms<=31}searchIn(t){if(!this.termSearchers.length)return{isMatch:!1,score:1};const e=[];let n=0,o=0,i=0,r=0;const s=this.combineAll&&!this.useMask?new Set:null;for(let c=0;c<this.termSearchers.length;c++){const l=this.termSearchers[c].searchIn(t),g=this.idfWeights[c];o+=g,l.isMatch&&(i++,n+=g*(1-l.score),l.indices&&e.push(...l.indices),this.combineAll&&(this.useMask?r|=1<<c:s.add(c)))}if(i===0)return{isMatch:!1,score:1};const a=o>0?1-n/o:0,A={isMatch:!0,score:Math.max(.001,a)};return this.options.includeMatches&&e.length&&(A.indices=k7e(e)),this.combineAll&&(this.useMask?A.matchedMask=r:A.matchedTerms=s,A.termCount=this.numTerms),A}};function z7e(t,e,n,o){const i=o.tokenize(e);if(!i.length)return;t.fieldCount++,t.docFieldCount.set(n,(t.docFieldCount.get(n)||0)+1);const r=new Set(i);let s=t.docTermFieldHits.get(n);s||(s=new Map,t.docTermFieldHits.set(n,s));for(const a of r)s.set(a,(s.get(a)||0)+1),t.df.set(a,(t.df.get(a)||0)+1)}function ROt(t,e,n,o){const{i,v:r,$:s}=e;if(r!==void 0){z7e(t,r,i,o);return}if(s)for(let a=0;a<n;a++){const A=s[a];if(A)if(Array.isArray(A))for(const c of A)z7e(t,c.v,i,o);else z7e(t,A.v,i,o)}}function vei(t,e,n){const o={fieldCount:0,df:new Map,docFieldCount:new Map,docTermFieldHits:new Map};for(const i of t)ROt(o,i,e,n);return o}function Pei(t,e,n,o){ROt(t,e,n,o)}function wei(t,e){const n=t.docFieldCount.get(e);if(n===void 0)return;t.fieldCount-=n,t.docFieldCount.delete(e);const o=t.docTermFieldHits.get(e);if(o){for(const[i,r]of o){const s=(t.df.get(i)||0)-r;s<=0?t.df.delete(i):t.df.set(i,s)}t.docTermFieldHits.delete(e)}}function TOt(t,e){if(e.length===0)return;const n=Array.from(new Set(e)).sort((a,A)=>a-A);for(const a of n)wei(t,a);const o=a=>{let A=0,c=n.length;for(;A<c;){const l=A+c>>>1;n[l]<a?A=l+1:c=l}return a-A},i=n[0],r=new Map;for(const[a,A]of t.docFieldCount)r.set(a>i?o(a):a,A);t.docFieldCount=r;const s=new Map;for(const[a,A]of t.docTermFieldHits)s.set(a>i?o(a):a,A);t.docTermFieldHits=s}var Aw=class{constructor(t,e,n){this.options={...Ls,...e},this.options.useExtendedSearch,this.options.useTokenSearch,this._keyStore=new oei(this.options.keys),this._docs=t,this._myIndex=null,this._invertedIndex=null,this.setCollection(t,n),this._lastQuery=null,this._lastSearcher=null}_getSearcher(t){if(this._lastQuery===t)return this._lastSearcher;const e=bae(t,this._invertedIndex?{...this.options,_invertedIndex:this._invertedIndex}:this.options);return this._lastQuery=t,this._lastSearcher=e,e}setCollection(t,e){if(this._docs=t,e&&!(e instanceof T7e))throw new Error(XZo);if(this._myIndex=e||bOt(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight}),this.options.useTokenSearch){const n=Y7e({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});this._invertedIndex=vei(this._myIndex.records,this._myIndex.keys.length,n)}this._invalidateSearcherCache()}add(t){if(!hE(t))return;this._docs.push(t);const e=this._myIndex.add(t,this._docs.length-1);if(this._invertedIndex&&e){const n=Y7e({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});Pei(this._invertedIndex,e,this._myIndex.keys.length,n)}this._invalidateSearcherCache()}remove(t=()=>!1){const e=[],n=[];for(let o=0,i=this._docs.length;o<i;o+=1)t(this._docs[o],o)&&(e.push(this._docs[o]),n.push(o));if(n.length){this._invertedIndex&&TOt(this._invertedIndex,n);const o=new Set(n);this._docs=this._docs.filter((i,r)=>!o.has(r)),this._myIndex.removeAll(n),this._invalidateSearcherCache()}return e}removeAt(t){if(!Number.isInteger(t)||t<0||t>=this._docs.length)throw new Error(R7e);this._invertedIndex&&TOt(this._invertedIndex,[t]);const e=this._docs.splice(t,1)[0];return this._myIndex.removeAt(t),this._invalidateSearcherCache(),e}_invalidateSearcherCache(){this._lastQuery=null,this._lastSearcher=null}getIndex(){return this._myIndex}_normalizedKeys(){return this._myIndex.keys.map(t=>this._keyStore.get(t.id)||t)}search(t,e){const{limit:n=-1}=e||{},{includeMatches:o,includeScore:i,shouldSort:r,sortFn:s,ignoreFieldNorm:a}=this.options;if(nC(t)&&!t.trim()){let u=this._docs.map((h,d)=>({item:h,refIndex:d}));return Bae(n)&&n>-1&&(u=u.slice(0,n)),u}const A=r&&Bae(n)&&n>0&&nC(t),c=s,l=(u,h)=>c(u,h)||u.idx-h.idx;let g;if(A){const u=new Eei(n,l);nC(this._docs[0])?this._searchStringList(t,{heap:u,ignoreFieldNorm:a}):this._searchObjectList(t,{heap:u,ignoreFieldNorm:a}),g=u.extractSorted()}else g=nC(t)?nC(this._docs[0])?this._searchStringList(t):this._searchObjectList(t):this._searchLogical(t),yei(g,{ignoreFieldNorm:a}),r&&g.sort(nC(t)?l:c),Bae(n)&&n>-1&&(g=g.slice(0,n));return Bei(g,this._docs,{includeMatches:o,includeScore:i})}_searchStringList(t,{heap:e,ignoreFieldNorm:n}={}){const o=this._getSearcher(t),i=this.options.useTokenSearch&&this.options.tokenMatch==="all",{records:r}=this._myIndex,s=e?null:[];return r.forEach(({v:a,i:A,n:c})=>{if(!hE(a))return;const l=o.searchIn(a);if(l.isMatch){const g={score:l.score,value:a,norm:c,indices:l.indices};i&&(g.matchedMask=l.matchedMask,g.matchedTerms=l.matchedTerms,g.termCount=l.termCount);const u=[g];if(!i||this._coversAllTokens(u)){const h={item:a,idx:A,matches:u};e?(h.score=U7e(h.matches,{ignoreFieldNorm:n}),e.insert(h)):s.push(h)}}}),s}_searchLogical(t){const e=MOt(t,this.options),n=this._normalizedKeys(),o=(a,A,c)=>{if(!("children"in a)){const{keyId:h,searcher:d}=a;let _;return h===null?(_=[],n.forEach((p,m)=>{_.push(...this._findMatches({key:p,value:A[m],searcher:d}))})):_=this._findMatches({key:this._keyStore.get(h),value:this._myIndex.getValueForItemAtKeyId(A,h),searcher:d}),_&&_.length?[{idx:c,item:A,matches:_}]:[]}const{children:l,operator:g}=a,u=[];for(let h=0,d=l.length;h<d;h+=1){const _=l[h],p=o(_,A,c);if(p.length)u.push(...p);else if(g===Dae.AND)return[]}return u},i=this._myIndex.records,r=new Map,s=[];return i.forEach(({$:a,i:A})=>{if(hE(a)){const c=o(e,a,A);c.length&&(r.has(A)||(r.set(A,{idx:A,item:a,matches:[]}),s.push(r.get(A))),c.forEach(({matches:l})=>{r.get(A).matches.push(...l)}))}}),s}_searchObjectList(t,{heap:e,ignoreFieldNorm:n}={}){const o=this._getSearcher(t),i=this.options.useTokenSearch&&this.options.tokenMatch==="all",{records:r}=this._myIndex,s=this._normalizedKeys(),a=e?null:[];return r.forEach(({$:A,i:c})=>{if(!hE(A))return;const l=[];let g=!1,u=!1;if(s.forEach((h,d)=>{const _=this._findMatches({key:h,value:A[d],searcher:o});_.length?(l.push(..._),_[0].hasInverse&&(u=!0)):g=!0}),!(u&&g)&&l.length&&(!i||this._coversAllTokens(l))){const h={idx:c,item:A,matches:l};e?(h.score=U7e(h.matches,{ignoreFieldNorm:n}),e.insert(h)):a.push(h)}}),a}_findMatches({key:t,value:e,searcher:n}){if(!hE(e))return[];const o=[];if(aw(e))e.forEach(({v:i,i:r,n:s})=>{if(!hE(i))return;const a=n.searchIn(i);if(a.isMatch){const A={score:a.score,key:t,value:i,idx:r,norm:s,indices:a.indices,hasInverse:a.hasInverse};a.termCount!==void 0&&(A.matchedMask=a.matchedMask,A.matchedTerms=a.matchedTerms,A.termCount=a.termCount),o.push(A)}});else{const{v:i,n:r}=e,s=n.searchIn(i);if(s.isMatch){const a={score:s.score,key:t,value:i,norm:r,indices:s.indices,hasInverse:s.hasInverse};s.termCount!==void 0&&(a.matchedMask=s.matchedMask,a.matchedTerms=s.matchedTerms,a.termCount=s.termCount),o.push(a)}}return o}_coversAllTokens(t){const e=t.length?t[0].termCount:void 0;if(e===void 0)return!0;if(e<=31){let o=0;for(let i=0;i<t.length;i++)o|=t[i].matchedMask||0;return o===2**e-1}const n=new Set;for(let o=0;o<t.length;o++){const i=t[o].matchedTerms;if(i)for(const r of i)n.add(r)}return n.size===e}};Aw.version="7.5.0",Aw.createIndex=bOt,Aw.parseIndex=aei,Aw.config=Ls,Aw.match=function(t,e,n){if(n&&n.useTokenSearch)throw new Error(nei);return bae(t,{...Ls,...n}).searchIn(e)},Aw.parseQuery=MOt,G7e(Iei),G7e(Dei),Aw.use=function(...t){t.forEach(e=>G7e(e))};var Mei=Aw;const Nei="https://kicad-mod-cache.tscircuit.com";let V7e=null,$Y=null,J7e=null;const Rei=async()=>V7e||$Y||($Y=fetch("https://kicad-mod-cache.tscircuit.com/kicad_files.json").then(t=>t.json()).then(t=>(V7e=t,$Y=null,t)),$Y),Tei=async(t,e=20)=>{const n=await Rei();return J7e||(J7e=new Mei(n)),J7e.search(t).slice(0,e).map(o=>o.item)},kei=t=>{const e=t.replace(".pretty/","/").replace(".kicad_mod",""),n=`kicad:${e}`;return{path:t,qualifiedName:n,description:e}},Fei=t=>t.replace(/^\/+/,"").split("/").map(e=>encodeURIComponent(e)).join("/"),Lei=async t=>{const e=await fetch(`${Nei}/${Fei(t)}`);if(!e.ok)throw new Error(`KiCad footprint fetch failed: ${e.status}`);const n=await e.text(),{KicadFootprintToCircuitJsonConverter:o}=await sQ("kicad-to-circuit-json"),i=new o;return i.addFile(t.split("/").pop()??"selected-footprint.kicad_mod",n),i.runUntilFinished(),i.getOutput()},kOt=t=>t?.source==="jlcpcb"||t?.source==="kicad",Hei=async(t,e)=>{if(t.source==="jlcpcb")return JZo(t.component.partNumber,e?.jlcpcb);if(t.source==="kicad")return Lei(t.footprint.path);throw new Error("Footprint preview is not available for this source")},Gei=({query:t,placeholder:e,isSearching:n,onQueryChange:o,onSubmit:i})=>{const r=$.useCallback(s=>{s.key==="Enter"&&(s.preventDefault(),i())},[i]);return V.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2 rf-mt-4",children:[V.jsxs("div",{className:"rf-relative rf-flex-grow",children:[V.jsx(r8e,{className:"rf-absolute rf-left-2 rf-top-2.5 rf-h-4 rf-w-4 rf-text-muted-foreground"}),V.jsx(e9e,{placeholder:e,className:"rf-pl-8",spellCheck:!1,autoComplete:"off",value:t,onChange:s=>o(s.target.value),onKeyDown:r})]}),V.jsx(cA,{onClick:i,disabled:n||t.trim().length<1,className:"sm:rf-px-4 rf-px-3",children:n?V.jsx(iQ,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):V.jsxs(V.Fragment,{children:[V.jsx(r8e,{className:"rf-h-4 rf-w-4 sm:rf-hidden"}),V.jsx("span",{className:"rf-hidden sm:rf-inline",children:"Search"})]})})]})},Oei=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}),Kei=t=>Oei.format(t),FOt=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"}},Uei=t=>{switch(t.source){case"tscircuit.com":return t.package.unscoped_name;case"jlcpcb":return t.component.isDirectLookup?t.component.partNumber:t.component.manufacturer;case"kicad":return t.footprint.qualifiedName}},Yei=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}},zei=t=>{switch(t.source){case"tscircuit.com":return t.package.name;case"jlcpcb":return t.component.isDirectLookup?void 0:t.component.partNumber;case"kicad":return}},Vei=({results:t,selected:e,onSelect:n,onShowDetails:o})=>{const i=e?FOt(e):null;return V.jsx("div",{className:"rf-divide-y rf-w-full rf-overflow-hidden",children:t.map(r=>{const s=FOt(r),a=i===s,A=Uei(r),c=Yei(r),l=zei(r),g=r.source==="jlcpcb"?r.component.stock:null,u=r.source==="jlcpcb"?r.component.price:null,h=r.source==="jlcpcb"?r.component.isBasic:null,d=r.source==="jlcpcb"?r.component.isDirectLookup:!1;return V.jsxs("div",{className:`rf-p-3 rf-flex rf-flex-col sm:rf-grid sm:rf-grid-cols-[minmax(0,1fr)_auto] rf-items-start sm:rf-items-center rf-cursor-pointer hover:rf-bg-zinc-100 rf-gap-2 rf-overflow-hidden ${a?"rf-bg-zinc-100":""}`,onClick:()=>n(r),children:[V.jsxs("div",{className:"rf-min-w-0 rf-overflow-hidden rf-w-full",children:[V.jsxs("div",{className:"rf-flex rf-items-start rf-gap-2 rf-min-w-0",children:[V.jsxs("div",{className:"rf-font-medium rf-text-sm rf-truncate rf-flex-1 rf-min-w-0 rf-flex rf-items-center rf-gap-1.5",children:[A,r.source==="jlcpcb"&&h!=null&&V.jsx("span",{className:`rf-text-xs rf-px-1.5 rf-py-0.5 rf-rounded rf-font-medium rf-flex-shrink-0 ${h?"rf-bg-green-100 rf-text-green-700":"rf-bg-orange-100 rf-text-orange-700"}`,children:h?"Basic":"Extended"}),d&&V.jsx("span",{className:"rf-text-xs rf-px-1.5 rf-py-0.5 rf-rounded rf-font-medium rf-flex-shrink-0 rf-bg-blue-100 rf-text-blue-700",children:"Direct lookup"}),r.source==="tscircuit.com"&&r.package.is_private&&V.jsx(MOo,{className:"rf-ml-1 rf-h-3 rf-w-3 rf-text-zinc-400 rf-flex-shrink-0"})]}),r.source==="jlcpcb"&&g!=null?V.jsxs("div",{className:"rf-text-xs rf-text-zinc-500 rf-font-medium rf-whitespace-nowrap rf-flex-shrink-0 sm:rf-hidden",children:[g.toLocaleString()," in stock"]}):null]}),V.jsxs("div",{className:"rf-text-xs rf-text-zinc-500 rf-truncate rf-w-full",children:[l?V.jsx("span",{className:"rf-mr-2",children:l}):null,c]})]}),V.jsxs("div",{children:[r.source==="tscircuit.com"&&o?V.jsx("div",{className:"rf-flex-shrink-0 rf-w-full sm:rf-w-auto",children:V.jsx(cA,{variant:"outline",size:"sm",className:"rf-text-xs rf-w-full sm:rf-w-auto",onClick:_=>{_.stopPropagation(),o(r)},children:"See Details"})}):r.source==="jlcpcb"&&g!=null?V.jsxs("div",{className:"rf-hidden sm:rf-block rf-text-xs rf-text-zinc-500 rf-font-medium rf-whitespace-nowrap rf-flex-shrink-0",children:[g.toLocaleString()," in stock"]}):null,u!=null&&V.jsx("div",{className:"rf-hidden sm:rf-block rf-text-xs rf-text-zinc-500 rf-font-medium rf-whitespace-nowrap rf-flex-shrink-0 rf-text-right",children:Kei(u)})]})]},s)})})},Jei=({circuitJson:t,error:e,isLoading:n,height:o})=>V.jsx("section",{className:"rf-flex rf-min-w-0 rf-items-center rf-justify-center",style:{height:o},children:n?V.jsxs("div",{className:"rf-flex rf-w-full rf-items-center rf-justify-center rf-gap-2 rf-bg-zinc-950 rf-text-sm rf-text-zinc-300",style:{height:o},children:[V.jsx(iQ,{className:"rf-h-4 rf-w-4 rf-animate-spin"}),"Loading preview..."]}):e?V.jsx("div",{className:"rf-flex rf-w-full rf-items-center rf-justify-center rf-bg-zinc-950 rf-p-4",style:{height:o},children:V.jsxs("div",{className:"rf-flex rf-max-w-[320px] rf-items-start rf-gap-2 rf-text-sm rf-text-zinc-300",children:[V.jsx(XNt,{className:"rf-mt-0.5 rf-h-4 rf-w-4 rf-flex-shrink-0"}),V.jsx("span",{children:e})]})}):t?V.jsx("div",{className:"rf-w-full rf-min-w-0 rf-overflow-hidden",children:V.jsx(YGt,{circuitJson:t,height:o,allowEditing:!1,clickToInteractEnabled:!1,focusOnHover:!1,disablePcbGroups:!0})}):V.jsx("div",{className:"rf-flex rf-w-full rf-items-center rf-justify-center rf-bg-zinc-950 rf-text-sm rf-text-zinc-300",style:{height:o},children:"No preview"})}),LOt={importComponentDialog:101,importComponentDetailsDialog:102},qei=({packageResult:t,isOpen:e,onOpenChange:n,isLoading:o,details:i,previewTab:r,onPreviewTabChange:s,isSubmitting:a,onImport:A})=>{const c=t?.package??null,l=c?.latest_pcb_preview_image_url,g=c?.latest_sch_preview_image_url,u=c?.latest_cad_preview_image_url,h=c?.unscoped_name?.split("/").pop()??c?.unscoped_name,d=c?.org_owner_tscircuit_handle??void 0,_=d?`https://tscircuit.com/${d}`:void 0,p=d&&h?`https://tscircuit.com/${d}/${h}`:void 0;return V.jsx(qk,{open:e,onOpenChange:n,children:V.jsxs(i8,{showOverlay:!1,style:{width:"calc(100vw - 2rem)",zIndex:LOt.importComponentDetailsDialog},className:"rf-max-w-5xl no-scrollbar !rf-overflow-y-auto rf-max-h-[90vh] rf-overflow-hidden rf-flex rf-flex-col rf-rounded-sm",children:[V.jsx(r8,{className:"rf-pb-4 rf-border-b",children:V.jsx("div",{className:"rf-flex rf-items-start rf-justify-between rf-gap-4",children:V.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[V.jsx(s8,{className:"rf-text-xl rf-font-semibold rf-truncate",children:h}),V.jsx(Wk,{children:c?.description})]})})}),V.jsxs("div",{className:"rf-flex-1 rf-overflow-y-auto rf-py-4 rf-space-y-6",children:[d?V.jsxs("div",{children:[V.jsx("span",{className:"rf-text-xs rf-font-medium rf-text-gray-500 rf-uppercase rf-tracking-wide",children:"Created by"}),V.jsx("div",{className:"rf-mt-1 rf-text-sm rf-font-medium",children:_?V.jsx("a",{href:_,target:"_blank",rel:"noopener noreferrer",className:"rf-text-black hover:rf-underline",children:d}):d})]}):null,(u||l||g)&&V.jsx(V.Fragment,{children:V.jsxs("div",{children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Preview"}),V.jsxs(Nxe,{value:r,onValueChange:m=>s(m),children:[V.jsxs(Hne,{className:"rf-inline-flex rf-h-9 rf-items-center rf-justify-center rf-rounded-lg rf-bg-zinc-100 rf-p-1 rf-text-zinc-500 dark:rf-bg-zinc-800 dark:rf-text-zinc-400",children:[l&&V.jsx(US,{value:"pcb",children:"PCB"}),g&&V.jsx(US,{value:"schematic",children:"Schematic"}),u&&V.jsx(US,{value:"3d",children:"3D"})]}),V.jsxs("div",{className:"rf-mt-4",children:[V.jsx(Vf,{value:"pcb",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:l?V.jsx("img",{src:l,alt:`${h??"package"} PCB preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null}),V.jsx(Vf,{value:"schematic",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:g?V.jsx("img",{src:g,alt:`${h??"package"} schematic preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null}),V.jsx(Vf,{value:"3d",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:u?V.jsx("img",{src:u,alt:`${h??"package"} 3D preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null})]})]})]})}),i?.ai_description?V.jsxs("section",{children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-3",children:"AI Description"}),V.jsx("div",{className:"rf-bg-gray-50 rf-border rf-border-gray-200 rf-rounded-lg rf-p-4",children:V.jsx("p",{className:"rf-text-sm rf-text-gray-700 rf-leading-relaxed",children:i.ai_description})})]}):null,i?.ai_usage_instructions?V.jsxs("section",{children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-3",children:"Usage Instructions"}),V.jsx("div",{className:"rf-bg-gray-50 rf-border rf-border-gray-200 rf-rounded-lg rf-p-4",children:V.jsx("p",{className:"rf-text-sm rf-text-gray-700 rf-leading-relaxed rf-whitespace-pre-wrap",children:i.ai_usage_instructions})})]}):null,o?V.jsxs("div",{className:"rf-flex rf-justify-center rf-items-center rf-gap-2 rf-text-gray-500",children:[V.jsx(iQ,{className:"rf-h-4 rf-w-4 rf-animate-spin"}),V.jsx("span",{className:"rf-text-sm",children:"Loading package details..."})]}):null]}),V.jsxs(jY,{className:"rf-pt-4 rf-border-t rf-flex rf-flex-col sm:rf-flex-row rf-justify-between rf-gap-2",children:[V.jsx("div",{className:"rf-flex-1",children:p?V.jsxs(cA,{variant:"outline",size:"sm",className:"rf-gap-2 rf-w-full sm:rf-w-auto",onClick:()=>window.open(p,"_blank"),children:[V.jsx(QOo,{className:"rf-h-4 rf-w-4"}),"View on tscircuit.com"]}):null}),V.jsxs("div",{className:"rf-flex rf-flex-col sm:rf-flex-row rf-gap-2",children:[V.jsx(cA,{variant:"outline",onClick:()=>n(!1),className:"rf-order-2 sm:rf-order-1",children:"Close"}),V.jsx(cA,{onClick:A,disabled:a,className:"rf-bg-blue-600 hover:rf-bg-blue-700",children:a?V.jsx(iQ,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):"Import Component"})]})]})]})})},Wei=()=>{const[t,e]=$.useState(null),[n,o]=$.useState(!1),i=$.useCallback(async(s,a)=>{o(!0);try{const A=await fetch(`https://api.tscircuit.com/packages/get?name=${encodeURIComponent(`${s}/${a}`)}`);if(!A.ok)throw new Error(`Failed to load package details: ${A.status}`);const c=await A.json();e(c.package??null)}catch(A){console.error("Failed to fetch package details",A),e(null)}finally{o(!1)}},[]),r=$.useCallback(()=>{e(null),o(!1)},[]);return{details:t,isLoading:n,fetchDetails:i,reset:r}},jei=(t,e)=>{const[n,o]=$.useState({circuitJson:null,error:null,isLoading:!1});return $.useEffect(()=>{if(!t||!kOt(t)){o({circuitJson:null,error:null,isLoading:!1});return}let i=!1;return o({circuitJson:null,error:null,isLoading:!0}),Hei(t,e).then(r=>{i||o({circuitJson:r,error:null,isLoading:!1})}).catch(r=>{i||o({circuitJson:null,error:r instanceof Error?r.message:"Failed to load footprint preview",isLoading:!1})}),()=>{i=!0}},[t,e]),n},Xei=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??[]},$ei=({sessionToken:t})=>{const[e,n]=$.useState([]),[o,i]=$.useState(!1),[r,s]=$.useState(null),[a,A]=$.useState(!1),c=$.useCallback(async g=>{const u=g.trim();if(!u)return[];i(!0),s(null);try{const d=(await Xei(u,t)).map(_=>({source:"tscircuit.com",package:_}));return n(d),d}catch(h){return console.error("Error searching tscircuit packages",h),n([]),s(h instanceof Error?h.message:"Failed to search tscircuit packages"),[]}finally{i(!1),A(!0)}},[t]),l=$.useCallback(()=>{n([]),i(!1),s(null),A(!1)},[]);return{results:e,isSearching:o,error:r,hasSearched:a,search:c,reset:l}},Zei=t=>{const e=/^C(\d+)$/i.exec(t.trim());if(!e)return null;const n=Number(e[1]);if(!Number.isSafeInteger(n))return null;const o=`C${e[1]}`;return{source:"jlcpcb",component:{lcscId:n,manufacturer:o,partNumber:o,description:"Import directly from EasyEDA; stock and availability are unknown",package:"",isDirectLookup:!0}}},HOt=(t,e)=>{const n=Zei(t);return n?e.some(i=>i.component.partNumber.toUpperCase()===n.component.partNumber)?e:[n,...e]:e},eti=t=>{const e=t.trim();return/^C\d+/i.test(e)?e.replace(/^C/i,""):e},tti=()=>{const[t,e]=$.useState([]),[n,o]=$.useState(!1),[i,r]=$.useState(null),[s,a]=$.useState(!1),A=$.useCallback(async l=>{const g=eti(l);if(!g)return[];o(!0),r(null);try{const u=await YZo(g,10),h=HOt(l,u.map(d=>({source:"jlcpcb",component:zZo(d)})));return e(h),h}catch(u){console.error("Error searching JLCPCB components",u);const h=HOt(l,[]);return e(h),r(h.length>0?null:u instanceof Error?u.message:"Failed to search JLCPCB components"),h}finally{o(!1),a(!0)}},[]),c=$.useCallback(()=>{e([]),o(!1),r(null),a(!1)},[]);return{results:t,isSearching:n,error:i,hasSearched:s,search:A,reset:c}},nti=()=>{const[t,e]=$.useState([]),[n,o]=$.useState(!1),[i,r]=$.useState(null),[s,a]=$.useState(!1),A=$.useCallback(async l=>{const g=l.trim();if(!g)return[];o(!0),r(null);try{const h=(await Tei(g,20)).map(d=>({source:"kicad",footprint:kei(d)}));return e(h),h}catch(u){return console.error("Error searching KiCad footprints",u),e([]),r(u instanceof Error?u.message:"Failed to search KiCad footprints"),[]}finally{o(!1),a(!0)}},[]),c=$.useCallback(()=>{e([]),o(!1),r(null),a(!1)},[]);return{results:t,isSearching:n,error:i,hasSearched:s,search:A,reset:c}},oti=({onTscircuitPackageSelected:t,onJlcpcbComponentTsxLoaded:e,onKicadStringSelected:n})=>{const o=[];return t&&o.push("tscircuit.com"),e&&o.push("jlcpcb"),n&&o.push("kicad"),o},iti=({isOpen:t,onClose:e,jlcpcbProxyRequestHeaders:n,onKicadStringSelected:o,onTscircuitPackageSelected:i,onJlcpcbComponentTsxLoaded:r,jlcpcbProxyApiBase:s,tscircuitSessionToken:a})=>{Iae();const A=$.useMemo(()=>oti({onKicadStringSelected:o,onTscircuitPackageSelected:i,onJlcpcbComponentTsxLoaded:r}),[o,i,r]),c=A.length>0,l=A.length===1,[g,u]=$.useState(A[0]??"tscircuit.com"),[h,d]=$.useState(""),[_,p]=$.useState(null),{results:m,isSearching:I,error:f,hasSearched:C,search:y,reset:E}=$ei({sessionToken:a}),{results:B,isSearching:Q,error:b,hasSearched:D,search:T,reset:N}=tti(),{results:H,isSearching:G,error:O,hasSearched:U,search:W,reset:j}=nti(),{details:ne,isLoading:re,fetchDetails:X,reset:Z}=Wei(),[se,ae]=$.useState(null),[le,fe]=$.useState(!1),[Ce,Ee]=$.useState("pcb"),[de,xe]=$.useState(null),[_e,Ne]=$.useState(!1),Oe=$.useMemo(()=>({jlcpcb:{headers:n,apiBase:s}}),[s,n]),{circuitJson:Je,error:Ie,isLoading:ze}=jei(_,Oe),Re=kOt(_);$.useEffect(()=>{xe(null)},[_]);const Le=$.useCallback(()=>{E(),N(),j(),p(null)},[N,j,E]);$.useEffect(()=>{t||(Le(),d(""),fe(!1),ae(null),xe(null))},[t,Le]),$.useEffect(()=>{d(""),p(null),g==="tscircuit.com"?E():g==="jlcpcb"?N():g==="kicad"&&j()},[g,N,j,E]);const Ve=dt=>{p(dt),ae(dt),Ee("pcb"),fe(!0),Z();const ot=dt.package.org_owner_tscircuit_handle,Qt=dt.package.unscoped_name;if(ot&&Qt){const It=Qt.split("/").pop()??Qt;X(ot,It)}},ke=async()=>{h.trim()&&(p(null),g==="tscircuit.com"?await y(h):g==="jlcpcb"?await T(h):g==="kicad"&&await W(h))},De=async dt=>{try{if(xe(null),Ne(!0),dt.source==="kicad"){if(!o)throw new Error("KiCad handler not provided");await o({result:dt,footprint:dt.footprint.qualifiedName})}else if(dt.source==="jlcpcb"){if(!r)throw new Error("JLCPCB handler not provided");const ot=await VZo(dt.component.partNumber,{headers:n,apiBase:s});await r({result:dt,tsx:ot})}else if(dt.source==="tscircuit.com"){if(!i)throw new Error("tscircuit package handler not provided");const ot=dt.package.org_owner_tscircuit_handle,Qt=dt.package.unscoped_name;if(!ot||!Qt)throw new Error("Missing package metadata");const It=Qt.split("/").pop()??Qt,Pt=`@tsci/${ot}.${It}`;await i({result:dt,fullPackageName:Pt})}return!0}catch(ot){return console.error("Failed to import component",ot),xe(ot instanceof Error?ot.message:"Failed to import component"),!1}finally{Ne(!1)}};let Ue=[],Pe=!1,We=null,et=!1;g==="tscircuit.com"?(Ue=m,Pe=I,We=f,et=C):g==="jlcpcb"?(Ue=B,Pe=Q,We=b,et=D):g==="kicad"&&(Ue=H,Pe=G,We=O,et=U);const At=async()=>{if(!_)return;await De(_)&&(e(),Le(),d(""))},gt=dt=>{dt||e()},_t=dt=>{fe(dt),dt||ae(null)};return V.jsxs(qk,{open:t,onOpenChange:gt,children:[V.jsxs(i8,{style:{width:"calc(100vw - 2rem)",maxWidth:Re?"min(1120px, calc(100vw - 2rem))":"min(672px, calc(100vw - 2rem))",zIndex:LOt.importComponentDialog},className:"rf-rounded-sm rf-max-h-[90vh] rf-overflow-y-auto rf-overflow-x-hidden rf-flex rf-flex-col",children:[V.jsxs(r8,{children:[V.jsxs(s8,{className:"rf-text-lg sm:rf-text-xl",children:["Import ",l?xae[g].label:""," ","Component"]}),V.jsx(Wk,{className:"rf-text-sm",children:c?"Search for components from available sources.":"Import options are disabled because no handlers were provided."})]}),c?V.jsxs(Nxe,{value:g,onValueChange:dt=>u(dt),className:"rf-min-w-0 rf-w-full",children:[!l&&V.jsx(Hne,{className:"rf-flex rf-w-full rf-gap-2",children:A.map(dt=>V.jsx(US,{value:dt,className:"rf-flex-1 rf-text-xs sm:rf-text-sm",children:xae[dt].label},dt))}),V.jsxs("div",{className:"rf-min-w-0",style:Re?{display:"grid",gridTemplateColumns:"minmax(0, 1fr) minmax(360px, 0.95fr)",gap:"1.5rem",alignItems:"start"}:void 0,children:[V.jsxs("div",{className:"rf-min-w-0",children:[V.jsx(Gei,{query:h,placeholder:xae[g].placeholder,isSearching:Pe,onQueryChange:d,onSubmit:ke}),V.jsx("div",{className:"no-scrollbar rf-mt-4 rf-flex-1 rf-min-h-[200px] !rf-max-h-[40vh] !rf-overflow-y-auto rf-overflow-x-hidden rf-border rf-rounded-md rf-min-w-0",children:Pe?V.jsxs("div",{className:"rf-p-8 rf-text-center rf-text-zinc-500",children:[V.jsx(iQ,{className:"rf-h-8 rf-w-8 rf-animate-spin rf-mx-auto rf-mb-2"}),V.jsx("p",{children:"Searching..."})]}):Ue.length>0?V.jsx(Vei,{results:Ue,selected:_,onSelect:p,onShowDetails:g==="tscircuit.com"?Ve:void 0}):V.jsx("div",{className:"rf-p-8 rf-text-center rf-text-zinc-500",children:We?`Error: ${We}`:et?xae[g].emptyMessage:"Enter a search term to find components"})})]}),Re?V.jsx("div",{className:"rf-mt-4",children:V.jsx(Jei,{circuitJson:Je,error:Ie,isLoading:ze,height:325})}):null]})]}):null,de?V.jsx("div",{className:"rf-text-sm rf-text-red-600 rf-mt-2",children:de}):null,V.jsxs(jY,{className:"rf-flex rf-flex-col sm:rf-flex-row rf-gap-2",children:[V.jsx(cA,{variant:"outline",onClick:e,className:"rf-order-2 sm:rf-order-1",children:"Cancel"}),V.jsx(cA,{onClick:At,disabled:!_||_e,className:"rf-order-1 sm:rf-order-2",children:_e?V.jsx(iQ,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):"Import"})]})]}),V.jsx(qei,{packageResult:se,isOpen:le,onOpenChange:_t,isLoading:re,details:ne,previewTab:Ce,onPreviewTabChange:dt=>Ee(dt),isSubmitting:_e,onImport:()=>{se&&De(se).then(dt=>{dt&&(fe(!1),e(),Le(),d(""))})}})]})},rti=t=>{const e=t.match(/export const (\w+) =/);if(!e)throw new Error("Could not determine component name from TSX contents");return e[1]},GOt=t=>{const e=od(s=>s.pushEvent),n=od(s=>s.upsertFile),o=async({result:s,fullPackageName:a})=>{const c=s.package.unscoped_name??s.package.name;await Ws.promise(e({event_type:"INSTALL_PACKAGE",full_package_name:a}),{loading:`Requesting install for "${c}"`,success:`Install requested for "${c}"`,error:l=>`Failed to request install: ${l instanceof Error?l.message:String(l)}`})},i=async({footprint:s})=>{await Ws.promise(navigator.clipboard.writeText(s),{loading:`Copying "${s}"`,success:`Copied "${s}" to clipboard`,error:a=>`Failed to copy footprint: ${a instanceof Error?a.message:String(a)}`})},r=async({result:s,tsx:a})=>{const c=`imports/${rti(a)}.tsx`;await Ws.promise(n(c,a),{loading:`Importing ${s.component.partNumber}`,success:`Imported to "${c}"`,error:l=>`Failed to import component: ${l instanceof Error?l.message:String(l)}`})};return V.jsx(iti,{...t,onTscircuitPackageSelected:o,onKicadStringSelected:i,onJlcpcbComponentTsxLoaded:r})};GOt.displayName="ImportComponentDialogForCli";var q7e={exports:{}},OOt;function sti(){return OOt||(OOt=1,(function(t,e){var n={env:{},version:""};(function(o){t.exports=o()})(function(){return(function o(i,r,s){function a(l,g){if(!r[l]){if(!i[l]){var u=typeof ND=="function"&&ND;if(!g&&u)return u(l,!0);if(A)return A(l,!0);var h=new Error("Cannot find module '"+l+"'");throw h.code="MODULE_NOT_FOUND",h}var d=r[l]={exports:{}};i[l][0].call(d.exports,function(_){var p=i[l][1][_];return a(p||_)},d,d.exports,o,i,r,s)}return r[l].exports}for(var A=typeof ND=="function"&&ND,c=0;c<s.length;c++)a(s[c]);return a})({1:[function(o,i,r){var s=o("./utils"),a=o("./support"),A="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";r.encode=function(c){for(var l,g,u,h,d,_,p,m=[],I=0,f=c.length,C=f,y=s.getTypeOf(c)!=="string";I<c.length;)C=f-I,u=y?(l=c[I++],g=I<f?c[I++]:0,I<f?c[I++]:0):(l=c.charCodeAt(I++),g=I<f?c.charCodeAt(I++):0,I<f?c.charCodeAt(I++):0),h=l>>2,d=(3&l)<<4|g>>4,_=1<C?(15&g)<<2|u>>6:64,p=2<C?63&u:64,m.push(A.charAt(h)+A.charAt(d)+A.charAt(_)+A.charAt(p));return m.join("")},r.decode=function(c){var l,g,u,h,d,_,p=0,m=0,I="data:";if(c.substr(0,I.length)===I)throw new Error("Invalid base64 input, it looks like a data url.");var f,C=3*(c=c.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(c.charAt(c.length-1)===A.charAt(64)&&C--,c.charAt(c.length-2)===A.charAt(64)&&C--,C%1!=0)throw new Error("Invalid base64 input, bad content length.");for(f=a.uint8array?new Uint8Array(0|C):new Array(0|C);p<c.length;)l=A.indexOf(c.charAt(p++))<<2|(h=A.indexOf(c.charAt(p++)))>>4,g=(15&h)<<4|(d=A.indexOf(c.charAt(p++)))>>2,u=(3&d)<<6|(_=A.indexOf(c.charAt(p++))),f[m++]=l,d!==64&&(f[m++]=g),_!==64&&(f[m++]=u);return f}},{"./support":30,"./utils":32}],2:[function(o,i,r){var s=o("./external"),a=o("./stream/DataWorker"),A=o("./stream/Crc32Probe"),c=o("./stream/DataLengthProbe");function l(g,u,h,d,_){this.compressedSize=g,this.uncompressedSize=u,this.crc32=h,this.compression=d,this.compressedContent=_}l.prototype={getContentWorker:function(){var g=new a(s.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new c("data_length")),u=this;return g.on("end",function(){if(this.streamInfo.data_length!==u.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),g},getCompressedWorker:function(){return new a(s.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},l.createWorkerFrom=function(g,u,h){return g.pipe(new A).pipe(new c("uncompressedSize")).pipe(u.compressWorker(h)).pipe(new c("compressedSize")).withStreamInfo("compression",u)},i.exports=l},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(o,i,r){var s=o("./stream/GenericWorker");r.STORE={magic:"\0\0",compressWorker:function(){return new s("STORE compression")},uncompressWorker:function(){return new s("STORE decompression")}},r.DEFLATE=o("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(o,i,r){var s=o("./utils"),a=(function(){for(var A,c=[],l=0;l<256;l++){A=l;for(var g=0;g<8;g++)A=1&A?3988292384^A>>>1:A>>>1;c[l]=A}return c})();i.exports=function(A,c){return A!==void 0&&A.length?s.getTypeOf(A)!=="string"?(function(l,g,u,h){var d=a,_=h+u;l^=-1;for(var p=h;p<_;p++)l=l>>>8^d[255&(l^g[p])];return-1^l})(0|c,A,A.length,0):(function(l,g,u,h){var d=a,_=h+u;l^=-1;for(var p=h;p<_;p++)l=l>>>8^d[255&(l^g.charCodeAt(p))];return-1^l})(0|c,A,A.length,0):0}},{"./utils":32}],5:[function(o,i,r){r.base64=!1,r.binary=!1,r.dir=!1,r.createFolders=!0,r.date=null,r.compression=null,r.compressionOptions=null,r.comment=null,r.unixPermissions=null,r.dosPermissions=null},{}],6:[function(o,i,r){var s=null;s=typeof Promise<"u"?Promise:o("lie"),i.exports={Promise:s}},{lie:37}],7:[function(o,i,r){var s=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",a=o("pako"),A=o("./utils"),c=o("./stream/GenericWorker"),l=s?"uint8array":"array";function g(u,h){c.call(this,"FlateWorker/"+u),this._pako=null,this._pakoAction=u,this._pakoOptions=h,this.meta={}}r.magic="\b\0",A.inherits(g,c),g.prototype.processChunk=function(u){this.meta=u.meta,this._pako===null&&this._createPako(),this._pako.push(A.transformTo(l,u.data),!1)},g.prototype.flush=function(){c.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},g.prototype.cleanUp=function(){c.prototype.cleanUp.call(this),this._pako=null},g.prototype._createPako=function(){this._pako=new a[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var u=this;this._pako.onData=function(h){u.push({data:h,meta:u.meta})}},r.compressWorker=function(u){return new g("Deflate",u)},r.uncompressWorker=function(){return new g("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(o,i,r){function s(d,_){var p,m="";for(p=0;p<_;p++)m+=String.fromCharCode(255&d),d>>>=8;return m}function a(d,_,p,m,I,f){var C,y,E=d.file,B=d.compression,Q=f!==l.utf8encode,b=A.transformTo("string",f(E.name)),D=A.transformTo("string",l.utf8encode(E.name)),T=E.comment,N=A.transformTo("string",f(T)),H=A.transformTo("string",l.utf8encode(T)),G=D.length!==E.name.length,O=H.length!==T.length,U="",W="",j="",ne=E.dir,re=E.date,X={crc32:0,compressedSize:0,uncompressedSize:0};_&&!p||(X.crc32=d.crc32,X.compressedSize=d.compressedSize,X.uncompressedSize=d.uncompressedSize);var Z=0;_&&(Z|=8),Q||!G&&!O||(Z|=2048);var se=0,ae=0;ne&&(se|=16),I==="UNIX"?(ae=798,se|=(function(fe,Ce){var Ee=fe;return fe||(Ee=Ce?16893:33204),(65535&Ee)<<16})(E.unixPermissions,ne)):(ae=20,se|=(function(fe){return 63&(fe||0)})(E.dosPermissions)),C=re.getUTCHours(),C<<=6,C|=re.getUTCMinutes(),C<<=5,C|=re.getUTCSeconds()/2,y=re.getUTCFullYear()-1980,y<<=4,y|=re.getUTCMonth()+1,y<<=5,y|=re.getUTCDate(),G&&(W=s(1,1)+s(g(b),4)+D,U+="up"+s(W.length,2)+W),O&&(j=s(1,1)+s(g(N),4)+H,U+="uc"+s(j.length,2)+j);var le="";return le+=`
5799
5799
  \0`,le+=s(Z,2),le+=B.magic,le+=s(C,2),le+=s(y,2),le+=s(X.crc32,4),le+=s(X.compressedSize,4),le+=s(X.uncompressedSize,4),le+=s(b.length,2),le+=s(U.length,2),{fileRecord:u.LOCAL_FILE_HEADER+le+b+U,dirRecord:u.CENTRAL_FILE_HEADER+s(ae,2)+le+s(N.length,2)+"\0\0\0\0"+s(se,4)+s(m,4)+b+U+N}}var A=o("../utils"),c=o("../stream/GenericWorker"),l=o("../utf8"),g=o("../crc32"),u=o("../signature");function h(d,_,p,m){c.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=_,this.zipPlatform=p,this.encodeFileName=m,this.streamFiles=d,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}A.inherits(h,c),h.prototype.push=function(d){var _=d.meta.percent||0,p=this.entriesCount,m=this._sources.length;this.accumulate?this.contentBuffer.push(d):(this.bytesWritten+=d.data.length,c.prototype.push.call(this,{data:d.data,meta:{currentFile:this.currentFile,percent:p?(_+100*(p-m-1))/p:100}}))},h.prototype.openedSource=function(d){this.currentSourceOffset=this.bytesWritten,this.currentFile=d.file.name;var _=this.streamFiles&&!d.file.dir;if(_){var p=a(d,_,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:p.fileRecord,meta:{percent:0}})}else this.accumulate=!0},h.prototype.closedSource=function(d){this.accumulate=!1;var _=this.streamFiles&&!d.file.dir,p=a(d,_,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(p.dirRecord),_)this.push({data:(function(m){return u.DATA_DESCRIPTOR+s(m.crc32,4)+s(m.compressedSize,4)+s(m.uncompressedSize,4)})(d),meta:{percent:100}});else for(this.push({data:p.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},h.prototype.flush=function(){for(var d=this.bytesWritten,_=0;_<this.dirRecords.length;_++)this.push({data:this.dirRecords[_],meta:{percent:100}});var p=this.bytesWritten-d,m=(function(I,f,C,y,E){var B=A.transformTo("string",E(y));return u.CENTRAL_DIRECTORY_END+"\0\0\0\0"+s(I,2)+s(I,2)+s(f,4)+s(C,4)+s(B.length,2)+B})(this.dirRecords.length,p,d,this.zipComment,this.encodeFileName);this.push({data:m,meta:{percent:100}})},h.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},h.prototype.registerPrevious=function(d){this._sources.push(d);var _=this;return d.on("data",function(p){_.processChunk(p)}),d.on("end",function(){_.closedSource(_.previous.streamInfo),_._sources.length?_.prepareNextSource():_.end()}),d.on("error",function(p){_.error(p)}),this},h.prototype.resume=function(){return!!c.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},h.prototype.error=function(d){var _=this._sources;if(!c.prototype.error.call(this,d))return!1;for(var p=0;p<_.length;p++)try{_[p].error(d)}catch{}return!0},h.prototype.lock=function(){c.prototype.lock.call(this);for(var d=this._sources,_=0;_<d.length;_++)d[_].lock()},i.exports=h},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(o,i,r){var s=o("../compressions"),a=o("./ZipFileWorker");r.generateWorker=function(A,c,l){var g=new a(c.streamFiles,l,c.platform,c.encodeFileName),u=0;try{A.forEach(function(h,d){u++;var _=(function(f,C){var y=f||C,E=s[y];if(!E)throw new Error(y+" is not a valid compression method !");return E})(d.options.compression,c.compression),p=d.options.compressionOptions||c.compressionOptions||{},m=d.dir,I=d.date;d._compressWorker(_,p).withStreamInfo("file",{name:h,dir:m,date:I,comment:d.comment||"",unixPermissions:d.unixPermissions,dosPermissions:d.dosPermissions}).pipe(g)}),g.entriesCount=u}catch(h){g.error(h)}return g}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(o,i,r){function s(){if(!(this instanceof s))return new s;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var a=new s;for(var A in this)typeof this[A]!="function"&&(a[A]=this[A]);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,A){return new s().loadAsync(a,A)},s.external=o("./external"),i.exports=s},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(o,i,r){var s=o("./utils"),a=o("./external"),A=o("./utf8"),c=o("./zipEntries"),l=o("./stream/Crc32Probe"),g=o("./nodejsUtils");function u(h){return new a.Promise(function(d,_){var p=h.decompressed.getContentWorker().pipe(new l);p.on("error",function(m){_(m)}).on("end",function(){p.streamInfo.crc32!==h.decompressed.crc32?_(new Error("Corrupted zip : CRC32 mismatch")):d()}).resume()})}i.exports=function(h,d){var _=this;return d=s.extend(d||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:A.utf8decode}),g.isNode&&g.isStream(h)?a.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):s.prepareContent("the loaded zip file",h,!0,d.optimizedBinaryString,d.base64).then(function(p){var m=new c(d);return m.load(p),m}).then(function(p){var m=[a.Promise.resolve(p)],I=p.files;if(d.checkCRC32)for(var f=0;f<I.length;f++)m.push(u(I[f]));return a.Promise.all(m)}).then(function(p){for(var m=p.shift(),I=m.files,f=0;f<I.length;f++){var C=I[f],y=C.fileNameStr,E=s.resolve(C.fileNameStr);_.file(E,C.decompressed,{binary:!0,optimizedBinaryString:!0,date:C.date,dir:C.dir,comment:C.fileCommentStr.length?C.fileCommentStr:null,unixPermissions:C.unixPermissions,dosPermissions:C.dosPermissions,createFolders:d.createFolders}),C.dir||(_.file(E).unsafeOriginalName=y)}return m.zipComment.length&&(_.comment=m.zipComment),_})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(o,i,r){var s=o("../utils"),a=o("../stream/GenericWorker");function A(c,l){a.call(this,"Nodejs stream input adapter for "+c),this._upstreamEnded=!1,this._bindStream(l)}s.inherits(A,a),A.prototype._bindStream=function(c){var l=this;(this._stream=c).pause(),c.on("data",function(g){l.push({data:g,meta:{percent:0}})}).on("error",function(g){l.isPaused?this.generatedError=g:l.error(g)}).on("end",function(){l.isPaused?l._upstreamEnded=!0:l.end()})},A.prototype.pause=function(){return!!a.prototype.pause.call(this)&&(this._stream.pause(),!0)},A.prototype.resume=function(){return!!a.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},i.exports=A},{"../stream/GenericWorker":28,"../utils":32}],13:[function(o,i,r){var s=o("readable-stream").Readable;function a(A,c,l){s.call(this,c),this._helper=A;var g=this;A.on("data",function(u,h){g.push(u)||g._helper.pause(),l&&l(h)}).on("error",function(u){g.emit("error",u)}).on("end",function(){g.push(null)})}o("../utils").inherits(a,s),a.prototype._read=function(){this._helper.resume()},i.exports=a},{"../utils":32,"readable-stream":16}],14:[function(o,i,r){i.exports={isNode:typeof Buffer<"u",newBufferFrom:function(s,a){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(s,a);if(typeof s=="number")throw new Error('The "data" argument must not be a number');return new Buffer(s,a)},allocBuffer:function(s){if(Buffer.alloc)return Buffer.alloc(s);var a=new Buffer(s);return a.fill(0),a},isBuffer:function(s){return Buffer.isBuffer(s)},isStream:function(s){return s&&typeof s.on=="function"&&typeof s.pause=="function"&&typeof s.resume=="function"}}},{}],15:[function(o,i,r){function s(E,B,Q){var b,D=A.getTypeOf(B),T=A.extend(Q||{},g);T.date=T.date||new Date,T.compression!==null&&(T.compression=T.compression.toUpperCase()),typeof T.unixPermissions=="string"&&(T.unixPermissions=parseInt(T.unixPermissions,8)),T.unixPermissions&&16384&T.unixPermissions&&(T.dir=!0),T.dosPermissions&&16&T.dosPermissions&&(T.dir=!0),T.dir&&(E=I(E)),T.createFolders&&(b=m(E))&&f.call(this,b,!0);var N=D==="string"&&T.binary===!1&&T.base64===!1;Q&&Q.binary!==void 0||(T.binary=!N),(B instanceof u&&B.uncompressedSize===0||T.dir||!B||B.length===0)&&(T.base64=!1,T.binary=!0,B="",T.compression="STORE",D="string");var H=null;H=B instanceof u||B instanceof c?B:_.isNode&&_.isStream(B)?new p(E,B):A.prepareContent(E,B,T.binary,T.optimizedBinaryString,T.base64);var G=new h(E,H,T);this.files[E]=G}var a=o("./utf8"),A=o("./utils"),c=o("./stream/GenericWorker"),l=o("./stream/StreamHelper"),g=o("./defaults"),u=o("./compressedObject"),h=o("./zipObject"),d=o("./generate"),_=o("./nodejsUtils"),p=o("./nodejs/NodejsStreamInputAdapter"),m=function(E){E.slice(-1)==="/"&&(E=E.substring(0,E.length-1));var B=E.lastIndexOf("/");return 0<B?E.substring(0,B):""},I=function(E){return E.slice(-1)!=="/"&&(E+="/"),E},f=function(E,B){return B=B!==void 0?B:g.createFolders,E=I(E),this.files[E]||s.call(this,E,null,{dir:!0,createFolders:B}),this.files[E]};function C(E){return Object.prototype.toString.call(E)==="[object RegExp]"}var y={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(E){var B,Q,b;for(B in this.files)b=this.files[B],(Q=B.slice(this.root.length,B.length))&&B.slice(0,this.root.length)===this.root&&E(Q,b)},filter:function(E){var B=[];return this.forEach(function(Q,b){E(Q,b)&&B.push(b)}),B},file:function(E,B,Q){if(arguments.length!==1)return E=this.root+E,s.call(this,E,B,Q),this;if(C(E)){var b=E;return this.filter(function(T,N){return!N.dir&&b.test(T)})}var D=this.files[this.root+E];return D&&!D.dir?D:null},folder:function(E){if(!E)return this;if(C(E))return this.filter(function(D,T){return T.dir&&E.test(D)});var B=this.root+E,Q=f.call(this,B),b=this.clone();return b.root=Q.name,b},remove:function(E){E=this.root+E;var B=this.files[E];if(B||(E.slice(-1)!=="/"&&(E+="/"),B=this.files[E]),B&&!B.dir)delete this.files[E];else for(var Q=this.filter(function(D,T){return T.name.slice(0,E.length)===E}),b=0;b<Q.length;b++)delete this.files[Q[b].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(E){var B,Q={};try{if((Q=A.extend(E||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:a.utf8encode})).type=Q.type.toLowerCase(),Q.compression=Q.compression.toUpperCase(),Q.type==="binarystring"&&(Q.type="string"),!Q.type)throw new Error("No output type specified.");A.checkSupport(Q.type),Q.platform!=="darwin"&&Q.platform!=="freebsd"&&Q.platform!=="linux"&&Q.platform!=="sunos"||(Q.platform="UNIX"),Q.platform==="win32"&&(Q.platform="DOS");var b=Q.comment||this.comment||"";B=d.generateWorker(this,Q,b)}catch(D){(B=new c("error")).error(D)}return new l(B,Q.type||"string",Q.mimeType)},generateAsync:function(E,B){return this.generateInternalStream(E).accumulate(B)},generateNodeStream:function(E,B){return(E=E||{}).type||(E.type="nodebuffer"),this.generateInternalStream(E).toNodejsStream(B)}};i.exports=y},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(o,i,r){i.exports=o("stream")},{stream:void 0}],17:[function(o,i,r){var s=o("./DataReader");function a(A){s.call(this,A);for(var c=0;c<this.data.length;c++)A[c]=255&A[c]}o("../utils").inherits(a,s),a.prototype.byteAt=function(A){return this.data[this.zero+A]},a.prototype.lastIndexOfSignature=function(A){for(var c=A.charCodeAt(0),l=A.charCodeAt(1),g=A.charCodeAt(2),u=A.charCodeAt(3),h=this.length-4;0<=h;--h)if(this.data[h]===c&&this.data[h+1]===l&&this.data[h+2]===g&&this.data[h+3]===u)return h-this.zero;return-1},a.prototype.readAndCheckSignature=function(A){var c=A.charCodeAt(0),l=A.charCodeAt(1),g=A.charCodeAt(2),u=A.charCodeAt(3),h=this.readData(4);return c===h[0]&&l===h[1]&&g===h[2]&&u===h[3]},a.prototype.readData=function(A){if(this.checkOffset(A),A===0)return[];var c=this.data.slice(this.zero+this.index,this.zero+this.index+A);return this.index+=A,c},i.exports=a},{"../utils":32,"./DataReader":18}],18:[function(o,i,r){var s=o("../utils");function a(A){this.data=A,this.length=A.length,this.index=0,this.zero=0}a.prototype={checkOffset:function(A){this.checkIndex(this.index+A)},checkIndex:function(A){if(this.length<this.zero+A||A<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+A+"). Corrupted zip ?")},setIndex:function(A){this.checkIndex(A),this.index=A},skip:function(A){this.setIndex(this.index+A)},byteAt:function(){},readInt:function(A){var c,l=0;for(this.checkOffset(A),c=this.index+A-1;c>=this.index;c--)l=(l<<8)+this.byteAt(c);return this.index+=A,l},readString:function(A){return s.transformTo("string",this.readData(A))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var A=this.readInt(4);return new Date(Date.UTC(1980+(A>>25&127),(A>>21&15)-1,A>>16&31,A>>11&31,A>>5&63,(31&A)<<1))}},i.exports=a},{"../utils":32}],19:[function(o,i,r){var s=o("./Uint8ArrayReader");function a(A){s.call(this,A)}o("../utils").inherits(a,s),a.prototype.readData=function(A){this.checkOffset(A);var c=this.data.slice(this.zero+this.index,this.zero+this.index+A);return this.index+=A,c},i.exports=a},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(o,i,r){var s=o("./DataReader");function a(A){s.call(this,A)}o("../utils").inherits(a,s),a.prototype.byteAt=function(A){return this.data.charCodeAt(this.zero+A)},a.prototype.lastIndexOfSignature=function(A){return this.data.lastIndexOf(A)-this.zero},a.prototype.readAndCheckSignature=function(A){return A===this.readData(4)},a.prototype.readData=function(A){this.checkOffset(A);var c=this.data.slice(this.zero+this.index,this.zero+this.index+A);return this.index+=A,c},i.exports=a},{"../utils":32,"./DataReader":18}],21:[function(o,i,r){var s=o("./ArrayReader");function a(A){s.call(this,A)}o("../utils").inherits(a,s),a.prototype.readData=function(A){if(this.checkOffset(A),A===0)return new Uint8Array(0);var c=this.data.subarray(this.zero+this.index,this.zero+this.index+A);return this.index+=A,c},i.exports=a},{"../utils":32,"./ArrayReader":17}],22:[function(o,i,r){var s=o("../utils"),a=o("../support"),A=o("./ArrayReader"),c=o("./StringReader"),l=o("./NodeBufferReader"),g=o("./Uint8ArrayReader");i.exports=function(u){var h=s.getTypeOf(u);return s.checkSupport(h),h!=="string"||a.uint8array?h==="nodebuffer"?new l(u):a.uint8array?new g(s.transformTo("uint8array",u)):new A(s.transformTo("array",u)):new c(u)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(o,i,r){r.LOCAL_FILE_HEADER="PK",r.CENTRAL_FILE_HEADER="PK",r.CENTRAL_DIRECTORY_END="PK",r.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",r.ZIP64_CENTRAL_DIRECTORY_END="PK",r.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(o,i,r){var s=o("./GenericWorker"),a=o("../utils");function A(c){s.call(this,"ConvertWorker to "+c),this.destType=c}a.inherits(A,s),A.prototype.processChunk=function(c){this.push({data:a.transformTo(this.destType,c.data),meta:c.meta})},i.exports=A},{"../utils":32,"./GenericWorker":28}],25:[function(o,i,r){var s=o("./GenericWorker"),a=o("../crc32");function A(){s.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}o("../utils").inherits(A,s),A.prototype.processChunk=function(c){this.streamInfo.crc32=a(c.data,this.streamInfo.crc32||0),this.push(c)},i.exports=A},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(o,i,r){var s=o("../utils"),a=o("./GenericWorker");function A(c){a.call(this,"DataLengthProbe for "+c),this.propName=c,this.withStreamInfo(c,0)}s.inherits(A,a),A.prototype.processChunk=function(c){if(c){var l=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=l+c.data.length}a.prototype.processChunk.call(this,c)},i.exports=A},{"../utils":32,"./GenericWorker":28}],27:[function(o,i,r){var s=o("../utils"),a=o("./GenericWorker");function A(c){a.call(this,"DataWorker");var l=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,c.then(function(g){l.dataIsReady=!0,l.data=g,l.max=g&&g.length||0,l.type=s.getTypeOf(g),l.isPaused||l._tickAndRepeat()},function(g){l.error(g)})}s.inherits(A,a),A.prototype.cleanUp=function(){a.prototype.cleanUp.call(this),this.data=null},A.prototype.resume=function(){return!!a.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,s.delay(this._tickAndRepeat,[],this)),!0)},A.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(s.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},A.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var c=null,l=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":c=this.data.substring(this.index,l);break;case"uint8array":c=this.data.subarray(this.index,l);break;case"array":case"nodebuffer":c=this.data.slice(this.index,l)}return this.index=l,this.push({data:c,meta:{percent:this.max?this.index/this.max*100:0}})},i.exports=A},{"../utils":32,"./GenericWorker":28}],28:[function(o,i,r){function 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,A){return this._listeners[a].push(A),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(a,A){if(this._listeners[a])for(var c=0;c<this._listeners[a].length;c++)this._listeners[a][c].call(this,A)},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 A=this;return a.on("data",function(c){A.processChunk(c)}),a.on("end",function(){A.end()}),a.on("error",function(c){A.error(c)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var 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,A){return this.extraStreamInfo[a]=A,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var a in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,a)&&(this.streamInfo[a]=this.extraStreamInfo[a])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var a="Worker "+this.name;return this.previous?this.previous+" -> "+a:a}},i.exports=s},{}],29:[function(o,i,r){var s=o("../utils"),a=o("./ConvertWorker"),A=o("./GenericWorker"),c=o("../base64"),l=o("../support"),g=o("../external"),u=null;if(l.nodestream)try{u=o("../nodejs/NodejsStreamOutputAdapter")}catch{}function h(_,p){return new g.Promise(function(m,I){var f=[],C=_._internalType,y=_._outputType,E=_._mimeType;_.on("data",function(B,Q){f.push(B),p&&p(Q)}).on("error",function(B){f=[],I(B)}).on("end",function(){try{var B=(function(Q,b,D){switch(Q){case"blob":return s.newBlob(s.transformTo("arraybuffer",b),D);case"base64":return c.encode(b);default:return s.transformTo(Q,b)}})(y,(function(Q,b){var D,T=0,N=null,H=0;for(D=0;D<b.length;D++)H+=b[D].length;switch(Q){case"string":return b.join("");case"array":return Array.prototype.concat.apply([],b);case"uint8array":for(N=new Uint8Array(H),D=0;D<b.length;D++)N.set(b[D],T),T+=b[D].length;return N;case"nodebuffer":return Buffer.concat(b);default:throw new Error("concat : unsupported type '"+Q+"'")}})(C,f),E);m(B)}catch(Q){I(Q)}f=[]}).resume()})}function d(_,p,m){var I=p;switch(p){case"blob":case"arraybuffer":I="uint8array";break;case"base64":I="string"}try{this._internalType=I,this._outputType=p,this._mimeType=m,s.checkSupport(I),this._worker=_.pipe(new a(I)),_.lock()}catch(f){this._worker=new A("error"),this._worker.error(f)}}d.prototype={accumulate:function(_){return h(this,_)},on:function(_,p){var m=this;return _==="data"?this._worker.on(_,function(I){p.call(m,I.data,I.meta)}):this._worker.on(_,function(){s.delay(p,arguments,m)}),this},resume:function(){return s.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(_){if(s.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new u(this,{objectMode:this._outputType!=="nodebuffer"},_)}},i.exports=d},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(o,i,r){if(r.base64=!0,r.array=!0,r.string=!0,r.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",r.nodebuffer=typeof Buffer<"u",r.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")r.blob=!1;else{var s=new ArrayBuffer(0);try{r.blob=new Blob([s],{type:"application/zip"}).size===0}catch{try{var a=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);a.append(s),r.blob=a.getBlob("application/zip").size===0}catch{r.blob=!1}}}try{r.nodestream=!!o("readable-stream").Readable}catch{r.nodestream=!1}},{"readable-stream":16}],31:[function(o,i,r){for(var s=o("./utils"),a=o("./support"),A=o("./nodejsUtils"),c=o("./stream/GenericWorker"),l=new Array(256),g=0;g<256;g++)l[g]=252<=g?6:248<=g?5:240<=g?4:224<=g?3:192<=g?2:1;l[254]=l[254]=1;function u(){c.call(this,"utf-8 decode"),this.leftOver=null}function h(){c.call(this,"utf-8 encode")}r.utf8encode=function(d){return a.nodebuffer?A.newBufferFrom(d,"utf-8"):(function(_){var p,m,I,f,C,y=_.length,E=0;for(f=0;f<y;f++)(64512&(m=_.charCodeAt(f)))==55296&&f+1<y&&(64512&(I=_.charCodeAt(f+1)))==56320&&(m=65536+(m-55296<<10)+(I-56320),f++),E+=m<128?1:m<2048?2:m<65536?3:4;for(p=a.uint8array?new Uint8Array(E):new Array(E),f=C=0;C<E;f++)(64512&(m=_.charCodeAt(f)))==55296&&f+1<y&&(64512&(I=_.charCodeAt(f+1)))==56320&&(m=65536+(m-55296<<10)+(I-56320),f++),m<128?p[C++]=m:(m<2048?p[C++]=192|m>>>6:(m<65536?p[C++]=224|m>>>12:(p[C++]=240|m>>>18,p[C++]=128|m>>>12&63),p[C++]=128|m>>>6&63),p[C++]=128|63&m);return p})(d)},r.utf8decode=function(d){return a.nodebuffer?s.transformTo("nodebuffer",d).toString("utf-8"):(function(_){var p,m,I,f,C=_.length,y=new Array(2*C);for(p=m=0;p<C;)if((I=_[p++])<128)y[m++]=I;else if(4<(f=l[I]))y[m++]=65533,p+=f-1;else{for(I&=f===2?31:f===3?15:7;1<f&&p<C;)I=I<<6|63&_[p++],f--;1<f?y[m++]=65533:I<65536?y[m++]=I:(I-=65536,y[m++]=55296|I>>10&1023,y[m++]=56320|1023&I)}return y.length!==m&&(y.subarray?y=y.subarray(0,m):y.length=m),s.applyFromCharCode(y)})(d=s.transformTo(a.uint8array?"uint8array":"array",d))},s.inherits(u,c),u.prototype.processChunk=function(d){var _=s.transformTo(a.uint8array?"uint8array":"array",d.data);if(this.leftOver&&this.leftOver.length){if(a.uint8array){var p=_;(_=new Uint8Array(p.length+this.leftOver.length)).set(this.leftOver,0),_.set(p,this.leftOver.length)}else _=this.leftOver.concat(_);this.leftOver=null}var m=(function(f,C){var y;for((C=C||f.length)>f.length&&(C=f.length),y=C-1;0<=y&&(192&f[y])==128;)y--;return y<0||y===0?C:y+l[f[y]]>C?y:C})(_),I=_;m!==_.length&&(a.uint8array?(I=_.subarray(0,m),this.leftOver=_.subarray(m,_.length)):(I=_.slice(0,m),this.leftOver=_.slice(m,_.length))),this.push({data:r.utf8decode(I),meta:d.meta})},u.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:r.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},r.Utf8DecodeWorker=u,s.inherits(h,c),h.prototype.processChunk=function(d){this.push({data:r.utf8encode(d.data),meta:d.meta})},r.Utf8EncodeWorker=h},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(o,i,r){var s=o("./support"),a=o("./base64"),A=o("./nodejsUtils"),c=o("./external");function l(p){return p}function g(p,m){for(var I=0;I<p.length;++I)m[I]=255&p.charCodeAt(I);return m}o("setimmediate"),r.newBlob=function(p,m){r.checkSupport("blob");try{return new Blob([p],{type:m})}catch{try{var I=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return I.append(p),I.getBlob(m)}catch{throw new Error("Bug : can't construct the Blob.")}}};var u={stringifyByChunk:function(p,m,I){var f=[],C=0,y=p.length;if(y<=I)return String.fromCharCode.apply(null,p);for(;C<y;)m==="array"||m==="nodebuffer"?f.push(String.fromCharCode.apply(null,p.slice(C,Math.min(C+I,y)))):f.push(String.fromCharCode.apply(null,p.subarray(C,Math.min(C+I,y)))),C+=I;return f.join("")},stringifyByChar:function(p){for(var m="",I=0;I<p.length;I++)m+=String.fromCharCode(p[I]);return m},applyCanBeUsed:{uint8array:(function(){try{return s.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}})(),nodebuffer:(function(){try{return s.nodebuffer&&String.fromCharCode.apply(null,A.allocBuffer(1)).length===1}catch{return!1}})()}};function h(p){var m=65536,I=r.getTypeOf(p),f=!0;if(I==="uint8array"?f=u.applyCanBeUsed.uint8array:I==="nodebuffer"&&(f=u.applyCanBeUsed.nodebuffer),f)for(;1<m;)try{return u.stringifyByChunk(p,I,m)}catch{m=Math.floor(m/2)}return u.stringifyByChar(p)}function d(p,m){for(var I=0;I<p.length;I++)m[I]=p[I];return m}r.applyFromCharCode=h;var _={};_.string={string:l,array:function(p){return g(p,new Array(p.length))},arraybuffer:function(p){return _.string.uint8array(p).buffer},uint8array:function(p){return g(p,new Uint8Array(p.length))},nodebuffer:function(p){return g(p,A.allocBuffer(p.length))}},_.array={string:h,array:l,arraybuffer:function(p){return new Uint8Array(p).buffer},uint8array:function(p){return new Uint8Array(p)},nodebuffer:function(p){return A.newBufferFrom(p)}},_.arraybuffer={string:function(p){return h(new Uint8Array(p))},array:function(p){return d(new Uint8Array(p),new Array(p.byteLength))},arraybuffer:l,uint8array:function(p){return new Uint8Array(p)},nodebuffer:function(p){return A.newBufferFrom(new Uint8Array(p))}},_.uint8array={string:h,array:function(p){return d(p,new Array(p.length))},arraybuffer:function(p){return p.buffer},uint8array:l,nodebuffer:function(p){return A.newBufferFrom(p)}},_.nodebuffer={string:h,array:function(p){return d(p,new Array(p.length))},arraybuffer:function(p){return _.nodebuffer.uint8array(p).buffer},uint8array:function(p){return d(p,new Uint8Array(p.length))},nodebuffer:l},r.transformTo=function(p,m){if(m=m||"",!p)return m;r.checkSupport(p);var I=r.getTypeOf(m);return _[I][p](m)},r.resolve=function(p){for(var m=p.split("/"),I=[],f=0;f<m.length;f++){var C=m[f];C==="."||C===""&&f!==0&&f!==m.length-1||(C===".."?I.pop():I.push(C))}return I.join("/")},r.getTypeOf=function(p){return typeof p=="string"?"string":Object.prototype.toString.call(p)==="[object Array]"?"array":s.nodebuffer&&A.isBuffer(p)?"nodebuffer":s.uint8array&&p instanceof Uint8Array?"uint8array":s.arraybuffer&&p instanceof ArrayBuffer?"arraybuffer":void 0},r.checkSupport=function(p){if(!s[p.toLowerCase()])throw new Error(p+" is not supported by this platform")},r.MAX_VALUE_16BITS=65535,r.MAX_VALUE_32BITS=-1,r.pretty=function(p){var m,I,f="";for(I=0;I<(p||"").length;I++)f+="\\x"+((m=p.charCodeAt(I))<16?"0":"")+m.toString(16).toUpperCase();return f},r.delay=function(p,m,I){setImmediate(function(){p.apply(I||null,m||[])})},r.inherits=function(p,m){function I(){}I.prototype=m.prototype,p.prototype=new I},r.extend=function(){var p,m,I={};for(p=0;p<arguments.length;p++)for(m in arguments[p])Object.prototype.hasOwnProperty.call(arguments[p],m)&&I[m]===void 0&&(I[m]=arguments[p][m]);return I},r.prepareContent=function(p,m,I,f,C){return c.Promise.resolve(m).then(function(y){return s.blob&&(y instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(y))!==-1)&&typeof FileReader<"u"?new c.Promise(function(E,B){var Q=new FileReader;Q.onload=function(b){E(b.target.result)},Q.onerror=function(b){B(b.target.error)},Q.readAsArrayBuffer(y)}):y}).then(function(y){var E=r.getTypeOf(y);return E?(E==="arraybuffer"?y=r.transformTo("uint8array",y):E==="string"&&(C?y=a.decode(y):I&&f!==!0&&(y=(function(B){return g(B,s.uint8array?new Uint8Array(B.length):new Array(B.length))})(y))),y):c.Promise.reject(new Error("Can't read the data of '"+p+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(o,i,r){var s=o("./reader/readerFor"),a=o("./utils"),A=o("./signature"),c=o("./zipEntry"),l=o("./support");function g(u){this.files=[],this.loadOptions=u}g.prototype={checkSignature:function(u){if(!this.reader.readAndCheckSignature(u)){this.reader.index-=4;var h=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+a.pretty(h)+", expected "+a.pretty(u)+")")}},isSignature:function(u,h){var d=this.reader.index;this.reader.setIndex(u);var _=this.reader.readString(4)===h;return this.reader.setIndex(d),_},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var u=this.reader.readData(this.zipCommentLength),h=l.uint8array?"uint8array":"array",d=a.transformTo(h,u);this.zipComment=this.loadOptions.decodeFileName(d)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var u,h,d,_=this.zip64EndOfCentralSize-44;0<_;)u=this.reader.readInt(2),h=this.reader.readInt(4),d=this.reader.readData(h),this.zip64ExtensibleData[u]={id:u,length:h,value:d}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var u,h;for(u=0;u<this.files.length;u++)h=this.files[u],this.reader.setIndex(h.localHeaderOffset),this.checkSignature(A.LOCAL_FILE_HEADER),h.readLocalPart(this.reader),h.handleUTF8(),h.processAttributes()},readCentralDir:function(){var u;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(A.CENTRAL_FILE_HEADER);)(u=new c({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(u);if(this.centralDirRecords!==this.files.length&&this.centralDirRecords!==0&&this.files.length===0)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var u=this.reader.lastIndexOfSignature(A.CENTRAL_DIRECTORY_END);if(u<0)throw this.isSignature(0,A.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(u);var h=u;if(this.checkSignature(A.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,(u=this.reader.lastIndexOfSignature(A.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(u),this.checkSignature(A.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,A.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(A.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(A.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var d=this.centralDirOffset+this.centralDirSize;this.zip64&&(d+=20,d+=12+this.zip64EndOfCentralSize);var _=h-d;if(0<_)this.isSignature(h,A.CENTRAL_FILE_HEADER)||(this.reader.zero=_);else if(_<0)throw new Error("Corrupted zip: missing "+Math.abs(_)+" bytes.")},prepareReader:function(u){this.reader=s(u)},load:function(u){this.prepareReader(u),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},i.exports=g},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(o,i,r){var s=o("./reader/readerFor"),a=o("./utils"),A=o("./compressedObject"),c=o("./crc32"),l=o("./utf8"),g=o("./compressions"),u=o("./support");function h(d,_){this.options=d,this.loadOptions=_}h.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(d){var _,p;if(d.skip(22),this.fileNameLength=d.readInt(2),p=d.readInt(2),this.fileName=d.readData(this.fileNameLength),d.skip(p),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((_=(function(m){for(var I in g)if(Object.prototype.hasOwnProperty.call(g,I)&&g[I].magic===m)return g[I];return null})(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+a.pretty(this.compressionMethod)+" unknown (inner file : "+a.transformTo("string",this.fileName)+")");this.decompressed=new A(this.compressedSize,this.uncompressedSize,this.crc32,_,d.readData(this.compressedSize))},readCentralPart:function(d){this.versionMadeBy=d.readInt(2),d.skip(2),this.bitFlag=d.readInt(2),this.compressionMethod=d.readString(2),this.date=d.readDate(),this.crc32=d.readInt(4),this.compressedSize=d.readInt(4),this.uncompressedSize=d.readInt(4);var _=d.readInt(2);if(this.extraFieldsLength=d.readInt(2),this.fileCommentLength=d.readInt(2),this.diskNumberStart=d.readInt(2),this.internalFileAttributes=d.readInt(2),this.externalFileAttributes=d.readInt(4),this.localHeaderOffset=d.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");d.skip(_),this.readExtraFields(d),this.parseZIP64ExtraField(d),this.fileComment=d.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var d=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),d==0&&(this.dosPermissions=63&this.externalFileAttributes),d==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var d=s(this.extraFields[1].value);this.uncompressedSize===a.MAX_VALUE_32BITS&&(this.uncompressedSize=d.readInt(8)),this.compressedSize===a.MAX_VALUE_32BITS&&(this.compressedSize=d.readInt(8)),this.localHeaderOffset===a.MAX_VALUE_32BITS&&(this.localHeaderOffset=d.readInt(8)),this.diskNumberStart===a.MAX_VALUE_32BITS&&(this.diskNumberStart=d.readInt(4))}},readExtraFields:function(d){var _,p,m,I=d.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});d.index+4<I;)_=d.readInt(2),p=d.readInt(2),m=d.readData(p),this.extraFields[_]={id:_,length:p,value:m};d.setIndex(I)},handleUTF8:function(){var d=u.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=l.utf8decode(this.fileName),this.fileCommentStr=l.utf8decode(this.fileComment);else{var _=this.findExtraFieldUnicodePath();if(_!==null)this.fileNameStr=_;else{var p=a.transformTo(d,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(p)}var m=this.findExtraFieldUnicodeComment();if(m!==null)this.fileCommentStr=m;else{var I=a.transformTo(d,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(I)}}},findExtraFieldUnicodePath:function(){var d=this.extraFields[28789];if(d){var _=s(d.value);return _.readInt(1)!==1||c(this.fileName)!==_.readInt(4)?null:l.utf8decode(_.readData(d.length-5))}return null},findExtraFieldUnicodeComment:function(){var d=this.extraFields[25461];if(d){var _=s(d.value);return _.readInt(1)!==1||c(this.fileComment)!==_.readInt(4)?null:l.utf8decode(_.readData(d.length-5))}return null}},i.exports=h},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(o,i,r){function s(_,p,m){this.name=_,this.dir=m.dir,this.date=m.date,this.comment=m.comment,this.unixPermissions=m.unixPermissions,this.dosPermissions=m.dosPermissions,this._data=p,this._dataBinary=m.binary,this.options={compression:m.compression,compressionOptions:m.compressionOptions}}var a=o("./stream/StreamHelper"),A=o("./stream/DataWorker"),c=o("./utf8"),l=o("./compressedObject"),g=o("./stream/GenericWorker");s.prototype={internalStream:function(_){var p=null,m="string";try{if(!_)throw new Error("No output type specified.");var I=(m=_.toLowerCase())==="string"||m==="text";m!=="binarystring"&&m!=="text"||(m="string"),p=this._decompressWorker();var f=!this._dataBinary;f&&!I&&(p=p.pipe(new c.Utf8EncodeWorker)),!f&&I&&(p=p.pipe(new c.Utf8DecodeWorker))}catch(C){(p=new g("error")).error(C)}return new a(p,m,"")},async:function(_,p){return this.internalStream(_).accumulate(p)},nodeStream:function(_,p){return this.internalStream(_||"nodebuffer").toNodejsStream(p)},_compressWorker:function(_,p){if(this._data instanceof l&&this._data.compression.magic===_.magic)return this._data.getCompressedWorker();var m=this._decompressWorker();return this._dataBinary||(m=m.pipe(new c.Utf8EncodeWorker)),l.createWorkerFrom(m,_,p)},_decompressWorker:function(){return this._data instanceof l?this._data.getContentWorker():this._data instanceof g?this._data:new A(this._data)}};for(var u=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],h=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},d=0;d<u.length;d++)s.prototype[u[d]]=h;i.exports=s},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(o,i,r){(function(s){var a,A,c=s.MutationObserver||s.WebKitMutationObserver;if(c){var l=0,g=new c(_),u=s.document.createTextNode("");g.observe(u,{characterData:!0}),a=function(){u.data=l=++l%2}}else if(s.setImmediate||s.MessageChannel===void 0)a="document"in s&&"onreadystatechange"in s.document.createElement("script")?function(){var p=s.document.createElement("script");p.onreadystatechange=function(){_(),p.onreadystatechange=null,p.parentNode.removeChild(p),p=null},s.document.documentElement.appendChild(p)}:function(){setTimeout(_,0)};else{var h=new s.MessageChannel;h.port1.onmessage=_,a=function(){h.port2.postMessage(0)}}var d=[];function _(){var p,m;A=!0;for(var I=d.length;I;){for(m=d,d=[],p=-1;++p<I;)m[p]();I=d.length}A=!1}i.exports=function(p){d.push(p)!==1||A||a()}}).call(this,typeof FC<"u"?FC:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(o,i,r){var s=o("immediate");function a(){}var A={},c=["REJECTED"],l=["FULFILLED"],g=["PENDING"];function u(I){if(typeof I!="function")throw new TypeError("resolver must be a function");this.state=g,this.queue=[],this.outcome=void 0,I!==a&&p(this,I)}function h(I,f,C){this.promise=I,typeof f=="function"&&(this.onFulfilled=f,this.callFulfilled=this.otherCallFulfilled),typeof C=="function"&&(this.onRejected=C,this.callRejected=this.otherCallRejected)}function d(I,f,C){s(function(){var y;try{y=f(C)}catch(E){return A.reject(I,E)}y===I?A.reject(I,new TypeError("Cannot resolve promise with itself")):A.resolve(I,y)})}function _(I){var f=I&&I.then;if(I&&(typeof I=="object"||typeof I=="function")&&typeof f=="function")return function(){f.apply(I,arguments)}}function p(I,f){var C=!1;function y(Q){C||(C=!0,A.reject(I,Q))}function E(Q){C||(C=!0,A.resolve(I,Q))}var B=m(function(){f(E,y)});B.status==="error"&&y(B.value)}function m(I,f){var C={};try{C.value=I(f),C.status="success"}catch(y){C.status="error",C.value=y}return C}(i.exports=u).prototype.finally=function(I){if(typeof I!="function")return this;var f=this.constructor;return this.then(function(C){return f.resolve(I()).then(function(){return C})},function(C){return f.resolve(I()).then(function(){throw C})})},u.prototype.catch=function(I){return this.then(null,I)},u.prototype.then=function(I,f){if(typeof I!="function"&&this.state===l||typeof f!="function"&&this.state===c)return this;var C=new this.constructor(a);return this.state!==g?d(C,this.state===l?I:f,this.outcome):this.queue.push(new h(C,I,f)),C},h.prototype.callFulfilled=function(I){A.resolve(this.promise,I)},h.prototype.otherCallFulfilled=function(I){d(this.promise,this.onFulfilled,I)},h.prototype.callRejected=function(I){A.reject(this.promise,I)},h.prototype.otherCallRejected=function(I){d(this.promise,this.onRejected,I)},A.resolve=function(I,f){var C=m(_,f);if(C.status==="error")return A.reject(I,C.value);var y=C.value;if(y)p(I,y);else{I.state=l,I.outcome=f;for(var E=-1,B=I.queue.length;++E<B;)I.queue[E].callFulfilled(f)}return I},A.reject=function(I,f){I.state=c,I.outcome=f;for(var C=-1,y=I.queue.length;++C<y;)I.queue[C].callRejected(f);return I},u.resolve=function(I){return I instanceof this?I:A.resolve(new this(a),I)},u.reject=function(I){var f=new this(a);return A.reject(f,I)},u.all=function(I){var f=this;if(Object.prototype.toString.call(I)!=="[object Array]")return this.reject(new TypeError("must be an array"));var C=I.length,y=!1;if(!C)return this.resolve([]);for(var E=new Array(C),B=0,Q=-1,b=new this(a);++Q<C;)D(I[Q],Q);return b;function D(T,N){f.resolve(T).then(function(H){E[N]=H,++B!==C||y||(y=!0,A.resolve(b,E))},function(H){y||(y=!0,A.reject(b,H))})}},u.race=function(I){var f=this;if(Object.prototype.toString.call(I)!=="[object Array]")return this.reject(new TypeError("must be an array"));var C=I.length,y=!1;if(!C)return this.resolve([]);for(var E=-1,B=new this(a);++E<C;)Q=I[E],f.resolve(Q).then(function(b){y||(y=!0,A.resolve(B,b))},function(b){y||(y=!0,A.reject(B,b))});var Q;return B}},{immediate:36}],38:[function(o,i,r){var s={};(0,o("./lib/utils/common").assign)(s,o("./lib/deflate"),o("./lib/inflate"),o("./lib/zlib/constants")),i.exports=s},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(o,i,r){var s=o("./zlib/deflate"),a=o("./utils/common"),A=o("./utils/strings"),c=o("./zlib/messages"),l=o("./zlib/zstream"),g=Object.prototype.toString,u=0,h=-1,d=0,_=8;function p(I){if(!(this instanceof p))return new p(I);this.options=a.assign({level:h,method:_,chunkSize:16384,windowBits:15,memLevel:8,strategy:d,to:""},I||{});var f=this.options;f.raw&&0<f.windowBits?f.windowBits=-f.windowBits:f.gzip&&0<f.windowBits&&f.windowBits<16&&(f.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new l,this.strm.avail_out=0;var C=s.deflateInit2(this.strm,f.level,f.method,f.windowBits,f.memLevel,f.strategy);if(C!==u)throw new Error(c[C]);if(f.header&&s.deflateSetHeader(this.strm,f.header),f.dictionary){var y;if(y=typeof f.dictionary=="string"?A.string2buf(f.dictionary):g.call(f.dictionary)==="[object ArrayBuffer]"?new Uint8Array(f.dictionary):f.dictionary,(C=s.deflateSetDictionary(this.strm,y))!==u)throw new Error(c[C]);this._dict_set=!0}}function m(I,f){var C=new p(f);if(C.push(I,!0),C.err)throw C.msg||c[C.err];return C.result}p.prototype.push=function(I,f){var C,y,E=this.strm,B=this.options.chunkSize;if(this.ended)return!1;y=f===~~f?f:f===!0?4:0,typeof I=="string"?E.input=A.string2buf(I):g.call(I)==="[object ArrayBuffer]"?E.input=new Uint8Array(I):E.input=I,E.next_in=0,E.avail_in=E.input.length;do{if(E.avail_out===0&&(E.output=new a.Buf8(B),E.next_out=0,E.avail_out=B),(C=s.deflate(E,y))!==1&&C!==u)return this.onEnd(C),!(this.ended=!0);E.avail_out!==0&&(E.avail_in!==0||y!==4&&y!==2)||(this.options.to==="string"?this.onData(A.buf2binstring(a.shrinkBuf(E.output,E.next_out))):this.onData(a.shrinkBuf(E.output,E.next_out)))}while((0<E.avail_in||E.avail_out===0)&&C!==1);return y===4?(C=s.deflateEnd(this.strm),this.onEnd(C),this.ended=!0,C===u):y!==2||(this.onEnd(u),!(E.avail_out=0))},p.prototype.onData=function(I){this.chunks.push(I)},p.prototype.onEnd=function(I){I===u&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=a.flattenChunks(this.chunks)),this.chunks=[],this.err=I,this.msg=this.strm.msg},r.Deflate=p,r.deflate=m,r.deflateRaw=function(I,f){return(f=f||{}).raw=!0,m(I,f)},r.gzip=function(I,f){return(f=f||{}).gzip=!0,m(I,f)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(o,i,r){var s=o("./zlib/inflate"),a=o("./utils/common"),A=o("./utils/strings"),c=o("./zlib/constants"),l=o("./zlib/messages"),g=o("./zlib/zstream"),u=o("./zlib/gzheader"),h=Object.prototype.toString;function d(p){if(!(this instanceof d))return new d(p);this.options=a.assign({chunkSize:16384,windowBits:0,to:""},p||{});var m=this.options;m.raw&&0<=m.windowBits&&m.windowBits<16&&(m.windowBits=-m.windowBits,m.windowBits===0&&(m.windowBits=-15)),!(0<=m.windowBits&&m.windowBits<16)||p&&p.windowBits||(m.windowBits+=32),15<m.windowBits&&m.windowBits<48&&(15&m.windowBits)==0&&(m.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new g,this.strm.avail_out=0;var I=s.inflateInit2(this.strm,m.windowBits);if(I!==c.Z_OK)throw new Error(l[I]);this.header=new u,s.inflateGetHeader(this.strm,this.header)}function _(p,m){var I=new d(m);if(I.push(p,!0),I.err)throw I.msg||l[I.err];return I.result}d.prototype.push=function(p,m){var I,f,C,y,E,B,Q=this.strm,b=this.options.chunkSize,D=this.options.dictionary,T=!1;if(this.ended)return!1;f=m===~~m?m:m===!0?c.Z_FINISH:c.Z_NO_FLUSH,typeof p=="string"?Q.input=A.binstring2buf(p):h.call(p)==="[object ArrayBuffer]"?Q.input=new Uint8Array(p):Q.input=p,Q.next_in=0,Q.avail_in=Q.input.length;do{if(Q.avail_out===0&&(Q.output=new a.Buf8(b),Q.next_out=0,Q.avail_out=b),(I=s.inflate(Q,c.Z_NO_FLUSH))===c.Z_NEED_DICT&&D&&(B=typeof D=="string"?A.string2buf(D):h.call(D)==="[object ArrayBuffer]"?new Uint8Array(D):D,I=s.inflateSetDictionary(this.strm,B)),I===c.Z_BUF_ERROR&&T===!0&&(I=c.Z_OK,T=!1),I!==c.Z_STREAM_END&&I!==c.Z_OK)return this.onEnd(I),!(this.ended=!0);Q.next_out&&(Q.avail_out!==0&&I!==c.Z_STREAM_END&&(Q.avail_in!==0||f!==c.Z_FINISH&&f!==c.Z_SYNC_FLUSH)||(this.options.to==="string"?(C=A.utf8border(Q.output,Q.next_out),y=Q.next_out-C,E=A.buf2string(Q.output,C),Q.next_out=y,Q.avail_out=b-y,y&&a.arraySet(Q.output,Q.output,C,y,0),this.onData(E)):this.onData(a.shrinkBuf(Q.output,Q.next_out)))),Q.avail_in===0&&Q.avail_out===0&&(T=!0)}while((0<Q.avail_in||Q.avail_out===0)&&I!==c.Z_STREAM_END);return I===c.Z_STREAM_END&&(f=c.Z_FINISH),f===c.Z_FINISH?(I=s.inflateEnd(this.strm),this.onEnd(I),this.ended=!0,I===c.Z_OK):f!==c.Z_SYNC_FLUSH||(this.onEnd(c.Z_OK),!(Q.avail_out=0))},d.prototype.onData=function(p){this.chunks.push(p)},d.prototype.onEnd=function(p){p===c.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=a.flattenChunks(this.chunks)),this.chunks=[],this.err=p,this.msg=this.strm.msg},r.Inflate=d,r.inflate=_,r.inflateRaw=function(p,m){return(m=m||{}).raw=!0,_(p,m)},r.ungzip=_},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(o,i,r){var s=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";r.assign=function(c){for(var l=Array.prototype.slice.call(arguments,1);l.length;){var g=l.shift();if(g){if(typeof g!="object")throw new TypeError(g+"must be non-object");for(var u in g)g.hasOwnProperty(u)&&(c[u]=g[u])}}return c},r.shrinkBuf=function(c,l){return c.length===l?c:c.subarray?c.subarray(0,l):(c.length=l,c)};var a={arraySet:function(c,l,g,u,h){if(l.subarray&&c.subarray)c.set(l.subarray(g,g+u),h);else for(var d=0;d<u;d++)c[h+d]=l[g+d]},flattenChunks:function(c){var l,g,u,h,d,_;for(l=u=0,g=c.length;l<g;l++)u+=c[l].length;for(_=new Uint8Array(u),l=h=0,g=c.length;l<g;l++)d=c[l],_.set(d,h),h+=d.length;return _}},A={arraySet:function(c,l,g,u,h){for(var d=0;d<u;d++)c[h+d]=l[g+d]},flattenChunks:function(c){return[].concat.apply([],c)}};r.setTyped=function(c){c?(r.Buf8=Uint8Array,r.Buf16=Uint16Array,r.Buf32=Int32Array,r.assign(r,a)):(r.Buf8=Array,r.Buf16=Array,r.Buf32=Array,r.assign(r,A))},r.setTyped(s)},{}],42:[function(o,i,r){var s=o("./common"),a=!0,A=!0;try{String.fromCharCode.apply(null,[0])}catch{a=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{A=!1}for(var c=new s.Buf8(256),l=0;l<256;l++)c[l]=252<=l?6:248<=l?5:240<=l?4:224<=l?3:192<=l?2:1;function g(u,h){if(h<65537&&(u.subarray&&A||!u.subarray&&a))return String.fromCharCode.apply(null,s.shrinkBuf(u,h));for(var d="",_=0;_<h;_++)d+=String.fromCharCode(u[_]);return d}c[254]=c[254]=1,r.string2buf=function(u){var h,d,_,p,m,I=u.length,f=0;for(p=0;p<I;p++)(64512&(d=u.charCodeAt(p)))==55296&&p+1<I&&(64512&(_=u.charCodeAt(p+1)))==56320&&(d=65536+(d-55296<<10)+(_-56320),p++),f+=d<128?1:d<2048?2:d<65536?3:4;for(h=new s.Buf8(f),p=m=0;m<f;p++)(64512&(d=u.charCodeAt(p)))==55296&&p+1<I&&(64512&(_=u.charCodeAt(p+1)))==56320&&(d=65536+(d-55296<<10)+(_-56320),p++),d<128?h[m++]=d:(d<2048?h[m++]=192|d>>>6:(d<65536?h[m++]=224|d>>>12:(h[m++]=240|d>>>18,h[m++]=128|d>>>12&63),h[m++]=128|d>>>6&63),h[m++]=128|63&d);return h},r.buf2binstring=function(u){return g(u,u.length)},r.binstring2buf=function(u){for(var h=new s.Buf8(u.length),d=0,_=h.length;d<_;d++)h[d]=u.charCodeAt(d);return h},r.buf2string=function(u,h){var d,_,p,m,I=h||u.length,f=new Array(2*I);for(d=_=0;d<I;)if((p=u[d++])<128)f[_++]=p;else if(4<(m=c[p]))f[_++]=65533,d+=m-1;else{for(p&=m===2?31:m===3?15:7;1<m&&d<I;)p=p<<6|63&u[d++],m--;1<m?f[_++]=65533:p<65536?f[_++]=p:(p-=65536,f[_++]=55296|p>>10&1023,f[_++]=56320|1023&p)}return g(f,_)},r.utf8border=function(u,h){var d;for((h=h||u.length)>u.length&&(h=u.length),d=h-1;0<=d&&(192&u[d])==128;)d--;return d<0||d===0?h:d+c[u[d]]>h?d:h}},{"./common":41}],43:[function(o,i,r){i.exports=function(s,a,A,c){for(var l=65535&s|0,g=s>>>16&65535|0,u=0;A!==0;){for(A-=u=2e3<A?2e3:A;g=g+(l=l+a[c++]|0)|0,--u;);l%=65521,g%=65521}return l|g<<16|0}},{}],44:[function(o,i,r){i.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(o,i,r){var s=(function(){for(var a,A=[],c=0;c<256;c++){a=c;for(var l=0;l<8;l++)a=1&a?3988292384^a>>>1:a>>>1;A[c]=a}return A})();i.exports=function(a,A,c,l){var g=s,u=l+c;a^=-1;for(var h=l;h<u;h++)a=a>>>8^g[255&(a^A[h])];return-1^a}},{}],46:[function(o,i,r){var s,a=o("../utils/common"),A=o("./trees"),c=o("./adler32"),l=o("./crc32"),g=o("./messages"),u=0,h=4,d=0,_=-2,p=-1,m=4,I=2,f=8,C=9,y=286,E=30,B=19,Q=2*y+1,b=15,D=3,T=258,N=T+D+1,H=42,G=113,O=1,U=2,W=3,j=4;function ne(Ie,ze){return Ie.msg=g[ze],ze}function re(Ie){return(Ie<<1)-(4<Ie?9:0)}function X(Ie){for(var ze=Ie.length;0<=--ze;)Ie[ze]=0}function Z(Ie){var ze=Ie.state,Re=ze.pending;Re>Ie.avail_out&&(Re=Ie.avail_out),Re!==0&&(a.arraySet(Ie.output,ze.pending_buf,ze.pending_out,Re,Ie.next_out),Ie.next_out+=Re,ze.pending_out+=Re,Ie.total_out+=Re,Ie.avail_out-=Re,ze.pending-=Re,ze.pending===0&&(ze.pending_out=0))}function se(Ie,ze){A._tr_flush_block(Ie,0<=Ie.block_start?Ie.block_start:-1,Ie.strstart-Ie.block_start,ze),Ie.block_start=Ie.strstart,Z(Ie.strm)}function ae(Ie,ze){Ie.pending_buf[Ie.pending++]=ze}function le(Ie,ze){Ie.pending_buf[Ie.pending++]=ze>>>8&255,Ie.pending_buf[Ie.pending++]=255&ze}function fe(Ie,ze){var Re,Le,Ve=Ie.max_chain_length,ke=Ie.strstart,De=Ie.prev_length,Ue=Ie.nice_match,Pe=Ie.strstart>Ie.w_size-N?Ie.strstart-(Ie.w_size-N):0,We=Ie.window,et=Ie.w_mask,At=Ie.prev,gt=Ie.strstart+T,_t=We[ke+De-1],dt=We[ke+De];Ie.prev_length>=Ie.good_match&&(Ve>>=2),Ue>Ie.lookahead&&(Ue=Ie.lookahead);do if(We[(Re=ze)+De]===dt&&We[Re+De-1]===_t&&We[Re]===We[ke]&&We[++Re]===We[ke+1]){ke+=2,Re++;do;while(We[++ke]===We[++Re]&&We[++ke]===We[++Re]&&We[++ke]===We[++Re]&&We[++ke]===We[++Re]&&We[++ke]===We[++Re]&&We[++ke]===We[++Re]&&We[++ke]===We[++Re]&&We[++ke]===We[++Re]&&ke<gt);if(Le=T-(gt-ke),ke=gt-T,De<Le){if(Ie.match_start=ze,Ue<=(De=Le))break;_t=We[ke+De-1],dt=We[ke+De]}}while((ze=At[ze&et])>Pe&&--Ve!=0);return De<=Ie.lookahead?De:Ie.lookahead}function Ce(Ie){var ze,Re,Le,Ve,ke,De,Ue,Pe,We,et,At=Ie.w_size;do{if(Ve=Ie.window_size-Ie.lookahead-Ie.strstart,Ie.strstart>=At+(At-N)){for(a.arraySet(Ie.window,Ie.window,At,At,0),Ie.match_start-=At,Ie.strstart-=At,Ie.block_start-=At,ze=Re=Ie.hash_size;Le=Ie.head[--ze],Ie.head[ze]=At<=Le?Le-At:0,--Re;);for(ze=Re=At;Le=Ie.prev[--ze],Ie.prev[ze]=At<=Le?Le-At:0,--Re;);Ve+=At}if(Ie.strm.avail_in===0)break;if(De=Ie.strm,Ue=Ie.window,Pe=Ie.strstart+Ie.lookahead,We=Ve,et=void 0,et=De.avail_in,We<et&&(et=We),Re=et===0?0:(De.avail_in-=et,a.arraySet(Ue,De.input,De.next_in,et,Pe),De.state.wrap===1?De.adler=c(De.adler,Ue,et,Pe):De.state.wrap===2&&(De.adler=l(De.adler,Ue,et,Pe)),De.next_in+=et,De.total_in+=et,et),Ie.lookahead+=Re,Ie.lookahead+Ie.insert>=D)for(ke=Ie.strstart-Ie.insert,Ie.ins_h=Ie.window[ke],Ie.ins_h=(Ie.ins_h<<Ie.hash_shift^Ie.window[ke+1])&Ie.hash_mask;Ie.insert&&(Ie.ins_h=(Ie.ins_h<<Ie.hash_shift^Ie.window[ke+D-1])&Ie.hash_mask,Ie.prev[ke&Ie.w_mask]=Ie.head[Ie.ins_h],Ie.head[Ie.ins_h]=ke,ke++,Ie.insert--,!(Ie.lookahead+Ie.insert<D)););}while(Ie.lookahead<N&&Ie.strm.avail_in!==0)}function Ee(Ie,ze){for(var Re,Le;;){if(Ie.lookahead<N){if(Ce(Ie),Ie.lookahead<N&&ze===u)return O;if(Ie.lookahead===0)break}if(Re=0,Ie.lookahead>=D&&(Ie.ins_h=(Ie.ins_h<<Ie.hash_shift^Ie.window[Ie.strstart+D-1])&Ie.hash_mask,Re=Ie.prev[Ie.strstart&Ie.w_mask]=Ie.head[Ie.ins_h],Ie.head[Ie.ins_h]=Ie.strstart),Re!==0&&Ie.strstart-Re<=Ie.w_size-N&&(Ie.match_length=fe(Ie,Re)),Ie.match_length>=D)if(Le=A._tr_tally(Ie,Ie.strstart-Ie.match_start,Ie.match_length-D),Ie.lookahead-=Ie.match_length,Ie.match_length<=Ie.max_lazy_match&&Ie.lookahead>=D){for(Ie.match_length--;Ie.strstart++,Ie.ins_h=(Ie.ins_h<<Ie.hash_shift^Ie.window[Ie.strstart+D-1])&Ie.hash_mask,Re=Ie.prev[Ie.strstart&Ie.w_mask]=Ie.head[Ie.ins_h],Ie.head[Ie.ins_h]=Ie.strstart,--Ie.match_length!=0;);Ie.strstart++}else Ie.strstart+=Ie.match_length,Ie.match_length=0,Ie.ins_h=Ie.window[Ie.strstart],Ie.ins_h=(Ie.ins_h<<Ie.hash_shift^Ie.window[Ie.strstart+1])&Ie.hash_mask;else Le=A._tr_tally(Ie,0,Ie.window[Ie.strstart]),Ie.lookahead--,Ie.strstart++;if(Le&&(se(Ie,!1),Ie.strm.avail_out===0))return O}return Ie.insert=Ie.strstart<D-1?Ie.strstart:D-1,ze===h?(se(Ie,!0),Ie.strm.avail_out===0?W:j):Ie.last_lit&&(se(Ie,!1),Ie.strm.avail_out===0)?O:U}function de(Ie,ze){for(var Re,Le,Ve;;){if(Ie.lookahead<N){if(Ce(Ie),Ie.lookahead<N&&ze===u)return O;if(Ie.lookahead===0)break}if(Re=0,Ie.lookahead>=D&&(Ie.ins_h=(Ie.ins_h<<Ie.hash_shift^Ie.window[Ie.strstart+D-1])&Ie.hash_mask,Re=Ie.prev[Ie.strstart&Ie.w_mask]=Ie.head[Ie.ins_h],Ie.head[Ie.ins_h]=Ie.strstart),Ie.prev_length=Ie.match_length,Ie.prev_match=Ie.match_start,Ie.match_length=D-1,Re!==0&&Ie.prev_length<Ie.max_lazy_match&&Ie.strstart-Re<=Ie.w_size-N&&(Ie.match_length=fe(Ie,Re),Ie.match_length<=5&&(Ie.strategy===1||Ie.match_length===D&&4096<Ie.strstart-Ie.match_start)&&(Ie.match_length=D-1)),Ie.prev_length>=D&&Ie.match_length<=Ie.prev_length){for(Ve=Ie.strstart+Ie.lookahead-D,Le=A._tr_tally(Ie,Ie.strstart-1-Ie.prev_match,Ie.prev_length-D),Ie.lookahead-=Ie.prev_length-1,Ie.prev_length-=2;++Ie.strstart<=Ve&&(Ie.ins_h=(Ie.ins_h<<Ie.hash_shift^Ie.window[Ie.strstart+D-1])&Ie.hash_mask,Re=Ie.prev[Ie.strstart&Ie.w_mask]=Ie.head[Ie.ins_h],Ie.head[Ie.ins_h]=Ie.strstart),--Ie.prev_length!=0;);if(Ie.match_available=0,Ie.match_length=D-1,Ie.strstart++,Le&&(se(Ie,!1),Ie.strm.avail_out===0))return O}else if(Ie.match_available){if((Le=A._tr_tally(Ie,0,Ie.window[Ie.strstart-1]))&&se(Ie,!1),Ie.strstart++,Ie.lookahead--,Ie.strm.avail_out===0)return O}else Ie.match_available=1,Ie.strstart++,Ie.lookahead--}return Ie.match_available&&(Le=A._tr_tally(Ie,0,Ie.window[Ie.strstart-1]),Ie.match_available=0),Ie.insert=Ie.strstart<D-1?Ie.strstart:D-1,ze===h?(se(Ie,!0),Ie.strm.avail_out===0?W:j):Ie.last_lit&&(se(Ie,!1),Ie.strm.avail_out===0)?O:U}function xe(Ie,ze,Re,Le,Ve){this.good_length=Ie,this.max_lazy=ze,this.nice_length=Re,this.max_chain=Le,this.func=Ve}function _e(){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=f,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*Q),this.dyn_dtree=new a.Buf16(2*(2*E+1)),this.bl_tree=new a.Buf16(2*(2*B+1)),X(this.dyn_ltree),X(this.dyn_dtree),X(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new a.Buf16(b+1),this.heap=new a.Buf16(2*y+1),X(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new a.Buf16(2*y+1),X(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 Ne(Ie){var ze;return Ie&&Ie.state?(Ie.total_in=Ie.total_out=0,Ie.data_type=I,(ze=Ie.state).pending=0,ze.pending_out=0,ze.wrap<0&&(ze.wrap=-ze.wrap),ze.status=ze.wrap?H:G,Ie.adler=ze.wrap===2?0:1,ze.last_flush=u,A._tr_init(ze),d):ne(Ie,_)}function Oe(Ie){var ze=Ne(Ie);return ze===d&&(function(Re){Re.window_size=2*Re.w_size,X(Re.head),Re.max_lazy_match=s[Re.level].max_lazy,Re.good_match=s[Re.level].good_length,Re.nice_match=s[Re.level].nice_length,Re.max_chain_length=s[Re.level].max_chain,Re.strstart=0,Re.block_start=0,Re.lookahead=0,Re.insert=0,Re.match_length=Re.prev_length=D-1,Re.match_available=0,Re.ins_h=0})(Ie.state),ze}function Je(Ie,ze,Re,Le,Ve,ke){if(!Ie)return _;var De=1;if(ze===p&&(ze=6),Le<0?(De=0,Le=-Le):15<Le&&(De=2,Le-=16),Ve<1||C<Ve||Re!==f||Le<8||15<Le||ze<0||9<ze||ke<0||m<ke)return ne(Ie,_);Le===8&&(Le=9);var Ue=new _e;return(Ie.state=Ue).strm=Ie,Ue.wrap=De,Ue.gzhead=null,Ue.w_bits=Le,Ue.w_size=1<<Ue.w_bits,Ue.w_mask=Ue.w_size-1,Ue.hash_bits=Ve+7,Ue.hash_size=1<<Ue.hash_bits,Ue.hash_mask=Ue.hash_size-1,Ue.hash_shift=~~((Ue.hash_bits+D-1)/D),Ue.window=new a.Buf8(2*Ue.w_size),Ue.head=new a.Buf16(Ue.hash_size),Ue.prev=new a.Buf16(Ue.w_size),Ue.lit_bufsize=1<<Ve+6,Ue.pending_buf_size=4*Ue.lit_bufsize,Ue.pending_buf=new a.Buf8(Ue.pending_buf_size),Ue.d_buf=1*Ue.lit_bufsize,Ue.l_buf=3*Ue.lit_bufsize,Ue.level=ze,Ue.strategy=ke,Ue.method=Re,Oe(Ie)}s=[new xe(0,0,0,0,function(Ie,ze){var Re=65535;for(Re>Ie.pending_buf_size-5&&(Re=Ie.pending_buf_size-5);;){if(Ie.lookahead<=1){if(Ce(Ie),Ie.lookahead===0&&ze===u)return O;if(Ie.lookahead===0)break}Ie.strstart+=Ie.lookahead,Ie.lookahead=0;var Le=Ie.block_start+Re;if((Ie.strstart===0||Ie.strstart>=Le)&&(Ie.lookahead=Ie.strstart-Le,Ie.strstart=Le,se(Ie,!1),Ie.strm.avail_out===0)||Ie.strstart-Ie.block_start>=Ie.w_size-N&&(se(Ie,!1),Ie.strm.avail_out===0))return O}return Ie.insert=0,ze===h?(se(Ie,!0),Ie.strm.avail_out===0?W:j):(Ie.strstart>Ie.block_start&&(se(Ie,!1),Ie.strm.avail_out),O)}),new xe(4,4,8,4,Ee),new xe(4,5,16,8,Ee),new xe(4,6,32,32,Ee),new xe(4,4,16,16,de),new xe(8,16,32,32,de),new xe(8,16,128,128,de),new xe(8,32,128,256,de),new xe(32,128,258,1024,de),new xe(32,258,258,4096,de)],r.deflateInit=function(Ie,ze){return Je(Ie,ze,f,15,8,0)},r.deflateInit2=Je,r.deflateReset=Oe,r.deflateResetKeep=Ne,r.deflateSetHeader=function(Ie,ze){return Ie&&Ie.state?Ie.state.wrap!==2?_:(Ie.state.gzhead=ze,d):_},r.deflate=function(Ie,ze){var Re,Le,Ve,ke;if(!Ie||!Ie.state||5<ze||ze<0)return Ie?ne(Ie,_):_;if(Le=Ie.state,!Ie.output||!Ie.input&&Ie.avail_in!==0||Le.status===666&&ze!==h)return ne(Ie,Ie.avail_out===0?-5:_);if(Le.strm=Ie,Re=Le.last_flush,Le.last_flush=ze,Le.status===H)if(Le.wrap===2)Ie.adler=0,ae(Le,31),ae(Le,139),ae(Le,8),Le.gzhead?(ae(Le,(Le.gzhead.text?1:0)+(Le.gzhead.hcrc?2:0)+(Le.gzhead.extra?4:0)+(Le.gzhead.name?8:0)+(Le.gzhead.comment?16:0)),ae(Le,255&Le.gzhead.time),ae(Le,Le.gzhead.time>>8&255),ae(Le,Le.gzhead.time>>16&255),ae(Le,Le.gzhead.time>>24&255),ae(Le,Le.level===9?2:2<=Le.strategy||Le.level<2?4:0),ae(Le,255&Le.gzhead.os),Le.gzhead.extra&&Le.gzhead.extra.length&&(ae(Le,255&Le.gzhead.extra.length),ae(Le,Le.gzhead.extra.length>>8&255)),Le.gzhead.hcrc&&(Ie.adler=l(Ie.adler,Le.pending_buf,Le.pending,0)),Le.gzindex=0,Le.status=69):(ae(Le,0),ae(Le,0),ae(Le,0),ae(Le,0),ae(Le,0),ae(Le,Le.level===9?2:2<=Le.strategy||Le.level<2?4:0),ae(Le,3),Le.status=G);else{var De=f+(Le.w_bits-8<<4)<<8;De|=(2<=Le.strategy||Le.level<2?0:Le.level<6?1:Le.level===6?2:3)<<6,Le.strstart!==0&&(De|=32),De+=31-De%31,Le.status=G,le(Le,De),Le.strstart!==0&&(le(Le,Ie.adler>>>16),le(Le,65535&Ie.adler)),Ie.adler=1}if(Le.status===69)if(Le.gzhead.extra){for(Ve=Le.pending;Le.gzindex<(65535&Le.gzhead.extra.length)&&(Le.pending!==Le.pending_buf_size||(Le.gzhead.hcrc&&Le.pending>Ve&&(Ie.adler=l(Ie.adler,Le.pending_buf,Le.pending-Ve,Ve)),Z(Ie),Ve=Le.pending,Le.pending!==Le.pending_buf_size));)ae(Le,255&Le.gzhead.extra[Le.gzindex]),Le.gzindex++;Le.gzhead.hcrc&&Le.pending>Ve&&(Ie.adler=l(Ie.adler,Le.pending_buf,Le.pending-Ve,Ve)),Le.gzindex===Le.gzhead.extra.length&&(Le.gzindex=0,Le.status=73)}else Le.status=73;if(Le.status===73)if(Le.gzhead.name){Ve=Le.pending;do{if(Le.pending===Le.pending_buf_size&&(Le.gzhead.hcrc&&Le.pending>Ve&&(Ie.adler=l(Ie.adler,Le.pending_buf,Le.pending-Ve,Ve)),Z(Ie),Ve=Le.pending,Le.pending===Le.pending_buf_size)){ke=1;break}ke=Le.gzindex<Le.gzhead.name.length?255&Le.gzhead.name.charCodeAt(Le.gzindex++):0,ae(Le,ke)}while(ke!==0);Le.gzhead.hcrc&&Le.pending>Ve&&(Ie.adler=l(Ie.adler,Le.pending_buf,Le.pending-Ve,Ve)),ke===0&&(Le.gzindex=0,Le.status=91)}else Le.status=91;if(Le.status===91)if(Le.gzhead.comment){Ve=Le.pending;do{if(Le.pending===Le.pending_buf_size&&(Le.gzhead.hcrc&&Le.pending>Ve&&(Ie.adler=l(Ie.adler,Le.pending_buf,Le.pending-Ve,Ve)),Z(Ie),Ve=Le.pending,Le.pending===Le.pending_buf_size)){ke=1;break}ke=Le.gzindex<Le.gzhead.comment.length?255&Le.gzhead.comment.charCodeAt(Le.gzindex++):0,ae(Le,ke)}while(ke!==0);Le.gzhead.hcrc&&Le.pending>Ve&&(Ie.adler=l(Ie.adler,Le.pending_buf,Le.pending-Ve,Ve)),ke===0&&(Le.status=103)}else Le.status=103;if(Le.status===103&&(Le.gzhead.hcrc?(Le.pending+2>Le.pending_buf_size&&Z(Ie),Le.pending+2<=Le.pending_buf_size&&(ae(Le,255&Ie.adler),ae(Le,Ie.adler>>8&255),Ie.adler=0,Le.status=G)):Le.status=G),Le.pending!==0){if(Z(Ie),Ie.avail_out===0)return Le.last_flush=-1,d}else if(Ie.avail_in===0&&re(ze)<=re(Re)&&ze!==h)return ne(Ie,-5);if(Le.status===666&&Ie.avail_in!==0)return ne(Ie,-5);if(Ie.avail_in!==0||Le.lookahead!==0||ze!==u&&Le.status!==666){var Ue=Le.strategy===2?(function(Pe,We){for(var et;;){if(Pe.lookahead===0&&(Ce(Pe),Pe.lookahead===0)){if(We===u)return O;break}if(Pe.match_length=0,et=A._tr_tally(Pe,0,Pe.window[Pe.strstart]),Pe.lookahead--,Pe.strstart++,et&&(se(Pe,!1),Pe.strm.avail_out===0))return O}return Pe.insert=0,We===h?(se(Pe,!0),Pe.strm.avail_out===0?W:j):Pe.last_lit&&(se(Pe,!1),Pe.strm.avail_out===0)?O:U})(Le,ze):Le.strategy===3?(function(Pe,We){for(var et,At,gt,_t,dt=Pe.window;;){if(Pe.lookahead<=T){if(Ce(Pe),Pe.lookahead<=T&&We===u)return O;if(Pe.lookahead===0)break}if(Pe.match_length=0,Pe.lookahead>=D&&0<Pe.strstart&&(At=dt[gt=Pe.strstart-1])===dt[++gt]&&At===dt[++gt]&&At===dt[++gt]){_t=Pe.strstart+T;do;while(At===dt[++gt]&&At===dt[++gt]&&At===dt[++gt]&&At===dt[++gt]&&At===dt[++gt]&&At===dt[++gt]&&At===dt[++gt]&&At===dt[++gt]&&gt<_t);Pe.match_length=T-(_t-gt),Pe.match_length>Pe.lookahead&&(Pe.match_length=Pe.lookahead)}if(Pe.match_length>=D?(et=A._tr_tally(Pe,1,Pe.match_length-D),Pe.lookahead-=Pe.match_length,Pe.strstart+=Pe.match_length,Pe.match_length=0):(et=A._tr_tally(Pe,0,Pe.window[Pe.strstart]),Pe.lookahead--,Pe.strstart++),et&&(se(Pe,!1),Pe.strm.avail_out===0))return O}return Pe.insert=0,We===h?(se(Pe,!0),Pe.strm.avail_out===0?W:j):Pe.last_lit&&(se(Pe,!1),Pe.strm.avail_out===0)?O:U})(Le,ze):s[Le.level].func(Le,ze);if(Ue!==W&&Ue!==j||(Le.status=666),Ue===O||Ue===W)return Ie.avail_out===0&&(Le.last_flush=-1),d;if(Ue===U&&(ze===1?A._tr_align(Le):ze!==5&&(A._tr_stored_block(Le,0,0,!1),ze===3&&(X(Le.head),Le.lookahead===0&&(Le.strstart=0,Le.block_start=0,Le.insert=0))),Z(Ie),Ie.avail_out===0))return Le.last_flush=-1,d}return ze!==h?d:Le.wrap<=0?1:(Le.wrap===2?(ae(Le,255&Ie.adler),ae(Le,Ie.adler>>8&255),ae(Le,Ie.adler>>16&255),ae(Le,Ie.adler>>24&255),ae(Le,255&Ie.total_in),ae(Le,Ie.total_in>>8&255),ae(Le,Ie.total_in>>16&255),ae(Le,Ie.total_in>>24&255)):(le(Le,Ie.adler>>>16),le(Le,65535&Ie.adler)),Z(Ie),0<Le.wrap&&(Le.wrap=-Le.wrap),Le.pending!==0?d:1)},r.deflateEnd=function(Ie){var ze;return Ie&&Ie.state?(ze=Ie.state.status)!==H&&ze!==69&&ze!==73&&ze!==91&&ze!==103&&ze!==G&&ze!==666?ne(Ie,_):(Ie.state=null,ze===G?ne(Ie,-3):d):_},r.deflateSetDictionary=function(Ie,ze){var Re,Le,Ve,ke,De,Ue,Pe,We,et=ze.length;if(!Ie||!Ie.state||(ke=(Re=Ie.state).wrap)===2||ke===1&&Re.status!==H||Re.lookahead)return _;for(ke===1&&(Ie.adler=c(Ie.adler,ze,et,0)),Re.wrap=0,et>=Re.w_size&&(ke===0&&(X(Re.head),Re.strstart=0,Re.block_start=0,Re.insert=0),We=new a.Buf8(Re.w_size),a.arraySet(We,ze,et-Re.w_size,Re.w_size,0),ze=We,et=Re.w_size),De=Ie.avail_in,Ue=Ie.next_in,Pe=Ie.input,Ie.avail_in=et,Ie.next_in=0,Ie.input=ze,Ce(Re);Re.lookahead>=D;){for(Le=Re.strstart,Ve=Re.lookahead-(D-1);Re.ins_h=(Re.ins_h<<Re.hash_shift^Re.window[Le+D-1])&Re.hash_mask,Re.prev[Le&Re.w_mask]=Re.head[Re.ins_h],Re.head[Re.ins_h]=Le,Le++,--Ve;);Re.strstart=Le,Re.lookahead=D-1,Ce(Re)}return Re.strstart+=Re.lookahead,Re.block_start=Re.strstart,Re.insert=Re.lookahead,Re.lookahead=0,Re.match_length=Re.prev_length=D-1,Re.match_available=0,Ie.next_in=Ue,Ie.input=Pe,Ie.avail_in=De,Re.wrap=ke,d},r.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(o,i,r){i.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(o,i,r){i.exports=function(s,a){var A,c,l,g,u,h,d,_,p,m,I,f,C,y,E,B,Q,b,D,T,N,H,G,O,U;A=s.state,c=s.next_in,O=s.input,l=c+(s.avail_in-5),g=s.next_out,U=s.output,u=g-(a-s.avail_out),h=g+(s.avail_out-257),d=A.dmax,_=A.wsize,p=A.whave,m=A.wnext,I=A.window,f=A.hold,C=A.bits,y=A.lencode,E=A.distcode,B=(1<<A.lenbits)-1,Q=(1<<A.distbits)-1;e:do{C<15&&(f+=O[c++]<<C,C+=8,f+=O[c++]<<C,C+=8),b=y[f&B];t:for(;;){if(f>>>=D=b>>>24,C-=D,(D=b>>>16&255)===0)U[g++]=65535&b;else{if(!(16&D)){if((64&D)==0){b=y[(65535&b)+(f&(1<<D)-1)];continue t}if(32&D){A.mode=12;break e}s.msg="invalid literal/length code",A.mode=30;break e}T=65535&b,(D&=15)&&(C<D&&(f+=O[c++]<<C,C+=8),T+=f&(1<<D)-1,f>>>=D,C-=D),C<15&&(f+=O[c++]<<C,C+=8,f+=O[c++]<<C,C+=8),b=E[f&Q];n:for(;;){if(f>>>=D=b>>>24,C-=D,!(16&(D=b>>>16&255))){if((64&D)==0){b=E[(65535&b)+(f&(1<<D)-1)];continue n}s.msg="invalid distance code",A.mode=30;break e}if(N=65535&b,C<(D&=15)&&(f+=O[c++]<<C,(C+=8)<D&&(f+=O[c++]<<C,C+=8)),d<(N+=f&(1<<D)-1)){s.msg="invalid distance too far back",A.mode=30;break e}if(f>>>=D,C-=D,(D=g-u)<N){if(p<(D=N-D)&&A.sane){s.msg="invalid distance too far back",A.mode=30;break e}if(G=I,(H=0)===m){if(H+=_-D,D<T){for(T-=D;U[g++]=I[H++],--D;);H=g-N,G=U}}else if(m<D){if(H+=_+m-D,(D-=m)<T){for(T-=D;U[g++]=I[H++],--D;);if(H=0,m<T){for(T-=D=m;U[g++]=I[H++],--D;);H=g-N,G=U}}}else if(H+=m-D,D<T){for(T-=D;U[g++]=I[H++],--D;);H=g-N,G=U}for(;2<T;)U[g++]=G[H++],U[g++]=G[H++],U[g++]=G[H++],T-=3;T&&(U[g++]=G[H++],1<T&&(U[g++]=G[H++]))}else{for(H=g-N;U[g++]=U[H++],U[g++]=U[H++],U[g++]=U[H++],2<(T-=3););T&&(U[g++]=U[H++],1<T&&(U[g++]=U[H++]))}break}}break}}while(c<l&&g<h);c-=T=C>>3,f&=(1<<(C-=T<<3))-1,s.next_in=c,s.next_out=g,s.avail_in=c<l?l-c+5:5-(c-l),s.avail_out=g<h?h-g+257:257-(g-h),A.hold=f,A.bits=C}},{}],49:[function(o,i,r){var s=o("../utils/common"),a=o("./adler32"),A=o("./crc32"),c=o("./inffast"),l=o("./inftrees"),g=1,u=2,h=0,d=-2,_=1,p=852,m=592;function I(H){return(H>>>24&255)+(H>>>8&65280)+((65280&H)<<8)+((255&H)<<24)}function f(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new s.Buf16(320),this.work=new s.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function C(H){var G;return H&&H.state?(G=H.state,H.total_in=H.total_out=G.total=0,H.msg="",G.wrap&&(H.adler=1&G.wrap),G.mode=_,G.last=0,G.havedict=0,G.dmax=32768,G.head=null,G.hold=0,G.bits=0,G.lencode=G.lendyn=new s.Buf32(p),G.distcode=G.distdyn=new s.Buf32(m),G.sane=1,G.back=-1,h):d}function y(H){var G;return H&&H.state?((G=H.state).wsize=0,G.whave=0,G.wnext=0,C(H)):d}function E(H,G){var O,U;return H&&H.state?(U=H.state,G<0?(O=0,G=-G):(O=1+(G>>4),G<48&&(G&=15)),G&&(G<8||15<G)?d:(U.window!==null&&U.wbits!==G&&(U.window=null),U.wrap=O,U.wbits=G,y(H))):d}function B(H,G){var O,U;return H?(U=new f,(H.state=U).window=null,(O=E(H,G))!==h&&(H.state=null),O):d}var Q,b,D=!0;function T(H){if(D){var G;for(Q=new s.Buf32(512),b=new s.Buf32(32),G=0;G<144;)H.lens[G++]=8;for(;G<256;)H.lens[G++]=9;for(;G<280;)H.lens[G++]=7;for(;G<288;)H.lens[G++]=8;for(l(g,H.lens,0,288,Q,0,H.work,{bits:9}),G=0;G<32;)H.lens[G++]=5;l(u,H.lens,0,32,b,0,H.work,{bits:5}),D=!1}H.lencode=Q,H.lenbits=9,H.distcode=b,H.distbits=5}function N(H,G,O,U){var W,j=H.state;return j.window===null&&(j.wsize=1<<j.wbits,j.wnext=0,j.whave=0,j.window=new s.Buf8(j.wsize)),U>=j.wsize?(s.arraySet(j.window,G,O-j.wsize,j.wsize,0),j.wnext=0,j.whave=j.wsize):(U<(W=j.wsize-j.wnext)&&(W=U),s.arraySet(j.window,G,O-U,W,j.wnext),(U-=W)?(s.arraySet(j.window,G,O-U,U,0),j.wnext=U,j.whave=j.wsize):(j.wnext+=W,j.wnext===j.wsize&&(j.wnext=0),j.whave<j.wsize&&(j.whave+=W))),0}r.inflateReset=y,r.inflateReset2=E,r.inflateResetKeep=C,r.inflateInit=function(H){return B(H,15)},r.inflateInit2=B,r.inflate=function(H,G){var O,U,W,j,ne,re,X,Z,se,ae,le,fe,Ce,Ee,de,xe,_e,Ne,Oe,Je,Ie,ze,Re,Le,Ve=0,ke=new s.Buf8(4),De=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!H||!H.state||!H.output||!H.input&&H.avail_in!==0)return d;(O=H.state).mode===12&&(O.mode=13),ne=H.next_out,W=H.output,X=H.avail_out,j=H.next_in,U=H.input,re=H.avail_in,Z=O.hold,se=O.bits,ae=re,le=X,ze=h;e:for(;;)switch(O.mode){case _:if(O.wrap===0){O.mode=13;break}for(;se<16;){if(re===0)break e;re--,Z+=U[j++]<<se,se+=8}if(2&O.wrap&&Z===35615){ke[O.check=0]=255&Z,ke[1]=Z>>>8&255,O.check=A(O.check,ke,2,0),se=Z=0,O.mode=2;break}if(O.flags=0,O.head&&(O.head.done=!1),!(1&O.wrap)||(((255&Z)<<8)+(Z>>8))%31){H.msg="incorrect header check",O.mode=30;break}if((15&Z)!=8){H.msg="unknown compression method",O.mode=30;break}if(se-=4,Ie=8+(15&(Z>>>=4)),O.wbits===0)O.wbits=Ie;else if(Ie>O.wbits){H.msg="invalid window size",O.mode=30;break}O.dmax=1<<Ie,H.adler=O.check=1,O.mode=512&Z?10:12,se=Z=0;break;case 2:for(;se<16;){if(re===0)break e;re--,Z+=U[j++]<<se,se+=8}if(O.flags=Z,(255&O.flags)!=8){H.msg="unknown compression method",O.mode=30;break}if(57344&O.flags){H.msg="unknown header flags set",O.mode=30;break}O.head&&(O.head.text=Z>>8&1),512&O.flags&&(ke[0]=255&Z,ke[1]=Z>>>8&255,O.check=A(O.check,ke,2,0)),se=Z=0,O.mode=3;case 3:for(;se<32;){if(re===0)break e;re--,Z+=U[j++]<<se,se+=8}O.head&&(O.head.time=Z),512&O.flags&&(ke[0]=255&Z,ke[1]=Z>>>8&255,ke[2]=Z>>>16&255,ke[3]=Z>>>24&255,O.check=A(O.check,ke,4,0)),se=Z=0,O.mode=4;case 4:for(;se<16;){if(re===0)break e;re--,Z+=U[j++]<<se,se+=8}O.head&&(O.head.xflags=255&Z,O.head.os=Z>>8),512&O.flags&&(ke[0]=255&Z,ke[1]=Z>>>8&255,O.check=A(O.check,ke,2,0)),se=Z=0,O.mode=5;case 5:if(1024&O.flags){for(;se<16;){if(re===0)break e;re--,Z+=U[j++]<<se,se+=8}O.length=Z,O.head&&(O.head.extra_len=Z),512&O.flags&&(ke[0]=255&Z,ke[1]=Z>>>8&255,O.check=A(O.check,ke,2,0)),se=Z=0}else O.head&&(O.head.extra=null);O.mode=6;case 6:if(1024&O.flags&&(re<(fe=O.length)&&(fe=re),fe&&(O.head&&(Ie=O.head.extra_len-O.length,O.head.extra||(O.head.extra=new Array(O.head.extra_len)),s.arraySet(O.head.extra,U,j,fe,Ie)),512&O.flags&&(O.check=A(O.check,U,fe,j)),re-=fe,j+=fe,O.length-=fe),O.length))break e;O.length=0,O.mode=7;case 7:if(2048&O.flags){if(re===0)break e;for(fe=0;Ie=U[j+fe++],O.head&&Ie&&O.length<65536&&(O.head.name+=String.fromCharCode(Ie)),Ie&&fe<re;);if(512&O.flags&&(O.check=A(O.check,U,fe,j)),re-=fe,j+=fe,Ie)break e}else O.head&&(O.head.name=null);O.length=0,O.mode=8;case 8:if(4096&O.flags){if(re===0)break e;for(fe=0;Ie=U[j+fe++],O.head&&Ie&&O.length<65536&&(O.head.comment+=String.fromCharCode(Ie)),Ie&&fe<re;);if(512&O.flags&&(O.check=A(O.check,U,fe,j)),re-=fe,j+=fe,Ie)break e}else O.head&&(O.head.comment=null);O.mode=9;case 9:if(512&O.flags){for(;se<16;){if(re===0)break e;re--,Z+=U[j++]<<se,se+=8}if(Z!==(65535&O.check)){H.msg="header crc mismatch",O.mode=30;break}se=Z=0}O.head&&(O.head.hcrc=O.flags>>9&1,O.head.done=!0),H.adler=O.check=0,O.mode=12;break;case 10:for(;se<32;){if(re===0)break e;re--,Z+=U[j++]<<se,se+=8}H.adler=O.check=I(Z),se=Z=0,O.mode=11;case 11:if(O.havedict===0)return H.next_out=ne,H.avail_out=X,H.next_in=j,H.avail_in=re,O.hold=Z,O.bits=se,2;H.adler=O.check=1,O.mode=12;case 12:if(G===5||G===6)break e;case 13:if(O.last){Z>>>=7&se,se-=7&se,O.mode=27;break}for(;se<3;){if(re===0)break e;re--,Z+=U[j++]<<se,se+=8}switch(O.last=1&Z,se-=1,3&(Z>>>=1)){case 0:O.mode=14;break;case 1:if(T(O),O.mode=20,G!==6)break;Z>>>=2,se-=2;break e;case 2:O.mode=17;break;case 3:H.msg="invalid block type",O.mode=30}Z>>>=2,se-=2;break;case 14:for(Z>>>=7&se,se-=7&se;se<32;){if(re===0)break e;re--,Z+=U[j++]<<se,se+=8}if((65535&Z)!=(Z>>>16^65535)){H.msg="invalid stored block lengths",O.mode=30;break}if(O.length=65535&Z,se=Z=0,O.mode=15,G===6)break e;case 15:O.mode=16;case 16:if(fe=O.length){if(re<fe&&(fe=re),X<fe&&(fe=X),fe===0)break e;s.arraySet(W,U,j,fe,ne),re-=fe,j+=fe,X-=fe,ne+=fe,O.length-=fe;break}O.mode=12;break;case 17:for(;se<14;){if(re===0)break e;re--,Z+=U[j++]<<se,se+=8}if(O.nlen=257+(31&Z),Z>>>=5,se-=5,O.ndist=1+(31&Z),Z>>>=5,se-=5,O.ncode=4+(15&Z),Z>>>=4,se-=4,286<O.nlen||30<O.ndist){H.msg="too many length or distance symbols",O.mode=30;break}O.have=0,O.mode=18;case 18:for(;O.have<O.ncode;){for(;se<3;){if(re===0)break e;re--,Z+=U[j++]<<se,se+=8}O.lens[De[O.have++]]=7&Z,Z>>>=3,se-=3}for(;O.have<19;)O.lens[De[O.have++]]=0;if(O.lencode=O.lendyn,O.lenbits=7,Re={bits:O.lenbits},ze=l(0,O.lens,0,19,O.lencode,0,O.work,Re),O.lenbits=Re.bits,ze){H.msg="invalid code lengths set",O.mode=30;break}O.have=0,O.mode=19;case 19:for(;O.have<O.nlen+O.ndist;){for(;xe=(Ve=O.lencode[Z&(1<<O.lenbits)-1])>>>16&255,_e=65535&Ve,!((de=Ve>>>24)<=se);){if(re===0)break e;re--,Z+=U[j++]<<se,se+=8}if(_e<16)Z>>>=de,se-=de,O.lens[O.have++]=_e;else{if(_e===16){for(Le=de+2;se<Le;){if(re===0)break e;re--,Z+=U[j++]<<se,se+=8}if(Z>>>=de,se-=de,O.have===0){H.msg="invalid bit length repeat",O.mode=30;break}Ie=O.lens[O.have-1],fe=3+(3&Z),Z>>>=2,se-=2}else if(_e===17){for(Le=de+3;se<Le;){if(re===0)break e;re--,Z+=U[j++]<<se,se+=8}se-=de,Ie=0,fe=3+(7&(Z>>>=de)),Z>>>=3,se-=3}else{for(Le=de+7;se<Le;){if(re===0)break e;re--,Z+=U[j++]<<se,se+=8}se-=de,Ie=0,fe=11+(127&(Z>>>=de)),Z>>>=7,se-=7}if(O.have+fe>O.nlen+O.ndist){H.msg="invalid bit length repeat",O.mode=30;break}for(;fe--;)O.lens[O.have++]=Ie}}if(O.mode===30)break;if(O.lens[256]===0){H.msg="invalid code -- missing end-of-block",O.mode=30;break}if(O.lenbits=9,Re={bits:O.lenbits},ze=l(g,O.lens,0,O.nlen,O.lencode,0,O.work,Re),O.lenbits=Re.bits,ze){H.msg="invalid literal/lengths set",O.mode=30;break}if(O.distbits=6,O.distcode=O.distdyn,Re={bits:O.distbits},ze=l(u,O.lens,O.nlen,O.ndist,O.distcode,0,O.work,Re),O.distbits=Re.bits,ze){H.msg="invalid distances set",O.mode=30;break}if(O.mode=20,G===6)break e;case 20:O.mode=21;case 21:if(6<=re&&258<=X){H.next_out=ne,H.avail_out=X,H.next_in=j,H.avail_in=re,O.hold=Z,O.bits=se,c(H,le),ne=H.next_out,W=H.output,X=H.avail_out,j=H.next_in,U=H.input,re=H.avail_in,Z=O.hold,se=O.bits,O.mode===12&&(O.back=-1);break}for(O.back=0;xe=(Ve=O.lencode[Z&(1<<O.lenbits)-1])>>>16&255,_e=65535&Ve,!((de=Ve>>>24)<=se);){if(re===0)break e;re--,Z+=U[j++]<<se,se+=8}if(xe&&(240&xe)==0){for(Ne=de,Oe=xe,Je=_e;xe=(Ve=O.lencode[Je+((Z&(1<<Ne+Oe)-1)>>Ne)])>>>16&255,_e=65535&Ve,!(Ne+(de=Ve>>>24)<=se);){if(re===0)break e;re--,Z+=U[j++]<<se,se+=8}Z>>>=Ne,se-=Ne,O.back+=Ne}if(Z>>>=de,se-=de,O.back+=de,O.length=_e,xe===0){O.mode=26;break}if(32&xe){O.back=-1,O.mode=12;break}if(64&xe){H.msg="invalid literal/length code",O.mode=30;break}O.extra=15&xe,O.mode=22;case 22:if(O.extra){for(Le=O.extra;se<Le;){if(re===0)break e;re--,Z+=U[j++]<<se,se+=8}O.length+=Z&(1<<O.extra)-1,Z>>>=O.extra,se-=O.extra,O.back+=O.extra}O.was=O.length,O.mode=23;case 23:for(;xe=(Ve=O.distcode[Z&(1<<O.distbits)-1])>>>16&255,_e=65535&Ve,!((de=Ve>>>24)<=se);){if(re===0)break e;re--,Z+=U[j++]<<se,se+=8}if((240&xe)==0){for(Ne=de,Oe=xe,Je=_e;xe=(Ve=O.distcode[Je+((Z&(1<<Ne+Oe)-1)>>Ne)])>>>16&255,_e=65535&Ve,!(Ne+(de=Ve>>>24)<=se);){if(re===0)break e;re--,Z+=U[j++]<<se,se+=8}Z>>>=Ne,se-=Ne,O.back+=Ne}if(Z>>>=de,se-=de,O.back+=de,64&xe){H.msg="invalid distance code",O.mode=30;break}O.offset=_e,O.extra=15&xe,O.mode=24;case 24:if(O.extra){for(Le=O.extra;se<Le;){if(re===0)break e;re--,Z+=U[j++]<<se,se+=8}O.offset+=Z&(1<<O.extra)-1,Z>>>=O.extra,se-=O.extra,O.back+=O.extra}if(O.offset>O.dmax){H.msg="invalid distance too far back",O.mode=30;break}O.mode=25;case 25:if(X===0)break e;if(fe=le-X,O.offset>fe){if((fe=O.offset-fe)>O.whave&&O.sane){H.msg="invalid distance too far back",O.mode=30;break}Ce=fe>O.wnext?(fe-=O.wnext,O.wsize-fe):O.wnext-fe,fe>O.length&&(fe=O.length),Ee=O.window}else Ee=W,Ce=ne-O.offset,fe=O.length;for(X<fe&&(fe=X),X-=fe,O.length-=fe;W[ne++]=Ee[Ce++],--fe;);O.length===0&&(O.mode=21);break;case 26:if(X===0)break e;W[ne++]=O.length,X--,O.mode=21;break;case 27:if(O.wrap){for(;se<32;){if(re===0)break e;re--,Z|=U[j++]<<se,se+=8}if(le-=X,H.total_out+=le,O.total+=le,le&&(H.adler=O.check=O.flags?A(O.check,W,le,ne-le):a(O.check,W,le,ne-le)),le=X,(O.flags?Z:I(Z))!==O.check){H.msg="incorrect data check",O.mode=30;break}se=Z=0}O.mode=28;case 28:if(O.wrap&&O.flags){for(;se<32;){if(re===0)break e;re--,Z+=U[j++]<<se,se+=8}if(Z!==(4294967295&O.total)){H.msg="incorrect length check",O.mode=30;break}se=Z=0}O.mode=29;case 29:ze=1;break e;case 30:ze=-3;break e;case 31:return-4;default:return d}return H.next_out=ne,H.avail_out=X,H.next_in=j,H.avail_in=re,O.hold=Z,O.bits=se,(O.wsize||le!==H.avail_out&&O.mode<30&&(O.mode<27||G!==4))&&N(H,H.output,H.next_out,le-H.avail_out)?(O.mode=31,-4):(ae-=H.avail_in,le-=H.avail_out,H.total_in+=ae,H.total_out+=le,O.total+=le,O.wrap&&le&&(H.adler=O.check=O.flags?A(O.check,W,le,H.next_out-le):a(O.check,W,le,H.next_out-le)),H.data_type=O.bits+(O.last?64:0)+(O.mode===12?128:0)+(O.mode===20||O.mode===15?256:0),(ae==0&&le===0||G===4)&&ze===h&&(ze=-5),ze)},r.inflateEnd=function(H){if(!H||!H.state)return d;var G=H.state;return G.window&&(G.window=null),H.state=null,h},r.inflateGetHeader=function(H,G){var O;return H&&H.state?(2&(O=H.state).wrap)==0?d:((O.head=G).done=!1,h):d},r.inflateSetDictionary=function(H,G){var O,U=G.length;return H&&H.state?(O=H.state).wrap!==0&&O.mode!==11?d:O.mode===11&&a(1,G,U,0)!==O.check?-3:N(H,G,U,U)?(O.mode=31,-4):(O.havedict=1,h):d},r.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(o,i,r){var s=o("../utils/common"),a=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],A=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],c=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],l=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];i.exports=function(g,u,h,d,_,p,m,I){var f,C,y,E,B,Q,b,D,T,N=I.bits,H=0,G=0,O=0,U=0,W=0,j=0,ne=0,re=0,X=0,Z=0,se=null,ae=0,le=new s.Buf16(16),fe=new s.Buf16(16),Ce=null,Ee=0;for(H=0;H<=15;H++)le[H]=0;for(G=0;G<d;G++)le[u[h+G]]++;for(W=N,U=15;1<=U&&le[U]===0;U--);if(U<W&&(W=U),U===0)return _[p++]=20971520,_[p++]=20971520,I.bits=1,0;for(O=1;O<U&&le[O]===0;O++);for(W<O&&(W=O),H=re=1;H<=15;H++)if(re<<=1,(re-=le[H])<0)return-1;if(0<re&&(g===0||U!==1))return-1;for(fe[1]=0,H=1;H<15;H++)fe[H+1]=fe[H]+le[H];for(G=0;G<d;G++)u[h+G]!==0&&(m[fe[u[h+G]]++]=G);if(Q=g===0?(se=Ce=m,19):g===1?(se=a,ae-=257,Ce=A,Ee-=257,256):(se=c,Ce=l,-1),H=O,B=p,ne=G=Z=0,y=-1,E=(X=1<<(j=W))-1,g===1&&852<X||g===2&&592<X)return 1;for(;;){for(b=H-ne,T=m[G]<Q?(D=0,m[G]):m[G]>Q?(D=Ce[Ee+m[G]],se[ae+m[G]]):(D=96,0),f=1<<H-ne,O=C=1<<j;_[B+(Z>>ne)+(C-=f)]=b<<24|D<<16|T|0,C!==0;);for(f=1<<H-1;Z&f;)f>>=1;if(f!==0?(Z&=f-1,Z+=f):Z=0,G++,--le[H]==0){if(H===U)break;H=u[h+m[G]]}if(W<H&&(Z&E)!==y){for(ne===0&&(ne=W),B+=O,re=1<<(j=H-ne);j+ne<U&&!((re-=le[j+ne])<=0);)j++,re<<=1;if(X+=1<<j,g===1&&852<X||g===2&&592<X)return 1;_[y=Z&E]=W<<24|j<<16|B-p|0}}return Z!==0&&(_[B+Z]=H-ne<<24|64<<16|0),I.bits=W,0}},{"../utils/common":41}],51:[function(o,i,r){i.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(o,i,r){var s=o("../utils/common"),a=0,A=1;function c(Ve){for(var ke=Ve.length;0<=--ke;)Ve[ke]=0}var l=0,g=29,u=256,h=u+1+g,d=30,_=19,p=2*h+1,m=15,I=16,f=7,C=256,y=16,E=17,B=18,Q=[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],b=[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],T=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],N=new Array(2*(h+2));c(N);var H=new Array(2*d);c(H);var G=new Array(512);c(G);var O=new Array(256);c(O);var U=new Array(g);c(U);var W,j,ne,re=new Array(d);function X(Ve,ke,De,Ue,Pe){this.static_tree=Ve,this.extra_bits=ke,this.extra_base=De,this.elems=Ue,this.max_length=Pe,this.has_stree=Ve&&Ve.length}function Z(Ve,ke){this.dyn_tree=Ve,this.max_code=0,this.stat_desc=ke}function se(Ve){return Ve<256?G[Ve]:G[256+(Ve>>>7)]}function ae(Ve,ke){Ve.pending_buf[Ve.pending++]=255&ke,Ve.pending_buf[Ve.pending++]=ke>>>8&255}function le(Ve,ke,De){Ve.bi_valid>I-De?(Ve.bi_buf|=ke<<Ve.bi_valid&65535,ae(Ve,Ve.bi_buf),Ve.bi_buf=ke>>I-Ve.bi_valid,Ve.bi_valid+=De-I):(Ve.bi_buf|=ke<<Ve.bi_valid&65535,Ve.bi_valid+=De)}function fe(Ve,ke,De){le(Ve,De[2*ke],De[2*ke+1])}function Ce(Ve,ke){for(var De=0;De|=1&Ve,Ve>>>=1,De<<=1,0<--ke;);return De>>>1}function Ee(Ve,ke,De){var Ue,Pe,We=new Array(m+1),et=0;for(Ue=1;Ue<=m;Ue++)We[Ue]=et=et+De[Ue-1]<<1;for(Pe=0;Pe<=ke;Pe++){var At=Ve[2*Pe+1];At!==0&&(Ve[2*Pe]=Ce(We[At]++,At))}}function de(Ve){var ke;for(ke=0;ke<h;ke++)Ve.dyn_ltree[2*ke]=0;for(ke=0;ke<d;ke++)Ve.dyn_dtree[2*ke]=0;for(ke=0;ke<_;ke++)Ve.bl_tree[2*ke]=0;Ve.dyn_ltree[2*C]=1,Ve.opt_len=Ve.static_len=0,Ve.last_lit=Ve.matches=0}function xe(Ve){8<Ve.bi_valid?ae(Ve,Ve.bi_buf):0<Ve.bi_valid&&(Ve.pending_buf[Ve.pending++]=Ve.bi_buf),Ve.bi_buf=0,Ve.bi_valid=0}function _e(Ve,ke,De,Ue){var Pe=2*ke,We=2*De;return Ve[Pe]<Ve[We]||Ve[Pe]===Ve[We]&&Ue[ke]<=Ue[De]}function Ne(Ve,ke,De){for(var Ue=Ve.heap[De],Pe=De<<1;Pe<=Ve.heap_len&&(Pe<Ve.heap_len&&_e(ke,Ve.heap[Pe+1],Ve.heap[Pe],Ve.depth)&&Pe++,!_e(ke,Ue,Ve.heap[Pe],Ve.depth));)Ve.heap[De]=Ve.heap[Pe],De=Pe,Pe<<=1;Ve.heap[De]=Ue}function Oe(Ve,ke,De){var Ue,Pe,We,et,At=0;if(Ve.last_lit!==0)for(;Ue=Ve.pending_buf[Ve.d_buf+2*At]<<8|Ve.pending_buf[Ve.d_buf+2*At+1],Pe=Ve.pending_buf[Ve.l_buf+At],At++,Ue===0?fe(Ve,Pe,ke):(fe(Ve,(We=O[Pe])+u+1,ke),(et=Q[We])!==0&&le(Ve,Pe-=U[We],et),fe(Ve,We=se(--Ue),De),(et=b[We])!==0&&le(Ve,Ue-=re[We],et)),At<Ve.last_lit;);fe(Ve,C,ke)}function Je(Ve,ke){var De,Ue,Pe,We=ke.dyn_tree,et=ke.stat_desc.static_tree,At=ke.stat_desc.has_stree,gt=ke.stat_desc.elems,_t=-1;for(Ve.heap_len=0,Ve.heap_max=p,De=0;De<gt;De++)We[2*De]!==0?(Ve.heap[++Ve.heap_len]=_t=De,Ve.depth[De]=0):We[2*De+1]=0;for(;Ve.heap_len<2;)We[2*(Pe=Ve.heap[++Ve.heap_len]=_t<2?++_t:0)]=1,Ve.depth[Pe]=0,Ve.opt_len--,At&&(Ve.static_len-=et[2*Pe+1]);for(ke.max_code=_t,De=Ve.heap_len>>1;1<=De;De--)Ne(Ve,We,De);for(Pe=gt;De=Ve.heap[1],Ve.heap[1]=Ve.heap[Ve.heap_len--],Ne(Ve,We,1),Ue=Ve.heap[1],Ve.heap[--Ve.heap_max]=De,Ve.heap[--Ve.heap_max]=Ue,We[2*Pe]=We[2*De]+We[2*Ue],Ve.depth[Pe]=(Ve.depth[De]>=Ve.depth[Ue]?Ve.depth[De]:Ve.depth[Ue])+1,We[2*De+1]=We[2*Ue+1]=Pe,Ve.heap[1]=Pe++,Ne(Ve,We,1),2<=Ve.heap_len;);Ve.heap[--Ve.heap_max]=Ve.heap[1],(function(dt,ot){var Qt,It,Pt,Ht,en,tn,zt=ot.dyn_tree,ye=ot.max_code,at=ot.stat_desc.static_tree,ut=ot.stat_desc.has_stree,pt=ot.stat_desc.extra_bits,Ft=ot.stat_desc.extra_base,Ot=ot.stat_desc.max_length,gn=0;for(Ht=0;Ht<=m;Ht++)dt.bl_count[Ht]=0;for(zt[2*dt.heap[dt.heap_max]+1]=0,Qt=dt.heap_max+1;Qt<p;Qt++)Ot<(Ht=zt[2*zt[2*(It=dt.heap[Qt])+1]+1]+1)&&(Ht=Ot,gn++),zt[2*It+1]=Ht,ye<It||(dt.bl_count[Ht]++,en=0,Ft<=It&&(en=pt[It-Ft]),tn=zt[2*It],dt.opt_len+=tn*(Ht+en),ut&&(dt.static_len+=tn*(at[2*It+1]+en)));if(gn!==0){do{for(Ht=Ot-1;dt.bl_count[Ht]===0;)Ht--;dt.bl_count[Ht]--,dt.bl_count[Ht+1]+=2,dt.bl_count[Ot]--,gn-=2}while(0<gn);for(Ht=Ot;Ht!==0;Ht--)for(It=dt.bl_count[Ht];It!==0;)ye<(Pt=dt.heap[--Qt])||(zt[2*Pt+1]!==Ht&&(dt.opt_len+=(Ht-zt[2*Pt+1])*zt[2*Pt],zt[2*Pt+1]=Ht),It--)}})(Ve,ke),Ee(We,_t,Ve.bl_count)}function Ie(Ve,ke,De){var Ue,Pe,We=-1,et=ke[1],At=0,gt=7,_t=4;for(et===0&&(gt=138,_t=3),ke[2*(De+1)+1]=65535,Ue=0;Ue<=De;Ue++)Pe=et,et=ke[2*(Ue+1)+1],++At<gt&&Pe===et||(At<_t?Ve.bl_tree[2*Pe]+=At:Pe!==0?(Pe!==We&&Ve.bl_tree[2*Pe]++,Ve.bl_tree[2*y]++):At<=10?Ve.bl_tree[2*E]++:Ve.bl_tree[2*B]++,We=Pe,_t=(At=0)===et?(gt=138,3):Pe===et?(gt=6,3):(gt=7,4))}function ze(Ve,ke,De){var Ue,Pe,We=-1,et=ke[1],At=0,gt=7,_t=4;for(et===0&&(gt=138,_t=3),Ue=0;Ue<=De;Ue++)if(Pe=et,et=ke[2*(Ue+1)+1],!(++At<gt&&Pe===et)){if(At<_t)for(;fe(Ve,Pe,Ve.bl_tree),--At!=0;);else Pe!==0?(Pe!==We&&(fe(Ve,Pe,Ve.bl_tree),At--),fe(Ve,y,Ve.bl_tree),le(Ve,At-3,2)):At<=10?(fe(Ve,E,Ve.bl_tree),le(Ve,At-3,3)):(fe(Ve,B,Ve.bl_tree),le(Ve,At-11,7));We=Pe,_t=(At=0)===et?(gt=138,3):Pe===et?(gt=6,3):(gt=7,4)}}c(re);var Re=!1;function Le(Ve,ke,De,Ue){le(Ve,(l<<1)+(Ue?1:0),3),(function(Pe,We,et,At){xe(Pe),ae(Pe,et),ae(Pe,~et),s.arraySet(Pe.pending_buf,Pe.window,We,et,Pe.pending),Pe.pending+=et})(Ve,ke,De)}r._tr_init=function(Ve){Re||((function(){var ke,De,Ue,Pe,We,et=new Array(m+1);for(Pe=Ue=0;Pe<g-1;Pe++)for(U[Pe]=Ue,ke=0;ke<1<<Q[Pe];ke++)O[Ue++]=Pe;for(O[Ue-1]=Pe,Pe=We=0;Pe<16;Pe++)for(re[Pe]=We,ke=0;ke<1<<b[Pe];ke++)G[We++]=Pe;for(We>>=7;Pe<d;Pe++)for(re[Pe]=We<<7,ke=0;ke<1<<b[Pe]-7;ke++)G[256+We++]=Pe;for(De=0;De<=m;De++)et[De]=0;for(ke=0;ke<=143;)N[2*ke+1]=8,ke++,et[8]++;for(;ke<=255;)N[2*ke+1]=9,ke++,et[9]++;for(;ke<=279;)N[2*ke+1]=7,ke++,et[7]++;for(;ke<=287;)N[2*ke+1]=8,ke++,et[8]++;for(Ee(N,h+1,et),ke=0;ke<d;ke++)H[2*ke+1]=5,H[2*ke]=Ce(ke,5);W=new X(N,Q,u+1,h,m),j=new X(H,b,0,d,m),ne=new X(new Array(0),D,0,_,f)})(),Re=!0),Ve.l_desc=new Z(Ve.dyn_ltree,W),Ve.d_desc=new Z(Ve.dyn_dtree,j),Ve.bl_desc=new Z(Ve.bl_tree,ne),Ve.bi_buf=0,Ve.bi_valid=0,de(Ve)},r._tr_stored_block=Le,r._tr_flush_block=function(Ve,ke,De,Ue){var Pe,We,et=0;0<Ve.level?(Ve.strm.data_type===2&&(Ve.strm.data_type=(function(At){var gt,_t=4093624447;for(gt=0;gt<=31;gt++,_t>>>=1)if(1&_t&&At.dyn_ltree[2*gt]!==0)return a;if(At.dyn_ltree[18]!==0||At.dyn_ltree[20]!==0||At.dyn_ltree[26]!==0)return A;for(gt=32;gt<u;gt++)if(At.dyn_ltree[2*gt]!==0)return A;return a})(Ve)),Je(Ve,Ve.l_desc),Je(Ve,Ve.d_desc),et=(function(At){var gt;for(Ie(At,At.dyn_ltree,At.l_desc.max_code),Ie(At,At.dyn_dtree,At.d_desc.max_code),Je(At,At.bl_desc),gt=_-1;3<=gt&&At.bl_tree[2*T[gt]+1]===0;gt--);return At.opt_len+=3*(gt+1)+5+5+4,gt})(Ve),Pe=Ve.opt_len+3+7>>>3,(We=Ve.static_len+3+7>>>3)<=Pe&&(Pe=We)):Pe=We=De+5,De+4<=Pe&&ke!==-1?Le(Ve,ke,De,Ue):Ve.strategy===4||We===Pe?(le(Ve,2+(Ue?1:0),3),Oe(Ve,N,H)):(le(Ve,4+(Ue?1:0),3),(function(At,gt,_t,dt){var ot;for(le(At,gt-257,5),le(At,_t-1,5),le(At,dt-4,4),ot=0;ot<dt;ot++)le(At,At.bl_tree[2*T[ot]+1],3);ze(At,At.dyn_ltree,gt-1),ze(At,At.dyn_dtree,_t-1)})(Ve,Ve.l_desc.max_code+1,Ve.d_desc.max_code+1,et+1),Oe(Ve,Ve.dyn_ltree,Ve.dyn_dtree)),de(Ve),Ue&&xe(Ve)},r._tr_tally=function(Ve,ke,De){return Ve.pending_buf[Ve.d_buf+2*Ve.last_lit]=ke>>>8&255,Ve.pending_buf[Ve.d_buf+2*Ve.last_lit+1]=255&ke,Ve.pending_buf[Ve.l_buf+Ve.last_lit]=255&De,Ve.last_lit++,ke===0?Ve.dyn_ltree[2*De]++:(Ve.matches++,ke--,Ve.dyn_ltree[2*(O[De]+u+1)]++,Ve.dyn_dtree[2*se(ke)]++),Ve.last_lit===Ve.lit_bufsize-1},r._tr_align=function(Ve){le(Ve,2,3),fe(Ve,C,N),(function(ke){ke.bi_valid===16?(ae(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)})(Ve)}},{"../utils/common":41}],53:[function(o,i,r){i.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(o,i,r){(function(s){(function(a,A){if(!a.setImmediate){var c,l,g,u,h=1,d={},_=!1,p=a.document,m=Object.getPrototypeOf&&Object.getPrototypeOf(a);m=m&&m.setTimeout?m:a,c={}.toString.call(a.process)==="[object process]"?function(y){n.nextTick(function(){f(y)})}:(function(){if(a.postMessage&&!a.importScripts){var y=!0,E=a.onmessage;return a.onmessage=function(){y=!1},a.postMessage("","*"),a.onmessage=E,y}})()?(u="setImmediate$"+Math.random()+"$",a.addEventListener?a.addEventListener("message",C,!1):a.attachEvent("onmessage",C),function(y){a.postMessage(u+y,"*")}):a.MessageChannel?((g=new MessageChannel).port1.onmessage=function(y){f(y.data)},function(y){g.port2.postMessage(y)}):p&&"onreadystatechange"in p.createElement("script")?(l=p.documentElement,function(y){var E=p.createElement("script");E.onreadystatechange=function(){f(y),E.onreadystatechange=null,l.removeChild(E),E=null},l.appendChild(E)}):function(y){setTimeout(f,0,y)},m.setImmediate=function(y){typeof y!="function"&&(y=new Function(""+y));for(var E=new Array(arguments.length-1),B=0;B<E.length;B++)E[B]=arguments[B+1];var Q={callback:y,args:E};return d[h]=Q,c(h),h++},m.clearImmediate=I}function I(y){delete d[y]}function f(y){if(_)setTimeout(f,0,y);else{var E=d[y];if(E){_=!0;try{(function(B){var Q=B.callback,b=B.args;switch(b.length){case 0:Q();break;case 1:Q(b[0]);break;case 2:Q(b[0],b[1]);break;case 3:Q(b[0],b[1],b[2]);break;default:Q.apply(A,b)}})(E)}finally{I(y),_=!1}}}}function C(y){y.source===a&&typeof y.data=="string"&&y.data.indexOf(u)===0&&f(+y.data.slice(u.length))}})(typeof self>"u"?s===void 0?this:s:self)}).call(this,typeof FC<"u"?FC:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(q7e)),q7e.exports}var ati=sti();const W7e=ay(ati),Ati=async({circuitJson:t,projectName:e})=>{await Ws.promise((async()=>{const n=new W7e,[{stringifyGerberCommandLayers:o,convertSoupToGerberCommands:i,convertSoupToExcellonDrillCommands:r,stringifyExcellonDrill:s},{convertCircuitJsonToBomRows:a,convertBomRowsToCsv:A},{convertCircuitJsonToPickAndPlaceCsv:c}]=await Promise.all([sQ("circuit-json-to-gerber"),sQ("circuit-json-to-bom-csv"),sQ("circuit-json-to-pnp-csv")]),l=t.filter(f=>!("error_type"in f)&&!("warning_type"in f)),g=i(l,{flip_y_axis:!1}),u=o(g);for(const[f,C]of Object.entries(u))n.file(`gerber/${f}.gbr`,C);const h=r({circuitJson:l,is_plated:!0,flip_y_axis:!1}),d=s(h);n.file("gerber/drill.drl",d);const _=await a({circuitJson:t}),p=await A(_);n.file("bom.csv",p);const m=await c(t,{supplier:"jlcpcb"});n.file("pick_and_place.csv",m);const I=await n.generateAsync({type:"blob"});Cb(I,{fileName:`${e}_fabrication_files.zip`})})(),{loading:"Generating fabrication files...",success:"Fabrication ZIP ready",error:n=>`Failed to generate fabrication files: ${n instanceof Error?n.message:String(n)}`})},cti=async({circuitJson:t,projectName:e})=>{let n;try{const{convertCircuitJsonToGltf:o}=await sQ("circuit-json-to-gltf");console.log("convertCircuitJsonToGltf",o);const i=await o(t,{format:"glb",boardTextureResolution:1024});if(!i||!(i instanceof ArrayBuffer))throw new Error("Invalid GLB data returned from converter");n=new Blob([i],{type:"model/gltf-binary"})}catch(o){console.error("GLB Export Error:",o);return}Cb(n,{fileName:`${e}.glb`})},lti=async({circuitJson:t,libraryName:e})=>{const{CircuitJsonToKicadLibraryConverter:n}=await sQ("circuit-json-to-kicad"),o=new n(t,{libraryName:e,footprintLibraryName:e});o.runUntilFinished();const i=o.getOutput(),r=new W7e;r.file(`${e}.kicad_sym`,i.kicadSymString);for(const s of i.footprints){const a=r.folder(`${e}.pretty`);a&&a.file(`${s.footprintName}.kicad_mod`,`${s.kicadModString}
5800
5800
  `)}if(i.model3dSourcePaths.length>0){const s=r.folder(`${e}.3dshapes`);if(s)for(const a of i.model3dSourcePaths)try{const A=a.split("/").pop()||a,c=await fetch(a);if(c.ok){const l=await c.arrayBuffer();s.file(A,l)}}catch{}}return r.file("fp-lib-table",i.fpLibTableString),r.file("sym-lib-table",i.symLibTableString),r},gti=async({circuitJson:t,projectName:e})=>{await Ws.promise((async()=>{const o=await(await lti({circuitJson:t,libraryName:e})).generateAsync({type:"blob"});Cb(o,{fileName:`${e}_kicad_library.zip`})})(),{loading:"Generating KiCad library...",success:"KiCad library ZIP ready",error:n=>`Failed to generate KiCad library: ${n instanceof Error?n.message:String(n)}`})},uti=async({circuitJson:t,projectName:e})=>{const{CircuitJsonToKicadPcbConverter:n,CircuitJsonToKicadSchConverter:o,CircuitJsonToKicadProConverter:i,resolveAndLoadKicad3dModelFiles:r}=await sQ("circuit-json-to-kicad"),s=new o(t);s.runUntilFinished();const a=s.getOutputString(),A=new n(t,{includeBuiltin3dModels:!0,projectName:e});A.runUntilFinished();const c=A.getOutputString(),l=new i(t,{projectName:e,schematicFilename:`${e}.kicad_sch`,pcbFilename:`${e}.kicad_pcb`});l.runUntilFinished();const g=l.getOutputString(),u=new W7e;return u.file(`${e}.kicad_sch`,a),u.file(`${e}.kicad_pcb`,c),u.file(`${e}.kicad_pro`,g),await r({projectName:e,model3dSourcePaths:A.getModel3dSourcePaths(),fetch,onModelFile:({outputPath:h,content:d})=>{u.file(h,d)},onError:({sourcePath:h})=>{console.warn(`Failed to load 3D model from ${h}`)}}),u},dti=async({circuitJson:t,projectName:e})=>{await Ws.promise((async()=>{const o=await(await uti({circuitJson:t,projectName:e})).generateAsync({type:"blob"});Cb(o,{fileName:`${e}_kicad_project.zip`})})(),{loading:"Generating KiCad project...",success:"KiCad project ZIP ready",error:n=>`Failed to generate KiCad project: ${n instanceof Error?n.message:String(n)}`})},KOt=async({circuitJson:t,projectName:e,options:n={}})=>{try{const{convertCircuitJsonToLbrn:o}=await sQ("circuit-json-to-lbrn"),r=(await o(t,{includeSilkscreen:n.includeSilkscreen??!1,includeOxidationCleaningLayer:n.includeOxidationCleaningLayer??!0})).toXml(),s=new Blob([r],{type:"application/lbrn"});Cb(s,{fileName:`${e}.lbrn2`})}catch(o){const i=o instanceof Error?o.message:"Unknown error";Ws.error(`Failed to export to LBRN format: ${i}`)}},hti=async({circuitJson:t,projectName:e})=>{const{convertCircuitJsonToPinoutSvg:n}=await sQ("circuit-to-svg"),o=n(t);Cb(o,{fileName:`${e}-pinout.svg`,mimeType:"image/svg+xml"})},_ti=async({circuitJson:t,projectName:e})=>{const{circuitJsonToStep:n}=await sQ("circuit-json-to-step"),o=t.find(c=>c.type==="pcb_board"),i=o&&"width"in o?o.width:void 0,r=o&&"height"in o?o.height:void 0,s=o&&"thickness"in o?o.thickness:void 0;if(i===void 0||r===void 0||s===void 0){Ws.error("Board dimensions not found. Please add a pcb_board with width, height, and thickness to your circuit.");return}let a;try{a=await n(t,{boardWidth:i,boardHeight:r,boardThickness:s,productName:e,includeComponents:!0,includeExternalMeshes:!0})}catch(c){const l=c instanceof Error?c.message:"Unknown error";Ws.error(`Failed to convert circuit to STEP format: ${l}`);return}const A=new Blob([a],{type:"application/step"});try{Cb(A,{fileName:`${e}.step`})}catch(c){const l=c instanceof Error?c.message:"Unknown error";Ws.error(`Failed to download STEP file: ${l}`)}},pti=[{extension:"json",name:"Circuit JSON"},{extension:"json",name:"Simple Route JSON"},{extension:"zip",name:"Fabrication Files"},{extension:"zip",name:"KiCad Project"},{extension:"zip",name:"KiCad Library"},{extension:"glb",name:"GLB (Binary GLTF)"},{extension:"svg",name:"Pinout SVG"},{extension:"step",name:"STEP"},{extension:"lbrn2",name:"LightBurn"}],mti=async({exportName:t,circuitJson:e,simpleRouteJson:n,projectName:o})=>{const i=qGt(o);if(t==="Fabrication Files"){await Ati({circuitJson:e,projectName:i});return}if(t==="KiCad Project"){await dti({circuitJson:e,projectName:i});return}if(t==="KiCad Library"){await gti({circuitJson:e,projectName:i});return}if(t==="Circuit JSON"){Cb(JSON.stringify(e,null,2),{fileName:`${i}.circuit.json`,mimeType:"application/json"});return}if(t==="Simple Route JSON"){if(!n)throw new Error("No Simple Route JSON available to export");Cb(JSON.stringify(n,null,2),{fileName:`${i}.simple-route.json`,mimeType:"application/json"});return}if(t==="GLB (Binary GLTF)"){await cti({circuitJson:e,projectName:i});return}if(t==="Pinout SVG"){hti({circuitJson:e,projectName:i});return}if(t==="STEP"){await _ti({circuitJson:e,projectName:i});return}if(t==="LightBurn"){await KOt({circuitJson:e,projectName:i});return}throw new Error(`Unsupported export type: "${t}"`)},Iti=({packageName:t,onSelectReview:e})=>{const n=od(g=>g.fsMap),o=od(g=>g.circuitJson),[i,r]=$.useState([]),[s,a]=$.useState(!1),[A,c]=$.useState(!1);$.useEffect(()=>{!t||!Lne()||(a(!0),bK.get("ai_reviews/list",{searchParams:{package_name:t}}).json().then(g=>r(g.ai_reviews)).catch(g=>{console.error("Failed to load AI reviews",g),Ws.error("Failed to load AI reviews")}).finally(()=>a(!1)))},[t]);const l=async()=>{if(!o){Ws.error("Need Circuit JSON to Request AI Review");return}if(!Lne()){Ws.error("Missing registry token");return}c(!0);try{const{ai_review:g}=await bK.post("ai_reviews/create",{json:{package_name:t??"unknown",fs_map:Object.fromEntries(n),circuit_json:o}}).json();r(u=>[g,...u]),e(g),Ws.success("AI review requested")}catch(g){console.error("Failed to create AI review",g),Ws.error("Failed to request AI review")}finally{c(!1)}};return V.jsxs(V.Fragment,{children:[V.jsxs(r8,{children:[V.jsx(s8,{children:"AI Review"}),V.jsx(Wk,{children:"Select an AI review or request a new one."})]}),V.jsx("div",{className:"rf-flex rf-gap-4 rf-mt-4",children:V.jsx("div",{className:"rf-w-48 rf-h-64 rf-overflow-y-auto rf-border rf-rounded rf-p-2 rf-flex-shrink-0",children:s?V.jsx("div",{className:"rf-text-sm",children:"Loading..."}):i.length>0?i.map(g=>V.jsx("div",{className:"rf-text-sm rf-p-2 rf-cursor-pointer rf-rounded hover:rf-bg-zinc-100",onClick:()=>e(g),children:new Date(g.created_at||"").toLocaleString()},g.ai_review_id)):V.jsx("div",{className:"rf-text-sm rf-text-muted-foreground",children:"No AI reviews found."})})}),V.jsx(jY,{className:"rf-mt-4",children:V.jsx(cA,{onClick:l,disabled:A,children:A?"Requesting...":"Review my Board"})})]})};function j7e(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var a8=j7e();function UOt(t){a8=t}var ZY={exec:()=>null};function Dl(t,e=""){let n=typeof t=="string"?t:t.source;const o={replace:(i,r)=>{let s=typeof r=="string"?r:r.source;return s=s.replace(d1.caret,"$1"),n=n.replace(i,s),o},getRegex:()=>new RegExp(n,e)};return o}var d1={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")},fti=/^(?:[ \t]*(?:\n|$))+/,Cti=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,yti=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,ez=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Eti=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,X7e=/(?:[*+-]|\d{1,9}[.)])/,YOt=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,zOt=Dl(YOt).replace(/bull/g,X7e).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(),xti=Dl(YOt).replace(/bull/g,X7e).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(),$7e=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Bti=/^[^\n]+/,Z7e=/(?!\s*\])(?:\\.|[^\[\]\\])+/,Qti=Dl(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Z7e).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Sti=Dl(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,X7e).getRegex(),vae="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",eNe=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,bti=Dl("^ {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",eNe).replace("tag",vae).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),VOt=Dl($7e).replace("hr",ez).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",vae).getRegex(),Dti=Dl(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",VOt).getRegex(),tNe={blockquote:Dti,code:Cti,def:Qti,fences:yti,heading:Eti,hr:ez,html:bti,lheading:zOt,list:Sti,newline:fti,paragraph:VOt,table:ZY,text:Bti},JOt=Dl("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",ez).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",vae).getRegex(),vti={...tNe,lheading:xti,table:JOt,paragraph:Dl($7e).replace("hr",ez).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",JOt).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",vae).getRegex()},Pti={...tNe,html:Dl(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",eNe).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:ZY,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Dl($7e).replace("hr",ez).replace("heading",` *#{1,6} *[^
5801
5801
  ]`).replace("lheading",zOt).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},wti=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Mti=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,qOt=/^( {2,}|\\)\n(?!\s*$)/,Nti=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Pae=/[\p{P}\p{S}]/u,nNe=/[\s\p{P}\p{S}]/u,WOt=/[^\s\p{P}\p{S}]/u,Rti=Dl(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,nNe).getRegex(),jOt=/(?!~)[\p{P}\p{S}]/u,Tti=/(?!~)[\s\p{P}\p{S}]/u,kti=/(?:[^\s\p{P}\p{S}]|~)/u,Fti=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,XOt=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,Lti=Dl(XOt,"u").replace(/punct/g,Pae).getRegex(),Hti=Dl(XOt,"u").replace(/punct/g,jOt).getRegex(),$Ot="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",Gti=Dl($Ot,"gu").replace(/notPunctSpace/g,WOt).replace(/punctSpace/g,nNe).replace(/punct/g,Pae).getRegex(),Oti=Dl($Ot,"gu").replace(/notPunctSpace/g,kti).replace(/punctSpace/g,Tti).replace(/punct/g,jOt).getRegex(),Kti=Dl("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,WOt).replace(/punctSpace/g,nNe).replace(/punct/g,Pae).getRegex(),Uti=Dl(/\\(punct)/,"gu").replace(/punct/g,Pae).getRegex(),Yti=Dl(/^<(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(),zti=Dl(eNe).replace("(?:-->|$)","-->").getRegex(),Vti=Dl("^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",zti).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),wae=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,Jti=Dl(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",wae).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),ZOt=Dl(/^!?\[(label)\]\[(ref)\]/).replace("label",wae).replace("ref",Z7e).getRegex(),eKt=Dl(/^!?\[(ref)\](?:\[\])?/).replace("ref",Z7e).getRegex(),qti=Dl("reflink|nolink(?!\\()","g").replace("reflink",ZOt).replace("nolink",eKt).getRegex(),oNe={_backpedal:ZY,anyPunctuation:Uti,autolink:Yti,blockSkip:Fti,br:qOt,code:Mti,del:ZY,emStrongLDelim:Lti,emStrongRDelimAst:Gti,emStrongRDelimUnd:Kti,escape:wti,link:Jti,nolink:eKt,punctuation:Rti,reflink:ZOt,reflinkSearch:qti,tag:Vti,text:Nti,url:ZY},Wti={...oNe,link:Dl(/^!?\[(label)\]\((.*?)\)/).replace("label",wae).getRegex(),reflink:Dl(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",wae).getRegex()},iNe={...oNe,emStrongRDelimAst:Oti,emStrongLDelim:Hti,url:Dl(/^((?: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.!#$%&'*+\/=?_`{\|}~-]+@)))/},jti={...iNe,br:Dl(qOt).replace("{2,}","*").getRegex(),text:Dl(iNe.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Mae={normal:tNe,gfm:vti,pedantic:Pti},tz={normal:oNe,gfm:iNe,breaks:jti,pedantic:Wti},Xti={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},tKt=t=>Xti[t];function Eb(t,e){if(e){if(d1.escapeTest.test(t))return t.replace(d1.escapeReplace,tKt)}else if(d1.escapeTestNoEncode.test(t))return t.replace(d1.escapeReplaceNoEncode,tKt);return t}function nKt(t){try{t=encodeURI(t).replace(d1.percentDecode,"%")}catch{return null}return t}function oKt(t,e){const n=t.replace(d1.findPipe,(r,s,a)=>{let A=!1,c=s;for(;--c>=0&&a[c]==="\\";)A=!A;return A?"|":" |"}),o=n.split(d1.splitPipe);let i=0;if(o[0].trim()||o.shift(),o.length>0&&!o.at(-1)?.trim()&&o.pop(),e)if(o.length>e)o.splice(e);else for(;o.length<e;)o.push("");for(;i<o.length;i++)o[i]=o[i].trim().replace(d1.slashPipe,"|");return o}function nz(t,e,n){const o=t.length;if(o===0)return"";let i=0;for(;i<o&&t.charAt(o-i-1)===e;)i++;return t.slice(0,o-i)}function $ti(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 iKt(t,e,n,o,i){const r=e.href,s=e.title||null,a=t[1].replace(i.other.outputLinkReplace,"$1");o.state.inLink=!0;const A={type:t[0].charAt(0)==="!"?"image":"link",raw:n,href:r,title:s,text:a,tokens:o.inlineTokens(a)};return o.state.inLink=!1,A}function Zti(t,e,n){const o=t.match(n.other.indentCodeCompensation);if(o===null)return e;const i=o[1];return e.split(`