petdex 0.3.9 → 0.4.1

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.
Files changed (3) hide show
  1. package/README.md +2 -2
  2. package/dist/petdex.js +249 -121
  3. package/package.json +4 -4
package/dist/petdex.js CHANGED
@@ -1,64 +1,81 @@
1
1
  #!/usr/bin/env node
2
- import{createRequire as pY}from"node:module";var kY=Object.create;var{getPrototypeOf:gY,defineProperty:v8,getOwnPropertyNames:DY}=Object;var hY=Object.prototype.hasOwnProperty;function _Y($){return this[$]}var bY,fY,C1=($,Q,q)=>{var V=$!=null&&typeof $==="object";if(V){var Y=Q?bY??=new WeakMap:fY??=new WeakMap,X=Y.get($);if(X)return X}q=$!=null?kY(gY($)):{};let J=Q||!$||!$.__esModule?v8(q,"default",{value:$,enumerable:!0}):q;for(let G of DY($))if(!hY.call(J,G))v8(J,G,{get:_Y.bind($,G),enumerable:!0});if(V)Y.set($,J);return J};var T=($,Q)=>()=>(Q||$((Q={exports:{}}).exports,Q),Q.exports);var mY=($)=>$;function cY($,Q){this[$]=mY.bind(null,Q)}var x8=($,Q)=>{for(var q in Q)v8($,q,{get:Q[q],enumerable:!0,configurable:!0,set:cY.bind(Q,q)})};var $0=($,Q)=>()=>($&&(Q=$($=0)),Q);var b=pY(import.meta.url);var E8=T((ZH,Uq)=>{var S8={to($,Q){if(!Q)return`\x1B[${$+1}G`;return`\x1B[${Q+1};${$+1}H`},move($,Q){let q="";if($<0)q+=`\x1B[${-$}D`;else if($>0)q+=`\x1B[${$}C`;if(Q<0)q+=`\x1B[${-Q}A`;else if(Q>0)q+=`\x1B[${Q}B`;return q},up:($=1)=>`\x1B[${$}A`,down:($=1)=>`\x1B[${$}B`,forward:($=1)=>`\x1B[${$}C`,backward:($=1)=>`\x1B[${$}D`,nextLine:($=1)=>"\x1B[E".repeat($),prevLine:($=1)=>"\x1B[F".repeat($),left:"\x1B[G",hide:"\x1B[?25l",show:"\x1B[?25h",save:"\x1B7",restore:"\x1B8"},uY={up:($=1)=>"\x1B[S".repeat($),down:($=1)=>"\x1B[T".repeat($)},dY={screen:"\x1B[2J",up:($=1)=>"\x1B[1J".repeat($),down:($=1)=>"\x1B[J".repeat($),line:"\x1B[2K",lineEnd:"\x1B[K",lineStart:"\x1B[1K",lines($){let Q="";for(let q=0;q<$;q++)Q+=this.line+(q<$-1?S8.up():"");if($)Q+=S8.left;return Q}};Uq.exports={cursor:S8,scroll:uY,erase:dY,beep:"\x07"}});var d1=T((zH,y8)=>{var j6=process||{},jq=j6.argv||[],U6=j6.env||{},lY=!(!!U6.NO_COLOR||jq.includes("--no-color"))&&(!!U6.FORCE_COLOR||jq.includes("--color")||j6.platform==="win32"||(j6.stdout||{}).isTTY&&U6.TERM!=="dumb"||!!U6.CI),oY=($,Q,q=$)=>(V)=>{let Y=""+V,X=Y.indexOf(Q,$.length);return~X?$+iY(Y,Q,q,X)+Q:$+Y+Q},iY=($,Q,q,V)=>{let Y="",X=0;do Y+=$.substring(X,V)+q,X=V+Q.length,V=$.indexOf(Q,X);while(~V);return Y+$.substring(X)},Zq=($=lY)=>{let Q=$?oY:()=>String;return{isColorSupported:$,reset:Q("\x1B[0m","\x1B[0m"),bold:Q("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:Q("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:Q("\x1B[3m","\x1B[23m"),underline:Q("\x1B[4m","\x1B[24m"),inverse:Q("\x1B[7m","\x1B[27m"),hidden:Q("\x1B[8m","\x1B[28m"),strikethrough:Q("\x1B[9m","\x1B[29m"),black:Q("\x1B[30m","\x1B[39m"),red:Q("\x1B[31m","\x1B[39m"),green:Q("\x1B[32m","\x1B[39m"),yellow:Q("\x1B[33m","\x1B[39m"),blue:Q("\x1B[34m","\x1B[39m"),magenta:Q("\x1B[35m","\x1B[39m"),cyan:Q("\x1B[36m","\x1B[39m"),white:Q("\x1B[37m","\x1B[39m"),gray:Q("\x1B[90m","\x1B[39m"),bgBlack:Q("\x1B[40m","\x1B[49m"),bgRed:Q("\x1B[41m","\x1B[49m"),bgGreen:Q("\x1B[42m","\x1B[49m"),bgYellow:Q("\x1B[43m","\x1B[49m"),bgBlue:Q("\x1B[44m","\x1B[49m"),bgMagenta:Q("\x1B[45m","\x1B[49m"),bgCyan:Q("\x1B[46m","\x1B[49m"),bgWhite:Q("\x1B[47m","\x1B[49m"),blackBright:Q("\x1B[90m","\x1B[39m"),redBright:Q("\x1B[91m","\x1B[39m"),greenBright:Q("\x1B[92m","\x1B[39m"),yellowBright:Q("\x1B[93m","\x1B[39m"),blueBright:Q("\x1B[94m","\x1B[39m"),magentaBright:Q("\x1B[95m","\x1B[39m"),cyanBright:Q("\x1B[96m","\x1B[39m"),whiteBright:Q("\x1B[97m","\x1B[39m"),bgBlackBright:Q("\x1B[100m","\x1B[49m"),bgRedBright:Q("\x1B[101m","\x1B[49m"),bgGreenBright:Q("\x1B[102m","\x1B[49m"),bgYellowBright:Q("\x1B[103m","\x1B[49m"),bgBlueBright:Q("\x1B[104m","\x1B[49m"),bgMagentaBright:Q("\x1B[105m","\x1B[49m"),bgCyanBright:Q("\x1B[106m","\x1B[49m"),bgWhiteBright:Q("\x1B[107m","\x1B[49m")}};y8.exports=Zq();y8.exports.createColors=Zq});import{stdin as Cq,stdout as wq}from"node:process";import*as Q0 from"node:readline";import zq from"node:readline";import{Writable as nY}from"node:stream";function rY({onlyFirst:$=!1}={}){let Q=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(Q,$?void 0:"g")}function Tq($){if(typeof $!="string")throw TypeError(`Expected a \`string\`, got \`${typeof $}\``);return $.replace(aY,"")}function Aq($){return $&&$.__esModule&&Object.prototype.hasOwnProperty.call($,"default")?$.default:$}function j$($,Q={}){if(typeof $!="string"||$.length===0||(Q={ambiguousIsNarrow:!0,...Q},$=Tq($),$.length===0))return 0;$=$.replace($4()," ");let q=Q.ambiguousIsNarrow?1:2,V=0;for(let Y of $){let X=Y.codePointAt(0);if(X<=31||X>=127&&X<=159||X>=768&&X<=879)continue;switch(tY.eastAsianWidth(Y)){case"F":case"W":V+=2;break;case"A":V+=q;break;default:V+=1}}return V}function V4(){let $=new Map;for(let[Q,q]of Object.entries(m)){for(let[V,Y]of Object.entries(q))m[V]={open:`\x1B[${Y[0]}m`,close:`\x1B[${Y[1]}m`},q[V]=m[V],$.set(Y[0],Y[1]);Object.defineProperty(m,Q,{value:q,enumerable:!1})}return Object.defineProperty(m,"codes",{value:$,enumerable:!1}),m.color.close="\x1B[39m",m.bgColor.close="\x1B[49m",m.color.ansi=Hq(),m.color.ansi256=Lq(),m.color.ansi16m=Pq(),m.bgColor.ansi=Hq(k8),m.bgColor.ansi256=Lq(k8),m.bgColor.ansi16m=Pq(k8),Object.defineProperties(m,{rgbToAnsi256:{value:(Q,q,V)=>Q===q&&q===V?Q<8?16:Q>248?231:Math.round((Q-8)/247*24)+232:16+36*Math.round(Q/255*5)+6*Math.round(q/255*5)+Math.round(V/255*5),enumerable:!1},hexToRgb:{value:(Q)=>{let q=/[a-f\d]{6}|[a-f\d]{3}/i.exec(Q.toString(16));if(!q)return[0,0,0];let[V]=q;V.length===3&&(V=[...V].map((X)=>X+X).join(""));let Y=Number.parseInt(V,16);return[Y>>16&255,Y>>8&255,Y&255]},enumerable:!1},hexToAnsi256:{value:(Q)=>m.rgbToAnsi256(...m.hexToRgb(Q)),enumerable:!1},ansi256ToAnsi:{value:(Q)=>{if(Q<8)return 30+Q;if(Q<16)return 90+(Q-8);let q,V,Y;if(Q>=232)q=((Q-232)*10+8)/255,V=q,Y=q;else{Q-=16;let G=Q%36;q=Math.floor(Q/36)/5,V=Math.floor(G/6)/5,Y=G%6/5}let X=Math.max(q,V,Y)*2;if(X===0)return 30;let J=30+(Math.round(Y)<<2|Math.round(V)<<1|Math.round(q));return X===2&&(J+=60),J},enumerable:!1},rgbToAnsi:{value:(Q,q,V)=>m.ansi256ToAnsi(m.rgbToAnsi256(Q,q,V)),enumerable:!1},hexToAnsi:{value:(Q)=>m.ansi256ToAnsi(m.hexToAnsi256(Q)),enumerable:!1}}),m}function Bq($,Q,q){return String($).normalize().replace(/\r\n/g,`
3
- `).split(`
4
- `).map((V)=>W4(V,Q,q)).join(`
5
- `)}function b8($,Q){if(typeof $=="string")return z6.aliases.get($)===Q;for(let q of $)if(q!==void 0&&b8(q,Q))return!0;return!1}function j4($,Q){if($===Q)return;let q=$.split(`
6
- `),V=Q.split(`
7
- `),Y=[];for(let X=0;X<Math.max(q.length,V.length);X++)q[X]!==V[X]&&Y.push(X);return Y}function q0($){return $===D8}function Z6($,Q){let q=$;q.isTTY&&q.setRawMode(Q)}function xq({input:$=Cq,output:Q=wq,overwrite:q=!0,hideCursor:V=!0}={}){let Y=Q0.createInterface({input:$,output:Q,prompt:"",tabSize:1});Q0.emitKeypressEvents($,Y),$.isTTY&&$.setRawMode(!0);let X=(J,{name:G,sequence:U})=>{let K=String(J);if(b8([K,G,U],"cancel")){V&&Q.write($1.cursor.show),process.exit(0);return}if(!q)return;Q0.moveCursor(Q,G==="return"?0:-1,G==="return"?-1:0,()=>{Q0.clearLine(Q,1,()=>{$.once("keypress",X)})})};return V&&Q.write($1.cursor.hide),$.once("keypress",X),()=>{$.off("keypress",X),V&&Q.write($1.cursor.show),$.isTTY&&!Z4&&$.setRawMode(!1),Y.terminal=!1,Y.close()}}class L6{constructor($,Q=!0){U1(this,"input"),U1(this,"output"),U1(this,"_abortSignal"),U1(this,"rl"),U1(this,"opts"),U1(this,"_render"),U1(this,"_track",!1),U1(this,"_prevFrame",""),U1(this,"_subscribers",new Map),U1(this,"_cursor",0),U1(this,"state","initial"),U1(this,"error",""),U1(this,"value");let{input:q=Cq,output:V=wq,render:Y,signal:X,...J}=$;this.opts=J,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=Y.bind(this),this._track=Q,this._abortSignal=X,this.input=q,this.output=V}unsubscribe(){this._subscribers.clear()}setSubscriber($,Q){let q=this._subscribers.get($)??[];q.push(Q),this._subscribers.set($,q)}on($,Q){this.setSubscriber($,{cb:Q})}once($,Q){this.setSubscriber($,{cb:Q,once:!0})}emit($,...Q){let q=this._subscribers.get($)??[],V=[];for(let Y of q)Y.cb(...Q),Y.once&&V.push(()=>q.splice(q.indexOf(Y),1));for(let Y of V)Y()}prompt(){return new Promise(($,Q)=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state="cancel",this.close(),$(D8);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}let q=new nY;q._write=(V,Y,X)=>{this._track&&(this.value=this.rl?.line.replace(/\t/g,""),this._cursor=this.rl?.cursor??0,this.emit("value",this.value)),X()},this.input.pipe(q),this.rl=zq.createInterface({input:this.input,output:q,tabSize:2,prompt:"",escapeCodeTimeout:50,terminal:!0}),zq.emitKeypressEvents(this.input,this.rl),this.rl.prompt(),this.opts.initialValue!==void 0&&this._track&&this.rl.write(this.opts.initialValue),this.input.on("keypress",this.onKeypress),Z6(this.input,!0),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write($1.cursor.show),this.output.off("resize",this.render),Z6(this.input,!1),$(this.value)}),this.once("cancel",()=>{this.output.write($1.cursor.show),this.output.off("resize",this.render),Z6(this.input,!1),$(D8)})})}onKeypress($,Q){if(this.state==="error"&&(this.state="active"),Q?.name&&(!this._track&&z6.aliases.has(Q.name)&&this.emit("cursor",z6.aliases.get(Q.name)),z6.actions.has(Q.name)&&this.emit("cursor",Q.name)),$&&($.toLowerCase()==="y"||$.toLowerCase()==="n")&&this.emit("confirm",$.toLowerCase()==="y"),$==="\t"&&this.opts.placeholder&&(this.value||(this.rl?.write(this.opts.placeholder),this.emit("value",this.opts.placeholder))),$&&this.emit("key",$.toLowerCase()),Q?.name==="return"){if(this.opts.validate){let q=this.opts.validate(this.value);q&&(this.error=q instanceof Error?q.message:q,this.state="error",this.rl?.write(this.value))}this.state!=="error"&&(this.state="submit")}b8([$,Q?.name,Q?.sequence],"cancel")&&(this.state="cancel"),(this.state==="submit"||this.state==="cancel")&&this.emit("finalize"),this.render(),(this.state==="submit"||this.state==="cancel")&&this.close()}close(){this.input.unpipe(),this.input.removeListener("keypress",this.onKeypress),this.output.write(`
8
- `),Z6(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let $=Bq(this._prevFrame,process.stdout.columns,{hard:!0}).split(`
9
- `).length-1;this.output.write($1.cursor.move(-999,$*-1))}render(){let $=Bq(this._render(this)??"",process.stdout.columns,{hard:!0});if($!==this._prevFrame){if(this.state==="initial")this.output.write($1.cursor.hide);else{let Q=j4(this._prevFrame,$);if(this.restoreCursor(),Q&&Q?.length===1){let q=Q[0];this.output.write($1.cursor.move(0,q)),this.output.write($1.erase.lines(1));let V=$.split(`
10
- `);this.output.write(V[q]),this._prevFrame=$,this.output.write($1.cursor.move(0,V.length-q-1));return}if(Q&&Q?.length>1){let q=Q[0];this.output.write($1.cursor.move(0,q)),this.output.write($1.erase.down());let V=$.split(`
11
- `).slice(q);this.output.write(V.join(`
12
- `)),this._prevFrame=$;return}this.output.write($1.erase.down())}this.output.write($),this.state==="initial"&&(this.state="active"),this._prevFrame=$}}}var $1,aY,Fq,sY,tY,eY=function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67)\uDB40\uDC7F|(?:\uD83E\uDDD1\uD83C\uDFFF\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFC-\uDFFF])|\uD83D\uDC68(?:\uD83C\uDFFB(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))?|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])\uFE0F|\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC)?|(?:\uD83D\uDC69(?:\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69]))|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC69(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83E\uDDD1(?:\u200D(?:\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDE36\u200D\uD83C\uDF2B|\uD83C\uDFF3\uFE0F\u200D\u26A7|\uD83D\uDC3B\u200D\u2744|(?:(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\uD83C\uDFF4\u200D\u2620|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])\u200D[\u2640\u2642]|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u2600-\u2604\u260E\u2611\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26B0\u26B1\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0\u26F1\u26F4\u26F7\u26F8\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u3030\u303D\u3297\u3299]|\uD83C[\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]|\uD83D[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3])\uFE0F|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDE35\u200D\uD83D\uDCAB|\uD83D\uDE2E\u200D\uD83D\uDCA8|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83E\uDDD1(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83D\uDC69(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDF4\uD83C\uDDF2|\uD83D\uDC08\u200D\u2B1B|\u2764\uFE0F\u200D(?:\uD83D\uDD25|\uD83E\uDE79)|\uD83D\uDC41\uFE0F|\uD83C\uDFF3\uFE0F|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|[#\*0-9]\uFE0F\u20E3|\u2764\uFE0F|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF4|(?:[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270C\u270D]|\uD83D[\uDD74\uDD90])(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC08\uDC15\uDC3B\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE2E\uDE35\uDE36\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5]|\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD]|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF]|[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0D\uDD0E\uDD10-\uDD17\uDD1D\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78\uDD7A-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCB\uDDD0\uDDE0-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6]|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDED7\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDD77\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g},$4,k8=10,Hq=($=0)=>(Q)=>`\x1B[${Q+$}m`,Lq=($=0)=>(Q)=>`\x1B[${38+$};5;${Q}m`,Pq=($=0)=>(Q,q,V)=>`\x1B[${38+$};2;${Q};${q};${V}m`,m,Q4,q4,J4,H6,Y4=39,h8="\x07",Rq="[",X4="]",vq="m",_8,Oq=($)=>`${H6.values().next().value}${Rq}${$}${vq}`,Mq=($)=>`${H6.values().next().value}${_8}${$}${h8}`,G4=($)=>$.split(" ").map((Q)=>j$(Q)),g8=($,Q,q)=>{let V=[...Q],Y=!1,X=!1,J=j$(Tq($[$.length-1]));for(let[G,U]of V.entries()){let K=j$(U);if(J+K<=q?$[$.length-1]+=U:($.push(U),J=0),H6.has(U)&&(Y=!0,X=V.slice(G+1).join("").startsWith(_8)),Y){X?U===h8&&(Y=!1,X=!1):U===vq&&(Y=!1);continue}J+=K,J===q&&G<V.length-1&&($.push(""),J=0)}!J&&$[$.length-1].length>0&&$.length>1&&($[$.length-2]+=$.pop())},K4=($)=>{let Q=$.split(" "),q=Q.length;for(;q>0&&!(j$(Q[q-1])>0);)q--;return q===Q.length?$:Q.slice(0,q).join(" ")+Q.slice(q).join("")},W4=($,Q,q={})=>{if(q.trim!==!1&&$.trim()==="")return"";let V="",Y,X,J=G4($),G=[""];for(let[K,W]of $.split(" ").entries()){q.trim!==!1&&(G[G.length-1]=G[G.length-1].trimStart());let Z=j$(G[G.length-1]);if(K!==0&&(Z>=Q&&(q.wordWrap===!1||q.trim===!1)&&(G.push(""),Z=0),(Z>0||q.trim===!1)&&(G[G.length-1]+=" ",Z++)),q.hard&&J[K]>Q){let z=Q-Z,H=1+Math.floor((J[K]-z-1)/Q);Math.floor((J[K]-1)/Q)<H&&G.push(""),g8(G,W,Q);continue}if(Z+J[K]>Q&&Z>0&&J[K]>0){if(q.wordWrap===!1&&Z<Q){g8(G,W,Q);continue}G.push("")}if(Z+J[K]>Q&&q.wordWrap===!1){g8(G,W,Q);continue}G[G.length-1]+=W}q.trim!==!1&&(G=G.map((K)=>K4(K)));let U=[...G.join(`
13
- `)];for(let[K,W]of U.entries()){if(V+=W,H6.has(W)){let{groups:z}=new RegExp(`(?:\\${Rq}(?<code>\\d+)m|\\${_8}(?<uri>.*)${h8})`).exec(U.slice(K).join(""))||{groups:{}};if(z.code!==void 0){let H=Number.parseFloat(z.code);Y=H===Y4?void 0:H}else z.uri!==void 0&&(X=z.uri.length===0?void 0:z.uri)}let Z=J4.codes.get(Number(Y));U[K+1]===`
14
- `?(X&&(V+=Mq("")),Y&&Z&&(V+=Oq(Z))):W===`
15
- `&&(Y&&Z&&(V+=Oq(Y)),X&&(V+=Mq(X)))}return V},U4,z6,Z4,D8,z4,H4=($,Q,q)=>(Q in $)?z4($,Q,{enumerable:!0,configurable:!0,writable:!0,value:q}):$[Q]=q,U1=($,Q,q)=>(H4($,typeof Q!="symbol"?Q+"":Q,q),q),f8,L4,P4,O4=($,Q,q)=>(Q in $)?P4($,Q,{enumerable:!0,configurable:!0,writable:!0,value:q}):$[Q]=q,Nq=($,Q,q)=>(O4($,typeof Q!="symbol"?Q+"":Q,q),q),Sq,M4,B4=($,Q,q)=>(Q in $)?M4($,Q,{enumerable:!0,configurable:!0,writable:!0,value:q}):$[Q]=q,Iq=($,Q,q)=>(B4($,typeof Q!="symbol"?Q+"":Q,q),q),m8;var c8=$0(()=>{$1=C1(E8(),1);aY=rY();Fq={exports:{}};(function($){var Q={};$.exports=Q,Q.eastAsianWidth=function(V){var Y=V.charCodeAt(0),X=V.length==2?V.charCodeAt(1):0,J=Y;return 55296<=Y&&Y<=56319&&56320<=X&&X<=57343&&(Y&=1023,X&=1023,J=Y<<10|X,J+=65536),J==12288||65281<=J&&J<=65376||65504<=J&&J<=65510?"F":J==8361||65377<=J&&J<=65470||65474<=J&&J<=65479||65482<=J&&J<=65487||65490<=J&&J<=65495||65498<=J&&J<=65500||65512<=J&&J<=65518?"H":4352<=J&&J<=4447||4515<=J&&J<=4519||4602<=J&&J<=4607||9001<=J&&J<=9002||11904<=J&&J<=11929||11931<=J&&J<=12019||12032<=J&&J<=12245||12272<=J&&J<=12283||12289<=J&&J<=12350||12353<=J&&J<=12438||12441<=J&&J<=12543||12549<=J&&J<=12589||12593<=J&&J<=12686||12688<=J&&J<=12730||12736<=J&&J<=12771||12784<=J&&J<=12830||12832<=J&&J<=12871||12880<=J&&J<=13054||13056<=J&&J<=19903||19968<=J&&J<=42124||42128<=J&&J<=42182||43360<=J&&J<=43388||44032<=J&&J<=55203||55216<=J&&J<=55238||55243<=J&&J<=55291||63744<=J&&J<=64255||65040<=J&&J<=65049||65072<=J&&J<=65106||65108<=J&&J<=65126||65128<=J&&J<=65131||110592<=J&&J<=110593||127488<=J&&J<=127490||127504<=J&&J<=127546||127552<=J&&J<=127560||127568<=J&&J<=127569||131072<=J&&J<=194367||177984<=J&&J<=196605||196608<=J&&J<=262141?"W":32<=J&&J<=126||162<=J&&J<=163||165<=J&&J<=166||J==172||J==175||10214<=J&&J<=10221||10629<=J&&J<=10630?"Na":J==161||J==164||167<=J&&J<=168||J==170||173<=J&&J<=174||176<=J&&J<=180||182<=J&&J<=186||188<=J&&J<=191||J==198||J==208||215<=J&&J<=216||222<=J&&J<=225||J==230||232<=J&&J<=234||236<=J&&J<=237||J==240||242<=J&&J<=243||247<=J&&J<=250||J==252||J==254||J==257||J==273||J==275||J==283||294<=J&&J<=295||J==299||305<=J&&J<=307||J==312||319<=J&&J<=322||J==324||328<=J&&J<=331||J==333||338<=J&&J<=339||358<=J&&J<=359||J==363||J==462||J==464||J==466||J==468||J==470||J==472||J==474||J==476||J==593||J==609||J==708||J==711||713<=J&&J<=715||J==717||J==720||728<=J&&J<=731||J==733||J==735||768<=J&&J<=879||913<=J&&J<=929||931<=J&&J<=937||945<=J&&J<=961||963<=J&&J<=969||J==1025||1040<=J&&J<=1103||J==1105||J==8208||8211<=J&&J<=8214||8216<=J&&J<=8217||8220<=J&&J<=8221||8224<=J&&J<=8226||8228<=J&&J<=8231||J==8240||8242<=J&&J<=8243||J==8245||J==8251||J==8254||J==8308||J==8319||8321<=J&&J<=8324||J==8364||J==8451||J==8453||J==8457||J==8467||J==8470||8481<=J&&J<=8482||J==8486||J==8491||8531<=J&&J<=8532||8539<=J&&J<=8542||8544<=J&&J<=8555||8560<=J&&J<=8569||J==8585||8592<=J&&J<=8601||8632<=J&&J<=8633||J==8658||J==8660||J==8679||J==8704||8706<=J&&J<=8707||8711<=J&&J<=8712||J==8715||J==8719||J==8721||J==8725||J==8730||8733<=J&&J<=8736||J==8739||J==8741||8743<=J&&J<=8748||J==8750||8756<=J&&J<=8759||8764<=J&&J<=8765||J==8776||J==8780||J==8786||8800<=J&&J<=8801||8804<=J&&J<=8807||8810<=J&&J<=8811||8814<=J&&J<=8815||8834<=J&&J<=8835||8838<=J&&J<=8839||J==8853||J==8857||J==8869||J==8895||J==8978||9312<=J&&J<=9449||9451<=J&&J<=9547||9552<=J&&J<=9587||9600<=J&&J<=9615||9618<=J&&J<=9621||9632<=J&&J<=9633||9635<=J&&J<=9641||9650<=J&&J<=9651||9654<=J&&J<=9655||9660<=J&&J<=9661||9664<=J&&J<=9665||9670<=J&&J<=9672||J==9675||9678<=J&&J<=9681||9698<=J&&J<=9701||J==9711||9733<=J&&J<=9734||J==9737||9742<=J&&J<=9743||9748<=J&&J<=9749||J==9756||J==9758||J==9792||J==9794||9824<=J&&J<=9825||9827<=J&&J<=9829||9831<=J&&J<=9834||9836<=J&&J<=9837||J==9839||9886<=J&&J<=9887||9918<=J&&J<=9919||9924<=J&&J<=9933||9935<=J&&J<=9953||J==9955||9960<=J&&J<=9983||J==10045||J==10071||10102<=J&&J<=10111||11093<=J&&J<=11097||12872<=J&&J<=12879||57344<=J&&J<=63743||65024<=J&&J<=65039||J==65533||127232<=J&&J<=127242||127248<=J&&J<=127277||127280<=J&&J<=127337||127344<=J&&J<=127386||917760<=J&&J<=917999||983040<=J&&J<=1048573||1048576<=J&&J<=1114109?"A":"N"},Q.characterLength=function(V){var Y=this.eastAsianWidth(V);return Y=="F"||Y=="W"||Y=="A"?2:1};function q(V){return V.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g)||[]}Q.length=function(V){for(var Y=q(V),X=0,J=0;J<Y.length;J++)X=X+this.characterLength(Y[J]);return X},Q.slice=function(V,Y,X){textLen=Q.length(V),Y=Y||0,X=X||1,Y<0&&(Y=textLen+Y),X<0&&(X=textLen+X);for(var J="",G=0,U=q(V),K=0;K<U.length;K++){var W=U[K],Z=Q.length(W);if(G>=Y-(Z==2?1:0))if(G+Z<=X)J+=W;else break;G+=Z}return J}})(Fq);sY=Fq.exports,tY=Aq(sY),$4=Aq(eY);m={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};Object.keys(m.modifier);Q4=Object.keys(m.color),q4=Object.keys(m.bgColor);[...Q4,...q4];J4=V4(),H6=new Set(["\x1B","›"]),_8=`${X4}8;;`;U4=["up","down","left","right","space","enter","cancel"],z6={actions:new Set(U4),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["\x03","cancel"],["escape","cancel"]])};Z4=globalThis.process.platform.startsWith("win"),D8=Symbol("clack:cancel");z4=Object.defineProperty;f8=class f8 extends L6{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor($){super($,!1),this.value=!!$.initialValue,this.on("value",()=>{this.value=this._value}),this.on("confirm",(Q)=>{this.output.write($1.cursor.move(0,-1)),this.value=Q,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}};L4=new WeakMap;P4=Object.defineProperty,Sq=class extends L6{constructor($){super($,!1),Nq(this,"options"),Nq(this,"cursor",0),this.options=$.options,this.value=[...$.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:Q})=>Q===$.cursorAt),0),this.on("key",(Q)=>{Q==="a"&&this.toggleAll()}),this.on("cursor",(Q)=>{switch(Q){case"left":case"up":this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case"down":case"right":this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break;case"space":this.toggleValue();break}})}get _value(){return this.options[this.cursor].value}toggleAll(){let $=this.value.length===this.options.length;this.value=$?[]:this.options.map((Q)=>Q.value)}toggleValue(){let $=this.value.includes(this._value);this.value=$?this.value.filter((Q)=>Q!==this._value):[...this.value,this._value]}},M4=Object.defineProperty;m8=class m8 extends L6{constructor($){super($,!1),Iq(this,"options"),Iq(this,"cursor",0),this.options=$.options,this.cursor=this.options.findIndex(({value:Q})=>Q===$.initialValue),this.cursor===-1&&(this.cursor=0),this.changeValue(),this.on("cursor",(Q)=>{switch(Q){case"left":case"up":this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case"down":case"right":this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break}this.changeValue()})}get _value(){return this.options[this.cursor]}changeValue(){this.value=this._value.value}}});import{stripVTControlCharacters as p8}from"node:util";import w1 from"node:process";function N4(){return w1.platform!=="win32"?w1.env.TERM!=="linux":!!w1.env.CI||!!w1.env.WT_SESSION||!!w1.env.TERMINUS_SUBLIME||w1.env.ConEmuTask==="{cmd::Cmder}"||w1.env.TERM_PROGRAM==="Terminus-Sublime"||w1.env.TERM_PROGRAM==="vscode"||w1.env.TERM==="xterm-256color"||w1.env.TERM==="alacritty"||w1.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var B,P6,u8,d=($,Q)=>u8?$:Q,I4,kq,gq,O6,C4,k,E0,d8,l8,w4,Eq,T4,RH,yq,A4,F4,R4,v4,x4,S4,E4,i8=($)=>{switch($){case"initial":case"active":return B.default.cyan(I4);case"cancel":return B.default.red(kq);case"error":return B.default.yellow(gq);case"submit":return B.default.green(O6)}},o8=($)=>{let{cursor:Q,options:q,style:V}=$,Y=$.maxItems??Number.POSITIVE_INFINITY,X=Math.max(process.stdout.rows-4,0),J=Math.min(X,Math.max(Y,5)),G=0;Q>=G+J-3?G=Math.max(Math.min(Q-J+3,q.length-J),0):Q<G+2&&(G=Math.max(Q-2,0));let U=J<q.length&&G>0,K=J<q.length&&G+J<q.length;return q.slice(G,G+J).map((W,Z,z)=>{let H=Z===0&&U,I=Z===z.length-1&&K;return H||I?B.default.dim("..."):V(W,Z+G===Q)})},M6=($)=>{let Q=$.active??"Yes",q=$.inactive??"No";return new f8({active:Q,inactive:q,initialValue:$.initialValue??!0,render(){let V=`${B.default.gray(k)}
16
- ${i8(this.state)} ${$.message}
17
- `,Y=this.value?Q:q;switch(this.state){case"submit":return`${V}${B.default.gray(k)} ${B.default.dim(Y)}`;case"cancel":return`${V}${B.default.gray(k)} ${B.default.strikethrough(B.default.dim(Y))}
18
- ${B.default.gray(k)}`;default:return`${V}${B.default.cyan(k)} ${this.value?`${B.default.green(d8)} ${Q}`:`${B.default.dim(l8)} ${B.default.dim(Q)}`} ${B.default.dim("/")} ${this.value?`${B.default.dim(l8)} ${B.default.dim(q)}`:`${B.default.green(d8)} ${q}`}
19
- ${B.default.cyan(E0)}
20
- `}}}).prompt()},Dq=($)=>{let Q=(q,V)=>{let Y=q.label??String(q.value);switch(V){case"selected":return`${B.default.dim(Y)}`;case"active":return`${B.default.green(d8)} ${Y} ${q.hint?B.default.dim(`(${q.hint})`):""}`;case"cancelled":return`${B.default.strikethrough(B.default.dim(Y))}`;default:return`${B.default.dim(l8)} ${B.default.dim(Y)}`}};return new m8({options:$.options,initialValue:$.initialValue,render(){let q=`${B.default.gray(k)}
21
- ${i8(this.state)} ${$.message}
22
- `;switch(this.state){case"submit":return`${q}${B.default.gray(k)} ${Q(this.options[this.cursor],"selected")}`;case"cancel":return`${q}${B.default.gray(k)} ${Q(this.options[this.cursor],"cancelled")}
23
- ${B.default.gray(k)}`;default:return`${q}${B.default.cyan(k)} ${o8({cursor:this.cursor,options:this.options,maxItems:$.maxItems,style:(V,Y)=>Q(V,Y?"active":"inactive")}).join(`
24
- ${B.default.cyan(k)} `)}
25
- ${B.default.cyan(E0)}
26
- `}}}).prompt()},hq=($)=>{let Q=(q,V)=>{let Y=q.label??String(q.value);return V==="active"?`${B.default.cyan(w4)} ${Y} ${q.hint?B.default.dim(`(${q.hint})`):""}`:V==="selected"?`${B.default.green(Eq)} ${B.default.dim(Y)} ${q.hint?B.default.dim(`(${q.hint})`):""}`:V==="cancelled"?`${B.default.strikethrough(B.default.dim(Y))}`:V==="active-selected"?`${B.default.green(Eq)} ${Y} ${q.hint?B.default.dim(`(${q.hint})`):""}`:V==="submitted"?`${B.default.dim(Y)}`:`${B.default.dim(T4)} ${B.default.dim(Y)}`};return new Sq({options:$.options,initialValues:$.initialValues,required:$.required??!0,cursorAt:$.cursorAt,validate(q){if(this.required&&q.length===0)return`Please select at least one option.
27
- ${B.default.reset(B.default.dim(`Press ${B.default.gray(B.default.bgWhite(B.default.inverse(" space ")))} to select, ${B.default.gray(B.default.bgWhite(B.default.inverse(" enter ")))} to submit`))}`},render(){let q=`${B.default.gray(k)}
28
- ${i8(this.state)} ${$.message}
29
- `,V=(Y,X)=>{let J=this.value.includes(Y.value);return X&&J?Q(Y,"active-selected"):J?Q(Y,"selected"):Q(Y,X?"active":"inactive")};switch(this.state){case"submit":return`${q}${B.default.gray(k)} ${this.options.filter(({value:Y})=>this.value.includes(Y)).map((Y)=>Q(Y,"submitted")).join(B.default.dim(", "))||B.default.dim("none")}`;case"cancel":{let Y=this.options.filter(({value:X})=>this.value.includes(X)).map((X)=>Q(X,"cancelled")).join(B.default.dim(", "));return`${q}${B.default.gray(k)} ${Y.trim()?`${Y}
30
- ${B.default.gray(k)}`:""}`}case"error":{let Y=this.error.split(`
31
- `).map((X,J)=>J===0?`${B.default.yellow(E0)} ${B.default.yellow(X)}`:` ${X}`).join(`
32
- `);return`${q+B.default.yellow(k)} ${o8({options:this.options,cursor:this.cursor,maxItems:$.maxItems,style:V}).join(`
33
- ${B.default.yellow(k)} `)}
34
- ${Y}
35
- `}default:return`${q}${B.default.cyan(k)} ${o8({options:this.options,cursor:this.cursor,maxItems:$.maxItems,style:V}).join(`
36
- ${B.default.cyan(k)} `)}
37
- ${B.default.cyan(E0)}
38
- `}}}).prompt()},T1=($="",Q="")=>{let q=`
39
- ${$}
40
- `.split(`
41
- `),V=p8(Q).length,Y=Math.max(q.reduce((J,G)=>{let U=p8(G);return U.length>J?U.length:J},0),V)+2,X=q.map((J)=>`${B.default.gray(k)} ${B.default.dim(J)}${" ".repeat(Y-p8(J).length)}${B.default.gray(k)}`).join(`
42
- `);process.stdout.write(`${B.default.gray(k)}
43
- ${B.default.green(O6)} ${B.default.reset(Q)} ${B.default.gray(yq.repeat(Math.max(Y-V-1,1))+A4)}
44
- ${X}
45
- ${B.default.gray(F4+yq.repeat(Y+2)+R4)}
46
- `)},Y1=($="")=>{process.stdout.write(`${B.default.gray(E0)} ${B.default.red($)}
47
-
48
- `)},A1=($="")=>{process.stdout.write(`${B.default.gray(C4)} ${$}
49
- `)},F1=($="")=>{process.stdout.write(`${B.default.gray(k)}
50
- ${B.default.gray(E0)} ${$}
51
-
52
- `)},u,vH,H1=({indicator:$="dots"}={})=>{let Q=u8?["◒","◐","◓","◑"]:["•","o","O","0"],q=u8?80:120,V=process.env.CI==="true",Y,X,J=!1,G="",U,K=performance.now(),W=(O)=>{let M=O>1?"Something went wrong":"Canceled";J&&C(M,O)},Z=()=>W(2),z=()=>W(1),H=()=>{process.on("uncaughtExceptionMonitor",Z),process.on("unhandledRejection",Z),process.on("SIGINT",z),process.on("SIGTERM",z),process.on("exit",W)},I=()=>{process.removeListener("uncaughtExceptionMonitor",Z),process.removeListener("unhandledRejection",Z),process.removeListener("SIGINT",z),process.removeListener("SIGTERM",z),process.removeListener("exit",W)},N=()=>{if(U===void 0)return;V&&process.stdout.write(`
53
- `);let O=U.split(`
54
- `);process.stdout.write(P6.cursor.move(-999,O.length-1)),process.stdout.write(P6.erase.down(O.length))},w=(O)=>O.replace(/\.+$/,""),P=(O)=>{let M=(performance.now()-O)/1000,F=Math.floor(M/60),R=Math.floor(M%60);return F>0?`[${F}m ${R}s]`:`[${R}s]`},L=(O="")=>{J=!0,Y=xq(),G=w(O),K=performance.now(),process.stdout.write(`${B.default.gray(k)}
55
- `);let M=0,F=0;H(),X=setInterval(()=>{if(V&&G===U)return;N(),U=G;let R=B.default.magenta(Q[M]);if(V)process.stdout.write(`${R} ${G}...`);else if($==="timer")process.stdout.write(`${R} ${G} ${P(K)}`);else{let v=".".repeat(Math.floor(F)).slice(0,3);process.stdout.write(`${R} ${G}${v}`)}M=M+1<Q.length?M+1:0,F=F<Q.length?F+0.125:0},q)},C=(O="",M=0)=>{J=!1,clearInterval(X),N();let F=M===0?B.default.green(O6):M===1?B.default.red(kq):B.default.red(gq);G=w(O??G),$==="timer"?process.stdout.write(`${F} ${G} ${P(K)}
56
- `):process.stdout.write(`${F} ${G}
57
- `),I(),Y()};return{start:L,stop:C,message:(O="")=>{G=w(O??G)}}};var y0=$0(()=>{c8();c8();B=C1(d1(),1),P6=C1(E8(),1);u8=N4(),I4=d("◆","*"),kq=d("■","x"),gq=d("▲","x"),O6=d("◇","o"),C4=d("┌","T"),k=d("│","|"),E0=d("└","—"),d8=d("●",">"),l8=d("○"," "),w4=d("◻","[•]"),Eq=d("◼","[+]"),T4=d("◻","[ ]"),RH=d("▪","•"),yq=d("─","-"),A4=d("╮","+"),F4=d("├","+"),R4=d("╯","+"),v4=d("●","•"),x4=d("◆","*"),S4=d("▲","!"),E4=d("■","x"),u={message:($="",{symbol:Q=B.default.gray(k)}={})=>{let q=[`${B.default.gray(k)}`];if($){let[V,...Y]=$.split(`
58
- `);q.push(`${Q} ${V}`,...Y.map((X)=>`${B.default.gray(k)} ${X}`))}process.stdout.write(`${q.join(`
2
+ import{createRequire as o3}from"node:module";var b3=Object.create;var{getPrototypeOf:h3,defineProperty:t2,getOwnPropertyNames:f3}=Object;var m3=Object.prototype.hasOwnProperty;function c3(Q){return this[Q]}var u3,p3,u0=(Q,$,J)=>{var q=Q!=null&&typeof Q==="object";if(q){var Y=$?u3??=new WeakMap:p3??=new WeakMap,V=Y.get(Q);if(V)return V}J=Q!=null?b3(h3(Q)):{};let X=$||!Q||!Q.__esModule?t2(J,"default",{value:Q,enumerable:!0}):J;for(let K of f3(Q))if(!m3.call(X,K))t2(X,K,{get:c3.bind(Q,K),enumerable:!0});if(q)Y.set(Q,X);return X};var w=(Q,$)=>()=>($||Q(($={exports:{}}).exports,$),$.exports);var d3=(Q)=>Q;function l3(Q,$){this[Q]=d3.bind(null,$)}var E8=(Q,$)=>{for(var J in $)t2(Q,J,{get:$[J],enumerable:!0,configurable:!0,set:l3.bind($,J)})};var z0=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var _=o3(import.meta.url);var aQ,sQ=(Q)=>{return Q===12288||Q>=65281&&Q<=65376||Q>=65504&&Q<=65510},tQ=(Q)=>{return Q===8987||Q===9001||Q>=12272&&Q<=12287||Q>=12289&&Q<=12350||Q>=12441&&Q<=12543||Q>=12549&&Q<=12591||Q>=12593&&Q<=12686||Q>=12688&&Q<=12771||Q>=12783&&Q<=12830||Q>=12832&&Q<=12871||Q>=12880&&Q<=19903||Q>=65040&&Q<=65049||Q>=65072&&Q<=65106||Q>=65108&&Q<=65126||Q>=65128&&Q<=65131||Q>=127488&&Q<=127490||Q>=127504&&Q<=127547||Q>=127552&&Q<=127560||Q>=131072&&Q<=196605||Q>=196608&&Q<=262141};var eQ=z0(()=>{aQ=(()=>{let Q=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return($)=>{let J=0;Q.lastIndex=0;while(Q.test($))J+=1;return $.length-J}})()});var i3,n3,Q7,r3,$7,a3,s3,t3,J7=(Q,$={},J={})=>{let q=$.limit??1/0,Y=$.ellipsis??"",V=$?.ellipsisWidth??(Y?J7(Y,t3,J).width:0),X=0,K=J.controlWidth??0,W=J.tabWidth??8,G=J.emojiWidth??2,U=2,z=J.regularWidth??1,j=J.wideWidth??2,H=[[a3,z],[i3,0],[n3,K],[r3,W],[$7,G],[Q7,j]],F=0,N=0,T=Q.length,P=0,L=!1,A=T,B=Math.max(0,q-V),O=0,M=0,C=0,D=0;Q:while(!0){if(M>O||N>=T&&N>F){let x=Q.slice(O,M)||Q.slice(F,N);P=0;for(let v of x.replaceAll(s3,"")){let R=v.codePointAt(0)||0;if(sQ(R))D=2;else if(tQ(R))D=j;else D=z;if(C+D>B)A=Math.min(A,Math.max(O,F)+P);if(C+D>q){L=!0;break Q}P+=v.length,C+=D}O=M=0}if(N>=T)break Q;for(let x=0,v=H.length;x<v;x++){let[R,$0]=H[x];if(R.lastIndex=N,R.test(Q)){if(P=R===Q7?aQ(Q.slice(N,R.lastIndex)):R===$7?1:R.lastIndex-N,D=P*$0,C+D>B)A=Math.min(A,N+Math.floor((B-C)/$0));if(C+D>q){L=!0;break Q}C+=D,O=F,M=N,N=F=R.lastIndex;continue Q}}N+=1}return{width:L?B:C,index:L?A:T,truncated:L,ellipsed:L&&q>=V}},q7;var Y7=z0(()=>{eQ();i3=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,n3=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,Q7=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu,r3=/\t{1,1000}/y,$7=/[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/yu,a3=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,s3=/\p{M}+/gu,t3={limit:1/0,ellipsis:""},q7=J7});var e3,QV=(Q,$={})=>{return q7(Q,e3,$).width},W0;var e2=z0(()=>{Y7();e3={limit:1/0,ellipsis:"",ellipsisWidth:0},W0=QV});function p0(Q,$,J){return String(Q).normalize().split(VV).map((q)=>YV(q,$,J)).join(`
3
+ `)}var S8="\x1B",W7="›",$V=39,$5="\x07",U7="[",JV="]",j7="m",J5,V7,X7=(Q)=>{if(Q>=30&&Q<=37)return 39;if(Q>=90&&Q<=97)return 39;if(Q>=40&&Q<=47)return 49;if(Q>=100&&Q<=107)return 49;if(Q===1||Q===2)return 22;if(Q===3)return 23;if(Q===4)return 24;if(Q===7)return 27;if(Q===8)return 28;if(Q===9)return 29;if(Q===0)return 0;return},K7=(Q)=>`${S8}${U7}${Q}${j7}`,G7=(Q)=>`${S8}${J5}${Q}${$5}`,Q5=(Q,$,J)=>{let q=$[Symbol.iterator](),Y=!1,V=!1,X=Q.at(-1),K=X===void 0?0:W0(X),W=q.next(),G=q.next(),U=0;while(!W.done){let z=W.value,j=W0(z);if(K+j<=J)Q[Q.length-1]+=z;else Q.push(z),K=0;if(z===S8||z===W7)Y=!0,V=$.startsWith(J5,U+1);if(Y){if(V){if(z===$5)Y=!1,V=!1}else if(z===j7)Y=!1}else if(K+=j,K===J&&!G.done)Q.push(""),K=0;W=G,G=q.next(),U+=z.length}if(X=Q.at(-1),!K&&X!==void 0&&X.length&&Q.length>1)Q[Q.length-2]+=Q.pop()},qV=(Q)=>{let $=Q.split(" "),J=$.length;while(J){if(W0($[J-1]))break;J--}if(J===$.length)return Q;return $.slice(0,J).join(" ")+$.slice(J).join("")},YV=(Q,$,J={})=>{if(J.trim!==!1&&Q.trim()==="")return"";let q="",Y,V,X=Q.split(" "),K=[""],W=0;for(let z=0;z<X.length;z++){let j=X[z];if(J.trim!==!1){let F=K.at(-1)??"",N=F.trimStart();if(F.length!==N.length)K[K.length-1]=N,W=W0(N)}if(z!==0){if(W>=$&&(J.wordWrap===!1||J.trim===!1))K.push(""),W=0;if(W||J.trim===!1)K[K.length-1]+=" ",W++}let H=W0(j);if(J.hard&&H>$){let F=$-W,N=1+Math.floor((H-F-1)/$);if(Math.floor((H-1)/$)<N)K.push("");Q5(K,j,$),W=W0(K.at(-1)??"");continue}if(W+H>$&&W&&H){if(J.wordWrap===!1&&W<$){Q5(K,j,$),W=W0(K.at(-1)??"");continue}K.push(""),W=0}if(W+H>$&&J.wordWrap===!1){Q5(K,j,$),W=W0(K.at(-1)??"");continue}K[K.length-1]+=j,W+=H}if(J.trim!==!1)K=K.map((z)=>qV(z));let G=K.join(`
4
+ `),U=!1;for(let z=0;z<G.length;z++){let j=G[z];if(q+=j,!U){if(U=j>="\uD800"&&j<="\uDBFF",U)continue}else U=!1;if(j===S8||j===W7){V7.lastIndex=z+1;let F=V7.exec(G)?.groups;if(F?.code!==void 0){let N=Number.parseFloat(F.code);Y=N===$V?void 0:N}else if(F?.uri!==void 0)V=F.uri.length===0?void 0:F.uri}if(G[z+1]===`
5
+ `){if(V)q+=G7("");let H=Y?X7(Y):void 0;if(Y&&H)q+=K7(H)}else if(j===`
6
+ `){if(Y&&X7(Y))q+=K7(Y);if(V)q+=G7(V)}}return q},VV;var q5=z0(()=>{e2();J5=`${JV}8;;`,V7=new RegExp(`(?:\\${U7}(?<code>\\d+)m|\\${J5}(?<uri>.*)${$5})`,"y"),VV=/\r?\n/});var V5=w((iF,Z7)=>{var Y5={to(Q,$){if(!$)return`\x1B[${Q+1}G`;return`\x1B[${$+1};${Q+1}H`},move(Q,$){let J="";if(Q<0)J+=`\x1B[${-Q}D`;else if(Q>0)J+=`\x1B[${Q}C`;if($<0)J+=`\x1B[${-$}A`;else if($>0)J+=`\x1B[${$}B`;return J},up:(Q=1)=>`\x1B[${Q}A`,down:(Q=1)=>`\x1B[${Q}B`,forward:(Q=1)=>`\x1B[${Q}C`,backward:(Q=1)=>`\x1B[${Q}D`,nextLine:(Q=1)=>"\x1B[E".repeat(Q),prevLine:(Q=1)=>"\x1B[F".repeat(Q),left:"\x1B[G",hide:"\x1B[?25l",show:"\x1B[?25h",save:"\x1B7",restore:"\x1B8"},XV={up:(Q=1)=>"\x1B[S".repeat(Q),down:(Q=1)=>"\x1B[T".repeat(Q)},KV={screen:"\x1B[2J",up:(Q=1)=>"\x1B[1J".repeat(Q),down:(Q=1)=>"\x1B[J".repeat(Q),line:"\x1B[2K",lineEnd:"\x1B[K",lineStart:"\x1B[1K",lines(Q){let $="";for(let J=0;J<Q;J++)$+=this.line+(J<Q-1?Y5.up():"");if(Q)$+=Y5.left;return $}};Z7.exports={cursor:Y5,scroll:XV,erase:KV,beep:"\x07"}});import{styleText as K5}from"node:util";import{stdout as U5,stdin as L7}from"node:process";import*as F1 from"node:readline";import GV from"node:readline";import{ReadStream as z7}from"node:tty";function Y1(Q,$,J){if(!J.some((X)=>!X.disabled))return Q;let q=Q+$,Y=Math.max(J.length-1,0),V=q<0?Y:q>Y?0:q;return J[V].disabled?Y1(V,$<0?-1:1,J):V}function k8(Q,$,J,q){let Y=q.split(`
7
+ `),V=0,X=Q;for(let W of Y){if(X<=W.length)break;X-=W.length+1,V++}for(V=Math.max(0,Math.min(Y.length-1,V+J)),X=Math.min(X,Y[V].length)+$;X<0&&V>0;)V--,X+=Y[V].length+1;for(;X>Y[V].length&&V<Y.length-1;)X-=Y[V].length+1,V++;X=Math.max(0,Math.min(Y[V].length,X));let K=0;for(let W=0;W<V;W++)K+=Y[W].length+1;return K+X}function j5(Q,$){if(typeof Q=="string")return n.aliases.get(Q)===$;for(let J of Q)if(J!==void 0&&j5(J,$))return!0;return!1}function jV(Q,$){if(Q===$)return;let J=Q.split(`
8
+ `),q=$.split(`
9
+ `),Y=Math.max(J.length,q.length),V=[];for(let X=0;X<Y;X++)J[X]!==q[X]&&V.push(X);return{lines:V,numLinesBefore:J.length,numLinesAfter:q.length,numLines:Y}}function L1(Q){return Q===G5}function y8(Q,$){let J=Q;J.isTTY&&J.setRawMode($)}function O7({input:Q=L7,output:$=U5,overwrite:J=!0,hideCursor:q=!0}={}){let Y=F1.createInterface({input:Q,output:$,prompt:"",tabSize:1});F1.emitKeypressEvents(Q,Y),Q instanceof z7&&Q.isTTY&&Q.setRawMode(!0);let V=(X,{name:K,sequence:W})=>{let G=String(X);if(j5([G,K,W],"cancel")){q&&$.write(X0.cursor.show),process.exit(0);return}if(!J)return;F1.moveCursor($,K==="return"?0:-1,K==="return"?-1:0,()=>{F1.clearLine($,1,()=>{Q.once("keypress",V)})})};return q&&$.write(X0.cursor.hide),Q.once("keypress",V),()=>{Q.off("keypress",V),q&&$.write(X0.cursor.show),Q instanceof z7&&Q.isTTY&&!ZV&&Q.setRawMode(!1),Y.terminal=!1,Y.close()}}function O1(Q,$,J,q=J,Y){let V=v6(Q??U5);return p0($,V-J.length,{hard:!0,trim:!1}).split(`
10
+ `).map((X,K)=>{let W=Y?Y(X,K):X;return`${K===0?q:J}${W}`}).join(`
11
+ `)}function zV(Q,$){if(Q===void 0||$.length===0)return 0;let J=$.findIndex((q)=>q.value===Q);return J!==-1?J:0}function HV(Q,$){return($.label??String($.value)).toLowerCase().includes(Q.toLowerCase())}function FV(Q,$){if($)return Q?$:$[0]}function H7(Q){return[...Q].map(($)=>OV[$])}function NV(Q){let $=new Intl.DateTimeFormat(Q,{year:"numeric",month:"2-digit",day:"2-digit"}).formatToParts(new Date(2000,0,15)),J=[],q="/";for(let Y of $)Y.type==="literal"?q=Y.value.trim()||Y.value:(Y.type==="year"||Y.type==="month"||Y.type==="day")&&J.push({type:Y.type,len:Y.type==="year"?4:2});return{segments:J,separator:q}}function X5(Q){return Number.parseInt((Q||"0").replace(/_/g,"0"),10)||0}function g8(Q){return{year:X5(Q.year),month:X5(Q.month),day:X5(Q.day)}}function W5(Q,$){return new Date(Q||2001,$||1,0).getDate()}function N7(Q){let{year:$,month:J,day:q}=g8(Q);if(!$||$<0||$>9999||!J||J<1||J>12||!q||q<1)return;let Y=new Date(Date.UTC($,J-1,q));if(!(Y.getUTCFullYear()!==$||Y.getUTCMonth()!==J-1||Y.getUTCDate()!==q))return{year:$,month:J,day:q}}function F7(Q){let $=N7(Q);return $?new Date(Date.UTC($.year,$.month-1,$.day)):void 0}function BV(Q,$,J,q){let Y=J?{year:J.getUTCFullYear(),month:J.getUTCMonth()+1,day:J.getUTCDate()}:null,V=q?{year:q.getUTCFullYear(),month:q.getUTCMonth()+1,day:q.getUTCDate()}:null;return Q==="year"?{min:Y?.year??1,max:V?.year??9999}:Q==="month"?{min:Y&&$.year===Y.year?Y.month:1,max:V&&$.year===V.year?V.month:12}:{min:Y&&$.year===Y.year&&$.month===Y.month?Y.day:1,max:V&&$.year===V.year&&$.month===V.month?V.day:W5($.year,$.month)}}var X0,WV,UV,n,ZV,G5,v6=(Q)=>("columns"in Q)&&typeof Q.columns=="number"?Q.columns:80,Z5=(Q)=>("rows"in Q)&&typeof Q.rows=="number"?Q.rows:20,y1=class{input;output;_abortSignal;rl;opts;_render;_track=!1;_prevFrame="";_subscribers=new Map;_cursor=0;state="initial";error="";value;userInput="";constructor(Q,$=!0){let{input:J=L7,output:q=U5,render:Y,signal:V,...X}=Q;this.opts=X,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=Y.bind(this),this._track=$,this._abortSignal=V,this.input=J,this.output=q}unsubscribe(){this._subscribers.clear()}setSubscriber(Q,$){let J=this._subscribers.get(Q)??[];J.push($),this._subscribers.set(Q,J)}on(Q,$){this.setSubscriber(Q,{cb:$})}once(Q,$){this.setSubscriber(Q,{cb:$,once:!0})}emit(Q,...$){let J=this._subscribers.get(Q)??[],q=[];for(let Y of J)Y.cb(...$),Y.once&&q.push(()=>J.splice(J.indexOf(Y),1));for(let Y of q)Y()}prompt(){return new Promise((Q)=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state="cancel",this.close(),Q(G5);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}this.rl=GV.createInterface({input:this.input,tabSize:2,prompt:"",escapeCodeTimeout:50,terminal:!0}),this.rl.prompt(),this.opts.initialUserInput!==void 0&&this._setUserInput(this.opts.initialUserInput,!0),this.input.on("keypress",this.onKeypress),y8(this.input,!0),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write(X0.cursor.show),this.output.off("resize",this.render),y8(this.input,!1),Q(this.value)}),this.once("cancel",()=>{this.output.write(X0.cursor.show),this.output.off("resize",this.render),y8(this.input,!1),Q(G5)})})}_isActionKey(Q,$){return Q==="\t"}_shouldSubmit(Q,$){return!0}_setValue(Q){this.value=Q,this.emit("value",this.value)}_setUserInput(Q,$){this.userInput=Q??"",this.emit("userInput",this.userInput),$&&this._track&&this.rl&&(this.rl.write(this.userInput),this._cursor=this.rl.cursor)}_clearUserInput(){this.rl?.write(null,{ctrl:!0,name:"u"}),this._setUserInput("")}onKeypress(Q,$){if(this._track&&$.name!=="return"&&($.name&&this._isActionKey(Q,$)&&this.rl?.write(null,{ctrl:!0,name:"h"}),this._cursor=this.rl?.cursor??0,this._setUserInput(this.rl?.line)),this.state==="error"&&(this.state="active"),$?.name&&(!this._track&&n.aliases.has($.name)&&this.emit("cursor",n.aliases.get($.name)),n.actions.has($.name)&&this.emit("cursor",$.name)),Q&&(Q.toLowerCase()==="y"||Q.toLowerCase()==="n")&&this.emit("confirm",Q.toLowerCase()==="y"),this.emit("key",Q?.toLowerCase(),$),$?.name==="return"&&this._shouldSubmit(Q,$)){if(this.opts.validate){let J=this.opts.validate(this.value);J&&(this.error=J instanceof Error?J.message:J,this.state="error",this.rl?.write(this.userInput))}this.state!=="error"&&(this.state="submit")}j5([Q,$?.name,$?.sequence],"cancel")&&(this.state="cancel"),(this.state==="submit"||this.state==="cancel")&&this.emit("finalize"),this.render(),(this.state==="submit"||this.state==="cancel")&&this.close()}close(){this.input.unpipe(),this.input.removeListener("keypress",this.onKeypress),this.output.write(`
12
+ `),y8(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let Q=p0(this._prevFrame,process.stdout.columns,{hard:!0,trim:!1}).split(`
13
+ `).length-1;this.output.write(X0.cursor.move(-999,Q*-1))}render(){let Q=p0(this._render(this)??"",process.stdout.columns,{hard:!0,trim:!1});if(Q!==this._prevFrame){if(this.state==="initial")this.output.write(X0.cursor.hide);else{let $=jV(this._prevFrame,Q),J=Z5(this.output);if(this.restoreCursor(),$){let q=Math.max(0,$.numLinesAfter-J),Y=Math.max(0,$.numLinesBefore-J),V=$.lines.find((X)=>X>=q);if(V===void 0){this._prevFrame=Q;return}if($.lines.length===1){this.output.write(X0.cursor.move(0,V-Y)),this.output.write(X0.erase.lines(1));let X=Q.split(`
14
+ `);this.output.write(X[V]),this._prevFrame=Q,this.output.write(X0.cursor.move(0,X.length-V-1));return}else if($.lines.length>1){if(q<Y)V=q;else{let K=V-Y;K>0&&this.output.write(X0.cursor.move(0,K))}this.output.write(X0.erase.down());let X=Q.split(`
15
+ `).slice(V);this.output.write(X.join(`
16
+ `)),this._prevFrame=Q;return}}this.output.write(X0.erase.down())}this.output.write(Q),this.state==="initial"&&(this.state="active"),this._prevFrame=Q}}},LV,z5,OV,B7,M7,P7,I7,H5;var F5=z0(()=>{q5();X0=u0(V5(),1);WV=["up","down","left","right","space","enter","cancel"],UV=["January","February","March","April","May","June","July","August","September","October","November","December"],n={actions:new Set(WV),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["\x03","cancel"],["escape","cancel"]]),messages:{cancel:"Canceled",error:"Something went wrong"},withGuide:!0,date:{monthNames:[...UV],messages:{required:"Please enter a valid date",invalidMonth:"There are only 12 months in a year",invalidDay:(Q,$)=>`There are only ${Q} days in ${$}`,afterMin:(Q)=>`Date must be on or after ${Q.toISOString().slice(0,10)}`,beforeMax:(Q)=>`Date must be on or before ${Q.toISOString().slice(0,10)}`}}};ZV=globalThis.process.platform.startsWith("win"),G5=Symbol("clack:cancel");LV=class extends y1{filteredOptions;multiple;isNavigating=!1;selectedValues=[];focusedValue;#$=0;#Y="";#Q;#V;#K;get cursor(){return this.#$}get userInputWithCursor(){if(!this.userInput)return K5(["inverse","hidden"],"_");if(this._cursor>=this.userInput.length)return`${this.userInput}█`;let Q=this.userInput.slice(0,this._cursor),[$,...J]=this.userInput.slice(this._cursor);return`${Q}${K5("inverse",$)}${J.join("")}`}get options(){return typeof this.#V=="function"?this.#V():this.#V}constructor(Q){super(Q),this.#V=Q.options,this.#K=Q.placeholder;let $=this.options;this.filteredOptions=[...$],this.multiple=Q.multiple===!0,this.#Q=typeof Q.options=="function"?Q.filter:Q.filter??HV;let J;if(Q.initialValue&&Array.isArray(Q.initialValue)?this.multiple?J=Q.initialValue:J=Q.initialValue.slice(0,1):!this.multiple&&this.options.length>0&&(J=[this.options[0].value]),J)for(let q of J){let Y=$.findIndex((V)=>V.value===q);Y!==-1&&(this.toggleSelected(q),this.#$=Y)}this.focusedValue=this.options[this.#$]?.value,this.on("key",(q,Y)=>this.#J(q,Y)),this.on("userInput",(q)=>this.#q(q))}_isActionKey(Q,$){return Q==="\t"||this.multiple&&this.isNavigating&&$.name==="space"&&Q!==void 0&&Q!==""}#J(Q,$){let J=$.name==="up",q=$.name==="down",Y=$.name==="return",V=this.userInput===""||this.userInput==="\t",X=this.#K,K=this.options,W=X!==void 0&&X!==""&&K.some((G)=>!G.disabled&&(this.#Q?this.#Q(X,G):!0));if($.name==="tab"&&V&&W){this.userInput==="\t"&&this._clearUserInput(),this._setUserInput(X,!0),this.isNavigating=!1;return}J||q?(this.#$=Y1(this.#$,J?-1:1,this.filteredOptions),this.focusedValue=this.filteredOptions[this.#$]?.value,this.multiple||(this.selectedValues=[this.focusedValue]),this.isNavigating=!0):Y?this.value=FV(this.multiple,this.selectedValues):this.multiple?this.focusedValue!==void 0&&($.name==="tab"||this.isNavigating&&$.name==="space")?this.toggleSelected(this.focusedValue):this.isNavigating=!1:(this.focusedValue&&(this.selectedValues=[this.focusedValue]),this.isNavigating=!1)}deselectAll(){this.selectedValues=[]}toggleSelected(Q){this.filteredOptions.length!==0&&(this.multiple?this.selectedValues.includes(Q)?this.selectedValues=this.selectedValues.filter(($)=>$!==Q):this.selectedValues=[...this.selectedValues,Q]:this.selectedValues=[Q])}#q(Q){if(Q!==this.#Y){this.#Y=Q;let $=this.options;Q&&this.#Q?this.filteredOptions=$.filter((Y)=>this.#Q?.(Q,Y)):this.filteredOptions=[...$];let J=zV(this.focusedValue,this.filteredOptions);this.#$=Y1(J,0,this.filteredOptions);let q=this.filteredOptions[this.#$];q&&!q.disabled?this.focusedValue=q.value:this.focusedValue=void 0,this.multiple||(this.focusedValue!==void 0?this.toggleSelected(this.focusedValue):this.deselectAll())}}};z5=class z5 extends y1{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor(Q){super(Q,!1),this.value=!!Q.initialValue,this.on("userInput",()=>{this.value=this._value}),this.on("confirm",($)=>{this.output.write(X0.cursor.move(0,-1)),this.value=$,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}};OV={Y:{type:"year",len:4},M:{type:"month",len:2},D:{type:"day",len:2}};B7=class B7 extends y1{#$;#Y;#Q;#V;#K;#J={segmentIndex:0,positionInSegment:0};#q=!0;#X=null;inlineError="";get segmentCursor(){return{...this.#J}}get segmentValues(){return{...this.#Q}}get segments(){return this.#$}get separator(){return this.#Y}get formattedValue(){return this.#j(this.#Q)}#j(Q){return this.#$.map(($)=>Q[$.type]).join(this.#Y)}#G(){this._setUserInput(this.#j(this.#Q)),this._setValue(F7(this.#Q)??void 0)}constructor(Q){let $=Q.format?{segments:H7(Q.format),separator:Q.separator??"/"}:NV(Q.locale),J=Q.separator??$.separator,q=Q.format?H7(Q.format):$.segments,Y=Q.initialValue??Q.defaultValue,V=Y?{year:String(Y.getUTCFullYear()).padStart(4,"0"),month:String(Y.getUTCMonth()+1).padStart(2,"0"),day:String(Y.getUTCDate()).padStart(2,"0")}:{year:"____",month:"__",day:"__"},X=q.map((K)=>V[K.type]).join(J);super({...Q,initialUserInput:X},!1),this.#$=q,this.#Y=J,this.#Q=V,this.#V=Q.minDate,this.#K=Q.maxDate,this.#G(),this.on("cursor",(K)=>this.#H(K)),this.on("key",(K,W)=>this.#F(K,W)),this.on("finalize",()=>this.#L(Q))}#W(){let Q=Math.max(0,Math.min(this.#J.segmentIndex,this.#$.length-1)),$=this.#$[Q];if($)return this.#J.positionInSegment=Math.max(0,Math.min(this.#J.positionInSegment,$.len-1)),{segment:$,index:Q}}#U(Q){this.inlineError="",this.#X=null;let $=this.#W();$&&(this.#J.segmentIndex=Math.max(0,Math.min(this.#$.length-1,$.index+Q)),this.#J.positionInSegment=0,this.#q=!0)}#Z(Q){let $=this.#W();if(!$)return;let{segment:J}=$,q=this.#Q[J.type],Y=!q||q.replace(/_/g,"")==="",V=Number.parseInt((q||"0").replace(/_/g,"0"),10)||0,X=BV(J.type,g8(this.#Q),this.#V,this.#K),K;Y?K=Q===1?X.min:X.max:K=Math.max(Math.min(X.max,V+Q),X.min),this.#Q={...this.#Q,[J.type]:K.toString().padStart(J.len,"0")},this.#q=!0,this.#X=null,this.#G()}#H(Q){if(Q)switch(Q){case"right":return this.#U(1);case"left":return this.#U(-1);case"up":return this.#Z(1);case"down":return this.#Z(-1)}}#F(Q,$){if($?.name==="backspace"||$?.sequence===""||$?.sequence==="\b"||Q===""||Q==="\b"){this.inlineError="";let J=this.#W();if(!J)return;if(!this.#Q[J.segment.type].replace(/_/g,"")){this.#U(-1);return}this.#Q[J.segment.type]="_".repeat(J.segment.len),this.#q=!0,this.#J.positionInSegment=0,this.#G();return}if($?.name==="tab"){this.inlineError="";let J=this.#W();if(!J)return;let q=$.shift?-1:1,Y=J.index+q;Y>=0&&Y<this.#$.length&&(this.#J.segmentIndex=Y,this.#J.positionInSegment=0,this.#q=!0);return}if(Q&&/^[0-9]$/.test(Q)){let J=this.#W();if(!J)return;let{segment:q}=J,Y=!this.#Q[q.type].replace(/_/g,"");if(this.#q&&this.#X!==null&&!Y){let j=this.#X+Q,H={...this.#Q,[q.type]:j},F=this.#z(H,q);if(F){this.inlineError=F,this.#X=null,this.#q=!1;return}this.inlineError="",this.#Q[q.type]=j,this.#X=null,this.#q=!1,this.#G(),J.index<this.#$.length-1&&(this.#J.segmentIndex=J.index+1,this.#J.positionInSegment=0,this.#q=!0);return}this.#q&&!Y&&(this.#Q[q.type]="_".repeat(q.len),this.#J.positionInSegment=0),this.#q=!1,this.#X=null;let V=this.#Q[q.type],X=V.indexOf("_"),K=X>=0?X:Math.min(this.#J.positionInSegment,q.len-1);if(K<0||K>=q.len)return;let W=V.slice(0,K)+Q+V.slice(K+1),G=!1;if(K===0&&V==="__"&&(q.type==="month"||q.type==="day")){let j=Number.parseInt(Q,10);W=`0${Q}`,G=j<=(q.type==="month"?1:2)}if(q.type==="year"&&(W=(V.replace(/_/g,"")+Q).padStart(q.len,"_")),!W.includes("_")){let j={...this.#Q,[q.type]:W},H=this.#z(j,q);if(H){this.inlineError=H;return}}this.inlineError="",this.#Q[q.type]=W;let U=W.includes("_")?void 0:N7(this.#Q);if(U){let{year:j,month:H}=U,F=W5(j,H);this.#Q={year:String(Math.max(0,Math.min(9999,j))).padStart(4,"0"),month:String(Math.max(1,Math.min(12,H))).padStart(2,"0"),day:String(Math.max(1,Math.min(F,U.day))).padStart(2,"0")}}this.#G();let z=W.indexOf("_");G?(this.#q=!0,this.#X=Q):z>=0?this.#J.positionInSegment=z:X>=0&&J.index<this.#$.length-1?(this.#J.segmentIndex=J.index+1,this.#J.positionInSegment=0,this.#q=!0):this.#J.positionInSegment=Math.min(K+1,q.len-1)}}#z(Q,$){let{month:J,day:q}=g8(Q);if($.type==="month"&&(J<0||J>12))return n.date.messages.invalidMonth;if($.type==="day"&&(q<0||q>31))return n.date.messages.invalidDay(31,"any month")}#L(Q){let{year:$,month:J,day:q}=g8(this.#Q);if($&&J&&q){let Y=W5($,J);this.#Q={...this.#Q,day:String(Math.min(q,Y)).padStart(2,"0")}}this.value=F7(this.#Q)??Q.defaultValue??void 0}};M7=class M7 extends y1{options;cursor=0;#$;getGroupItems(Q){return this.options.filter(($)=>$.group===Q)}isGroupSelected(Q){let $=this.getGroupItems(Q),J=this.value;return J===void 0?!1:$.every((q)=>J.includes(q.value))}toggleValue(){let Q=this.options[this.cursor];if(this.value===void 0&&(this.value=[]),Q.group===!0){let $=Q.value,J=this.getGroupItems($);this.isGroupSelected($)?this.value=this.value.filter((q)=>J.findIndex((Y)=>Y.value===q)===-1):this.value=[...this.value,...J.map((q)=>q.value)],this.value=Array.from(new Set(this.value))}else{let $=this.value.includes(Q.value);this.value=$?this.value.filter((J)=>J!==Q.value):[...this.value,Q.value]}}constructor(Q){super(Q,!1);let{options:$}=Q;this.#$=Q.selectableGroups!==!1,this.options=Object.entries($).flatMap(([J,q])=>[{value:J,group:!0,label:J},...q.map((Y)=>({...Y,group:J}))]),this.value=[...Q.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:J})=>J===Q.cursorAt),this.#$?0:1),this.on("cursor",(J)=>{switch(J){case"left":case"up":{this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;let q=this.options[this.cursor]?.group===!0;!this.#$&&q&&(this.cursor=this.cursor===0?this.options.length-1:this.cursor-1);break}case"down":case"right":{this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;let q=this.options[this.cursor]?.group===!0;!this.#$&&q&&(this.cursor=this.cursor===this.options.length-1?0:this.cursor+1);break}case"space":this.toggleValue();break}})}};P7=class P7 extends y1{#$=!1;#Y;focused="editor";get userInputWithCursor(){if(this.state==="submit")return this.userInput;let Q=this.userInput;if(this.cursor>=Q.length)return`${Q}█`;let $=Q.slice(0,this.cursor),J=Q[this.cursor],q=Q.slice(this.cursor+1);return J===`
17
+ `?`${$}█
18
+ ${q}`:`${$}${K5("inverse",J)}${q}`}get cursor(){return this._cursor}#Q(Q){if(this.userInput.length===0){this._setUserInput(Q);return}this._setUserInput(this.userInput.slice(0,this.cursor)+Q+this.userInput.slice(this.cursor))}#V(Q){let $=this.value??"";switch(Q){case"up":this._cursor=k8(this._cursor,0,-1,$);return;case"down":this._cursor=k8(this._cursor,0,1,$);return;case"left":this._cursor=k8(this._cursor,-1,0,$);return;case"right":this._cursor=k8(this._cursor,1,0,$);return}}_shouldSubmit(Q,$){if(this.#Y)return this.focused==="submit"?!0:(this.#Q(`
19
+ `),this._cursor++,!1);let J=this.#$;return this.#$=!0,J?(this.userInput[this.cursor-1]===`
20
+ `&&(this._setUserInput(this.userInput.slice(0,this.cursor-1)+this.userInput.slice(this.cursor)),this._cursor--),!0):(this.#Q(`
21
+ `),this._cursor++,!1)}constructor(Q){super(Q,!1),this.#Y=Q.showSubmit??!1,this.on("key",($,J)=>{if(J?.name&&n.actions.has(J.name)){this.#V(J.name);return}if($==="\t"&&this.#Y){this.focused=this.focused==="editor"?"submit":"editor";return}if(J?.name!=="return"){if(this.#$=!1,J?.name==="backspace"&&this.cursor>0){this._setUserInput(this.userInput.slice(0,this.cursor-1)+this.userInput.slice(this.cursor)),this._cursor--;return}if(J?.name==="delete"&&this.cursor<this.userInput.length){this._setUserInput(this.userInput.slice(0,this.cursor)+this.userInput.slice(this.cursor+1));return}$&&(this.#Y&&this.focused==="submit"&&(this.focused="editor"),this.#Q($??""),this._cursor++)}}),this.on("userInput",($)=>{this._setValue($)}),this.on("finalize",()=>{this.value||(this.value=Q.defaultValue),this.value===void 0&&(this.value="")})}};I7=class extends y1{options;cursor=0;get _value(){return this.options[this.cursor].value}get _enabledOptions(){return this.options.filter((Q)=>Q.disabled!==!0)}toggleAll(){let Q=this._enabledOptions,$=this.value!==void 0&&this.value.length===Q.length;this.value=$?[]:Q.map((J)=>J.value)}toggleInvert(){let Q=this.value;if(!Q)return;let $=this._enabledOptions.filter((J)=>!Q.includes(J.value));this.value=$.map((J)=>J.value)}toggleValue(){this.value===void 0&&(this.value=[]);let Q=this.value.includes(this._value);this.value=Q?this.value.filter(($)=>$!==this._value):[...this.value,this._value]}constructor(Q){super(Q,!1),this.options=Q.options,this.value=[...Q.initialValues??[]];let $=Math.max(this.options.findIndex(({value:J})=>J===Q.cursorAt),0);this.cursor=this.options[$].disabled?Y1($,1,this.options):$,this.on("key",(J)=>{J==="a"&&this.toggleAll(),J==="i"&&this.toggleInvert()}),this.on("cursor",(J)=>{switch(J){case"left":case"up":this.cursor=Y1(this.cursor,-1,this.options);break;case"down":case"right":this.cursor=Y1(this.cursor,1,this.options);break;case"space":this.toggleValue();break}})}};H5=class H5 extends y1{options;cursor=0;get _selectedValue(){return this.options[this.cursor]}changeValue(){this.value=this._selectedValue.value}constructor(Q){super(Q,!1),this.options=Q.options;let $=this.options.findIndex(({value:q})=>q===Q.initialValue),J=$===-1?0:$;this.cursor=this.options[J].disabled?Y1(J,1,this.options):J,this.changeValue(),this.on("cursor",(q)=>{switch(q){case"left":case"up":this.cursor=Y1(this.cursor,-1,this.options);break;case"down":case"right":this.cursor=Y1(this.cursor,1,this.options);break}this.changeValue()})}}});import{styleText as I,stripVTControlCharacters as WL}from"node:util";import C0 from"node:process";function MV(){return C0.platform!=="win32"?C0.env.TERM!=="linux":!!C0.env.CI||!!C0.env.WT_SESSION||!!C0.env.TERMINUS_SUBLIME||C0.env.ConEmuTask==="{cmd::Cmder}"||C0.env.TERM_PROGRAM==="Terminus-Sublime"||C0.env.TERM_PROGRAM==="vscode"||C0.env.TERM==="xterm-256color"||C0.env.TERM==="alacritty"||C0.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var S6,L5,PV=()=>process.env.CI==="true",b=(Q,$)=>L5?Q:$,IV,D7,w7,h8,TV,y,r1,zL,HL,O5,b8,CV,T7,C7,FL,A7,AV,DV,wV,RV,LL,xV,vV,EV,SV,B5=(Q)=>{switch(Q){case"initial":case"active":return I("cyan",IV);case"cancel":return I("red",D7);case"error":return I("yellow",w7);case"submit":return I("green",h8)}},R7=(Q)=>{switch(Q){case"initial":case"active":return I("cyan",y);case"cancel":return I("red",y);case"error":return I("yellow",y);case"submit":return I("green",y)}},kV=(Q,$,J,q,Y)=>{let V=$,X=0;for(let K=J;K<q;K++){let W=Q[K];if(V=V-W.length,X++,V<=Y)break}return{lineCount:V,removals:X}},N5=({cursor:Q,options:$,style:J,output:q=process.stdout,maxItems:Y=Number.POSITIVE_INFINITY,columnPadding:V=0,rowPadding:X=4})=>{let K=v6(q)-V,W=Z5(q),G=I("dim","..."),U=Math.max(W-X,0),z=Math.max(Math.min(Y,U),5),j=0;Q>=z-3&&(j=Math.max(Math.min(Q-z+3,$.length-z),0));let H=z<$.length&&j>0,F=z<$.length&&j+z<$.length,N=Math.min(j+z,$.length),T=[],P=0;H&&P++,F&&P++;let L=j+(H?1:0),A=N-(F?1:0);for(let O=L;O<A;O++){let M=p0(J($[O],O===Q),K,{hard:!0,trim:!1}).split(`
22
+ `);T.push(M),P+=M.length}if(P>U){let O=0,M=0,C=P,D=Q-L,x=(v,R)=>kV(T,C,v,R,U);H?({lineCount:C,removals:O}=x(0,D),C>U&&({lineCount:C,removals:M}=x(D+1,T.length))):({lineCount:C,removals:M}=x(D+1,T.length),C>U&&({lineCount:C,removals:O}=x(0,D))),O>0&&(H=!0,T.splice(0,O)),M>0&&(F=!0,T.splice(T.length-M,M))}let B=[];H&&B.push(G);for(let O of T)for(let M of O)B.push(M);return F&&B.push(G),B},f8=(Q)=>{let $=Q.active??"Yes",J=Q.inactive??"No";return new z5({active:$,inactive:J,signal:Q.signal,input:Q.input,output:Q.output,initialValue:Q.initialValue??!0,render(){let q=Q.withGuide??n.withGuide,Y=`${B5(this.state)} `,V=q?`${I("gray",y)} `:"",X=O1(Q.output,Q.message,V,Y),K=`${q?`${I("gray",y)}
23
+ `:""}${X}
24
+ `,W=this.value?$:J;switch(this.state){case"submit":{let G=q?`${I("gray",y)} `:"";return`${K}${G}${I("dim",W)}`}case"cancel":{let G=q?`${I("gray",y)} `:"";return`${K}${G}${I(["strikethrough","dim"],W)}${q?`
25
+ ${I("gray",y)}`:""}`}default:{let G=q?`${I("cyan",y)} `:"",U=q?I("cyan",r1):"";return`${K}${G}${this.value?`${I("green",O5)} ${$}`:`${I("dim",b8)} ${I("dim",$)}`}${Q.vertical?q?`
26
+ ${I("cyan",y)} `:`
27
+ `:` ${I("dim","/")} `}${this.value?`${I("dim",b8)} ${I("dim",J)}`:`${I("green",O5)} ${J}`}
28
+ ${U}
29
+ `}}}}).prompt()},o,r=(Q="",$)=>{let J=$?.output??process.stdout,q=$?.withGuide??n.withGuide?`${I("gray",r1)} `:"";J.write(`${q}${I("red",Q)}
30
+
31
+ `)},A0=(Q="",$)=>{let J=$?.output??process.stdout,q=$?.withGuide??n.withGuide?`${I("gray",TV)} `:"";J.write(`${q}${Q}
32
+ `)},D0=(Q="",$)=>{let J=$?.output??process.stdout,q=$?.withGuide??n.withGuide?`${I("gray",y)}
33
+ ${I("gray",r1)} `:"";J.write(`${q}${Q}
34
+
35
+ `)},E6=(Q,$)=>Q.split(`
36
+ `).map((J)=>$(J)).join(`
37
+ `),x7=(Q)=>{let $=(q,Y)=>{let V=q.label??String(q.value);return Y==="disabled"?`${I("gray",C7)} ${E6(V,(X)=>I(["strikethrough","gray"],X))}${q.hint?` ${I("dim",`(${q.hint??"disabled"})`)}`:""}`:Y==="active"?`${I("cyan",CV)} ${V}${q.hint?` ${I("dim",`(${q.hint})`)}`:""}`:Y==="selected"?`${I("green",T7)} ${E6(V,(X)=>I("dim",X))}${q.hint?` ${I("dim",`(${q.hint})`)}`:""}`:Y==="cancelled"?`${E6(V,(X)=>I(["strikethrough","dim"],X))}`:Y==="active-selected"?`${I("green",T7)} ${V}${q.hint?` ${I("dim",`(${q.hint})`)}`:""}`:Y==="submitted"?`${E6(V,(X)=>I("dim",X))}`:`${I("dim",C7)} ${E6(V,(X)=>I("dim",X))}`},J=Q.required??!0;return new I7({options:Q.options,signal:Q.signal,input:Q.input,output:Q.output,initialValues:Q.initialValues,required:J,cursorAt:Q.cursorAt,validate(q){if(J&&(q===void 0||q.length===0))return`Please select at least one option.
38
+ ${I("reset",I("dim",`Press ${I(["gray","bgWhite","inverse"]," space ")} to select, ${I("gray",I("bgWhite",I("inverse"," enter ")))} to submit`))}`},render(){let q=Q.withGuide??n.withGuide,Y=O1(Q.output,Q.message,q?`${R7(this.state)} `:"",`${B5(this.state)} `),V=`${q?`${I("gray",y)}
39
+ `:""}${Y}
40
+ `,X=this.value??[],K=(W,G)=>{if(W.disabled)return $(W,"disabled");let U=X.includes(W.value);return G&&U?$(W,"active-selected"):U?$(W,"selected"):$(W,G?"active":"inactive")};switch(this.state){case"submit":{let W=this.options.filter(({value:U})=>X.includes(U)).map((U)=>$(U,"submitted")).join(I("dim",", "))||I("dim","none"),G=O1(Q.output,W,q?`${I("gray",y)} `:"");return`${V}${G}`}case"cancel":{let W=this.options.filter(({value:U})=>X.includes(U)).map((U)=>$(U,"cancelled")).join(I("dim",", "));if(W.trim()==="")return`${V}${I("gray",y)}`;let G=O1(Q.output,W,q?`${I("gray",y)} `:"");return`${V}${G}${q?`
41
+ ${I("gray",y)}`:""}`}case"error":{let W=q?`${I("yellow",y)} `:"",G=this.error.split(`
42
+ `).map((j,H)=>H===0?`${q?`${I("yellow",r1)} `:""}${I("yellow",j)}`:` ${j}`).join(`
43
+ `),U=V.split(`
44
+ `).length,z=G.split(`
45
+ `).length+1;return`${V}${W}${N5({output:Q.output,options:this.options,cursor:this.cursor,maxItems:Q.maxItems,columnPadding:W.length,rowPadding:U+z,style:K}).join(`
46
+ ${W}`)}
47
+ ${G}
48
+ `}default:{let W=q?`${I("cyan",y)} `:"",G=V.split(`
49
+ `).length,U=q?2:1;return`${V}${W}${N5({output:Q.output,options:this.options,cursor:this.cursor,maxItems:Q.maxItems,columnPadding:W.length,rowPadding:G+U,style:K}).join(`
50
+ ${W}`)}
51
+ ${q?I("cyan",r1):""}
52
+ `}}}}).prompt()},yV=(Q)=>I("dim",Q),gV=(Q,$,J)=>{let q={hard:!0,trim:!1},Y=p0(Q,$,q).split(`
53
+ `),V=Y.reduce((W,G)=>Math.max(W0(G),W),0),X=Y.map(J).reduce((W,G)=>Math.max(W0(G),W),0),K=$-(X-V);return p0(Q,K,q)},_0=(Q="",$="",J)=>{let q=J?.output??C0.stdout,Y=J?.withGuide??n.withGuide,V=J?.format??yV,X=["",...gV(Q,v6(q)-6,V).split(`
54
+ `).map(V),""],K=W0($),W=Math.max(X.reduce((j,H)=>{let F=W0(H);return F>j?F:j},0),K)+2,G=X.map((j)=>`${I("gray",y)} ${j}${" ".repeat(W-W0(j))}${I("gray",y)}`).join(`
55
+ `),U=Y?`${I("gray",y)}
56
+ `:"",z=Y?DV:RV;q.write(`${U}${I("green",h8)} ${I("reset",$)} ${I("gray",A7.repeat(Math.max(W-K-1,1))+AV)}
57
+ ${G}
58
+ ${I("gray",z+A7.repeat(W+2)+wV)}
59
+ `)},_V=(Q)=>I("magenta",Q),H0=({indicator:Q="dots",onCancel:$,output:J=process.stdout,cancelMessage:q,errorMessage:Y,frames:V=L5?["◒","◐","◓","◑"]:["•","o","O","0"],delay:X=L5?80:120,signal:K,...W}={})=>{let G=PV(),U,z,j=!1,H=!1,F="",N,T=performance.now(),P=v6(J),L=W?.styleFrame??_V,A=(h)=>{let G0=h>1?Y??n.messages.error:q??n.messages.cancel;H=h===1,j&&(I0(G0,h),H&&typeof $=="function"&&$())},B=()=>A(2),O=()=>A(1),M=()=>{process.on("uncaughtExceptionMonitor",B),process.on("unhandledRejection",B),process.on("SIGINT",O),process.on("SIGTERM",O),process.on("exit",A),K&&K.addEventListener("abort",O)},C=()=>{process.removeListener("uncaughtExceptionMonitor",B),process.removeListener("unhandledRejection",B),process.removeListener("SIGINT",O),process.removeListener("SIGTERM",O),process.removeListener("exit",A),K&&K.removeEventListener("abort",O)},D=()=>{if(N===void 0)return;G&&J.write(`
60
+ `);let h=p0(N,P,{hard:!0,trim:!1}).split(`
61
+ `);h.length>1&&J.write(S6.cursor.up(h.length-1)),J.write(S6.cursor.to(0)),J.write(S6.erase.down())},x=(h)=>h.replace(/\.+$/,""),v=(h)=>{let G0=(performance.now()-h)/1000,T0=Math.floor(G0/60),Z0=Math.floor(G0%60);return T0>0?`[${T0}m ${Z0}s]`:`[${Z0}s]`},R=W.withGuide??n.withGuide,$0=(h="")=>{j=!0,U=O7({output:J}),F=x(h),T=performance.now(),R&&J.write(`${I("gray",y)}
62
+ `);let G0=0,T0=0;M(),z=setInterval(()=>{if(G&&F===N)return;D(),N=F;let Z0=L(V[G0]),q1;if(G)q1=`${Z0} ${F}...`;else if(Q==="timer")q1=`${Z0} ${F} ${v(T)}`;else{let _3=".".repeat(Math.floor(T0)).slice(0,3);q1=`${Z0} ${F}${_3}`}let g3=p0(q1,P,{hard:!0,trim:!1});J.write(g3),G0=G0+1<V.length?G0+1:0,T0=T0<4?T0+0.125:0},X)},I0=(h="",G0=0,T0=!1)=>{if(!j)return;j=!1,clearInterval(z),D();let Z0=G0===0?I("green",h8):G0===1?I("red",D7):I("red",w7);F=h??F,T0||(Q==="timer"?J.write(`${Z0} ${F} ${v(T)}
63
+ `):J.write(`${Z0} ${F}
64
+ `)),C(),U()};return{start:$0,stop:(h="")=>I0(h,0),message:(h="")=>{F=x(h??F)},cancel:(h="")=>I0(h,1),error:(h="")=>I0(h,2),clear:()=>I0("",0,!0),get isCancelled(){return H}}},OL,_8=(Q,$)=>Q.includes(`
65
+ `)?Q.split(`
66
+ `).map((J)=>$(J)).join(`
67
+ `):$(Q),v7=(Q)=>{let $=(J,q)=>{let Y=J.label??String(J.value);switch(q){case"disabled":return`${I("gray",b8)} ${_8(Y,(V)=>I("gray",V))}${J.hint?` ${I("dim",`(${J.hint??"disabled"})`)}`:""}`;case"selected":return`${_8(Y,(V)=>I("dim",V))}`;case"active":return`${I("green",O5)} ${Y}${J.hint?` ${I("dim",`(${J.hint})`)}`:""}`;case"cancelled":return`${_8(Y,(V)=>I(["strikethrough","dim"],V))}`;default:return`${I("dim",b8)} ${_8(Y,(V)=>I("dim",V))}`}};return new H5({options:Q.options,signal:Q.signal,input:Q.input,output:Q.output,initialValue:Q.initialValue,render(){let J=Q.withGuide??n.withGuide,q=`${B5(this.state)} `,Y=`${R7(this.state)} `,V=O1(Q.output,Q.message,Y,q),X=`${J?`${I("gray",y)}
68
+ `:""}${V}
69
+ `;switch(this.state){case"submit":{let K=J?`${I("gray",y)} `:"",W=O1(Q.output,$(this.options[this.cursor],"selected"),K);return`${X}${W}`}case"cancel":{let K=J?`${I("gray",y)} `:"",W=O1(Q.output,$(this.options[this.cursor],"cancelled"),K);return`${X}${W}${J?`
70
+ ${I("gray",y)}`:""}`}default:{let K=J?`${I("cyan",y)} `:"",W=J?I("cyan",r1):"",G=X.split(`
71
+ `).length,U=J?2:1;return`${X}${K}${N5({output:Q.output,cursor:this.cursor,options:this.options,maxItems:Q.maxItems,columnPadding:K.length,rowPadding:G+U,style:(z,j)=>$(z,z.disabled?"disabled":j?"active":"inactive")}).join(`
72
+ ${K}`)}
73
+ ${W}
74
+ `}}}}).prompt()},NL;var a1=z0(()=>{F5();F5();q5();e2();S6=u0(V5(),1);L5=MV(),IV=b("◆","*"),D7=b("■","x"),w7=b("▲","x"),h8=b("◇","o"),TV=b("┌","T"),y=b("│","|"),r1=b("└","—"),zL=b("┐","T"),HL=b("┘","—"),O5=b("●",">"),b8=b("○"," "),CV=b("◻","[•]"),T7=b("◼","[+]"),C7=b("◻","[ ]"),FL=b("▪","•"),A7=b("─","-"),AV=b("╮","+"),DV=b("├","+"),wV=b("╯","+"),RV=b("╰","+"),LL=b("╭","+"),xV=b("●","•"),vV=b("◆","*"),EV=b("▲","!"),SV=b("■","x"),o={message:(Q=[],{symbol:$=I("gray",y),secondarySymbol:J=I("gray",y),output:q=process.stdout,spacing:Y=1,withGuide:V}={})=>{let X=[],K=V??n.withGuide,W=K?J:"",G=K?`${$} `:"",U=K?`${J} `:"";for(let j=0;j<Y;j++)X.push(W);let z=Array.isArray(Q)?Q:Q.split(`
75
+ `);if(z.length>0){let[j,...H]=z;j.length>0?X.push(`${G}${j}`):X.push(K?$:"");for(let F of H)F.length>0?X.push(`${U}${F}`):X.push(K?J:"")}q.write(`${X.join(`
59
76
  `)}
60
- `)},info:($)=>{u.message($,{symbol:B.default.blue(v4)})},success:($)=>{u.message($,{symbol:B.default.green(x4)})},step:($)=>{u.message($,{symbol:B.default.green(O6)})},warn:($)=>{u.message($,{symbol:B.default.yellow(S4)})},warning:($)=>{u.warn($)},error:($)=>{u.message($,{symbol:B.default.red(E4)})}},vH=`${B.default.gray(k)} `});var z$=T((SH,n8)=>{if(typeof process>"u"||!process.version||process.version.indexOf("v0.")===0||process.version.indexOf("v1.")===0&&process.version.indexOf("v1.8.")!==0)n8.exports={nextTick:y4};else n8.exports=process;function y4($,Q,q,V){if(typeof $!=="function")throw TypeError('"callback" argument must be a function');var Y=arguments.length,X,J;switch(Y){case 0:case 1:return process.nextTick($);case 2:return process.nextTick(function(){$.call(null,Q)});case 3:return process.nextTick(function(){$.call(null,Q,q)});case 4:return process.nextTick(function(){$.call(null,Q,q,V)});default:X=Array(Y-1),J=0;while(J<X.length)X[J++]=arguments[J];return process.nextTick(function(){$.apply(null,X)})}}});var bq=T((EH,_q)=>{var k4={}.toString;_q.exports=Array.isArray||function($){return k4.call($)=="[object Array]"}});var H$=T((r8,mq)=>{var B6=b("buffer"),l1=B6.Buffer;function fq($,Q){for(var q in $)Q[q]=$[q]}if(l1.from&&l1.alloc&&l1.allocUnsafe&&l1.allocUnsafeSlow)mq.exports=B6;else fq(B6,r8),r8.Buffer=k0;function k0($,Q,q){return l1($,Q,q)}fq(l1,k0);k0.from=function($,Q,q){if(typeof $==="number")throw TypeError("Argument must not be a number");return l1($,Q,q)};k0.alloc=function($,Q,q){if(typeof $!=="number")throw TypeError("Argument must be a number");var V=l1($);if(Q!==void 0)if(typeof q==="string")V.fill(Q,q);else V.fill(Q);else V.fill(0);return V};k0.allocUnsafe=function($){if(typeof $!=="number")throw TypeError("Argument must be a number");return l1($)};k0.allocUnsafeSlow=function($){if(typeof $!=="number")throw TypeError("Argument must be a number");return B6.SlowBuffer($)}});var g0=T((n4)=>{function g4($){if(Array.isArray)return Array.isArray($);return N6($)==="[object Array]"}n4.isArray=g4;function D4($){return typeof $==="boolean"}n4.isBoolean=D4;function h4($){return $===null}n4.isNull=h4;function _4($){return $==null}n4.isNullOrUndefined=_4;function b4($){return typeof $==="number"}n4.isNumber=b4;function f4($){return typeof $==="string"}n4.isString=f4;function m4($){return typeof $==="symbol"}n4.isSymbol=m4;function c4($){return $===void 0}n4.isUndefined=c4;function p4($){return N6($)==="[object RegExp]"}n4.isRegExp=p4;function u4($){return typeof $==="object"&&$!==null}n4.isObject=u4;function d4($){return N6($)==="[object Date]"}n4.isDate=d4;function l4($){return N6($)==="[object Error]"||$ instanceof Error}n4.isError=l4;function o4($){return typeof $==="function"}n4.isFunction=o4;function i4($){return $===null||typeof $==="boolean"||typeof $==="number"||typeof $==="string"||typeof $==="symbol"||typeof $>"u"}n4.isPrimitive=i4;n4.isBuffer=b("buffer").Buffer.isBuffer;function N6($){return Object.prototype.toString.call($)}});var cq=T((kH,a8)=>{if(typeof Object.create==="function")a8.exports=function(Q,q){if(q)Q.super_=q,Q.prototype=Object.create(q.prototype,{constructor:{value:Q,enumerable:!1,writable:!0,configurable:!0}})};else a8.exports=function(Q,q){if(q){Q.super_=q;var V=function(){};V.prototype=q.prototype,Q.prototype=new V,Q.prototype.constructor=Q}}});var D0=T((gH,s8)=>{try{if(I6=b("util"),typeof I6.inherits!=="function")throw"";s8.exports=I6.inherits}catch($){s8.exports=cq()}var I6});var uq=T((DH,t8)=>{function UX($,Q){if(!($ instanceof Q))throw TypeError("Cannot call a class as a function")}var pq=H$().Buffer,L$=b("util");function jX($,Q,q){$.copy(Q,q)}t8.exports=function(){function $(){UX(this,$),this.head=null,this.tail=null,this.length=0}return $.prototype.push=function(q){var V={data:q,next:null};if(this.length>0)this.tail.next=V;else this.head=V;this.tail=V,++this.length},$.prototype.unshift=function(q){var V={data:q,next:this.head};if(this.length===0)this.tail=V;this.head=V,++this.length},$.prototype.shift=function(){if(this.length===0)return;var q=this.head.data;if(this.length===1)this.head=this.tail=null;else this.head=this.head.next;return--this.length,q},$.prototype.clear=function(){this.head=this.tail=null,this.length=0},$.prototype.join=function(q){if(this.length===0)return"";var V=this.head,Y=""+V.data;while(V=V.next)Y+=q+V.data;return Y},$.prototype.concat=function(q){if(this.length===0)return pq.alloc(0);var V=pq.allocUnsafe(q>>>0),Y=this.head,X=0;while(Y)jX(Y.data,V,X),X+=Y.data.length,Y=Y.next;return V},$}();if(L$&&L$.inspect&&L$.inspect.custom)t8.exports.prototype[L$.inspect.custom]=function(){var $=L$.inspect({length:this.length});return this.constructor.name+" "+$}});var e8=T((hH,dq)=>{var C6=z$();function ZX($,Q){var q=this,V=this._readableState&&this._readableState.destroyed,Y=this._writableState&&this._writableState.destroyed;if(V||Y){if(Q)Q($);else if($){if(!this._writableState)C6.nextTick(w6,this,$);else if(!this._writableState.errorEmitted)this._writableState.errorEmitted=!0,C6.nextTick(w6,this,$)}return this}if(this._readableState)this._readableState.destroyed=!0;if(this._writableState)this._writableState.destroyed=!0;return this._destroy($||null,function(X){if(!Q&&X){if(!q._writableState)C6.nextTick(w6,q,X);else if(!q._writableState.errorEmitted)q._writableState.errorEmitted=!0,C6.nextTick(w6,q,X)}else if(Q)Q(X)}),this}function zX(){if(this._readableState)this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1;if(this._writableState)this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1}function w6($,Q){$.emit("error",Q)}dq.exports={destroy:ZX,undestroy:zX}});var oq=T((_H,lq)=>{lq.exports=b("util").deprecate});var Q5=T((bH,$V)=>{var L0=z$();$V.exports=o;function nq($){var Q=this;this.next=null,this.entry=null,this.finish=function(){EX(Q,$)}}var HX=["v0.10","v0.9."].indexOf(process.version.slice(0,5))>-1?setImmediate:L0.nextTick,h0;o.WritableState=O$;var rq=Object.create(g0());rq.inherits=D0();var LX={deprecate:oq()},aq=b("stream"),A6=H$().Buffer,PX=(typeof global<"u"?global:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function OX($){return A6.from($)}function MX($){return A6.isBuffer($)||$ instanceof PX}var sq=e8();rq.inherits(o,aq);function BX(){}function O$($,Q){h0=h0||P0(),$=$||{};var q=Q instanceof h0;if(this.objectMode=!!$.objectMode,q)this.objectMode=this.objectMode||!!$.writableObjectMode;var{highWaterMark:V,writableHighWaterMark:Y}=$,X=this.objectMode?16:16384;if(V||V===0)this.highWaterMark=V;else if(q&&(Y||Y===0))this.highWaterMark=Y;else this.highWaterMark=X;this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var J=$.decodeStrings===!1;this.decodeStrings=!J,this.defaultEncoding=$.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(G){FX(Q,G)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new nq(this)}O$.prototype.getBuffer=function(){var Q=this.bufferedRequest,q=[];while(Q)q.push(Q),Q=Q.next;return q};(function(){try{Object.defineProperty(O$.prototype,"buffer",{get:LX.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch($){}})();var T6;if(typeof Symbol==="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]==="function")T6=Function.prototype[Symbol.hasInstance],Object.defineProperty(o,Symbol.hasInstance,{value:function($){if(T6.call(this,$))return!0;if(this!==o)return!1;return $&&$._writableState instanceof O$}});else T6=function($){return $ instanceof this};function o($){if(h0=h0||P0(),!T6.call(o,this)&&!(this instanceof h0))return new o($);if(this._writableState=new O$($,this),this.writable=!0,$){if(typeof $.write==="function")this._write=$.write;if(typeof $.writev==="function")this._writev=$.writev;if(typeof $.destroy==="function")this._destroy=$.destroy;if(typeof $.final==="function")this._final=$.final}aq.call(this)}o.prototype.pipe=function(){this.emit("error",Error("Cannot pipe, not readable"))};function NX($,Q){var q=Error("write after end");$.emit("error",q),L0.nextTick(Q,q)}function IX($,Q,q,V){var Y=!0,X=!1;if(q===null)X=TypeError("May not write null values to stream");else if(typeof q!=="string"&&q!==void 0&&!Q.objectMode)X=TypeError("Invalid non-string/buffer chunk");if(X)$.emit("error",X),L0.nextTick(V,X),Y=!1;return Y}o.prototype.write=function($,Q,q){var V=this._writableState,Y=!1,X=!V.objectMode&&MX($);if(X&&!A6.isBuffer($))$=OX($);if(typeof Q==="function")q=Q,Q=null;if(X)Q="buffer";else if(!Q)Q=V.defaultEncoding;if(typeof q!=="function")q=BX;if(V.ended)NX(this,q);else if(X||IX(this,V,$,q))V.pendingcb++,Y=wX(this,V,X,$,Q,q);return Y};o.prototype.cork=function(){var $=this._writableState;$.corked++};o.prototype.uncork=function(){var $=this._writableState;if($.corked){if($.corked--,!$.writing&&!$.corked&&!$.bufferProcessing&&$.bufferedRequest)tq(this,$)}};o.prototype.setDefaultEncoding=function(Q){if(typeof Q==="string")Q=Q.toLowerCase();if(!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((Q+"").toLowerCase())>-1))throw TypeError("Unknown encoding: "+Q);return this._writableState.defaultEncoding=Q,this};function CX($,Q,q){if(!$.objectMode&&$.decodeStrings!==!1&&typeof Q==="string")Q=A6.from(Q,q);return Q}Object.defineProperty(o.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function wX($,Q,q,V,Y,X){if(!q){var J=CX(Q,V,Y);if(V!==J)q=!0,Y="buffer",V=J}var G=Q.objectMode?1:V.length;Q.length+=G;var U=Q.length<Q.highWaterMark;if(!U)Q.needDrain=!0;if(Q.writing||Q.corked){var K=Q.lastBufferedRequest;if(Q.lastBufferedRequest={chunk:V,encoding:Y,isBuf:q,callback:X,next:null},K)K.next=Q.lastBufferedRequest;else Q.bufferedRequest=Q.lastBufferedRequest;Q.bufferedRequestCount+=1}else $5($,Q,!1,G,V,Y,X);return U}function $5($,Q,q,V,Y,X,J){if(Q.writelen=V,Q.writecb=J,Q.writing=!0,Q.sync=!0,q)$._writev(Y,Q.onwrite);else $._write(Y,X,Q.onwrite);Q.sync=!1}function TX($,Q,q,V,Y){if(--Q.pendingcb,q)L0.nextTick(Y,V),L0.nextTick(P$,$,Q),$._writableState.errorEmitted=!0,$.emit("error",V);else Y(V),$._writableState.errorEmitted=!0,$.emit("error",V),P$($,Q)}function AX($){$.writing=!1,$.writecb=null,$.length-=$.writelen,$.writelen=0}function FX($,Q){var q=$._writableState,V=q.sync,Y=q.writecb;if(AX(q),Q)TX($,q,V,Q,Y);else{var X=eq(q);if(!X&&!q.corked&&!q.bufferProcessing&&q.bufferedRequest)tq($,q);if(V)HX(iq,$,q,X,Y);else iq($,q,X,Y)}}function iq($,Q,q,V){if(!q)RX($,Q);Q.pendingcb--,V(),P$($,Q)}function RX($,Q){if(Q.length===0&&Q.needDrain)Q.needDrain=!1,$.emit("drain")}function tq($,Q){Q.bufferProcessing=!0;var q=Q.bufferedRequest;if($._writev&&q&&q.next){var V=Q.bufferedRequestCount,Y=Array(V),X=Q.corkedRequestsFree;X.entry=q;var J=0,G=!0;while(q){if(Y[J]=q,!q.isBuf)G=!1;q=q.next,J+=1}if(Y.allBuffers=G,$5($,Q,!0,Q.length,Y,"",X.finish),Q.pendingcb++,Q.lastBufferedRequest=null,X.next)Q.corkedRequestsFree=X.next,X.next=null;else Q.corkedRequestsFree=new nq(Q);Q.bufferedRequestCount=0}else{while(q){var{chunk:U,encoding:K,callback:W}=q,Z=Q.objectMode?1:U.length;if($5($,Q,!1,Z,U,K,W),q=q.next,Q.bufferedRequestCount--,Q.writing)break}if(q===null)Q.lastBufferedRequest=null}Q.bufferedRequest=q,Q.bufferProcessing=!1}o.prototype._write=function($,Q,q){q(Error("_write() is not implemented"))};o.prototype._writev=null;o.prototype.end=function($,Q,q){var V=this._writableState;if(typeof $==="function")q=$,$=null,Q=null;else if(typeof Q==="function")q=Q,Q=null;if($!==null&&$!==void 0)this.write($,Q);if(V.corked)V.corked=1,this.uncork();if(!V.ending)SX(this,V,q)};function eq($){return $.ending&&$.length===0&&$.bufferedRequest===null&&!$.finished&&!$.writing}function vX($,Q){$._final(function(q){if(Q.pendingcb--,q)$.emit("error",q);Q.prefinished=!0,$.emit("prefinish"),P$($,Q)})}function xX($,Q){if(!Q.prefinished&&!Q.finalCalled)if(typeof $._final==="function")Q.pendingcb++,Q.finalCalled=!0,L0.nextTick(vX,$,Q);else Q.prefinished=!0,$.emit("prefinish")}function P$($,Q){var q=eq(Q);if(q){if(xX($,Q),Q.pendingcb===0)Q.finished=!0,$.emit("finish")}return q}function SX($,Q,q){if(Q.ending=!0,P$($,Q),q)if(Q.finished)L0.nextTick(q);else $.once("finish",q);Q.ended=!0,$.writable=!1}function EX($,Q,q){var V=$.entry;$.entry=null;while(V){var Y=V.callback;Q.pendingcb--,Y(q),V=V.next}Q.corkedRequestsFree.next=$}Object.defineProperty(o.prototype,"destroyed",{get:function(){if(this._writableState===void 0)return!1;return this._writableState.destroyed},set:function($){if(!this._writableState)return;this._writableState.destroyed=$}});o.prototype.destroy=sq.destroy;o.prototype._undestroy=sq.undestroy;o.prototype._destroy=function($,Q){this.end(),Q($)}});var P0=T((fH,JV)=>{var QV=z$(),yX=Object.keys||function($){var Q=[];for(var q in $)Q.push(q);return Q};JV.exports=o1;var qV=Object.create(g0());qV.inherits=D0();var VV=V5(),q5=Q5();qV.inherits(o1,VV);{F6=yX(q5.prototype);for(M$=0;M$<F6.length;M$++)if(B$=F6[M$],!o1.prototype[B$])o1.prototype[B$]=q5.prototype[B$]}var F6,B$,M$;function o1($){if(!(this instanceof o1))return new o1($);if(VV.call(this,$),q5.call(this,$),$&&$.readable===!1)this.readable=!1;if($&&$.writable===!1)this.writable=!1;if(this.allowHalfOpen=!0,$&&$.allowHalfOpen===!1)this.allowHalfOpen=!1;this.once("end",kX)}Object.defineProperty(o1.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function kX(){if(this.allowHalfOpen||this._writableState.ended)return;QV.nextTick(gX,this)}function gX($){$.end()}Object.defineProperty(o1.prototype,"destroyed",{get:function(){if(this._readableState===void 0||this._writableState===void 0)return!1;return this._readableState.destroyed&&this._writableState.destroyed},set:function($){if(this._readableState===void 0||this._writableState===void 0)return;this._readableState.destroyed=$,this._writableState.destroyed=$}});o1.prototype._destroy=function($,Q){this.push(null),this.end(),QV.nextTick(Q,$)}});var X5=T((nX)=>{var Y5=H$().Buffer,YV=Y5.isEncoding||function($){switch($=""+$,$&&$.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function DX($){if(!$)return"utf8";var Q;while(!0)switch($){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return $;default:if(Q)return;$=(""+$).toLowerCase(),Q=!0}}function hX($){var Q=DX($);if(typeof Q!=="string"&&(Y5.isEncoding===YV||!YV($)))throw Error("Unknown encoding: "+$);return Q||$}nX.StringDecoder=N$;function N$($){this.encoding=hX($);var Q;switch(this.encoding){case"utf16le":this.text=pX,this.end=uX,Q=4;break;case"utf8":this.fillLast=fX,Q=4;break;case"base64":this.text=dX,this.end=lX,Q=3;break;default:this.write=oX,this.end=iX;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=Y5.allocUnsafe(Q)}N$.prototype.write=function($){if($.length===0)return"";var Q,q;if(this.lastNeed){if(Q=this.fillLast($),Q===void 0)return"";q=this.lastNeed,this.lastNeed=0}else q=0;if(q<$.length)return Q?Q+this.text($,q):this.text($,q);return Q||""};N$.prototype.end=cX;N$.prototype.text=mX;N$.prototype.fillLast=function($){if(this.lastNeed<=$.length)return $.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);$.copy(this.lastChar,this.lastTotal-this.lastNeed,0,$.length),this.lastNeed-=$.length};function J5($){if($<=127)return 0;else if($>>5===6)return 2;else if($>>4===14)return 3;else if($>>3===30)return 4;return $>>6===2?-1:-2}function _X($,Q,q){var V=Q.length-1;if(V<q)return 0;var Y=J5(Q[V]);if(Y>=0){if(Y>0)$.lastNeed=Y-1;return Y}if(--V<q||Y===-2)return 0;if(Y=J5(Q[V]),Y>=0){if(Y>0)$.lastNeed=Y-2;return Y}if(--V<q||Y===-2)return 0;if(Y=J5(Q[V]),Y>=0){if(Y>0)if(Y===2)Y=0;else $.lastNeed=Y-3;return Y}return 0}function bX($,Q,q){if((Q[0]&192)!==128)return $.lastNeed=0,"�";if($.lastNeed>1&&Q.length>1){if((Q[1]&192)!==128)return $.lastNeed=1,"�";if($.lastNeed>2&&Q.length>2){if((Q[2]&192)!==128)return $.lastNeed=2,"�"}}}function fX($){var Q=this.lastTotal-this.lastNeed,q=bX(this,$,Q);if(q!==void 0)return q;if(this.lastNeed<=$.length)return $.copy(this.lastChar,Q,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);$.copy(this.lastChar,Q,0,$.length),this.lastNeed-=$.length}function mX($,Q){var q=_X(this,$,Q);if(!this.lastNeed)return $.toString("utf8",Q);this.lastTotal=q;var V=$.length-(q-this.lastNeed);return $.copy(this.lastChar,0,V),$.toString("utf8",Q,V)}function cX($){var Q=$&&$.length?this.write($):"";if(this.lastNeed)return Q+"�";return Q}function pX($,Q){if(($.length-Q)%2===0){var q=$.toString("utf16le",Q);if(q){var V=q.charCodeAt(q.length-1);if(V>=55296&&V<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=$[$.length-2],this.lastChar[1]=$[$.length-1],q.slice(0,-1)}return q}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=$[$.length-1],$.toString("utf16le",Q,$.length-1)}function uX($){var Q=$&&$.length?this.write($):"";if(this.lastNeed){var q=this.lastTotal-this.lastNeed;return Q+this.lastChar.toString("utf16le",0,q)}return Q}function dX($,Q){var q=($.length-Q)%3;if(q===0)return $.toString("base64",Q);if(this.lastNeed=3-q,this.lastTotal=3,q===1)this.lastChar[0]=$[$.length-1];else this.lastChar[0]=$[$.length-2],this.lastChar[1]=$[$.length-1];return $.toString("base64",Q,$.length-q)}function lX($){var Q=$&&$.length?this.write($):"";if(this.lastNeed)return Q+this.lastChar.toString("base64",0,3-this.lastNeed);return Q}function oX($){return $.toString(this.encoding)}function iX($){return $&&$.length?this.write($):""}});var V5=T((pH,OV)=>{var b0=z$();OV.exports=f;var aX=bq(),I$;f.ReadableState=ZV;var cH=b("events").EventEmitter,WV=function($,Q){return $.listeners(Q).length},j5=b("stream"),C$=H$().Buffer,sX=(typeof global<"u"?global:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function tX($){return C$.from($)}function eX($){return C$.isBuffer($)||$ instanceof sX}var UV=Object.create(g0());UV.inherits=D0();var G5=b("util"),y=void 0;if(G5&&G5.debuglog)y=G5.debuglog("stream");else y=function(){};var $3=uq(),jV=e8(),_0;UV.inherits(f,j5);var K5=["error","close","destroy","pause","resume"];function Q3($,Q,q){if(typeof $.prependListener==="function")return $.prependListener(Q,q);if(!$._events||!$._events[Q])$.on(Q,q);else if(aX($._events[Q]))$._events[Q].unshift(q);else $._events[Q]=[q,$._events[Q]]}function ZV($,Q){I$=I$||P0(),$=$||{};var q=Q instanceof I$;if(this.objectMode=!!$.objectMode,q)this.objectMode=this.objectMode||!!$.readableObjectMode;var{highWaterMark:V,readableHighWaterMark:Y}=$,X=this.objectMode?16:16384;if(V||V===0)this.highWaterMark=V;else if(q&&(Y||Y===0))this.highWaterMark=Y;else this.highWaterMark=X;if(this.highWaterMark=Math.floor(this.highWaterMark),this.buffer=new $3,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.destroyed=!1,this.defaultEncoding=$.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,$.encoding){if(!_0)_0=X5().StringDecoder;this.decoder=new _0($.encoding),this.encoding=$.encoding}}function f($){if(I$=I$||P0(),!(this instanceof f))return new f($);if(this._readableState=new ZV($,this),this.readable=!0,$){if(typeof $.read==="function")this._read=$.read;if(typeof $.destroy==="function")this._destroy=$.destroy}j5.call(this)}Object.defineProperty(f.prototype,"destroyed",{get:function(){if(this._readableState===void 0)return!1;return this._readableState.destroyed},set:function($){if(!this._readableState)return;this._readableState.destroyed=$}});f.prototype.destroy=jV.destroy;f.prototype._undestroy=jV.undestroy;f.prototype._destroy=function($,Q){this.push(null),Q($)};f.prototype.push=function($,Q){var q=this._readableState,V;if(!q.objectMode){if(typeof $==="string"){if(Q=Q||q.defaultEncoding,Q!==q.encoding)$=C$.from($,Q),Q="";V=!0}}else V=!0;return zV(this,$,Q,!1,V)};f.prototype.unshift=function($){return zV(this,$,null,!0,!1)};function zV($,Q,q,V,Y){var X=$._readableState;if(Q===null)X.reading=!1,Y3($,X);else{var J;if(!Y)J=q3(X,Q);if(J)$.emit("error",J);else if(X.objectMode||Q&&Q.length>0){if(typeof Q!=="string"&&!X.objectMode&&Object.getPrototypeOf(Q)!==C$.prototype)Q=tX(Q);if(V)if(X.endEmitted)$.emit("error",Error("stream.unshift() after end event"));else W5($,X,Q,!0);else if(X.ended)$.emit("error",Error("stream.push() after EOF"));else if(X.reading=!1,X.decoder&&!q)if(Q=X.decoder.write(Q),X.objectMode||Q.length!==0)W5($,X,Q,!1);else HV($,X);else W5($,X,Q,!1)}else if(!V)X.reading=!1}return V3(X)}function W5($,Q,q,V){if(Q.flowing&&Q.length===0&&!Q.sync)$.emit("data",q),$.read(0);else{if(Q.length+=Q.objectMode?1:q.length,V)Q.buffer.unshift(q);else Q.buffer.push(q);if(Q.needReadable)R6($)}HV($,Q)}function q3($,Q){var q;if(!eX(Q)&&typeof Q!=="string"&&Q!==void 0&&!$.objectMode)q=TypeError("Invalid non-string/buffer chunk");return q}function V3($){return!$.ended&&($.needReadable||$.length<$.highWaterMark||$.length===0)}f.prototype.isPaused=function(){return this._readableState.flowing===!1};f.prototype.setEncoding=function($){if(!_0)_0=X5().StringDecoder;return this._readableState.decoder=new _0($),this._readableState.encoding=$,this};var XV=8388608;function J3($){if($>=XV)$=XV;else $--,$|=$>>>1,$|=$>>>2,$|=$>>>4,$|=$>>>8,$|=$>>>16,$++;return $}function GV($,Q){if($<=0||Q.length===0&&Q.ended)return 0;if(Q.objectMode)return 1;if($!==$)if(Q.flowing&&Q.length)return Q.buffer.head.data.length;else return Q.length;if($>Q.highWaterMark)Q.highWaterMark=J3($);if($<=Q.length)return $;if(!Q.ended)return Q.needReadable=!0,0;return Q.length}f.prototype.read=function($){y("read",$),$=parseInt($,10);var Q=this._readableState,q=$;if($!==0)Q.emittedReadable=!1;if($===0&&Q.needReadable&&(Q.length>=Q.highWaterMark||Q.ended)){if(y("read: emitReadable",Q.length,Q.ended),Q.length===0&&Q.ended)U5(this);else R6(this);return null}if($=GV($,Q),$===0&&Q.ended){if(Q.length===0)U5(this);return null}var V=Q.needReadable;if(y("need readable",V),Q.length===0||Q.length-$<Q.highWaterMark)V=!0,y("length less than watermark",V);if(Q.ended||Q.reading)V=!1,y("reading or ended",V);else if(V){if(y("do read"),Q.reading=!0,Q.sync=!0,Q.length===0)Q.needReadable=!0;if(this._read(Q.highWaterMark),Q.sync=!1,!Q.reading)$=GV(q,Q)}var Y;if($>0)Y=LV($,Q);else Y=null;if(Y===null)Q.needReadable=!0,$=0;else Q.length-=$;if(Q.length===0){if(!Q.ended)Q.needReadable=!0;if(q!==$&&Q.ended)U5(this)}if(Y!==null)this.emit("data",Y);return Y};function Y3($,Q){if(Q.ended)return;if(Q.decoder){var q=Q.decoder.end();if(q&&q.length)Q.buffer.push(q),Q.length+=Q.objectMode?1:q.length}Q.ended=!0,R6($)}function R6($){var Q=$._readableState;if(Q.needReadable=!1,!Q.emittedReadable)if(y("emitReadable",Q.flowing),Q.emittedReadable=!0,Q.sync)b0.nextTick(KV,$);else KV($)}function KV($){y("emit readable"),$.emit("readable"),Z5($)}function HV($,Q){if(!Q.readingMore)Q.readingMore=!0,b0.nextTick(X3,$,Q)}function X3($,Q){var q=Q.length;while(!Q.reading&&!Q.flowing&&!Q.ended&&Q.length<Q.highWaterMark)if(y("maybeReadMore read 0"),$.read(0),q===Q.length)break;else q=Q.length;Q.readingMore=!1}f.prototype._read=function($){this.emit("error",Error("_read() is not implemented"))};f.prototype.pipe=function($,Q){var q=this,V=this._readableState;switch(V.pipesCount){case 0:V.pipes=$;break;case 1:V.pipes=[V.pipes,$];break;default:V.pipes.push($);break}V.pipesCount+=1,y("pipe count=%d opts=%j",V.pipesCount,Q);var Y=(!Q||Q.end!==!1)&&$!==process.stdout&&$!==process.stderr,X=Y?G:w;if(V.endEmitted)b0.nextTick(X);else q.once("end",X);$.on("unpipe",J);function J(P,L){if(y("onunpipe"),P===q){if(L&&L.hasUnpiped===!1)L.hasUnpiped=!0,W()}}function G(){y("onend"),$.end()}var U=G3(q);$.on("drain",U);var K=!1;function W(){if(y("cleanup"),$.removeListener("close",I),$.removeListener("finish",N),$.removeListener("drain",U),$.removeListener("error",H),$.removeListener("unpipe",J),q.removeListener("end",G),q.removeListener("end",w),q.removeListener("data",z),K=!0,V.awaitDrain&&(!$._writableState||$._writableState.needDrain))U()}var Z=!1;q.on("data",z);function z(P){y("ondata"),Z=!1;var L=$.write(P);if(L===!1&&!Z){if((V.pipesCount===1&&V.pipes===$||V.pipesCount>1&&PV(V.pipes,$)!==-1)&&!K)y("false write response, pause",V.awaitDrain),V.awaitDrain++,Z=!0;q.pause()}}function H(P){if(y("onerror",P),w(),$.removeListener("error",H),WV($,"error")===0)$.emit("error",P)}Q3($,"error",H);function I(){$.removeListener("finish",N),w()}$.once("close",I);function N(){y("onfinish"),$.removeListener("close",I),w()}$.once("finish",N);function w(){y("unpipe"),q.unpipe($)}if($.emit("pipe",q),!V.flowing)y("pipe resume"),q.resume();return $};function G3($){return function(){var Q=$._readableState;if(y("pipeOnDrain",Q.awaitDrain),Q.awaitDrain)Q.awaitDrain--;if(Q.awaitDrain===0&&WV($,"data"))Q.flowing=!0,Z5($)}}f.prototype.unpipe=function($){var Q=this._readableState,q={hasUnpiped:!1};if(Q.pipesCount===0)return this;if(Q.pipesCount===1){if($&&$!==Q.pipes)return this;if(!$)$=Q.pipes;if(Q.pipes=null,Q.pipesCount=0,Q.flowing=!1,$)$.emit("unpipe",this,q);return this}if(!$){var{pipes:V,pipesCount:Y}=Q;Q.pipes=null,Q.pipesCount=0,Q.flowing=!1;for(var X=0;X<Y;X++)V[X].emit("unpipe",this,{hasUnpiped:!1});return this}var J=PV(Q.pipes,$);if(J===-1)return this;if(Q.pipes.splice(J,1),Q.pipesCount-=1,Q.pipesCount===1)Q.pipes=Q.pipes[0];return $.emit("unpipe",this,q),this};f.prototype.on=function($,Q){var q=j5.prototype.on.call(this,$,Q);if($==="data"){if(this._readableState.flowing!==!1)this.resume()}else if($==="readable"){var V=this._readableState;if(!V.endEmitted&&!V.readableListening){if(V.readableListening=V.needReadable=!0,V.emittedReadable=!1,!V.reading)b0.nextTick(K3,this);else if(V.length)R6(this)}}return q};f.prototype.addListener=f.prototype.on;function K3($){y("readable nexttick read 0"),$.read(0)}f.prototype.resume=function(){var $=this._readableState;if(!$.flowing)y("resume"),$.flowing=!0,W3(this,$);return this};function W3($,Q){if(!Q.resumeScheduled)Q.resumeScheduled=!0,b0.nextTick(U3,$,Q)}function U3($,Q){if(!Q.reading)y("resume read 0"),$.read(0);if(Q.resumeScheduled=!1,Q.awaitDrain=0,$.emit("resume"),Z5($),Q.flowing&&!Q.reading)$.read(0)}f.prototype.pause=function(){if(y("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1)y("pause"),this._readableState.flowing=!1,this.emit("pause");return this};function Z5($){var Q=$._readableState;y("flow",Q.flowing);while(Q.flowing&&$.read()!==null);}f.prototype.wrap=function($){var Q=this,q=this._readableState,V=!1;$.on("end",function(){if(y("wrapped end"),q.decoder&&!q.ended){var J=q.decoder.end();if(J&&J.length)Q.push(J)}Q.push(null)}),$.on("data",function(J){if(y("wrapped data"),q.decoder)J=q.decoder.write(J);if(q.objectMode&&(J===null||J===void 0))return;else if(!q.objectMode&&(!J||!J.length))return;var G=Q.push(J);if(!G)V=!0,$.pause()});for(var Y in $)if(this[Y]===void 0&&typeof $[Y]==="function")this[Y]=function(J){return function(){return $[J].apply($,arguments)}}(Y);for(var X=0;X<K5.length;X++)$.on(K5[X],this.emit.bind(this,K5[X]));return this._read=function(J){if(y("wrapped _read",J),V)V=!1,$.resume()},this};Object.defineProperty(f.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}});f._fromList=LV;function LV($,Q){if(Q.length===0)return null;var q;if(Q.objectMode)q=Q.buffer.shift();else if(!$||$>=Q.length){if(Q.decoder)q=Q.buffer.join("");else if(Q.buffer.length===1)q=Q.buffer.head.data;else q=Q.buffer.concat(Q.length);Q.buffer.clear()}else q=j3($,Q.buffer,Q.decoder);return q}function j3($,Q,q){var V;if($<Q.head.data.length)V=Q.head.data.slice(0,$),Q.head.data=Q.head.data.slice($);else if($===Q.head.data.length)V=Q.shift();else V=q?Z3($,Q):z3($,Q);return V}function Z3($,Q){var q=Q.head,V=1,Y=q.data;$-=Y.length;while(q=q.next){var X=q.data,J=$>X.length?X.length:$;if(J===X.length)Y+=X;else Y+=X.slice(0,$);if($-=J,$===0){if(J===X.length)if(++V,q.next)Q.head=q.next;else Q.head=Q.tail=null;else Q.head=q,q.data=X.slice(J);break}++V}return Q.length-=V,Y}function z3($,Q){var q=C$.allocUnsafe($),V=Q.head,Y=1;V.data.copy(q),$-=V.data.length;while(V=V.next){var X=V.data,J=$>X.length?X.length:$;if(X.copy(q,q.length-$,0,J),$-=J,$===0){if(J===X.length)if(++Y,V.next)Q.head=V.next;else Q.head=Q.tail=null;else Q.head=V,V.data=X.slice(J);break}++Y}return Q.length-=Y,q}function U5($){var Q=$._readableState;if(Q.length>0)throw Error('"endReadable()" called on non-empty stream');if(!Q.endEmitted)Q.ended=!0,b0.nextTick(H3,Q,$)}function H3($,Q){if(!$.endEmitted&&$.length===0)$.endEmitted=!0,Q.readable=!1,Q.emit("end")}function PV($,Q){for(var q=0,V=$.length;q<V;q++)if($[q]===Q)return q;return-1}});var z5=T((uH,NV)=>{NV.exports=i1;var v6=P0(),BV=Object.create(g0());BV.inherits=D0();BV.inherits(i1,v6);function L3($,Q){var q=this._transformState;q.transforming=!1;var V=q.writecb;if(!V)return this.emit("error",Error("write callback called multiple times"));if(q.writechunk=null,q.writecb=null,Q!=null)this.push(Q);V($);var Y=this._readableState;if(Y.reading=!1,Y.needReadable||Y.length<Y.highWaterMark)this._read(Y.highWaterMark)}function i1($){if(!(this instanceof i1))return new i1($);if(v6.call(this,$),this._transformState={afterTransform:L3.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,$){if(typeof $.transform==="function")this._transform=$.transform;if(typeof $.flush==="function")this._flush=$.flush}this.on("prefinish",P3)}function P3(){var $=this;if(typeof this._flush==="function")this._flush(function(Q,q){MV($,Q,q)});else MV(this,null,null)}i1.prototype.push=function($,Q){return this._transformState.needTransform=!1,v6.prototype.push.call(this,$,Q)};i1.prototype._transform=function($,Q,q){throw Error("_transform() is not implemented")};i1.prototype._write=function($,Q,q){var V=this._transformState;if(V.writecb=q,V.writechunk=$,V.writeencoding=Q,!V.transforming){var Y=this._readableState;if(V.needTransform||Y.needReadable||Y.length<Y.highWaterMark)this._read(Y.highWaterMark)}};i1.prototype._read=function($){var Q=this._transformState;if(Q.writechunk!==null&&Q.writecb&&!Q.transforming)Q.transforming=!0,this._transform(Q.writechunk,Q.writeencoding,Q.afterTransform);else Q.needTransform=!0};i1.prototype._destroy=function($,Q){var q=this;v6.prototype._destroy.call(this,$,function(V){Q(V),q.emit("close")})};function MV($,Q,q){if(Q)return $.emit("error",Q);if(q!=null)$.push(q);if($._writableState.length)throw Error("Calling transform done when ws.length != 0");if($._transformState.transforming)throw Error("Calling transform done when still transforming");return $.push(null)}});var TV=T((dH,wV)=>{wV.exports=w$;var IV=z5(),CV=Object.create(g0());CV.inherits=D0();CV.inherits(w$,IV);function w$($){if(!(this instanceof w$))return new w$($);IV.call(this,$)}w$.prototype._transform=function($,Q,q){q(null,$)}});var H5=T((s,x6)=>{var E1=b("stream");if(process.env.READABLE_STREAM==="disable"&&E1)x6.exports=E1,s=x6.exports=E1.Readable,s.Readable=E1.Readable,s.Writable=E1.Writable,s.Duplex=E1.Duplex,s.Transform=E1.Transform,s.PassThrough=E1.PassThrough,s.Stream=E1;else s=x6.exports=V5(),s.Stream=E1||s,s.Readable=s,s.Writable=Q5(),s.Duplex=P0(),s.Transform=z5(),s.PassThrough=TV()});var n1=T((M3)=>{M3.base64=!0;M3.array=!0;M3.string=!0;M3.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u";M3.nodebuffer=typeof Buffer<"u";M3.uint8array=typeof Uint8Array<"u";if(typeof ArrayBuffer>"u")M3.blob=!1;else{S6=new ArrayBuffer(0);try{M3.blob=new Blob([S6],{type:"application/zip"}).size===0}catch($){try{P5=self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder,E6=new P5,E6.append(S6),M3.blob=E6.getBlob("application/zip").size===0}catch(Q){M3.blob=!1}}}var S6,P5,E6;try{M3.nodestream=!!H5().Readable}catch($){M3.nodestream=!1}});var O5=T((R3)=>{var A3=p(),F3=n1(),y1="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";R3.encode=function($){var Q=[],q,V,Y,X,J,G,U,K=0,W=$.length,Z=W,z=A3.getTypeOf($)!=="string";while(K<$.length){if(Z=W-K,!z)q=$.charCodeAt(K++),V=K<W?$.charCodeAt(K++):0,Y=K<W?$.charCodeAt(K++):0;else q=$[K++],V=K<W?$[K++]:0,Y=K<W?$[K++]:0;X=q>>2,J=(q&3)<<4|V>>4,G=Z>1?(V&15)<<2|Y>>6:64,U=Z>2?Y&63:64,Q.push(y1.charAt(X)+y1.charAt(J)+y1.charAt(G)+y1.charAt(U))}return Q.join("")};R3.decode=function($){var Q,q,V,Y,X,J,G,U=0,K=0,W="data:";if($.substr(0,W.length)===W)throw Error("Invalid base64 input, it looks like a data url.");$=$.replace(/[^A-Za-z0-9+/=]/g,"");var Z=$.length*3/4;if($.charAt($.length-1)===y1.charAt(64))Z--;if($.charAt($.length-2)===y1.charAt(64))Z--;if(Z%1!==0)throw Error("Invalid base64 input, bad content length.");var z;if(F3.uint8array)z=new Uint8Array(Z|0);else z=Array(Z|0);while(U<$.length){if(Y=y1.indexOf($.charAt(U++)),X=y1.indexOf($.charAt(U++)),J=y1.indexOf($.charAt(U++)),G=y1.indexOf($.charAt(U++)),Q=Y<<2|X>>4,q=(X&15)<<4|J>>2,V=(J&3)<<6|G,z[K++]=Q,J!==64)z[K++]=q;if(G!==64)z[K++]=V}return z}});var T$=T((iH,AV)=>{AV.exports={isNode:typeof Buffer<"u",newBufferFrom:function($,Q){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from($,Q);else{if(typeof $==="number")throw Error('The "data" argument must not be a number');return new Buffer($,Q)}},allocBuffer:function($){if(Buffer.alloc)return Buffer.alloc($);else{var Q=new Buffer($);return Q.fill(0),Q}},isBuffer:function($){return Buffer.isBuffer($)},isStream:function($){return $&&typeof $.on==="function"&&typeof $.pause==="function"&&typeof $.resume==="function"}}});var vV=T((rH,RV)=>{var nH=global.MutationObserver||global.WebKitMutationObserver,FV;FV=function(){process.nextTick(g3)};var S3,E3,y3,k3,M5,A$=[];function g3(){M5=!0;var $,Q,q=A$.length;while(q){Q=A$,A$=[],$=-1;while(++$<q)Q[$]();q=A$.length}M5=!1}RV.exports=D3;function D3($){if(A$.push($)===1&&!M5)FV()}});var DV=T((aH,gV)=>{var xV=vV();function m0(){}var Q1={},SV=["REJECTED"],B5=["FULFILLED"],EV=["PENDING"];f0=["UNHANDLED"];var f0;gV.exports=V0;function V0($){if(typeof $!=="function")throw TypeError("resolver must be a function");if(this.state=EV,this.queue=[],this.outcome=void 0,this.handled=f0,$!==m0)yV(this,$)}V0.prototype.finally=function($){if(typeof $!=="function")return this;var Q=this.constructor;return this.then(q,V);function q(Y){function X(){return Y}return Q.resolve($()).then(X)}function V(Y){function X(){throw Y}return Q.resolve($()).then(X)}};V0.prototype.catch=function($){return this.then(null,$)};V0.prototype.then=function($,Q){if(typeof $!=="function"&&this.state===B5||typeof Q!=="function"&&this.state===SV)return this;var q=new this.constructor(m0);if(this.handled===f0)this.handled=null;if(this.state!==EV){var V=this.state===B5?$:Q;N5(q,V,this.outcome)}else this.queue.push(new F$(q,$,Q));return q};function F$($,Q,q){if(this.promise=$,typeof Q==="function")this.onFulfilled=Q,this.callFulfilled=this.otherCallFulfilled;if(typeof q==="function")this.onRejected=q,this.callRejected=this.otherCallRejected}F$.prototype.callFulfilled=function($){Q1.resolve(this.promise,$)};F$.prototype.otherCallFulfilled=function($){N5(this.promise,this.onFulfilled,$)};F$.prototype.callRejected=function($){Q1.reject(this.promise,$)};F$.prototype.otherCallRejected=function($){N5(this.promise,this.onRejected,$)};function N5($,Q,q){xV(function(){var V;try{V=Q(q)}catch(Y){return Q1.reject($,Y)}if(V===$)Q1.reject($,TypeError("Cannot resolve promise with itself"));else Q1.resolve($,V)})}Q1.resolve=function($,Q){var q=kV(h3,Q);if(q.status==="error")return Q1.reject($,q.value);var V=q.value;if(V)yV($,V);else{$.state=B5,$.outcome=Q;var Y=-1,X=$.queue.length;while(++Y<X)$.queue[Y].callFulfilled(Q)}return $};Q1.reject=function($,Q){if($.state=SV,$.outcome=Q,$.handled===f0)xV(function(){if($.handled===f0)process.emit("unhandledRejection",Q,$)});var q=-1,V=$.queue.length;while(++q<V)$.queue[q].callRejected(Q);return $};function h3($){var Q=$&&$.then;if($&&(typeof $==="object"||typeof $==="function")&&typeof Q==="function")return function(){Q.apply($,arguments)}}function yV($,Q){var q=!1;function V(G){if(q)return;q=!0,Q1.reject($,G)}function Y(G){if(q)return;q=!0,Q1.resolve($,G)}function X(){Q(Y,V)}var J=kV(X);if(J.status==="error")V(J.value)}function kV($,Q){var q={};try{q.value=$(Q),q.status="success"}catch(V){q.status="error",q.value=V}return q}V0.resolve=_3;function _3($){if($ instanceof this)return $;return Q1.resolve(new this(m0),$)}V0.reject=b3;function b3($){var Q=new this(m0);return Q1.reject(Q,$)}V0.all=f3;function f3($){var Q=this;if(Object.prototype.toString.call($)!=="[object Array]")return this.reject(TypeError("must be an array"));var q=$.length,V=!1;if(!q)return this.resolve([]);var Y=Array(q),X=0,J=-1,G=new this(m0);while(++J<q)U($[J],J);return G;function U(K,W){Q.resolve(K).then(Z,function(z){if(!V)V=!0,Q1.reject(G,z)});function Z(z){if(Y[W]=z,++X===q&&!V)V=!0,Q1.resolve(G,Y)}}}V0.race=m3;function m3($){var Q=this;if(Object.prototype.toString.call($)!=="[object Array]")return this.reject(TypeError("must be an array"));var q=$.length,V=!1;if(!q)return this.resolve([]);var Y=-1,X=new this(m0);while(++Y<q)J($[Y]);return X;function J(G){Q.resolve(G).then(function(U){if(!V)V=!0,Q1.resolve(X,U)},function(U){if(!V)V=!0,Q1.reject(X,U)})}}});var c0=T((sH,hV)=>{var I5=null;if(typeof Promise<"u")I5=Promise;else I5=DV();hV.exports={Promise:I5}});var bV=T((_V)=>{(function($,Q){if($.setImmediate)return;var q=1,V={},Y=!1,X=$.document,J;function G(L){if(typeof L!=="function")L=Function(""+L);var C=Array(arguments.length-1);for(var O=0;O<C.length;O++)C[O]=arguments[O+1];var M={callback:L,args:C};return V[q]=M,J(q),q++}function U(L){delete V[L]}function K(L){var{callback:C,args:O}=L;switch(O.length){case 0:C();break;case 1:C(O[0]);break;case 2:C(O[0],O[1]);break;case 3:C(O[0],O[1],O[2]);break;default:C.apply(Q,O);break}}function W(L){if(Y)setTimeout(W,0,L);else{var C=V[L];if(C){Y=!0;try{K(C)}finally{U(L),Y=!1}}}}function Z(){J=function(L){process.nextTick(function(){W(L)})}}function z(){if($.postMessage&&!$.importScripts){var L=!0,C=$.onmessage;return $.onmessage=function(){L=!1},$.postMessage("","*"),$.onmessage=C,L}}function H(){var L="setImmediate$"+Math.random()+"$",C=function(O){if(O.source===$&&typeof O.data==="string"&&O.data.indexOf(L)===0)W(+O.data.slice(L.length))};if($.addEventListener)$.addEventListener("message",C,!1);else $.attachEvent("onmessage",C);J=function(O){$.postMessage(L+O,"*")}}function I(){var L=new MessageChannel;L.port1.onmessage=function(C){var O=C.data;W(O)},J=function(C){L.port2.postMessage(C)}}function N(){var L=X.documentElement;J=function(C){var O=X.createElement("script");O.onreadystatechange=function(){W(C),O.onreadystatechange=null,L.removeChild(O),O=null},L.appendChild(O)}}function w(){J=function(L){setTimeout(W,0,L)}}var P=Object.getPrototypeOf&&Object.getPrototypeOf($);if(P=P&&P.setTimeout?P:$,{}.toString.call($.process)==="[object process]")Z();else if(z())H();else if($.MessageChannel)I();else if(X&&"onreadystatechange"in X.createElement("script"))N();else w();P.setImmediate=G,P.clearImmediate=U})(typeof self>"u"?typeof global>"u"?_V:global:self)});var p=T((u3)=>{var J0=n1(),c3=O5(),p0=T$(),C5=c0();bV();function p3($){var Q=null;if(J0.uint8array)Q=new Uint8Array($.length);else Q=Array($.length);return k6($,Q)}u3.newBlob=function($,Q){u3.checkSupport("blob");try{return new Blob([$],{type:Q})}catch(Y){try{var q=self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder,V=new q;return V.append($),V.getBlob(Q)}catch(X){throw Error("Bug : can't construct the Blob.")}}};function R$($){return $}function k6($,Q){for(var q=0;q<$.length;++q)Q[q]=$.charCodeAt(q)&255;return Q}var y6={stringifyByChunk:function($,Q,q){var V=[],Y=0,X=$.length;if(X<=q)return String.fromCharCode.apply(null,$);while(Y<X){if(Q==="array"||Q==="nodebuffer")V.push(String.fromCharCode.apply(null,$.slice(Y,Math.min(Y+q,X))));else V.push(String.fromCharCode.apply(null,$.subarray(Y,Math.min(Y+q,X))));Y+=q}return V.join("")},stringifyByChar:function($){var Q="";for(var q=0;q<$.length;q++)Q+=String.fromCharCode($[q]);return Q},applyCanBeUsed:{uint8array:function(){try{return J0.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch($){return!1}}(),nodebuffer:function(){try{return J0.nodebuffer&&String.fromCharCode.apply(null,p0.allocBuffer(1)).length===1}catch($){return!1}}()}};function v$($){var Q=65536,q=u3.getTypeOf($),V=!0;if(q==="uint8array")V=y6.applyCanBeUsed.uint8array;else if(q==="nodebuffer")V=y6.applyCanBeUsed.nodebuffer;if(V)while(Q>1)try{return y6.stringifyByChunk($,q,Q)}catch(Y){Q=Math.floor(Q/2)}return y6.stringifyByChar($)}u3.applyFromCharCode=v$;function g6($,Q){for(var q=0;q<$.length;q++)Q[q]=$[q];return Q}var Y0={};Y0.string={string:R$,array:function($){return k6($,Array($.length))},arraybuffer:function($){return Y0.string.uint8array($).buffer},uint8array:function($){return k6($,new Uint8Array($.length))},nodebuffer:function($){return k6($,p0.allocBuffer($.length))}};Y0.array={string:v$,array:R$,arraybuffer:function($){return new Uint8Array($).buffer},uint8array:function($){return new Uint8Array($)},nodebuffer:function($){return p0.newBufferFrom($)}};Y0.arraybuffer={string:function($){return v$(new Uint8Array($))},array:function($){return g6(new Uint8Array($),Array($.byteLength))},arraybuffer:R$,uint8array:function($){return new Uint8Array($)},nodebuffer:function($){return p0.newBufferFrom(new Uint8Array($))}};Y0.uint8array={string:v$,array:function($){return g6($,Array($.length))},arraybuffer:function($){return $.buffer},uint8array:R$,nodebuffer:function($){return p0.newBufferFrom($)}};Y0.nodebuffer={string:v$,array:function($){return g6($,Array($.length))},arraybuffer:function($){return Y0.nodebuffer.uint8array($).buffer},uint8array:function($){return g6($,new Uint8Array($.length))},nodebuffer:R$};u3.transformTo=function($,Q){if(!Q)Q="";if(!$)return Q;u3.checkSupport($);var q=u3.getTypeOf(Q),V=Y0[q][$](Q);return V};u3.resolve=function($){var Q=$.split("/"),q=[];for(var V=0;V<Q.length;V++){var Y=Q[V];if(Y==="."||Y===""&&V!==0&&V!==Q.length-1)continue;else if(Y==="..")q.pop();else q.push(Y)}return q.join("/")};u3.getTypeOf=function($){if(typeof $==="string")return"string";if(Object.prototype.toString.call($)==="[object Array]")return"array";if(J0.nodebuffer&&p0.isBuffer($))return"nodebuffer";if(J0.uint8array&&$ instanceof Uint8Array)return"uint8array";if(J0.arraybuffer&&$ instanceof ArrayBuffer)return"arraybuffer"};u3.checkSupport=function($){var Q=J0[$.toLowerCase()];if(!Q)throw Error($+" is not supported by this platform")};u3.MAX_VALUE_16BITS=65535;u3.MAX_VALUE_32BITS=-1;u3.pretty=function($){var Q="",q,V;for(V=0;V<($||"").length;V++)q=$.charCodeAt(V),Q+="\\x"+(q<16?"0":"")+q.toString(16).toUpperCase();return Q};u3.delay=function($,Q,q){setImmediate(function(){$.apply(q||null,Q||[])})};u3.inherits=function($,Q){var q=function(){};q.prototype=Q.prototype,$.prototype=new q};u3.extend=function(){var $={},Q,q;for(Q=0;Q<arguments.length;Q++)for(q in arguments[Q])if(Object.prototype.hasOwnProperty.call(arguments[Q],q)&&typeof $[q]>"u")$[q]=arguments[Q][q];return $};u3.prepareContent=function($,Q,q,V,Y){var X=C5.Promise.resolve(Q).then(function(J){var G=J0.blob&&(J instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(J))!==-1);if(G&&typeof FileReader<"u")return new C5.Promise(function(U,K){var W=new FileReader;W.onload=function(Z){U(Z.target.result)},W.onerror=function(Z){K(Z.target.error)},W.readAsArrayBuffer(J)});else return J});return X.then(function(J){var G=u3.getTypeOf(J);if(!G)return C5.Promise.reject(Error("Can't read the data of '"+$+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"));if(G==="arraybuffer")J=u3.transformTo("uint8array",J);else if(G==="string"){if(Y)J=c3.decode(J);else if(q){if(V!==!0)J=p3(J)}}return J})}});var j1=T(($L,pV)=>{function cV($){this.name=$||"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}cV.prototype={push:function($){this.emit("data",$)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch($){this.emit("error",$)}return!0},error:function($){if(this.isFinished)return!1;if(this.isPaused)this.generatedError=$;else{if(this.isFinished=!0,this.emit("error",$),this.previous)this.previous.error($);this.cleanUp()}return!0},on:function($,Q){return this._listeners[$].push(Q),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function($,Q){if(this._listeners[$])for(var q=0;q<this._listeners[$].length;q++)this._listeners[$][q].call(this,Q)},pipe:function($){return $.registerPrevious(this)},registerPrevious:function($){if(this.isLocked)throw Error("The stream '"+this+"' has already been used.");this.streamInfo=$.streamInfo,this.mergeStreamInfo(),this.previous=$;var Q=this;return $.on("data",function(q){Q.processChunk(q)}),$.on("end",function(){Q.end()}),$.on("error",function(q){Q.error(q)}),this},pause:function(){if(this.isPaused||this.isFinished)return!1;if(this.isPaused=!0,this.previous)this.previous.pause();return!0},resume:function(){if(!this.isPaused||this.isFinished)return!1;this.isPaused=!1;var $=!1;if(this.generatedError)this.error(this.generatedError),$=!0;if(this.previous)this.previous.resume();return!$},flush:function(){},processChunk:function($){this.push($)},withStreamInfo:function($,Q){return this.extraStreamInfo[$]=Q,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var $ in this.extraStreamInfo){if(!Object.prototype.hasOwnProperty.call(this.extraStreamInfo,$))continue;this.streamInfo[$]=this.extraStreamInfo[$]}},lock:function(){if(this.isLocked)throw Error("The stream '"+this+"' has already been used.");if(this.isLocked=!0,this.previous)this.previous.lock()},toString:function(){var $="Worker "+this.name;if(this.previous)return this.previous+" -> "+$;else return $}};pV.exports=cV});var d0=T((JG)=>{var u0=p(),O0=n1(),$G=T$(),D6=j1(),x$=Array(256);for(k1=0;k1<256;k1++)x$[k1]=k1>=252?6:k1>=248?5:k1>=240?4:k1>=224?3:k1>=192?2:1;var k1;x$[254]=x$[254]=1;var QG=function($){var Q,q,V,Y,X,J=$.length,G=0;for(Y=0;Y<J;Y++){if(q=$.charCodeAt(Y),(q&64512)===55296&&Y+1<J){if(V=$.charCodeAt(Y+1),(V&64512)===56320)q=65536+(q-55296<<10)+(V-56320),Y++}G+=q<128?1:q<2048?2:q<65536?3:4}if(O0.uint8array)Q=new Uint8Array(G);else Q=Array(G);for(X=0,Y=0;X<G;Y++){if(q=$.charCodeAt(Y),(q&64512)===55296&&Y+1<J){if(V=$.charCodeAt(Y+1),(V&64512)===56320)q=65536+(q-55296<<10)+(V-56320),Y++}if(q<128)Q[X++]=q;else if(q<2048)Q[X++]=192|q>>>6,Q[X++]=128|q&63;else if(q<65536)Q[X++]=224|q>>>12,Q[X++]=128|q>>>6&63,Q[X++]=128|q&63;else Q[X++]=240|q>>>18,Q[X++]=128|q>>>12&63,Q[X++]=128|q>>>6&63,Q[X++]=128|q&63}return Q},qG=function($,Q){var q;if(Q=Q||$.length,Q>$.length)Q=$.length;q=Q-1;while(q>=0&&($[q]&192)===128)q--;if(q<0)return Q;if(q===0)return Q;return q+x$[$[q]]>Q?q:Q},VG=function($){var Q,q,V,Y,X=$.length,J=Array(X*2);for(q=0,Q=0;Q<X;){if(V=$[Q++],V<128){J[q++]=V;continue}if(Y=x$[V],Y>4){J[q++]=65533,Q+=Y-1;continue}V&=Y===2?31:Y===3?15:7;while(Y>1&&Q<X)V=V<<6|$[Q++]&63,Y--;if(Y>1){J[q++]=65533;continue}if(V<65536)J[q++]=V;else V-=65536,J[q++]=55296|V>>10&1023,J[q++]=56320|V&1023}if(J.length!==q)if(J.subarray)J=J.subarray(0,q);else J.length=q;return u0.applyFromCharCode(J)};JG.utf8encode=function(Q){if(O0.nodebuffer)return $G.newBufferFrom(Q,"utf-8");return QG(Q)};JG.utf8decode=function(Q){if(O0.nodebuffer)return u0.transformTo("nodebuffer",Q).toString("utf-8");return Q=u0.transformTo(O0.uint8array?"uint8array":"array",Q),VG(Q)};function h6(){D6.call(this,"utf-8 decode"),this.leftOver=null}u0.inherits(h6,D6);h6.prototype.processChunk=function($){var Q=u0.transformTo(O0.uint8array?"uint8array":"array",$.data);if(this.leftOver&&this.leftOver.length){if(O0.uint8array){var q=Q;Q=new Uint8Array(q.length+this.leftOver.length),Q.set(this.leftOver,0),Q.set(q,this.leftOver.length)}else Q=this.leftOver.concat(Q);this.leftOver=null}var V=qG(Q),Y=Q;if(V!==Q.length)if(O0.uint8array)Y=Q.subarray(0,V),this.leftOver=Q.subarray(V,Q.length);else Y=Q.slice(0,V),this.leftOver=Q.slice(V,Q.length);this.push({data:JG.utf8decode(Y),meta:$.meta})};h6.prototype.flush=function(){if(this.leftOver&&this.leftOver.length)this.push({data:JG.utf8decode(this.leftOver),meta:{}}),this.leftOver=null};JG.Utf8DecodeWorker=h6;function T5(){D6.call(this,"utf-8 encode")}u0.inherits(T5,D6);T5.prototype.processChunk=function($){this.push({data:JG.utf8encode($.data),meta:$.meta})};JG.Utf8EncodeWorker=T5});var iV=T((qL,oV)=>{var dV=j1(),lV=p();function F5($){dV.call(this,"ConvertWorker to "+$),this.destType=$}lV.inherits(F5,dV);F5.prototype.processChunk=function($){this.push({data:lV.transformTo(this.destType,$.data),meta:$.meta})};oV.exports=F5});var aV=T((VL,rV)=>{var nV=H5().Readable,GG=p();GG.inherits(R5,nV);function R5($,Q,q){nV.call(this,Q),this._helper=$;var V=this;$.on("data",function(Y,X){if(!V.push(Y))V._helper.pause();if(q)q(X)}).on("error",function(Y){V.emit("error",Y)}).on("end",function(){V.push(null)})}R5.prototype._read=function(){this._helper.resume()};rV.exports=R5});var v5=T((JL,eV)=>{var M0=p(),KG=iV(),WG=j1(),UG=O5(),jG=n1(),ZG=c0(),sV=null;if(jG.nodestream)try{sV=aV()}catch($){}function zG($,Q,q){switch($){case"blob":return M0.newBlob(M0.transformTo("arraybuffer",Q),q);case"base64":return UG.encode(Q);default:return M0.transformTo($,Q)}}function HG($,Q){var q,V=0,Y=null,X=0;for(q=0;q<Q.length;q++)X+=Q[q].length;switch($){case"string":return Q.join("");case"array":return Array.prototype.concat.apply([],Q);case"uint8array":Y=new Uint8Array(X);for(q=0;q<Q.length;q++)Y.set(Q[q],V),V+=Q[q].length;return Y;case"nodebuffer":return Buffer.concat(Q);default:throw Error("concat : unsupported type '"+$+"'")}}function LG($,Q){return new ZG.Promise(function(q,V){var Y=[],X=$._internalType,J=$._outputType,G=$._mimeType;$.on("data",function(U,K){if(Y.push(U),Q)Q(K)}).on("error",function(U){Y=[],V(U)}).on("end",function(){try{var U=zG(J,HG(X,Y),G);q(U)}catch(K){V(K)}Y=[]}).resume()})}function tV($,Q,q){var V=Q;switch(Q){case"blob":case"arraybuffer":V="uint8array";break;case"base64":V="string";break}try{this._internalType=V,this._outputType=Q,this._mimeType=q,M0.checkSupport(V),this._worker=$.pipe(new KG(V)),$.lock()}catch(Y){this._worker=new WG("error"),this._worker.error(Y)}}tV.prototype={accumulate:function($){return LG(this,$)},on:function($,Q){var q=this;if($==="data")this._worker.on($,function(V){Q.call(q,V.data,V.meta)});else this._worker.on($,function(){M0.delay(Q,arguments,q)});return this},resume:function(){return M0.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function($){if(M0.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw Error(this._outputType+" is not supported by this method");return new sV(this,{objectMode:this._outputType!=="nodebuffer"},$)}};eV.exports=tV});var x5=T((PG)=>{PG.base64=!1;PG.binary=!1;PG.dir=!1;PG.createFolders=!0;PG.date=null;PG.compression=null;PG.compressionOptions=null;PG.comment=null;PG.unixPermissions=null;PG.dosPermissions=null});var S5=T((XL,$9)=>{var _6=p(),b6=j1(),RG=16384;function l0($){b6.call(this,"DataWorker");var Q=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,$.then(function(q){if(Q.dataIsReady=!0,Q.data=q,Q.max=q&&q.length||0,Q.type=_6.getTypeOf(q),!Q.isPaused)Q._tickAndRepeat()},function(q){Q.error(q)})}_6.inherits(l0,b6);l0.prototype.cleanUp=function(){b6.prototype.cleanUp.call(this),this.data=null};l0.prototype.resume=function(){if(!b6.prototype.resume.call(this))return!1;if(!this._tickScheduled&&this.dataIsReady)this._tickScheduled=!0,_6.delay(this._tickAndRepeat,[],this);return!0};l0.prototype._tickAndRepeat=function(){if(this._tickScheduled=!1,this.isPaused||this.isFinished)return;if(this._tick(),!this.isFinished)_6.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0};l0.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var $=RG,Q=null,q=Math.min(this.max,this.index+$);if(this.index>=this.max)return this.end();else{switch(this.type){case"string":Q=this.data.substring(this.index,q);break;case"uint8array":Q=this.data.subarray(this.index,q);break;case"array":case"nodebuffer":Q=this.data.slice(this.index,q);break}return this.index=q,this.push({data:Q,meta:{percent:this.max?this.index/this.max*100:0}})}};$9.exports=l0});var f6=T((GL,q9)=>{var vG=p();function xG(){var $,Q=[];for(var q=0;q<256;q++){$=q;for(var V=0;V<8;V++)$=$&1?3988292384^$>>>1:$>>>1;Q[q]=$}return Q}var Q9=xG();function SG($,Q,q,V){var Y=Q9,X=V+q;$=$^-1;for(var J=V;J<X;J++)$=$>>>8^Y[($^Q[J])&255];return $^-1}function EG($,Q,q,V){var Y=Q9,X=V+q;$=$^-1;for(var J=V;J<X;J++)$=$>>>8^Y[($^Q.charCodeAt(J))&255];return $^-1}q9.exports=function(Q,q){if(typeof Q>"u"||!Q.length)return 0;var V=vG.getTypeOf(Q)!=="string";if(V)return SG(q|0,Q,Q.length,0);else return EG(q|0,Q,Q.length,0)}});var y5=T((KL,J9)=>{var V9=j1(),yG=f6(),kG=p();function E5(){V9.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}kG.inherits(E5,V9);E5.prototype.processChunk=function($){this.streamInfo.crc32=yG($.data,this.streamInfo.crc32||0),this.push($)};J9.exports=E5});var X9=T((WL,Y9)=>{var gG=p(),k5=j1();function g5($){k5.call(this,"DataLengthProbe for "+$),this.propName=$,this.withStreamInfo($,0)}gG.inherits(g5,k5);g5.prototype.processChunk=function($){if($){var Q=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=Q+$.data.length}k5.prototype.processChunk.call(this,$)};Y9.exports=g5});var m6=T((UL,W9)=>{var G9=c0(),K9=S5(),DG=y5(),D5=X9();function h5($,Q,q,V,Y){this.compressedSize=$,this.uncompressedSize=Q,this.crc32=q,this.compression=V,this.compressedContent=Y}h5.prototype={getContentWorker:function(){var $=new K9(G9.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new D5("data_length")),Q=this;return $.on("end",function(){if(this.streamInfo.data_length!==Q.uncompressedSize)throw Error("Bug : uncompressed data size mismatch")}),$},getCompressedWorker:function(){return new K9(G9.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}};h5.createWorkerFrom=function($,Q,q){return $.pipe(new DG).pipe(new D5("uncompressedSize")).pipe(Q.compressWorker(q)).pipe(new D5("compressedSize")).withStreamInfo("compression",Q)};W9.exports=h5});var z9=T((jL,Z9)=>{var hG=v5(),_G=S5(),_5=d0(),b5=m6(),U9=j1(),f5=function($,Q,q){this.name=$,this.dir=q.dir,this.date=q.date,this.comment=q.comment,this.unixPermissions=q.unixPermissions,this.dosPermissions=q.dosPermissions,this._data=Q,this._dataBinary=q.binary,this.options={compression:q.compression,compressionOptions:q.compressionOptions}};f5.prototype={internalStream:function($){var Q=null,q="string";try{if(!$)throw Error("No output type specified.");q=$.toLowerCase();var V=q==="string"||q==="text";if(q==="binarystring"||q==="text")q="string";Q=this._decompressWorker();var Y=!this._dataBinary;if(Y&&!V)Q=Q.pipe(new _5.Utf8EncodeWorker);if(!Y&&V)Q=Q.pipe(new _5.Utf8DecodeWorker)}catch(X){Q=new U9("error"),Q.error(X)}return new hG(Q,q,"")},async:function($,Q){return this.internalStream($).accumulate(Q)},nodeStream:function($,Q){return this.internalStream($||"nodebuffer").toNodejsStream(Q)},_compressWorker:function($,Q){if(this._data instanceof b5&&this._data.compression.magic===$.magic)return this._data.getCompressedWorker();else{var q=this._decompressWorker();if(!this._dataBinary)q=q.pipe(new _5.Utf8EncodeWorker);return b5.createWorkerFrom(q,$,Q)}},_decompressWorker:function(){if(this._data instanceof b5)return this._data.getContentWorker();else if(this._data instanceof U9)return this._data;else return new _G(this._data)}};var j9=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],bG=function(){throw Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")};for(S$=0;S$<j9.length;S$++)f5.prototype[j9[S$]]=bG;var S$;Z9.exports=f5});var r1=T((m5)=>{var pG=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";function uG($,Q){return Object.prototype.hasOwnProperty.call($,Q)}m5.assign=function($){var Q=Array.prototype.slice.call(arguments,1);while(Q.length){var q=Q.shift();if(!q)continue;if(typeof q!=="object")throw TypeError(q+"must be non-object");for(var V in q)if(uG(q,V))$[V]=q[V]}return $};m5.shrinkBuf=function($,Q){if($.length===Q)return $;if($.subarray)return $.subarray(0,Q);return $.length=Q,$};var dG={arraySet:function($,Q,q,V,Y){if(Q.subarray&&$.subarray){$.set(Q.subarray(q,q+V),Y);return}for(var X=0;X<V;X++)$[Y+X]=Q[q+X]},flattenChunks:function($){var Q,q,V,Y,X,J;V=0;for(Q=0,q=$.length;Q<q;Q++)V+=$[Q].length;J=new Uint8Array(V),Y=0;for(Q=0,q=$.length;Q<q;Q++)X=$[Q],J.set(X,Y),Y+=X.length;return J}},lG={arraySet:function($,Q,q,V,Y){for(var X=0;X<V;X++)$[Y+X]=Q[q+X]},flattenChunks:function($){return[].concat.apply([],$)}};m5.setTyped=function($){if($)m5.Buf8=Uint8Array,m5.Buf16=Uint16Array,m5.Buf32=Int32Array,m5.assign(m5,dG);else m5.Buf8=Array,m5.Buf16=Array,m5.Buf32=Array,m5.assign(m5,lG)};m5.setTyped(pG)});var _9=T((HK)=>{var iG=r1(),nG=4,L9=0,P9=1,rG=2;function i0($){var Q=$.length;while(--Q>=0)$[Q]=0}var aG=0,C9=1,sG=2,tG=3,eG=258,n5=29,h$=256,y$=h$+1+n5,o0=30,r5=19,w9=2*y$+1,B0=15,p5=16,$K=7,a5=256,T9=16,A9=17,F9=18,o5=[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],c6=[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],QK=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],R9=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],qK=512,a1=Array((y$+2)*2);i0(a1);var E$=Array(o0*2);i0(E$);var k$=Array(qK);i0(k$);var g$=Array(eG-tG+1);i0(g$);var s5=Array(n5);i0(s5);var p6=Array(o0);i0(p6);function u5($,Q,q,V,Y){this.static_tree=$,this.extra_bits=Q,this.extra_base=q,this.elems=V,this.max_length=Y,this.has_stree=$&&$.length}var v9,x9,S9;function d5($,Q){this.dyn_tree=$,this.max_code=0,this.stat_desc=Q}function E9($){return $<256?k$[$]:k$[256+($>>>7)]}function D$($,Q){$.pending_buf[$.pending++]=Q&255,$.pending_buf[$.pending++]=Q>>>8&255}function X1($,Q,q){if($.bi_valid>p5-q)$.bi_buf|=Q<<$.bi_valid&65535,D$($,$.bi_buf),$.bi_buf=Q>>p5-$.bi_valid,$.bi_valid+=q-p5;else $.bi_buf|=Q<<$.bi_valid&65535,$.bi_valid+=q}function g1($,Q,q){X1($,q[Q*2],q[Q*2+1])}function y9($,Q){var q=0;do q|=$&1,$>>>=1,q<<=1;while(--Q>0);return q>>>1}function VK($){if($.bi_valid===16)D$($,$.bi_buf),$.bi_buf=0,$.bi_valid=0;else if($.bi_valid>=8)$.pending_buf[$.pending++]=$.bi_buf&255,$.bi_buf>>=8,$.bi_valid-=8}function JK($,Q){var{dyn_tree:q,max_code:V}=Q,Y=Q.stat_desc.static_tree,X=Q.stat_desc.has_stree,J=Q.stat_desc.extra_bits,G=Q.stat_desc.extra_base,U=Q.stat_desc.max_length,K,W,Z,z,H,I,N=0;for(z=0;z<=B0;z++)$.bl_count[z]=0;q[$.heap[$.heap_max]*2+1]=0;for(K=$.heap_max+1;K<w9;K++){if(W=$.heap[K],z=q[q[W*2+1]*2+1]+1,z>U)z=U,N++;if(q[W*2+1]=z,W>V)continue;if($.bl_count[z]++,H=0,W>=G)H=J[W-G];if(I=q[W*2],$.opt_len+=I*(z+H),X)$.static_len+=I*(Y[W*2+1]+H)}if(N===0)return;do{z=U-1;while($.bl_count[z]===0)z--;$.bl_count[z]--,$.bl_count[z+1]+=2,$.bl_count[U]--,N-=2}while(N>0);for(z=U;z!==0;z--){W=$.bl_count[z];while(W!==0){if(Z=$.heap[--K],Z>V)continue;if(q[Z*2+1]!==z)$.opt_len+=(z-q[Z*2+1])*q[Z*2],q[Z*2+1]=z;W--}}}function k9($,Q,q){var V=Array(B0+1),Y=0,X,J;for(X=1;X<=B0;X++)V[X]=Y=Y+q[X-1]<<1;for(J=0;J<=Q;J++){var G=$[J*2+1];if(G===0)continue;$[J*2]=y9(V[G]++,G)}}function YK(){var $,Q,q,V,Y,X=Array(B0+1);q=0;for(V=0;V<n5-1;V++){s5[V]=q;for($=0;$<1<<o5[V];$++)g$[q++]=V}g$[q-1]=V,Y=0;for(V=0;V<16;V++){p6[V]=Y;for($=0;$<1<<c6[V];$++)k$[Y++]=V}Y>>=7;for(;V<o0;V++){p6[V]=Y<<7;for($=0;$<1<<c6[V]-7;$++)k$[256+Y++]=V}for(Q=0;Q<=B0;Q++)X[Q]=0;$=0;while($<=143)a1[$*2+1]=8,$++,X[8]++;while($<=255)a1[$*2+1]=9,$++,X[9]++;while($<=279)a1[$*2+1]=7,$++,X[7]++;while($<=287)a1[$*2+1]=8,$++,X[8]++;k9(a1,y$+1,X);for($=0;$<o0;$++)E$[$*2+1]=5,E$[$*2]=y9($,5);v9=new u5(a1,o5,h$+1,y$,B0),x9=new u5(E$,c6,0,o0,B0),S9=new u5([],QK,0,r5,$K)}function g9($){var Q;for(Q=0;Q<y$;Q++)$.dyn_ltree[Q*2]=0;for(Q=0;Q<o0;Q++)$.dyn_dtree[Q*2]=0;for(Q=0;Q<r5;Q++)$.bl_tree[Q*2]=0;$.dyn_ltree[a5*2]=1,$.opt_len=$.static_len=0,$.last_lit=$.matches=0}function D9($){if($.bi_valid>8)D$($,$.bi_buf);else if($.bi_valid>0)$.pending_buf[$.pending++]=$.bi_buf;$.bi_buf=0,$.bi_valid=0}function XK($,Q,q,V){if(D9($),V)D$($,q),D$($,~q);iG.arraySet($.pending_buf,$.window,Q,q,$.pending),$.pending+=q}function O9($,Q,q,V){var Y=Q*2,X=q*2;return $[Y]<$[X]||$[Y]===$[X]&&V[Q]<=V[q]}function l5($,Q,q){var V=$.heap[q],Y=q<<1;while(Y<=$.heap_len){if(Y<$.heap_len&&O9(Q,$.heap[Y+1],$.heap[Y],$.depth))Y++;if(O9(Q,V,$.heap[Y],$.depth))break;$.heap[q]=$.heap[Y],q=Y,Y<<=1}$.heap[q]=V}function M9($,Q,q){var V,Y,X=0,J,G;if($.last_lit!==0)do if(V=$.pending_buf[$.d_buf+X*2]<<8|$.pending_buf[$.d_buf+X*2+1],Y=$.pending_buf[$.l_buf+X],X++,V===0)g1($,Y,Q);else{if(J=g$[Y],g1($,J+h$+1,Q),G=o5[J],G!==0)Y-=s5[J],X1($,Y,G);if(V--,J=E9(V),g1($,J,q),G=c6[J],G!==0)V-=p6[J],X1($,V,G)}while(X<$.last_lit);g1($,a5,Q)}function i5($,Q){var q=Q.dyn_tree,V=Q.stat_desc.static_tree,Y=Q.stat_desc.has_stree,X=Q.stat_desc.elems,J,G,U=-1,K;$.heap_len=0,$.heap_max=w9;for(J=0;J<X;J++)if(q[J*2]!==0)$.heap[++$.heap_len]=U=J,$.depth[J]=0;else q[J*2+1]=0;while($.heap_len<2)if(K=$.heap[++$.heap_len]=U<2?++U:0,q[K*2]=1,$.depth[K]=0,$.opt_len--,Y)$.static_len-=V[K*2+1];Q.max_code=U;for(J=$.heap_len>>1;J>=1;J--)l5($,q,J);K=X;do J=$.heap[1],$.heap[1]=$.heap[$.heap_len--],l5($,q,1),G=$.heap[1],$.heap[--$.heap_max]=J,$.heap[--$.heap_max]=G,q[K*2]=q[J*2]+q[G*2],$.depth[K]=($.depth[J]>=$.depth[G]?$.depth[J]:$.depth[G])+1,q[J*2+1]=q[G*2+1]=K,$.heap[1]=K++,l5($,q,1);while($.heap_len>=2);$.heap[--$.heap_max]=$.heap[1],JK($,Q),k9(q,U,$.bl_count)}function B9($,Q,q){var V,Y=-1,X,J=Q[1],G=0,U=7,K=4;if(J===0)U=138,K=3;Q[(q+1)*2+1]=65535;for(V=0;V<=q;V++){if(X=J,J=Q[(V+1)*2+1],++G<U&&X===J)continue;else if(G<K)$.bl_tree[X*2]+=G;else if(X!==0){if(X!==Y)$.bl_tree[X*2]++;$.bl_tree[T9*2]++}else if(G<=10)$.bl_tree[A9*2]++;else $.bl_tree[F9*2]++;if(G=0,Y=X,J===0)U=138,K=3;else if(X===J)U=6,K=3;else U=7,K=4}}function N9($,Q,q){var V,Y=-1,X,J=Q[1],G=0,U=7,K=4;if(J===0)U=138,K=3;for(V=0;V<=q;V++){if(X=J,J=Q[(V+1)*2+1],++G<U&&X===J)continue;else if(G<K)do g1($,X,$.bl_tree);while(--G!==0);else if(X!==0){if(X!==Y)g1($,X,$.bl_tree),G--;g1($,T9,$.bl_tree),X1($,G-3,2)}else if(G<=10)g1($,A9,$.bl_tree),X1($,G-3,3);else g1($,F9,$.bl_tree),X1($,G-11,7);if(G=0,Y=X,J===0)U=138,K=3;else if(X===J)U=6,K=3;else U=7,K=4}}function GK($){var Q;B9($,$.dyn_ltree,$.l_desc.max_code),B9($,$.dyn_dtree,$.d_desc.max_code),i5($,$.bl_desc);for(Q=r5-1;Q>=3;Q--)if($.bl_tree[R9[Q]*2+1]!==0)break;return $.opt_len+=3*(Q+1)+5+5+4,Q}function KK($,Q,q,V){var Y;X1($,Q-257,5),X1($,q-1,5),X1($,V-4,4);for(Y=0;Y<V;Y++)X1($,$.bl_tree[R9[Y]*2+1],3);N9($,$.dyn_ltree,Q-1),N9($,$.dyn_dtree,q-1)}function WK($){var Q=4093624447,q;for(q=0;q<=31;q++,Q>>>=1)if(Q&1&&$.dyn_ltree[q*2]!==0)return L9;if($.dyn_ltree[18]!==0||$.dyn_ltree[20]!==0||$.dyn_ltree[26]!==0)return P9;for(q=32;q<h$;q++)if($.dyn_ltree[q*2]!==0)return P9;return L9}var I9=!1;function UK($){if(!I9)YK(),I9=!0;$.l_desc=new d5($.dyn_ltree,v9),$.d_desc=new d5($.dyn_dtree,x9),$.bl_desc=new d5($.bl_tree,S9),$.bi_buf=0,$.bi_valid=0,g9($)}function h9($,Q,q,V){X1($,(aG<<1)+(V?1:0),3),XK($,Q,q,!0)}function jK($){X1($,C9<<1,3),g1($,a5,a1),VK($)}function ZK($,Q,q,V){var Y,X,J=0;if($.level>0){if($.strm.data_type===rG)$.strm.data_type=WK($);if(i5($,$.l_desc),i5($,$.d_desc),J=GK($),Y=$.opt_len+3+7>>>3,X=$.static_len+3+7>>>3,X<=Y)Y=X}else Y=X=q+5;if(q+4<=Y&&Q!==-1)h9($,Q,q,V);else if($.strategy===nG||X===Y)X1($,(C9<<1)+(V?1:0),3),M9($,a1,E$);else X1($,(sG<<1)+(V?1:0),3),KK($,$.l_desc.max_code+1,$.d_desc.max_code+1,J+1),M9($,$.dyn_ltree,$.dyn_dtree);if(g9($),V)D9($)}function zK($,Q,q){if($.pending_buf[$.d_buf+$.last_lit*2]=Q>>>8&255,$.pending_buf[$.d_buf+$.last_lit*2+1]=Q&255,$.pending_buf[$.l_buf+$.last_lit]=q&255,$.last_lit++,Q===0)$.dyn_ltree[q*2]++;else $.matches++,Q--,$.dyn_ltree[(g$[q]+h$+1)*2]++,$.dyn_dtree[E9(Q)*2]++;return $.last_lit===$.lit_bufsize-1}HK._tr_init=UK;HK._tr_stored_block=h9;HK._tr_flush_block=ZK;HK._tr_tally=zK;HK._tr_align=jK});var t5=T((HL,b9)=>{function NK($,Q,q,V){var Y=$&65535|0,X=$>>>16&65535|0,J=0;while(q!==0){J=q>2000?2000:q,q-=J;do Y=Y+Q[V++]|0,X=X+Y|0;while(--J);Y%=65521,X%=65521}return Y|X<<16|0}b9.exports=NK});var e5=T((LL,f9)=>{function IK(){var $,Q=[];for(var q=0;q<256;q++){$=q;for(var V=0;V<8;V++)$=$&1?3988292384^$>>>1:$>>>1;Q[q]=$}return Q}var CK=IK();function wK($,Q,q,V){var Y=CK,X=V+q;$^=-1;for(var J=V;J<X;J++)$=$>>>8^Y[($^Q[J])&255];return $^-1}f9.exports=wK});var u6=T((PL,m9)=>{m9.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"}});var r9=T((qW)=>{var V1=r1(),L1=_9(),d9=t5(),X0=e5(),TK=u6(),w0=0,AK=1,FK=3,j0=4,c9=5,h1=0,p9=1,P1=-2,RK=-3,$Q=-5,vK=-1,xK=1,d6=2,SK=3,EK=4,yK=0,kK=2,n6=8,gK=9,DK=15,hK=8,_K=29,bK=256,qQ=bK+1+_K,fK=30,mK=19,cK=2*qQ+1,pK=15,S=3,W0=258,R1=W0+S+1,uK=32,r6=42,VQ=69,l6=73,o6=91,i6=103,N0=113,b$=666,n=1,f$=2,I0=3,a0=4,dK=3;function U0($,Q){return $.msg=TK[Q],Q}function u9($){return($<<1)-($>4?9:0)}function K0($){var Q=$.length;while(--Q>=0)$[Q]=0}function G0($){var Q=$.state,q=Q.pending;if(q>$.avail_out)q=$.avail_out;if(q===0)return;if(V1.arraySet($.output,Q.pending_buf,Q.pending_out,q,$.next_out),$.next_out+=q,Q.pending_out+=q,$.total_out+=q,$.avail_out-=q,Q.pending-=q,Q.pending===0)Q.pending_out=0}function t($,Q){L1._tr_flush_block($,$.block_start>=0?$.block_start:-1,$.strstart-$.block_start,Q),$.block_start=$.strstart,G0($.strm)}function E($,Q){$.pending_buf[$.pending++]=Q}function _$($,Q){$.pending_buf[$.pending++]=Q>>>8&255,$.pending_buf[$.pending++]=Q&255}function lK($,Q,q,V){var Y=$.avail_in;if(Y>V)Y=V;if(Y===0)return 0;if($.avail_in-=Y,V1.arraySet(Q,$.input,$.next_in,Y,q),$.state.wrap===1)$.adler=d9($.adler,Q,Y,q);else if($.state.wrap===2)$.adler=X0($.adler,Q,Y,q);return $.next_in+=Y,$.total_in+=Y,Y}function l9($,Q){var{max_chain_length:q,strstart:V}=$,Y,X,J=$.prev_length,G=$.nice_match,U=$.strstart>$.w_size-R1?$.strstart-($.w_size-R1):0,K=$.window,W=$.w_mask,Z=$.prev,z=$.strstart+W0,H=K[V+J-1],I=K[V+J];if($.prev_length>=$.good_match)q>>=2;if(G>$.lookahead)G=$.lookahead;do{if(Y=Q,K[Y+J]!==I||K[Y+J-1]!==H||K[Y]!==K[V]||K[++Y]!==K[V+1])continue;V+=2,Y++;do;while(K[++V]===K[++Y]&&K[++V]===K[++Y]&&K[++V]===K[++Y]&&K[++V]===K[++Y]&&K[++V]===K[++Y]&&K[++V]===K[++Y]&&K[++V]===K[++Y]&&K[++V]===K[++Y]&&V<z);if(X=W0-(z-V),V=z-W0,X>J){if($.match_start=Q,J=X,X>=G)break;H=K[V+J-1],I=K[V+J]}}while((Q=Z[Q&W])>U&&--q!==0);if(J<=$.lookahead)return J;return $.lookahead}function C0($){var Q=$.w_size,q,V,Y,X,J;do{if(X=$.window_size-$.lookahead-$.strstart,$.strstart>=Q+(Q-R1)){V1.arraySet($.window,$.window,Q,Q,0),$.match_start-=Q,$.strstart-=Q,$.block_start-=Q,V=$.hash_size,q=V;do Y=$.head[--q],$.head[q]=Y>=Q?Y-Q:0;while(--V);V=Q,q=V;do Y=$.prev[--q],$.prev[q]=Y>=Q?Y-Q:0;while(--V);X+=Q}if($.strm.avail_in===0)break;if(V=lK($.strm,$.window,$.strstart+$.lookahead,X),$.lookahead+=V,$.lookahead+$.insert>=S){J=$.strstart-$.insert,$.ins_h=$.window[J],$.ins_h=($.ins_h<<$.hash_shift^$.window[J+1])&$.hash_mask;while($.insert)if($.ins_h=($.ins_h<<$.hash_shift^$.window[J+S-1])&$.hash_mask,$.prev[J&$.w_mask]=$.head[$.ins_h],$.head[$.ins_h]=J,J++,$.insert--,$.lookahead+$.insert<S)break}}while($.lookahead<R1&&$.strm.avail_in!==0)}function oK($,Q){var q=65535;if(q>$.pending_buf_size-5)q=$.pending_buf_size-5;for(;;){if($.lookahead<=1){if(C0($),$.lookahead===0&&Q===w0)return n;if($.lookahead===0)break}$.strstart+=$.lookahead,$.lookahead=0;var V=$.block_start+q;if($.strstart===0||$.strstart>=V){if($.lookahead=$.strstart-V,$.strstart=V,t($,!1),$.strm.avail_out===0)return n}if($.strstart-$.block_start>=$.w_size-R1){if(t($,!1),$.strm.avail_out===0)return n}}if($.insert=0,Q===j0){if(t($,!0),$.strm.avail_out===0)return I0;return a0}if($.strstart>$.block_start){if(t($,!1),$.strm.avail_out===0)return n}return n}function QQ($,Q){var q,V;for(;;){if($.lookahead<R1){if(C0($),$.lookahead<R1&&Q===w0)return n;if($.lookahead===0)break}if(q=0,$.lookahead>=S)$.ins_h=($.ins_h<<$.hash_shift^$.window[$.strstart+S-1])&$.hash_mask,q=$.prev[$.strstart&$.w_mask]=$.head[$.ins_h],$.head[$.ins_h]=$.strstart;if(q!==0&&$.strstart-q<=$.w_size-R1)$.match_length=l9($,q);if($.match_length>=S)if(V=L1._tr_tally($,$.strstart-$.match_start,$.match_length-S),$.lookahead-=$.match_length,$.match_length<=$.max_lazy_match&&$.lookahead>=S){$.match_length--;do $.strstart++,$.ins_h=($.ins_h<<$.hash_shift^$.window[$.strstart+S-1])&$.hash_mask,q=$.prev[$.strstart&$.w_mask]=$.head[$.ins_h],$.head[$.ins_h]=$.strstart;while(--$.match_length!==0);$.strstart++}else $.strstart+=$.match_length,$.match_length=0,$.ins_h=$.window[$.strstart],$.ins_h=($.ins_h<<$.hash_shift^$.window[$.strstart+1])&$.hash_mask;else V=L1._tr_tally($,0,$.window[$.strstart]),$.lookahead--,$.strstart++;if(V){if(t($,!1),$.strm.avail_out===0)return n}}if($.insert=$.strstart<S-1?$.strstart:S-1,Q===j0){if(t($,!0),$.strm.avail_out===0)return I0;return a0}if($.last_lit){if(t($,!1),$.strm.avail_out===0)return n}return f$}function n0($,Q){var q,V,Y;for(;;){if($.lookahead<R1){if(C0($),$.lookahead<R1&&Q===w0)return n;if($.lookahead===0)break}if(q=0,$.lookahead>=S)$.ins_h=($.ins_h<<$.hash_shift^$.window[$.strstart+S-1])&$.hash_mask,q=$.prev[$.strstart&$.w_mask]=$.head[$.ins_h],$.head[$.ins_h]=$.strstart;if($.prev_length=$.match_length,$.prev_match=$.match_start,$.match_length=S-1,q!==0&&$.prev_length<$.max_lazy_match&&$.strstart-q<=$.w_size-R1){if($.match_length=l9($,q),$.match_length<=5&&($.strategy===xK||$.match_length===S&&$.strstart-$.match_start>4096))$.match_length=S-1}if($.prev_length>=S&&$.match_length<=$.prev_length){Y=$.strstart+$.lookahead-S,V=L1._tr_tally($,$.strstart-1-$.prev_match,$.prev_length-S),$.lookahead-=$.prev_length-1,$.prev_length-=2;do if(++$.strstart<=Y)$.ins_h=($.ins_h<<$.hash_shift^$.window[$.strstart+S-1])&$.hash_mask,q=$.prev[$.strstart&$.w_mask]=$.head[$.ins_h],$.head[$.ins_h]=$.strstart;while(--$.prev_length!==0);if($.match_available=0,$.match_length=S-1,$.strstart++,V){if(t($,!1),$.strm.avail_out===0)return n}}else if($.match_available){if(V=L1._tr_tally($,0,$.window[$.strstart-1]),V)t($,!1);if($.strstart++,$.lookahead--,$.strm.avail_out===0)return n}else $.match_available=1,$.strstart++,$.lookahead--}if($.match_available)V=L1._tr_tally($,0,$.window[$.strstart-1]),$.match_available=0;if($.insert=$.strstart<S-1?$.strstart:S-1,Q===j0){if(t($,!0),$.strm.avail_out===0)return I0;return a0}if($.last_lit){if(t($,!1),$.strm.avail_out===0)return n}return f$}function iK($,Q){var q,V,Y,X,J=$.window;for(;;){if($.lookahead<=W0){if(C0($),$.lookahead<=W0&&Q===w0)return n;if($.lookahead===0)break}if($.match_length=0,$.lookahead>=S&&$.strstart>0){if(Y=$.strstart-1,V=J[Y],V===J[++Y]&&V===J[++Y]&&V===J[++Y]){X=$.strstart+W0;do;while(V===J[++Y]&&V===J[++Y]&&V===J[++Y]&&V===J[++Y]&&V===J[++Y]&&V===J[++Y]&&V===J[++Y]&&V===J[++Y]&&Y<X);if($.match_length=W0-(X-Y),$.match_length>$.lookahead)$.match_length=$.lookahead}}if($.match_length>=S)q=L1._tr_tally($,1,$.match_length-S),$.lookahead-=$.match_length,$.strstart+=$.match_length,$.match_length=0;else q=L1._tr_tally($,0,$.window[$.strstart]),$.lookahead--,$.strstart++;if(q){if(t($,!1),$.strm.avail_out===0)return n}}if($.insert=0,Q===j0){if(t($,!0),$.strm.avail_out===0)return I0;return a0}if($.last_lit){if(t($,!1),$.strm.avail_out===0)return n}return f$}function nK($,Q){var q;for(;;){if($.lookahead===0){if(C0($),$.lookahead===0){if(Q===w0)return n;break}}if($.match_length=0,q=L1._tr_tally($,0,$.window[$.strstart]),$.lookahead--,$.strstart++,q){if(t($,!1),$.strm.avail_out===0)return n}}if($.insert=0,Q===j0){if(t($,!0),$.strm.avail_out===0)return I0;return a0}if($.last_lit){if(t($,!1),$.strm.avail_out===0)return n}return f$}function D1($,Q,q,V,Y){this.good_length=$,this.max_lazy=Q,this.nice_length=q,this.max_chain=V,this.func=Y}var r0;r0=[new D1(0,0,0,0,oK),new D1(4,4,8,4,QQ),new D1(4,5,16,8,QQ),new D1(4,6,32,32,QQ),new D1(4,4,16,16,n0),new D1(8,16,32,32,n0),new D1(8,16,128,128,n0),new D1(8,32,128,256,n0),new D1(32,128,258,1024,n0),new D1(32,258,258,4096,n0)];function rK($){$.window_size=2*$.w_size,K0($.head),$.max_lazy_match=r0[$.level].max_lazy,$.good_match=r0[$.level].good_length,$.nice_match=r0[$.level].nice_length,$.max_chain_length=r0[$.level].max_chain,$.strstart=0,$.block_start=0,$.lookahead=0,$.insert=0,$.match_length=$.prev_length=S-1,$.match_available=0,$.ins_h=0}function aK(){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=n6,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 V1.Buf16(cK*2),this.dyn_dtree=new V1.Buf16((2*fK+1)*2),this.bl_tree=new V1.Buf16((2*mK+1)*2),K0(this.dyn_ltree),K0(this.dyn_dtree),K0(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new V1.Buf16(pK+1),this.heap=new V1.Buf16(2*qQ+1),K0(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new V1.Buf16(2*qQ+1),K0(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 o9($){var Q;if(!$||!$.state)return U0($,P1);if($.total_in=$.total_out=0,$.data_type=kK,Q=$.state,Q.pending=0,Q.pending_out=0,Q.wrap<0)Q.wrap=-Q.wrap;return Q.status=Q.wrap?r6:N0,$.adler=Q.wrap===2?0:1,Q.last_flush=w0,L1._tr_init(Q),h1}function i9($){var Q=o9($);if(Q===h1)rK($.state);return Q}function sK($,Q){if(!$||!$.state)return P1;if($.state.wrap!==2)return P1;return $.state.gzhead=Q,h1}function n9($,Q,q,V,Y,X){if(!$)return P1;var J=1;if(Q===vK)Q=6;if(V<0)J=0,V=-V;else if(V>15)J=2,V-=16;if(Y<1||Y>gK||q!==n6||V<8||V>15||Q<0||Q>9||X<0||X>EK)return U0($,P1);if(V===8)V=9;var G=new aK;return $.state=G,G.strm=$,G.wrap=J,G.gzhead=null,G.w_bits=V,G.w_size=1<<G.w_bits,G.w_mask=G.w_size-1,G.hash_bits=Y+7,G.hash_size=1<<G.hash_bits,G.hash_mask=G.hash_size-1,G.hash_shift=~~((G.hash_bits+S-1)/S),G.window=new V1.Buf8(G.w_size*2),G.head=new V1.Buf16(G.hash_size),G.prev=new V1.Buf16(G.w_size),G.lit_bufsize=1<<Y+6,G.pending_buf_size=G.lit_bufsize*4,G.pending_buf=new V1.Buf8(G.pending_buf_size),G.d_buf=1*G.lit_bufsize,G.l_buf=3*G.lit_bufsize,G.level=Q,G.strategy=X,G.method=q,i9($)}function tK($,Q){return n9($,Q,n6,DK,hK,yK)}function eK($,Q){var q,V,Y,X;if(!$||!$.state||Q>c9||Q<0)return $?U0($,P1):P1;if(V=$.state,!$.output||!$.input&&$.avail_in!==0||V.status===b$&&Q!==j0)return U0($,$.avail_out===0?$Q:P1);if(V.strm=$,q=V.last_flush,V.last_flush=Q,V.status===r6)if(V.wrap===2)if($.adler=0,E(V,31),E(V,139),E(V,8),!V.gzhead)E(V,0),E(V,0),E(V,0),E(V,0),E(V,0),E(V,V.level===9?2:V.strategy>=d6||V.level<2?4:0),E(V,dK),V.status=N0;else{if(E(V,(V.gzhead.text?1:0)+(V.gzhead.hcrc?2:0)+(!V.gzhead.extra?0:4)+(!V.gzhead.name?0:8)+(!V.gzhead.comment?0:16)),E(V,V.gzhead.time&255),E(V,V.gzhead.time>>8&255),E(V,V.gzhead.time>>16&255),E(V,V.gzhead.time>>24&255),E(V,V.level===9?2:V.strategy>=d6||V.level<2?4:0),E(V,V.gzhead.os&255),V.gzhead.extra&&V.gzhead.extra.length)E(V,V.gzhead.extra.length&255),E(V,V.gzhead.extra.length>>8&255);if(V.gzhead.hcrc)$.adler=X0($.adler,V.pending_buf,V.pending,0);V.gzindex=0,V.status=VQ}else{var J=n6+(V.w_bits-8<<4)<<8,G=-1;if(V.strategy>=d6||V.level<2)G=0;else if(V.level<6)G=1;else if(V.level===6)G=2;else G=3;if(J|=G<<6,V.strstart!==0)J|=uK;if(J+=31-J%31,V.status=N0,_$(V,J),V.strstart!==0)_$(V,$.adler>>>16),_$(V,$.adler&65535);$.adler=1}if(V.status===VQ)if(V.gzhead.extra){Y=V.pending;while(V.gzindex<(V.gzhead.extra.length&65535)){if(V.pending===V.pending_buf_size){if(V.gzhead.hcrc&&V.pending>Y)$.adler=X0($.adler,V.pending_buf,V.pending-Y,Y);if(G0($),Y=V.pending,V.pending===V.pending_buf_size)break}E(V,V.gzhead.extra[V.gzindex]&255),V.gzindex++}if(V.gzhead.hcrc&&V.pending>Y)$.adler=X0($.adler,V.pending_buf,V.pending-Y,Y);if(V.gzindex===V.gzhead.extra.length)V.gzindex=0,V.status=l6}else V.status=l6;if(V.status===l6)if(V.gzhead.name){Y=V.pending;do{if(V.pending===V.pending_buf_size){if(V.gzhead.hcrc&&V.pending>Y)$.adler=X0($.adler,V.pending_buf,V.pending-Y,Y);if(G0($),Y=V.pending,V.pending===V.pending_buf_size){X=1;break}}if(V.gzindex<V.gzhead.name.length)X=V.gzhead.name.charCodeAt(V.gzindex++)&255;else X=0;E(V,X)}while(X!==0);if(V.gzhead.hcrc&&V.pending>Y)$.adler=X0($.adler,V.pending_buf,V.pending-Y,Y);if(X===0)V.gzindex=0,V.status=o6}else V.status=o6;if(V.status===o6)if(V.gzhead.comment){Y=V.pending;do{if(V.pending===V.pending_buf_size){if(V.gzhead.hcrc&&V.pending>Y)$.adler=X0($.adler,V.pending_buf,V.pending-Y,Y);if(G0($),Y=V.pending,V.pending===V.pending_buf_size){X=1;break}}if(V.gzindex<V.gzhead.comment.length)X=V.gzhead.comment.charCodeAt(V.gzindex++)&255;else X=0;E(V,X)}while(X!==0);if(V.gzhead.hcrc&&V.pending>Y)$.adler=X0($.adler,V.pending_buf,V.pending-Y,Y);if(X===0)V.status=i6}else V.status=i6;if(V.status===i6)if(V.gzhead.hcrc){if(V.pending+2>V.pending_buf_size)G0($);if(V.pending+2<=V.pending_buf_size)E(V,$.adler&255),E(V,$.adler>>8&255),$.adler=0,V.status=N0}else V.status=N0;if(V.pending!==0){if(G0($),$.avail_out===0)return V.last_flush=-1,h1}else if($.avail_in===0&&u9(Q)<=u9(q)&&Q!==j0)return U0($,$Q);if(V.status===b$&&$.avail_in!==0)return U0($,$Q);if($.avail_in!==0||V.lookahead!==0||Q!==w0&&V.status!==b$){var U=V.strategy===d6?nK(V,Q):V.strategy===SK?iK(V,Q):r0[V.level].func(V,Q);if(U===I0||U===a0)V.status=b$;if(U===n||U===I0){if($.avail_out===0)V.last_flush=-1;return h1}if(U===f$){if(Q===AK)L1._tr_align(V);else if(Q!==c9){if(L1._tr_stored_block(V,0,0,!1),Q===FK){if(K0(V.head),V.lookahead===0)V.strstart=0,V.block_start=0,V.insert=0}}if(G0($),$.avail_out===0)return V.last_flush=-1,h1}}if(Q!==j0)return h1;if(V.wrap<=0)return p9;if(V.wrap===2)E(V,$.adler&255),E(V,$.adler>>8&255),E(V,$.adler>>16&255),E(V,$.adler>>24&255),E(V,$.total_in&255),E(V,$.total_in>>8&255),E(V,$.total_in>>16&255),E(V,$.total_in>>24&255);else _$(V,$.adler>>>16),_$(V,$.adler&65535);if(G0($),V.wrap>0)V.wrap=-V.wrap;return V.pending!==0?h1:p9}function $W($){var Q;if(!$||!$.state)return P1;if(Q=$.state.status,Q!==r6&&Q!==VQ&&Q!==l6&&Q!==o6&&Q!==i6&&Q!==N0&&Q!==b$)return U0($,P1);return $.state=null,Q===N0?U0($,RK):h1}function QW($,Q){var q=Q.length,V,Y,X,J,G,U,K,W;if(!$||!$.state)return P1;if(V=$.state,J=V.wrap,J===2||J===1&&V.status!==r6||V.lookahead)return P1;if(J===1)$.adler=d9($.adler,Q,q,0);if(V.wrap=0,q>=V.w_size){if(J===0)K0(V.head),V.strstart=0,V.block_start=0,V.insert=0;W=new V1.Buf8(V.w_size),V1.arraySet(W,Q,q-V.w_size,V.w_size,0),Q=W,q=V.w_size}G=$.avail_in,U=$.next_in,K=$.input,$.avail_in=q,$.next_in=0,$.input=Q,C0(V);while(V.lookahead>=S){Y=V.strstart,X=V.lookahead-(S-1);do V.ins_h=(V.ins_h<<V.hash_shift^V.window[Y+S-1])&V.hash_mask,V.prev[Y&V.w_mask]=V.head[V.ins_h],V.head[V.ins_h]=Y,Y++;while(--X);V.strstart=Y,V.lookahead=S-1,C0(V)}return V.strstart+=V.lookahead,V.block_start=V.strstart,V.insert=V.lookahead,V.lookahead=0,V.match_length=V.prev_length=S-1,V.match_available=0,$.next_in=U,$.input=K,$.avail_in=G,V.wrap=J,h1}qW.deflateInit=tK;qW.deflateInit2=n9;qW.deflateReset=i9;qW.deflateResetKeep=o9;qW.deflateSetHeader=sK;qW.deflate=eK;qW.deflateEnd=$W;qW.deflateSetDictionary=QW;qW.deflateInfo="pako deflate (from Nodeca project)"});var JQ=T((ZW)=>{var a6=r1(),a9=!0,s9=!0;try{String.fromCharCode.apply(null,[0])}catch($){a9=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch($){s9=!1}var m$=new a6.Buf8(256);for(_1=0;_1<256;_1++)m$[_1]=_1>=252?6:_1>=248?5:_1>=240?4:_1>=224?3:_1>=192?2:1;var _1;m$[254]=m$[254]=1;ZW.string2buf=function($){var Q,q,V,Y,X,J=$.length,G=0;for(Y=0;Y<J;Y++){if(q=$.charCodeAt(Y),(q&64512)===55296&&Y+1<J){if(V=$.charCodeAt(Y+1),(V&64512)===56320)q=65536+(q-55296<<10)+(V-56320),Y++}G+=q<128?1:q<2048?2:q<65536?3:4}Q=new a6.Buf8(G);for(X=0,Y=0;X<G;Y++){if(q=$.charCodeAt(Y),(q&64512)===55296&&Y+1<J){if(V=$.charCodeAt(Y+1),(V&64512)===56320)q=65536+(q-55296<<10)+(V-56320),Y++}if(q<128)Q[X++]=q;else if(q<2048)Q[X++]=192|q>>>6,Q[X++]=128|q&63;else if(q<65536)Q[X++]=224|q>>>12,Q[X++]=128|q>>>6&63,Q[X++]=128|q&63;else Q[X++]=240|q>>>18,Q[X++]=128|q>>>12&63,Q[X++]=128|q>>>6&63,Q[X++]=128|q&63}return Q};function t9($,Q){if(Q<65534){if($.subarray&&s9||!$.subarray&&a9)return String.fromCharCode.apply(null,a6.shrinkBuf($,Q))}var q="";for(var V=0;V<Q;V++)q+=String.fromCharCode($[V]);return q}ZW.buf2binstring=function($){return t9($,$.length)};ZW.binstring2buf=function($){var Q=new a6.Buf8($.length);for(var q=0,V=Q.length;q<V;q++)Q[q]=$.charCodeAt(q);return Q};ZW.buf2string=function($,Q){var q,V,Y,X,J=Q||$.length,G=Array(J*2);for(V=0,q=0;q<J;){if(Y=$[q++],Y<128){G[V++]=Y;continue}if(X=m$[Y],X>4){G[V++]=65533,q+=X-1;continue}Y&=X===2?31:X===3?15:7;while(X>1&&q<J)Y=Y<<6|$[q++]&63,X--;if(X>1){G[V++]=65533;continue}if(Y<65536)G[V++]=Y;else Y-=65536,G[V++]=55296|Y>>10&1023,G[V++]=56320|Y&1023}return t9(G,V)};ZW.utf8border=function($,Q){var q;if(Q=Q||$.length,Q>$.length)Q=$.length;q=Q-1;while(q>=0&&($[q]&192)===128)q--;if(q<0)return Q;if(q===0)return Q;return q+m$[$[q]]>Q?q:Q}});var YQ=T((BL,e9)=>{function MW(){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}e9.exports=MW});var V2=T((FW)=>{var c$=r9(),p$=r1(),GQ=JQ(),KQ=u6(),BW=YQ(),q2=Object.prototype.toString,NW=0,XQ=4,s0=0,$2=1,Q2=2,IW=-1,CW=0,wW=8;function T0($){if(!(this instanceof T0))return new T0($);this.options=p$.assign({level:IW,method:wW,chunkSize:16384,windowBits:15,memLevel:8,strategy:CW,to:""},$||{});var Q=this.options;if(Q.raw&&Q.windowBits>0)Q.windowBits=-Q.windowBits;else if(Q.gzip&&Q.windowBits>0&&Q.windowBits<16)Q.windowBits+=16;this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new BW,this.strm.avail_out=0;var q=c$.deflateInit2(this.strm,Q.level,Q.method,Q.windowBits,Q.memLevel,Q.strategy);if(q!==s0)throw Error(KQ[q]);if(Q.header)c$.deflateSetHeader(this.strm,Q.header);if(Q.dictionary){var V;if(typeof Q.dictionary==="string")V=GQ.string2buf(Q.dictionary);else if(q2.call(Q.dictionary)==="[object ArrayBuffer]")V=new Uint8Array(Q.dictionary);else V=Q.dictionary;if(q=c$.deflateSetDictionary(this.strm,V),q!==s0)throw Error(KQ[q]);this._dict_set=!0}}T0.prototype.push=function($,Q){var q=this.strm,V=this.options.chunkSize,Y,X;if(this.ended)return!1;if(X=Q===~~Q?Q:Q===!0?XQ:NW,typeof $==="string")q.input=GQ.string2buf($);else if(q2.call($)==="[object ArrayBuffer]")q.input=new Uint8Array($);else q.input=$;q.next_in=0,q.avail_in=q.input.length;do{if(q.avail_out===0)q.output=new p$.Buf8(V),q.next_out=0,q.avail_out=V;if(Y=c$.deflate(q,X),Y!==$2&&Y!==s0)return this.onEnd(Y),this.ended=!0,!1;if(q.avail_out===0||q.avail_in===0&&(X===XQ||X===Q2))if(this.options.to==="string")this.onData(GQ.buf2binstring(p$.shrinkBuf(q.output,q.next_out)));else this.onData(p$.shrinkBuf(q.output,q.next_out))}while((q.avail_in>0||q.avail_out===0)&&Y!==$2);if(X===XQ)return Y=c$.deflateEnd(this.strm),this.onEnd(Y),this.ended=!0,Y===s0;if(X===Q2)return this.onEnd(s0),q.avail_out=0,!0;return!0};T0.prototype.onData=function($){this.chunks.push($)};T0.prototype.onEnd=function($){if($===s0)if(this.options.to==="string")this.result=this.chunks.join("");else this.result=p$.flattenChunks(this.chunks);this.chunks=[],this.err=$,this.msg=this.strm.msg};function WQ($,Q){var q=new T0(Q);if(q.push($,!0),q.err)throw q.msg||KQ[q.err];return q.result}function TW($,Q){return Q=Q||{},Q.raw=!0,WQ($,Q)}function AW($,Q){return Q=Q||{},Q.gzip=!0,WQ($,Q)}FW.Deflate=T0;FW.deflate=WQ;FW.deflateRaw=TW;FW.gzip=AW});var Y2=T((IL,J2)=>{var s6=30,EW=12;J2.exports=function(Q,q){var V,Y,X,J,G,U,K,W,Z,z,H,I,N,w,P,L,C,O,M,F,R,v,x,_,A;V=Q.state,Y=Q.next_in,_=Q.input,X=Y+(Q.avail_in-5),J=Q.next_out,A=Q.output,G=J-(q-Q.avail_out),U=J+(Q.avail_out-257),K=V.dmax,W=V.wsize,Z=V.whave,z=V.wnext,H=V.window,I=V.hold,N=V.bits,w=V.lencode,P=V.distcode,L=(1<<V.lenbits)-1,C=(1<<V.distbits)-1;$:do{if(N<15)I+=_[Y++]<<N,N+=8,I+=_[Y++]<<N,N+=8;O=w[I&L];Q:for(;;){if(M=O>>>24,I>>>=M,N-=M,M=O>>>16&255,M===0)A[J++]=O&65535;else if(M&16){if(F=O&65535,M&=15,M){if(N<M)I+=_[Y++]<<N,N+=8;F+=I&(1<<M)-1,I>>>=M,N-=M}if(N<15)I+=_[Y++]<<N,N+=8,I+=_[Y++]<<N,N+=8;O=P[I&C];q:for(;;){if(M=O>>>24,I>>>=M,N-=M,M=O>>>16&255,M&16){if(R=O&65535,M&=15,N<M){if(I+=_[Y++]<<N,N+=8,N<M)I+=_[Y++]<<N,N+=8}if(R+=I&(1<<M)-1,R>K){Q.msg="invalid distance too far back",V.mode=s6;break $}if(I>>>=M,N-=M,M=J-G,R>M){if(M=R-M,M>Z){if(V.sane){Q.msg="invalid distance too far back",V.mode=s6;break $}}if(v=0,x=H,z===0){if(v+=W-M,M<F){F-=M;do A[J++]=H[v++];while(--M);v=J-R,x=A}}else if(z<M){if(v+=W+z-M,M-=z,M<F){F-=M;do A[J++]=H[v++];while(--M);if(v=0,z<F){M=z,F-=M;do A[J++]=H[v++];while(--M);v=J-R,x=A}}}else if(v+=z-M,M<F){F-=M;do A[J++]=H[v++];while(--M);v=J-R,x=A}while(F>2)A[J++]=x[v++],A[J++]=x[v++],A[J++]=x[v++],F-=3;if(F){if(A[J++]=x[v++],F>1)A[J++]=x[v++]}}else{v=J-R;do A[J++]=A[v++],A[J++]=A[v++],A[J++]=A[v++],F-=3;while(F>2);if(F){if(A[J++]=A[v++],F>1)A[J++]=A[v++]}}}else if((M&64)===0){O=P[(O&65535)+(I&(1<<M)-1)];continue q}else{Q.msg="invalid distance code",V.mode=s6;break $}break}}else if((M&64)===0){O=w[(O&65535)+(I&(1<<M)-1)];continue Q}else if(M&32){V.mode=EW;break $}else{Q.msg="invalid literal/length code",V.mode=s6;break $}break}}while(Y<X&&J<U);F=N>>3,Y-=F,N-=F<<3,I&=(1<<N)-1,Q.next_in=Y,Q.next_out=J,Q.avail_in=Y<X?5+(X-Y):5-(Y-X),Q.avail_out=J<U?257+(U-J):257-(J-U),V.hold=I,V.bits=N;return}});var Z2=T((CL,j2)=>{var X2=r1(),t0=15,G2=852,K2=592,W2=0,UQ=1,U2=2,yW=[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],kW=[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],gW=[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],DW=[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];j2.exports=function(Q,q,V,Y,X,J,G,U){var K=U.bits,W=0,Z=0,z=0,H=0,I=0,N=0,w=0,P=0,L=0,C=0,O,M,F,R,v,x=null,_=0,A,W1=new X2.Buf16(t0+1),S0=new X2.Buf16(t0+1),G6=null,Kq=0,Wq,K6,W6;for(W=0;W<=t0;W++)W1[W]=0;for(Z=0;Z<Y;Z++)W1[q[V+Z]]++;I=K;for(H=t0;H>=1;H--)if(W1[H]!==0)break;if(I>H)I=H;if(H===0)return X[J++]=20971520,X[J++]=20971520,U.bits=1,0;for(z=1;z<H;z++)if(W1[z]!==0)break;if(I<z)I=z;P=1;for(W=1;W<=t0;W++)if(P<<=1,P-=W1[W],P<0)return-1;if(P>0&&(Q===W2||H!==1))return-1;S0[1]=0;for(W=1;W<t0;W++)S0[W+1]=S0[W]+W1[W];for(Z=0;Z<Y;Z++)if(q[V+Z]!==0)G[S0[q[V+Z]]++]=Z;if(Q===W2)x=G6=G,A=19;else if(Q===UQ)x=yW,_-=257,G6=kW,Kq-=257,A=256;else x=gW,G6=DW,A=-1;if(C=0,Z=0,W=z,v=J,N=I,w=0,F=-1,L=1<<I,R=L-1,Q===UQ&&L>G2||Q===U2&&L>K2)return 1;for(;;){if(Wq=W-w,G[Z]<A)K6=0,W6=G[Z];else if(G[Z]>A)K6=G6[Kq+G[Z]],W6=x[_+G[Z]];else K6=96,W6=0;O=1<<W-w,M=1<<N,z=M;do M-=O,X[v+(C>>w)+M]=Wq<<24|K6<<16|W6|0;while(M!==0);O=1<<W-1;while(C&O)O>>=1;if(O!==0)C&=O-1,C+=O;else C=0;if(Z++,--W1[W]===0){if(W===H)break;W=q[V+G[Z]]}if(W>I&&(C&R)!==F){if(w===0)w=I;v+=z,N=W-w,P=1<<N;while(N+w<H){if(P-=W1[N+w],P<=0)break;N++,P<<=1}if(L+=1<<N,Q===UQ&&L>G2||Q===U2&&L>K2)return 1;F=C&R,X[F]=I<<24|N<<16|v-J|0}}if(C!==0)X[v+C]=W-w<<24|4194304|0;return U.bits=I,0}});var i2=T(($U)=>{var Z1=r1(),PQ=t5(),b1=e5(),hW=Y2(),u$=Z2(),_W=0,b2=1,f2=2,z2=4,bW=5,t6=6,A0=0,fW=1,mW=2,O1=-2,m2=-3,OQ=-4,cW=-5,H2=8,c2=1,L2=2,P2=3,O2=4,M2=5,B2=6,N2=7,I2=8,C2=9,w2=10,Q8=11,s1=12,jQ=13,T2=14,ZQ=15,A2=16,F2=17,R2=18,v2=19,e6=20,$8=21,x2=22,S2=23,E2=24,y2=25,k2=26,zQ=27,g2=28,D2=29,c=30,MQ=31,pW=32,uW=852,dW=592,lW=15,oW=lW;function h2($){return($>>>24&255)+($>>>8&65280)+(($&65280)<<8)+(($&255)<<24)}function iW(){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 Z1.Buf16(320),this.work=new Z1.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function p2($){var Q;if(!$||!$.state)return O1;if(Q=$.state,$.total_in=$.total_out=Q.total=0,$.msg="",Q.wrap)$.adler=Q.wrap&1;return Q.mode=c2,Q.last=0,Q.havedict=0,Q.dmax=32768,Q.head=null,Q.hold=0,Q.bits=0,Q.lencode=Q.lendyn=new Z1.Buf32(uW),Q.distcode=Q.distdyn=new Z1.Buf32(dW),Q.sane=1,Q.back=-1,A0}function u2($){var Q;if(!$||!$.state)return O1;return Q=$.state,Q.wsize=0,Q.whave=0,Q.wnext=0,p2($)}function d2($,Q){var q,V;if(!$||!$.state)return O1;if(V=$.state,Q<0)q=0,Q=-Q;else if(q=(Q>>4)+1,Q<48)Q&=15;if(Q&&(Q<8||Q>15))return O1;if(V.window!==null&&V.wbits!==Q)V.window=null;return V.wrap=q,V.wbits=Q,u2($)}function l2($,Q){var q,V;if(!$)return O1;if(V=new iW,$.state=V,V.window=null,q=d2($,Q),q!==A0)$.state=null;return q}function nW($){return l2($,oW)}var _2=!0,HQ,LQ;function rW($){if(_2){var Q;HQ=new Z1.Buf32(512),LQ=new Z1.Buf32(32),Q=0;while(Q<144)$.lens[Q++]=8;while(Q<256)$.lens[Q++]=9;while(Q<280)$.lens[Q++]=7;while(Q<288)$.lens[Q++]=8;u$(b2,$.lens,0,288,HQ,0,$.work,{bits:9}),Q=0;while(Q<32)$.lens[Q++]=5;u$(f2,$.lens,0,32,LQ,0,$.work,{bits:5}),_2=!1}$.lencode=HQ,$.lenbits=9,$.distcode=LQ,$.distbits=5}function o2($,Q,q,V){var Y,X=$.state;if(X.window===null)X.wsize=1<<X.wbits,X.wnext=0,X.whave=0,X.window=new Z1.Buf8(X.wsize);if(V>=X.wsize)Z1.arraySet(X.window,Q,q-X.wsize,X.wsize,0),X.wnext=0,X.whave=X.wsize;else{if(Y=X.wsize-X.wnext,Y>V)Y=V;if(Z1.arraySet(X.window,Q,q-V,Y,X.wnext),V-=Y,V)Z1.arraySet(X.window,Q,q-V,V,0),X.wnext=V,X.whave=X.wsize;else{if(X.wnext+=Y,X.wnext===X.wsize)X.wnext=0;if(X.whave<X.wsize)X.whave+=Y}}return 0}function aW($,Q){var q,V,Y,X,J,G,U,K,W,Z,z,H,I,N,w=0,P,L,C,O,M,F,R,v,x=new Z1.Buf8(4),_,A,W1=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!$||!$.state||!$.output||!$.input&&$.avail_in!==0)return O1;if(q=$.state,q.mode===s1)q.mode=jQ;J=$.next_out,Y=$.output,U=$.avail_out,X=$.next_in,V=$.input,G=$.avail_in,K=q.hold,W=q.bits,Z=G,z=U,v=A0;$:for(;;)switch(q.mode){case c2:if(q.wrap===0){q.mode=jQ;break}while(W<16){if(G===0)break $;G--,K+=V[X++]<<W,W+=8}if(q.wrap&2&&K===35615){q.check=0,x[0]=K&255,x[1]=K>>>8&255,q.check=b1(q.check,x,2,0),K=0,W=0,q.mode=L2;break}if(q.flags=0,q.head)q.head.done=!1;if(!(q.wrap&1)||(((K&255)<<8)+(K>>8))%31){$.msg="incorrect header check",q.mode=c;break}if((K&15)!==H2){$.msg="unknown compression method",q.mode=c;break}if(K>>>=4,W-=4,R=(K&15)+8,q.wbits===0)q.wbits=R;else if(R>q.wbits){$.msg="invalid window size",q.mode=c;break}q.dmax=1<<R,$.adler=q.check=1,q.mode=K&512?w2:s1,K=0,W=0;break;case L2:while(W<16){if(G===0)break $;G--,K+=V[X++]<<W,W+=8}if(q.flags=K,(q.flags&255)!==H2){$.msg="unknown compression method",q.mode=c;break}if(q.flags&57344){$.msg="unknown header flags set",q.mode=c;break}if(q.head)q.head.text=K>>8&1;if(q.flags&512)x[0]=K&255,x[1]=K>>>8&255,q.check=b1(q.check,x,2,0);K=0,W=0,q.mode=P2;case P2:while(W<32){if(G===0)break $;G--,K+=V[X++]<<W,W+=8}if(q.head)q.head.time=K;if(q.flags&512)x[0]=K&255,x[1]=K>>>8&255,x[2]=K>>>16&255,x[3]=K>>>24&255,q.check=b1(q.check,x,4,0);K=0,W=0,q.mode=O2;case O2:while(W<16){if(G===0)break $;G--,K+=V[X++]<<W,W+=8}if(q.head)q.head.xflags=K&255,q.head.os=K>>8;if(q.flags&512)x[0]=K&255,x[1]=K>>>8&255,q.check=b1(q.check,x,2,0);K=0,W=0,q.mode=M2;case M2:if(q.flags&1024){while(W<16){if(G===0)break $;G--,K+=V[X++]<<W,W+=8}if(q.length=K,q.head)q.head.extra_len=K;if(q.flags&512)x[0]=K&255,x[1]=K>>>8&255,q.check=b1(q.check,x,2,0);K=0,W=0}else if(q.head)q.head.extra=null;q.mode=B2;case B2:if(q.flags&1024){if(H=q.length,H>G)H=G;if(H){if(q.head){if(R=q.head.extra_len-q.length,!q.head.extra)q.head.extra=Array(q.head.extra_len);Z1.arraySet(q.head.extra,V,X,H,R)}if(q.flags&512)q.check=b1(q.check,V,H,X);G-=H,X+=H,q.length-=H}if(q.length)break $}q.length=0,q.mode=N2;case N2:if(q.flags&2048){if(G===0)break $;H=0;do if(R=V[X+H++],q.head&&R&&q.length<65536)q.head.name+=String.fromCharCode(R);while(R&&H<G);if(q.flags&512)q.check=b1(q.check,V,H,X);if(G-=H,X+=H,R)break $}else if(q.head)q.head.name=null;q.length=0,q.mode=I2;case I2:if(q.flags&4096){if(G===0)break $;H=0;do if(R=V[X+H++],q.head&&R&&q.length<65536)q.head.comment+=String.fromCharCode(R);while(R&&H<G);if(q.flags&512)q.check=b1(q.check,V,H,X);if(G-=H,X+=H,R)break $}else if(q.head)q.head.comment=null;q.mode=C2;case C2:if(q.flags&512){while(W<16){if(G===0)break $;G--,K+=V[X++]<<W,W+=8}if(K!==(q.check&65535)){$.msg="header crc mismatch",q.mode=c;break}K=0,W=0}if(q.head)q.head.hcrc=q.flags>>9&1,q.head.done=!0;$.adler=q.check=0,q.mode=s1;break;case w2:while(W<32){if(G===0)break $;G--,K+=V[X++]<<W,W+=8}$.adler=q.check=h2(K),K=0,W=0,q.mode=Q8;case Q8:if(q.havedict===0)return $.next_out=J,$.avail_out=U,$.next_in=X,$.avail_in=G,q.hold=K,q.bits=W,mW;$.adler=q.check=1,q.mode=s1;case s1:if(Q===bW||Q===t6)break $;case jQ:if(q.last){K>>>=W&7,W-=W&7,q.mode=zQ;break}while(W<3){if(G===0)break $;G--,K+=V[X++]<<W,W+=8}switch(q.last=K&1,K>>>=1,W-=1,K&3){case 0:q.mode=T2;break;case 1:if(rW(q),q.mode=e6,Q===t6){K>>>=2,W-=2;break $}break;case 2:q.mode=F2;break;case 3:$.msg="invalid block type",q.mode=c}K>>>=2,W-=2;break;case T2:K>>>=W&7,W-=W&7;while(W<32){if(G===0)break $;G--,K+=V[X++]<<W,W+=8}if((K&65535)!==(K>>>16^65535)){$.msg="invalid stored block lengths",q.mode=c;break}if(q.length=K&65535,K=0,W=0,q.mode=ZQ,Q===t6)break $;case ZQ:q.mode=A2;case A2:if(H=q.length,H){if(H>G)H=G;if(H>U)H=U;if(H===0)break $;Z1.arraySet(Y,V,X,H,J),G-=H,X+=H,U-=H,J+=H,q.length-=H;break}q.mode=s1;break;case F2:while(W<14){if(G===0)break $;G--,K+=V[X++]<<W,W+=8}if(q.nlen=(K&31)+257,K>>>=5,W-=5,q.ndist=(K&31)+1,K>>>=5,W-=5,q.ncode=(K&15)+4,K>>>=4,W-=4,q.nlen>286||q.ndist>30){$.msg="too many length or distance symbols",q.mode=c;break}q.have=0,q.mode=R2;case R2:while(q.have<q.ncode){while(W<3){if(G===0)break $;G--,K+=V[X++]<<W,W+=8}q.lens[W1[q.have++]]=K&7,K>>>=3,W-=3}while(q.have<19)q.lens[W1[q.have++]]=0;if(q.lencode=q.lendyn,q.lenbits=7,_={bits:q.lenbits},v=u$(_W,q.lens,0,19,q.lencode,0,q.work,_),q.lenbits=_.bits,v){$.msg="invalid code lengths set",q.mode=c;break}q.have=0,q.mode=v2;case v2:while(q.have<q.nlen+q.ndist){for(;;){if(w=q.lencode[K&(1<<q.lenbits)-1],P=w>>>24,L=w>>>16&255,C=w&65535,P<=W)break;if(G===0)break $;G--,K+=V[X++]<<W,W+=8}if(C<16)K>>>=P,W-=P,q.lens[q.have++]=C;else{if(C===16){A=P+2;while(W<A){if(G===0)break $;G--,K+=V[X++]<<W,W+=8}if(K>>>=P,W-=P,q.have===0){$.msg="invalid bit length repeat",q.mode=c;break}R=q.lens[q.have-1],H=3+(K&3),K>>>=2,W-=2}else if(C===17){A=P+3;while(W<A){if(G===0)break $;G--,K+=V[X++]<<W,W+=8}K>>>=P,W-=P,R=0,H=3+(K&7),K>>>=3,W-=3}else{A=P+7;while(W<A){if(G===0)break $;G--,K+=V[X++]<<W,W+=8}K>>>=P,W-=P,R=0,H=11+(K&127),K>>>=7,W-=7}if(q.have+H>q.nlen+q.ndist){$.msg="invalid bit length repeat",q.mode=c;break}while(H--)q.lens[q.have++]=R}}if(q.mode===c)break;if(q.lens[256]===0){$.msg="invalid code -- missing end-of-block",q.mode=c;break}if(q.lenbits=9,_={bits:q.lenbits},v=u$(b2,q.lens,0,q.nlen,q.lencode,0,q.work,_),q.lenbits=_.bits,v){$.msg="invalid literal/lengths set",q.mode=c;break}if(q.distbits=6,q.distcode=q.distdyn,_={bits:q.distbits},v=u$(f2,q.lens,q.nlen,q.ndist,q.distcode,0,q.work,_),q.distbits=_.bits,v){$.msg="invalid distances set",q.mode=c;break}if(q.mode=e6,Q===t6)break $;case e6:q.mode=$8;case $8:if(G>=6&&U>=258){if($.next_out=J,$.avail_out=U,$.next_in=X,$.avail_in=G,q.hold=K,q.bits=W,hW($,z),J=$.next_out,Y=$.output,U=$.avail_out,X=$.next_in,V=$.input,G=$.avail_in,K=q.hold,W=q.bits,q.mode===s1)q.back=-1;break}q.back=0;for(;;){if(w=q.lencode[K&(1<<q.lenbits)-1],P=w>>>24,L=w>>>16&255,C=w&65535,P<=W)break;if(G===0)break $;G--,K+=V[X++]<<W,W+=8}if(L&&(L&240)===0){O=P,M=L,F=C;for(;;){if(w=q.lencode[F+((K&(1<<O+M)-1)>>O)],P=w>>>24,L=w>>>16&255,C=w&65535,O+P<=W)break;if(G===0)break $;G--,K+=V[X++]<<W,W+=8}K>>>=O,W-=O,q.back+=O}if(K>>>=P,W-=P,q.back+=P,q.length=C,L===0){q.mode=k2;break}if(L&32){q.back=-1,q.mode=s1;break}if(L&64){$.msg="invalid literal/length code",q.mode=c;break}q.extra=L&15,q.mode=x2;case x2:if(q.extra){A=q.extra;while(W<A){if(G===0)break $;G--,K+=V[X++]<<W,W+=8}q.length+=K&(1<<q.extra)-1,K>>>=q.extra,W-=q.extra,q.back+=q.extra}q.was=q.length,q.mode=S2;case S2:for(;;){if(w=q.distcode[K&(1<<q.distbits)-1],P=w>>>24,L=w>>>16&255,C=w&65535,P<=W)break;if(G===0)break $;G--,K+=V[X++]<<W,W+=8}if((L&240)===0){O=P,M=L,F=C;for(;;){if(w=q.distcode[F+((K&(1<<O+M)-1)>>O)],P=w>>>24,L=w>>>16&255,C=w&65535,O+P<=W)break;if(G===0)break $;G--,K+=V[X++]<<W,W+=8}K>>>=O,W-=O,q.back+=O}if(K>>>=P,W-=P,q.back+=P,L&64){$.msg="invalid distance code",q.mode=c;break}q.offset=C,q.extra=L&15,q.mode=E2;case E2:if(q.extra){A=q.extra;while(W<A){if(G===0)break $;G--,K+=V[X++]<<W,W+=8}q.offset+=K&(1<<q.extra)-1,K>>>=q.extra,W-=q.extra,q.back+=q.extra}if(q.offset>q.dmax){$.msg="invalid distance too far back",q.mode=c;break}q.mode=y2;case y2:if(U===0)break $;if(H=z-U,q.offset>H){if(H=q.offset-H,H>q.whave){if(q.sane){$.msg="invalid distance too far back",q.mode=c;break}}if(H>q.wnext)H-=q.wnext,I=q.wsize-H;else I=q.wnext-H;if(H>q.length)H=q.length;N=q.window}else N=Y,I=J-q.offset,H=q.length;if(H>U)H=U;U-=H,q.length-=H;do Y[J++]=N[I++];while(--H);if(q.length===0)q.mode=$8;break;case k2:if(U===0)break $;Y[J++]=q.length,U--,q.mode=$8;break;case zQ:if(q.wrap){while(W<32){if(G===0)break $;G--,K|=V[X++]<<W,W+=8}if(z-=U,$.total_out+=z,q.total+=z,z)$.adler=q.check=q.flags?b1(q.check,Y,z,J-z):PQ(q.check,Y,z,J-z);if(z=U,(q.flags?K:h2(K))!==q.check){$.msg="incorrect data check",q.mode=c;break}K=0,W=0}q.mode=g2;case g2:if(q.wrap&&q.flags){while(W<32){if(G===0)break $;G--,K+=V[X++]<<W,W+=8}if(K!==(q.total&4294967295)){$.msg="incorrect length check",q.mode=c;break}K=0,W=0}q.mode=D2;case D2:v=fW;break $;case c:v=m2;break $;case MQ:return OQ;case pW:default:return O1}if($.next_out=J,$.avail_out=U,$.next_in=X,$.avail_in=G,q.hold=K,q.bits=W,q.wsize||z!==$.avail_out&&q.mode<c&&(q.mode<zQ||Q!==z2)){if(o2($,$.output,$.next_out,z-$.avail_out))return q.mode=MQ,OQ}if(Z-=$.avail_in,z-=$.avail_out,$.total_in+=Z,$.total_out+=z,q.total+=z,q.wrap&&z)$.adler=q.check=q.flags?b1(q.check,Y,z,$.next_out-z):PQ(q.check,Y,z,$.next_out-z);if($.data_type=q.bits+(q.last?64:0)+(q.mode===s1?128:0)+(q.mode===e6||q.mode===ZQ?256:0),(Z===0&&z===0||Q===z2)&&v===A0)v=cW;return v}function sW($){if(!$||!$.state)return O1;var Q=$.state;if(Q.window)Q.window=null;return $.state=null,A0}function tW($,Q){var q;if(!$||!$.state)return O1;if(q=$.state,(q.wrap&2)===0)return O1;return q.head=Q,Q.done=!1,A0}function eW($,Q){var q=Q.length,V,Y,X;if(!$||!$.state)return O1;if(V=$.state,V.wrap!==0&&V.mode!==Q8)return O1;if(V.mode===Q8){if(Y=1,Y=PQ(Y,Q,q,0),Y!==V.check)return m2}if(X=o2($,Q,q,q),X)return V.mode=MQ,OQ;return V.havedict=1,A0}$U.inflateReset=u2;$U.inflateReset2=d2;$U.inflateResetKeep=p2;$U.inflateInit=nW;$U.inflateInit2=l2;$U.inflate=aW;$U.inflateEnd=sW;$U.inflateGetHeader=tW;$U.inflateSetDictionary=eW;$U.inflateInfo="pako inflate (from Nodeca project)"});var BQ=T((TL,n2)=>{n2.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}});var a2=T((AL,r2)=>{function jU(){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}r2.exports=jU});var t2=T((LU)=>{var e0=i2(),d$=r1(),q8=JQ(),l=BQ(),NQ=u6(),ZU=YQ(),zU=a2(),s2=Object.prototype.toString;function F0($){if(!(this instanceof F0))return new F0($);this.options=d$.assign({chunkSize:16384,windowBits:0,to:""},$||{});var Q=this.options;if(Q.raw&&Q.windowBits>=0&&Q.windowBits<16){if(Q.windowBits=-Q.windowBits,Q.windowBits===0)Q.windowBits=-15}if(Q.windowBits>=0&&Q.windowBits<16&&!($&&$.windowBits))Q.windowBits+=32;if(Q.windowBits>15&&Q.windowBits<48){if((Q.windowBits&15)===0)Q.windowBits|=15}this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new ZU,this.strm.avail_out=0;var q=e0.inflateInit2(this.strm,Q.windowBits);if(q!==l.Z_OK)throw Error(NQ[q]);if(this.header=new zU,e0.inflateGetHeader(this.strm,this.header),Q.dictionary){if(typeof Q.dictionary==="string")Q.dictionary=q8.string2buf(Q.dictionary);else if(s2.call(Q.dictionary)==="[object ArrayBuffer]")Q.dictionary=new Uint8Array(Q.dictionary);if(Q.raw){if(q=e0.inflateSetDictionary(this.strm,Q.dictionary),q!==l.Z_OK)throw Error(NQ[q])}}}F0.prototype.push=function($,Q){var q=this.strm,V=this.options.chunkSize,Y=this.options.dictionary,X,J,G,U,K,W=!1;if(this.ended)return!1;if(J=Q===~~Q?Q:Q===!0?l.Z_FINISH:l.Z_NO_FLUSH,typeof $==="string")q.input=q8.binstring2buf($);else if(s2.call($)==="[object ArrayBuffer]")q.input=new Uint8Array($);else q.input=$;q.next_in=0,q.avail_in=q.input.length;do{if(q.avail_out===0)q.output=new d$.Buf8(V),q.next_out=0,q.avail_out=V;if(X=e0.inflate(q,l.Z_NO_FLUSH),X===l.Z_NEED_DICT&&Y)X=e0.inflateSetDictionary(this.strm,Y);if(X===l.Z_BUF_ERROR&&W===!0)X=l.Z_OK,W=!1;if(X!==l.Z_STREAM_END&&X!==l.Z_OK)return this.onEnd(X),this.ended=!0,!1;if(q.next_out){if(q.avail_out===0||X===l.Z_STREAM_END||q.avail_in===0&&(J===l.Z_FINISH||J===l.Z_SYNC_FLUSH))if(this.options.to==="string"){if(G=q8.utf8border(q.output,q.next_out),U=q.next_out-G,K=q8.buf2string(q.output,G),q.next_out=U,q.avail_out=V-U,U)d$.arraySet(q.output,q.output,G,U,0);this.onData(K)}else this.onData(d$.shrinkBuf(q.output,q.next_out))}if(q.avail_in===0&&q.avail_out===0)W=!0}while((q.avail_in>0||q.avail_out===0)&&X!==l.Z_STREAM_END);if(X===l.Z_STREAM_END)J=l.Z_FINISH;if(J===l.Z_FINISH)return X=e0.inflateEnd(this.strm),this.onEnd(X),this.ended=!0,X===l.Z_OK;if(J===l.Z_SYNC_FLUSH)return this.onEnd(l.Z_OK),q.avail_out=0,!0;return!0};F0.prototype.onData=function($){this.chunks.push($)};F0.prototype.onEnd=function($){if($===l.Z_OK)if(this.options.to==="string")this.result=this.chunks.join("");else this.result=d$.flattenChunks(this.chunks);this.chunks=[],this.err=$,this.msg=this.strm.msg};function IQ($,Q){var q=new F0(Q);if(q.push($,!0),q.err)throw q.msg||NQ[q.err];return q.result}function HU($,Q){return Q=Q||{},Q.raw=!0,IQ($,Q)}LU.Inflate=F0;LU.inflate=IQ;LU.inflateRaw=HU;LU.ungzip=IQ});var Q7=T((RL,$7)=>{var NU=r1().assign,IU=V2(),CU=t2(),wU=BQ(),e2={};NU(e2,IU,CU,wU);$7.exports=e2});var V7=T((RU)=>{var TU=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",AU=Q7(),q7=p(),V8=j1(),FU=TU?"uint8array":"array";RU.magic="\b\x00";function R0($,Q){V8.call(this,"FlateWorker/"+$),this._pako=null,this._pakoAction=$,this._pakoOptions=Q,this.meta={}}q7.inherits(R0,V8);R0.prototype.processChunk=function($){if(this.meta=$.meta,this._pako===null)this._createPako();this._pako.push(q7.transformTo(FU,$.data),!1)};R0.prototype.flush=function(){if(V8.prototype.flush.call(this),this._pako===null)this._createPako();this._pako.push([],!0)};R0.prototype.cleanUp=function(){V8.prototype.cleanUp.call(this),this._pako=null};R0.prototype._createPako=function(){this._pako=new AU[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var $=this;this._pako.onData=function(Q){$.push({data:Q,meta:$.meta})}};RU.compressWorker=function($){return new R0("Deflate",$)};RU.uncompressWorker=function(){return new R0("Inflate",{})}});var CQ=T((EU)=>{var J7=j1();EU.STORE={magic:"\x00\x00",compressWorker:function(){return new J7("STORE compression")},uncompressWorker:function(){return new J7("STORE decompression")}};EU.DEFLATE=V7()});var wQ=T((gU)=>{gU.LOCAL_FILE_HEADER="PK\x03\x04";gU.CENTRAL_FILE_HEADER="PK\x01\x02";gU.CENTRAL_DIRECTORY_END="PK\x05\x06";gU.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x06\x07";gU.ZIP64_CENTRAL_DIRECTORY_END="PK\x06\x06";gU.DATA_DESCRIPTOR="PK\x07\b"});var K7=T((EL,G7)=>{var $$=p(),Q$=j1(),TQ=d0(),Y7=f6(),J8=wQ(),h=function($,Q){var q="",V;for(V=0;V<Q;V++)q+=String.fromCharCode($&255),$=$>>>8;return q},cU=function($,Q){var q=$;if(!$)q=Q?16893:33204;return(q&65535)<<16},pU=function($){return($||0)&63},X7=function($,Q,q,V,Y,X){var{file:J,compression:G}=$,U=X!==TQ.utf8encode,K=$$.transformTo("string",X(J.name)),W=$$.transformTo("string",TQ.utf8encode(J.name)),Z=J.comment,z=$$.transformTo("string",X(Z)),H=$$.transformTo("string",TQ.utf8encode(Z)),I=W.length!==J.name.length,N=H.length!==Z.length,w,P,L="",C="",O="",M=J.dir,F=J.date,R={crc32:0,compressedSize:0,uncompressedSize:0};if(!Q||q)R.crc32=$.crc32,R.compressedSize=$.compressedSize,R.uncompressedSize=$.uncompressedSize;var v=0;if(Q)v|=8;if(!U&&(I||N))v|=2048;var x=0,_=0;if(M)x|=16;if(Y==="UNIX")_=798,x|=cU(J.unixPermissions,M);else _=20,x|=pU(J.dosPermissions,M);if(w=F.getUTCHours(),w=w<<6,w=w|F.getUTCMinutes(),w=w<<5,w=w|F.getUTCSeconds()/2,P=F.getUTCFullYear()-1980,P=P<<4,P=P|F.getUTCMonth()+1,P=P<<5,P=P|F.getUTCDate(),I)C=h(1,1)+h(Y7(K),4)+W,L+="up"+h(C.length,2)+C;if(N)O=h(1,1)+h(Y7(z),4)+H,L+="uc"+h(O.length,2)+O;var A="";A+=`
61
- \x00`,A+=h(v,2),A+=G.magic,A+=h(w,2),A+=h(P,2),A+=h(R.crc32,4),A+=h(R.compressedSize,4),A+=h(R.uncompressedSize,4),A+=h(K.length,2),A+=h(L.length,2);var W1=J8.LOCAL_FILE_HEADER+A+K+L,S0=J8.CENTRAL_FILE_HEADER+h(_,2)+A+h(z.length,2)+"\x00\x00\x00\x00"+h(x,4)+h(V,4)+K+L+z;return{fileRecord:W1,dirRecord:S0}},uU=function($,Q,q,V,Y){var X="",J=$$.transformTo("string",Y(V));return X=J8.CENTRAL_DIRECTORY_END+"\x00\x00\x00\x00"+h($,2)+h($,2)+h(Q,4)+h(q,4)+h(J.length,2)+J,X},dU=function($){var Q="";return Q=J8.DATA_DESCRIPTOR+h($.crc32,4)+h($.compressedSize,4)+h($.uncompressedSize,4),Q};function v1($,Q,q,V){Q$.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=Q,this.zipPlatform=q,this.encodeFileName=V,this.streamFiles=$,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}$$.inherits(v1,Q$);v1.prototype.push=function($){var Q=$.meta.percent||0,q=this.entriesCount,V=this._sources.length;if(this.accumulate)this.contentBuffer.push($);else this.bytesWritten+=$.data.length,Q$.prototype.push.call(this,{data:$.data,meta:{currentFile:this.currentFile,percent:q?(Q+100*(q-V-1))/q:100}})};v1.prototype.openedSource=function($){this.currentSourceOffset=this.bytesWritten,this.currentFile=$.file.name;var Q=this.streamFiles&&!$.file.dir;if(Q){var q=X7($,Q,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:q.fileRecord,meta:{percent:0}})}else this.accumulate=!0};v1.prototype.closedSource=function($){this.accumulate=!1;var Q=this.streamFiles&&!$.file.dir,q=X7($,Q,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(q.dirRecord),Q)this.push({data:dU($),meta:{percent:100}});else{this.push({data:q.fileRecord,meta:{percent:0}});while(this.contentBuffer.length)this.push(this.contentBuffer.shift())}this.currentFile=null};v1.prototype.flush=function(){var $=this.bytesWritten;for(var Q=0;Q<this.dirRecords.length;Q++)this.push({data:this.dirRecords[Q],meta:{percent:100}});var q=this.bytesWritten-$,V=uU(this.dirRecords.length,q,$,this.zipComment,this.encodeFileName);this.push({data:V,meta:{percent:100}})};v1.prototype.prepareNextSource=function(){if(this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused)this.previous.pause();else this.previous.resume()};v1.prototype.registerPrevious=function($){this._sources.push($);var Q=this;return $.on("data",function(q){Q.processChunk(q)}),$.on("end",function(){if(Q.closedSource(Q.previous.streamInfo),Q._sources.length)Q.prepareNextSource();else Q.end()}),$.on("error",function(q){Q.error(q)}),this};v1.prototype.resume=function(){if(!Q$.prototype.resume.call(this))return!1;if(!this.previous&&this._sources.length)return this.prepareNextSource(),!0;if(!this.previous&&!this._sources.length&&!this.generatedError)return this.end(),!0};v1.prototype.error=function($){var Q=this._sources;if(!Q$.prototype.error.call(this,$))return!1;for(var q=0;q<Q.length;q++)try{Q[q].error($)}catch(V){}return!0};v1.prototype.lock=function(){Q$.prototype.lock.call(this);var $=this._sources;for(var Q=0;Q<$.length;Q++)$[Q].lock()};G7.exports=v1});var W7=T((nU)=>{var lU=CQ(),oU=K7(),iU=function($,Q){var q=$||Q,V=lU[q];if(!V)throw Error(q+" is not a valid compression method !");return V};nU.generateWorker=function($,Q,q){var V=new oU(Q.streamFiles,q,Q.platform,Q.encodeFileName),Y=0;try{$.forEach(function(X,J){Y++;var G=iU(J.options.compression,Q.compression),U=J.options.compressionOptions||Q.compressionOptions||{},K=J.dir,W=J.date;J._compressWorker(G,U).withStreamInfo("file",{name:X,dir:K,date:W,comment:J.comment||"",unixPermissions:J.unixPermissions,dosPermissions:J.dosPermissions}).pipe(V)}),V.entriesCount=Y}catch(X){V.error(X)}return V}});var j7=T((kL,U7)=>{var aU=p(),Y8=j1();function l$($,Q){Y8.call(this,"Nodejs stream input adapter for "+$),this._upstreamEnded=!1,this._bindStream(Q)}aU.inherits(l$,Y8);l$.prototype._bindStream=function($){var Q=this;this._stream=$,$.pause(),$.on("data",function(q){Q.push({data:q,meta:{percent:0}})}).on("error",function(q){if(Q.isPaused)this.generatedError=q;else Q.error(q)}).on("end",function(){if(Q.isPaused)Q._upstreamEnded=!0;else Q.end()})};l$.prototype.pause=function(){if(!Y8.prototype.pause.call(this))return!1;return this._stream.pause(),!0};l$.prototype.resume=function(){if(!Y8.prototype.resume.call(this))return!1;if(this._upstreamEnded)this.end();else this._stream.resume();return!0};U7.exports=l$});var I7=T((gL,N7)=>{var sU=d0(),o$=p(),L7=j1(),tU=v5(),P7=x5(),Z7=m6(),eU=z9(),$j=W7(),z7=T$(),Qj=j7(),O7=function($,Q,q){var V=o$.getTypeOf(Q),Y,X=o$.extend(q||{},P7);if(X.date=X.date||new Date,X.compression!==null)X.compression=X.compression.toUpperCase();if(typeof X.unixPermissions==="string")X.unixPermissions=parseInt(X.unixPermissions,8);if(X.unixPermissions&&X.unixPermissions&16384)X.dir=!0;if(X.dosPermissions&&X.dosPermissions&16)X.dir=!0;if(X.dir)$=M7($);if(X.createFolders&&(Y=qj($)))B7.call(this,Y,!0);var J=V==="string"&&X.binary===!1&&X.base64===!1;if(!q||typeof q.binary>"u")X.binary=!J;var G=Q instanceof Z7&&Q.uncompressedSize===0;if(G||X.dir||!Q||Q.length===0)X.base64=!1,X.binary=!0,Q="",X.compression="STORE",V="string";var U=null;if(Q instanceof Z7||Q instanceof L7)U=Q;else if(z7.isNode&&z7.isStream(Q))U=new Qj($,Q);else U=o$.prepareContent($,Q,X.binary,X.optimizedBinaryString,X.base64);var K=new eU($,U,X);this.files[$]=K},qj=function($){if($.slice(-1)==="/")$=$.substring(0,$.length-1);var Q=$.lastIndexOf("/");return Q>0?$.substring(0,Q):""},M7=function($){if($.slice(-1)!=="/")$+="/";return $},B7=function($,Q){if(Q=typeof Q<"u"?Q:P7.createFolders,$=M7($),!this.files[$])O7.call(this,$,null,{dir:!0,createFolders:Q});return this.files[$]};function H7($){return Object.prototype.toString.call($)==="[object RegExp]"}var Vj={load:function(){throw Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function($){var Q,q,V;for(Q in this.files)if(V=this.files[Q],q=Q.slice(this.root.length,Q.length),q&&Q.slice(0,this.root.length)===this.root)$(q,V)},filter:function($){var Q=[];return this.forEach(function(q,V){if($(q,V))Q.push(V)}),Q},file:function($,Q,q){if(arguments.length===1)if(H7($)){var V=$;return this.filter(function(X,J){return!J.dir&&V.test(X)})}else{var Y=this.files[this.root+$];if(Y&&!Y.dir)return Y;else return null}else $=this.root+$,O7.call(this,$,Q,q);return this},folder:function($){if(!$)return this;if(H7($))return this.filter(function(Y,X){return X.dir&&$.test(Y)});var Q=this.root+$,q=B7.call(this,Q),V=this.clone();return V.root=q.name,V},remove:function($){$=this.root+$;var Q=this.files[$];if(!Q){if($.slice(-1)!=="/")$+="/";Q=this.files[$]}if(Q&&!Q.dir)delete this.files[$];else{var q=this.filter(function(Y,X){return X.name.slice(0,$.length)===$});for(var V=0;V<q.length;V++)delete this.files[q[V].name]}return this},generate:function(){throw Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function($){var Q,q={};try{if(q=o$.extend($||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:sU.utf8encode}),q.type=q.type.toLowerCase(),q.compression=q.compression.toUpperCase(),q.type==="binarystring")q.type="string";if(!q.type)throw Error("No output type specified.");if(o$.checkSupport(q.type),q.platform==="darwin"||q.platform==="freebsd"||q.platform==="linux"||q.platform==="sunos")q.platform="UNIX";if(q.platform==="win32")q.platform="DOS";var V=q.comment||this.comment||"";Q=$j.generateWorker(this,q,V)}catch(Y){Q=new L7("error"),Q.error(Y)}return new tU(Q,q.type||"string",q.mimeType)},generateAsync:function($,Q){return this.generateInternalStream($).accumulate(Q)},generateNodeStream:function($,Q){if($=$||{},!$.type)$.type="nodebuffer";return this.generateInternalStream($).toNodejsStream(Q)}};N7.exports=Vj});var AQ=T((DL,w7)=>{var Jj=p();function C7($){this.data=$,this.length=$.length,this.index=0,this.zero=0}C7.prototype={checkOffset:function($){this.checkIndex(this.index+$)},checkIndex:function($){if(this.length<this.zero+$||$<0)throw Error("End of data reached (data length = "+this.length+", asked index = "+$+"). Corrupted zip ?")},setIndex:function($){this.checkIndex($),this.index=$},skip:function($){this.setIndex(this.index+$)},byteAt:function(){},readInt:function($){var Q=0,q;this.checkOffset($);for(q=this.index+$-1;q>=this.index;q--)Q=(Q<<8)+this.byteAt(q);return this.index+=$,Q},readString:function($){return Jj.transformTo("string",this.readData($))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var $=this.readInt(4);return new Date(Date.UTC(($>>25&127)+1980,($>>21&15)-1,$>>16&31,$>>11&31,$>>5&63,($&31)<<1))}};w7.exports=C7});var FQ=T((hL,A7)=>{var T7=AQ(),Yj=p();function q$($){T7.call(this,$);for(var Q=0;Q<this.data.length;Q++)$[Q]=$[Q]&255}Yj.inherits(q$,T7);q$.prototype.byteAt=function($){return this.data[this.zero+$]};q$.prototype.lastIndexOfSignature=function($){var Q=$.charCodeAt(0),q=$.charCodeAt(1),V=$.charCodeAt(2),Y=$.charCodeAt(3);for(var X=this.length-4;X>=0;--X)if(this.data[X]===Q&&this.data[X+1]===q&&this.data[X+2]===V&&this.data[X+3]===Y)return X-this.zero;return-1};q$.prototype.readAndCheckSignature=function($){var Q=$.charCodeAt(0),q=$.charCodeAt(1),V=$.charCodeAt(2),Y=$.charCodeAt(3),X=this.readData(4);return Q===X[0]&&q===X[1]&&V===X[2]&&Y===X[3]};q$.prototype.readData=function($){if(this.checkOffset($),$===0)return[];var Q=this.data.slice(this.zero+this.index,this.zero+this.index+$);return this.index+=$,Q};A7.exports=q$});var v7=T((_L,R7)=>{var F7=AQ(),Xj=p();function V$($){F7.call(this,$)}Xj.inherits(V$,F7);V$.prototype.byteAt=function($){return this.data.charCodeAt(this.zero+$)};V$.prototype.lastIndexOfSignature=function($){return this.data.lastIndexOf($)-this.zero};V$.prototype.readAndCheckSignature=function($){var Q=this.readData(4);return $===Q};V$.prototype.readData=function($){this.checkOffset($);var Q=this.data.slice(this.zero+this.index,this.zero+this.index+$);return this.index+=$,Q};R7.exports=V$});var vQ=T((bL,S7)=>{var x7=FQ(),Gj=p();function RQ($){x7.call(this,$)}Gj.inherits(RQ,x7);RQ.prototype.readData=function($){if(this.checkOffset($),$===0)return new Uint8Array(0);var Q=this.data.subarray(this.zero+this.index,this.zero+this.index+$);return this.index+=$,Q};S7.exports=RQ});var k7=T((fL,y7)=>{var E7=vQ(),Kj=p();function xQ($){E7.call(this,$)}Kj.inherits(xQ,E7);xQ.prototype.readData=function($){this.checkOffset($);var Q=this.data.slice(this.zero+this.index,this.zero+this.index+$);return this.index+=$,Q};y7.exports=xQ});var SQ=T((mL,D7)=>{var X8=p(),g7=n1(),Wj=FQ(),Uj=v7(),jj=k7(),Zj=vQ();D7.exports=function($){var Q=X8.getTypeOf($);if(X8.checkSupport(Q),Q==="string"&&!g7.uint8array)return new Uj($);if(Q==="nodebuffer")return new jj($);if(g7.uint8array)return new Zj(X8.transformTo("uint8array",$));return new Wj(X8.transformTo("array",$))}});var f7=T((cL,b7)=>{var EQ=SQ(),Z0=p(),zj=m6(),h7=f6(),G8=d0(),K8=CQ(),Hj=n1(),Lj=0,Pj=3,Oj=function($){for(var Q in K8){if(!Object.prototype.hasOwnProperty.call(K8,Q))continue;if(K8[Q].magic===$)return K8[Q]}return null};function _7($,Q){this.options=$,this.loadOptions=Q}_7.prototype={isEncrypted:function(){return(this.bitFlag&1)===1},useUTF8:function(){return(this.bitFlag&2048)===2048},readLocalPart:function($){var Q,q;if($.skip(22),this.fileNameLength=$.readInt(2),q=$.readInt(2),this.fileName=$.readData(this.fileNameLength),$.skip(q),this.compressedSize===-1||this.uncompressedSize===-1)throw Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if(Q=Oj(this.compressionMethod),Q===null)throw Error("Corrupted zip : compression "+Z0.pretty(this.compressionMethod)+" unknown (inner file : "+Z0.transformTo("string",this.fileName)+")");this.decompressed=new zj(this.compressedSize,this.uncompressedSize,this.crc32,Q,$.readData(this.compressedSize))},readCentralPart:function($){this.versionMadeBy=$.readInt(2),$.skip(2),this.bitFlag=$.readInt(2),this.compressionMethod=$.readString(2),this.date=$.readDate(),this.crc32=$.readInt(4),this.compressedSize=$.readInt(4),this.uncompressedSize=$.readInt(4);var Q=$.readInt(2);if(this.extraFieldsLength=$.readInt(2),this.fileCommentLength=$.readInt(2),this.diskNumberStart=$.readInt(2),this.internalFileAttributes=$.readInt(2),this.externalFileAttributes=$.readInt(4),this.localHeaderOffset=$.readInt(4),this.isEncrypted())throw Error("Encrypted zip are not supported");$.skip(Q),this.readExtraFields($),this.parseZIP64ExtraField($),this.fileComment=$.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var $=this.versionMadeBy>>8;if(this.dir=this.externalFileAttributes&16?!0:!1,$===Lj)this.dosPermissions=this.externalFileAttributes&63;if($===Pj)this.unixPermissions=this.externalFileAttributes>>16&65535;if(!this.dir&&this.fileNameStr.slice(-1)==="/")this.dir=!0},parseZIP64ExtraField:function(){if(!this.extraFields[1])return;var $=EQ(this.extraFields[1].value);if(this.uncompressedSize===Z0.MAX_VALUE_32BITS)this.uncompressedSize=$.readInt(8);if(this.compressedSize===Z0.MAX_VALUE_32BITS)this.compressedSize=$.readInt(8);if(this.localHeaderOffset===Z0.MAX_VALUE_32BITS)this.localHeaderOffset=$.readInt(8);if(this.diskNumberStart===Z0.MAX_VALUE_32BITS)this.diskNumberStart=$.readInt(4)},readExtraFields:function($){var Q=$.index+this.extraFieldsLength,q,V,Y;if(!this.extraFields)this.extraFields={};while($.index+4<Q)q=$.readInt(2),V=$.readInt(2),Y=$.readData(V),this.extraFields[q]={id:q,length:V,value:Y};$.setIndex(Q)},handleUTF8:function(){var $=Hj.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=G8.utf8decode(this.fileName),this.fileCommentStr=G8.utf8decode(this.fileComment);else{var Q=this.findExtraFieldUnicodePath();if(Q!==null)this.fileNameStr=Q;else{var q=Z0.transformTo($,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(q)}var V=this.findExtraFieldUnicodeComment();if(V!==null)this.fileCommentStr=V;else{var Y=Z0.transformTo($,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(Y)}}},findExtraFieldUnicodePath:function(){var $=this.extraFields[28789];if($){var Q=EQ($.value);if(Q.readInt(1)!==1)return null;if(h7(this.fileName)!==Q.readInt(4))return null;return G8.utf8decode(Q.readData($.length-5))}return null},findExtraFieldUnicodeComment:function(){var $=this.extraFields[25461];if($){var Q=EQ($.value);if(Q.readInt(1)!==1)return null;if(h7(this.fileComment)!==Q.readInt(4))return null;return G8.utf8decode(Q.readData($.length-5))}return null}};b7.exports=_7});var p7=T((pL,c7)=>{var Mj=SQ(),t1=p(),x1=wQ(),Bj=f7(),Nj=n1();function m7($){this.files=[],this.loadOptions=$}m7.prototype={checkSignature:function($){if(!this.reader.readAndCheckSignature($)){this.reader.index-=4;var Q=this.reader.readString(4);throw Error("Corrupted zip or bug: unexpected signature ("+t1.pretty(Q)+", expected "+t1.pretty($)+")")}},isSignature:function($,Q){var q=this.reader.index;this.reader.setIndex($);var V=this.reader.readString(4),Y=V===Q;return this.reader.setIndex(q),Y},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 $=this.reader.readData(this.zipCommentLength),Q=Nj.uint8array?"uint8array":"array",q=t1.transformTo(Q,$);this.zipComment=this.loadOptions.decodeFileName(q)},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={};var $=this.zip64EndOfCentralSize-44,Q=0,q,V,Y;while(Q<$)q=this.reader.readInt(2),V=this.reader.readInt(4),Y=this.reader.readData(V),this.zip64ExtensibleData[q]={id:q,length:V,value:Y}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),this.disksCount>1)throw Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var $,Q;for($=0;$<this.files.length;$++)Q=this.files[$],this.reader.setIndex(Q.localHeaderOffset),this.checkSignature(x1.LOCAL_FILE_HEADER),Q.readLocalPart(this.reader),Q.handleUTF8(),Q.processAttributes()},readCentralDir:function(){var $;this.reader.setIndex(this.centralDirOffset);while(this.reader.readAndCheckSignature(x1.CENTRAL_FILE_HEADER))$=new Bj({zip64:this.zip64},this.loadOptions),$.readCentralPart(this.reader),this.files.push($);if(this.centralDirRecords!==this.files.length){if(this.centralDirRecords!==0&&this.files.length===0)throw Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)}},readEndOfCentral:function(){var $=this.reader.lastIndexOfSignature(x1.CENTRAL_DIRECTORY_END);if($<0){var Q=!this.isSignature(0,x1.LOCAL_FILE_HEADER);if(Q)throw 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");else throw Error("Corrupted zip: can't find end of central directory")}this.reader.setIndex($);var q=$;if(this.checkSignature(x1.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===t1.MAX_VALUE_16BITS||this.diskWithCentralDirStart===t1.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===t1.MAX_VALUE_16BITS||this.centralDirRecords===t1.MAX_VALUE_16BITS||this.centralDirSize===t1.MAX_VALUE_32BITS||this.centralDirOffset===t1.MAX_VALUE_32BITS){if(this.zip64=!0,$=this.reader.lastIndexOfSignature(x1.ZIP64_CENTRAL_DIRECTORY_LOCATOR),$<0)throw Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex($),this.checkSignature(x1.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,x1.ZIP64_CENTRAL_DIRECTORY_END)){if(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(x1.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0)throw Error("Corrupted zip: can't find the ZIP64 end of central directory")}this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(x1.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var V=this.centralDirOffset+this.centralDirSize;if(this.zip64)V+=20,V+=12+this.zip64EndOfCentralSize;var Y=q-V;if(Y>0)if(this.isSignature(q,x1.CENTRAL_FILE_HEADER));else this.reader.zero=Y;else if(Y<0)throw Error("Corrupted zip: missing "+Math.abs(Y)+" bytes.")},prepareReader:function($){this.reader=Mj($)},load:function($){this.prepareReader($),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}};c7.exports=m7});var l7=T((uL,d7)=>{var yQ=p(),W8=c0(),Ij=d0(),Cj=p7(),wj=y5(),u7=T$();function Tj($){return new W8.Promise(function(Q,q){var V=$.decompressed.getContentWorker().pipe(new wj);V.on("error",function(Y){q(Y)}).on("end",function(){if(V.streamInfo.crc32!==$.decompressed.crc32)q(Error("Corrupted zip : CRC32 mismatch"));else Q()}).resume()})}d7.exports=function($,Q){var q=this;if(Q=yQ.extend(Q||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:Ij.utf8decode}),u7.isNode&&u7.isStream($))return W8.Promise.reject(Error("JSZip can't accept a stream when loading a zip file."));return yQ.prepareContent("the loaded zip file",$,!0,Q.optimizedBinaryString,Q.base64).then(function(V){var Y=new Cj(Q);return Y.load(V),Y}).then(function(Y){var X=[W8.Promise.resolve(Y)],J=Y.files;if(Q.checkCRC32)for(var G=0;G<J.length;G++)X.push(Tj(J[G]));return W8.Promise.all(X)}).then(function(Y){var X=Y.shift(),J=X.files;for(var G=0;G<J.length;G++){var U=J[G],K=U.fileNameStr,W=yQ.resolve(U.fileNameStr);if(q.file(W,U.decompressed,{binary:!0,optimizedBinaryString:!0,date:U.date,dir:U.dir,comment:U.fileCommentStr.length?U.fileCommentStr:null,unixPermissions:U.unixPermissions,dosPermissions:U.dosPermissions,createFolders:Q.createFolders}),!U.dir)q.file(W).unsafeOriginalName=K}if(X.zipComment.length)q.comment=X.zipComment;return q})}});var i7=T((dL,o7)=>{function M1(){if(!(this instanceof M1))return new M1;if(arguments.length)throw 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 $=new M1;for(var Q in this)if(typeof this[Q]!=="function")$[Q]=this[Q];return $}}M1.prototype=I7();M1.prototype.loadAsync=l7();M1.support=n1();M1.defaults=x5();M1.version="3.10.1";M1.loadAsync=function($,Q){return new M1().loadAsync($,Q)};M1.external=c0();o7.exports=M1});import{homedir as zZ}from"node:os";import a from"node:path";function HZ($=process.env,Q=G1){if($.OPENCODE_CONFIG_DIR)return $.OPENCODE_CONFIG_DIR;if($.XDG_CONFIG_HOME)return a.join($.XDG_CONFIG_HOME,"opencode");return a.join(Q,".config","opencode")}function z1($,Q,q,V){return`[ -f "$HOME/.petdex/runtime/hooks-disabled" ] && exit 0; ${['if [ -x "$HOME/.petdex/bin/petdex.js" ] || [ -f "$HOME/.petdex/bin/petdex.js" ]; then',` node "$HOME/.petdex/bin/petdex.js" bubble ${Q} ${$} >/dev/null 2>&1 || true;`,"else",` ${LZ($,q,V)};`,"fi"].join(" ")}`}function LZ($,Q,q){let V=q!=null?`{"state":"${Q}","duration":${q},"agent_source":"${$}"}`:`{"state":"${Q}","agent_source":"${$}"}`;return['T="$(cat "$HOME/.petdex/runtime/update-token" 2>/dev/null)"',`[ -n "$T" ] && curl -s -m 0.3 -X POST ${v0}`,'-H "Content-Type: application/json"','-H "X-Petdex-Update-Token: $T"',`--data-raw '${V}'`,">/dev/null 2>&1 || true"].join(" ")}function PZ(){let $=v0.replace(/\/state$/,"/bubble");return String.raw`// petdex hook plugin. Auto-generated by 'petdex hooks install'.
77
+ `)},info:(Q,$)=>{o.message(Q,{...$,symbol:I("blue",xV)})},success:(Q,$)=>{o.message(Q,{...$,symbol:I("green",vV)})},step:(Q,$)=>{o.message(Q,{...$,symbol:I("green",h8)})},warn:(Q,$)=>{o.message(Q,{...$,symbol:I("yellow",EV)})},warning:(Q,$)=>{o.warn(Q,$)},error:(Q,$)=>{o.message(Q,{...$,symbol:I("red",SV)})}},OL={light:b("─","-"),heavy:b("━","="),block:b("█","#")},NL=`${I("gray",y)} `});var y6=w((ML,M5)=>{if(typeof process>"u"||!process.version||process.version.indexOf("v0.")===0||process.version.indexOf("v1.")===0&&process.version.indexOf("v1.8.")!==0)M5.exports={nextTick:bV};else M5.exports=process;function bV(Q,$,J,q){if(typeof Q!=="function")throw TypeError('"callback" argument must be a function');var Y=arguments.length,V,X;switch(Y){case 0:case 1:return process.nextTick(Q);case 2:return process.nextTick(function(){Q.call(null,$)});case 3:return process.nextTick(function(){Q.call(null,$,J)});case 4:return process.nextTick(function(){Q.call(null,$,J,q)});default:V=Array(Y-1),X=0;while(X<V.length)V[X++]=arguments[X];return process.nextTick(function(){Q.apply(null,V)})}}});var S7=w((PL,E7)=>{var hV={}.toString;E7.exports=Array.isArray||function(Q){return hV.call(Q)=="[object Array]"}});var g6=w((P5,y7)=>{var m8=_("buffer"),V1=m8.Buffer;function k7(Q,$){for(var J in Q)$[J]=Q[J]}if(V1.from&&V1.alloc&&V1.allocUnsafe&&V1.allocUnsafeSlow)y7.exports=m8;else k7(m8,P5),P5.Buffer=s1;function s1(Q,$,J){return V1(Q,$,J)}k7(V1,s1);s1.from=function(Q,$,J){if(typeof Q==="number")throw TypeError("Argument must not be a number");return V1(Q,$,J)};s1.alloc=function(Q,$,J){if(typeof Q!=="number")throw TypeError("Argument must be a number");var q=V1(Q);if($!==void 0)if(typeof J==="string")q.fill($,J);else q.fill($);else q.fill(0);return q};s1.allocUnsafe=function(Q){if(typeof Q!=="number")throw TypeError("Argument must be a number");return V1(Q)};s1.allocUnsafeSlow=function(Q){if(typeof Q!=="number")throw TypeError("Argument must be a number");return m8.SlowBuffer(Q)}});var t1=w((eV)=>{function fV(Q){if(Array.isArray)return Array.isArray(Q);return c8(Q)==="[object Array]"}eV.isArray=fV;function mV(Q){return typeof Q==="boolean"}eV.isBoolean=mV;function cV(Q){return Q===null}eV.isNull=cV;function uV(Q){return Q==null}eV.isNullOrUndefined=uV;function pV(Q){return typeof Q==="number"}eV.isNumber=pV;function dV(Q){return typeof Q==="string"}eV.isString=dV;function lV(Q){return typeof Q==="symbol"}eV.isSymbol=lV;function oV(Q){return Q===void 0}eV.isUndefined=oV;function iV(Q){return c8(Q)==="[object RegExp]"}eV.isRegExp=iV;function nV(Q){return typeof Q==="object"&&Q!==null}eV.isObject=nV;function rV(Q){return c8(Q)==="[object Date]"}eV.isDate=rV;function aV(Q){return c8(Q)==="[object Error]"||Q instanceof Error}eV.isError=aV;function sV(Q){return typeof Q==="function"}eV.isFunction=sV;function tV(Q){return Q===null||typeof Q==="boolean"||typeof Q==="number"||typeof Q==="string"||typeof Q==="symbol"||typeof Q>"u"}eV.isPrimitive=tV;eV.isBuffer=_("buffer").Buffer.isBuffer;function c8(Q){return Object.prototype.toString.call(Q)}});var g7=w((TL,I5)=>{if(typeof Object.create==="function")I5.exports=function($,J){if(J)$.super_=J,$.prototype=Object.create(J.prototype,{constructor:{value:$,enumerable:!1,writable:!0,configurable:!0}})};else I5.exports=function($,J){if(J){$.super_=J;var q=function(){};q.prototype=J.prototype,$.prototype=new q,$.prototype.constructor=$}}});var e1=w((CL,T5)=>{try{if(u8=_("util"),typeof u8.inherits!=="function")throw"";T5.exports=u8.inherits}catch(Q){T5.exports=g7()}var u8});var b7=w((AL,C5)=>{function FX(Q,$){if(!(Q instanceof $))throw TypeError("Cannot call a class as a function")}var _7=g6().Buffer,_6=_("util");function LX(Q,$,J){Q.copy($,J)}C5.exports=function(){function Q(){FX(this,Q),this.head=null,this.tail=null,this.length=0}return Q.prototype.push=function(J){var q={data:J,next:null};if(this.length>0)this.tail.next=q;else this.head=q;this.tail=q,++this.length},Q.prototype.unshift=function(J){var q={data:J,next:this.head};if(this.length===0)this.tail=q;this.head=q,++this.length},Q.prototype.shift=function(){if(this.length===0)return;var J=this.head.data;if(this.length===1)this.head=this.tail=null;else this.head=this.head.next;return--this.length,J},Q.prototype.clear=function(){this.head=this.tail=null,this.length=0},Q.prototype.join=function(J){if(this.length===0)return"";var q=this.head,Y=""+q.data;while(q=q.next)Y+=J+q.data;return Y},Q.prototype.concat=function(J){if(this.length===0)return _7.alloc(0);var q=_7.allocUnsafe(J>>>0),Y=this.head,V=0;while(Y)LX(Y.data,q,V),V+=Y.data.length,Y=Y.next;return q},Q}();if(_6&&_6.inspect&&_6.inspect.custom)C5.exports.prototype[_6.inspect.custom]=function(){var Q=_6.inspect({length:this.length});return this.constructor.name+" "+Q}});var A5=w((DL,h7)=>{var p8=y6();function OX(Q,$){var J=this,q=this._readableState&&this._readableState.destroyed,Y=this._writableState&&this._writableState.destroyed;if(q||Y){if($)$(Q);else if(Q){if(!this._writableState)p8.nextTick(d8,this,Q);else if(!this._writableState.errorEmitted)this._writableState.errorEmitted=!0,p8.nextTick(d8,this,Q)}return this}if(this._readableState)this._readableState.destroyed=!0;if(this._writableState)this._writableState.destroyed=!0;return this._destroy(Q||null,function(V){if(!$&&V){if(!J._writableState)p8.nextTick(d8,J,V);else if(!J._writableState.errorEmitted)J._writableState.errorEmitted=!0,p8.nextTick(d8,J,V)}else if($)$(V)}),this}function NX(){if(this._readableState)this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1;if(this._writableState)this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1}function d8(Q,$){Q.emit("error",$)}h7.exports={destroy:OX,undestroy:NX}});var m7=w((wL,f7)=>{f7.exports=_("util").deprecate});var w5=w((RL,n7)=>{var g1=y6();n7.exports=a;function u7(Q){var $=this;this.next=null,this.entry=null,this.finish=function(){_X($,Q)}}var BX=["v0.10","v0.9."].indexOf(process.version.slice(0,5))>-1?setImmediate:g1.nextTick,Q6;a.WritableState=h6;var p7=Object.create(t1());p7.inherits=e1();var MX={deprecate:m7()},d7=_("stream"),o8=g6().Buffer,PX=(typeof global<"u"?global:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function IX(Q){return o8.from(Q)}function TX(Q){return o8.isBuffer(Q)||Q instanceof PX}var l7=A5();p7.inherits(a,d7);function CX(){}function h6(Q,$){Q6=Q6||_1(),Q=Q||{};var J=$ instanceof Q6;if(this.objectMode=!!Q.objectMode,J)this.objectMode=this.objectMode||!!Q.writableObjectMode;var{highWaterMark:q,writableHighWaterMark:Y}=Q,V=this.objectMode?16:16384;if(q||q===0)this.highWaterMark=q;else if(J&&(Y||Y===0))this.highWaterMark=Y;else this.highWaterMark=V;this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var X=Q.decodeStrings===!1;this.decodeStrings=!X,this.defaultEncoding=Q.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(K){EX($,K)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new u7(this)}h6.prototype.getBuffer=function(){var $=this.bufferedRequest,J=[];while($)J.push($),$=$.next;return J};(function(){try{Object.defineProperty(h6.prototype,"buffer",{get:MX.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(Q){}})();var l8;if(typeof Symbol==="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]==="function")l8=Function.prototype[Symbol.hasInstance],Object.defineProperty(a,Symbol.hasInstance,{value:function(Q){if(l8.call(this,Q))return!0;if(this!==a)return!1;return Q&&Q._writableState instanceof h6}});else l8=function(Q){return Q instanceof this};function a(Q){if(Q6=Q6||_1(),!l8.call(a,this)&&!(this instanceof Q6))return new a(Q);if(this._writableState=new h6(Q,this),this.writable=!0,Q){if(typeof Q.write==="function")this._write=Q.write;if(typeof Q.writev==="function")this._writev=Q.writev;if(typeof Q.destroy==="function")this._destroy=Q.destroy;if(typeof Q.final==="function")this._final=Q.final}d7.call(this)}a.prototype.pipe=function(){this.emit("error",Error("Cannot pipe, not readable"))};function AX(Q,$){var J=Error("write after end");Q.emit("error",J),g1.nextTick($,J)}function DX(Q,$,J,q){var Y=!0,V=!1;if(J===null)V=TypeError("May not write null values to stream");else if(typeof J!=="string"&&J!==void 0&&!$.objectMode)V=TypeError("Invalid non-string/buffer chunk");if(V)Q.emit("error",V),g1.nextTick(q,V),Y=!1;return Y}a.prototype.write=function(Q,$,J){var q=this._writableState,Y=!1,V=!q.objectMode&&TX(Q);if(V&&!o8.isBuffer(Q))Q=IX(Q);if(typeof $==="function")J=$,$=null;if(V)$="buffer";else if(!$)$=q.defaultEncoding;if(typeof J!=="function")J=CX;if(q.ended)AX(this,J);else if(V||DX(this,q,Q,J))q.pendingcb++,Y=RX(this,q,V,Q,$,J);return Y};a.prototype.cork=function(){var Q=this._writableState;Q.corked++};a.prototype.uncork=function(){var Q=this._writableState;if(Q.corked){if(Q.corked--,!Q.writing&&!Q.corked&&!Q.bufferProcessing&&Q.bufferedRequest)o7(this,Q)}};a.prototype.setDefaultEncoding=function($){if(typeof $==="string")$=$.toLowerCase();if(!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf(($+"").toLowerCase())>-1))throw TypeError("Unknown encoding: "+$);return this._writableState.defaultEncoding=$,this};function wX(Q,$,J){if(!Q.objectMode&&Q.decodeStrings!==!1&&typeof $==="string")$=o8.from($,J);return $}Object.defineProperty(a.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function RX(Q,$,J,q,Y,V){if(!J){var X=wX($,q,Y);if(q!==X)J=!0,Y="buffer",q=X}var K=$.objectMode?1:q.length;$.length+=K;var W=$.length<$.highWaterMark;if(!W)$.needDrain=!0;if($.writing||$.corked){var G=$.lastBufferedRequest;if($.lastBufferedRequest={chunk:q,encoding:Y,isBuf:J,callback:V,next:null},G)G.next=$.lastBufferedRequest;else $.bufferedRequest=$.lastBufferedRequest;$.bufferedRequestCount+=1}else D5(Q,$,!1,K,q,Y,V);return W}function D5(Q,$,J,q,Y,V,X){if($.writelen=q,$.writecb=X,$.writing=!0,$.sync=!0,J)Q._writev(Y,$.onwrite);else Q._write(Y,V,$.onwrite);$.sync=!1}function xX(Q,$,J,q,Y){if(--$.pendingcb,J)g1.nextTick(Y,q),g1.nextTick(b6,Q,$),Q._writableState.errorEmitted=!0,Q.emit("error",q);else Y(q),Q._writableState.errorEmitted=!0,Q.emit("error",q),b6(Q,$)}function vX(Q){Q.writing=!1,Q.writecb=null,Q.length-=Q.writelen,Q.writelen=0}function EX(Q,$){var J=Q._writableState,q=J.sync,Y=J.writecb;if(vX(J),$)xX(Q,J,q,$,Y);else{var V=i7(J);if(!V&&!J.corked&&!J.bufferProcessing&&J.bufferedRequest)o7(Q,J);if(q)BX(c7,Q,J,V,Y);else c7(Q,J,V,Y)}}function c7(Q,$,J,q){if(!J)SX(Q,$);$.pendingcb--,q(),b6(Q,$)}function SX(Q,$){if($.length===0&&$.needDrain)$.needDrain=!1,Q.emit("drain")}function o7(Q,$){$.bufferProcessing=!0;var J=$.bufferedRequest;if(Q._writev&&J&&J.next){var q=$.bufferedRequestCount,Y=Array(q),V=$.corkedRequestsFree;V.entry=J;var X=0,K=!0;while(J){if(Y[X]=J,!J.isBuf)K=!1;J=J.next,X+=1}if(Y.allBuffers=K,D5(Q,$,!0,$.length,Y,"",V.finish),$.pendingcb++,$.lastBufferedRequest=null,V.next)$.corkedRequestsFree=V.next,V.next=null;else $.corkedRequestsFree=new u7($);$.bufferedRequestCount=0}else{while(J){var{chunk:W,encoding:G,callback:U}=J,z=$.objectMode?1:W.length;if(D5(Q,$,!1,z,W,G,U),J=J.next,$.bufferedRequestCount--,$.writing)break}if(J===null)$.lastBufferedRequest=null}$.bufferedRequest=J,$.bufferProcessing=!1}a.prototype._write=function(Q,$,J){J(Error("_write() is not implemented"))};a.prototype._writev=null;a.prototype.end=function(Q,$,J){var q=this._writableState;if(typeof Q==="function")J=Q,Q=null,$=null;else if(typeof $==="function")J=$,$=null;if(Q!==null&&Q!==void 0)this.write(Q,$);if(q.corked)q.corked=1,this.uncork();if(!q.ending)gX(this,q,J)};function i7(Q){return Q.ending&&Q.length===0&&Q.bufferedRequest===null&&!Q.finished&&!Q.writing}function kX(Q,$){Q._final(function(J){if($.pendingcb--,J)Q.emit("error",J);$.prefinished=!0,Q.emit("prefinish"),b6(Q,$)})}function yX(Q,$){if(!$.prefinished&&!$.finalCalled)if(typeof Q._final==="function")$.pendingcb++,$.finalCalled=!0,g1.nextTick(kX,Q,$);else $.prefinished=!0,Q.emit("prefinish")}function b6(Q,$){var J=i7($);if(J){if(yX(Q,$),$.pendingcb===0)$.finished=!0,Q.emit("finish")}return J}function gX(Q,$,J){if($.ending=!0,b6(Q,$),J)if($.finished)g1.nextTick(J);else Q.once("finish",J);$.ended=!0,Q.writable=!1}function _X(Q,$,J){var q=Q.entry;Q.entry=null;while(q){var Y=q.callback;$.pendingcb--,Y(J),q=q.next}$.corkedRequestsFree.next=Q}Object.defineProperty(a.prototype,"destroyed",{get:function(){if(this._writableState===void 0)return!1;return this._writableState.destroyed},set:function(Q){if(!this._writableState)return;this._writableState.destroyed=Q}});a.prototype.destroy=l7.destroy;a.prototype._undestroy=l7.undestroy;a.prototype._destroy=function(Q,$){this.end(),$(Q)}});var _1=w((xL,t7)=>{var r7=y6(),bX=Object.keys||function(Q){var $=[];for(var J in Q)$.push(J);return $};t7.exports=X1;var a7=Object.create(t1());a7.inherits=e1();var s7=x5(),R5=w5();a7.inherits(X1,s7);{i8=bX(R5.prototype);for(f6=0;f6<i8.length;f6++)if(m6=i8[f6],!X1.prototype[m6])X1.prototype[m6]=R5.prototype[m6]}var i8,m6,f6;function X1(Q){if(!(this instanceof X1))return new X1(Q);if(s7.call(this,Q),R5.call(this,Q),Q&&Q.readable===!1)this.readable=!1;if(Q&&Q.writable===!1)this.writable=!1;if(this.allowHalfOpen=!0,Q&&Q.allowHalfOpen===!1)this.allowHalfOpen=!1;this.once("end",hX)}Object.defineProperty(X1.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function hX(){if(this.allowHalfOpen||this._writableState.ended)return;r7.nextTick(fX,this)}function fX(Q){Q.end()}Object.defineProperty(X1.prototype,"destroyed",{get:function(){if(this._readableState===void 0||this._writableState===void 0)return!1;return this._readableState.destroyed&&this._writableState.destroyed},set:function(Q){if(this._readableState===void 0||this._writableState===void 0)return;this._readableState.destroyed=Q,this._writableState.destroyed=Q}});X1.prototype._destroy=function(Q,$){this.push(null),this.end(),r7.nextTick($,Q)}});var S5=w((eX)=>{var E5=g6().Buffer,e7=E5.isEncoding||function(Q){switch(Q=""+Q,Q&&Q.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function mX(Q){if(!Q)return"utf8";var $;while(!0)switch(Q){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return Q;default:if($)return;Q=(""+Q).toLowerCase(),$=!0}}function cX(Q){var $=mX(Q);if(typeof $!=="string"&&(E5.isEncoding===e7||!e7(Q)))throw Error("Unknown encoding: "+Q);return $||Q}eX.StringDecoder=c6;function c6(Q){this.encoding=cX(Q);var $;switch(this.encoding){case"utf16le":this.text=iX,this.end=nX,$=4;break;case"utf8":this.fillLast=dX,$=4;break;case"base64":this.text=rX,this.end=aX,$=3;break;default:this.write=sX,this.end=tX;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=E5.allocUnsafe($)}c6.prototype.write=function(Q){if(Q.length===0)return"";var $,J;if(this.lastNeed){if($=this.fillLast(Q),$===void 0)return"";J=this.lastNeed,this.lastNeed=0}else J=0;if(J<Q.length)return $?$+this.text(Q,J):this.text(Q,J);return $||""};c6.prototype.end=oX;c6.prototype.text=lX;c6.prototype.fillLast=function(Q){if(this.lastNeed<=Q.length)return Q.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);Q.copy(this.lastChar,this.lastTotal-this.lastNeed,0,Q.length),this.lastNeed-=Q.length};function v5(Q){if(Q<=127)return 0;else if(Q>>5===6)return 2;else if(Q>>4===14)return 3;else if(Q>>3===30)return 4;return Q>>6===2?-1:-2}function uX(Q,$,J){var q=$.length-1;if(q<J)return 0;var Y=v5($[q]);if(Y>=0){if(Y>0)Q.lastNeed=Y-1;return Y}if(--q<J||Y===-2)return 0;if(Y=v5($[q]),Y>=0){if(Y>0)Q.lastNeed=Y-2;return Y}if(--q<J||Y===-2)return 0;if(Y=v5($[q]),Y>=0){if(Y>0)if(Y===2)Y=0;else Q.lastNeed=Y-3;return Y}return 0}function pX(Q,$,J){if(($[0]&192)!==128)return Q.lastNeed=0,"�";if(Q.lastNeed>1&&$.length>1){if(($[1]&192)!==128)return Q.lastNeed=1,"�";if(Q.lastNeed>2&&$.length>2){if(($[2]&192)!==128)return Q.lastNeed=2,"�"}}}function dX(Q){var $=this.lastTotal-this.lastNeed,J=pX(this,Q,$);if(J!==void 0)return J;if(this.lastNeed<=Q.length)return Q.copy(this.lastChar,$,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);Q.copy(this.lastChar,$,0,Q.length),this.lastNeed-=Q.length}function lX(Q,$){var J=uX(this,Q,$);if(!this.lastNeed)return Q.toString("utf8",$);this.lastTotal=J;var q=Q.length-(J-this.lastNeed);return Q.copy(this.lastChar,0,q),Q.toString("utf8",$,q)}function oX(Q){var $=Q&&Q.length?this.write(Q):"";if(this.lastNeed)return $+"�";return $}function iX(Q,$){if((Q.length-$)%2===0){var J=Q.toString("utf16le",$);if(J){var q=J.charCodeAt(J.length-1);if(q>=55296&&q<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=Q[Q.length-2],this.lastChar[1]=Q[Q.length-1],J.slice(0,-1)}return J}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=Q[Q.length-1],Q.toString("utf16le",$,Q.length-1)}function nX(Q){var $=Q&&Q.length?this.write(Q):"";if(this.lastNeed){var J=this.lastTotal-this.lastNeed;return $+this.lastChar.toString("utf16le",0,J)}return $}function rX(Q,$){var J=(Q.length-$)%3;if(J===0)return Q.toString("base64",$);if(this.lastNeed=3-J,this.lastTotal=3,J===1)this.lastChar[0]=Q[Q.length-1];else this.lastChar[0]=Q[Q.length-2],this.lastChar[1]=Q[Q.length-1];return Q.toString("base64",$,Q.length-J)}function aX(Q){var $=Q&&Q.length?this.write(Q):"";if(this.lastNeed)return $+this.lastChar.toString("base64",0,3-this.lastNeed);return $}function sX(Q){return Q.toString(this.encoding)}function tX(Q){return Q&&Q.length?this.write(Q):""}});var x5=w((SL,j4)=>{var J6=y6();j4.exports=c;var $K=S7(),u6;c.ReadableState=X4;var EL=_("events").EventEmitter,q4=function(Q,$){return Q.listeners($).length},b5=_("stream"),p6=g6().Buffer,JK=(typeof global<"u"?global:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function qK(Q){return p6.from(Q)}function YK(Q){return p6.isBuffer(Q)||Q instanceof JK}var Y4=Object.create(t1());Y4.inherits=e1();var k5=_("util"),g=void 0;if(k5&&k5.debuglog)g=k5.debuglog("stream");else g=function(){};var VK=b7(),V4=A5(),$6;Y4.inherits(c,b5);var y5=["error","close","destroy","pause","resume"];function XK(Q,$,J){if(typeof Q.prependListener==="function")return Q.prependListener($,J);if(!Q._events||!Q._events[$])Q.on($,J);else if($K(Q._events[$]))Q._events[$].unshift(J);else Q._events[$]=[J,Q._events[$]]}function X4(Q,$){u6=u6||_1(),Q=Q||{};var J=$ instanceof u6;if(this.objectMode=!!Q.objectMode,J)this.objectMode=this.objectMode||!!Q.readableObjectMode;var{highWaterMark:q,readableHighWaterMark:Y}=Q,V=this.objectMode?16:16384;if(q||q===0)this.highWaterMark=q;else if(J&&(Y||Y===0))this.highWaterMark=Y;else this.highWaterMark=V;if(this.highWaterMark=Math.floor(this.highWaterMark),this.buffer=new VK,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.destroyed=!1,this.defaultEncoding=Q.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,Q.encoding){if(!$6)$6=S5().StringDecoder;this.decoder=new $6(Q.encoding),this.encoding=Q.encoding}}function c(Q){if(u6=u6||_1(),!(this instanceof c))return new c(Q);if(this._readableState=new X4(Q,this),this.readable=!0,Q){if(typeof Q.read==="function")this._read=Q.read;if(typeof Q.destroy==="function")this._destroy=Q.destroy}b5.call(this)}Object.defineProperty(c.prototype,"destroyed",{get:function(){if(this._readableState===void 0)return!1;return this._readableState.destroyed},set:function(Q){if(!this._readableState)return;this._readableState.destroyed=Q}});c.prototype.destroy=V4.destroy;c.prototype._undestroy=V4.undestroy;c.prototype._destroy=function(Q,$){this.push(null),$(Q)};c.prototype.push=function(Q,$){var J=this._readableState,q;if(!J.objectMode){if(typeof Q==="string"){if($=$||J.defaultEncoding,$!==J.encoding)Q=p6.from(Q,$),$="";q=!0}}else q=!0;return K4(this,Q,$,!1,q)};c.prototype.unshift=function(Q){return K4(this,Q,null,!0,!1)};function K4(Q,$,J,q,Y){var V=Q._readableState;if($===null)V.reading=!1,UK(Q,V);else{var X;if(!Y)X=KK(V,$);if(X)Q.emit("error",X);else if(V.objectMode||$&&$.length>0){if(typeof $!=="string"&&!V.objectMode&&Object.getPrototypeOf($)!==p6.prototype)$=qK($);if(q)if(V.endEmitted)Q.emit("error",Error("stream.unshift() after end event"));else g5(Q,V,$,!0);else if(V.ended)Q.emit("error",Error("stream.push() after EOF"));else if(V.reading=!1,V.decoder&&!J)if($=V.decoder.write($),V.objectMode||$.length!==0)g5(Q,V,$,!1);else G4(Q,V);else g5(Q,V,$,!1)}else if(!q)V.reading=!1}return GK(V)}function g5(Q,$,J,q){if($.flowing&&$.length===0&&!$.sync)Q.emit("data",J),Q.read(0);else{if($.length+=$.objectMode?1:J.length,q)$.buffer.unshift(J);else $.buffer.push(J);if($.needReadable)n8(Q)}G4(Q,$)}function KK(Q,$){var J;if(!YK($)&&typeof $!=="string"&&$!==void 0&&!Q.objectMode)J=TypeError("Invalid non-string/buffer chunk");return J}function GK(Q){return!Q.ended&&(Q.needReadable||Q.length<Q.highWaterMark||Q.length===0)}c.prototype.isPaused=function(){return this._readableState.flowing===!1};c.prototype.setEncoding=function(Q){if(!$6)$6=S5().StringDecoder;return this._readableState.decoder=new $6(Q),this._readableState.encoding=Q,this};var Q4=8388608;function WK(Q){if(Q>=Q4)Q=Q4;else Q--,Q|=Q>>>1,Q|=Q>>>2,Q|=Q>>>4,Q|=Q>>>8,Q|=Q>>>16,Q++;return Q}function $4(Q,$){if(Q<=0||$.length===0&&$.ended)return 0;if($.objectMode)return 1;if(Q!==Q)if($.flowing&&$.length)return $.buffer.head.data.length;else return $.length;if(Q>$.highWaterMark)$.highWaterMark=WK(Q);if(Q<=$.length)return Q;if(!$.ended)return $.needReadable=!0,0;return $.length}c.prototype.read=function(Q){g("read",Q),Q=parseInt(Q,10);var $=this._readableState,J=Q;if(Q!==0)$.emittedReadable=!1;if(Q===0&&$.needReadable&&($.length>=$.highWaterMark||$.ended)){if(g("read: emitReadable",$.length,$.ended),$.length===0&&$.ended)_5(this);else n8(this);return null}if(Q=$4(Q,$),Q===0&&$.ended){if($.length===0)_5(this);return null}var q=$.needReadable;if(g("need readable",q),$.length===0||$.length-Q<$.highWaterMark)q=!0,g("length less than watermark",q);if($.ended||$.reading)q=!1,g("reading or ended",q);else if(q){if(g("do read"),$.reading=!0,$.sync=!0,$.length===0)$.needReadable=!0;if(this._read($.highWaterMark),$.sync=!1,!$.reading)Q=$4(J,$)}var Y;if(Q>0)Y=W4(Q,$);else Y=null;if(Y===null)$.needReadable=!0,Q=0;else $.length-=Q;if($.length===0){if(!$.ended)$.needReadable=!0;if(J!==Q&&$.ended)_5(this)}if(Y!==null)this.emit("data",Y);return Y};function UK(Q,$){if($.ended)return;if($.decoder){var J=$.decoder.end();if(J&&J.length)$.buffer.push(J),$.length+=$.objectMode?1:J.length}$.ended=!0,n8(Q)}function n8(Q){var $=Q._readableState;if($.needReadable=!1,!$.emittedReadable)if(g("emitReadable",$.flowing),$.emittedReadable=!0,$.sync)J6.nextTick(J4,Q);else J4(Q)}function J4(Q){g("emit readable"),Q.emit("readable"),h5(Q)}function G4(Q,$){if(!$.readingMore)$.readingMore=!0,J6.nextTick(jK,Q,$)}function jK(Q,$){var J=$.length;while(!$.reading&&!$.flowing&&!$.ended&&$.length<$.highWaterMark)if(g("maybeReadMore read 0"),Q.read(0),J===$.length)break;else J=$.length;$.readingMore=!1}c.prototype._read=function(Q){this.emit("error",Error("_read() is not implemented"))};c.prototype.pipe=function(Q,$){var J=this,q=this._readableState;switch(q.pipesCount){case 0:q.pipes=Q;break;case 1:q.pipes=[q.pipes,Q];break;default:q.pipes.push(Q);break}q.pipesCount+=1,g("pipe count=%d opts=%j",q.pipesCount,$);var Y=(!$||$.end!==!1)&&Q!==process.stdout&&Q!==process.stderr,V=Y?K:T;if(q.endEmitted)J6.nextTick(V);else J.once("end",V);Q.on("unpipe",X);function X(P,L){if(g("onunpipe"),P===J){if(L&&L.hasUnpiped===!1)L.hasUnpiped=!0,U()}}function K(){g("onend"),Q.end()}var W=ZK(J);Q.on("drain",W);var G=!1;function U(){if(g("cleanup"),Q.removeListener("close",F),Q.removeListener("finish",N),Q.removeListener("drain",W),Q.removeListener("error",H),Q.removeListener("unpipe",X),J.removeListener("end",K),J.removeListener("end",T),J.removeListener("data",j),G=!0,q.awaitDrain&&(!Q._writableState||Q._writableState.needDrain))W()}var z=!1;J.on("data",j);function j(P){g("ondata"),z=!1;var L=Q.write(P);if(L===!1&&!z){if((q.pipesCount===1&&q.pipes===Q||q.pipesCount>1&&U4(q.pipes,Q)!==-1)&&!G)g("false write response, pause",q.awaitDrain),q.awaitDrain++,z=!0;J.pause()}}function H(P){if(g("onerror",P),T(),Q.removeListener("error",H),q4(Q,"error")===0)Q.emit("error",P)}XK(Q,"error",H);function F(){Q.removeListener("finish",N),T()}Q.once("close",F);function N(){g("onfinish"),Q.removeListener("close",F),T()}Q.once("finish",N);function T(){g("unpipe"),J.unpipe(Q)}if(Q.emit("pipe",J),!q.flowing)g("pipe resume"),J.resume();return Q};function ZK(Q){return function(){var $=Q._readableState;if(g("pipeOnDrain",$.awaitDrain),$.awaitDrain)$.awaitDrain--;if($.awaitDrain===0&&q4(Q,"data"))$.flowing=!0,h5(Q)}}c.prototype.unpipe=function(Q){var $=this._readableState,J={hasUnpiped:!1};if($.pipesCount===0)return this;if($.pipesCount===1){if(Q&&Q!==$.pipes)return this;if(!Q)Q=$.pipes;if($.pipes=null,$.pipesCount=0,$.flowing=!1,Q)Q.emit("unpipe",this,J);return this}if(!Q){var{pipes:q,pipesCount:Y}=$;$.pipes=null,$.pipesCount=0,$.flowing=!1;for(var V=0;V<Y;V++)q[V].emit("unpipe",this,{hasUnpiped:!1});return this}var X=U4($.pipes,Q);if(X===-1)return this;if($.pipes.splice(X,1),$.pipesCount-=1,$.pipesCount===1)$.pipes=$.pipes[0];return Q.emit("unpipe",this,J),this};c.prototype.on=function(Q,$){var J=b5.prototype.on.call(this,Q,$);if(Q==="data"){if(this._readableState.flowing!==!1)this.resume()}else if(Q==="readable"){var q=this._readableState;if(!q.endEmitted&&!q.readableListening){if(q.readableListening=q.needReadable=!0,q.emittedReadable=!1,!q.reading)J6.nextTick(zK,this);else if(q.length)n8(this)}}return J};c.prototype.addListener=c.prototype.on;function zK(Q){g("readable nexttick read 0"),Q.read(0)}c.prototype.resume=function(){var Q=this._readableState;if(!Q.flowing)g("resume"),Q.flowing=!0,HK(this,Q);return this};function HK(Q,$){if(!$.resumeScheduled)$.resumeScheduled=!0,J6.nextTick(FK,Q,$)}function FK(Q,$){if(!$.reading)g("resume read 0"),Q.read(0);if($.resumeScheduled=!1,$.awaitDrain=0,Q.emit("resume"),h5(Q),$.flowing&&!$.reading)Q.read(0)}c.prototype.pause=function(){if(g("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1)g("pause"),this._readableState.flowing=!1,this.emit("pause");return this};function h5(Q){var $=Q._readableState;g("flow",$.flowing);while($.flowing&&Q.read()!==null);}c.prototype.wrap=function(Q){var $=this,J=this._readableState,q=!1;Q.on("end",function(){if(g("wrapped end"),J.decoder&&!J.ended){var X=J.decoder.end();if(X&&X.length)$.push(X)}$.push(null)}),Q.on("data",function(X){if(g("wrapped data"),J.decoder)X=J.decoder.write(X);if(J.objectMode&&(X===null||X===void 0))return;else if(!J.objectMode&&(!X||!X.length))return;var K=$.push(X);if(!K)q=!0,Q.pause()});for(var Y in Q)if(this[Y]===void 0&&typeof Q[Y]==="function")this[Y]=function(X){return function(){return Q[X].apply(Q,arguments)}}(Y);for(var V=0;V<y5.length;V++)Q.on(y5[V],this.emit.bind(this,y5[V]));return this._read=function(X){if(g("wrapped _read",X),q)q=!1,Q.resume()},this};Object.defineProperty(c.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}});c._fromList=W4;function W4(Q,$){if($.length===0)return null;var J;if($.objectMode)J=$.buffer.shift();else if(!Q||Q>=$.length){if($.decoder)J=$.buffer.join("");else if($.buffer.length===1)J=$.buffer.head.data;else J=$.buffer.concat($.length);$.buffer.clear()}else J=LK(Q,$.buffer,$.decoder);return J}function LK(Q,$,J){var q;if(Q<$.head.data.length)q=$.head.data.slice(0,Q),$.head.data=$.head.data.slice(Q);else if(Q===$.head.data.length)q=$.shift();else q=J?OK(Q,$):NK(Q,$);return q}function OK(Q,$){var J=$.head,q=1,Y=J.data;Q-=Y.length;while(J=J.next){var V=J.data,X=Q>V.length?V.length:Q;if(X===V.length)Y+=V;else Y+=V.slice(0,Q);if(Q-=X,Q===0){if(X===V.length)if(++q,J.next)$.head=J.next;else $.head=$.tail=null;else $.head=J,J.data=V.slice(X);break}++q}return $.length-=q,Y}function NK(Q,$){var J=p6.allocUnsafe(Q),q=$.head,Y=1;q.data.copy(J),Q-=q.data.length;while(q=q.next){var V=q.data,X=Q>V.length?V.length:Q;if(V.copy(J,J.length-Q,0,X),Q-=X,Q===0){if(X===V.length)if(++Y,q.next)$.head=q.next;else $.head=$.tail=null;else $.head=q,q.data=V.slice(X);break}++Y}return $.length-=Y,J}function _5(Q){var $=Q._readableState;if($.length>0)throw Error('"endReadable()" called on non-empty stream');if(!$.endEmitted)$.ended=!0,J6.nextTick(BK,$,Q)}function BK(Q,$){if(!Q.endEmitted&&Q.length===0)Q.endEmitted=!0,$.readable=!1,$.emit("end")}function U4(Q,$){for(var J=0,q=Q.length;J<q;J++)if(Q[J]===$)return J;return-1}});var f5=w((kL,H4)=>{H4.exports=K1;var r8=_1(),z4=Object.create(t1());z4.inherits=e1();z4.inherits(K1,r8);function MK(Q,$){var J=this._transformState;J.transforming=!1;var q=J.writecb;if(!q)return this.emit("error",Error("write callback called multiple times"));if(J.writechunk=null,J.writecb=null,$!=null)this.push($);q(Q);var Y=this._readableState;if(Y.reading=!1,Y.needReadable||Y.length<Y.highWaterMark)this._read(Y.highWaterMark)}function K1(Q){if(!(this instanceof K1))return new K1(Q);if(r8.call(this,Q),this._transformState={afterTransform:MK.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,Q){if(typeof Q.transform==="function")this._transform=Q.transform;if(typeof Q.flush==="function")this._flush=Q.flush}this.on("prefinish",PK)}function PK(){var Q=this;if(typeof this._flush==="function")this._flush(function($,J){Z4(Q,$,J)});else Z4(this,null,null)}K1.prototype.push=function(Q,$){return this._transformState.needTransform=!1,r8.prototype.push.call(this,Q,$)};K1.prototype._transform=function(Q,$,J){throw Error("_transform() is not implemented")};K1.prototype._write=function(Q,$,J){var q=this._transformState;if(q.writecb=J,q.writechunk=Q,q.writeencoding=$,!q.transforming){var Y=this._readableState;if(q.needTransform||Y.needReadable||Y.length<Y.highWaterMark)this._read(Y.highWaterMark)}};K1.prototype._read=function(Q){var $=this._transformState;if($.writechunk!==null&&$.writecb&&!$.transforming)$.transforming=!0,this._transform($.writechunk,$.writeencoding,$.afterTransform);else $.needTransform=!0};K1.prototype._destroy=function(Q,$){var J=this;r8.prototype._destroy.call(this,Q,function(q){$(q),J.emit("close")})};function Z4(Q,$,J){if($)return Q.emit("error",$);if(J!=null)Q.push(J);if(Q._writableState.length)throw Error("Calling transform done when ws.length != 0");if(Q._transformState.transforming)throw Error("Calling transform done when still transforming");return Q.push(null)}});var N4=w((yL,O4)=>{O4.exports=d6;var F4=f5(),L4=Object.create(t1());L4.inherits=e1();L4.inherits(d6,F4);function d6(Q){if(!(this instanceof d6))return new d6(Q);F4.call(this,Q)}d6.prototype._transform=function(Q,$,J){J(null,Q)}});var m5=w((J0,a8)=>{var d0=_("stream");if(process.env.READABLE_STREAM==="disable"&&d0)a8.exports=d0,J0=a8.exports=d0.Readable,J0.Readable=d0.Readable,J0.Writable=d0.Writable,J0.Duplex=d0.Duplex,J0.Transform=d0.Transform,J0.PassThrough=d0.PassThrough,J0.Stream=d0;else J0=a8.exports=x5(),J0.Stream=d0||J0,J0.Readable=J0,J0.Writable=w5(),J0.Duplex=_1(),J0.Transform=f5(),J0.PassThrough=N4()});var G1=w((TK)=>{TK.base64=!0;TK.array=!0;TK.string=!0;TK.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u";TK.nodebuffer=typeof Buffer<"u";TK.uint8array=typeof Uint8Array<"u";if(typeof ArrayBuffer>"u")TK.blob=!1;else{s8=new ArrayBuffer(0);try{TK.blob=new Blob([s8],{type:"application/zip"}).size===0}catch(Q){try{u5=self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder,t8=new u5,t8.append(s8),TK.blob=t8.getBlob("application/zip").size===0}catch($){TK.blob=!1}}}var s8,u5,t8;try{TK.nodestream=!!m5().Readable}catch(Q){TK.nodestream=!1}});var p5=w((SK)=>{var vK=d(),EK=G1(),l0="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";SK.encode=function(Q){var $=[],J,q,Y,V,X,K,W,G=0,U=Q.length,z=U,j=vK.getTypeOf(Q)!=="string";while(G<Q.length){if(z=U-G,!j)J=Q.charCodeAt(G++),q=G<U?Q.charCodeAt(G++):0,Y=G<U?Q.charCodeAt(G++):0;else J=Q[G++],q=G<U?Q[G++]:0,Y=G<U?Q[G++]:0;V=J>>2,X=(J&3)<<4|q>>4,K=z>1?(q&15)<<2|Y>>6:64,W=z>2?Y&63:64,$.push(l0.charAt(V)+l0.charAt(X)+l0.charAt(K)+l0.charAt(W))}return $.join("")};SK.decode=function(Q){var $,J,q,Y,V,X,K,W=0,G=0,U="data:";if(Q.substr(0,U.length)===U)throw Error("Invalid base64 input, it looks like a data url.");Q=Q.replace(/[^A-Za-z0-9+/=]/g,"");var z=Q.length*3/4;if(Q.charAt(Q.length-1)===l0.charAt(64))z--;if(Q.charAt(Q.length-2)===l0.charAt(64))z--;if(z%1!==0)throw Error("Invalid base64 input, bad content length.");var j;if(EK.uint8array)j=new Uint8Array(z|0);else j=Array(z|0);while(W<Q.length){if(Y=l0.indexOf(Q.charAt(W++)),V=l0.indexOf(Q.charAt(W++)),X=l0.indexOf(Q.charAt(W++)),K=l0.indexOf(Q.charAt(W++)),$=Y<<2|V>>4,J=(V&15)<<4|X>>2,q=(X&3)<<6|K,j[G++]=$,X!==64)j[G++]=J;if(K!==64)j[G++]=q}return j}});var l6=w((bL,B4)=>{B4.exports={isNode:typeof Buffer<"u",newBufferFrom:function(Q,$){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(Q,$);else{if(typeof Q==="number")throw Error('The "data" argument must not be a number');return new Buffer(Q,$)}},allocBuffer:function(Q){if(Buffer.alloc)return Buffer.alloc(Q);else{var $=new Buffer(Q);return $.fill(0),$}},isBuffer:function(Q){return Buffer.isBuffer(Q)},isStream:function(Q){return Q&&typeof Q.on==="function"&&typeof Q.pause==="function"&&typeof Q.resume==="function"}}});var I4=w((fL,P4)=>{var hL=global.MutationObserver||global.WebKitMutationObserver,M4;M4=function(){process.nextTick(fK)};var gK,_K,bK,hK,d5,o6=[];function fK(){d5=!0;var Q,$,J=o6.length;while(J){$=o6,o6=[],Q=-1;while(++Q<J)$[Q]();J=o6.length}d5=!1}P4.exports=mK;function mK(Q){if(o6.push(Q)===1&&!d5)M4()}});var x4=w((mL,R4)=>{var T4=I4();function Y6(){}var K0={},C4=["REJECTED"],l5=["FULFILLED"],A4=["PENDING"];q6=["UNHANDLED"];var q6;R4.exports=N1;function N1(Q){if(typeof Q!=="function")throw TypeError("resolver must be a function");if(this.state=A4,this.queue=[],this.outcome=void 0,this.handled=q6,Q!==Y6)D4(this,Q)}N1.prototype.finally=function(Q){if(typeof Q!=="function")return this;var $=this.constructor;return this.then(J,q);function J(Y){function V(){return Y}return $.resolve(Q()).then(V)}function q(Y){function V(){throw Y}return $.resolve(Q()).then(V)}};N1.prototype.catch=function(Q){return this.then(null,Q)};N1.prototype.then=function(Q,$){if(typeof Q!=="function"&&this.state===l5||typeof $!=="function"&&this.state===C4)return this;var J=new this.constructor(Y6);if(this.handled===q6)this.handled=null;if(this.state!==A4){var q=this.state===l5?Q:$;o5(J,q,this.outcome)}else this.queue.push(new i6(J,Q,$));return J};function i6(Q,$,J){if(this.promise=Q,typeof $==="function")this.onFulfilled=$,this.callFulfilled=this.otherCallFulfilled;if(typeof J==="function")this.onRejected=J,this.callRejected=this.otherCallRejected}i6.prototype.callFulfilled=function(Q){K0.resolve(this.promise,Q)};i6.prototype.otherCallFulfilled=function(Q){o5(this.promise,this.onFulfilled,Q)};i6.prototype.callRejected=function(Q){K0.reject(this.promise,Q)};i6.prototype.otherCallRejected=function(Q){o5(this.promise,this.onRejected,Q)};function o5(Q,$,J){T4(function(){var q;try{q=$(J)}catch(Y){return K0.reject(Q,Y)}if(q===Q)K0.reject(Q,TypeError("Cannot resolve promise with itself"));else K0.resolve(Q,q)})}K0.resolve=function(Q,$){var J=w4(cK,$);if(J.status==="error")return K0.reject(Q,J.value);var q=J.value;if(q)D4(Q,q);else{Q.state=l5,Q.outcome=$;var Y=-1,V=Q.queue.length;while(++Y<V)Q.queue[Y].callFulfilled($)}return Q};K0.reject=function(Q,$){if(Q.state=C4,Q.outcome=$,Q.handled===q6)T4(function(){if(Q.handled===q6)process.emit("unhandledRejection",$,Q)});var J=-1,q=Q.queue.length;while(++J<q)Q.queue[J].callRejected($);return Q};function cK(Q){var $=Q&&Q.then;if(Q&&(typeof Q==="object"||typeof Q==="function")&&typeof $==="function")return function(){$.apply(Q,arguments)}}function D4(Q,$){var J=!1;function q(K){if(J)return;J=!0,K0.reject(Q,K)}function Y(K){if(J)return;J=!0,K0.resolve(Q,K)}function V(){$(Y,q)}var X=w4(V);if(X.status==="error")q(X.value)}function w4(Q,$){var J={};try{J.value=Q($),J.status="success"}catch(q){J.status="error",J.value=q}return J}N1.resolve=uK;function uK(Q){if(Q instanceof this)return Q;return K0.resolve(new this(Y6),Q)}N1.reject=pK;function pK(Q){var $=new this(Y6);return K0.reject($,Q)}N1.all=dK;function dK(Q){var $=this;if(Object.prototype.toString.call(Q)!=="[object Array]")return this.reject(TypeError("must be an array"));var J=Q.length,q=!1;if(!J)return this.resolve([]);var Y=Array(J),V=0,X=-1,K=new this(Y6);while(++X<J)W(Q[X],X);return K;function W(G,U){$.resolve(G).then(z,function(j){if(!q)q=!0,K0.reject(K,j)});function z(j){if(Y[U]=j,++V===J&&!q)q=!0,K0.resolve(K,Y)}}}N1.race=lK;function lK(Q){var $=this;if(Object.prototype.toString.call(Q)!=="[object Array]")return this.reject(TypeError("must be an array"));var J=Q.length,q=!1;if(!J)return this.resolve([]);var Y=-1,V=new this(Y6);while(++Y<J)X(Q[Y]);return V;function X(K){$.resolve(K).then(function(W){if(!q)q=!0,K0.resolve(V,W)},function(W){if(!q)q=!0,K0.reject(V,W)})}}});var V6=w((cL,v4)=>{var i5=null;if(typeof Promise<"u")i5=Promise;else i5=x4();v4.exports={Promise:i5}});var S4=w((E4)=>{(function(Q,$){if(Q.setImmediate)return;var J=1,q={},Y=!1,V=Q.document,X;function K(L){if(typeof L!=="function")L=Function(""+L);var A=Array(arguments.length-1);for(var B=0;B<A.length;B++)A[B]=arguments[B+1];var O={callback:L,args:A};return q[J]=O,X(J),J++}function W(L){delete q[L]}function G(L){var{callback:A,args:B}=L;switch(B.length){case 0:A();break;case 1:A(B[0]);break;case 2:A(B[0],B[1]);break;case 3:A(B[0],B[1],B[2]);break;default:A.apply($,B);break}}function U(L){if(Y)setTimeout(U,0,L);else{var A=q[L];if(A){Y=!0;try{G(A)}finally{W(L),Y=!1}}}}function z(){X=function(L){process.nextTick(function(){U(L)})}}function j(){if(Q.postMessage&&!Q.importScripts){var L=!0,A=Q.onmessage;return Q.onmessage=function(){L=!1},Q.postMessage("","*"),Q.onmessage=A,L}}function H(){var L="setImmediate$"+Math.random()+"$",A=function(B){if(B.source===Q&&typeof B.data==="string"&&B.data.indexOf(L)===0)U(+B.data.slice(L.length))};if(Q.addEventListener)Q.addEventListener("message",A,!1);else Q.attachEvent("onmessage",A);X=function(B){Q.postMessage(L+B,"*")}}function F(){var L=new MessageChannel;L.port1.onmessage=function(A){var B=A.data;U(B)},X=function(A){L.port2.postMessage(A)}}function N(){var L=V.documentElement;X=function(A){var B=V.createElement("script");B.onreadystatechange=function(){U(A),B.onreadystatechange=null,L.removeChild(B),B=null},L.appendChild(B)}}function T(){X=function(L){setTimeout(U,0,L)}}var P=Object.getPrototypeOf&&Object.getPrototypeOf(Q);if(P=P&&P.setTimeout?P:Q,{}.toString.call(Q.process)==="[object process]")z();else if(j())H();else if(Q.MessageChannel)F();else if(V&&"onreadystatechange"in V.createElement("script"))N();else T();P.setImmediate=K,P.clearImmediate=W})(typeof self>"u"?typeof global>"u"?E4:global:self)});var d=w((nK)=>{var B1=G1(),oK=p5(),X6=l6(),n5=V6();S4();function iK(Q){var $=null;if(B1.uint8array)$=new Uint8Array(Q.length);else $=Array(Q.length);return Q2(Q,$)}nK.newBlob=function(Q,$){nK.checkSupport("blob");try{return new Blob([Q],{type:$})}catch(Y){try{var J=self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder,q=new J;return q.append(Q),q.getBlob($)}catch(V){throw Error("Bug : can't construct the Blob.")}}};function n6(Q){return Q}function Q2(Q,$){for(var J=0;J<Q.length;++J)$[J]=Q.charCodeAt(J)&255;return $}var e8={stringifyByChunk:function(Q,$,J){var q=[],Y=0,V=Q.length;if(V<=J)return String.fromCharCode.apply(null,Q);while(Y<V){if($==="array"||$==="nodebuffer")q.push(String.fromCharCode.apply(null,Q.slice(Y,Math.min(Y+J,V))));else q.push(String.fromCharCode.apply(null,Q.subarray(Y,Math.min(Y+J,V))));Y+=J}return q.join("")},stringifyByChar:function(Q){var $="";for(var J=0;J<Q.length;J++)$+=String.fromCharCode(Q[J]);return $},applyCanBeUsed:{uint8array:function(){try{return B1.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch(Q){return!1}}(),nodebuffer:function(){try{return B1.nodebuffer&&String.fromCharCode.apply(null,X6.allocBuffer(1)).length===1}catch(Q){return!1}}()}};function r6(Q){var $=65536,J=nK.getTypeOf(Q),q=!0;if(J==="uint8array")q=e8.applyCanBeUsed.uint8array;else if(J==="nodebuffer")q=e8.applyCanBeUsed.nodebuffer;if(q)while($>1)try{return e8.stringifyByChunk(Q,J,$)}catch(Y){$=Math.floor($/2)}return e8.stringifyByChar(Q)}nK.applyFromCharCode=r6;function $2(Q,$){for(var J=0;J<Q.length;J++)$[J]=Q[J];return $}var M1={};M1.string={string:n6,array:function(Q){return Q2(Q,Array(Q.length))},arraybuffer:function(Q){return M1.string.uint8array(Q).buffer},uint8array:function(Q){return Q2(Q,new Uint8Array(Q.length))},nodebuffer:function(Q){return Q2(Q,X6.allocBuffer(Q.length))}};M1.array={string:r6,array:n6,arraybuffer:function(Q){return new Uint8Array(Q).buffer},uint8array:function(Q){return new Uint8Array(Q)},nodebuffer:function(Q){return X6.newBufferFrom(Q)}};M1.arraybuffer={string:function(Q){return r6(new Uint8Array(Q))},array:function(Q){return $2(new Uint8Array(Q),Array(Q.byteLength))},arraybuffer:n6,uint8array:function(Q){return new Uint8Array(Q)},nodebuffer:function(Q){return X6.newBufferFrom(new Uint8Array(Q))}};M1.uint8array={string:r6,array:function(Q){return $2(Q,Array(Q.length))},arraybuffer:function(Q){return Q.buffer},uint8array:n6,nodebuffer:function(Q){return X6.newBufferFrom(Q)}};M1.nodebuffer={string:r6,array:function(Q){return $2(Q,Array(Q.length))},arraybuffer:function(Q){return M1.nodebuffer.uint8array(Q).buffer},uint8array:function(Q){return $2(Q,new Uint8Array(Q.length))},nodebuffer:n6};nK.transformTo=function(Q,$){if(!$)$="";if(!Q)return $;nK.checkSupport(Q);var J=nK.getTypeOf($),q=M1[J][Q]($);return q};nK.resolve=function(Q){var $=Q.split("/"),J=[];for(var q=0;q<$.length;q++){var Y=$[q];if(Y==="."||Y===""&&q!==0&&q!==$.length-1)continue;else if(Y==="..")J.pop();else J.push(Y)}return J.join("/")};nK.getTypeOf=function(Q){if(typeof Q==="string")return"string";if(Object.prototype.toString.call(Q)==="[object Array]")return"array";if(B1.nodebuffer&&X6.isBuffer(Q))return"nodebuffer";if(B1.uint8array&&Q instanceof Uint8Array)return"uint8array";if(B1.arraybuffer&&Q instanceof ArrayBuffer)return"arraybuffer"};nK.checkSupport=function(Q){var $=B1[Q.toLowerCase()];if(!$)throw Error(Q+" is not supported by this platform")};nK.MAX_VALUE_16BITS=65535;nK.MAX_VALUE_32BITS=-1;nK.pretty=function(Q){var $="",J,q;for(q=0;q<(Q||"").length;q++)J=Q.charCodeAt(q),$+="\\x"+(J<16?"0":"")+J.toString(16).toUpperCase();return $};nK.delay=function(Q,$,J){setImmediate(function(){Q.apply(J||null,$||[])})};nK.inherits=function(Q,$){var J=function(){};J.prototype=$.prototype,Q.prototype=new J};nK.extend=function(){var Q={},$,J;for($=0;$<arguments.length;$++)for(J in arguments[$])if(Object.prototype.hasOwnProperty.call(arguments[$],J)&&typeof Q[J]>"u")Q[J]=arguments[$][J];return Q};nK.prepareContent=function(Q,$,J,q,Y){var V=n5.Promise.resolve($).then(function(X){var K=B1.blob&&(X instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(X))!==-1);if(K&&typeof FileReader<"u")return new n5.Promise(function(W,G){var U=new FileReader;U.onload=function(z){W(z.target.result)},U.onerror=function(z){G(z.target.error)},U.readAsArrayBuffer(X)});else return X});return V.then(function(X){var K=nK.getTypeOf(X);if(!K)return n5.Promise.reject(Error("Can't read the data of '"+Q+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"));if(K==="arraybuffer")X=nK.transformTo("uint8array",X);else if(K==="string"){if(Y)X=oK.decode(X);else if(J){if(q!==!0)X=iK(X)}}return X})}});var N0=w((dL,_4)=>{function g4(Q){this.name=Q||"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}g4.prototype={push:function(Q){this.emit("data",Q)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(Q){this.emit("error",Q)}return!0},error:function(Q){if(this.isFinished)return!1;if(this.isPaused)this.generatedError=Q;else{if(this.isFinished=!0,this.emit("error",Q),this.previous)this.previous.error(Q);this.cleanUp()}return!0},on:function(Q,$){return this._listeners[Q].push($),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(Q,$){if(this._listeners[Q])for(var J=0;J<this._listeners[Q].length;J++)this._listeners[Q][J].call(this,$)},pipe:function(Q){return Q.registerPrevious(this)},registerPrevious:function(Q){if(this.isLocked)throw Error("The stream '"+this+"' has already been used.");this.streamInfo=Q.streamInfo,this.mergeStreamInfo(),this.previous=Q;var $=this;return Q.on("data",function(J){$.processChunk(J)}),Q.on("end",function(){$.end()}),Q.on("error",function(J){$.error(J)}),this},pause:function(){if(this.isPaused||this.isFinished)return!1;if(this.isPaused=!0,this.previous)this.previous.pause();return!0},resume:function(){if(!this.isPaused||this.isFinished)return!1;this.isPaused=!1;var Q=!1;if(this.generatedError)this.error(this.generatedError),Q=!0;if(this.previous)this.previous.resume();return!Q},flush:function(){},processChunk:function(Q){this.push(Q)},withStreamInfo:function(Q,$){return this.extraStreamInfo[Q]=$,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var Q in this.extraStreamInfo){if(!Object.prototype.hasOwnProperty.call(this.extraStreamInfo,Q))continue;this.streamInfo[Q]=this.extraStreamInfo[Q]}},lock:function(){if(this.isLocked)throw Error("The stream '"+this+"' has already been used.");if(this.isLocked=!0,this.previous)this.previous.lock()},toString:function(){var Q="Worker "+this.name;if(this.previous)return this.previous+" -> "+Q;else return Q}};_4.exports=g4});var G6=w((WG)=>{var K6=d(),b1=G1(),VG=l6(),J2=N0(),a6=Array(256);for(o0=0;o0<256;o0++)a6[o0]=o0>=252?6:o0>=248?5:o0>=240?4:o0>=224?3:o0>=192?2:1;var o0;a6[254]=a6[254]=1;var XG=function(Q){var $,J,q,Y,V,X=Q.length,K=0;for(Y=0;Y<X;Y++){if(J=Q.charCodeAt(Y),(J&64512)===55296&&Y+1<X){if(q=Q.charCodeAt(Y+1),(q&64512)===56320)J=65536+(J-55296<<10)+(q-56320),Y++}K+=J<128?1:J<2048?2:J<65536?3:4}if(b1.uint8array)$=new Uint8Array(K);else $=Array(K);for(V=0,Y=0;V<K;Y++){if(J=Q.charCodeAt(Y),(J&64512)===55296&&Y+1<X){if(q=Q.charCodeAt(Y+1),(q&64512)===56320)J=65536+(J-55296<<10)+(q-56320),Y++}if(J<128)$[V++]=J;else if(J<2048)$[V++]=192|J>>>6,$[V++]=128|J&63;else if(J<65536)$[V++]=224|J>>>12,$[V++]=128|J>>>6&63,$[V++]=128|J&63;else $[V++]=240|J>>>18,$[V++]=128|J>>>12&63,$[V++]=128|J>>>6&63,$[V++]=128|J&63}return $},KG=function(Q,$){var J;if($=$||Q.length,$>Q.length)$=Q.length;J=$-1;while(J>=0&&(Q[J]&192)===128)J--;if(J<0)return $;if(J===0)return $;return J+a6[Q[J]]>$?J:$},GG=function(Q){var $,J,q,Y,V=Q.length,X=Array(V*2);for(J=0,$=0;$<V;){if(q=Q[$++],q<128){X[J++]=q;continue}if(Y=a6[q],Y>4){X[J++]=65533,$+=Y-1;continue}q&=Y===2?31:Y===3?15:7;while(Y>1&&$<V)q=q<<6|Q[$++]&63,Y--;if(Y>1){X[J++]=65533;continue}if(q<65536)X[J++]=q;else q-=65536,X[J++]=55296|q>>10&1023,X[J++]=56320|q&1023}if(X.length!==J)if(X.subarray)X=X.subarray(0,J);else X.length=J;return K6.applyFromCharCode(X)};WG.utf8encode=function($){if(b1.nodebuffer)return VG.newBufferFrom($,"utf-8");return XG($)};WG.utf8decode=function($){if(b1.nodebuffer)return K6.transformTo("nodebuffer",$).toString("utf-8");return $=K6.transformTo(b1.uint8array?"uint8array":"array",$),GG($)};function q2(){J2.call(this,"utf-8 decode"),this.leftOver=null}K6.inherits(q2,J2);q2.prototype.processChunk=function(Q){var $=K6.transformTo(b1.uint8array?"uint8array":"array",Q.data);if(this.leftOver&&this.leftOver.length){if(b1.uint8array){var J=$;$=new Uint8Array(J.length+this.leftOver.length),$.set(this.leftOver,0),$.set(J,this.leftOver.length)}else $=this.leftOver.concat($);this.leftOver=null}var q=KG($),Y=$;if(q!==$.length)if(b1.uint8array)Y=$.subarray(0,q),this.leftOver=$.subarray(q,$.length);else Y=$.slice(0,q),this.leftOver=$.slice(q,$.length);this.push({data:WG.utf8decode(Y),meta:Q.meta})};q2.prototype.flush=function(){if(this.leftOver&&this.leftOver.length)this.push({data:WG.utf8decode(this.leftOver),meta:{}}),this.leftOver=null};WG.Utf8DecodeWorker=q2;function a5(){J2.call(this,"utf-8 encode")}K6.inherits(a5,J2);a5.prototype.processChunk=function(Q){this.push({data:WG.utf8encode(Q.data),meta:Q.meta})};WG.Utf8EncodeWorker=a5});var c4=w((oL,m4)=>{var h4=N0(),f4=d();function t5(Q){h4.call(this,"ConvertWorker to "+Q),this.destType=Q}f4.inherits(t5,h4);t5.prototype.processChunk=function(Q){this.push({data:f4.transformTo(this.destType,Q.data),meta:Q.meta})};m4.exports=t5});var d4=w((iL,p4)=>{var u4=m5().Readable,ZG=d();ZG.inherits(e5,u4);function e5(Q,$,J){u4.call(this,$),this._helper=Q;var q=this;Q.on("data",function(Y,V){if(!q.push(Y))q._helper.pause();if(J)J(V)}).on("error",function(Y){q.emit("error",Y)}).on("end",function(){q.push(null)})}e5.prototype._read=function(){this._helper.resume()};p4.exports=e5});var Q9=w((nL,i4)=>{var h1=d(),zG=c4(),HG=N0(),FG=p5(),LG=G1(),OG=V6(),l4=null;if(LG.nodestream)try{l4=d4()}catch(Q){}function NG(Q,$,J){switch(Q){case"blob":return h1.newBlob(h1.transformTo("arraybuffer",$),J);case"base64":return FG.encode($);default:return h1.transformTo(Q,$)}}function BG(Q,$){var J,q=0,Y=null,V=0;for(J=0;J<$.length;J++)V+=$[J].length;switch(Q){case"string":return $.join("");case"array":return Array.prototype.concat.apply([],$);case"uint8array":Y=new Uint8Array(V);for(J=0;J<$.length;J++)Y.set($[J],q),q+=$[J].length;return Y;case"nodebuffer":return Buffer.concat($);default:throw Error("concat : unsupported type '"+Q+"'")}}function MG(Q,$){return new OG.Promise(function(J,q){var Y=[],V=Q._internalType,X=Q._outputType,K=Q._mimeType;Q.on("data",function(W,G){if(Y.push(W),$)$(G)}).on("error",function(W){Y=[],q(W)}).on("end",function(){try{var W=NG(X,BG(V,Y),K);J(W)}catch(G){q(G)}Y=[]}).resume()})}function o4(Q,$,J){var q=$;switch($){case"blob":case"arraybuffer":q="uint8array";break;case"base64":q="string";break}try{this._internalType=q,this._outputType=$,this._mimeType=J,h1.checkSupport(q),this._worker=Q.pipe(new zG(q)),Q.lock()}catch(Y){this._worker=new HG("error"),this._worker.error(Y)}}o4.prototype={accumulate:function(Q){return MG(this,Q)},on:function(Q,$){var J=this;if(Q==="data")this._worker.on(Q,function(q){$.call(J,q.data,q.meta)});else this._worker.on(Q,function(){h1.delay($,arguments,J)});return this},resume:function(){return h1.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(Q){if(h1.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw Error(this._outputType+" is not supported by this method");return new l4(this,{objectMode:this._outputType!=="nodebuffer"},Q)}};i4.exports=o4});var $9=w((PG)=>{PG.base64=!1;PG.binary=!1;PG.dir=!1;PG.createFolders=!0;PG.date=null;PG.compression=null;PG.compressionOptions=null;PG.comment=null;PG.unixPermissions=null;PG.dosPermissions=null});var J9=w((aL,n4)=>{var Y2=d(),V2=N0(),SG=16384;function W6(Q){V2.call(this,"DataWorker");var $=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,Q.then(function(J){if($.dataIsReady=!0,$.data=J,$.max=J&&J.length||0,$.type=Y2.getTypeOf(J),!$.isPaused)$._tickAndRepeat()},function(J){$.error(J)})}Y2.inherits(W6,V2);W6.prototype.cleanUp=function(){V2.prototype.cleanUp.call(this),this.data=null};W6.prototype.resume=function(){if(!V2.prototype.resume.call(this))return!1;if(!this._tickScheduled&&this.dataIsReady)this._tickScheduled=!0,Y2.delay(this._tickAndRepeat,[],this);return!0};W6.prototype._tickAndRepeat=function(){if(this._tickScheduled=!1,this.isPaused||this.isFinished)return;if(this._tick(),!this.isFinished)Y2.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0};W6.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var Q=SG,$=null,J=Math.min(this.max,this.index+Q);if(this.index>=this.max)return this.end();else{switch(this.type){case"string":$=this.data.substring(this.index,J);break;case"uint8array":$=this.data.subarray(this.index,J);break;case"array":case"nodebuffer":$=this.data.slice(this.index,J);break}return this.index=J,this.push({data:$,meta:{percent:this.max?this.index/this.max*100:0}})}};n4.exports=W6});var X2=w((sL,a4)=>{var kG=d();function yG(){var Q,$=[];for(var J=0;J<256;J++){Q=J;for(var q=0;q<8;q++)Q=Q&1?3988292384^Q>>>1:Q>>>1;$[J]=Q}return $}var r4=yG();function gG(Q,$,J,q){var Y=r4,V=q+J;Q=Q^-1;for(var X=q;X<V;X++)Q=Q>>>8^Y[(Q^$[X])&255];return Q^-1}function _G(Q,$,J,q){var Y=r4,V=q+J;Q=Q^-1;for(var X=q;X<V;X++)Q=Q>>>8^Y[(Q^$.charCodeAt(X))&255];return Q^-1}a4.exports=function($,J){if(typeof $>"u"||!$.length)return 0;var q=kG.getTypeOf($)!=="string";if(q)return gG(J|0,$,$.length,0);else return _G(J|0,$,$.length,0)}});var Y9=w((tL,t4)=>{var s4=N0(),bG=X2(),hG=d();function q9(){s4.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}hG.inherits(q9,s4);q9.prototype.processChunk=function(Q){this.streamInfo.crc32=bG(Q.data,this.streamInfo.crc32||0),this.push(Q)};t4.exports=q9});var Q$=w((eL,e4)=>{var fG=d(),V9=N0();function X9(Q){V9.call(this,"DataLengthProbe for "+Q),this.propName=Q,this.withStreamInfo(Q,0)}fG.inherits(X9,V9);X9.prototype.processChunk=function(Q){if(Q){var $=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=$+Q.data.length}V9.prototype.processChunk.call(this,Q)};e4.exports=X9});var K2=w((QO,q$)=>{var $$=V6(),J$=J9(),mG=Y9(),K9=Q$();function G9(Q,$,J,q,Y){this.compressedSize=Q,this.uncompressedSize=$,this.crc32=J,this.compression=q,this.compressedContent=Y}G9.prototype={getContentWorker:function(){var Q=new J$($$.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new K9("data_length")),$=this;return Q.on("end",function(){if(this.streamInfo.data_length!==$.uncompressedSize)throw Error("Bug : uncompressed data size mismatch")}),Q},getCompressedWorker:function(){return new J$($$.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}};G9.createWorkerFrom=function(Q,$,J){return Q.pipe(new mG).pipe(new K9("uncompressedSize")).pipe($.compressWorker(J)).pipe(new K9("compressedSize")).withStreamInfo("compression",$)};q$.exports=G9});var K$=w(($O,X$)=>{var cG=Q9(),uG=J9(),W9=G6(),U9=K2(),Y$=N0(),j9=function(Q,$,J){this.name=Q,this.dir=J.dir,this.date=J.date,this.comment=J.comment,this.unixPermissions=J.unixPermissions,this.dosPermissions=J.dosPermissions,this._data=$,this._dataBinary=J.binary,this.options={compression:J.compression,compressionOptions:J.compressionOptions}};j9.prototype={internalStream:function(Q){var $=null,J="string";try{if(!Q)throw Error("No output type specified.");J=Q.toLowerCase();var q=J==="string"||J==="text";if(J==="binarystring"||J==="text")J="string";$=this._decompressWorker();var Y=!this._dataBinary;if(Y&&!q)$=$.pipe(new W9.Utf8EncodeWorker);if(!Y&&q)$=$.pipe(new W9.Utf8DecodeWorker)}catch(V){$=new Y$("error"),$.error(V)}return new cG($,J,"")},async:function(Q,$){return this.internalStream(Q).accumulate($)},nodeStream:function(Q,$){return this.internalStream(Q||"nodebuffer").toNodejsStream($)},_compressWorker:function(Q,$){if(this._data instanceof U9&&this._data.compression.magic===Q.magic)return this._data.getCompressedWorker();else{var J=this._decompressWorker();if(!this._dataBinary)J=J.pipe(new W9.Utf8EncodeWorker);return U9.createWorkerFrom(J,Q,$)}},_decompressWorker:function(){if(this._data instanceof U9)return this._data.getContentWorker();else if(this._data instanceof Y$)return this._data;else return new uG(this._data)}};var V$=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],pG=function(){throw Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")};for(s6=0;s6<V$.length;s6++)j9.prototype[V$[s6]]=pG;var s6;X$.exports=j9});var W1=w((Z9)=>{var iG=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";function nG(Q,$){return Object.prototype.hasOwnProperty.call(Q,$)}Z9.assign=function(Q){var $=Array.prototype.slice.call(arguments,1);while($.length){var J=$.shift();if(!J)continue;if(typeof J!=="object")throw TypeError(J+"must be non-object");for(var q in J)if(nG(J,q))Q[q]=J[q]}return Q};Z9.shrinkBuf=function(Q,$){if(Q.length===$)return Q;if(Q.subarray)return Q.subarray(0,$);return Q.length=$,Q};var rG={arraySet:function(Q,$,J,q,Y){if($.subarray&&Q.subarray){Q.set($.subarray(J,J+q),Y);return}for(var V=0;V<q;V++)Q[Y+V]=$[J+V]},flattenChunks:function(Q){var $,J,q,Y,V,X;q=0;for($=0,J=Q.length;$<J;$++)q+=Q[$].length;X=new Uint8Array(q),Y=0;for($=0,J=Q.length;$<J;$++)V=Q[$],X.set(V,Y),Y+=V.length;return X}},aG={arraySet:function(Q,$,J,q,Y){for(var V=0;V<q;V++)Q[Y+V]=$[J+V]},flattenChunks:function(Q){return[].concat.apply([],Q)}};Z9.setTyped=function(Q){if(Q)Z9.Buf8=Uint8Array,Z9.Buf16=Uint16Array,Z9.Buf32=Int32Array,Z9.assign(Z9,rG);else Z9.Buf8=Array,Z9.Buf16=Array,Z9.Buf32=Array,Z9.assign(Z9,aG)};Z9.setTyped(iG)});var E$=w((BW)=>{var tG=W1(),eG=4,W$=0,U$=1,QW=2;function j6(Q){var $=Q.length;while(--$>=0)Q[$]=0}var $W=0,L$=1,JW=2,qW=3,YW=258,M9=29,q8=256,e6=q8+1+M9,U6=30,P9=19,O$=2*e6+1,f1=15,H9=16,VW=7,I9=256,N$=16,B$=17,M$=18,N9=[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],G2=[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],XW=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],P$=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],KW=512,U1=Array((e6+2)*2);j6(U1);var t6=Array(U6*2);j6(t6);var Q8=Array(KW);j6(Q8);var $8=Array(YW-qW+1);j6($8);var T9=Array(M9);j6(T9);var W2=Array(U6);j6(W2);function F9(Q,$,J,q,Y){this.static_tree=Q,this.extra_bits=$,this.extra_base=J,this.elems=q,this.max_length=Y,this.has_stree=Q&&Q.length}var I$,T$,C$;function L9(Q,$){this.dyn_tree=Q,this.max_code=0,this.stat_desc=$}function A$(Q){return Q<256?Q8[Q]:Q8[256+(Q>>>7)]}function J8(Q,$){Q.pending_buf[Q.pending++]=$&255,Q.pending_buf[Q.pending++]=$>>>8&255}function F0(Q,$,J){if(Q.bi_valid>H9-J)Q.bi_buf|=$<<Q.bi_valid&65535,J8(Q,Q.bi_buf),Q.bi_buf=$>>H9-Q.bi_valid,Q.bi_valid+=J-H9;else Q.bi_buf|=$<<Q.bi_valid&65535,Q.bi_valid+=J}function i0(Q,$,J){F0(Q,J[$*2],J[$*2+1])}function D$(Q,$){var J=0;do J|=Q&1,Q>>>=1,J<<=1;while(--$>0);return J>>>1}function GW(Q){if(Q.bi_valid===16)J8(Q,Q.bi_buf),Q.bi_buf=0,Q.bi_valid=0;else if(Q.bi_valid>=8)Q.pending_buf[Q.pending++]=Q.bi_buf&255,Q.bi_buf>>=8,Q.bi_valid-=8}function WW(Q,$){var{dyn_tree:J,max_code:q}=$,Y=$.stat_desc.static_tree,V=$.stat_desc.has_stree,X=$.stat_desc.extra_bits,K=$.stat_desc.extra_base,W=$.stat_desc.max_length,G,U,z,j,H,F,N=0;for(j=0;j<=f1;j++)Q.bl_count[j]=0;J[Q.heap[Q.heap_max]*2+1]=0;for(G=Q.heap_max+1;G<O$;G++){if(U=Q.heap[G],j=J[J[U*2+1]*2+1]+1,j>W)j=W,N++;if(J[U*2+1]=j,U>q)continue;if(Q.bl_count[j]++,H=0,U>=K)H=X[U-K];if(F=J[U*2],Q.opt_len+=F*(j+H),V)Q.static_len+=F*(Y[U*2+1]+H)}if(N===0)return;do{j=W-1;while(Q.bl_count[j]===0)j--;Q.bl_count[j]--,Q.bl_count[j+1]+=2,Q.bl_count[W]--,N-=2}while(N>0);for(j=W;j!==0;j--){U=Q.bl_count[j];while(U!==0){if(z=Q.heap[--G],z>q)continue;if(J[z*2+1]!==j)Q.opt_len+=(j-J[z*2+1])*J[z*2],J[z*2+1]=j;U--}}}function w$(Q,$,J){var q=Array(f1+1),Y=0,V,X;for(V=1;V<=f1;V++)q[V]=Y=Y+J[V-1]<<1;for(X=0;X<=$;X++){var K=Q[X*2+1];if(K===0)continue;Q[X*2]=D$(q[K]++,K)}}function UW(){var Q,$,J,q,Y,V=Array(f1+1);J=0;for(q=0;q<M9-1;q++){T9[q]=J;for(Q=0;Q<1<<N9[q];Q++)$8[J++]=q}$8[J-1]=q,Y=0;for(q=0;q<16;q++){W2[q]=Y;for(Q=0;Q<1<<G2[q];Q++)Q8[Y++]=q}Y>>=7;for(;q<U6;q++){W2[q]=Y<<7;for(Q=0;Q<1<<G2[q]-7;Q++)Q8[256+Y++]=q}for($=0;$<=f1;$++)V[$]=0;Q=0;while(Q<=143)U1[Q*2+1]=8,Q++,V[8]++;while(Q<=255)U1[Q*2+1]=9,Q++,V[9]++;while(Q<=279)U1[Q*2+1]=7,Q++,V[7]++;while(Q<=287)U1[Q*2+1]=8,Q++,V[8]++;w$(U1,e6+1,V);for(Q=0;Q<U6;Q++)t6[Q*2+1]=5,t6[Q*2]=D$(Q,5);I$=new F9(U1,N9,q8+1,e6,f1),T$=new F9(t6,G2,0,U6,f1),C$=new F9([],XW,0,P9,VW)}function R$(Q){var $;for($=0;$<e6;$++)Q.dyn_ltree[$*2]=0;for($=0;$<U6;$++)Q.dyn_dtree[$*2]=0;for($=0;$<P9;$++)Q.bl_tree[$*2]=0;Q.dyn_ltree[I9*2]=1,Q.opt_len=Q.static_len=0,Q.last_lit=Q.matches=0}function x$(Q){if(Q.bi_valid>8)J8(Q,Q.bi_buf);else if(Q.bi_valid>0)Q.pending_buf[Q.pending++]=Q.bi_buf;Q.bi_buf=0,Q.bi_valid=0}function jW(Q,$,J,q){if(x$(Q),q)J8(Q,J),J8(Q,~J);tG.arraySet(Q.pending_buf,Q.window,$,J,Q.pending),Q.pending+=J}function j$(Q,$,J,q){var Y=$*2,V=J*2;return Q[Y]<Q[V]||Q[Y]===Q[V]&&q[$]<=q[J]}function O9(Q,$,J){var q=Q.heap[J],Y=J<<1;while(Y<=Q.heap_len){if(Y<Q.heap_len&&j$($,Q.heap[Y+1],Q.heap[Y],Q.depth))Y++;if(j$($,q,Q.heap[Y],Q.depth))break;Q.heap[J]=Q.heap[Y],J=Y,Y<<=1}Q.heap[J]=q}function Z$(Q,$,J){var q,Y,V=0,X,K;if(Q.last_lit!==0)do if(q=Q.pending_buf[Q.d_buf+V*2]<<8|Q.pending_buf[Q.d_buf+V*2+1],Y=Q.pending_buf[Q.l_buf+V],V++,q===0)i0(Q,Y,$);else{if(X=$8[Y],i0(Q,X+q8+1,$),K=N9[X],K!==0)Y-=T9[X],F0(Q,Y,K);if(q--,X=A$(q),i0(Q,X,J),K=G2[X],K!==0)q-=W2[X],F0(Q,q,K)}while(V<Q.last_lit);i0(Q,I9,$)}function B9(Q,$){var J=$.dyn_tree,q=$.stat_desc.static_tree,Y=$.stat_desc.has_stree,V=$.stat_desc.elems,X,K,W=-1,G;Q.heap_len=0,Q.heap_max=O$;for(X=0;X<V;X++)if(J[X*2]!==0)Q.heap[++Q.heap_len]=W=X,Q.depth[X]=0;else J[X*2+1]=0;while(Q.heap_len<2)if(G=Q.heap[++Q.heap_len]=W<2?++W:0,J[G*2]=1,Q.depth[G]=0,Q.opt_len--,Y)Q.static_len-=q[G*2+1];$.max_code=W;for(X=Q.heap_len>>1;X>=1;X--)O9(Q,J,X);G=V;do X=Q.heap[1],Q.heap[1]=Q.heap[Q.heap_len--],O9(Q,J,1),K=Q.heap[1],Q.heap[--Q.heap_max]=X,Q.heap[--Q.heap_max]=K,J[G*2]=J[X*2]+J[K*2],Q.depth[G]=(Q.depth[X]>=Q.depth[K]?Q.depth[X]:Q.depth[K])+1,J[X*2+1]=J[K*2+1]=G,Q.heap[1]=G++,O9(Q,J,1);while(Q.heap_len>=2);Q.heap[--Q.heap_max]=Q.heap[1],WW(Q,$),w$(J,W,Q.bl_count)}function z$(Q,$,J){var q,Y=-1,V,X=$[1],K=0,W=7,G=4;if(X===0)W=138,G=3;$[(J+1)*2+1]=65535;for(q=0;q<=J;q++){if(V=X,X=$[(q+1)*2+1],++K<W&&V===X)continue;else if(K<G)Q.bl_tree[V*2]+=K;else if(V!==0){if(V!==Y)Q.bl_tree[V*2]++;Q.bl_tree[N$*2]++}else if(K<=10)Q.bl_tree[B$*2]++;else Q.bl_tree[M$*2]++;if(K=0,Y=V,X===0)W=138,G=3;else if(V===X)W=6,G=3;else W=7,G=4}}function H$(Q,$,J){var q,Y=-1,V,X=$[1],K=0,W=7,G=4;if(X===0)W=138,G=3;for(q=0;q<=J;q++){if(V=X,X=$[(q+1)*2+1],++K<W&&V===X)continue;else if(K<G)do i0(Q,V,Q.bl_tree);while(--K!==0);else if(V!==0){if(V!==Y)i0(Q,V,Q.bl_tree),K--;i0(Q,N$,Q.bl_tree),F0(Q,K-3,2)}else if(K<=10)i0(Q,B$,Q.bl_tree),F0(Q,K-3,3);else i0(Q,M$,Q.bl_tree),F0(Q,K-11,7);if(K=0,Y=V,X===0)W=138,G=3;else if(V===X)W=6,G=3;else W=7,G=4}}function ZW(Q){var $;z$(Q,Q.dyn_ltree,Q.l_desc.max_code),z$(Q,Q.dyn_dtree,Q.d_desc.max_code),B9(Q,Q.bl_desc);for($=P9-1;$>=3;$--)if(Q.bl_tree[P$[$]*2+1]!==0)break;return Q.opt_len+=3*($+1)+5+5+4,$}function zW(Q,$,J,q){var Y;F0(Q,$-257,5),F0(Q,J-1,5),F0(Q,q-4,4);for(Y=0;Y<q;Y++)F0(Q,Q.bl_tree[P$[Y]*2+1],3);H$(Q,Q.dyn_ltree,$-1),H$(Q,Q.dyn_dtree,J-1)}function HW(Q){var $=4093624447,J;for(J=0;J<=31;J++,$>>>=1)if($&1&&Q.dyn_ltree[J*2]!==0)return W$;if(Q.dyn_ltree[18]!==0||Q.dyn_ltree[20]!==0||Q.dyn_ltree[26]!==0)return U$;for(J=32;J<q8;J++)if(Q.dyn_ltree[J*2]!==0)return U$;return W$}var F$=!1;function FW(Q){if(!F$)UW(),F$=!0;Q.l_desc=new L9(Q.dyn_ltree,I$),Q.d_desc=new L9(Q.dyn_dtree,T$),Q.bl_desc=new L9(Q.bl_tree,C$),Q.bi_buf=0,Q.bi_valid=0,R$(Q)}function v$(Q,$,J,q){F0(Q,($W<<1)+(q?1:0),3),jW(Q,$,J,!0)}function LW(Q){F0(Q,L$<<1,3),i0(Q,I9,U1),GW(Q)}function OW(Q,$,J,q){var Y,V,X=0;if(Q.level>0){if(Q.strm.data_type===QW)Q.strm.data_type=HW(Q);if(B9(Q,Q.l_desc),B9(Q,Q.d_desc),X=ZW(Q),Y=Q.opt_len+3+7>>>3,V=Q.static_len+3+7>>>3,V<=Y)Y=V}else Y=V=J+5;if(J+4<=Y&&$!==-1)v$(Q,$,J,q);else if(Q.strategy===eG||V===Y)F0(Q,(L$<<1)+(q?1:0),3),Z$(Q,U1,t6);else F0(Q,(JW<<1)+(q?1:0),3),zW(Q,Q.l_desc.max_code+1,Q.d_desc.max_code+1,X+1),Z$(Q,Q.dyn_ltree,Q.dyn_dtree);if(R$(Q),q)x$(Q)}function NW(Q,$,J){if(Q.pending_buf[Q.d_buf+Q.last_lit*2]=$>>>8&255,Q.pending_buf[Q.d_buf+Q.last_lit*2+1]=$&255,Q.pending_buf[Q.l_buf+Q.last_lit]=J&255,Q.last_lit++,$===0)Q.dyn_ltree[J*2]++;else Q.matches++,$--,Q.dyn_ltree[($8[J]+q8+1)*2]++,Q.dyn_dtree[A$($)*2]++;return Q.last_lit===Q.lit_bufsize-1}BW._tr_init=FW;BW._tr_stored_block=v$;BW._tr_flush_block=OW;BW._tr_tally=NW;BW._tr_align=LW});var C9=w((YO,S$)=>{function AW(Q,$,J,q){var Y=Q&65535|0,V=Q>>>16&65535|0,X=0;while(J!==0){X=J>2000?2000:J,J-=X;do Y=Y+$[q++]|0,V=V+Y|0;while(--X);Y%=65521,V%=65521}return Y|V<<16|0}S$.exports=AW});var A9=w((VO,k$)=>{function DW(){var Q,$=[];for(var J=0;J<256;J++){Q=J;for(var q=0;q<8;q++)Q=Q&1?3988292384^Q>>>1:Q>>>1;$[J]=Q}return $}var wW=DW();function RW(Q,$,J,q){var Y=wW,V=q+J;Q^=-1;for(var X=q;X<V;X++)Q=Q>>>8^Y[(Q^$[X])&255];return Q^-1}k$.exports=RW});var U2=w((XO,y$)=>{y$.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"}});var p$=w((KU)=>{var U0=W1(),w0=E$(),h$=C9(),P1=A9(),xW=U2(),p1=0,vW=1,EW=3,D1=4,g$=5,r0=0,_$=1,R0=-2,SW=-3,D9=-5,kW=-1,yW=1,j2=2,gW=3,_W=4,bW=0,hW=2,F2=8,fW=9,mW=15,cW=8,uW=29,pW=256,R9=pW+1+uW,dW=30,lW=19,oW=2*R9+1,iW=15,E=3,C1=258,b0=C1+E+1,nW=32,L2=42,x9=69,Z2=73,z2=91,H2=103,m1=113,V8=666,t=1,X8=2,c1=3,H6=4,rW=3;function A1(Q,$){return Q.msg=xW[$],$}function b$(Q){return(Q<<1)-(Q>4?9:0)}function T1(Q){var $=Q.length;while(--$>=0)Q[$]=0}function I1(Q){var $=Q.state,J=$.pending;if(J>Q.avail_out)J=Q.avail_out;if(J===0)return;if(U0.arraySet(Q.output,$.pending_buf,$.pending_out,J,Q.next_out),Q.next_out+=J,$.pending_out+=J,Q.total_out+=J,Q.avail_out-=J,$.pending-=J,$.pending===0)$.pending_out=0}function q0(Q,$){w0._tr_flush_block(Q,Q.block_start>=0?Q.block_start:-1,Q.strstart-Q.block_start,$),Q.block_start=Q.strstart,I1(Q.strm)}function k(Q,$){Q.pending_buf[Q.pending++]=$}function Y8(Q,$){Q.pending_buf[Q.pending++]=$>>>8&255,Q.pending_buf[Q.pending++]=$&255}function aW(Q,$,J,q){var Y=Q.avail_in;if(Y>q)Y=q;if(Y===0)return 0;if(Q.avail_in-=Y,U0.arraySet($,Q.input,Q.next_in,Y,J),Q.state.wrap===1)Q.adler=h$(Q.adler,$,Y,J);else if(Q.state.wrap===2)Q.adler=P1(Q.adler,$,Y,J);return Q.next_in+=Y,Q.total_in+=Y,Y}function f$(Q,$){var{max_chain_length:J,strstart:q}=Q,Y,V,X=Q.prev_length,K=Q.nice_match,W=Q.strstart>Q.w_size-b0?Q.strstart-(Q.w_size-b0):0,G=Q.window,U=Q.w_mask,z=Q.prev,j=Q.strstart+C1,H=G[q+X-1],F=G[q+X];if(Q.prev_length>=Q.good_match)J>>=2;if(K>Q.lookahead)K=Q.lookahead;do{if(Y=$,G[Y+X]!==F||G[Y+X-1]!==H||G[Y]!==G[q]||G[++Y]!==G[q+1])continue;q+=2,Y++;do;while(G[++q]===G[++Y]&&G[++q]===G[++Y]&&G[++q]===G[++Y]&&G[++q]===G[++Y]&&G[++q]===G[++Y]&&G[++q]===G[++Y]&&G[++q]===G[++Y]&&G[++q]===G[++Y]&&q<j);if(V=C1-(j-q),q=j-C1,V>X){if(Q.match_start=$,X=V,V>=K)break;H=G[q+X-1],F=G[q+X]}}while(($=z[$&U])>W&&--J!==0);if(X<=Q.lookahead)return X;return Q.lookahead}function u1(Q){var $=Q.w_size,J,q,Y,V,X;do{if(V=Q.window_size-Q.lookahead-Q.strstart,Q.strstart>=$+($-b0)){U0.arraySet(Q.window,Q.window,$,$,0),Q.match_start-=$,Q.strstart-=$,Q.block_start-=$,q=Q.hash_size,J=q;do Y=Q.head[--J],Q.head[J]=Y>=$?Y-$:0;while(--q);q=$,J=q;do Y=Q.prev[--J],Q.prev[J]=Y>=$?Y-$:0;while(--q);V+=$}if(Q.strm.avail_in===0)break;if(q=aW(Q.strm,Q.window,Q.strstart+Q.lookahead,V),Q.lookahead+=q,Q.lookahead+Q.insert>=E){X=Q.strstart-Q.insert,Q.ins_h=Q.window[X],Q.ins_h=(Q.ins_h<<Q.hash_shift^Q.window[X+1])&Q.hash_mask;while(Q.insert)if(Q.ins_h=(Q.ins_h<<Q.hash_shift^Q.window[X+E-1])&Q.hash_mask,Q.prev[X&Q.w_mask]=Q.head[Q.ins_h],Q.head[Q.ins_h]=X,X++,Q.insert--,Q.lookahead+Q.insert<E)break}}while(Q.lookahead<b0&&Q.strm.avail_in!==0)}function sW(Q,$){var J=65535;if(J>Q.pending_buf_size-5)J=Q.pending_buf_size-5;for(;;){if(Q.lookahead<=1){if(u1(Q),Q.lookahead===0&&$===p1)return t;if(Q.lookahead===0)break}Q.strstart+=Q.lookahead,Q.lookahead=0;var q=Q.block_start+J;if(Q.strstart===0||Q.strstart>=q){if(Q.lookahead=Q.strstart-q,Q.strstart=q,q0(Q,!1),Q.strm.avail_out===0)return t}if(Q.strstart-Q.block_start>=Q.w_size-b0){if(q0(Q,!1),Q.strm.avail_out===0)return t}}if(Q.insert=0,$===D1){if(q0(Q,!0),Q.strm.avail_out===0)return c1;return H6}if(Q.strstart>Q.block_start){if(q0(Q,!1),Q.strm.avail_out===0)return t}return t}function w9(Q,$){var J,q;for(;;){if(Q.lookahead<b0){if(u1(Q),Q.lookahead<b0&&$===p1)return t;if(Q.lookahead===0)break}if(J=0,Q.lookahead>=E)Q.ins_h=(Q.ins_h<<Q.hash_shift^Q.window[Q.strstart+E-1])&Q.hash_mask,J=Q.prev[Q.strstart&Q.w_mask]=Q.head[Q.ins_h],Q.head[Q.ins_h]=Q.strstart;if(J!==0&&Q.strstart-J<=Q.w_size-b0)Q.match_length=f$(Q,J);if(Q.match_length>=E)if(q=w0._tr_tally(Q,Q.strstart-Q.match_start,Q.match_length-E),Q.lookahead-=Q.match_length,Q.match_length<=Q.max_lazy_match&&Q.lookahead>=E){Q.match_length--;do Q.strstart++,Q.ins_h=(Q.ins_h<<Q.hash_shift^Q.window[Q.strstart+E-1])&Q.hash_mask,J=Q.prev[Q.strstart&Q.w_mask]=Q.head[Q.ins_h],Q.head[Q.ins_h]=Q.strstart;while(--Q.match_length!==0);Q.strstart++}else Q.strstart+=Q.match_length,Q.match_length=0,Q.ins_h=Q.window[Q.strstart],Q.ins_h=(Q.ins_h<<Q.hash_shift^Q.window[Q.strstart+1])&Q.hash_mask;else q=w0._tr_tally(Q,0,Q.window[Q.strstart]),Q.lookahead--,Q.strstart++;if(q){if(q0(Q,!1),Q.strm.avail_out===0)return t}}if(Q.insert=Q.strstart<E-1?Q.strstart:E-1,$===D1){if(q0(Q,!0),Q.strm.avail_out===0)return c1;return H6}if(Q.last_lit){if(q0(Q,!1),Q.strm.avail_out===0)return t}return X8}function Z6(Q,$){var J,q,Y;for(;;){if(Q.lookahead<b0){if(u1(Q),Q.lookahead<b0&&$===p1)return t;if(Q.lookahead===0)break}if(J=0,Q.lookahead>=E)Q.ins_h=(Q.ins_h<<Q.hash_shift^Q.window[Q.strstart+E-1])&Q.hash_mask,J=Q.prev[Q.strstart&Q.w_mask]=Q.head[Q.ins_h],Q.head[Q.ins_h]=Q.strstart;if(Q.prev_length=Q.match_length,Q.prev_match=Q.match_start,Q.match_length=E-1,J!==0&&Q.prev_length<Q.max_lazy_match&&Q.strstart-J<=Q.w_size-b0){if(Q.match_length=f$(Q,J),Q.match_length<=5&&(Q.strategy===yW||Q.match_length===E&&Q.strstart-Q.match_start>4096))Q.match_length=E-1}if(Q.prev_length>=E&&Q.match_length<=Q.prev_length){Y=Q.strstart+Q.lookahead-E,q=w0._tr_tally(Q,Q.strstart-1-Q.prev_match,Q.prev_length-E),Q.lookahead-=Q.prev_length-1,Q.prev_length-=2;do if(++Q.strstart<=Y)Q.ins_h=(Q.ins_h<<Q.hash_shift^Q.window[Q.strstart+E-1])&Q.hash_mask,J=Q.prev[Q.strstart&Q.w_mask]=Q.head[Q.ins_h],Q.head[Q.ins_h]=Q.strstart;while(--Q.prev_length!==0);if(Q.match_available=0,Q.match_length=E-1,Q.strstart++,q){if(q0(Q,!1),Q.strm.avail_out===0)return t}}else if(Q.match_available){if(q=w0._tr_tally(Q,0,Q.window[Q.strstart-1]),q)q0(Q,!1);if(Q.strstart++,Q.lookahead--,Q.strm.avail_out===0)return t}else Q.match_available=1,Q.strstart++,Q.lookahead--}if(Q.match_available)q=w0._tr_tally(Q,0,Q.window[Q.strstart-1]),Q.match_available=0;if(Q.insert=Q.strstart<E-1?Q.strstart:E-1,$===D1){if(q0(Q,!0),Q.strm.avail_out===0)return c1;return H6}if(Q.last_lit){if(q0(Q,!1),Q.strm.avail_out===0)return t}return X8}function tW(Q,$){var J,q,Y,V,X=Q.window;for(;;){if(Q.lookahead<=C1){if(u1(Q),Q.lookahead<=C1&&$===p1)return t;if(Q.lookahead===0)break}if(Q.match_length=0,Q.lookahead>=E&&Q.strstart>0){if(Y=Q.strstart-1,q=X[Y],q===X[++Y]&&q===X[++Y]&&q===X[++Y]){V=Q.strstart+C1;do;while(q===X[++Y]&&q===X[++Y]&&q===X[++Y]&&q===X[++Y]&&q===X[++Y]&&q===X[++Y]&&q===X[++Y]&&q===X[++Y]&&Y<V);if(Q.match_length=C1-(V-Y),Q.match_length>Q.lookahead)Q.match_length=Q.lookahead}}if(Q.match_length>=E)J=w0._tr_tally(Q,1,Q.match_length-E),Q.lookahead-=Q.match_length,Q.strstart+=Q.match_length,Q.match_length=0;else J=w0._tr_tally(Q,0,Q.window[Q.strstart]),Q.lookahead--,Q.strstart++;if(J){if(q0(Q,!1),Q.strm.avail_out===0)return t}}if(Q.insert=0,$===D1){if(q0(Q,!0),Q.strm.avail_out===0)return c1;return H6}if(Q.last_lit){if(q0(Q,!1),Q.strm.avail_out===0)return t}return X8}function eW(Q,$){var J;for(;;){if(Q.lookahead===0){if(u1(Q),Q.lookahead===0){if($===p1)return t;break}}if(Q.match_length=0,J=w0._tr_tally(Q,0,Q.window[Q.strstart]),Q.lookahead--,Q.strstart++,J){if(q0(Q,!1),Q.strm.avail_out===0)return t}}if(Q.insert=0,$===D1){if(q0(Q,!0),Q.strm.avail_out===0)return c1;return H6}if(Q.last_lit){if(q0(Q,!1),Q.strm.avail_out===0)return t}return X8}function n0(Q,$,J,q,Y){this.good_length=Q,this.max_lazy=$,this.nice_length=J,this.max_chain=q,this.func=Y}var z6;z6=[new n0(0,0,0,0,sW),new n0(4,4,8,4,w9),new n0(4,5,16,8,w9),new n0(4,6,32,32,w9),new n0(4,4,16,16,Z6),new n0(8,16,32,32,Z6),new n0(8,16,128,128,Z6),new n0(8,32,128,256,Z6),new n0(32,128,258,1024,Z6),new n0(32,258,258,4096,Z6)];function QU(Q){Q.window_size=2*Q.w_size,T1(Q.head),Q.max_lazy_match=z6[Q.level].max_lazy,Q.good_match=z6[Q.level].good_length,Q.nice_match=z6[Q.level].nice_length,Q.max_chain_length=z6[Q.level].max_chain,Q.strstart=0,Q.block_start=0,Q.lookahead=0,Q.insert=0,Q.match_length=Q.prev_length=E-1,Q.match_available=0,Q.ins_h=0}function $U(){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=F2,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 U0.Buf16(oW*2),this.dyn_dtree=new U0.Buf16((2*dW+1)*2),this.bl_tree=new U0.Buf16((2*lW+1)*2),T1(this.dyn_ltree),T1(this.dyn_dtree),T1(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new U0.Buf16(iW+1),this.heap=new U0.Buf16(2*R9+1),T1(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new U0.Buf16(2*R9+1),T1(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 m$(Q){var $;if(!Q||!Q.state)return A1(Q,R0);if(Q.total_in=Q.total_out=0,Q.data_type=hW,$=Q.state,$.pending=0,$.pending_out=0,$.wrap<0)$.wrap=-$.wrap;return $.status=$.wrap?L2:m1,Q.adler=$.wrap===2?0:1,$.last_flush=p1,w0._tr_init($),r0}function c$(Q){var $=m$(Q);if($===r0)QU(Q.state);return $}function JU(Q,$){if(!Q||!Q.state)return R0;if(Q.state.wrap!==2)return R0;return Q.state.gzhead=$,r0}function u$(Q,$,J,q,Y,V){if(!Q)return R0;var X=1;if($===kW)$=6;if(q<0)X=0,q=-q;else if(q>15)X=2,q-=16;if(Y<1||Y>fW||J!==F2||q<8||q>15||$<0||$>9||V<0||V>_W)return A1(Q,R0);if(q===8)q=9;var K=new $U;return Q.state=K,K.strm=Q,K.wrap=X,K.gzhead=null,K.w_bits=q,K.w_size=1<<K.w_bits,K.w_mask=K.w_size-1,K.hash_bits=Y+7,K.hash_size=1<<K.hash_bits,K.hash_mask=K.hash_size-1,K.hash_shift=~~((K.hash_bits+E-1)/E),K.window=new U0.Buf8(K.w_size*2),K.head=new U0.Buf16(K.hash_size),K.prev=new U0.Buf16(K.w_size),K.lit_bufsize=1<<Y+6,K.pending_buf_size=K.lit_bufsize*4,K.pending_buf=new U0.Buf8(K.pending_buf_size),K.d_buf=1*K.lit_bufsize,K.l_buf=3*K.lit_bufsize,K.level=$,K.strategy=V,K.method=J,c$(Q)}function qU(Q,$){return u$(Q,$,F2,mW,cW,bW)}function YU(Q,$){var J,q,Y,V;if(!Q||!Q.state||$>g$||$<0)return Q?A1(Q,R0):R0;if(q=Q.state,!Q.output||!Q.input&&Q.avail_in!==0||q.status===V8&&$!==D1)return A1(Q,Q.avail_out===0?D9:R0);if(q.strm=Q,J=q.last_flush,q.last_flush=$,q.status===L2)if(q.wrap===2)if(Q.adler=0,k(q,31),k(q,139),k(q,8),!q.gzhead)k(q,0),k(q,0),k(q,0),k(q,0),k(q,0),k(q,q.level===9?2:q.strategy>=j2||q.level<2?4:0),k(q,rW),q.status=m1;else{if(k(q,(q.gzhead.text?1:0)+(q.gzhead.hcrc?2:0)+(!q.gzhead.extra?0:4)+(!q.gzhead.name?0:8)+(!q.gzhead.comment?0:16)),k(q,q.gzhead.time&255),k(q,q.gzhead.time>>8&255),k(q,q.gzhead.time>>16&255),k(q,q.gzhead.time>>24&255),k(q,q.level===9?2:q.strategy>=j2||q.level<2?4:0),k(q,q.gzhead.os&255),q.gzhead.extra&&q.gzhead.extra.length)k(q,q.gzhead.extra.length&255),k(q,q.gzhead.extra.length>>8&255);if(q.gzhead.hcrc)Q.adler=P1(Q.adler,q.pending_buf,q.pending,0);q.gzindex=0,q.status=x9}else{var X=F2+(q.w_bits-8<<4)<<8,K=-1;if(q.strategy>=j2||q.level<2)K=0;else if(q.level<6)K=1;else if(q.level===6)K=2;else K=3;if(X|=K<<6,q.strstart!==0)X|=nW;if(X+=31-X%31,q.status=m1,Y8(q,X),q.strstart!==0)Y8(q,Q.adler>>>16),Y8(q,Q.adler&65535);Q.adler=1}if(q.status===x9)if(q.gzhead.extra){Y=q.pending;while(q.gzindex<(q.gzhead.extra.length&65535)){if(q.pending===q.pending_buf_size){if(q.gzhead.hcrc&&q.pending>Y)Q.adler=P1(Q.adler,q.pending_buf,q.pending-Y,Y);if(I1(Q),Y=q.pending,q.pending===q.pending_buf_size)break}k(q,q.gzhead.extra[q.gzindex]&255),q.gzindex++}if(q.gzhead.hcrc&&q.pending>Y)Q.adler=P1(Q.adler,q.pending_buf,q.pending-Y,Y);if(q.gzindex===q.gzhead.extra.length)q.gzindex=0,q.status=Z2}else q.status=Z2;if(q.status===Z2)if(q.gzhead.name){Y=q.pending;do{if(q.pending===q.pending_buf_size){if(q.gzhead.hcrc&&q.pending>Y)Q.adler=P1(Q.adler,q.pending_buf,q.pending-Y,Y);if(I1(Q),Y=q.pending,q.pending===q.pending_buf_size){V=1;break}}if(q.gzindex<q.gzhead.name.length)V=q.gzhead.name.charCodeAt(q.gzindex++)&255;else V=0;k(q,V)}while(V!==0);if(q.gzhead.hcrc&&q.pending>Y)Q.adler=P1(Q.adler,q.pending_buf,q.pending-Y,Y);if(V===0)q.gzindex=0,q.status=z2}else q.status=z2;if(q.status===z2)if(q.gzhead.comment){Y=q.pending;do{if(q.pending===q.pending_buf_size){if(q.gzhead.hcrc&&q.pending>Y)Q.adler=P1(Q.adler,q.pending_buf,q.pending-Y,Y);if(I1(Q),Y=q.pending,q.pending===q.pending_buf_size){V=1;break}}if(q.gzindex<q.gzhead.comment.length)V=q.gzhead.comment.charCodeAt(q.gzindex++)&255;else V=0;k(q,V)}while(V!==0);if(q.gzhead.hcrc&&q.pending>Y)Q.adler=P1(Q.adler,q.pending_buf,q.pending-Y,Y);if(V===0)q.status=H2}else q.status=H2;if(q.status===H2)if(q.gzhead.hcrc){if(q.pending+2>q.pending_buf_size)I1(Q);if(q.pending+2<=q.pending_buf_size)k(q,Q.adler&255),k(q,Q.adler>>8&255),Q.adler=0,q.status=m1}else q.status=m1;if(q.pending!==0){if(I1(Q),Q.avail_out===0)return q.last_flush=-1,r0}else if(Q.avail_in===0&&b$($)<=b$(J)&&$!==D1)return A1(Q,D9);if(q.status===V8&&Q.avail_in!==0)return A1(Q,D9);if(Q.avail_in!==0||q.lookahead!==0||$!==p1&&q.status!==V8){var W=q.strategy===j2?eW(q,$):q.strategy===gW?tW(q,$):z6[q.level].func(q,$);if(W===c1||W===H6)q.status=V8;if(W===t||W===c1){if(Q.avail_out===0)q.last_flush=-1;return r0}if(W===X8){if($===vW)w0._tr_align(q);else if($!==g$){if(w0._tr_stored_block(q,0,0,!1),$===EW){if(T1(q.head),q.lookahead===0)q.strstart=0,q.block_start=0,q.insert=0}}if(I1(Q),Q.avail_out===0)return q.last_flush=-1,r0}}if($!==D1)return r0;if(q.wrap<=0)return _$;if(q.wrap===2)k(q,Q.adler&255),k(q,Q.adler>>8&255),k(q,Q.adler>>16&255),k(q,Q.adler>>24&255),k(q,Q.total_in&255),k(q,Q.total_in>>8&255),k(q,Q.total_in>>16&255),k(q,Q.total_in>>24&255);else Y8(q,Q.adler>>>16),Y8(q,Q.adler&65535);if(I1(Q),q.wrap>0)q.wrap=-q.wrap;return q.pending!==0?r0:_$}function VU(Q){var $;if(!Q||!Q.state)return R0;if($=Q.state.status,$!==L2&&$!==x9&&$!==Z2&&$!==z2&&$!==H2&&$!==m1&&$!==V8)return A1(Q,R0);return Q.state=null,$===m1?A1(Q,SW):r0}function XU(Q,$){var J=$.length,q,Y,V,X,K,W,G,U;if(!Q||!Q.state)return R0;if(q=Q.state,X=q.wrap,X===2||X===1&&q.status!==L2||q.lookahead)return R0;if(X===1)Q.adler=h$(Q.adler,$,J,0);if(q.wrap=0,J>=q.w_size){if(X===0)T1(q.head),q.strstart=0,q.block_start=0,q.insert=0;U=new U0.Buf8(q.w_size),U0.arraySet(U,$,J-q.w_size,q.w_size,0),$=U,J=q.w_size}K=Q.avail_in,W=Q.next_in,G=Q.input,Q.avail_in=J,Q.next_in=0,Q.input=$,u1(q);while(q.lookahead>=E){Y=q.strstart,V=q.lookahead-(E-1);do q.ins_h=(q.ins_h<<q.hash_shift^q.window[Y+E-1])&q.hash_mask,q.prev[Y&q.w_mask]=q.head[q.ins_h],q.head[q.ins_h]=Y,Y++;while(--V);q.strstart=Y,q.lookahead=E-1,u1(q)}return q.strstart+=q.lookahead,q.block_start=q.strstart,q.insert=q.lookahead,q.lookahead=0,q.match_length=q.prev_length=E-1,q.match_available=0,Q.next_in=W,Q.input=G,Q.avail_in=K,q.wrap=X,r0}KU.deflateInit=qU;KU.deflateInit2=u$;KU.deflateReset=c$;KU.deflateResetKeep=m$;KU.deflateSetHeader=JU;KU.deflate=YU;KU.deflateEnd=VU;KU.deflateSetDictionary=XU;KU.deflateInfo="pako deflate (from Nodeca project)"});var v9=w((OU)=>{var O2=W1(),d$=!0,l$=!0;try{String.fromCharCode.apply(null,[0])}catch(Q){d$=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(Q){l$=!1}var K8=new O2.Buf8(256);for(a0=0;a0<256;a0++)K8[a0]=a0>=252?6:a0>=248?5:a0>=240?4:a0>=224?3:a0>=192?2:1;var a0;K8[254]=K8[254]=1;OU.string2buf=function(Q){var $,J,q,Y,V,X=Q.length,K=0;for(Y=0;Y<X;Y++){if(J=Q.charCodeAt(Y),(J&64512)===55296&&Y+1<X){if(q=Q.charCodeAt(Y+1),(q&64512)===56320)J=65536+(J-55296<<10)+(q-56320),Y++}K+=J<128?1:J<2048?2:J<65536?3:4}$=new O2.Buf8(K);for(V=0,Y=0;V<K;Y++){if(J=Q.charCodeAt(Y),(J&64512)===55296&&Y+1<X){if(q=Q.charCodeAt(Y+1),(q&64512)===56320)J=65536+(J-55296<<10)+(q-56320),Y++}if(J<128)$[V++]=J;else if(J<2048)$[V++]=192|J>>>6,$[V++]=128|J&63;else if(J<65536)$[V++]=224|J>>>12,$[V++]=128|J>>>6&63,$[V++]=128|J&63;else $[V++]=240|J>>>18,$[V++]=128|J>>>12&63,$[V++]=128|J>>>6&63,$[V++]=128|J&63}return $};function o$(Q,$){if($<65534){if(Q.subarray&&l$||!Q.subarray&&d$)return String.fromCharCode.apply(null,O2.shrinkBuf(Q,$))}var J="";for(var q=0;q<$;q++)J+=String.fromCharCode(Q[q]);return J}OU.buf2binstring=function(Q){return o$(Q,Q.length)};OU.binstring2buf=function(Q){var $=new O2.Buf8(Q.length);for(var J=0,q=$.length;J<q;J++)$[J]=Q.charCodeAt(J);return $};OU.buf2string=function(Q,$){var J,q,Y,V,X=$||Q.length,K=Array(X*2);for(q=0,J=0;J<X;){if(Y=Q[J++],Y<128){K[q++]=Y;continue}if(V=K8[Y],V>4){K[q++]=65533,J+=V-1;continue}Y&=V===2?31:V===3?15:7;while(V>1&&J<X)Y=Y<<6|Q[J++]&63,V--;if(V>1){K[q++]=65533;continue}if(Y<65536)K[q++]=Y;else Y-=65536,K[q++]=55296|Y>>10&1023,K[q++]=56320|Y&1023}return o$(K,q)};OU.utf8border=function(Q,$){var J;if($=$||Q.length,$>Q.length)$=Q.length;J=$-1;while(J>=0&&(Q[J]&192)===128)J--;if(J<0)return $;if(J===0)return $;return J+K8[Q[J]]>$?J:$}});var E9=w((WO,i$)=>{function TU(){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}i$.exports=TU});var s$=w((EU)=>{var G8=p$(),W8=W1(),k9=v9(),y9=U2(),CU=E9(),a$=Object.prototype.toString,AU=0,S9=4,F6=0,n$=1,r$=2,DU=-1,wU=0,RU=8;function d1(Q){if(!(this instanceof d1))return new d1(Q);this.options=W8.assign({level:DU,method:RU,chunkSize:16384,windowBits:15,memLevel:8,strategy:wU,to:""},Q||{});var $=this.options;if($.raw&&$.windowBits>0)$.windowBits=-$.windowBits;else if($.gzip&&$.windowBits>0&&$.windowBits<16)$.windowBits+=16;this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new CU,this.strm.avail_out=0;var J=G8.deflateInit2(this.strm,$.level,$.method,$.windowBits,$.memLevel,$.strategy);if(J!==F6)throw Error(y9[J]);if($.header)G8.deflateSetHeader(this.strm,$.header);if($.dictionary){var q;if(typeof $.dictionary==="string")q=k9.string2buf($.dictionary);else if(a$.call($.dictionary)==="[object ArrayBuffer]")q=new Uint8Array($.dictionary);else q=$.dictionary;if(J=G8.deflateSetDictionary(this.strm,q),J!==F6)throw Error(y9[J]);this._dict_set=!0}}d1.prototype.push=function(Q,$){var J=this.strm,q=this.options.chunkSize,Y,V;if(this.ended)return!1;if(V=$===~~$?$:$===!0?S9:AU,typeof Q==="string")J.input=k9.string2buf(Q);else if(a$.call(Q)==="[object ArrayBuffer]")J.input=new Uint8Array(Q);else J.input=Q;J.next_in=0,J.avail_in=J.input.length;do{if(J.avail_out===0)J.output=new W8.Buf8(q),J.next_out=0,J.avail_out=q;if(Y=G8.deflate(J,V),Y!==n$&&Y!==F6)return this.onEnd(Y),this.ended=!0,!1;if(J.avail_out===0||J.avail_in===0&&(V===S9||V===r$))if(this.options.to==="string")this.onData(k9.buf2binstring(W8.shrinkBuf(J.output,J.next_out)));else this.onData(W8.shrinkBuf(J.output,J.next_out))}while((J.avail_in>0||J.avail_out===0)&&Y!==n$);if(V===S9)return Y=G8.deflateEnd(this.strm),this.onEnd(Y),this.ended=!0,Y===F6;if(V===r$)return this.onEnd(F6),J.avail_out=0,!0;return!0};d1.prototype.onData=function(Q){this.chunks.push(Q)};d1.prototype.onEnd=function(Q){if(Q===F6)if(this.options.to==="string")this.result=this.chunks.join("");else this.result=W8.flattenChunks(this.chunks);this.chunks=[],this.err=Q,this.msg=this.strm.msg};function g9(Q,$){var J=new d1($);if(J.push(Q,!0),J.err)throw J.msg||y9[J.err];return J.result}function xU(Q,$){return $=$||{},$.raw=!0,g9(Q,$)}function vU(Q,$){return $=$||{},$.gzip=!0,g9(Q,$)}EU.Deflate=d1;EU.deflate=g9;EU.deflateRaw=xU;EU.gzip=vU});var e$=w((jO,t$)=>{var N2=30,_U=12;t$.exports=function($,J){var q,Y,V,X,K,W,G,U,z,j,H,F,N,T,P,L,A,B,O,M,C,D,x,v,R;q=$.state,Y=$.next_in,v=$.input,V=Y+($.avail_in-5),X=$.next_out,R=$.output,K=X-(J-$.avail_out),W=X+($.avail_out-257),G=q.dmax,U=q.wsize,z=q.whave,j=q.wnext,H=q.window,F=q.hold,N=q.bits,T=q.lencode,P=q.distcode,L=(1<<q.lenbits)-1,A=(1<<q.distbits)-1;Q:do{if(N<15)F+=v[Y++]<<N,N+=8,F+=v[Y++]<<N,N+=8;B=T[F&L];$:for(;;){if(O=B>>>24,F>>>=O,N-=O,O=B>>>16&255,O===0)R[X++]=B&65535;else if(O&16){if(M=B&65535,O&=15,O){if(N<O)F+=v[Y++]<<N,N+=8;M+=F&(1<<O)-1,F>>>=O,N-=O}if(N<15)F+=v[Y++]<<N,N+=8,F+=v[Y++]<<N,N+=8;B=P[F&A];J:for(;;){if(O=B>>>24,F>>>=O,N-=O,O=B>>>16&255,O&16){if(C=B&65535,O&=15,N<O){if(F+=v[Y++]<<N,N+=8,N<O)F+=v[Y++]<<N,N+=8}if(C+=F&(1<<O)-1,C>G){$.msg="invalid distance too far back",q.mode=N2;break Q}if(F>>>=O,N-=O,O=X-K,C>O){if(O=C-O,O>z){if(q.sane){$.msg="invalid distance too far back",q.mode=N2;break Q}}if(D=0,x=H,j===0){if(D+=U-O,O<M){M-=O;do R[X++]=H[D++];while(--O);D=X-C,x=R}}else if(j<O){if(D+=U+j-O,O-=j,O<M){M-=O;do R[X++]=H[D++];while(--O);if(D=0,j<M){O=j,M-=O;do R[X++]=H[D++];while(--O);D=X-C,x=R}}}else if(D+=j-O,O<M){M-=O;do R[X++]=H[D++];while(--O);D=X-C,x=R}while(M>2)R[X++]=x[D++],R[X++]=x[D++],R[X++]=x[D++],M-=3;if(M){if(R[X++]=x[D++],M>1)R[X++]=x[D++]}}else{D=X-C;do R[X++]=R[D++],R[X++]=R[D++],R[X++]=R[D++],M-=3;while(M>2);if(M){if(R[X++]=R[D++],M>1)R[X++]=R[D++]}}}else if((O&64)===0){B=P[(B&65535)+(F&(1<<O)-1)];continue J}else{$.msg="invalid distance code",q.mode=N2;break Q}break}}else if((O&64)===0){B=T[(B&65535)+(F&(1<<O)-1)];continue $}else if(O&32){q.mode=_U;break Q}else{$.msg="invalid literal/length code",q.mode=N2;break Q}break}}while(Y<V&&X<W);M=N>>3,Y-=M,N-=M<<3,F&=(1<<N)-1,$.next_in=Y,$.next_out=X,$.avail_in=Y<V?5+(V-Y):5-(Y-V),$.avail_out=X<W?257+(W-X):257-(X-W),q.hold=F,q.bits=N;return}});var XJ=w((ZO,VJ)=>{var QJ=W1(),L6=15,$J=852,JJ=592,qJ=0,_9=1,YJ=2,bU=[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],hU=[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],fU=[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],mU=[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];VJ.exports=function($,J,q,Y,V,X,K,W){var G=W.bits,U=0,z=0,j=0,H=0,F=0,N=0,T=0,P=0,L=0,A=0,B,O,M,C,D,x=null,v=0,R,$0=new QJ.Buf16(L6+1),I0=new QJ.Buf16(L6+1),h=null,G0=0,T0,Z0,q1;for(U=0;U<=L6;U++)$0[U]=0;for(z=0;z<Y;z++)$0[J[q+z]]++;F=G;for(H=L6;H>=1;H--)if($0[H]!==0)break;if(F>H)F=H;if(H===0)return V[X++]=20971520,V[X++]=20971520,W.bits=1,0;for(j=1;j<H;j++)if($0[j]!==0)break;if(F<j)F=j;P=1;for(U=1;U<=L6;U++)if(P<<=1,P-=$0[U],P<0)return-1;if(P>0&&($===qJ||H!==1))return-1;I0[1]=0;for(U=1;U<L6;U++)I0[U+1]=I0[U]+$0[U];for(z=0;z<Y;z++)if(J[q+z]!==0)K[I0[J[q+z]]++]=z;if($===qJ)x=h=K,R=19;else if($===_9)x=bU,v-=257,h=hU,G0-=257,R=256;else x=fU,h=mU,R=-1;if(A=0,z=0,U=j,D=X,N=F,T=0,M=-1,L=1<<F,C=L-1,$===_9&&L>$J||$===YJ&&L>JJ)return 1;for(;;){if(T0=U-T,K[z]<R)Z0=0,q1=K[z];else if(K[z]>R)Z0=h[G0+K[z]],q1=x[v+K[z]];else Z0=96,q1=0;B=1<<U-T,O=1<<N,j=O;do O-=B,V[D+(A>>T)+O]=T0<<24|Z0<<16|q1|0;while(O!==0);B=1<<U-1;while(A&B)B>>=1;if(B!==0)A&=B-1,A+=B;else A=0;if(z++,--$0[U]===0){if(U===H)break;U=J[q+K[z]]}if(U>F&&(A&C)!==M){if(T===0)T=F;D+=j,N=U-T,P=1<<N;while(N+T<H){if(P-=$0[N+T],P<=0)break;N++,P<<=1}if(L+=1<<N,$===_9&&L>$J||$===YJ&&L>JJ)return 1;M=A&C,V[M]=F<<24|N<<16|D-X|0}}if(A!==0)V[D+A]=U-T<<24|4194304|0;return W.bits=F,0}});var cJ=w((Vj)=>{var B0=W1(),u9=C9(),s0=A9(),cU=e$(),U8=XJ(),uU=0,SJ=1,kJ=2,KJ=4,pU=5,B2=6,l1=0,dU=1,lU=2,x0=-2,yJ=-3,p9=-4,oU=-5,GJ=8,gJ=1,WJ=2,UJ=3,jJ=4,ZJ=5,zJ=6,HJ=7,FJ=8,LJ=9,OJ=10,I2=11,j1=12,b9=13,NJ=14,h9=15,BJ=16,MJ=17,PJ=18,IJ=19,M2=20,P2=21,TJ=22,CJ=23,AJ=24,DJ=25,wJ=26,f9=27,RJ=28,xJ=29,p=30,d9=31,iU=32,nU=852,rU=592,aU=15,sU=aU;function vJ(Q){return(Q>>>24&255)+(Q>>>8&65280)+((Q&65280)<<8)+((Q&255)<<24)}function tU(){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 B0.Buf16(320),this.work=new B0.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function _J(Q){var $;if(!Q||!Q.state)return x0;if($=Q.state,Q.total_in=Q.total_out=$.total=0,Q.msg="",$.wrap)Q.adler=$.wrap&1;return $.mode=gJ,$.last=0,$.havedict=0,$.dmax=32768,$.head=null,$.hold=0,$.bits=0,$.lencode=$.lendyn=new B0.Buf32(nU),$.distcode=$.distdyn=new B0.Buf32(rU),$.sane=1,$.back=-1,l1}function bJ(Q){var $;if(!Q||!Q.state)return x0;return $=Q.state,$.wsize=0,$.whave=0,$.wnext=0,_J(Q)}function hJ(Q,$){var J,q;if(!Q||!Q.state)return x0;if(q=Q.state,$<0)J=0,$=-$;else if(J=($>>4)+1,$<48)$&=15;if($&&($<8||$>15))return x0;if(q.window!==null&&q.wbits!==$)q.window=null;return q.wrap=J,q.wbits=$,bJ(Q)}function fJ(Q,$){var J,q;if(!Q)return x0;if(q=new tU,Q.state=q,q.window=null,J=hJ(Q,$),J!==l1)Q.state=null;return J}function eU(Q){return fJ(Q,sU)}var EJ=!0,m9,c9;function Qj(Q){if(EJ){var $;m9=new B0.Buf32(512),c9=new B0.Buf32(32),$=0;while($<144)Q.lens[$++]=8;while($<256)Q.lens[$++]=9;while($<280)Q.lens[$++]=7;while($<288)Q.lens[$++]=8;U8(SJ,Q.lens,0,288,m9,0,Q.work,{bits:9}),$=0;while($<32)Q.lens[$++]=5;U8(kJ,Q.lens,0,32,c9,0,Q.work,{bits:5}),EJ=!1}Q.lencode=m9,Q.lenbits=9,Q.distcode=c9,Q.distbits=5}function mJ(Q,$,J,q){var Y,V=Q.state;if(V.window===null)V.wsize=1<<V.wbits,V.wnext=0,V.whave=0,V.window=new B0.Buf8(V.wsize);if(q>=V.wsize)B0.arraySet(V.window,$,J-V.wsize,V.wsize,0),V.wnext=0,V.whave=V.wsize;else{if(Y=V.wsize-V.wnext,Y>q)Y=q;if(B0.arraySet(V.window,$,J-q,Y,V.wnext),q-=Y,q)B0.arraySet(V.window,$,J-q,q,0),V.wnext=q,V.whave=V.wsize;else{if(V.wnext+=Y,V.wnext===V.wsize)V.wnext=0;if(V.whave<V.wsize)V.whave+=Y}}return 0}function $j(Q,$){var J,q,Y,V,X,K,W,G,U,z,j,H,F,N,T=0,P,L,A,B,O,M,C,D,x=new B0.Buf8(4),v,R,$0=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!Q||!Q.state||!Q.output||!Q.input&&Q.avail_in!==0)return x0;if(J=Q.state,J.mode===j1)J.mode=b9;X=Q.next_out,Y=Q.output,W=Q.avail_out,V=Q.next_in,q=Q.input,K=Q.avail_in,G=J.hold,U=J.bits,z=K,j=W,D=l1;Q:for(;;)switch(J.mode){case gJ:if(J.wrap===0){J.mode=b9;break}while(U<16){if(K===0)break Q;K--,G+=q[V++]<<U,U+=8}if(J.wrap&2&&G===35615){J.check=0,x[0]=G&255,x[1]=G>>>8&255,J.check=s0(J.check,x,2,0),G=0,U=0,J.mode=WJ;break}if(J.flags=0,J.head)J.head.done=!1;if(!(J.wrap&1)||(((G&255)<<8)+(G>>8))%31){Q.msg="incorrect header check",J.mode=p;break}if((G&15)!==GJ){Q.msg="unknown compression method",J.mode=p;break}if(G>>>=4,U-=4,C=(G&15)+8,J.wbits===0)J.wbits=C;else if(C>J.wbits){Q.msg="invalid window size",J.mode=p;break}J.dmax=1<<C,Q.adler=J.check=1,J.mode=G&512?OJ:j1,G=0,U=0;break;case WJ:while(U<16){if(K===0)break Q;K--,G+=q[V++]<<U,U+=8}if(J.flags=G,(J.flags&255)!==GJ){Q.msg="unknown compression method",J.mode=p;break}if(J.flags&57344){Q.msg="unknown header flags set",J.mode=p;break}if(J.head)J.head.text=G>>8&1;if(J.flags&512)x[0]=G&255,x[1]=G>>>8&255,J.check=s0(J.check,x,2,0);G=0,U=0,J.mode=UJ;case UJ:while(U<32){if(K===0)break Q;K--,G+=q[V++]<<U,U+=8}if(J.head)J.head.time=G;if(J.flags&512)x[0]=G&255,x[1]=G>>>8&255,x[2]=G>>>16&255,x[3]=G>>>24&255,J.check=s0(J.check,x,4,0);G=0,U=0,J.mode=jJ;case jJ:while(U<16){if(K===0)break Q;K--,G+=q[V++]<<U,U+=8}if(J.head)J.head.xflags=G&255,J.head.os=G>>8;if(J.flags&512)x[0]=G&255,x[1]=G>>>8&255,J.check=s0(J.check,x,2,0);G=0,U=0,J.mode=ZJ;case ZJ:if(J.flags&1024){while(U<16){if(K===0)break Q;K--,G+=q[V++]<<U,U+=8}if(J.length=G,J.head)J.head.extra_len=G;if(J.flags&512)x[0]=G&255,x[1]=G>>>8&255,J.check=s0(J.check,x,2,0);G=0,U=0}else if(J.head)J.head.extra=null;J.mode=zJ;case zJ:if(J.flags&1024){if(H=J.length,H>K)H=K;if(H){if(J.head){if(C=J.head.extra_len-J.length,!J.head.extra)J.head.extra=Array(J.head.extra_len);B0.arraySet(J.head.extra,q,V,H,C)}if(J.flags&512)J.check=s0(J.check,q,H,V);K-=H,V+=H,J.length-=H}if(J.length)break Q}J.length=0,J.mode=HJ;case HJ:if(J.flags&2048){if(K===0)break Q;H=0;do if(C=q[V+H++],J.head&&C&&J.length<65536)J.head.name+=String.fromCharCode(C);while(C&&H<K);if(J.flags&512)J.check=s0(J.check,q,H,V);if(K-=H,V+=H,C)break Q}else if(J.head)J.head.name=null;J.length=0,J.mode=FJ;case FJ:if(J.flags&4096){if(K===0)break Q;H=0;do if(C=q[V+H++],J.head&&C&&J.length<65536)J.head.comment+=String.fromCharCode(C);while(C&&H<K);if(J.flags&512)J.check=s0(J.check,q,H,V);if(K-=H,V+=H,C)break Q}else if(J.head)J.head.comment=null;J.mode=LJ;case LJ:if(J.flags&512){while(U<16){if(K===0)break Q;K--,G+=q[V++]<<U,U+=8}if(G!==(J.check&65535)){Q.msg="header crc mismatch",J.mode=p;break}G=0,U=0}if(J.head)J.head.hcrc=J.flags>>9&1,J.head.done=!0;Q.adler=J.check=0,J.mode=j1;break;case OJ:while(U<32){if(K===0)break Q;K--,G+=q[V++]<<U,U+=8}Q.adler=J.check=vJ(G),G=0,U=0,J.mode=I2;case I2:if(J.havedict===0)return Q.next_out=X,Q.avail_out=W,Q.next_in=V,Q.avail_in=K,J.hold=G,J.bits=U,lU;Q.adler=J.check=1,J.mode=j1;case j1:if($===pU||$===B2)break Q;case b9:if(J.last){G>>>=U&7,U-=U&7,J.mode=f9;break}while(U<3){if(K===0)break Q;K--,G+=q[V++]<<U,U+=8}switch(J.last=G&1,G>>>=1,U-=1,G&3){case 0:J.mode=NJ;break;case 1:if(Qj(J),J.mode=M2,$===B2){G>>>=2,U-=2;break Q}break;case 2:J.mode=MJ;break;case 3:Q.msg="invalid block type",J.mode=p}G>>>=2,U-=2;break;case NJ:G>>>=U&7,U-=U&7;while(U<32){if(K===0)break Q;K--,G+=q[V++]<<U,U+=8}if((G&65535)!==(G>>>16^65535)){Q.msg="invalid stored block lengths",J.mode=p;break}if(J.length=G&65535,G=0,U=0,J.mode=h9,$===B2)break Q;case h9:J.mode=BJ;case BJ:if(H=J.length,H){if(H>K)H=K;if(H>W)H=W;if(H===0)break Q;B0.arraySet(Y,q,V,H,X),K-=H,V+=H,W-=H,X+=H,J.length-=H;break}J.mode=j1;break;case MJ:while(U<14){if(K===0)break Q;K--,G+=q[V++]<<U,U+=8}if(J.nlen=(G&31)+257,G>>>=5,U-=5,J.ndist=(G&31)+1,G>>>=5,U-=5,J.ncode=(G&15)+4,G>>>=4,U-=4,J.nlen>286||J.ndist>30){Q.msg="too many length or distance symbols",J.mode=p;break}J.have=0,J.mode=PJ;case PJ:while(J.have<J.ncode){while(U<3){if(K===0)break Q;K--,G+=q[V++]<<U,U+=8}J.lens[$0[J.have++]]=G&7,G>>>=3,U-=3}while(J.have<19)J.lens[$0[J.have++]]=0;if(J.lencode=J.lendyn,J.lenbits=7,v={bits:J.lenbits},D=U8(uU,J.lens,0,19,J.lencode,0,J.work,v),J.lenbits=v.bits,D){Q.msg="invalid code lengths set",J.mode=p;break}J.have=0,J.mode=IJ;case IJ:while(J.have<J.nlen+J.ndist){for(;;){if(T=J.lencode[G&(1<<J.lenbits)-1],P=T>>>24,L=T>>>16&255,A=T&65535,P<=U)break;if(K===0)break Q;K--,G+=q[V++]<<U,U+=8}if(A<16)G>>>=P,U-=P,J.lens[J.have++]=A;else{if(A===16){R=P+2;while(U<R){if(K===0)break Q;K--,G+=q[V++]<<U,U+=8}if(G>>>=P,U-=P,J.have===0){Q.msg="invalid bit length repeat",J.mode=p;break}C=J.lens[J.have-1],H=3+(G&3),G>>>=2,U-=2}else if(A===17){R=P+3;while(U<R){if(K===0)break Q;K--,G+=q[V++]<<U,U+=8}G>>>=P,U-=P,C=0,H=3+(G&7),G>>>=3,U-=3}else{R=P+7;while(U<R){if(K===0)break Q;K--,G+=q[V++]<<U,U+=8}G>>>=P,U-=P,C=0,H=11+(G&127),G>>>=7,U-=7}if(J.have+H>J.nlen+J.ndist){Q.msg="invalid bit length repeat",J.mode=p;break}while(H--)J.lens[J.have++]=C}}if(J.mode===p)break;if(J.lens[256]===0){Q.msg="invalid code -- missing end-of-block",J.mode=p;break}if(J.lenbits=9,v={bits:J.lenbits},D=U8(SJ,J.lens,0,J.nlen,J.lencode,0,J.work,v),J.lenbits=v.bits,D){Q.msg="invalid literal/lengths set",J.mode=p;break}if(J.distbits=6,J.distcode=J.distdyn,v={bits:J.distbits},D=U8(kJ,J.lens,J.nlen,J.ndist,J.distcode,0,J.work,v),J.distbits=v.bits,D){Q.msg="invalid distances set",J.mode=p;break}if(J.mode=M2,$===B2)break Q;case M2:J.mode=P2;case P2:if(K>=6&&W>=258){if(Q.next_out=X,Q.avail_out=W,Q.next_in=V,Q.avail_in=K,J.hold=G,J.bits=U,cU(Q,j),X=Q.next_out,Y=Q.output,W=Q.avail_out,V=Q.next_in,q=Q.input,K=Q.avail_in,G=J.hold,U=J.bits,J.mode===j1)J.back=-1;break}J.back=0;for(;;){if(T=J.lencode[G&(1<<J.lenbits)-1],P=T>>>24,L=T>>>16&255,A=T&65535,P<=U)break;if(K===0)break Q;K--,G+=q[V++]<<U,U+=8}if(L&&(L&240)===0){B=P,O=L,M=A;for(;;){if(T=J.lencode[M+((G&(1<<B+O)-1)>>B)],P=T>>>24,L=T>>>16&255,A=T&65535,B+P<=U)break;if(K===0)break Q;K--,G+=q[V++]<<U,U+=8}G>>>=B,U-=B,J.back+=B}if(G>>>=P,U-=P,J.back+=P,J.length=A,L===0){J.mode=wJ;break}if(L&32){J.back=-1,J.mode=j1;break}if(L&64){Q.msg="invalid literal/length code",J.mode=p;break}J.extra=L&15,J.mode=TJ;case TJ:if(J.extra){R=J.extra;while(U<R){if(K===0)break Q;K--,G+=q[V++]<<U,U+=8}J.length+=G&(1<<J.extra)-1,G>>>=J.extra,U-=J.extra,J.back+=J.extra}J.was=J.length,J.mode=CJ;case CJ:for(;;){if(T=J.distcode[G&(1<<J.distbits)-1],P=T>>>24,L=T>>>16&255,A=T&65535,P<=U)break;if(K===0)break Q;K--,G+=q[V++]<<U,U+=8}if((L&240)===0){B=P,O=L,M=A;for(;;){if(T=J.distcode[M+((G&(1<<B+O)-1)>>B)],P=T>>>24,L=T>>>16&255,A=T&65535,B+P<=U)break;if(K===0)break Q;K--,G+=q[V++]<<U,U+=8}G>>>=B,U-=B,J.back+=B}if(G>>>=P,U-=P,J.back+=P,L&64){Q.msg="invalid distance code",J.mode=p;break}J.offset=A,J.extra=L&15,J.mode=AJ;case AJ:if(J.extra){R=J.extra;while(U<R){if(K===0)break Q;K--,G+=q[V++]<<U,U+=8}J.offset+=G&(1<<J.extra)-1,G>>>=J.extra,U-=J.extra,J.back+=J.extra}if(J.offset>J.dmax){Q.msg="invalid distance too far back",J.mode=p;break}J.mode=DJ;case DJ:if(W===0)break Q;if(H=j-W,J.offset>H){if(H=J.offset-H,H>J.whave){if(J.sane){Q.msg="invalid distance too far back",J.mode=p;break}}if(H>J.wnext)H-=J.wnext,F=J.wsize-H;else F=J.wnext-H;if(H>J.length)H=J.length;N=J.window}else N=Y,F=X-J.offset,H=J.length;if(H>W)H=W;W-=H,J.length-=H;do Y[X++]=N[F++];while(--H);if(J.length===0)J.mode=P2;break;case wJ:if(W===0)break Q;Y[X++]=J.length,W--,J.mode=P2;break;case f9:if(J.wrap){while(U<32){if(K===0)break Q;K--,G|=q[V++]<<U,U+=8}if(j-=W,Q.total_out+=j,J.total+=j,j)Q.adler=J.check=J.flags?s0(J.check,Y,j,X-j):u9(J.check,Y,j,X-j);if(j=W,(J.flags?G:vJ(G))!==J.check){Q.msg="incorrect data check",J.mode=p;break}G=0,U=0}J.mode=RJ;case RJ:if(J.wrap&&J.flags){while(U<32){if(K===0)break Q;K--,G+=q[V++]<<U,U+=8}if(G!==(J.total&4294967295)){Q.msg="incorrect length check",J.mode=p;break}G=0,U=0}J.mode=xJ;case xJ:D=dU;break Q;case p:D=yJ;break Q;case d9:return p9;case iU:default:return x0}if(Q.next_out=X,Q.avail_out=W,Q.next_in=V,Q.avail_in=K,J.hold=G,J.bits=U,J.wsize||j!==Q.avail_out&&J.mode<p&&(J.mode<f9||$!==KJ)){if(mJ(Q,Q.output,Q.next_out,j-Q.avail_out))return J.mode=d9,p9}if(z-=Q.avail_in,j-=Q.avail_out,Q.total_in+=z,Q.total_out+=j,J.total+=j,J.wrap&&j)Q.adler=J.check=J.flags?s0(J.check,Y,j,Q.next_out-j):u9(J.check,Y,j,Q.next_out-j);if(Q.data_type=J.bits+(J.last?64:0)+(J.mode===j1?128:0)+(J.mode===M2||J.mode===h9?256:0),(z===0&&j===0||$===KJ)&&D===l1)D=oU;return D}function Jj(Q){if(!Q||!Q.state)return x0;var $=Q.state;if($.window)$.window=null;return Q.state=null,l1}function qj(Q,$){var J;if(!Q||!Q.state)return x0;if(J=Q.state,(J.wrap&2)===0)return x0;return J.head=$,$.done=!1,l1}function Yj(Q,$){var J=$.length,q,Y,V;if(!Q||!Q.state)return x0;if(q=Q.state,q.wrap!==0&&q.mode!==I2)return x0;if(q.mode===I2){if(Y=1,Y=u9(Y,$,J,0),Y!==q.check)return yJ}if(V=mJ(Q,$,J,J),V)return q.mode=d9,p9;return q.havedict=1,l1}Vj.inflateReset=bJ;Vj.inflateReset2=hJ;Vj.inflateResetKeep=_J;Vj.inflateInit=eU;Vj.inflateInit2=fJ;Vj.inflate=$j;Vj.inflateEnd=Jj;Vj.inflateGetHeader=qj;Vj.inflateSetDictionary=Yj;Vj.inflateInfo="pako inflate (from Nodeca project)"});var l9=w((HO,uJ)=>{uJ.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}});var dJ=w((FO,pJ)=>{function Lj(){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}pJ.exports=Lj});var oJ=w((Mj)=>{var O6=cJ(),j8=W1(),T2=v9(),i=l9(),o9=U2(),Oj=E9(),Nj=dJ(),lJ=Object.prototype.toString;function o1(Q){if(!(this instanceof o1))return new o1(Q);this.options=j8.assign({chunkSize:16384,windowBits:0,to:""},Q||{});var $=this.options;if($.raw&&$.windowBits>=0&&$.windowBits<16){if($.windowBits=-$.windowBits,$.windowBits===0)$.windowBits=-15}if($.windowBits>=0&&$.windowBits<16&&!(Q&&Q.windowBits))$.windowBits+=32;if($.windowBits>15&&$.windowBits<48){if(($.windowBits&15)===0)$.windowBits|=15}this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Oj,this.strm.avail_out=0;var J=O6.inflateInit2(this.strm,$.windowBits);if(J!==i.Z_OK)throw Error(o9[J]);if(this.header=new Nj,O6.inflateGetHeader(this.strm,this.header),$.dictionary){if(typeof $.dictionary==="string")$.dictionary=T2.string2buf($.dictionary);else if(lJ.call($.dictionary)==="[object ArrayBuffer]")$.dictionary=new Uint8Array($.dictionary);if($.raw){if(J=O6.inflateSetDictionary(this.strm,$.dictionary),J!==i.Z_OK)throw Error(o9[J])}}}o1.prototype.push=function(Q,$){var J=this.strm,q=this.options.chunkSize,Y=this.options.dictionary,V,X,K,W,G,U=!1;if(this.ended)return!1;if(X=$===~~$?$:$===!0?i.Z_FINISH:i.Z_NO_FLUSH,typeof Q==="string")J.input=T2.binstring2buf(Q);else if(lJ.call(Q)==="[object ArrayBuffer]")J.input=new Uint8Array(Q);else J.input=Q;J.next_in=0,J.avail_in=J.input.length;do{if(J.avail_out===0)J.output=new j8.Buf8(q),J.next_out=0,J.avail_out=q;if(V=O6.inflate(J,i.Z_NO_FLUSH),V===i.Z_NEED_DICT&&Y)V=O6.inflateSetDictionary(this.strm,Y);if(V===i.Z_BUF_ERROR&&U===!0)V=i.Z_OK,U=!1;if(V!==i.Z_STREAM_END&&V!==i.Z_OK)return this.onEnd(V),this.ended=!0,!1;if(J.next_out){if(J.avail_out===0||V===i.Z_STREAM_END||J.avail_in===0&&(X===i.Z_FINISH||X===i.Z_SYNC_FLUSH))if(this.options.to==="string"){if(K=T2.utf8border(J.output,J.next_out),W=J.next_out-K,G=T2.buf2string(J.output,K),J.next_out=W,J.avail_out=q-W,W)j8.arraySet(J.output,J.output,K,W,0);this.onData(G)}else this.onData(j8.shrinkBuf(J.output,J.next_out))}if(J.avail_in===0&&J.avail_out===0)U=!0}while((J.avail_in>0||J.avail_out===0)&&V!==i.Z_STREAM_END);if(V===i.Z_STREAM_END)X=i.Z_FINISH;if(X===i.Z_FINISH)return V=O6.inflateEnd(this.strm),this.onEnd(V),this.ended=!0,V===i.Z_OK;if(X===i.Z_SYNC_FLUSH)return this.onEnd(i.Z_OK),J.avail_out=0,!0;return!0};o1.prototype.onData=function(Q){this.chunks.push(Q)};o1.prototype.onEnd=function(Q){if(Q===i.Z_OK)if(this.options.to==="string")this.result=this.chunks.join("");else this.result=j8.flattenChunks(this.chunks);this.chunks=[],this.err=Q,this.msg=this.strm.msg};function i9(Q,$){var J=new o1($);if(J.push(Q,!0),J.err)throw J.msg||o9[J.err];return J.result}function Bj(Q,$){return $=$||{},$.raw=!0,i9(Q,$)}Mj.Inflate=o1;Mj.inflate=i9;Mj.inflateRaw=Bj;Mj.ungzip=i9});var rJ=w((OO,nJ)=>{var Aj=W1().assign,Dj=s$(),wj=oJ(),Rj=l9(),iJ={};Aj(iJ,Dj,wj,Rj);nJ.exports=iJ});var sJ=w((Sj)=>{var xj=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",vj=rJ(),aJ=d(),C2=N0(),Ej=xj?"uint8array":"array";Sj.magic="\b\x00";function i1(Q,$){C2.call(this,"FlateWorker/"+Q),this._pako=null,this._pakoAction=Q,this._pakoOptions=$,this.meta={}}aJ.inherits(i1,C2);i1.prototype.processChunk=function(Q){if(this.meta=Q.meta,this._pako===null)this._createPako();this._pako.push(aJ.transformTo(Ej,Q.data),!1)};i1.prototype.flush=function(){if(C2.prototype.flush.call(this),this._pako===null)this._createPako();this._pako.push([],!0)};i1.prototype.cleanUp=function(){C2.prototype.cleanUp.call(this),this._pako=null};i1.prototype._createPako=function(){this._pako=new vj[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var Q=this;this._pako.onData=function($){Q.push({data:$,meta:Q.meta})}};Sj.compressWorker=function(Q){return new i1("Deflate",Q)};Sj.uncompressWorker=function(){return new i1("Inflate",{})}});var n9=w((_j)=>{var tJ=N0();_j.STORE={magic:"\x00\x00",compressWorker:function(){return new tJ("STORE compression")},uncompressWorker:function(){return new tJ("STORE decompression")}};_j.DEFLATE=sJ()});var r9=w((fj)=>{fj.LOCAL_FILE_HEADER="PK\x03\x04";fj.CENTRAL_FILE_HEADER="PK\x01\x02";fj.CENTRAL_DIRECTORY_END="PK\x05\x06";fj.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x06\x07";fj.ZIP64_CENTRAL_DIRECTORY_END="PK\x06\x06";fj.DATA_DESCRIPTOR="PK\x07\b"});var Jq=w((PO,$q)=>{var N6=d(),B6=N0(),a9=G6(),eJ=X2(),A2=r9(),m=function(Q,$){var J="",q;for(q=0;q<$;q++)J+=String.fromCharCode(Q&255),Q=Q>>>8;return J},oj=function(Q,$){var J=Q;if(!Q)J=$?16893:33204;return(J&65535)<<16},ij=function(Q){return(Q||0)&63},Qq=function(Q,$,J,q,Y,V){var{file:X,compression:K}=Q,W=V!==a9.utf8encode,G=N6.transformTo("string",V(X.name)),U=N6.transformTo("string",a9.utf8encode(X.name)),z=X.comment,j=N6.transformTo("string",V(z)),H=N6.transformTo("string",a9.utf8encode(z)),F=U.length!==X.name.length,N=H.length!==z.length,T,P,L="",A="",B="",O=X.dir,M=X.date,C={crc32:0,compressedSize:0,uncompressedSize:0};if(!$||J)C.crc32=Q.crc32,C.compressedSize=Q.compressedSize,C.uncompressedSize=Q.uncompressedSize;var D=0;if($)D|=8;if(!W&&(F||N))D|=2048;var x=0,v=0;if(O)x|=16;if(Y==="UNIX")v=798,x|=oj(X.unixPermissions,O);else v=20,x|=ij(X.dosPermissions,O);if(T=M.getUTCHours(),T=T<<6,T=T|M.getUTCMinutes(),T=T<<5,T=T|M.getUTCSeconds()/2,P=M.getUTCFullYear()-1980,P=P<<4,P=P|M.getUTCMonth()+1,P=P<<5,P=P|M.getUTCDate(),F)A=m(1,1)+m(eJ(G),4)+U,L+="up"+m(A.length,2)+A;if(N)B=m(1,1)+m(eJ(j),4)+H,L+="uc"+m(B.length,2)+B;var R="";R+=`
78
+ \x00`,R+=m(D,2),R+=K.magic,R+=m(T,2),R+=m(P,2),R+=m(C.crc32,4),R+=m(C.compressedSize,4),R+=m(C.uncompressedSize,4),R+=m(G.length,2),R+=m(L.length,2);var $0=A2.LOCAL_FILE_HEADER+R+G+L,I0=A2.CENTRAL_FILE_HEADER+m(v,2)+R+m(j.length,2)+"\x00\x00\x00\x00"+m(x,4)+m(q,4)+G+L+j;return{fileRecord:$0,dirRecord:I0}},nj=function(Q,$,J,q,Y){var V="",X=N6.transformTo("string",Y(q));return V=A2.CENTRAL_DIRECTORY_END+"\x00\x00\x00\x00"+m(Q,2)+m(Q,2)+m($,4)+m(J,4)+m(X.length,2)+X,V},rj=function(Q){var $="";return $=A2.DATA_DESCRIPTOR+m(Q.crc32,4)+m(Q.compressedSize,4)+m(Q.uncompressedSize,4),$};function h0(Q,$,J,q){B6.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=$,this.zipPlatform=J,this.encodeFileName=q,this.streamFiles=Q,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}N6.inherits(h0,B6);h0.prototype.push=function(Q){var $=Q.meta.percent||0,J=this.entriesCount,q=this._sources.length;if(this.accumulate)this.contentBuffer.push(Q);else this.bytesWritten+=Q.data.length,B6.prototype.push.call(this,{data:Q.data,meta:{currentFile:this.currentFile,percent:J?($+100*(J-q-1))/J:100}})};h0.prototype.openedSource=function(Q){this.currentSourceOffset=this.bytesWritten,this.currentFile=Q.file.name;var $=this.streamFiles&&!Q.file.dir;if($){var J=Qq(Q,$,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:J.fileRecord,meta:{percent:0}})}else this.accumulate=!0};h0.prototype.closedSource=function(Q){this.accumulate=!1;var $=this.streamFiles&&!Q.file.dir,J=Qq(Q,$,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(J.dirRecord),$)this.push({data:rj(Q),meta:{percent:100}});else{this.push({data:J.fileRecord,meta:{percent:0}});while(this.contentBuffer.length)this.push(this.contentBuffer.shift())}this.currentFile=null};h0.prototype.flush=function(){var Q=this.bytesWritten;for(var $=0;$<this.dirRecords.length;$++)this.push({data:this.dirRecords[$],meta:{percent:100}});var J=this.bytesWritten-Q,q=nj(this.dirRecords.length,J,Q,this.zipComment,this.encodeFileName);this.push({data:q,meta:{percent:100}})};h0.prototype.prepareNextSource=function(){if(this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused)this.previous.pause();else this.previous.resume()};h0.prototype.registerPrevious=function(Q){this._sources.push(Q);var $=this;return Q.on("data",function(J){$.processChunk(J)}),Q.on("end",function(){if($.closedSource($.previous.streamInfo),$._sources.length)$.prepareNextSource();else $.end()}),Q.on("error",function(J){$.error(J)}),this};h0.prototype.resume=function(){if(!B6.prototype.resume.call(this))return!1;if(!this.previous&&this._sources.length)return this.prepareNextSource(),!0;if(!this.previous&&!this._sources.length&&!this.generatedError)return this.end(),!0};h0.prototype.error=function(Q){var $=this._sources;if(!B6.prototype.error.call(this,Q))return!1;for(var J=0;J<$.length;J++)try{$[J].error(Q)}catch(q){}return!0};h0.prototype.lock=function(){B6.prototype.lock.call(this);var Q=this._sources;for(var $=0;$<Q.length;$++)Q[$].lock()};$q.exports=h0});var qq=w((ej)=>{var aj=n9(),sj=Jq(),tj=function(Q,$){var J=Q||$,q=aj[J];if(!q)throw Error(J+" is not a valid compression method !");return q};ej.generateWorker=function(Q,$,J){var q=new sj($.streamFiles,J,$.platform,$.encodeFileName),Y=0;try{Q.forEach(function(V,X){Y++;var K=tj(X.options.compression,$.compression),W=X.options.compressionOptions||$.compressionOptions||{},G=X.dir,U=X.date;X._compressWorker(K,W).withStreamInfo("file",{name:V,dir:G,date:U,comment:X.comment||"",unixPermissions:X.unixPermissions,dosPermissions:X.dosPermissions}).pipe(q)}),q.entriesCount=Y}catch(V){q.error(V)}return q}});var Vq=w((TO,Yq)=>{var $Z=d(),D2=N0();function Z8(Q,$){D2.call(this,"Nodejs stream input adapter for "+Q),this._upstreamEnded=!1,this._bindStream($)}$Z.inherits(Z8,D2);Z8.prototype._bindStream=function(Q){var $=this;this._stream=Q,Q.pause(),Q.on("data",function(J){$.push({data:J,meta:{percent:0}})}).on("error",function(J){if($.isPaused)this.generatedError=J;else $.error(J)}).on("end",function(){if($.isPaused)$._upstreamEnded=!0;else $.end()})};Z8.prototype.pause=function(){if(!D2.prototype.pause.call(this))return!1;return this._stream.pause(),!0};Z8.prototype.resume=function(){if(!D2.prototype.resume.call(this))return!1;if(this._upstreamEnded)this.end();else this._stream.resume();return!0};Yq.exports=Z8});var Fq=w((CO,Hq)=>{var JZ=G6(),z8=d(),Wq=N0(),qZ=Q9(),Uq=$9(),Xq=K2(),YZ=K$(),VZ=qq(),Kq=l6(),XZ=Vq(),jq=function(Q,$,J){var q=z8.getTypeOf($),Y,V=z8.extend(J||{},Uq);if(V.date=V.date||new Date,V.compression!==null)V.compression=V.compression.toUpperCase();if(typeof V.unixPermissions==="string")V.unixPermissions=parseInt(V.unixPermissions,8);if(V.unixPermissions&&V.unixPermissions&16384)V.dir=!0;if(V.dosPermissions&&V.dosPermissions&16)V.dir=!0;if(V.dir)Q=Zq(Q);if(V.createFolders&&(Y=KZ(Q)))zq.call(this,Y,!0);var X=q==="string"&&V.binary===!1&&V.base64===!1;if(!J||typeof J.binary>"u")V.binary=!X;var K=$ instanceof Xq&&$.uncompressedSize===0;if(K||V.dir||!$||$.length===0)V.base64=!1,V.binary=!0,$="",V.compression="STORE",q="string";var W=null;if($ instanceof Xq||$ instanceof Wq)W=$;else if(Kq.isNode&&Kq.isStream($))W=new XZ(Q,$);else W=z8.prepareContent(Q,$,V.binary,V.optimizedBinaryString,V.base64);var G=new YZ(Q,W,V);this.files[Q]=G},KZ=function(Q){if(Q.slice(-1)==="/")Q=Q.substring(0,Q.length-1);var $=Q.lastIndexOf("/");return $>0?Q.substring(0,$):""},Zq=function(Q){if(Q.slice(-1)!=="/")Q+="/";return Q},zq=function(Q,$){if($=typeof $<"u"?$:Uq.createFolders,Q=Zq(Q),!this.files[Q])jq.call(this,Q,null,{dir:!0,createFolders:$});return this.files[Q]};function Gq(Q){return Object.prototype.toString.call(Q)==="[object RegExp]"}var GZ={load:function(){throw Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(Q){var $,J,q;for($ in this.files)if(q=this.files[$],J=$.slice(this.root.length,$.length),J&&$.slice(0,this.root.length)===this.root)Q(J,q)},filter:function(Q){var $=[];return this.forEach(function(J,q){if(Q(J,q))$.push(q)}),$},file:function(Q,$,J){if(arguments.length===1)if(Gq(Q)){var q=Q;return this.filter(function(V,X){return!X.dir&&q.test(V)})}else{var Y=this.files[this.root+Q];if(Y&&!Y.dir)return Y;else return null}else Q=this.root+Q,jq.call(this,Q,$,J);return this},folder:function(Q){if(!Q)return this;if(Gq(Q))return this.filter(function(Y,V){return V.dir&&Q.test(Y)});var $=this.root+Q,J=zq.call(this,$),q=this.clone();return q.root=J.name,q},remove:function(Q){Q=this.root+Q;var $=this.files[Q];if(!$){if(Q.slice(-1)!=="/")Q+="/";$=this.files[Q]}if($&&!$.dir)delete this.files[Q];else{var J=this.filter(function(Y,V){return V.name.slice(0,Q.length)===Q});for(var q=0;q<J.length;q++)delete this.files[J[q].name]}return this},generate:function(){throw Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(Q){var $,J={};try{if(J=z8.extend(Q||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:JZ.utf8encode}),J.type=J.type.toLowerCase(),J.compression=J.compression.toUpperCase(),J.type==="binarystring")J.type="string";if(!J.type)throw Error("No output type specified.");if(z8.checkSupport(J.type),J.platform==="darwin"||J.platform==="freebsd"||J.platform==="linux"||J.platform==="sunos")J.platform="UNIX";if(J.platform==="win32")J.platform="DOS";var q=J.comment||this.comment||"";$=VZ.generateWorker(this,J,q)}catch(Y){$=new Wq("error"),$.error(Y)}return new qZ($,J.type||"string",J.mimeType)},generateAsync:function(Q,$){return this.generateInternalStream(Q).accumulate($)},generateNodeStream:function(Q,$){if(Q=Q||{},!Q.type)Q.type="nodebuffer";return this.generateInternalStream(Q).toNodejsStream($)}};Hq.exports=GZ});var s9=w((AO,Oq)=>{var WZ=d();function Lq(Q){this.data=Q,this.length=Q.length,this.index=0,this.zero=0}Lq.prototype={checkOffset:function(Q){this.checkIndex(this.index+Q)},checkIndex:function(Q){if(this.length<this.zero+Q||Q<0)throw Error("End of data reached (data length = "+this.length+", asked index = "+Q+"). Corrupted zip ?")},setIndex:function(Q){this.checkIndex(Q),this.index=Q},skip:function(Q){this.setIndex(this.index+Q)},byteAt:function(){},readInt:function(Q){var $=0,J;this.checkOffset(Q);for(J=this.index+Q-1;J>=this.index;J--)$=($<<8)+this.byteAt(J);return this.index+=Q,$},readString:function(Q){return WZ.transformTo("string",this.readData(Q))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var Q=this.readInt(4);return new Date(Date.UTC((Q>>25&127)+1980,(Q>>21&15)-1,Q>>16&31,Q>>11&31,Q>>5&63,(Q&31)<<1))}};Oq.exports=Lq});var t9=w((DO,Bq)=>{var Nq=s9(),UZ=d();function M6(Q){Nq.call(this,Q);for(var $=0;$<this.data.length;$++)Q[$]=Q[$]&255}UZ.inherits(M6,Nq);M6.prototype.byteAt=function(Q){return this.data[this.zero+Q]};M6.prototype.lastIndexOfSignature=function(Q){var $=Q.charCodeAt(0),J=Q.charCodeAt(1),q=Q.charCodeAt(2),Y=Q.charCodeAt(3);for(var V=this.length-4;V>=0;--V)if(this.data[V]===$&&this.data[V+1]===J&&this.data[V+2]===q&&this.data[V+3]===Y)return V-this.zero;return-1};M6.prototype.readAndCheckSignature=function(Q){var $=Q.charCodeAt(0),J=Q.charCodeAt(1),q=Q.charCodeAt(2),Y=Q.charCodeAt(3),V=this.readData(4);return $===V[0]&&J===V[1]&&q===V[2]&&Y===V[3]};M6.prototype.readData=function(Q){if(this.checkOffset(Q),Q===0)return[];var $=this.data.slice(this.zero+this.index,this.zero+this.index+Q);return this.index+=Q,$};Bq.exports=M6});var Iq=w((wO,Pq)=>{var Mq=s9(),jZ=d();function P6(Q){Mq.call(this,Q)}jZ.inherits(P6,Mq);P6.prototype.byteAt=function(Q){return this.data.charCodeAt(this.zero+Q)};P6.prototype.lastIndexOfSignature=function(Q){return this.data.lastIndexOf(Q)-this.zero};P6.prototype.readAndCheckSignature=function(Q){var $=this.readData(4);return Q===$};P6.prototype.readData=function(Q){this.checkOffset(Q);var $=this.data.slice(this.zero+this.index,this.zero+this.index+Q);return this.index+=Q,$};Pq.exports=P6});var QQ=w((RO,Cq)=>{var Tq=t9(),ZZ=d();function e9(Q){Tq.call(this,Q)}ZZ.inherits(e9,Tq);e9.prototype.readData=function(Q){if(this.checkOffset(Q),Q===0)return new Uint8Array(0);var $=this.data.subarray(this.zero+this.index,this.zero+this.index+Q);return this.index+=Q,$};Cq.exports=e9});var wq=w((xO,Dq)=>{var Aq=QQ(),zZ=d();function $Q(Q){Aq.call(this,Q)}zZ.inherits($Q,Aq);$Q.prototype.readData=function(Q){this.checkOffset(Q);var $=this.data.slice(this.zero+this.index,this.zero+this.index+Q);return this.index+=Q,$};Dq.exports=$Q});var JQ=w((vO,xq)=>{var w2=d(),Rq=G1(),HZ=t9(),FZ=Iq(),LZ=wq(),OZ=QQ();xq.exports=function(Q){var $=w2.getTypeOf(Q);if(w2.checkSupport($),$==="string"&&!Rq.uint8array)return new FZ(Q);if($==="nodebuffer")return new LZ(Q);if(Rq.uint8array)return new OZ(w2.transformTo("uint8array",Q));return new HZ(w2.transformTo("array",Q))}});var kq=w((EO,Sq)=>{var qQ=JQ(),w1=d(),NZ=K2(),vq=X2(),R2=G6(),x2=n9(),BZ=G1(),MZ=0,PZ=3,IZ=function(Q){for(var $ in x2){if(!Object.prototype.hasOwnProperty.call(x2,$))continue;if(x2[$].magic===Q)return x2[$]}return null};function Eq(Q,$){this.options=Q,this.loadOptions=$}Eq.prototype={isEncrypted:function(){return(this.bitFlag&1)===1},useUTF8:function(){return(this.bitFlag&2048)===2048},readLocalPart:function(Q){var $,J;if(Q.skip(22),this.fileNameLength=Q.readInt(2),J=Q.readInt(2),this.fileName=Q.readData(this.fileNameLength),Q.skip(J),this.compressedSize===-1||this.uncompressedSize===-1)throw Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if($=IZ(this.compressionMethod),$===null)throw Error("Corrupted zip : compression "+w1.pretty(this.compressionMethod)+" unknown (inner file : "+w1.transformTo("string",this.fileName)+")");this.decompressed=new NZ(this.compressedSize,this.uncompressedSize,this.crc32,$,Q.readData(this.compressedSize))},readCentralPart:function(Q){this.versionMadeBy=Q.readInt(2),Q.skip(2),this.bitFlag=Q.readInt(2),this.compressionMethod=Q.readString(2),this.date=Q.readDate(),this.crc32=Q.readInt(4),this.compressedSize=Q.readInt(4),this.uncompressedSize=Q.readInt(4);var $=Q.readInt(2);if(this.extraFieldsLength=Q.readInt(2),this.fileCommentLength=Q.readInt(2),this.diskNumberStart=Q.readInt(2),this.internalFileAttributes=Q.readInt(2),this.externalFileAttributes=Q.readInt(4),this.localHeaderOffset=Q.readInt(4),this.isEncrypted())throw Error("Encrypted zip are not supported");Q.skip($),this.readExtraFields(Q),this.parseZIP64ExtraField(Q),this.fileComment=Q.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var Q=this.versionMadeBy>>8;if(this.dir=this.externalFileAttributes&16?!0:!1,Q===MZ)this.dosPermissions=this.externalFileAttributes&63;if(Q===PZ)this.unixPermissions=this.externalFileAttributes>>16&65535;if(!this.dir&&this.fileNameStr.slice(-1)==="/")this.dir=!0},parseZIP64ExtraField:function(){if(!this.extraFields[1])return;var Q=qQ(this.extraFields[1].value);if(this.uncompressedSize===w1.MAX_VALUE_32BITS)this.uncompressedSize=Q.readInt(8);if(this.compressedSize===w1.MAX_VALUE_32BITS)this.compressedSize=Q.readInt(8);if(this.localHeaderOffset===w1.MAX_VALUE_32BITS)this.localHeaderOffset=Q.readInt(8);if(this.diskNumberStart===w1.MAX_VALUE_32BITS)this.diskNumberStart=Q.readInt(4)},readExtraFields:function(Q){var $=Q.index+this.extraFieldsLength,J,q,Y;if(!this.extraFields)this.extraFields={};while(Q.index+4<$)J=Q.readInt(2),q=Q.readInt(2),Y=Q.readData(q),this.extraFields[J]={id:J,length:q,value:Y};Q.setIndex($)},handleUTF8:function(){var Q=BZ.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=R2.utf8decode(this.fileName),this.fileCommentStr=R2.utf8decode(this.fileComment);else{var $=this.findExtraFieldUnicodePath();if($!==null)this.fileNameStr=$;else{var J=w1.transformTo(Q,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(J)}var q=this.findExtraFieldUnicodeComment();if(q!==null)this.fileCommentStr=q;else{var Y=w1.transformTo(Q,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(Y)}}},findExtraFieldUnicodePath:function(){var Q=this.extraFields[28789];if(Q){var $=qQ(Q.value);if($.readInt(1)!==1)return null;if(vq(this.fileName)!==$.readInt(4))return null;return R2.utf8decode($.readData(Q.length-5))}return null},findExtraFieldUnicodeComment:function(){var Q=this.extraFields[25461];if(Q){var $=qQ(Q.value);if($.readInt(1)!==1)return null;if(vq(this.fileComment)!==$.readInt(4))return null;return R2.utf8decode($.readData(Q.length-5))}return null}};Sq.exports=Eq});var _q=w((SO,gq)=>{var TZ=JQ(),Z1=d(),f0=r9(),CZ=kq(),AZ=G1();function yq(Q){this.files=[],this.loadOptions=Q}yq.prototype={checkSignature:function(Q){if(!this.reader.readAndCheckSignature(Q)){this.reader.index-=4;var $=this.reader.readString(4);throw Error("Corrupted zip or bug: unexpected signature ("+Z1.pretty($)+", expected "+Z1.pretty(Q)+")")}},isSignature:function(Q,$){var J=this.reader.index;this.reader.setIndex(Q);var q=this.reader.readString(4),Y=q===$;return this.reader.setIndex(J),Y},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 Q=this.reader.readData(this.zipCommentLength),$=AZ.uint8array?"uint8array":"array",J=Z1.transformTo($,Q);this.zipComment=this.loadOptions.decodeFileName(J)},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={};var Q=this.zip64EndOfCentralSize-44,$=0,J,q,Y;while($<Q)J=this.reader.readInt(2),q=this.reader.readInt(4),Y=this.reader.readData(q),this.zip64ExtensibleData[J]={id:J,length:q,value:Y}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),this.disksCount>1)throw Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var Q,$;for(Q=0;Q<this.files.length;Q++)$=this.files[Q],this.reader.setIndex($.localHeaderOffset),this.checkSignature(f0.LOCAL_FILE_HEADER),$.readLocalPart(this.reader),$.handleUTF8(),$.processAttributes()},readCentralDir:function(){var Q;this.reader.setIndex(this.centralDirOffset);while(this.reader.readAndCheckSignature(f0.CENTRAL_FILE_HEADER))Q=new CZ({zip64:this.zip64},this.loadOptions),Q.readCentralPart(this.reader),this.files.push(Q);if(this.centralDirRecords!==this.files.length){if(this.centralDirRecords!==0&&this.files.length===0)throw Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)}},readEndOfCentral:function(){var Q=this.reader.lastIndexOfSignature(f0.CENTRAL_DIRECTORY_END);if(Q<0){var $=!this.isSignature(0,f0.LOCAL_FILE_HEADER);if($)throw 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");else throw Error("Corrupted zip: can't find end of central directory")}this.reader.setIndex(Q);var J=Q;if(this.checkSignature(f0.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===Z1.MAX_VALUE_16BITS||this.diskWithCentralDirStart===Z1.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===Z1.MAX_VALUE_16BITS||this.centralDirRecords===Z1.MAX_VALUE_16BITS||this.centralDirSize===Z1.MAX_VALUE_32BITS||this.centralDirOffset===Z1.MAX_VALUE_32BITS){if(this.zip64=!0,Q=this.reader.lastIndexOfSignature(f0.ZIP64_CENTRAL_DIRECTORY_LOCATOR),Q<0)throw Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(Q),this.checkSignature(f0.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,f0.ZIP64_CENTRAL_DIRECTORY_END)){if(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(f0.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0)throw Error("Corrupted zip: can't find the ZIP64 end of central directory")}this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(f0.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var q=this.centralDirOffset+this.centralDirSize;if(this.zip64)q+=20,q+=12+this.zip64EndOfCentralSize;var Y=J-q;if(Y>0)if(this.isSignature(J,f0.CENTRAL_FILE_HEADER));else this.reader.zero=Y;else if(Y<0)throw Error("Corrupted zip: missing "+Math.abs(Y)+" bytes.")},prepareReader:function(Q){this.reader=TZ(Q)},load:function(Q){this.prepareReader(Q),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}};gq.exports=yq});var fq=w((kO,hq)=>{var YQ=d(),v2=V6(),DZ=G6(),wZ=_q(),RZ=Y9(),bq=l6();function xZ(Q){return new v2.Promise(function($,J){var q=Q.decompressed.getContentWorker().pipe(new RZ);q.on("error",function(Y){J(Y)}).on("end",function(){if(q.streamInfo.crc32!==Q.decompressed.crc32)J(Error("Corrupted zip : CRC32 mismatch"));else $()}).resume()})}hq.exports=function(Q,$){var J=this;if($=YQ.extend($||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:DZ.utf8decode}),bq.isNode&&bq.isStream(Q))return v2.Promise.reject(Error("JSZip can't accept a stream when loading a zip file."));return YQ.prepareContent("the loaded zip file",Q,!0,$.optimizedBinaryString,$.base64).then(function(q){var Y=new wZ($);return Y.load(q),Y}).then(function(Y){var V=[v2.Promise.resolve(Y)],X=Y.files;if($.checkCRC32)for(var K=0;K<X.length;K++)V.push(xZ(X[K]));return v2.Promise.all(V)}).then(function(Y){var V=Y.shift(),X=V.files;for(var K=0;K<X.length;K++){var W=X[K],G=W.fileNameStr,U=YQ.resolve(W.fileNameStr);if(J.file(U,W.decompressed,{binary:!0,optimizedBinaryString:!0,date:W.date,dir:W.dir,comment:W.fileCommentStr.length?W.fileCommentStr:null,unixPermissions:W.unixPermissions,dosPermissions:W.dosPermissions,createFolders:$.createFolders}),!W.dir)J.file(U).unsafeOriginalName=G}if(V.zipComment.length)J.comment=V.zipComment;return J})}});var cq=w((yO,mq)=>{function v0(){if(!(this instanceof v0))return new v0;if(arguments.length)throw 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 Q=new v0;for(var $ in this)if(typeof this[$]!=="function")Q[$]=this[$];return Q}}v0.prototype=Fq();v0.prototype.loadAsync=fq();v0.support=G1();v0.defaults=$9();v0.version="3.10.1";v0.loadAsync=function(Q,$){return new v0().loadAsync(Q,$)};v0.external=V6();mq.exports=v0});var R1=w((gO,VQ)=>{var S2=process||{},uq=S2.argv||[],E2=S2.env||{},vZ=!(!!E2.NO_COLOR||uq.includes("--no-color"))&&(!!E2.FORCE_COLOR||uq.includes("--color")||S2.platform==="win32"||(S2.stdout||{}).isTTY&&E2.TERM!=="dumb"||!!E2.CI),EZ=(Q,$,J=Q)=>(q)=>{let Y=""+q,V=Y.indexOf($,Q.length);return~V?Q+SZ(Y,$,J,V)+$:Q+Y+$},SZ=(Q,$,J,q)=>{let Y="",V=0;do Y+=Q.substring(V,q)+J,V=q+$.length,q=Q.indexOf($,V);while(~q);return Y+Q.substring(V)},pq=(Q=vZ)=>{let $=Q?EZ:()=>String;return{isColorSupported:Q,reset:$("\x1B[0m","\x1B[0m"),bold:$("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:$("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:$("\x1B[3m","\x1B[23m"),underline:$("\x1B[4m","\x1B[24m"),inverse:$("\x1B[7m","\x1B[27m"),hidden:$("\x1B[8m","\x1B[28m"),strikethrough:$("\x1B[9m","\x1B[29m"),black:$("\x1B[30m","\x1B[39m"),red:$("\x1B[31m","\x1B[39m"),green:$("\x1B[32m","\x1B[39m"),yellow:$("\x1B[33m","\x1B[39m"),blue:$("\x1B[34m","\x1B[39m"),magenta:$("\x1B[35m","\x1B[39m"),cyan:$("\x1B[36m","\x1B[39m"),white:$("\x1B[37m","\x1B[39m"),gray:$("\x1B[90m","\x1B[39m"),bgBlack:$("\x1B[40m","\x1B[49m"),bgRed:$("\x1B[41m","\x1B[49m"),bgGreen:$("\x1B[42m","\x1B[49m"),bgYellow:$("\x1B[43m","\x1B[49m"),bgBlue:$("\x1B[44m","\x1B[49m"),bgMagenta:$("\x1B[45m","\x1B[49m"),bgCyan:$("\x1B[46m","\x1B[49m"),bgWhite:$("\x1B[47m","\x1B[49m"),blackBright:$("\x1B[90m","\x1B[39m"),redBright:$("\x1B[91m","\x1B[39m"),greenBright:$("\x1B[92m","\x1B[39m"),yellowBright:$("\x1B[93m","\x1B[39m"),blueBright:$("\x1B[94m","\x1B[39m"),magentaBright:$("\x1B[95m","\x1B[39m"),cyanBright:$("\x1B[96m","\x1B[39m"),whiteBright:$("\x1B[97m","\x1B[39m"),bgBlackBright:$("\x1B[100m","\x1B[49m"),bgRedBright:$("\x1B[101m","\x1B[49m"),bgGreenBright:$("\x1B[102m","\x1B[49m"),bgYellowBright:$("\x1B[103m","\x1B[49m"),bgBlueBright:$("\x1B[104m","\x1B[49m"),bgMagentaBright:$("\x1B[105m","\x1B[49m"),bgCyanBright:$("\x1B[106m","\x1B[49m"),bgWhiteBright:$("\x1B[107m","\x1B[49m")}};VQ.exports=pq();VQ.exports.createColors=pq});import{homedir as aZ}from"node:os";import u from"node:path";function sZ(Q=process.env,$=e){if(Q.OPENCODE_CONFIG_DIR)return Q.OPENCODE_CONFIG_DIR;if(Q.XDG_CONFIG_HOME)return u.join(Q.XDG_CONFIG_HOME,"opencode");return u.join($,".config","opencode")}function v1(){let Q=process.env.LOCALAPPDATA??u.join(e,"AppData","Local"),$=u.join(Q,"Programs","antigravity","User","mcp_config.json"),J=u.join(e,".gemini","antigravity","mcp_config.json"),q=u.join(e,".antigravity","mcp_config.json");if(process.platform==="win32")return[$,J,q];return[J,q,$]}async function GY(){let{stat:Q}=await import("node:fs/promises"),[$,...J]=v1();for(let q of[$,...J])try{return await Q(q),q}catch{}return $}function WY(){let[Q]=v1();return Q}function tZ(){return u.dirname(WY())}function E1(){return u.join(e,".gemini","antigravity","skills","petdex")}function M0(Q,$,J,q){return`[ -f "$HOME/.petdex/runtime/hooks-disabled" ] && exit 0; ${['if [ -x "$HOME/.petdex/bin/petdex.js" ] || [ -f "$HOME/.petdex/bin/petdex.js" ]; then',` node "$HOME/.petdex/bin/petdex.js" bubble ${$} ${Q} >/dev/null 2>&1 || true;`,"else",` ${eZ(Q,J,q)};`,"fi"].join(" ")}`}function eZ(Q,$,J){let q=J!=null?`{"state":"${$}","duration":${J},"agent_source":"${Q}"}`:`{"state":"${$}","agent_source":"${Q}"}`;return['T="$(cat "$HOME/.petdex/runtime/update-token" 2>/dev/null)"',`[ -n "$T" ] && curl -s -m 0.3 -X POST ${n1}`,'-H "Content-Type: application/json"','-H "X-Petdex-Update-Token: $T"',`--data-raw '${q}'`,">/dev/null 2>&1 || true"].join(" ")}function Qz(){let Q=n1.replace(/\/state$/,"/bubble");return String.raw`// petdex hook plugin. Auto-generated by 'petdex hooks install'.
62
79
  // Forwards OpenCode lifecycle events to the petdex desktop mascot via HTTP.
63
80
  // Edit STATE_MAP below to customize which state each event triggers.
64
81
 
@@ -67,8 +84,8 @@ import { readFile } from "node:fs/promises";
67
84
  import { homedir } from "node:os";
68
85
  import { join } from "node:path";
69
86
 
70
- const SIDECAR_URL = ${JSON.stringify(v0)};
71
- const SIDECAR_BUBBLE_URL = ${JSON.stringify($)};
87
+ const SIDECAR_URL = ${JSON.stringify(n1)};
88
+ const SIDECAR_BUBBLE_URL = ${JSON.stringify(Q)};
72
89
  const RUNTIME_DIR = join(homedir(), ".petdex", "runtime");
73
90
  const TOKEN_PATH = join(RUNTIME_DIR, "update-token");
74
91
  const KILLSWITCH_PATH = join(RUNTIME_DIR, "hooks-disabled");
@@ -222,18 +239,104 @@ const PetdexPlugin = {
222
239
 
223
240
  export default PetdexPlugin;
224
241
  export { PetdexPlugin };
225
- `}function H0($){if($.startsWith(G1))return`~${$.slice(G1.length)}`;return $}function OZ($){let Q=$.split(`
226
- `),q=/^\s*\[([^[\]]+)\]\s*(?:#.*)?$/,V=/^\s*codex_hooks\s*=\s*(.+?)\s*(?:#.*)?$/,Y=null,X=null;for(let J=0;J<Q.length;J+=1){let G=Q[J],U=G.match(q);if(U){if(Y=U[1].trim(),Y==="features"&&X===null)X=J;continue}if(Y!=="features")continue;let K=G.match(V);if(!K)continue;if(K[1].trim()==="true")return{state:"enabled"};return{state:"wrong-value",replaceLine:J}}if(X===null)return{state:"no-features-section"};return{state:"no-key",insertAfterLine:X}}function MZ($,Q){if(Q.state==="enabled"||Q.state==="missing-file")return $;let q=$.split(`
227
- `);if(Q.state==="wrong-value"){let Y=q[Q.replaceLine],X=/^(\s*codex_hooks\s*=\s*)([^#\n]+?)(\s*(?:#.*)?)$/,J=Y.match(X);return q[Q.replaceLine]=J?`${J[1]}true${J[3]}`:"codex_hooks = true",q.join(`
228
- `)}if(Q.state==="no-key")return q.splice(Q.insertAfterLine+1,0,"codex_hooks = true"),q.join(`
229
- `);let V=$.endsWith(`
230
- `)||$.length===0?"":`
231
- `;return`${$}${V}
242
+ `}function x1(Q){if(Q.startsWith(e))return`~${Q.slice(e.length)}`;return Q}function $z(Q){let $=Q.split(`
243
+ `),J=/^\s*\[([^[\]]+)\]\s*(?:#.*)?$/,q=/^\s*codex_hooks\s*=\s*(.+?)\s*(?:#.*)?$/,Y=null,V=null;for(let X=0;X<$.length;X+=1){let K=$[X],W=K.match(J);if(W){if(Y=W[1].trim(),Y==="features"&&V===null)V=X;continue}if(Y!=="features")continue;let G=K.match(q);if(!G)continue;if(G[1].trim()==="true")return{state:"enabled"};return{state:"wrong-value",replaceLine:X}}if(V===null)return{state:"no-features-section"};return{state:"no-key",insertAfterLine:V}}function Jz(Q,$){if($.state==="enabled"||$.state==="missing-file")return Q;let J=Q.split(`
244
+ `);if($.state==="wrong-value"){let Y=J[$.replaceLine],V=/^(\s*codex_hooks\s*=\s*)([^#\n]+?)(\s*(?:#.*)?)$/,X=Y.match(V);return J[$.replaceLine]=X?`${X[1]}true${X[3]}`:"codex_hooks = true",J.join(`
245
+ `)}if($.state==="no-key")return J.splice($.insertAfterLine+1,0,"codex_hooks = true"),J.join(`
246
+ `);let q=Q.endsWith(`
247
+ `)||Q.length===0?"":`
248
+ `;return`${Q}${q}
232
249
  [features]
233
250
  codex_hooks = true
234
- `}var e$=7777,v0,G1,P8,e1;var $6=$0(()=>{v0=`http://127.0.0.1:${e$}/state`,G1=zZ(),P8=HZ();e1=[{id:"claude-code",displayName:"Claude Code",configDir:a.join(G1,".claude"),configFile:a.join(G1,".claude","settings.json"),slashCommandPath:a.join(G1,".claude","commands","petdex.md"),docsUrl:"https://docs.anthropic.com/en/docs/claude-code/hooks",hookEntries:[{event:"UserPromptSubmit",kind:"user.prompt"},{event:"PreToolUse",kind:"tool.before"},{event:"PostToolUse",kind:"tool.after"},{event:"Notification",kind:"session.waiting"},{event:"Stop",kind:"session.end"}],build(){return{hooks:{UserPromptSubmit:[{hooks:[{type:"command",command:z1("claude-code","user-prompt","jumping",800)}]}],PreToolUse:[{hooks:[{type:"command",command:z1("claude-code","pre","running")}]}],PostToolUse:[{hooks:[{type:"command",command:z1("claude-code","post","idle")}]}],Notification:[{hooks:[{type:"command",command:z1("claude-code","notification","waiting")}]}],Stop:[{hooks:[{type:"command",command:z1("claude-code","stop","waving",1500)}]}]}}}},{id:"codex",displayName:"Codex CLI",configDir:a.join(G1,".codex"),configFile:a.join(G1,".codex","hooks.json"),slashCommandPath:a.join(G1,".codex","prompts","petdex.md"),docsUrl:"https://developers.openai.com/codex/hooks",hookEntries:[{event:"UserPromptSubmit",kind:"user.prompt"},{event:"PreToolUse",kind:"tool.before"},{event:"PostToolUse",kind:"tool.after"},{event:"PermissionRequest",kind:"session.waiting"},{event:"Stop",kind:"session.end"}],async postInstallChecks(){let{readFile:$}=await import("node:fs/promises"),Q=a.join(G1,".codex","config.toml"),q=!0,V="";try{V=await $(Q,"utf8")}catch(J){let G=J.code;if(G==="ENOENT")q=!1;else return[{level:"warn",message:`Could not read ${Q} (${G??"io_error"}). Make sure [features] codex_hooks = true is set there before Codex picks up the hooks.`}]}let Y=q?OZ(V):{state:"missing-file"};if(Y.state==="enabled")return[];let X={prompt:Y.state==="missing-file"?`Create ${H0(Q)} with [features] codex_hooks = true?`:Y.state==="wrong-value"?`Set codex_hooks = true under [features] in ${H0(Q)}? (a .bak of the current file is created first)`:`Add codex_hooks = true under [features] in ${H0(Q)}? (a .bak of the current file is created first)`,apply:async()=>{let{writeFile:J,mkdir:G}=await import("node:fs/promises");if(await G(a.dirname(Q),{recursive:!0}),!q)try{return await J(Q,`[features]
251
+ `}var H8=7777,n1,e,g2,z1;var F8=z0(()=>{n1=`http://127.0.0.1:${H8}/state`,e=aZ(),g2=sZ();z1=[{id:"claude-code",displayName:"Claude Code",configDir:u.join(e,".claude"),configFile:u.join(e,".claude","settings.json"),slashCommandPath:u.join(e,".claude","commands","petdex.md"),docsUrl:"https://docs.anthropic.com/en/docs/claude-code/hooks",hookEntries:[{event:"UserPromptSubmit",kind:"user.prompt"},{event:"PreToolUse",kind:"tool.before"},{event:"PostToolUse",kind:"tool.after"},{event:"Notification",kind:"session.waiting"},{event:"Stop",kind:"session.end"}],build(){return{hooks:{UserPromptSubmit:[{hooks:[{type:"command",command:M0("claude-code","user-prompt","jumping",800)}]}],PreToolUse:[{hooks:[{type:"command",command:M0("claude-code","pre","running")}]}],PostToolUse:[{hooks:[{type:"command",command:M0("claude-code","post","idle")}]}],Notification:[{hooks:[{type:"command",command:M0("claude-code","notification","waiting")}]}],Stop:[{hooks:[{type:"command",command:M0("claude-code","stop","waving",1500)}]}]}}}},{id:"codex",displayName:"Codex CLI",configDir:u.join(e,".codex"),configFile:u.join(e,".codex","hooks.json"),slashCommandPath:u.join(e,".codex","prompts","petdex.md"),docsUrl:"https://developers.openai.com/codex/hooks",hookEntries:[{event:"UserPromptSubmit",kind:"user.prompt"},{event:"PreToolUse",kind:"tool.before"},{event:"PostToolUse",kind:"tool.after"},{event:"PermissionRequest",kind:"session.waiting"},{event:"Stop",kind:"session.end"}],async postInstallChecks(){let{readFile:Q}=await import("node:fs/promises"),$=u.join(e,".codex","config.toml"),J=!0,q="";try{q=await Q($,"utf8")}catch(X){let K=X.code;if(K==="ENOENT")J=!1;else return[{level:"warn",message:`Could not read ${$} (${K??"io_error"}). Make sure [features] codex_hooks = true is set there before Codex picks up the hooks.`}]}let Y=J?$z(q):{state:"missing-file"};if(Y.state==="enabled")return[];let V={prompt:Y.state==="missing-file"?`Create ${x1($)} with [features] codex_hooks = true?`:Y.state==="wrong-value"?`Set codex_hooks = true under [features] in ${x1($)}? (a .bak of the current file is created first)`:`Add codex_hooks = true under [features] in ${x1($)}? (a .bak of the current file is created first)`,apply:async()=>{let{writeFile:X,mkdir:K}=await import("node:fs/promises");if(await K(u.dirname($),{recursive:!0}),!J)try{return await X($,`[features]
235
252
  codex_hooks = true
236
- `,"utf8"),{ok:!0,message:`Created ${H0(Q)} with [features] codex_hooks = true`}}catch(Z){return{ok:!1,message:`Write failed: ${Z.message}`}}let U=new Date().toISOString().replace(/[:.]/g,"-"),K=`${Q}.${U}.bak`;try{await J(K,V)}catch(Z){return{ok:!1,message:`Backup failed: ${Z.message}`}}let W=MZ(V,Y);try{return await J(Q,W,"utf8"),{ok:!0,message:`codex_hooks = true set in ${H0(Q)} (backup: ${a.basename(K)})`}}catch(Z){return{ok:!1,message:`Write failed: ${Z.message}`}}}};return[{level:"action",message:`Codex needs codex_hooks = true under [features] in ${H0(Q)} before it loads ${H0(a.join(G1,".codex","hooks.json"))}.`,fix:X}]},build(){return{hooks:{UserPromptSubmit:[{hooks:[{type:"command",command:z1("codex","user-prompt","jumping",800)}]}],PreToolUse:[{hooks:[{type:"command",command:z1("codex","pre","running")}]}],PostToolUse:[{hooks:[{type:"command",command:z1("codex","post","idle")}]}],PermissionRequest:[{hooks:[{type:"command",command:z1("codex","notification","waiting")}]}],Stop:[{hooks:[{type:"command",command:z1("codex","stop","waving",1500)}]}]}}}},{id:"gemini",displayName:"Gemini CLI",configDir:a.join(G1,".gemini"),configFile:a.join(G1,".gemini","settings.json"),slashCommandPath:a.join(G1,".gemini","antigravity","global_workflows","petdex.md"),docsUrl:"https://google-gemini.github.io/gemini-cli/docs/hooks",hookEntries:[{event:"BeforeTool",kind:"tool.before"},{event:"AfterTool",kind:"tool.after"},{event:"SessionEnd",kind:"session.end"}],build(){return{hooks:{BeforeTool:[{hooks:[{type:"command",command:z1("gemini","pre","running")}]}],AfterTool:[{hooks:[{type:"command",command:z1("gemini","post","idle")}]}],SessionEnd:[{hooks:[{type:"command",command:z1("gemini","stop","waving",1500)}]}]}}}},{id:"opencode",displayName:"OpenCode",configDir:P8,configFile:a.join(P8,"plugins","petdex.js"),slashCommandPath:a.join(P8,"command","petdex.md"),docsUrl:"https://opencode.ai/docs/plugins",hookEntries:[{event:"tool.execute.before",kind:"tool.before"},{event:"tool.execute.after",kind:"tool.after"},{event:"session.idle",kind:"session.end"},{event:"session.error",kind:"session.error"}],build(){return PZ()},async postInstallChecks(){return[{level:"info",message:`OpenCode plugin installed at ${H0(a.join(P8,"plugins","petdex.js"))}. If hooks still do not load, start OpenCode with the same OPENCODE_CONFIG_DIR/XDG_CONFIG_HOME environment used during install.`}]}}]});import{mkdir as bZ,rm as fZ,writeFile as mZ}from"node:fs/promises";import cZ from"node:path";async function bJ($){await bZ(cZ.dirname($.slashCommandPath),{recursive:!0}),await mZ($.slashCommandPath,pZ,"utf8")}async function fJ($){try{await fZ($.slashCommandPath,{force:!0})}catch{}}var V6='node "$HOME/.petdex/bin/petdex.js"',pZ;var oQ=$0(()=>{pZ=`---
253
+ `,"utf8"),{ok:!0,message:`Created ${x1($)} with [features] codex_hooks = true`}}catch(z){return{ok:!1,message:`Write failed: ${z.message}`}}let W=new Date().toISOString().replace(/[:.]/g,"-"),G=`${$}.${W}.bak`;try{await X(G,q)}catch(z){return{ok:!1,message:`Backup failed: ${z.message}`}}let U=Jz(q,Y);try{return await X($,U,"utf8"),{ok:!0,message:`codex_hooks = true set in ${x1($)} (backup: ${u.basename(G)})`}}catch(z){return{ok:!1,message:`Write failed: ${z.message}`}}}};return[{level:"action",message:`Codex needs codex_hooks = true under [features] in ${x1($)} before it loads ${x1(u.join(e,".codex","hooks.json"))}.`,fix:V}]},build(){return{hooks:{UserPromptSubmit:[{hooks:[{type:"command",command:M0("codex","user-prompt","jumping",800)}]}],PreToolUse:[{hooks:[{type:"command",command:M0("codex","pre","running")}]}],PostToolUse:[{hooks:[{type:"command",command:M0("codex","post","idle")}]}],PermissionRequest:[{hooks:[{type:"command",command:M0("codex","notification","waiting")}]}],Stop:[{hooks:[{type:"command",command:M0("codex","stop","waving",1500)}]}]}}}},{id:"gemini",displayName:"Gemini CLI",configDir:u.join(e,".gemini"),configFile:u.join(e,".gemini","settings.json"),slashCommandPath:u.join(e,".gemini","commands","petdex.toml"),docsUrl:"https://google-gemini.github.io/gemini-cli/docs/hooks",hookEntries:[{event:"BeforeTool",kind:"tool.before"},{event:"AfterTool",kind:"tool.after"},{event:"SessionEnd",kind:"session.end"}],build(){return{hooks:{BeforeTool:[{hooks:[{type:"command",command:M0("gemini","pre","running")}]}],AfterTool:[{hooks:[{type:"command",command:M0("gemini","post","idle")}]}],SessionEnd:[{hooks:[{type:"command",command:M0("gemini","stop","waving",1500)}]}]}}}},{id:"opencode",displayName:"OpenCode",configDir:g2,configFile:u.join(g2,"plugins","petdex.js"),slashCommandPath:u.join(g2,"command","petdex.md"),docsUrl:"https://opencode.ai/docs/plugins",hookEntries:[{event:"tool.execute.before",kind:"tool.before"},{event:"tool.execute.after",kind:"tool.after"},{event:"session.idle",kind:"session.end"},{event:"session.error",kind:"session.error"}],build(){return Qz()},async postInstallChecks(){return[{level:"info",message:`OpenCode plugin installed at ${x1(u.join(g2,"plugins","petdex.js"))}. If hooks still do not load, start OpenCode with the same OPENCODE_CONFIG_DIR/XDG_CONFIG_HOME environment used during install.`}]}},{id:"antigravity",displayName:"Antigravity",configDir:tZ(),configFile:WY(),slashCommandPath:u.join(e,".gemini","antigravity","skills","petdex","SKILL.md"),docsUrl:"https://antigravity.google/docs/skills",hookEntries:[],build(){return{}},async postInstallChecks(){return[{level:"action",message:`Antigravity uses MCP instead of hooks. The petdex MCP server was injected into your Antigravity MCP config.
254
+
255
+ To activate:
256
+ 1. Open Antigravity → Agent Panel → ... → MCP Servers
257
+ 2. Verify "petdex" MCP server is listed and running
258
+ 3. The Petdex Agent Skill is installed at ~/.gemini/antigravity/skills/petdex/
259
+
260
+ The agent should start updating the mascot automatically when working in this project.`}]}}]});var uY={};E8(uY,{persistRunningBinary:()=>A8,PERSIST_PATH:()=>y0,PERSIST_DIR:()=>AQ});import{copyFile as QH,mkdir as $H}from"node:fs/promises";import{homedir as JH}from"node:os";import{join as cY}from"node:path";async function A8(){let Q=process.argv[1];if(!Q)return{ok:!1,path:y0,reason:"no argv[1]"};try{await $H(AQ,{recursive:!0}),await QH(Q,y0);let{chmod:$}=await import("node:fs/promises");try{await $(y0,493)}catch{}return{ok:!0,path:y0}}catch($){return{ok:!1,path:y0,reason:$.message}}}var AQ,y0;var D8=z0(()=>{AQ=cY(JH(),".petdex","bin"),y0=cY(AQ,"petdex.js")});function pY(){return`---
261
+ name: petdex
262
+ description: >
263
+ Coordinates with the petdex desktop mascot to reflect agent activity.
264
+ The pet is a transparent, always-on-top companion that animates based
265
+ on what the agent is doing. Call these MCP tools before/after every
266
+ tool use so the pet stays in sync.
267
+ ---
268
+
269
+ # Petdex Desktop Mascot
270
+
271
+ When this skill is active, call the petdex MCP tools at the points below.
272
+ **Important:** Do NOT call Petdex MCP tools around calls to Petdex MCP tools
273
+ themselves (petdex_set_state, petdex_show_bubble, petdex_status). Only
274
+ wrap non-Petdex tool calls — otherwise every state update would trigger
275
+ another update in a recursive loop.
276
+
277
+ ## Before every non-Petdex tool use
278
+
279
+ Call \`petdex_set_state\` with:
280
+ - state: "running"
281
+ - duration: (no duration — will be updated on tool completion)
282
+
283
+ Call \`petdex_show_bubble\` with a brief description of what you're about
284
+ to do. Examples:
285
+ - "Reading server.ts"
286
+ - "Searching for patterns"
287
+ - "Running git status"
288
+ - "Editing auth middleware"
289
+ - "Writing unit tests"
290
+
291
+ The bubble text should be short (under 40 chars) and in present tense
292
+ ("Reading", "Running", "Editing" — never past tense for pre-tool calls).
293
+
294
+ ## After every non-Petdex tool use
295
+
296
+ Call \`petdex_set_state\` with:
297
+ - state: "idle"
298
+
299
+ ## On session end / task completion
300
+
301
+ Call \`petdex_set_state\` with:
302
+ - state: "waving"
303
+ - duration: 1500
304
+
305
+ ## On error
306
+
307
+ If you encounter an error mid-task (from a non-Petdex tool), call
308
+ \`petdex_set_state\` with:
309
+ - state: "failed"
310
+ - duration: 2500
311
+
312
+ ## On waiting for user input
313
+
314
+ Call \`petdex_set_state\` with:
315
+ - state: "waiting"
316
+
317
+ ## Available MCP tools
318
+
319
+ All tools are exposed via the "petdex" MCP server (configured in
320
+ mcp_config.json):
321
+
322
+ - \`petdex_set_state\`: Set animation state (idle, running, waving,
323
+ jumping, failed, review, waiting)
324
+ - \`petdex_show_bubble\`: Show a speech bubble with text
325
+ - \`petdex_status\`: Check if the mascot is reachable
326
+
327
+ **Do not** wrap these tools with Petdex calls. Only non-Petdex tools
328
+ should trigger petdex_set_state / petdex_show_bubble.
329
+
330
+ ## Configuration
331
+
332
+ This skill requires the petdex MCP server to be running.
333
+ Configure it in Antigravity: Agent Panel → ... → MCP Servers.
334
+ The server command is installed with the same Node.js runtime that ran
335
+ \`petdex hooks install\`: \`${process.execPath}\`
336
+
337
+ Make sure petdex-desktop is running (\`petdex up\`) for the mascot to
338
+ appear.
339
+ `}function dY(){return{mcpServers:{petdex:{command:process.execPath,args:[y0,"mcp-server"]}}}}var lY=z0(()=>{D8()});import{mkdir as qH,rm as DQ,writeFile as YH}from"node:fs/promises";import{homedir as VH}from"node:os";import oY from"node:path";async function nY(Q){if(await qH(oY.dirname(Q.slashCommandPath),{recursive:!0}),await YH(Q.slashCommandPath,Q.id==="gemini"?KH:XH,"utf8"),Q.id==="gemini")await DQ(iY,{force:!0})}async function l2(Q){try{if(await DQ(Q.slashCommandPath,{force:!0}),Q.id==="gemini")await DQ(iY,{force:!0})}catch{}}var $1='node "$HOME/.petdex/bin/petdex.js"',XH,KH,iY;var wQ=z0(()=>{XH=`---
237
340
  description: Wake or sleep the petdex mascot. Toggles the floating pet on/off
238
341
  ---
239
342
 
@@ -241,74 +344,99 @@ The user wants to control the petdex mascot from inside the agent. The mascot is
241
344
 
242
345
  Run the matching command using the persisted petdex binary at \`$HOME/.petdex/bin/petdex.js\` (always present after \`petdex hooks install\`):
243
346
 
244
- - \`/petdex\` (no args) → run \`${V6} toggle\`
245
- - \`/petdex up\` → run \`${V6} up\`
246
- - \`/petdex down\` → run \`${V6} down\`
247
- - \`/petdex status\` → run \`${V6} hooks status\`
248
- - \`/petdex doctor\` → run \`${V6} doctor\`
347
+ - \`/petdex\` (no args) → run \`${$1} toggle\`
348
+ - \`/petdex up\` → run \`${$1} up\`
349
+ - \`/petdex down\` → run \`${$1} down\`
350
+ - \`/petdex status\` → run \`${$1} hooks status\`
351
+ - \`/petdex doctor\` → run \`${$1} doctor\`
249
352
 
250
353
  Show the command output verbatim to the user. Don't reinterpret, don't explain. The CLI's output is already user-facing.
251
354
 
252
355
  If \`$HOME/.petdex/bin/petdex.js\` doesn't exist, the user hasn't run \`petdex hooks install\` yet. Tell them to run \`npx petdex@latest init\` first, then retry.
253
356
 
254
357
  Arguments: \`$ARGUMENTS\`
255
- `});var cJ={};x8(cJ,{persistRunningBinary:()=>nQ,PERSIST_PATH:()=>W$,PERSIST_DIR:()=>iQ});import{copyFile as uZ,mkdir as dZ}from"node:fs/promises";import{homedir as lZ}from"node:os";import{join as mJ}from"node:path";async function nQ(){let $=process.argv[1];if(!$)return{ok:!1,path:W$,reason:"no argv[1]"};try{await dZ(iQ,{recursive:!0}),await uZ($,W$);let{chmod:Q}=await import("node:fs/promises");try{await Q(W$,493)}catch{}return{ok:!0,path:W$}}catch(Q){return{ok:!1,path:W$,reason:Q.message}}}var iQ,W$;var rQ=$0(()=>{iQ=mJ(lZ(),".petdex","bin"),W$=mJ(iQ,"petdex.js")});import{mkdir as oZ,readFile as uJ,stat as iZ,writeFile as aQ}from"node:fs/promises";import nZ from"node:path";async function rZ(){return Promise.all(e1.map(async($)=>({agent:$,installed:await dJ($.configDir)})))}async function dJ($){try{return await iZ($),!0}catch{return!1}}async function sQ(){A1(i.default.bgMagenta(i.default.white(" petdex hooks install ")));try{let{persistRunningBinary:J}=await Promise.resolve().then(() => (rQ(),cJ)),G=await J();if(!G.ok&&G.reason)u.warn(`Could not persist petdex binary (${G.reason}). Bubbles will be disabled.`)}catch(J){u.warn(`Could not persist petdex binary (${J.message}). Bubbles will be disabled.`)}let $=await rZ(),Q=$.some((J)=>J.installed);u.info(Q?"Found these agents on your system:":"No coding agent configs detected. You can still pre-write hooks for any agent. They'll activate when you install it.");for(let{agent:J,installed:G}of $){let U=G?i.default.green("●"):i.default.dim("○"),K=G?i.default.dim("installed"):i.default.dim("not found");console.log(` ${U} ${i.default.bold(J.displayName)} ${K}`)}let q=await hq({message:"Which agents should drive the mascot?",options:$.map(({agent:J,installed:G})=>({value:J.id,label:J.displayName,hint:G?"installed":"not installed yet"})),initialValues:$.filter((J)=>J.installed).map((J)=>J.agent.id),required:!1});if(q0(q)||q.length===0)return Y1("No agents selected. Bye."),{installedAgents:[]};let V=[],Y=[],X=[];for(let J of q){let G=e1.find((U)=>U.id===J);if(!G)continue;try{let U=await tQ(G);if(X.push(G.id),V.push(` ${i.default.green("✓")} ${i.default.bold(G.displayName)}`),G.postInstallChecks)try{let K=await G.postInstallChecks();if(K.length>0)Y.push({agent:G.displayName,notes:K})}catch{}}catch(U){V.push(` ${i.default.red("✗")} ${i.default.bold(G.displayName)} ${i.default.red(U instanceof Error?U.message:String(U))}`)}}T1(V.join(`
256
- `),"Done");for(let{agent:J,notes:G}of Y)for(let U of G){let K=U.level==="action"?i.default.bgYellow(i.default.black(" action needed ")):U.level==="warn"?i.default.yellow("!"):i.default.cyan("i");if(u.warn(`${K} ${i.default.bold(J)}
257
- ${U.message}`),U.fix){let W=await M6({message:U.fix.prompt,initialValue:!0});if(!q0(W)&&W){let Z=await U.fix.apply();if(Z.ok)u.info(`${i.default.green("✓")} ${Z.message}`);else u.warn(`${i.default.red("✗")} ${Z.message}`)}}}return{installedAgents:X}}async function tQ($){await oZ(nZ.dirname($.configFile),{recursive:!0});let Q=$.build();if(await bJ($),$.id==="opencode"){let J=await pJ($.configFile);return await aQ($.configFile,Q,"utf8"),{backupPath:J}}let q=await aZ($.configFile);if(q.kind==="error")throw Error(`Refusing to overwrite ${$.configFile}: ${q.message}.
258
- Fix the file (or rename it) and run \`petdex hooks install\` again.`);let V=q.kind==="ok"?await pJ($.configFile):null,Y=q.kind==="ok"?q.value:{},X=sZ(Y,Q);return await aQ($.configFile,`${JSON.stringify(X,null,2)}
259
- `,"utf8"),{backupPath:V}}async function aZ($){let Q;try{Q=await uJ($,"utf8")}catch(q){let V=q.code;if(V==="ENOENT")return{kind:"missing"};return{kind:"error",message:`read failed (${V??q.name}): ${q.message}`}}try{return{kind:"ok",value:JSON.parse(Q)}}catch(q){return{kind:"error",message:`JSON parse failed: ${q.message}`}}}async function pJ($){if(!await dJ($))return null;let Q=new Date().toISOString().replace(/[:.]/g,"-"),q=`${$}.${Q}.bak`,V=await uJ($);return await aQ(q,V),q}function sZ($,Q){let q={...$},V=Q.hooks??{},X={...q.hooks??{}};for(let[J,G]of Object.entries(V)){let K=(Array.isArray(X[J])?X[J]:[]).filter((W)=>!tZ(W));X[J]=[...K,...G]}return q.hooks=X,q}function tZ($){if(typeof $!=="object"||$==null)return!1;return eZ($).some((q)=>q.includes(`localhost:${e$}/state`)||q.includes(v0))}function eZ($){let Q=[];function q(V){if(typeof V==="string"){Q.push(V);return}if(Array.isArray(V)){for(let Y of V)q(Y);return}if(typeof V==="object"&&V!=null)for(let Y of Object.values(V))q(Y)}return q($),Q}var i;var eQ=$0(()=>{y0();$6();oQ();i=C1(d1(),1)});var $q={};x8($q,{runRefresh:()=>Qz});import{existsSync as lJ}from"node:fs";function $z($){return lJ($.configFile)||lJ($.slashCommandPath)}async function Qz(){let $={refreshed:[],skipped:[],binaryPersisted:!1};try{let Q=await nQ();if($.binaryPersisted=Q.ok,!Q.ok)$.binaryReason=Q.reason}catch(Q){$.binaryReason=Q.message}for(let Q of e1){if(!$z(Q)){$.skipped.push({id:Q.id,reason:"not installed"});continue}try{await tQ(Q),$.refreshed.push(Q.id)}catch(q){$.skipped.push({id:Q.id,reason:q.message})}}return $}var Qq=$0(()=>{$6();eQ();rQ()});function Cz($){let Q=$.toLowerCase();if(Q==="read")return"read";if(Q==="edit"||Q==="multiedit")return"edit";if(Q==="write")return"write";if(Q==="bash"||Q==="shell")return"bash";if(Q==="grep")return"grep";if(Q==="glob")return"glob";if(Q==="webfetch"||Q==="websearch")return"webfetch";if(Q==="task"||Q==="agent")return"task";return"unknown"}function u1($,Q){if($==null||typeof $!=="object")return null;let q=$[Q];return typeof q==="string"?q:null}function UY($){let Q=Math.max($.lastIndexOf("/"),$.lastIndexOf("\\"));return Q>=0?$.slice(Q+1):$}function S1($,Q=40){if($.length<=Q)return $;return`${$.slice(0,Q-1)}…`}function jY($){if($.kind==="session.start")return"Thinking…";if($.kind==="session.end")return"Done.";if($.kind==="session.waiting")return"Waiting for you…";let{toolName:Q,phase:q,toolInput:V}=$,Y=Cz(Q),X=q==="done";switch(Y){case"read":{let J=u1(V,"file_path")??u1(V,"path"),G=J?S1(UY(J)):null;if(G)return X?`Read ${G}`:`Reading ${G}`;return X?"Read file":"Reading file"}case"edit":case"write":{let J=u1(V,"file_path")??u1(V,"path"),G=J?S1(UY(J)):null;if(G)return X?`Edited ${G}`:`Editing ${G}`;return X?"Edited file":"Editing file"}case"bash":{let J=u1(V,"command");if(J){let G=S1(J.split(/\s+/)[0]??J,24);return X?`Ran ${G}`:`Running ${G}`}return X?"Ran command":"Running command"}case"grep":{let J=u1(V,"pattern");if(J)return X?`Searched "${S1(J,28)}"`:`Searching "${S1(J,28)}"`;return X?"Searched files":"Searching files"}case"glob":{let J=u1(V,"pattern");if(J)return X?`Listed ${S1(J,28)}`:`Listing ${S1(J,28)}`;return X?"Listed files":"Listing files"}case"webfetch":{let J=u1(V,"url");if(J)try{let G=new URL(J).hostname;return X?`Fetched ${S1(G,28)}`:`Fetching ${S1(G,28)}`}catch{}return X?"Fetched web":"Searching web"}case"task":{let J=u1(V,"description")??u1(V,"subject");if(J)return X?"Subagent done":`Spawning ${S1(J,28)}`;return X?"Subagent done":"Spawning subagent"}case"unknown":default:{let J=S1(Q,28);return X?`Called ${J}`:`Calling ${J}`}}}var BY={};x8(BY,{stateForEvent:()=>PY,runBubble:()=>yz,eventFromArgs:()=>MY});import{existsSync as wz,readFileSync as Tz}from"node:fs";import{homedir as Az}from"node:os";import{join as Vq}from"node:path";function PY($,Q){let q=$[0];if(q==="pre"){if(Q){let V=Q.toLowerCase();if(V==="read"||V==="grep"||V==="glob")return"review"}return"running"}if(q==="post")return"idle";if(q==="stop"||q==="session-end")return"waving";if(q==="user-prompt"||q==="session-start")return"jumping";if(q==="waiting"||q==="notification")return"waiting";return null}async function Sz(){if(process.stdin.isTTY)return"";return await new Promise(($)=>{let Q="",q=!1;process.stdin.setEncoding("utf8"),process.stdin.on("data",(V)=>{if(q)return;if(Q.length+V.length>ZY){Q+=V.slice(0,ZY-Q.length),q=!0;return}Q+=V}),process.stdin.on("end",()=>$(Q)),process.stdin.on("error",()=>$(Q))})}function OY($){if(!$.trim())return{toolName:null,toolInput:void 0,agentSource:null};try{let Q=JSON.parse($),q=typeof Q.tool_name==="string"?Q.tool_name:null,V=Q.tool_input,Y=typeof Q.agent_source==="string"?Q.agent_source:null;return{toolName:q,toolInput:V,agentSource:Y}}catch{return{toolName:null,toolInput:void 0,agentSource:null}}}function MY($,Q){let q=$[0];if(!q)return null;if(q==="stop"||q==="session-end")return{kind:"session.end"};if(q==="user-prompt"||q==="session-start")return{kind:"session.start"};if(q==="waiting"||q==="notification")return{kind:"session.waiting"};let V=q==="pre"?"running":q==="post"?"done":null;if(!V)return null;let{toolName:Y,toolInput:X}=OY(Q);if(!Y)return{kind:"tool",phase:V,toolName:"tool",toolInput:void 0};return{kind:"tool",phase:V,toolName:Y,toolInput:X}}function Ez(){try{let $=Tz(Fz,"utf8").trim();return $.length>0?$:null}catch{return null}}async function zY($,Q,q){let V=new AbortController,Y=setTimeout(()=>V.abort(),300);try{await fetch($,{method:"POST",headers:{"Content-Type":"application/json","X-Petdex-Update-Token":q},body:JSON.stringify(Q),signal:V.signal})}catch{}finally{clearTimeout(Y)}}async function yz($){if(wz(Rz))return;let Q=$[1]??null,q=await Sz(),V=MY($,q);if(!V)return;let{toolName:Y,agentSource:X}=OY(q),J=X??Q,G=jY(V),U=PY($,Y),K=Ez();if(!K)return;let W=[];if(G)W.push(zY(vz,{text:G,agent_source:J},K));if(U)W.push(zY(xz,{state:U,agent_source:J},K));await Promise.all(W)}var HY,Fz,Rz,LY="http://127.0.0.1:7777",vz,xz,ZY=65536;var NY=$0(()=>{HY=Vq(Az(),".petdex","runtime"),Fz=Vq(HY,"update-token"),Rz=Vq(HY,"hooks-disabled"),vz=`${LY}/bubble`,xz=`${LY}/state`});y0();var Gq=C1(i7(),1),j=C1(d1(),1);import{existsSync as kz}from"node:fs";import{mkdir as IY,readdir as gz,readFile as Xq,stat as vY,writeFile as w8}from"node:fs/promises";import{homedir as CY}from"node:os";import J1 from"node:path";import{spawn as bj}from"node:child_process";import{createServer as Aj}from"node:http";class g extends Error{code;constructor($,Q){super(Q);this.name="ClerkCliAuthError",this.code=$}}var Fj=`<!doctype html>
358
+ `,KH=`description = "Wake or sleep the petdex mascot. Toggles the floating pet on/off"
359
+
360
+ prompt = """
361
+ The user wants to control the petdex mascot from inside the agent. The mascot is a floating macOS window driven by hooks installed in agent settings. /petdex is a one-shot toggle that flips the entire state in a single command.
362
+
363
+ Run the matching command using the persisted petdex binary at \`$HOME/.petdex/bin/petdex.js\` (always present after \`petdex hooks install\`):
364
+
365
+ - \`/petdex\` (no args) -> run \`${$1} toggle\`
366
+ - \`/petdex up\` -> run \`${$1} up\`
367
+ - \`/petdex down\` -> run \`${$1} down\`
368
+ - \`/petdex status\` -> run \`${$1} hooks status\`
369
+ - \`/petdex doctor\` -> run \`${$1} doctor\`
370
+
371
+ Show the command output verbatim to the user. Don't reinterpret, don't explain. The CLI's output is already user-facing.
372
+
373
+ If \`$HOME/.petdex/bin/petdex.js\` doesn't exist, the user hasn't run \`petdex hooks install\` yet. Tell them to run \`npx petdex@latest init\` first, then retry.
374
+
375
+ Arguments: \`{{args}}\`
376
+ """
377
+ `,iY=oY.join(VH(),".gemini","antigravity","global_workflows","petdex.md")});import{spawnSync as GH}from"node:child_process";import{mkdir as RQ,readFile as EQ,rm as WH,stat as rY,writeFile as w8}from"node:fs/promises";import{homedir as UH}from"node:os";import o2 from"node:path";async function ZH(){return Promise.all(z1.map(async(Q)=>({agent:Q,installed:await aY(Q.configDir)})))}async function aY(Q){try{return await rY(Q),!0}catch{return!1}}async function SQ(){A0(s.default.bgMagenta(s.default.white(" petdex hooks install ")));try{let{persistRunningBinary:W}=await Promise.resolve().then(() => (D8(),uY)),G=await W();if(!G.ok&&G.reason)o.warn(`Could not persist petdex binary (${G.reason}). Bubbles will be disabled.`)}catch(W){o.warn(`Could not persist petdex binary (${W.message}). Bubbles will be disabled.`)}let Q=await ZH(),$=Q.some((W)=>W.installed);o.info($?"Found these agents on your system:":"No coding agent configs detected. You can still pre-write hooks for any agent. They'll activate when you install it.");for(let{agent:W,installed:G}of Q){let U=G?s.default.green("●"):s.default.dim("○"),z=G?s.default.dim("installed"):s.default.dim("not found");console.log(` ${U} ${s.default.bold(W.displayName)} ${z}`)}let J=await x7({message:"Which agents should drive the mascot?",options:Q.map(({agent:W,installed:G})=>({value:W.id,label:W.displayName,hint:G?"installed":"not installed yet"})),initialValues:Q.filter((W)=>W.installed).map((W)=>W.agent.id),required:!1});if(L1(J)||J.length===0)return r("No agents selected. Bye."),{installedAgents:[]};let q=[],Y=[],V=[],X=J,K=new Set(X);for(let W of X){let G=z1.find((U)=>U.id===W);if(!G)continue;try{if(await kQ(G,{installSlashCommand:zH(G,K)}),V.push(G.id),q.push(` ${s.default.green("✓")} ${s.default.bold(G.displayName)}`),G.postInstallChecks)try{let U=await G.postInstallChecks();if(U.length>0)Y.push({agent:G.displayName,notes:U})}catch{}}catch(U){q.push(` ${s.default.red("✗")} ${s.default.bold(G.displayName)} ${s.default.red(U instanceof Error?U.message:String(U))}`)}}_0(q.join(`
378
+ `),"Done");for(let{agent:W,notes:G}of Y)for(let U of G){let z=U.level==="action"?s.default.bgYellow(s.default.black(" action needed ")):U.level==="warn"?s.default.yellow("!"):s.default.cyan("i");if(o.warn(`${z} ${s.default.bold(W)}
379
+ ${U.message}`),U.fix){let j=await f8({message:U.fix.prompt,initialValue:!0});if(!L1(j)&&j){let H=await U.fix.apply();if(H.ok)o.info(`${s.default.green("✓")} ${H.message}`);else o.warn(`${s.default.red("✗")} ${H.message}`)}}}return{installedAgents:V}}function zH(Q,$){return Q.id!=="antigravity"&&!(Q.id==="gemini"&&$.has("antigravity"))}async function kQ(Q,$={}){await RQ(o2.dirname(Q.configFile),{recursive:!0});let J=Q.build();if(Q.id!=="antigravity")if($.installSlashCommand===!1)await l2(Q);else await nY(Q);if(Q.id==="opencode"){let K=await vQ(Q.configFile);return await w8(Q.configFile,J,"utf8"),{backupPath:K}}if(Q.id==="antigravity")return await NH(),{backupPath:null};let q=await xQ(Q.configFile);if(q.kind==="error")throw Error(`Refusing to overwrite ${Q.configFile}: ${q.message}.
380
+ Fix the file (or rename it) and run \`petdex hooks install\` again.`);let Y=q.kind==="ok"?await vQ(Q.configFile):null,V=q.kind==="ok"?q.value:{},X=HH(V,J);return await w8(Q.configFile,`${JSON.stringify(X,null,2)}
381
+ `,"utf8"),{backupPath:Y}}async function xQ(Q){let $;try{$=await EQ(Q,"utf8")}catch(J){let q=J.code;if(q==="ENOENT")return{kind:"missing"};return{kind:"error",message:`read failed (${q??J.name}): ${J.message}`}}try{return{kind:"ok",value:JSON.parse($)}}catch(J){return{kind:"error",message:`JSON parse failed: ${J.message}`}}}async function vQ(Q){if(!await aY(Q))return null;let $=new Date().toISOString().replace(/[:.]/g,"-"),J=`${Q}.${$}.bak`,q=await EQ(Q);return await w8(J,q),J}function HH(Q,$){let J={...Q},q=$.hooks??{},V={...J.hooks??{}};for(let[X,K]of Object.entries(q)){let G=(Array.isArray(V[X])?V[X]:[]).filter((U)=>!FH(U));V[X]=[...G,...K]}return J.hooks=V,J}function FH(Q){if(typeof Q!=="object"||Q==null)return!1;return LH(Q).some((J)=>J.includes(`localhost:${H8}/state`)||J.includes(n1))}function LH(Q){let $=[];function J(q){if(typeof q==="string"){$.push(q);return}if(Array.isArray(q)){for(let Y of q)J(Y);return}if(typeof q==="object"&&q!=null)for(let Y of Object.values(q))J(Y)}return J(Q),$}async function OH(){try{await rY(y0);let Q=GH(process.execPath,[y0,"mcp-server"],{encoding:"utf8",input:"",timeout:5000});return Q.status===0&&Q.stdout===""}catch{return!1}}async function NH(){if(await A8().catch(()=>{}),!await OH())throw Error(`Petdex persisted binary missing or not functional: ${y0}.
382
+ The mcp-server subcommand is required for Antigravity integration.
383
+ Run \`npx petdex@latest hooks install\` to persist a fresh binary, then re-run.`);let $=await GY();await RQ(o2.dirname($),{recursive:!0});let J=dY(),q=await BH($);if(q.kind==="error")throw Error(`Refusing to overwrite ${$}: ${q.message}.
384
+ Fix the file (or rename it) and run \`petdex hooks install\` again.`);if(q.kind==="ok")await vQ($);let Y=q.kind==="ok"?q.value:{},V=Y.mcpServers??{},X={...Y,mcpServers:{...V,...J.mcpServers}};await w8($,`${JSON.stringify(X,null,2)}
385
+ `,"utf8");let K=E1();await RQ(K,{recursive:!0}),await w8(o2.join(K,"SKILL.md"),pY(),"utf8"),await WH(jH,{recursive:!0,force:!0})}async function BH(Q){try{if((await EQ(Q,"utf8")).trim()==="")return{kind:"missing"}}catch{return xQ(Q)}return xQ(Q)}var s,jH;var yQ=z0(()=>{a1();F8();lY();D8();wQ();s=u0(R1(),1),jH=o2.join(UH(),".antigravity","skills","petdex")});var gQ={};E8(gQ,{runRefresh:()=>PH});import{existsSync as sY}from"node:fs";function MH(Q){return sY(Q.configFile)||sY(Q.slashCommandPath)}async function PH(){let Q={refreshed:[],skipped:[],binaryPersisted:!1};try{let $=await A8();if(Q.binaryPersisted=$.ok,!$.ok)Q.binaryReason=$.reason}catch($){Q.binaryReason=$.message}for(let $ of z1){if(!MH($)){Q.skipped.push({id:$.id,reason:"not installed"});continue}try{await kQ($),Q.refreshed.push($.id)}catch(J){Q.skipped.push({id:$.id,reason:J.message})}}return Q}var _Q=z0(()=>{F8();yQ();D8()});function hH(Q){let $=Q.toLowerCase();if($==="read")return"read";if($==="edit"||$==="multiedit")return"edit";if($==="write")return"write";if($==="bash"||$==="shell")return"bash";if($==="grep")return"grep";if($==="glob")return"glob";if($==="webfetch"||$==="websearch")return"webfetch";if($==="task"||$==="agent")return"task";return"unknown"}function J1(Q,$){if(Q==null||typeof Q!=="object")return null;let J=Q[$];return typeof J==="string"?J:null}function Y3(Q){let $=Math.max(Q.lastIndexOf("/"),Q.lastIndexOf("\\"));return $>=0?Q.slice($+1):Q}function m0(Q,$=40){if(Q.length<=$)return Q;return`${Q.slice(0,$-1)}…`}function V3(Q){if(Q.kind==="session.start")return"Thinking…";if(Q.kind==="session.end")return"Done.";if(Q.kind==="session.waiting")return"Waiting for you…";let{toolName:$,phase:J,toolInput:q}=Q,Y=hH($),V=J==="done";switch(Y){case"read":{let X=J1(q,"file_path")??J1(q,"path"),K=X?m0(Y3(X)):null;if(K)return V?`Read ${K}`:`Reading ${K}`;return V?"Read file":"Reading file"}case"edit":case"write":{let X=J1(q,"file_path")??J1(q,"path"),K=X?m0(Y3(X)):null;if(K)return V?`Edited ${K}`:`Editing ${K}`;return V?"Edited file":"Editing file"}case"bash":{let X=J1(q,"command");if(X){let K=m0(X.split(/\s+/)[0]??X,24);return V?`Ran ${K}`:`Running ${K}`}return V?"Ran command":"Running command"}case"grep":{let X=J1(q,"pattern");if(X)return V?`Searched "${m0(X,28)}"`:`Searching "${m0(X,28)}"`;return V?"Searched files":"Searching files"}case"glob":{let X=J1(q,"pattern");if(X)return V?`Listed ${m0(X,28)}`:`Listing ${m0(X,28)}`;return V?"Listed files":"Listing files"}case"webfetch":{let X=J1(q,"url");if(X)try{let K=new URL(X).hostname;return V?`Fetched ${m0(K,28)}`:`Fetching ${m0(K,28)}`}catch{}return V?"Fetched web":"Searching web"}case"task":{let X=J1(q,"description")??J1(q,"subject");if(X)return V?"Subagent done":`Spawning ${m0(X,28)}`;return V?"Subagent done":"Spawning subagent"}default:{let X=m0($,28);return V?`Called ${X}`:`Calling ${X}`}}}var z3={};E8(z3,{stateForEvent:()=>U3,runBubble:()=>nH,eventFromArgs:()=>Z3});import{existsSync as fH,readFileSync as mH}from"node:fs";import{homedir as cH}from"node:os";import{join as pQ}from"node:path";function U3(Q,$){let J=Q[0];if(J==="pre"){if($){let q=$.toLowerCase();if(q==="read"||q==="grep"||q==="glob")return"review"}return"running"}if(J==="post")return"idle";if(J==="stop"||J==="session-end")return"waving";if(J==="user-prompt"||J==="session-start")return"jumping";if(J==="waiting"||J==="notification")return"waiting";return null}async function oH(){if(process.stdin.isTTY)return"";return await new Promise((Q)=>{let $="",J=!1;process.stdin.setEncoding("utf8"),process.stdin.on("data",(q)=>{if(J)return;if($.length+q.length>X3){$+=q.slice(0,X3-$.length),J=!0;return}$+=q}),process.stdin.on("end",()=>Q($)),process.stdin.on("error",()=>Q($))})}function j3(Q){if(!Q.trim())return{toolName:null,toolInput:void 0,agentSource:null};try{let $=JSON.parse(Q),J=typeof $.tool_name==="string"?$.tool_name:null,q=$.tool_input,Y=typeof $.agent_source==="string"?$.agent_source:null;return{toolName:J,toolInput:q,agentSource:Y}}catch{return{toolName:null,toolInput:void 0,agentSource:null}}}function Z3(Q,$){let J=Q[0];if(!J)return null;if(J==="stop"||J==="session-end")return{kind:"session.end"};if(J==="user-prompt"||J==="session-start")return{kind:"session.start"};if(J==="waiting"||J==="notification")return{kind:"session.waiting"};let q=J==="pre"?"running":J==="post"?"done":null;if(!q)return null;let{toolName:Y,toolInput:V}=j3($);if(!Y)return{kind:"tool",phase:q,toolName:"tool",toolInput:void 0};return{kind:"tool",phase:q,toolName:Y,toolInput:V}}function iH(){try{let Q=mH(uH,"utf8").trim();return Q.length>0?Q:null}catch{return null}}async function K3(Q,$,J){let q=new AbortController,Y=setTimeout(()=>q.abort(),300);try{await fetch(Q,{method:"POST",headers:{"Content-Type":"application/json","X-Petdex-Update-Token":J},body:JSON.stringify($),signal:q.signal})}catch{}finally{clearTimeout(Y)}}async function nH(Q){if(fH(pH))return;let $=Q[1]??null,J=await oH(),q=Z3(Q,J);if(!q)return;let{toolName:Y,agentSource:V}=j3(J),X=V??$,K=V3(q),W=U3(Q,Y),G=iH();if(!G)return;let U=[];if(K)U.push(K3(dH,{text:K,agent_source:X},G));if(W)U.push(K3(lH,{state:W,agent_source:X},G));await Promise.all(U)}var G3,uH,pH,W3="http://127.0.0.1:7777",dH,lH,X3=65536;var H3=z0(()=>{G3=pQ(cH(),".petdex","runtime"),uH=pQ(G3,"update-token"),pH=pQ(G3,"hooks-disabled"),dH=`${W3}/bubble`,lH=`${W3}/state`});var B3={};E8(B3,{runMcpServer:()=>YF});import{readFile as L3}from"node:fs/promises";import{homedir as O3}from"node:os";import N3 from"node:path";async function QF(){try{return(await L3(sH,"utf8")).trim()}catch{return null}}async function $F(){try{return await L3(tH),!0}catch{return!1}}async function F3(Q,$){let J=await QF();if(!J)return{ok:!1,status:0};try{let q=await fetch(Q,{method:"POST",headers:{"Content-Type":"application/json","X-Petdex-Update-Token":J},body:JSON.stringify($),signal:AbortSignal.timeout(300)});return{ok:q.ok,status:q.status}}catch{return{ok:!1,status:0}}}function g0(Q){let $=JSON.stringify(Q);if(dQ==="jsonl"){process.stdout.write(`${$}
386
+ `);return}let q=`Content-Length: ${new TextEncoder().encode($).length}\r
387
+ \r
388
+ `;process.stdout.write(q),process.stdout.write($)}function R8(Q,$,J){return{jsonrpc:"2.0",id:Q,error:{code:$,message:J}}}async function qF(Q){let{id:$,method:J,params:q}=Q;switch(J){case"initialize":{let Y=q?.protocolVersion??"2025-03-26";g0({jsonrpc:"2.0",id:$,result:{protocolVersion:Y,capabilities:{tools:{listChanged:!1}},serverInfo:{name:"petdex-mcp-server",version:eH}}});return}case"tools/list":{g0({jsonrpc:"2.0",id:$,result:{tools:JF}});return}case"tools/call":{let Y=q?.name,V=q?.arguments??{};if(await $F()){g0({jsonrpc:"2.0",id:$,result:{content:[{type:"text",text:"Petdex hooks are disabled. Run /petdex in your agent or `petdex hooks on` to re-enable."}]}});return}switch(Y){case"petdex_set_state":{let X=V.state;if(!X){g0(R8($,-32602,"Missing required argument: state"));return}let K={state:X,agent_source:"antigravity"};if(typeof V.duration==="number")K.duration=V.duration;let W=await F3(rH,K);g0({jsonrpc:"2.0",id:$,result:{content:[{type:"text",text:W.ok?`Pet state set to "${X}"`:"Sidecar unreachable — is petdex-desktop running?"}]}});return}case"petdex_show_bubble":{let X=V.text;if(!X){g0(R8($,-32602,"Missing required argument: text"));return}let K=await F3(aH,{text:X,agent_source:"antigravity"});g0({jsonrpc:"2.0",id:$,result:{content:[{type:"text",text:K.ok?`Bubble shown: "${X}"`:"Sidecar unreachable — is petdex-desktop running?"}]}});return}case"petdex_status":{let X=!1;try{X=(await fetch(`${oQ}/health`,{signal:AbortSignal.timeout(500)})).ok}catch{X=!1}g0({jsonrpc:"2.0",id:$,result:{content:[{type:"text",text:X?"Petdex desktop is reachable.":"Petdex desktop not detected. Start it with `petdex up`."}]}});return}default:{g0(R8($,-32601,`Unknown tool: ${Y}`));return}}}case"notifications/initialized":return;default:g0(R8($,-32601,`Unknown method: ${J}`))}}async function YF(){let Q=new Uint8Array(0),$=0,J=!1,q=new TextDecoder;function Y(){if($===0)process.exit(0)}process.stdin.on("data",(X)=>{let K=typeof X==="string"?new TextEncoder().encode(X):X,W=new Uint8Array(Q.length+K.length);W.set(Q),W.set(K,Q.length),Q=W;while(!0){let G=XF(Q);if(G===123||G===91){let B=lQ(Q,new Uint8Array([10]));if(B===-1)break;let O=KF(Q.slice(0,B));Q=Q.slice(B+1);let M=q.decode(O).trim();if(!M)continue;dQ="jsonl",V(M);continue}let U=VF(Q),z=U.index;if(z===-1)break;let j=Q.slice(0,z),F=q.decode(j).match(/Content-Length:\s*(\d+)/i);if(!F){Q=Q.slice(z+U.length);continue}let N=parseInt(F[1],10),T=z+U.length,P=T+N;if(Q.length<P)break;let L=Q.slice(T,P),A=q.decode(L);Q=Q.slice(P),dQ="framed",V(A)}}),process.stdin.on("end",()=>{J=!0,Y(),setTimeout(()=>process.exit(0),3000).unref()});function V(X){try{let K=JSON.parse(X);$++,qF(K).catch((W)=>{g0(R8(K.id,-32603,`Internal error: ${W.message}`))}).finally(()=>{if($--,J)Y()})}catch(K){g0({jsonrpc:"2.0",id:null,error:{code:-32700,message:`Parse error: ${K.message}`}})}}}function lQ(Q,$){Q:for(let J=0;J<=Q.length-$.length;J++){for(let q=0;q<$.length;q++)if(Q[J+q]!==$[q])continue Q;return J}return-1}function VF(Q){let $=lQ(Q,new Uint8Array([13,10,13,10]));if($!==-1)return{index:$,length:4};let J=lQ(Q,new Uint8Array([10,10]));if(J!==-1)return{index:J,length:2};return{index:-1,length:0}}function XF(Q){for(let $ of Q)if($!==32&&$!==9&&$!==10&&$!==13)return $;return null}function KF(Q){if(Q.at(-1)===13)return Q.slice(0,-1);return Q}var oQ="http://127.0.0.1:7777",rH,aH,sH,tH,eH="0.1.0",dQ="framed",JF;var M3=z0(()=>{rH=`${oQ}/state`,aH=`${oQ}/bubble`,sH=N3.join(O3(),".petdex","runtime","update-token"),tH=N3.join(O3(),".petdex","runtime","hooks-disabled");JF=[{name:"petdex_set_state",description:"Set the pet's animation state. Call this before/after tool use to reflect agent activity.",inputSchema:{type:"object",properties:{state:{type:"string",description:"Animation state: idle, running, running-left, running-right, waving, jumping, failed, review, waiting",enum:["idle","running","running-left","running-right","waving","jumping","failed","review","waiting"]},duration:{type:"number",description:"Optional duration in ms to hold this state"}},required:["state"]}},{name:"petdex_show_bubble",description:"Show a speech bubble above the pet with the given text. Use to display what the agent is currently doing.",inputSchema:{type:"object",properties:{text:{type:"string",description:"The bubble text to display (e.g. 'Reading server.ts')"}},required:["text"]}},{name:"petdex_status",description:"Check if the petdex desktop mascot is reachable. Returns connection status.",inputSchema:{type:"object",properties:{}}}]});a1();var rQ=u0(cq(),1),Z=u0(R1(),1);import{existsSync as P3}from"node:fs";import{mkdir as I3,readdir as GF,readFile as nQ,stat as x3,writeFile as n2}from"node:fs/promises";import{homedir as T3}from"node:os";import j0 from"node:path";import{spawn as oZ}from"node:child_process";import{createServer as kZ}from"node:http";class f extends Error{code;constructor(Q,$){super($);this.name="ClerkCliAuthError",this.code=Q}}var yZ=`<!doctype html>
260
389
  <html>
261
390
  <head><meta charset="utf-8"><title>Authentication complete</title></head>
262
391
  <body><h1>Authentication complete</h1><p>You can close this tab and return to your terminal.</p></body>
263
- </html>`,Rj=`<!doctype html>
392
+ </html>`,gZ=`<!doctype html>
264
393
  <html>
265
394
  <head><meta charset="utf-8"><title>Authentication failed</title></head>
266
395
  <body><h1>Authentication failed</h1><p>You can close this tab and return to your terminal.</p></body>
267
- </html>`;function kQ($,Q){return new g($,Q)}function n7($){let{expectedState:Q,port:q=0,timeoutMs:V=120000,successHtml:Y=Fj,errorHtml:X=Rj}=$,J,G=!1,U=!1,K,W,Z=new Promise((I,N)=>{K=I,W=N}),z=(I)=>{if(U)return;U=!0,I.close()},H=Aj((I,N)=>{if(G){N.writeHead(410,{"Content-Type":"text/plain; charset=utf-8"}),N.end("Authentication callback already handled.");return}if(I.method!=="GET"||!I.url){N.writeHead(404,{"Content-Type":"text/plain; charset=utf-8"}),N.end("Not found");return}let w=new URL(I.url,"http://127.0.0.1");if(w.pathname!=="/callback"){N.writeHead(404,{"Content-Type":"text/plain; charset=utf-8"}),N.end("Clerk CLI auth server is waiting for /callback.");return}let P=w.searchParams.get("code"),L=w.searchParams.get("state"),C=w.searchParams.get("error"),O=w.searchParams.get("error_description")??C,M=(F,R,v)=>{if(G=!0,J)clearTimeout(J);N.writeHead(F,{"Content-Type":"text/html; charset=utf-8"}),N.end(R,()=>{if(v)W(v);else if(P&&L)K({code:P,state:L});z(H)})};if(C){M(400,X,kQ("token_exchange",`OAuth authorization failed: ${O??"unknown error"}`));return}if(L!==Q){M(400,X,kQ("state_mismatch","OAuth callback state did not match."));return}if(!P){M(400,X,kQ("token_exchange","OAuth callback did not include an authorization code."));return}M(200,Y)});return new Promise((I,N)=>{H.once("error",(w)=>{N(new g("config",`Failed to start local auth callback server: ${w.message}`))}),H.listen(q,"127.0.0.1",()=>{let P=H.address().port,L=`http://127.0.0.1:${P}/callback`;J=setTimeout(()=>{if(G)return;G=!0,W(new g("timeout",`OAuth callback timed out after ${V}ms.`)),z(H)},V),I({port:P,redirectUri:L,waitForCallback:()=>Z,close:()=>{if(J)clearTimeout(J);if(!G)G=!0,W(new g("timeout","OAuth callback server was closed."));z(H)}})})})}import{chmod as vj,mkdir as xj,readFile as Sj,writeFile as Ej}from"node:fs/promises";import{homedir as yj}from"node:os";import{dirname as kj,join as gj}from"node:path";function r7($,Q){if(Q instanceof g)return Q;let q=Q instanceof Error?Q.message:String(Q);return new g("storage",`${$}: ${q}`)}function s7($){return $?.environment??"default"}function Dj($){return gj(yj(),".config","clerk-cli-auth",`${$}.json`)}class t7{values=new Map;async get($){return this.values.get($)??null}async set($,Q){this.values.set($,Q)}async delete($){this.values.delete($)}}class e7{filePath;queue=Promise.resolve();constructor($){this.filePath=$}enqueue($){let Q=this.queue.then($,$);return this.queue=Q.catch(()=>{return}),Q}async readAll(){try{let $=await Sj(this.filePath,"utf8");if(!$.trim())return{};let Q=JSON.parse($);if(!Q||typeof Q!=="object"||Array.isArray(Q))return{};let q={};for(let[V,Y]of Object.entries(Q))if(typeof Y==="string")q[V]=Y;return q}catch($){if($.code==="ENOENT")return{};throw r7(`Failed to read credential file ${this.filePath}`,$)}}async writeAll($){try{await xj(kj(this.filePath),{recursive:!0}),await Ej(this.filePath,`${JSON.stringify($,null,2)}
268
- `,{mode:384}),await vj(this.filePath,384)}catch(Q){throw r7(`Failed to write credential file ${this.filePath}`,Q)}}async get($){return this.enqueue(async()=>{return(await this.readAll())[$]??null})}async set($,Q){return this.enqueue(async()=>{let q=await this.readAll();q[$]=Q,await this.writeAll(q)})}async delete($){return this.enqueue(async()=>{let Q=await this.readAll();delete Q[$],await this.writeAll(Q)})}}class $J{service;environment;fallback;keyringPromise=null;constructor($,Q,q){this.service=$;this.environment=Q;this.fallback=q}account($){return`${this.environment}:${$}`}warnFallback($,Q){let q=Q instanceof Error?Q.message:String(Q);if($==="initialization"&&q.includes("Cannot find package"))return;console.warn(`Keychain ${$} failed; falling back to file store. ${q}`)}async loadKeyring(){return this.keyringPromise??=import("@napi-rs/keyring").catch(($)=>{return this.warnFallback("initialization",$),null}),this.keyringPromise}async get($){try{let Q=await this.loadKeyring();if(!Q)return this.fallback.get($);return new Q.Entry(this.service,this.account($)).getPassword()??await this.fallback.get($)}catch(Q){return this.warnFallback("get",Q),this.fallback.get($)}}async set($,Q){try{let q=await this.loadKeyring();if(!q){await this.fallback.set($,Q);return}new q.Entry(this.service,this.account($)).setPassword(Q)}catch(q){this.warnFallback("set",q),await this.fallback.set($,Q)}}async delete($){try{let Q=await this.loadKeyring();if(Q)new Q.Entry(this.service,this.account($)).deletePassword()}catch(Q){this.warnFallback("delete",Q)}await this.fallback.delete($)}}function a7($){let Q=s7($);return new e7($?.filePath??Dj(Q))}function QJ($,Q){if($==="memory")return new t7;if($==="file")return a7(Q);let q=a7(Q),V=Q?.keychainService??"clerk-cli-auth",Y=s7(Q);return new $J(V,Y,q)}import{createHash as hj,randomBytes as qJ}from"node:crypto";function gQ($){return $.toString("base64url")}function VJ(){return gQ(qJ(32))}async function JJ($){return gQ(hj("sha256").update($).digest())}function YJ(){return gQ(qJ(32))}function XJ($,Q){return`${$.replace(/\/+$/,"")}${Q}`}async function GJ($){if(($.headers.get("content-type")??"").includes("application/json"))return $.json();return $.text()}function KJ($,Q){if(typeof $==="string"&&$.trim())return $.trim();if($&&typeof $==="object"){let q=$;for(let V of["error_description","message","error"]){let Y=q[V];if(typeof Y==="string"&&Y.trim())return Y.trim()}}return Q}function _j($){if(typeof $.access_token!=="string"||$.access_token.length===0)throw new g("token_exchange","Token response did not include access_token.");let Q={accessToken:$.access_token};if(typeof $.refresh_token==="string")Q.refreshToken=$.refresh_token;if(typeof $.id_token==="string")Q.idToken=$.id_token;if(typeof $.scope==="string")Q.scope=$.scope;if(typeof $.token_type==="string")Q.tokenType=$.token_type;if(typeof $.expires_in==="number")Q.expiresAt=Date.now()+$.expires_in*1000;return Q}async function WJ($,Q){let q;try{q=await fetch(XJ($,"/oauth/token"),{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:Q.toString()})}catch(Y){throw new g("token_exchange",`Token request failed: ${Y.message}`)}let V;try{V=await GJ(q)}catch(Y){throw new g("token_exchange",`Token response could not be parsed: ${Y.message}`)}if(!q.ok)throw new g("token_exchange",KJ(V,`Token request failed with HTTP ${q.status}.`));if(!V||typeof V!=="object")throw new g("token_exchange","Token response was not JSON.");return _j(V)}async function UJ($){let Q=new URLSearchParams({grant_type:"authorization_code",client_id:$.clientId,code:$.code,code_verifier:$.codeVerifier,redirect_uri:$.redirectUri});return WJ($.issuer,Q)}async function jJ($){let Q=new URLSearchParams({grant_type:"refresh_token",client_id:$.clientId,refresh_token:$.refreshToken});if($.scopes?.length)Q.set("scope",$.scopes.join(" "));return WJ($.issuer,Q)}async function DQ($){let Q;try{Q=await fetch(XJ($.issuer,"/oauth/userinfo"),{headers:{Authorization:`Bearer ${$.accessToken}`}})}catch(Y){throw new g("userinfo",`Userinfo request failed: ${Y.message}`)}let q;try{q=await GJ(Q)}catch(Y){throw new g("userinfo",`Userinfo response could not be parsed: ${Y.message}`)}if(!Q.ok)throw new g("userinfo",KJ(q,`Userinfo request failed with HTTP ${Q.status}.`));if(!q||typeof q!=="object")throw new g("userinfo","Userinfo response was not JSON.");let V=q;if(typeof V.sub!=="string"||V.sub.length===0)throw new g("userinfo","Userinfo response did not include sub.");return V}var fj=["profile","email","openid","offline_access"];function mj($){let Q=$.trim().replace(/\/+$/,"");try{let q=new URL(Q);if(q.protocol!=="http:"&&q.protocol!=="https:")throw Error("issuer must use http or https");return Q}catch(q){throw new g("config",`issuer must be a valid URL: ${q.message}`)}}function U8($,Q){if(Q instanceof g)return Q;let q=Q instanceof Error?Q.message:String(Q);return new g("storage",`Failed to ${$}: ${q}`)}async function cj($){console.log(`Open this URL to sign in:
269
- ${$}`);let Q=process.platform,q=Q==="darwin"?"open":Q==="win32"?"cmd":"xdg-open",V=Q==="win32"?["/c","start","",$]:[$];await new Promise((Y)=>{let X=bj(q,V,{detached:!0,stdio:"ignore"});X.once("error",()=>Y()),X.unref(),Y()})}class j8{config;constructor($){if(!$.clientId)throw new g("config","clientId is required");if(!$.issuer)throw new g("config","issuer is required");let Q=$.environment??"default",q=typeof $.storage==="object"&&$.storage!==null?$.storage:QJ($.storage??"keychain",{environment:Q,keychainService:$.keychainService});this.config={clientId:$.clientId,issuer:mj($.issuer),scopes:$.scopes??fj,storage:q,keychainService:$.keychainService??"clerk-cli-auth",environment:Q,callbackPort:$.callbackPort??0,timeoutMs:$.timeoutMs??120000,openBrowser:$.openBrowser}}async login(){let $=VJ(),Q=await JJ($),q=YJ(),V=await n7({expectedState:q,port:this.config.callbackPort,timeoutMs:this.config.timeoutMs});try{let Y=new URL(`${this.config.issuer}/oauth/authorize`);Y.searchParams.set("response_type","code"),Y.searchParams.set("client_id",this.config.clientId),Y.searchParams.set("redirect_uri",V.redirectUri),Y.searchParams.set("scope",this.config.scopes.join(" ")),Y.searchParams.set("state",q),Y.searchParams.set("code_challenge",Q),Y.searchParams.set("code_challenge_method","S256");try{await(this.config.openBrowser??cj)(Y.toString())}catch(U){throw new g("config",`Failed to open authorization URL: ${U.message}`)}let{code:X}=await V.waitForCallback(),J=await UJ({issuer:this.config.issuer,clientId:this.config.clientId,code:X,codeVerifier:$,redirectUri:V.redirectUri});await this.setJson("tokens",J);let G=await DQ({issuer:this.config.issuer,accessToken:J.accessToken});return await this.setJson("user",G),{tokens:J,user:G}}finally{V.close()}}async getAccessToken(){let $=await this.getTokenSet();if(!$)return null;if(($.expiresAt??Number.POSITIVE_INFINITY)>=Date.now()+30000)return $.accessToken;if(!$.refreshToken)return null;let q=await jJ({issuer:this.config.issuer,clientId:this.config.clientId,refreshToken:$.refreshToken,scopes:this.config.scopes}),V={...$,...q,refreshToken:q.refreshToken??$.refreshToken};return await this.setJson("tokens",V),V.accessToken}async whoami(){let $=await this.getJson("user");if($)return $;let Q=await this.getAccessToken();if(!Q)return null;let q=await DQ({issuer:this.config.issuer,accessToken:Q});return await this.setJson("user",q),q}async logout(){try{await Promise.all([this.config.storage.delete("tokens"),this.config.storage.delete("user")])}catch($){throw U8("clear stored credentials",$)}}async getTokenSet(){return this.getJson("tokens")}async getJson($){let Q;try{Q=await this.config.storage.get($)}catch(q){throw U8(`read ${$}`,q)}if(!Q)return null;try{return JSON.parse(Q)}catch(q){throw U8(`parse stored ${$}`,q)}}async setJson($,Q){try{await this.config.storage.set($,JSON.stringify(Q))}catch(q){throw U8(`write ${$}`,q)}}}import{randomBytes as PJ}from"node:crypto";import{existsSync as _Q,statSync as pj}from"node:fs";import{chmod as uj,mkdir as Z8,rename as i$,rm as f1,writeFile as z8}from"node:fs/promises";import{homedir as J$,arch as dj,platform as n$}from"node:os";import q1 from"node:path";y0();var r=C1(d1(),1),lj="https://api.github.com/repos/crafter-station/petdex/releases",ZJ=30,oj=5,zJ="desktop-v",OJ="petdex-desktop-sidecar.js";function bQ(){let $=n$(),Q=dj(),q=$==="darwin"?"darwin":$==="linux"?"linux":$==="win32"?"win32":$,V=Q==="arm64"?"arm64":Q==="x64"?"x64":Q;return{osLabel:q,archLabel:V,assetSuffix:`${q}-${V}`}}function m1(){let $=n$()==="win32"?".exe":"";if(n$()==="darwin"){let Q=["/Applications/Petdex.app/Contents/MacOS/petdex-desktop",q1.join(J$(),"Applications","Petdex.app","Contents","MacOS","petdex-desktop")];for(let q of Q)if(_Q(q))return q}return q1.join(J$(),".petdex","bin",`petdex-desktop${$}`)}function H8(){if(n$()==="darwin"){let $=["/Applications/Petdex.app/Contents/Resources/sidecar/server.js",q1.join(J$(),"Applications","Petdex.app","Contents","Resources","sidecar","server.js")];for(let Q of $)if(_Q(Q))return Q}return q1.join(J$(),".petdex","sidecar","server.js")}async function fQ($={}){let Q=$.fetchOverride??fetch,q=$.maxPages??oj,V=0;for(let Y=1;Y<=q;Y++){let X=`${lj}?per_page=${ZJ}&page=${Y}`,J=await Q(X,{headers:{Accept:"application/vnd.github+json"}});if(!J.ok)throw Error(`GitHub API ${J.status}`);let G=await J.json();if(!Array.isArray(G)||G.length===0)break;V+=G.length;let U=G.find((K)=>!K.draft&&!K.prerelease&&typeof K.tag_name==="string"&&K.tag_name.startsWith(zJ));if(U)return U;if(G.length<ZJ)break}throw Error(`No ${zJ}* release found in the last ${V} releases (scanned ${q} page(s))`)}function ij($,Q){let q=`petdex-desktop-${Q}`,V=$.assets.find((Y)=>Y.name.startsWith(q));if(!V){let Y=$.assets.map((X)=>` ${X.name}`).join(`
270
- `);throw Error(`No binary for ${Q} in ${$.tag_name}.
271
- Available:
272
- ${Y}`)}return V}function nj($){return $.assets.find((Q)=>Q.name===OJ)??null}function rj($,Q){let q=`Petdex-${Q}.dmg`;return $.assets.find((V)=>V.name===q)??null}function MJ($){let q=$.indexOf("/Contents/MacOS/");if(q===-1)return null;return $.slice(0,q)}async function hQ($,Q,q){let V=await fetch($);if(!V.ok||!V.body)throw Error(`download ${$} → ${V.status}`);let Y=Buffer.from(await V.arrayBuffer()),X=`${Q}.tmp`;try{if(await z8(X,Y),q!==void 0)await uj(X,q);if(n$()==="darwin")try{let{spawnSync:J}=await import("node:child_process");J("xattr",["-d","com.apple.quarantine",X],{stdio:"ignore"})}catch{}return{tmpPath:X,destPath:Q}}catch(J){try{await f1(X,{force:!0})}catch{}throw J}}async function aj($){let Q=[];for(let q of $){let V=null;try{let Y=`${q.destPath}.prev`;try{await i$(q.destPath,Y),V=Y}catch(X){if(X.code!=="ENOENT")throw X}await i$(q.tmpPath,q.destPath),Q.push({dest:q.destPath,backup:V})}catch(Y){if(V)try{await f1(q.destPath,{force:!0}),await i$(V,q.destPath)}catch{}for(let X of Q.reverse())try{if(X.backup)await f1(X.dest,{force:!0}),await i$(X.backup,X.dest);else await f1(X.dest,{force:!0})}catch{}for(let X of $)try{await f1(X.tmpPath,{force:!0})}catch{}throw Y}}for(let q of Q){if(!q.backup)continue;try{await f1(q.backup,{force:!0})}catch{}}}async function mQ($){let Q=bQ(),q=ij($,Q.assetSuffix),V=nj($),Y=m1(),X=H8();await Z8(q1.dirname(Y),{recursive:!0}),await Z8(q1.dirname(X),{recursive:!0});let J=[];try{if(J.push(await hQ(q.browser_download_url,Y,493)),V)J.push(await hQ(V.browser_download_url,X))}catch(G){for(let U of J)try{await f1(U.tmpPath,{force:!0})}catch{}throw G}return{binAsset:q,sidecarAsset:V,staged:J}}async function cQ($){await aj($.staged)}async function sj($){let Q=await mQ($);return await cQ(Q),{binAsset:Q.binAsset,sidecarAsset:Q.sidecarAsset}}async function BJ($,Q){let q=bQ(),V=rj($,q.archLabel);if(!V)throw Error(`No DMG asset (Petdex-${q.archLabel}.dmg) in ${$.tag_name}. App-bundle update requires a DMG; falling back is not safe.`);let{join:Y}=await import("node:path"),{tmpdir:X}=await import("node:os"),J=Y(X(),`petdex-${PJ(8).toString("hex")}-${V.name}`),G=await hQ(V.browser_download_url,J),{rename:U}=await import("node:fs/promises");await U(G.tmpPath,J);let{spawnSync:K}=await import("node:child_process"),W=K("hdiutil",["attach","-nobrowse","-quiet",J],{encoding:"utf8"});if(W.status!==0)throw Error(`hdiutil attach failed (exit ${W.status}): ${W.stderr||W.stdout||"no output"}`);let Z=tj(W.stdout)??"/Volumes/Petdex";try{let z=`${Z}/Petdex.app`,{existsSync:H}=await import("node:fs");if(!H(z))throw Error(`mounted DMG at ${Z} does not contain Petdex.app — is the release shape unchanged?`);let I=K("ditto",[z,Q],{encoding:"utf8"});if(I.status!==0)throw Error(`ditto failed (exit ${I.status}): ${I.stderr||I.stdout||"no output"}`);K("xattr",["-dr","com.apple.quarantine",Q],{encoding:"utf8"})}finally{K("hdiutil",["detach","-quiet",Z],{encoding:"utf8"});try{await f1(J,{force:!0})}catch{}}return{appBundleRoot:Q,dmgAsset:V}}function tj($){let Q=$.split(`
273
- `),q=null;for(let V of Q){let Y=V.indexOf("/Volumes/");if(Y===-1)continue;let X=V.slice(Y).trim();if(!q||X.length>q.length)q=X}return q}var ej="boba",$Z=process.env.PETDEX_URL??"https://petdex.crafter.run",QZ=new Set(["pub-94495283df974cfea5e98d6a9e3fa462.r2.dev","yu2vz9gndp.ufs.sh"]);function r$($){try{let Q=new URL($);if(Q.protocol!=="https:")return!1;return QZ.has(Q.hostname)}catch{return!1}}function NJ(){return process.env.HOME??J$()}function IJ(){return q1.join(NJ(),".petdex","pets")}function CJ(){return q1.join(NJ(),".codex","pets")}var qZ=16777216;function VZ($){for(let Q of["spritesheet.webp","spritesheet.png"]){let q=q1.join($,Q);try{let V=pj(q);if(V.isFile()&&V.size>0&&V.size<=qZ)return!0}catch{}}return!1}async function JZ(){let{readdir:$}=await import("node:fs/promises");for(let Q of[IJ(),CJ()]){let q;try{q=await $(Q)}catch{continue}for(let V of q)if(VZ(q1.join(Q,V)))return!0}return!1}async function YZ($={}){let Q=$.fetchOverride??fetch,q=$.petdexUrl??$Z,V;try{let G=await Q(`${q}/api/manifest`,{signal:AbortSignal.timeout(8000)});if(!G.ok)return null;let U=await G.json();V=Array.isArray(U?.pets)?U.pets:[]}catch{return null}if(V.length===0)return null;let Y=[],X=new Set,J=V.find((G)=>G.slug===ej);if(J)Y.push(J),X.add(J.slug);for(let G of V)if(!X.has(G.slug))Y.push(G),X.add(G.slug);for(let G of Y){let U=await XZ(G,Q);if(U)return U}return null}async function XZ($,Q){if(!r$($.spritesheetUrl)||!r$($.petJsonUrl))return null;let q=$.spritesheetUrl.endsWith(".png")?"png":"webp",V=[q1.join(IJ(),$.slug),q1.join(CJ(),$.slug)];for(let K of V)if(_Q(K))return null;let Y=async(K)=>{let W=await Q(K,{signal:AbortSignal.timeout(15000)});if(!W.ok)throw Error(`download ${K} → ${W.status}`);return W.arrayBuffer()},X,J;try{[X,J]=await Promise.all([Y($.petJsonUrl),Y($.spritesheetUrl)])}catch{return null}let G=[],U=[];try{for(let K of V){let W=`${K}.partial-${PJ(6).toString("hex")}`;await Z8(W,{recursive:!0}),G.push(W),await Promise.all([z8(q1.join(W,"pet.json"),Buffer.from(X)),z8(q1.join(W,`spritesheet.${q}`),Buffer.from(J))]),await Z8(q1.dirname(K),{recursive:!0}),await i$(W,K),G.pop(),U.push(K)}return $.slug}catch{return await Promise.all([...G.map((K)=>f1(K,{recursive:!0,force:!0})),...U.map((K)=>f1(K,{recursive:!0,force:!0}))]),null}}async function pQ(){A1(r.default.bgMagenta(r.default.white(" petdex install desktop ")));let $=bQ();u.info(`Platform: ${r.default.cyan(`${$.osLabel} ${$.archLabel}`)}`);let Q=H1();Q.start("Looking up the latest release");let q;try{q=await fQ()}catch(W){throw Q.stop(r.default.red("failed")),Error(`Could not reach GitHub. Check your connection.
274
- ${W.message}`)}Q.stop(`${r.default.green("✓")} Latest: ${r.default.bold(q.tag_name)}`);let V=H1();V.start("Downloading desktop binary and sidecar");let Y;try{Y=await sj(q)}catch(W){throw V.stop(r.default.red("failed")),W}let X=m1(),J=q1.join(J$(),".petdex","version");await z8(J,`${q.tag_name}
275
- `);let G=Y.sidecarAsset?`
276
- ${r.default.dim("•")} Sidecar at ${r.default.cyan(LJ(H8()))} (${HJ(Y.sidecarAsset.size)})`:`
277
- ${r.default.yellow("!")} No sidecar in this release. Hooks won't reach the mascot until a release ships ${OJ}.`;V.stop(`${r.default.green("✓")} Binary at ${r.default.cyan(LJ(X))} (${HJ(Y.binAsset.size)})${G}`);let U=null;if(!await JZ()){let W=H1();if(W.start("Installing a starter pet so the desktop has something to show"),U=await YZ(),U)W.stop(`${r.default.green("✓")} Starter pet: ${r.default.bold(U)}`);else W.stop(`${r.default.yellow("!")} Could not download a starter pet. Run \`petdex install <slug>\` before \`petdex desktop start\`.`)}let K=["Run it with:",` ${r.default.cyan("petdex desktop start")}`,"","Or wire it into your coding agents:",` ${r.default.cyan("petdex hooks install")}`];return T1(K.join(`
278
- `),"Next"),F1(`${r.default.green("✓")} ${q.tag_name}`),{tag:q.tag_name}}function HJ($){if($<1024)return`${$} B`;if($<1048576)return`${($/1024).toFixed(1)} KB`;return`${($/1024/1024).toFixed(1)} MB`}function LJ($){let Q=process.env.HOME;if(Q&&$.startsWith(Q))return`~${$.slice(Q.length)}`;return $}var B1=C1(d1(),1);import{execFileSync as wJ,spawn as TJ}from"node:child_process";import{existsSync as AJ,readFileSync as GZ,unlinkSync as KZ}from"node:fs";import{mkdir as WZ,writeFile as FJ}from"node:fs/promises";import{homedir as RJ}from"node:os";import z0 from"node:path";function t$(){let $=process.env.HOME??RJ();return z0.join($,".petdex","desktop.pid")}function s$(){let $=process.env.HOME??RJ();return z0.join($,".petdex","desktop.log")}function vJ(){if(!AJ(t$()))return null;let $;try{$=GZ(t$(),"utf8").trim()}catch{return null}if($.startsWith("{")){try{let q=JSON.parse($);if(typeof q.pid==="number"&&Number.isFinite(q.pid)&&q.pid>0&&typeof q.lstart==="string"&&q.lstart.length>0)return{pid:q.pid,lstart:q.lstart}}catch{}return null}let Q=Number($);if(Number.isFinite(Q)&&Q>0)return{pid:Q,lstart:""};return null}function uQ($){try{let q=wJ("ps",["-p",String($),"-o","lstart="],{encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trim();return q.length>0?q:null}catch{return null}}function xJ($){if($.lstart.length===0)return!1;let Q=uQ($.pid);return Q!==null&&Q===$.lstart}function a$(){try{KZ(t$())}catch{}}function c1(){let $=vJ();if($==null)return{state:"stopped"};if(xJ($))return{state:"running",pid:$.pid};return{state:"stale",pid:$.pid}}async function Y$(){let $=c1();if($.state==="running")return{ok:!0,pid:$.pid,alreadyRunning:!0};if($.state==="stale")a$();let Q=m1();if(!AJ(Q))return{ok:!1,reason:`petdex-desktop binary not found at ${Q}. Run \`petdex install desktop\` first.`};await WZ(z0.dirname(s$()),{recursive:!0});let q=await import("node:fs").then((U)=>U.openSync(s$(),"a")),V=await import("node:fs").then((U)=>U.openSync(s$(),"a")),Y=UZ(Q);if(Y)return jZ(Y);let X=TJ(Q,[],{detached:!0,stdio:["ignore",q,V]});if(X.unref(),!X.pid)return{ok:!1,reason:"Failed to spawn petdex-desktop"};let J=uQ(X.pid)??"",G={pid:X.pid,lstart:J};return await FJ(t$(),JSON.stringify(G)),{ok:!0,pid:X.pid,alreadyRunning:!1}}function UZ($){let Q=z0.dirname($);if(z0.basename(Q)!=="MacOS")return null;let q=z0.dirname(Q);if(z0.basename(q)!=="Contents")return null;let V=z0.dirname(q);if(!V.endsWith(".app"))return null;return V}async function jZ($){TJ("open",["-gj",$],{stdio:"ignore",detached:!0}).unref();let q=Date.now()+3000,V=null;while(Date.now()<q){if(V=ZZ(),V)break;await new Promise((J)=>setTimeout(J,100))}if(!V)return{ok:!1,reason:`Launched ${$} but couldn't find the resulting process. Check ${s$()}.`};let Y=uQ(V)??"",X={pid:V,lstart:Y};return await FJ(t$(),JSON.stringify(X)),{ok:!0,pid:V,alreadyRunning:!1}}function ZZ(){try{let $=wJ("pgrep",["-f","petdex-desktop"],{encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trim();if(!$)return null;let Q=$.split(`
279
- `).filter((V)=>V.length>0),q=Number(Q[Q.length-1]);return Number.isFinite(q)&&q>0?q:null}catch{return null}}var SJ=7777;async function X$($={}){let Q=$.sidecarPort??SJ,q=$.portWaitTimeoutMs??5000,V=c1();if(V.state==="stopped")return{ok:!1,reason:"petdex-desktop is not running"};if(V.state==="stale")return a$(),{ok:!1,reason:`petdex-desktop is not running (stale pid ${V.pid} cleared)`};let Y=V.pid,X=vJ();if(X===null||!xJ(X))return a$(),{ok:!1,reason:`petdex-desktop exited before stop (pid ${Y} no longer alive)`};try{process.kill(Y,"SIGTERM")}catch(G){if(a$(),G.code==="ESRCH"){let K=await L8(Q,{timeoutMs:q});return{ok:!0,pid:Y,portReleased:K}}return{ok:!1,reason:`Failed to signal pid ${Y}: ${G.message}`}}a$();let J=await L8(Q,{timeoutMs:q});return{ok:!0,pid:Y,portReleased:J}}async function EJ(){let $=await Y$();if(!$.ok)console.error(`${B1.default.red("✗")} ${$.reason}`),process.exit(1);if($.alreadyRunning)console.log(`${B1.default.dim("•")} petdex-desktop already running (pid ${$.pid})`);else console.log(`${B1.default.green("✓")} petdex-desktop started (pid ${$.pid})`),console.log(B1.default.dim(` log: ${s$()}`))}async function yJ(){let $=await X$();if(!$.ok)console.error(`${B1.default.dim("•")} ${$.reason}`),process.exit($.reason.includes("not running")?0:1);if($.portReleased)console.log(`${B1.default.green("✓")} stopped pid ${$.pid}`);else console.log(`${B1.default.yellow("!")} stopped pid ${$.pid}, but :${SJ} still busy`),console.log(B1.default.dim(" if 'petdex desktop start' fails with EADDRINUSE, wait a moment and retry"))}async function L8($,Q={}){let q=Q.timeoutMs??1e4,V=Q.intervalMs??100,Y=Q.host??"127.0.0.1",{createConnection:X}=await import("node:net"),J=Date.now()+q;while(Date.now()<J){if(await new Promise((U)=>{let K=X({host:Y,port:$}),W=(Z)=>{K.removeAllListeners(),K.destroy(),U(Z)};K.once("connect",()=>W(!1)),K.once("error",(Z)=>{W(Z.code==="ECONNREFUSED")}),K.setTimeout(V,()=>W(!1))}))return!0;await new Promise((U)=>setTimeout(U,V))}return!1}function kJ(){let $=c1();switch($.state){case"running":console.log(`${B1.default.green("●")} running (pid ${$.pid})`);break;case"stopped":console.log(`${B1.default.dim("○")} stopped`);break;case"stale":console.log(`${B1.default.yellow("?")} pid ${$.pid} written but not alive (run \`petdex desktop start\` to restart)`);break}}$6();var K1=C1(d1(),1);import{execSync as TZ}from"node:child_process";import{existsSync as p1,readFileSync as O8,statSync as lQ}from"node:fs";import{homedir as AZ}from"node:os";import x0 from"node:path";import{existsSync as BZ,mkdirSync as NZ,unlinkSync as IZ,writeFileSync as CZ}from"node:fs";import{homedir as wZ}from"node:os";import dQ from"node:path";function gJ(){return process.env.HOME??wZ()}function DJ(){return dQ.join(gJ(),".petdex","runtime","hooks-disabled")}function Q6(){return dQ.join(gJ(),".petdex","runtime","update-token")}function G$(){return BZ(DJ())?"off":"on"}function K$($){let Q=DJ();if($==="off")NZ(dQ.dirname(Q),{recursive:!0}),CZ(Q,`# Petdex hook killswitch.
396
+ </html>`;function XQ(Q,$){return new f(Q,$)}function dq(Q){let{expectedState:$,port:J=0,timeoutMs:q=120000,successHtml:Y=yZ,errorHtml:V=gZ}=Q,X,K=!1,W=!1,G,U,z=new Promise((F,N)=>{G=F,U=N}),j=(F)=>{if(W)return;W=!0,F.close()},H=kZ((F,N)=>{if(K){N.writeHead(410,{"Content-Type":"text/plain; charset=utf-8"}),N.end("Authentication callback already handled.");return}if(F.method!=="GET"||!F.url){N.writeHead(404,{"Content-Type":"text/plain; charset=utf-8"}),N.end("Not found");return}let T=new URL(F.url,"http://127.0.0.1");if(T.pathname!=="/callback"){N.writeHead(404,{"Content-Type":"text/plain; charset=utf-8"}),N.end("Clerk CLI auth server is waiting for /callback.");return}let P=T.searchParams.get("code"),L=T.searchParams.get("state"),A=T.searchParams.get("error"),B=T.searchParams.get("error_description")??A,O=(M,C,D)=>{if(K=!0,X)clearTimeout(X);N.writeHead(M,{"Content-Type":"text/html; charset=utf-8"}),N.end(C,()=>{if(D)U(D);else if(P&&L)G({code:P,state:L});j(H)})};if(A){O(400,V,XQ("token_exchange",`OAuth authorization failed: ${B??"unknown error"}`));return}if(L!==$){O(400,V,XQ("state_mismatch","OAuth callback state did not match."));return}if(!P){O(400,V,XQ("token_exchange","OAuth callback did not include an authorization code."));return}O(200,Y)});return new Promise((F,N)=>{H.once("error",(T)=>{N(new f("config",`Failed to start local auth callback server: ${T.message}`))}),H.listen(J,"127.0.0.1",()=>{let P=H.address().port,L=`http://127.0.0.1:${P}/callback`;X=setTimeout(()=>{if(K)return;K=!0,U(new f("timeout",`OAuth callback timed out after ${q}ms.`)),j(H)},q),F({port:P,redirectUri:L,waitForCallback:()=>z,close:()=>{if(X)clearTimeout(X);if(!K)K=!0,U(new f("timeout","OAuth callback server was closed."));j(H)}})})})}import{chmod as _Z,mkdir as bZ,readFile as hZ,writeFile as fZ}from"node:fs/promises";import{homedir as mZ}from"node:os";import{dirname as cZ,join as uZ}from"node:path";function lq(Q,$){if($ instanceof f)return $;let J=$ instanceof Error?$.message:String($);return new f("storage",`${Q}: ${J}`)}function iq(Q){return Q?.environment??"default"}function pZ(Q){return uZ(mZ(),".config","clerk-cli-auth",`${Q}.json`)}class nq{values=new Map;async get(Q){return this.values.get(Q)??null}async set(Q,$){this.values.set(Q,$)}async delete(Q){this.values.delete(Q)}}class rq{filePath;queue=Promise.resolve();constructor(Q){this.filePath=Q}enqueue(Q){let $=this.queue.then(Q,Q);return this.queue=$.catch(()=>{return}),$}async readAll(){try{let Q=await hZ(this.filePath,"utf8");if(!Q.trim())return{};let $=JSON.parse(Q);if(!$||typeof $!=="object"||Array.isArray($))return{};let J={};for(let[q,Y]of Object.entries($))if(typeof Y==="string")J[q]=Y;return J}catch(Q){if(Q.code==="ENOENT")return{};throw lq(`Failed to read credential file ${this.filePath}`,Q)}}async writeAll(Q){try{await bZ(cZ(this.filePath),{recursive:!0}),await fZ(this.filePath,`${JSON.stringify(Q,null,2)}
397
+ `,{mode:384}),await _Z(this.filePath,384)}catch($){throw lq(`Failed to write credential file ${this.filePath}`,$)}}async get(Q){return this.enqueue(async()=>{return(await this.readAll())[Q]??null})}async set(Q,$){return this.enqueue(async()=>{let J=await this.readAll();J[Q]=$,await this.writeAll(J)})}async delete(Q){return this.enqueue(async()=>{let $=await this.readAll();delete $[Q],await this.writeAll($)})}}class aq{service;environment;fallback;keyringPromise=null;constructor(Q,$,J){this.service=Q;this.environment=$;this.fallback=J}account(Q){return`${this.environment}:${Q}`}warnFallback(Q,$){let J=$ instanceof Error?$.message:String($);if(Q==="initialization"&&J.includes("Cannot find package"))return;console.warn(`Keychain ${Q} failed; falling back to file store. ${J}`)}async loadKeyring(){return this.keyringPromise??=import("@napi-rs/keyring").catch((Q)=>{return this.warnFallback("initialization",Q),null}),this.keyringPromise}async get(Q){try{let $=await this.loadKeyring();if(!$)return this.fallback.get(Q);return new $.Entry(this.service,this.account(Q)).getPassword()??await this.fallback.get(Q)}catch($){return this.warnFallback("get",$),this.fallback.get(Q)}}async set(Q,$){try{let J=await this.loadKeyring();if(!J){await this.fallback.set(Q,$);return}new J.Entry(this.service,this.account(Q)).setPassword($)}catch(J){this.warnFallback("set",J),await this.fallback.set(Q,$)}}async delete(Q){try{let $=await this.loadKeyring();if($)new $.Entry(this.service,this.account(Q)).deletePassword()}catch($){this.warnFallback("delete",$)}await this.fallback.delete(Q)}}function oq(Q){let $=iq(Q);return new rq(Q?.filePath??pZ($))}function sq(Q,$){if(Q==="memory")return new nq;if(Q==="file")return oq($);let J=oq($),q=$?.keychainService??"clerk-cli-auth",Y=iq($);return new aq(q,Y,J)}import{createHash as dZ,randomBytes as tq}from"node:crypto";function KQ(Q){return Q.toString("base64url")}function eq(){return KQ(tq(32))}async function QY(Q){return KQ(dZ("sha256").update(Q).digest())}function $Y(){return KQ(tq(32))}function JY(Q,$){return`${Q.replace(/\/+$/,"")}${$}`}async function qY(Q){if((Q.headers.get("content-type")??"").includes("application/json"))return Q.json();return Q.text()}function YY(Q,$){if(typeof Q==="string"&&Q.trim())return Q.trim();if(Q&&typeof Q==="object"){let J=Q;for(let q of["error_description","message","error"]){let Y=J[q];if(typeof Y==="string"&&Y.trim())return Y.trim()}}return $}function lZ(Q){if(typeof Q.access_token!=="string"||Q.access_token.length===0)throw new f("token_exchange","Token response did not include access_token.");let $={accessToken:Q.access_token};if(typeof Q.refresh_token==="string")$.refreshToken=Q.refresh_token;if(typeof Q.id_token==="string")$.idToken=Q.id_token;if(typeof Q.scope==="string")$.scope=Q.scope;if(typeof Q.token_type==="string")$.tokenType=Q.token_type;if(typeof Q.expires_in==="number")$.expiresAt=Date.now()+Q.expires_in*1000;return $}async function VY(Q,$){let J;try{J=await fetch(JY(Q,"/oauth/token"),{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:$.toString()})}catch(Y){throw new f("token_exchange",`Token request failed: ${Y.message}`)}let q;try{q=await qY(J)}catch(Y){throw new f("token_exchange",`Token response could not be parsed: ${Y.message}`)}if(!J.ok)throw new f("token_exchange",YY(q,`Token request failed with HTTP ${J.status}.`));if(!q||typeof q!=="object")throw new f("token_exchange","Token response was not JSON.");return lZ(q)}async function XY(Q){let $=new URLSearchParams({grant_type:"authorization_code",client_id:Q.clientId,code:Q.code,code_verifier:Q.codeVerifier,redirect_uri:Q.redirectUri});return VY(Q.issuer,$)}async function KY(Q){let $=new URLSearchParams({grant_type:"refresh_token",client_id:Q.clientId,refresh_token:Q.refreshToken});if(Q.scopes?.length)$.set("scope",Q.scopes.join(" "));return VY(Q.issuer,$)}async function GQ(Q){let $;try{$=await fetch(JY(Q.issuer,"/oauth/userinfo"),{headers:{Authorization:`Bearer ${Q.accessToken}`}})}catch(Y){throw new f("userinfo",`Userinfo request failed: ${Y.message}`)}let J;try{J=await qY($)}catch(Y){throw new f("userinfo",`Userinfo response could not be parsed: ${Y.message}`)}if(!$.ok)throw new f("userinfo",YY(J,`Userinfo request failed with HTTP ${$.status}.`));if(!J||typeof J!=="object")throw new f("userinfo","Userinfo response was not JSON.");let q=J;if(typeof q.sub!=="string"||q.sub.length===0)throw new f("userinfo","Userinfo response did not include sub.");return q}var iZ=["profile","email","openid","offline_access"];function nZ(Q){let $=Q.trim().replace(/\/+$/,"");try{let J=new URL($);if(J.protocol!=="http:"&&J.protocol!=="https:")throw Error("issuer must use http or https");return $}catch(J){throw new f("config",`issuer must be a valid URL: ${J.message}`)}}function k2(Q,$){if($ instanceof f)return $;let J=$ instanceof Error?$.message:String($);return new f("storage",`Failed to ${Q}: ${J}`)}async function rZ(Q){console.log(`Open this URL to sign in:
398
+ ${Q}`);let $=process.platform,J=$==="darwin"?"open":$==="win32"?"cmd":"xdg-open",q=$==="win32"?["/c","start","",Q]:[Q];await new Promise((Y)=>{let V=oZ(J,q,{detached:!0,stdio:"ignore"});V.once("error",()=>Y()),V.unref(),Y()})}class y2{config;constructor(Q){if(!Q.clientId)throw new f("config","clientId is required");if(!Q.issuer)throw new f("config","issuer is required");let $=Q.environment??"default",J=typeof Q.storage==="object"&&Q.storage!==null?Q.storage:sq(Q.storage??"keychain",{environment:$,keychainService:Q.keychainService});this.config={clientId:Q.clientId,issuer:nZ(Q.issuer),scopes:Q.scopes??iZ,storage:J,keychainService:Q.keychainService??"clerk-cli-auth",environment:$,callbackPort:Q.callbackPort??0,timeoutMs:Q.timeoutMs??120000,openBrowser:Q.openBrowser}}async login(){let Q=eq(),$=await QY(Q),J=$Y(),q=await dq({expectedState:J,port:this.config.callbackPort,timeoutMs:this.config.timeoutMs});try{let Y=new URL(`${this.config.issuer}/oauth/authorize`);Y.searchParams.set("response_type","code"),Y.searchParams.set("client_id",this.config.clientId),Y.searchParams.set("redirect_uri",q.redirectUri),Y.searchParams.set("scope",this.config.scopes.join(" ")),Y.searchParams.set("state",J),Y.searchParams.set("code_challenge",$),Y.searchParams.set("code_challenge_method","S256");try{await(this.config.openBrowser??rZ)(Y.toString())}catch(W){throw new f("config",`Failed to open authorization URL: ${W.message}`)}let{code:V}=await q.waitForCallback(),X=await XY({issuer:this.config.issuer,clientId:this.config.clientId,code:V,codeVerifier:Q,redirectUri:q.redirectUri});await this.setJson("tokens",X);let K=await GQ({issuer:this.config.issuer,accessToken:X.accessToken});return await this.setJson("user",K),{tokens:X,user:K}}finally{q.close()}}async getAccessToken(){let Q=await this.getTokenSet();if(!Q)return null;if((Q.expiresAt??Number.POSITIVE_INFINITY)>=Date.now()+30000)return Q.accessToken;if(!Q.refreshToken)return null;let J=await KY({issuer:this.config.issuer,clientId:this.config.clientId,refreshToken:Q.refreshToken,scopes:this.config.scopes}),q={...Q,...J,refreshToken:J.refreshToken??Q.refreshToken};return await this.setJson("tokens",q),q.accessToken}async whoami(){let Q=await this.getJson("user");if(Q)return Q;let $=await this.getAccessToken();if(!$)return null;let J=await GQ({issuer:this.config.issuer,accessToken:$});return await this.setJson("user",J),J}async logout(){try{await Promise.all([this.config.storage.delete("tokens"),this.config.storage.delete("user")])}catch(Q){throw k2("clear stored credentials",Q)}}async getTokenSet(){return this.getJson("tokens")}async getJson(Q){let $;try{$=await this.config.storage.get(Q)}catch(J){throw k2(`read ${Q}`,J)}if(!$)return null;try{return JSON.parse($)}catch(J){throw k2(`parse stored ${Q}`,J)}}async setJson(Q,$){try{await this.config.storage.set(Q,JSON.stringify($))}catch(J){throw k2(`write ${Q}`,J)}}}F8();var L0=u0(R1(),1);import{execSync as Az}from"node:child_process";import{existsSync as O0,readFileSync as u2,statSync as IQ}from"node:fs";import{homedir as Dz}from"node:os";import S1 from"node:path";import{existsSync as qz,mkdirSync as Yz,unlinkSync as Vz,writeFileSync as Xz}from"node:fs";import{homedir as Kz}from"node:os";import WQ from"node:path";function UY(){return process.env.HOME??Kz()}function jY(){return WQ.join(UY(),".petdex","runtime","hooks-disabled")}function L8(){return WQ.join(UY(),".petdex","runtime","update-token")}function I6(){return qz(jY())?"off":"on"}function T6(Q){let $=jY();if(Q==="off")Yz(WQ.dirname($),{recursive:!0}),Xz($,`# Petdex hook killswitch.
280
399
  # Hooks are DISABLED while this file exists.
281
400
  # Re-enable: petdex hooks on (or /petdex from inside your agent).
282
- `,{mode:384});else try{IZ(Q)}catch{}return $}function hJ(){return K$(G$()==="on"?"off":"on")}function q6(){return process.env.HOME??AZ()}function FZ(){return x0.join(q6(),".petdex","runtime","update-token")}function RZ(){return x0.join(q6(),".petdex","desktop.pid")}function vZ(){let $=m1();if(!p1($))return{status:"fail",label:"Desktop binary",detail:`not found at ${$}`,hint:"Run `petdex install desktop` to download it."};try{if(!(lQ($).mode&73))return{status:"fail",label:"Desktop binary",detail:`${$} exists but is not executable`,hint:`chmod +x ${$}`}}catch{return{status:"fail",label:"Desktop binary",detail:`${$} unreadable`,hint:"Reinstall: `petdex install desktop`"}}return{status:"ok",label:"Desktop binary",detail:$}}function xZ(){let $=H8();if(!p1($))return{status:"fail",label:"Sidecar bundle",detail:`not found at ${$}`,hint:"Reinstall: `petdex install desktop`"};return{status:"ok",label:"Sidecar bundle",detail:$}}async function SZ(){try{let $=await fetch("http://127.0.0.1:7777/health",{signal:AbortSignal.timeout(500)});if(!$.ok)return{status:"warn",label:"Sidecar reachable",detail:`:7777 responded ${$.status}`,hint:"Restart: `petdex desktop stop && petdex desktop start`"};let Q=await $.json().catch(()=>null);if(Q?.ok&&Q?.port===7777)return{status:"ok",label:"Sidecar reachable",detail:":7777 healthy"};return{status:"warn",label:"Sidecar reachable",detail:":7777 responded but body shape was unexpected"}}catch{return{status:"info",label:"Sidecar reachable",detail:"not running (this is fine if you haven't started the desktop)",hint:"Start with `petdex desktop start`"}}}function EZ(){let $=RZ();if(!p1($))return{status:"info",label:"PID file",detail:"not present (desktop not running)"};let Q;try{Q=O8($,"utf8").trim()}catch{return{status:"warn",label:"PID file",detail:`unreadable at ${$}`,hint:`Delete it: rm ${$}`}}if(!Q.startsWith("{"))return{status:"warn",label:"PID file",detail:"legacy bare-pid format detected",hint:"Run `petdex desktop start` to rewrite it in the new format."};try{let q=JSON.parse(Q);if(typeof q.pid!=="number"||typeof q.lstart!=="string")return{status:"warn",label:"PID file",detail:"unexpected JSON shape",hint:`Delete it: rm ${$}`};return{status:"ok",label:"PID file",detail:`pid ${q.pid}, started ${q.lstart}`}}catch{return{status:"warn",label:"PID file",detail:"JSON parse failed",hint:`Delete it: rm ${$}`}}}function yZ(){let $=FZ();if(!p1($))return{status:"info",label:"Update token",detail:"absent (will be created when sidecar starts)"};try{if(O8($,"utf8").trim().length<16)return{status:"warn",label:"Update token",detail:"present but suspiciously short",hint:"Stop the desktop and run `petdex desktop start` to regenerate."};let V=lQ($).mode&511;if(V!==384)return{status:"warn",label:"Update token",detail:`present, mode ${V.toString(8)} (expected 600)`,hint:`chmod 600 ${$}`};return{status:"ok",label:"Update token",detail:"present, mode 600"}}catch(Q){return{status:"warn",label:"Update token",detail:`read failed: ${Q.message}`}}}function kZ(){if(G$()==="off")return{status:"warn",label:"Killswitch",detail:"DISABLED. Agent hooks are short-circuited.",hint:"Re-enable with `petdex hooks on` or `/petdex on` from inside your agent."};return{status:"ok",label:"Killswitch",detail:"hooks enabled"}}function gZ(){let $=[];for(let Q of e1){let q=p1(Q.configFile),V=p1(Q.slashCommandPath);if(!p1(Q.configDir)){$.push({status:"info",label:Q.displayName,detail:"not installed on this machine"});continue}let Y=!1;if(q)try{let X=O8(Q.configFile,"utf8");Y=X.includes("127.0.0.1:7777/state")||X.includes("/state")}catch{Y=!1}if(!Y){$.push({status:"warn",label:Q.displayName,detail:"petdex hook NOT detected",hint:"Run `petdex hooks install`"});continue}if(!V){$.push({status:"warn",label:Q.displayName,detail:"hook installed, but /petdex slash command missing",hint:"Re-run `petdex hooks install` to add the slash command."});continue}$.push({status:"ok",label:Q.displayName,detail:"hooks + /petdex installed"})}return $}function DZ(){let $=x0.join(q6(),".codex","config.toml");if(!p1($))return{status:"info",label:"Codex codex_hooks flag",detail:"config.toml absent (Codex not installed?)"};try{let Q=O8($,"utf8");if(/\[features\][\s\S]*?codex_hooks\s*=\s*true/.test(Q))return{status:"ok",label:"Codex codex_hooks flag",detail:"[features] codex_hooks = true"};return{status:"warn",label:"Codex codex_hooks flag",detail:"missing or set to non-true",hint:"Re-run `petdex hooks install` and accept the auto-fix prompt."}}catch{return{status:"warn",label:"Codex codex_hooks flag",detail:"config.toml unreadable"}}}function hZ(){let $=[x0.join(q6(),".petdex","pets"),x0.join(q6(),".codex","pets")],Q=0;for(let q of $){if(!p1(q))continue;try{let{readdirSync:V}=b("node:fs"),Y=V(q);for(let X of Y){let J=x0.join(q,X);for(let G of["spritesheet.webp","spritesheet.png"]){let U=x0.join(J,G);if(!p1(U))continue;try{let K=lQ(U);if(K.size>0&&K.size<=16777216){Q+=1;break}}catch{}}}}catch{}}if(Q===0)return{status:"fail",label:"Installed pets",detail:"no usable pets in ~/.petdex/pets or ~/.codex/pets",hint:"Install one with `petdex install <slug>`"};return{status:"ok",label:"Installed pets",detail:`${Q} usable spritesheet(s) on disk`}}function _Z($){switch($){case"ok":return K1.default.green("✓");case"warn":return K1.default.yellow("!");case"fail":return K1.default.red("✗");case"info":return K1.default.dim("○")}}function N1($){let Q=$.detail?` ${K1.default.dim($.detail)}`:"";if(console.log(` ${_Z($.status)} ${K1.default.bold($.label)}${Q}`),$.hint)console.log(` ${K1.default.cyan("→")} ${$.hint}`)}async function _J(){console.log(K1.default.bgMagenta(K1.default.white(" petdex doctor "))),console.log(""),console.log(K1.default.bold("Install")),N1(vZ()),N1(xZ()),N1(hZ()),console.log(""),console.log(K1.default.bold("Runtime")),N1(await SZ()),N1(EZ()),N1(yZ()),N1(kZ()),console.log(""),console.log(K1.default.bold("Agents"));for(let Q of gZ())N1(Q);N1(DZ()),console.log(""),console.log(K1.default.bold("Network"));let $=null;try{$=TZ("lsof -nP -iTCP:7777 -sTCP:LISTEN 2>/dev/null || true",{encoding:"utf8"}).trim()}catch{$=null}if($===null)N1({status:"info",label:":7777 listener",detail:"lsof unavailable"});else if($.length===0)N1({status:"info",label:":7777 listener",detail:"nothing bound (sidecar offline)"});else{let Q=$.split(`
283
- `).length-1;N1({status:Q===1?"ok":"warn",label:":7777 listener",detail:Q===1?"1 process bound":`${Q} processes bound`,hint:Q>1?"Multiple sidecars contending for the same port. Stop both and start fresh.":void 0})}console.log("")}y0();var D=C1(d1(),1);import{existsSync as qz,readFileSync as nJ}from"node:fs";import{writeFile as oJ}from"node:fs/promises";import{homedir as rJ}from"node:os";import aJ from"node:path";var B8=7777,Vz="x-petdex-update-token",Jz=aJ.join(rJ(),".petdex","runtime","update-token"),N8=aJ.join(rJ(),".petdex","version");async function Yz($={}){let Q=$.port??B8,q=$.timeoutMs??2000,V=$.tokenPath??Jz,Y;try{Y=nJ(V,"utf8").trim()}catch{return!1}if(!Y)return!1;let X=new AbortController,J=setTimeout(()=>X.abort(),q);try{return(await fetch(`http://127.0.0.1:${Q}/update/handoff`,{method:"POST",headers:{[Vz]:Y},signal:X.signal})).ok}catch{return!1}finally{clearTimeout(J)}}function Xz(){if(!qz(N8))return null;try{return nJ(N8,"utf8").trim()||null}catch{return null}}async function sJ($=[]){let Q=$.includes("--force"),q=$.includes("--silent"),V=(P)=>{if(q)console.log(`[petdex update] ${P}`);else A1(D.default.bgMagenta(D.default.white(` ${P} `)))},Y=(P)=>{if(q)console.log(P);else u.info(P)},X=(P)=>{if(q)console.warn(P);else u.warn(P)},J=(P)=>{if(q)console.log(P);else F1(P)},G=()=>{if(q)return{start:(L)=>console.log(L),stop:(L)=>console.log(L)};let P=H1();return{start:(L)=>P.start(L),stop:(L)=>P.stop(L)}};V("petdex update");let U=Xz();Y(U?`Installed: ${q?U:D.default.cyan(U)}`:"No installed version recorded - treating as fresh install.");let K=G();K.start("Checking GitHub for the latest release");let W;try{W=await fQ()}catch(P){throw K.stop(q?"failed":D.default.red("failed")),Error(`Could not reach GitHub. Check your connection.
284
- ${P.message}`)}if(K.stop(q?`Latest: ${W.tag_name}`:`${D.default.green("✓")} Latest: ${D.default.bold(W.tag_name)}`),!Q&&U&&U===W.tag_name){J(q?"Already up to date.":`${D.default.green("✓")} Already up to date.`);return}let Z=m1(),z=MJ(Z),H=c1().state==="running";if(z){if(H)Y(q?"Stopping running petdex-desktop":`${D.default.dim("•")} Stopping running petdex-desktop`),await X$();let P=G();P.start(`Downloading ${W.tag_name} DMG`);let L;try{L=await BJ(W,z)}catch(O){throw P.stop(q?"failed":D.default.red("failed")),O}P.stop(q?`Replaced ${z} (${M8(L.dmgAsset.size)})`:`${D.default.green("✓")} Replaced ${D.default.bold(z)} (${M8(L.dmgAsset.size)})`),await oJ(N8,`${W.tag_name}
285
- `),await iJ(Y,X,q);let C=U?`${U} → ${W.tag_name}`:W.tag_name;J(q?`${C} (relaunch Petdex from /Applications to use it)`:`${D.default.green("✓")} ${C}
286
- ${D.default.dim(" Relaunch Petdex from /Applications to use it.")}`);return}let I=G();I.start(`Downloading ${W.tag_name}`);let N;try{N=await mQ(W)}catch(P){throw I.stop(q?"failed":D.default.red("failed")),P}if(I.stop(q?`Downloaded ${W.tag_name} (${M8(N.binAsset.size)})`:`${D.default.green("✓")} Downloaded ${D.default.bold(W.tag_name)} (${M8(N.binAsset.size)})`),H)Y(q?"Stopping running petdex-desktop":`${D.default.dim("•")} Stopping running petdex-desktop`),await X$();if(await cQ(N),await oJ(N8,`${W.tag_name}
287
- `),H){Y(q?"Asking sidecar to release port":`${D.default.dim("•")} Asking sidecar to release port`);let P=await Yz();if(Y(q?P?"Sidecar acknowledged handoff":"Sidecar handoff unavailable, falling back to port wait":P?`${D.default.dim("•")} Sidecar acknowledged handoff`:`${D.default.dim("•")} Sidecar handoff unavailable, falling back to port wait`),!await L8(B8,{timeoutMs:1e4})){X(q?`Port ${B8} still in use after 10s. Run 'petdex desktop stop && petdex desktop start' to recover.`:`${D.default.yellow("!")} Port ${B8} still in use after 10s. Run \`petdex desktop stop && petdex desktop start\` to recover.`);return}Y(q?"Restarting petdex-desktop":`${D.default.dim("•")} Restarting petdex-desktop`);let C=await Y$();if(C.ok)Y(q?`Restarted (pid ${C.pid})`:`${D.default.green("✓")} Restarted (pid ${C.pid})`);else X(q?`Could not restart: ${C.reason}. Run 'petdex desktop start' manually.`:`${D.default.yellow("!")} Could not restart: ${C.reason}. Run \`petdex desktop start\` manually.`)}await iJ(Y,X,q);let w=U?`${U} → ${W.tag_name}`:W.tag_name;J(q?w:`${D.default.green("✓")} ${w}`)}async function iJ($,Q,q){try{let{runRefresh:V}=await Promise.resolve().then(() => (Qq(),$q)),Y=await V();if(Y.refreshed.length>0)$(q?`Refreshed hooks for: ${Y.refreshed.join(", ")}`:`Refreshed hooks for ${D.default.cyan(Y.refreshed.join(", "))}`)}catch(V){Q(`Hook refresh failed: ${V.message}`)}}function M8($){if($<1024)return`${$} B`;if($<1048576)return`${($/1024).toFixed(1)} KB`;return`${($/1024/1024).toFixed(1)} MB`}eQ();y0();$6();var e=C1(d1(),1);import{existsSync as J6}from"node:fs";import{readFile as eJ,rm as $Y,writeFile as QY}from"node:fs/promises";import Gz from"node:path";oQ();async function qY($={}){A1(e.default.bgMagenta(e.default.white(" petdex hooks uninstall ")));let q=(await Kz()).filter((X)=>X.installed);if(q.length===0)return F1(e.default.dim("No agent configs found. Nothing to uninstall.")),{uninstalledAgents:[]};let V=[],Y=[];for(let{agent:X}of q)try{let J=await Wz(X);if(J.removed){Y.push(X.id);let G=J.backupPath?` ${e.default.dim(`(backup: ${Gz.basename(J.backupPath)})`)}`:"";V.push(` ${e.default.green("✓")} ${e.default.bold(X.displayName)}${G}`)}else V.push(` ${e.default.dim("•")} ${e.default.bold(X.displayName)} ${e.default.dim("(no petdex entries found)")}`);await fJ(X)}catch(J){V.push(` ${e.default.red("✗")} ${e.default.bold(X.displayName)} ${e.default.red(J instanceof Error?J.message:String(J))}`)}if(T1(V.join(`
288
- `),"Done"),$.removeToken)try{await $Y(Q6(),{force:!0}),u.info(`${e.default.green("✓")} Removed ${Q6()}`)}catch{}else if(J6(Q6()))u.info(e.default.dim(`Token file at ${Q6()} kept. Pass --remove-token to delete it.`));return F1(`${e.default.green("✓")} Done. Run ${e.default.cyan("petdex hooks install")} to wire petdex back in.`),{uninstalledAgents:Y}}async function Kz(){return Promise.all(e1.map(async($)=>({agent:$,installed:J6($.configDir)})))}async function Wz($){if($.id==="opencode"){if(!J6($.configFile))return{removed:!1,backupPath:null};let X=await tJ($.configFile);return await $Y($.configFile,{force:!0}),{removed:!0,backupPath:X}}if(!J6($.configFile))return{removed:!1,backupPath:null};let Q;try{Q=await eJ($.configFile,"utf8")}catch(X){throw Error(`Could not read ${$.configFile}: ${X.message}`)}let q;try{q=JSON.parse(Q)}catch(X){throw Error(`Refusing to overwrite ${$.configFile}: invalid JSON (${X.message}). Hand-edit the file to remove petdex entries.`)}let V=Uz(q);if(!V.changed)return{removed:!1,backupPath:null};let Y=await tJ($.configFile);return await QY($.configFile,`${JSON.stringify(V.value,null,2)}
289
- `,"utf8"),{removed:!0,backupPath:Y}}function Uz($){let Q={...$},q=Q.hooks;if(!q||typeof q!=="object"||Array.isArray(q))return{value:Q,changed:!1};let V=!1,Y={};for(let[X,J]of Object.entries(q)){if(!Array.isArray(J)){Y[X]=J;continue}let G=J.filter((U)=>!jz(U));if(G.length!==J.length)V=!0;if(G.length>0)Y[X]=G}if(!V)return{value:Q,changed:!1};if(Object.keys(Y).length===0){let{hooks:X,...J}=Q;return{value:J,changed:!0}}return Q.hooks=Y,{value:Q,changed:!0}}function jz($){if(typeof $!=="object"||$==null)return!1;return Zz($).some((q)=>q.includes(`localhost:${e$}/state`)||q.includes(v0))}function Zz($){let Q=[];function q(V){if(typeof V==="string"){Q.push(V);return}if(Array.isArray(V)){for(let Y of V)q(Y);return}if(typeof V==="object"&&V!=null)for(let Y of Object.values(V))q(Y)}return q($),Q}async function tJ($){if(!J6($))return null;let Q=new Date().toISOString().replace(/[:.]/g,"-"),q=`${$}.${Q}.bak`,V=await eJ($);return await QY(q,V),q}import{spawn as zz}from"node:child_process";import{randomUUID as VY}from"node:crypto";import{existsSync as Hz,mkdirSync as Lz,readFileSync as Pz,writeFileSync as Oz}from"node:fs";import{homedir as Mz}from"node:os";import JY from"node:path";function I8(){let $=process.env.HOME??Mz();return JY.join($,".petdex","telemetry.json")}var Bz=process.env.PETDEX_TELEMETRY_URL??"https://petdex.crafter.run/api/telemetry/event",Nz=2000;function C8(){if(!Hz(I8()))return{kind:"missing"};let $;try{$=Pz(I8(),"utf8")}catch(Q){return{kind:"error",reason:`read failed: ${Q.message}`}}try{return{kind:"ok",config:JSON.parse($)}}catch(Q){return{kind:"error",reason:`parse failed: ${Q.message}`}}}function qq($){try{return Lz(JY.dirname(I8()),{recursive:!0}),Oz(I8(),`${JSON.stringify($,null,2)}
290
- `),!0}catch{return!1}}function YY(){if(process.env.PETDEX_TELEMETRY==="0")return null;let $=C8();if($.kind==="ok")return $.config;if($.kind==="error")return null;let Q={install_id:VY(),enabled:!0,notice_seen:!1,first_seen:new Date().toISOString()};return qq(Q)?Q:null}function XY(){if(process.env.PETDEX_TELEMETRY==="0")return!1;let $=C8();if($.kind==="missing")return!0;if($.kind==="error")return!1;return $.config.enabled}function GY($){let Q=C8(),q;if(Q.kind==="ok")q=Q.config,q.enabled=$;else q={install_id:VY(),enabled:$,notice_seen:!0,first_seen:new Date().toISOString()};return qq(q)}function KY(){let $=C8();return{enabled:XY(),install_id:$.kind==="ok"?$.config.install_id:null}}function WY(){if(process.env.PETDEX_TELEMETRY==="0")return;let $=YY();if(!$)return;if($.notice_seen)return;console.log(["","petdex collects anonymous usage stats (install volume, OS, agents wired up).","No personal data, no file contents. Disable any time:"," petdex telemetry off","Details: https://petdex.crafter.run/legal/telemetry",""].join(`
291
- `)),$.notice_seen=!0,qq($)}function Y6($,Q={}){if(!XY())return;let q=YY();if(!q)return;let V=JSON.stringify({install_id:q.install_id,event:$,...Q});try{let Y=`
401
+ `,{mode:384});else try{Vz($)}catch{}return Q}function ZY(){return T6(I6()==="on"?"off":"on")}import{randomBytes as FY}from"node:crypto";import{existsSync as zQ,statSync as Gz}from"node:fs";import{chmod as Wz,mkdir as C6,rename as O8,rm as t0,writeFile as _2}from"node:fs/promises";import{homedir as b2,arch as Uz,platform as A6}from"node:os";import Q0 from"node:path";a1();var l=u0(R1(),1),jz="https://api.github.com/repos/crafter-station/petdex/releases",zY=30,Zz=5,HY="desktop-v",LY="petdex-desktop-sidecar.js";function HQ(){let Q=A6(),$=Uz(),J=Q==="darwin"?"darwin":Q==="linux"?"linux":Q==="win32"?"win32":Q,q=$==="arm64"?"arm64":$==="x64"?"x64":$;return{osLabel:J,archLabel:q,assetSuffix:`${J}-${q}`}}function E0(){let Q=A6()==="win32"?".exe":"";if(A6()==="darwin"){let $=e0(),J=["/Applications/Petdex.app/Contents/MacOS/petdex-desktop",Q0.join($,"Applications","Petdex.app","Contents","MacOS","petdex-desktop")];for(let q of J)if(zQ(q))return q}return Q0.join(b2(),".petdex","bin",`petdex-desktop${Q}`)}function h2(){if(A6()==="darwin"){let Q=e0(),$=["/Applications/Petdex.app/Contents/Resources/sidecar/server.js",Q0.join(Q,"Applications","Petdex.app","Contents","Resources","sidecar","server.js")];for(let J of $)if(zQ(J))return J}return Q0.join(b2(),".petdex","sidecar","server.js")}async function FQ(Q={}){let $=Q.fetchOverride??fetch,J=Q.maxPages??Zz,q=0;for(let Y=1;Y<=J;Y++){let V=`${jz}?per_page=${zY}&page=${Y}`,X=await $(V,{headers:{Accept:"application/vnd.github+json"}});if(!X.ok)throw Error(`GitHub API ${X.status}`);let K=await X.json();if(!Array.isArray(K)||K.length===0)break;q+=K.length;let W=K.find((G)=>!G.draft&&!G.prerelease&&typeof G.tag_name==="string"&&G.tag_name.startsWith(HY));if(W)return W;if(K.length<zY)break}throw Error(`No ${HY}* release found in the last ${q} releases (scanned ${J} page(s))`)}function zz(Q){return Q.assets.find(($)=>$.name===LY)??null}function f2(Q,$=HQ()){let J=`petdex-desktop-${$.assetSuffix}`,q=Q.assets.find((Y)=>Y.name===J)??Q.assets.find((Y)=>Y.name.startsWith(J));if(q)return{kind:"bare",target:$,binAsset:q,sidecarAsset:zz(Q)};if($.osLabel==="darwin"){let Y=OY(Q,$.archLabel);if(Y)return{kind:"macos-dmg",target:$,dmgAsset:Y}}if($.osLabel==="linux")return{kind:"unsupported",target:$,reason:`No Linux desktop binary for ${$.archLabel} in ${Q.tag_name}.`,hint:"Hooks-only setup still works on Linux: run `petdex hooks install`. Desktop Linux support is tracked in issue #296."};return{kind:"unsupported",target:$,reason:`No desktop binary for ${$.assetSuffix} in ${Q.tag_name}.`,hint:"Run `petdex hooks install` for hooks-only setup, or download a supported desktop build from https://petdex.crafter.run/download."}}function m2(Q){if(Q.kind!=="unsupported")return Error("Desktop install plan is supported");return Error(`${Q.reason}
402
+ ${Q.hint}`)}function OY(Q,$){let J=`Petdex-${$}.dmg`;return Q.assets.find((q)=>q.name===J)??null}function NY(Q){let J=Q.indexOf("/Contents/MacOS/");if(J===-1)return null;return Q.slice(0,J)}async function ZQ(Q,$,J){let q=await fetch(Q);if(!q.ok||!q.body)throw Error(`download ${Q} → ${q.status}`);let Y=Buffer.from(await q.arrayBuffer()),V=`${$}.tmp`;try{if(await _2(V,Y),J!==void 0)await Wz(V,J);if(A6()==="darwin")try{let{spawnSync:X}=await import("node:child_process");X("xattr",["-d","com.apple.quarantine",V],{stdio:"ignore"})}catch{}return{tmpPath:V,destPath:$}}catch(X){try{await t0(V,{force:!0})}catch{}throw X}}async function Hz(Q){let $=[];for(let J of Q){let q=null;try{let Y=`${J.destPath}.prev`;try{await O8(J.destPath,Y),q=Y}catch(V){if(V.code!=="ENOENT")throw V}await O8(J.tmpPath,J.destPath),$.push({dest:J.destPath,backup:q})}catch(Y){if(q)try{await t0(J.destPath,{force:!0}),await O8(q,J.destPath)}catch{}for(let V of $.reverse())try{if(V.backup)await t0(V.dest,{force:!0}),await O8(V.backup,V.dest);else await t0(V.dest,{force:!0})}catch{}for(let V of Q)try{await t0(V.tmpPath,{force:!0})}catch{}throw Y}}for(let J of $){if(!J.backup)continue;try{await t0(J.backup,{force:!0})}catch{}}}async function LQ(Q){let $=f2(Q);if($.kind==="unsupported")throw m2($);if($.kind==="macos-dmg")throw Error(`No bare desktop binary for ${$.target.assetSuffix} in ${Q.tag_name}. Use the DMG install path instead.`);let{binAsset:J,sidecarAsset:q}=$,Y=E0(),V=h2();await C6(Q0.dirname(Y),{recursive:!0}),await C6(Q0.dirname(V),{recursive:!0});let X=[];try{if(X.push(await ZQ(J.browser_download_url,Y,493)),q)X.push(await ZQ(q.browser_download_url,V))}catch(K){for(let W of X)try{await t0(W.tmpPath,{force:!0})}catch{}throw K}return{binAsset:J,sidecarAsset:q,staged:X}}async function OQ(Q){await Hz(Q.staged)}async function Fz(Q){let $=await LQ(Q);return await OQ($),{binAsset:$.binAsset,sidecarAsset:$.sidecarAsset}}async function NQ(Q,$){let J=HQ(),q=OY(Q,J.archLabel);if(!q)throw Error(`No DMG asset (Petdex-${J.archLabel}.dmg) in ${Q.tag_name}. App-bundle update requires a DMG; falling back is not safe.`);let{join:Y}=await import("node:path"),{tmpdir:V}=await import("node:os"),X=Y(V(),`petdex-${FY(8).toString("hex")}-${q.name}`),K=await ZQ(q.browser_download_url,X),{rename:W}=await import("node:fs/promises");await W(K.tmpPath,X);let{spawnSync:G}=await import("node:child_process"),U=G("hdiutil",["attach","-nobrowse","-quiet",X],{encoding:"utf8"});if(U.status!==0)throw Error(`hdiutil attach failed (exit ${U.status}): ${U.stderr||U.stdout||"no output"}`);let z=Lz(U.stdout)??"/Volumes/Petdex";try{let j=`${z}/Petdex.app`,{existsSync:H}=await import("node:fs");if(!H(j))throw Error(`mounted DMG at ${z} does not contain Petdex.app — is the release shape unchanged?`);let F=G("ditto",[j,$],{encoding:"utf8"});if(F.status!==0)throw Error(`ditto failed (exit ${F.status}): ${F.stderr||F.stdout||"no output"}`);G("xattr",["-dr","com.apple.quarantine",$],{encoding:"utf8"})}finally{G("hdiutil",["detach","-quiet",z],{encoding:"utf8"});try{await t0(X,{force:!0})}catch{}}return{appBundleRoot:$,dmgAsset:q}}function c2(){return Q0.join(e0(),"Applications","Petdex.app")}async function BQ(Q,$=c2()){return await C6(Q0.dirname($),{recursive:!0}),NQ(Q,$)}function Lz(Q){let $=Q.split(`
403
+ `),J=null;for(let q of $){let Y=q.indexOf("/Volumes/");if(Y===-1)continue;let V=q.slice(Y).trim();if(!J||V.length>J.length)J=V}return J}var Oz="boba",Nz=process.env.PETDEX_URL??"https://petdex.crafter.run",Bz=new Set(["pub-94495283df974cfea5e98d6a9e3fa462.r2.dev","yu2vz9gndp.ufs.sh"]);function N8(Q){try{let $=new URL(Q);if($.protocol!=="https:")return!1;return Bz.has($.hostname)}catch{return!1}}function e0(){if(A6()==="win32")return process.env.USERPROFILE??process.env.HOME??b2();return process.env.HOME??process.env.USERPROFILE??b2()}function BY(){return Q0.join(e0(),".petdex","pets")}function MY(){return Q0.join(e0(),".codex","pets")}var Mz=16777216;function Pz(Q){for(let $ of["spritesheet.webp","spritesheet.png"]){let J=Q0.join(Q,$);try{let q=Gz(J);if(q.isFile()&&q.size>0&&q.size<=Mz)return!0}catch{}}return!1}async function Iz(){let{readdir:Q}=await import("node:fs/promises");for(let $ of[BY(),MY()]){let J;try{J=await Q($)}catch{continue}for(let q of J)if(Pz(Q0.join($,q)))return!0}return!1}async function MQ(){if(await Iz())return{status:"present"};let Q=await Tz();return Q?{status:"installed",slug:Q}:{status:"missing"}}async function Tz(Q={}){let $=Q.fetchOverride??fetch,J=Q.petdexUrl??Nz,q;try{let K=await $(`${J}/api/manifest`,{signal:AbortSignal.timeout(8000)});if(!K.ok)return null;let W=await K.json();q=Array.isArray(W?.pets)?W.pets:[]}catch{return null}if(q.length===0)return null;let Y=[],V=new Set,X=q.find((K)=>K.slug===Oz);if(X)Y.push(X),V.add(X.slug);for(let K of q)if(!V.has(K.slug))Y.push(K),V.add(K.slug);for(let K of Y){let W=await Cz(K,$);if(W)return W}return null}async function Cz(Q,$){if(!N8(Q.spritesheetUrl)||!N8(Q.petJsonUrl))return null;let J=Q.spritesheetUrl.endsWith(".png")?"png":"webp",q=[Q0.join(BY(),Q.slug),Q0.join(MY(),Q.slug)];for(let G of q)if(zQ(G))return null;let Y=async(G)=>{let U=await $(G,{signal:AbortSignal.timeout(15000)});if(!U.ok)throw Error(`download ${G} → ${U.status}`);return U.arrayBuffer()},V,X;try{[V,X]=await Promise.all([Y(Q.petJsonUrl),Y(Q.spritesheetUrl)])}catch{return null}let K=[],W=[];try{for(let G of q){let U=`${G}.partial-${FY(6).toString("hex")}`;await C6(U,{recursive:!0}),K.push(U),await Promise.all([_2(Q0.join(U,"pet.json"),Buffer.from(V)),_2(Q0.join(U,`spritesheet.${J}`),Buffer.from(X))]),await C6(Q0.dirname(G),{recursive:!0}),await O8(U,G),K.pop(),W.push(G)}return Q.slug}catch{return await Promise.all([...K.map((G)=>t0(G,{recursive:!0,force:!0})),...W.map((G)=>t0(G,{recursive:!0,force:!0}))]),null}}async function PQ(){A0(l.default.bgMagenta(l.default.white(" petdex install desktop ")));let Q=HQ();o.info(`Platform: ${l.default.cyan(`${Q.osLabel} ${Q.archLabel}`)}`);let $=H0();$.start("Looking up the latest release");let J;try{J=await FQ()}catch(W){throw $.stop(l.default.red("failed")),Error(`Could not reach GitHub. Check your connection.
404
+ ${W.message}`)}$.stop(`${l.default.green("✓")} Latest: ${l.default.bold(J.tag_name)}`);let q=f2(J);if(q.kind==="unsupported")throw m2(q);if(q.kind==="bare"){let W=H0();W.start("Downloading desktop binary and sidecar");let G;try{G=await Fz(J)}catch(j){throw W.stop(l.default.red("failed")),j}let U=E0(),z=G.sidecarAsset?`
405
+ ${l.default.dim("•")} Sidecar at ${l.default.cyan(jQ(h2()))} (${UQ(G.sidecarAsset.size)})`:`
406
+ ${l.default.yellow("!")} No sidecar in this release. Hooks won't reach the mascot until a release ships ${LY}.`;W.stop(`${l.default.green("✓")} Binary at ${l.default.cyan(jQ(U))} (${UQ(G.binAsset.size)})${z}`)}else{let W=H0();W.start("Installing macOS app from DMG");try{await BQ(J)}catch(G){throw W.stop(l.default.red("failed")),G}W.stop(`${l.default.green("✓")} App at ${l.default.cyan(jQ(c2()))} (${UQ(q.dmgAsset.size)})`)}let Y=Q0.join(e0(),".petdex","version");await C6(Q0.dirname(Y),{recursive:!0}),await _2(Y,`${J.tag_name}
407
+ `);let V=H0();V.start("Checking starter pet");let X=await MQ();if(X.status==="installed")V.stop(`${l.default.green("✓")} Starter pet: ${l.default.bold(X.slug)}`);else if(X.status==="present")V.stop(`${l.default.green("✓")} Pet library ready`);else V.stop(`${l.default.yellow("!")} Could not download a starter pet. Run \`petdex install <slug>\` before \`petdex desktop start\`.`);let K=["Run it with:",` ${l.default.cyan("petdex desktop start")}`,"","Or wire it into your coding agents:",` ${l.default.cyan("petdex hooks install")}`];return _0(K.join(`
408
+ `),"Next"),D0(`${l.default.green("✓")} ${J.tag_name}`),{tag:J.tag_name}}function UQ(Q){if(Q<1024)return`${Q} B`;if(Q<1048576)return`${(Q/1024).toFixed(1)} KB`;return`${(Q/1024/1024).toFixed(1)} MB`}function jQ(Q){let $=e0();if(Q.startsWith($))return`~${Q.slice($.length)}`;return Q}function B8(){return process.env.HOME??Dz()}function wz(){return S1.join(B8(),".petdex","runtime","update-token")}function Rz(){return S1.join(B8(),".petdex","desktop.pid")}function xz(){let Q=E0();if(!O0(Q))return{status:"fail",label:"Desktop binary",detail:`not found at ${Q}`,hint:"Run `petdex install desktop` to download it."};try{if(!(IQ(Q).mode&73))return{status:"fail",label:"Desktop binary",detail:`${Q} exists but is not executable`,hint:`chmod +x ${Q}`}}catch{return{status:"fail",label:"Desktop binary",detail:`${Q} unreadable`,hint:"Reinstall: `petdex install desktop`"}}return{status:"ok",label:"Desktop binary",detail:Q}}function vz(){let Q=h2();if(!O0(Q))return{status:"fail",label:"Sidecar bundle",detail:`not found at ${Q}`,hint:"Reinstall: `petdex install desktop`"};return{status:"ok",label:"Sidecar bundle",detail:Q}}async function Ez(){try{let Q=await fetch("http://127.0.0.1:7777/health",{signal:AbortSignal.timeout(500)});if(!Q.ok)return{status:"warn",label:"Sidecar reachable",detail:`:7777 responded ${Q.status}`,hint:"Restart: `petdex desktop stop && petdex desktop start`"};let $=await Q.json().catch(()=>null);if($?.ok&&$?.port===7777)return{status:"ok",label:"Sidecar reachable",detail:":7777 healthy"};return{status:"warn",label:"Sidecar reachable",detail:":7777 responded but body shape was unexpected"}}catch{return{status:"info",label:"Sidecar reachable",detail:"not running (this is fine if you haven't started the desktop)",hint:"Start with `petdex desktop start`"}}}function Sz(){let Q=Rz();if(!O0(Q))return{status:"info",label:"PID file",detail:"not present (desktop not running)"};let $;try{$=u2(Q,"utf8").trim()}catch{return{status:"warn",label:"PID file",detail:`unreadable at ${Q}`,hint:`Delete it: rm ${Q}`}}if(!$.startsWith("{"))return{status:"warn",label:"PID file",detail:"legacy bare-pid format detected",hint:"Run `petdex desktop start` to rewrite it in the new format."};try{let J=JSON.parse($);if(typeof J.pid!=="number"||typeof J.lstart!=="string")return{status:"warn",label:"PID file",detail:"unexpected JSON shape",hint:`Delete it: rm ${Q}`};return{status:"ok",label:"PID file",detail:`pid ${J.pid}, started ${J.lstart}`}}catch{return{status:"warn",label:"PID file",detail:"JSON parse failed",hint:`Delete it: rm ${Q}`}}}function kz(){let Q=wz();if(!O0(Q))return{status:"info",label:"Update token",detail:"absent (will be created when sidecar starts)"};try{if(u2(Q,"utf8").trim().length<16)return{status:"warn",label:"Update token",detail:"present but suspiciously short",hint:"Stop the desktop and run `petdex desktop start` to regenerate."};let q=IQ(Q).mode&511;if(q!==384)return{status:"warn",label:"Update token",detail:`present, mode ${q.toString(8)} (expected 600)`,hint:`chmod 600 ${Q}`};return{status:"ok",label:"Update token",detail:"present, mode 600"}}catch($){return{status:"warn",label:"Update token",detail:`read failed: ${$.message}`}}}function yz(){if(I6()==="off")return{status:"warn",label:"Killswitch",detail:"DISABLED. Agent hooks are short-circuited.",hint:"Re-enable with `petdex hooks on` or `/petdex on` from inside your agent."};return{status:"ok",label:"Killswitch",detail:"hooks enabled"}}function gz(){let Q=[];for(let $ of z1){let J=$.id==="antigravity"?(()=>{let X=v1(),[K]=X;return X.find((W)=>O0(W))??K})():$.configFile,q=O0(J),Y=O0($.slashCommandPath);if(!_z($)){Q.push({status:"info",label:$.displayName,detail:"not installed on this machine"});continue}let V=!1;if(q)try{let X=u2(J,"utf8");if($.id==="antigravity")V=X.includes('"petdex"')||X.includes("petdex");else V=X.includes("127.0.0.1:7777/state")||X.includes("/state")}catch{V=!1}if(!V){Q.push({status:"warn",label:$.displayName,detail:"petdex hook NOT detected",hint:"Run `petdex hooks install`"});continue}if($.id==="antigravity"){let X=O0(E1());Q.push({status:X?"ok":"warn",label:$.displayName,detail:X?"MCP server + Skill installed":"MCP server configured, but Skill not found",hint:X?void 0:"Re-run `petdex hooks install` to install the Agent Skill."});continue}if(!Y){Q.push({status:"warn",label:$.displayName,detail:"hook installed, but /petdex slash command missing",hint:"Re-run `petdex hooks install` to add the slash command."});continue}Q.push({status:"ok",label:$.displayName,detail:"hooks + /petdex installed"})}return Q}function _z(Q){if(Q.id!=="antigravity")return O0(Q.configDir);return v1().some(($)=>O0(S1.dirname($)))||O0(E1())}function bz(){let Q=S1.join(B8(),".codex","config.toml");if(!O0(Q))return{status:"info",label:"Codex codex_hooks flag",detail:"config.toml absent (Codex not installed?)"};try{let $=u2(Q,"utf8");if(/\[features\][\s\S]*?codex_hooks\s*=\s*true/.test($))return{status:"ok",label:"Codex codex_hooks flag",detail:"[features] codex_hooks = true"};return{status:"warn",label:"Codex codex_hooks flag",detail:"missing or set to non-true",hint:"Re-run `petdex hooks install` and accept the auto-fix prompt."}}catch{return{status:"warn",label:"Codex codex_hooks flag",detail:"config.toml unreadable"}}}function hz(){let Q=[S1.join(B8(),".petdex","pets"),S1.join(B8(),".codex","pets")],$=0;for(let J of Q){if(!O0(J))continue;try{let{readdirSync:q}=_("node:fs"),Y=q(J);for(let V of Y){let X=S1.join(J,V);for(let K of["spritesheet.webp","spritesheet.png"]){let W=S1.join(X,K);if(!O0(W))continue;try{let G=IQ(W);if(G.size>0&&G.size<=16777216){$+=1;break}}catch{}}}}catch{}}if($===0)return{status:"fail",label:"Installed pets",detail:"no usable pets in ~/.petdex/pets or ~/.codex/pets",hint:"Install one with `petdex install <slug>`"};return{status:"ok",label:"Installed pets",detail:`${$} usable spritesheet(s) on disk`}}function fz(Q){switch(Q){case"ok":return L0.default.green("✓");case"warn":return L0.default.yellow("!");case"fail":return L0.default.red("✗");case"info":return L0.default.dim("○")}}function S0(Q){let $=Q.detail?` ${L0.default.dim(Q.detail)}`:"";if(console.log(` ${fz(Q.status)} ${L0.default.bold(Q.label)}${$}`),Q.hint)console.log(` ${L0.default.cyan("→")} ${Q.hint}`)}async function PY(){console.log(L0.default.bgMagenta(L0.default.white(" petdex doctor "))),console.log(""),console.log(L0.default.bold("Install")),S0(xz()),S0(vz()),S0(hz()),console.log(""),console.log(L0.default.bold("Runtime")),S0(await Ez()),S0(Sz()),S0(kz()),S0(yz()),console.log(""),console.log(L0.default.bold("Agents"));for(let $ of gz())S0($);S0(bz()),console.log(""),console.log(L0.default.bold("Network"));let Q=null;try{Q=Az("lsof -nP -iTCP:7777 -sTCP:LISTEN 2>/dev/null || true",{encoding:"utf8"}).trim()}catch{Q=null}if(Q===null)S0({status:"info",label:":7777 listener",detail:"lsof unavailable"});else if(Q.length===0)S0({status:"info",label:":7777 listener",detail:"nothing bound (sidecar offline)"});else{let $=Q.split(`
409
+ `).length-1;S0({status:$===1?"ok":"warn",label:":7777 listener",detail:$===1?"1 process bound":`${$} processes bound`,hint:$>1?"Multiple sidecars contending for the same port. Stop both and start fresh.":void 0})}console.log("")}var k0=u0(R1(),1);import{execFileSync as T8,spawn as IY}from"node:child_process";import{existsSync as TY,readFileSync as mz,unlinkSync as cz}from"node:fs";import{mkdir as uz,writeFile as CY}from"node:fs/promises";import H1 from"node:path";function I8(){return H1.join(e0(),".petdex","desktop.pid")}function M8(){return H1.join(e0(),".petdex","desktop.log")}function AY(){if(!TY(I8()))return null;let Q;try{Q=mz(I8(),"utf8").trim()}catch{return null}if(Q.startsWith("{")){try{let J=JSON.parse(Q);if(typeof J.pid==="number"&&Number.isFinite(J.pid)&&J.pid>0&&typeof J.lstart==="string"&&J.lstart.length>0)return{pid:J.pid,lstart:J.lstart}}catch{}return null}let $=Number(Q);if(Number.isFinite($)&&$>0)return{pid:$,lstart:""};return null}function DY(Q){if(process.platform==="win32")return null;try{let J=T8("ps",["-p",String(Q),"-o","lstart="],{encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trim();return J.length>0?J:null}catch{return null}}function wY(Q){try{let J=T8("tasklist",["/fi",`PID eq ${Q}`,"/fo","csv","/nh"],{encoding:"utf8",stdio:["ignore","pipe","ignore"]}).match(/^"([^"]+)"/m);return J?J[1].toLowerCase():null}catch{return null}}function RY(Q){if(process.platform==="win32")return H1.basename(E0()).toLowerCase();return DY(Q)??""}function TQ(Q){if(process.platform==="win32")return wY(Q)!==null;try{return T8("ps",["-p",String(Q)],{stdio:["ignore","ignore","ignore"]}),!0}catch{return!1}}function xY(Q){if(Q.lstart.length===0)return!1;if(process.platform==="win32"){let J=wY(Q.pid);return J!==null&&J===Q.lstart}let $=DY(Q.pid);return $!==null&&$===Q.lstart}function D6(){try{cz(I8())}catch{}}function Q1(){let Q=AY();if(Q==null)return{state:"stopped"};if(xY(Q))return{state:"running",pid:Q.pid};return{state:"stale",pid:Q.pid}}async function w6(){let Q=Q1();if(Q.state==="running")return{ok:!0,pid:Q.pid,alreadyRunning:!0};if(Q.state==="stale")D6();let $=E0();if(!TY($))return{ok:!1,reason:`petdex-desktop binary not found at ${$}. Run \`petdex install desktop\` first.`};await uz(H1.dirname(M8()),{recursive:!0});let J=await import("node:fs").then((K)=>K.openSync(M8(),"a")),q=await import("node:fs").then((K)=>K.openSync(M8(),"a")),Y=pz($);if(Y)return dz(Y);let V=IY($,[],{detached:!0,stdio:["ignore",J,q]});if(V.unref(),!V.pid)return{ok:!1,reason:"Failed to spawn petdex-desktop"};let X={pid:V.pid,lstart:RY(V.pid)};return await CY(I8(),JSON.stringify(X)),{ok:!0,pid:V.pid,alreadyRunning:!1}}function pz(Q){let $=H1.dirname(Q);if(H1.basename($)!=="MacOS")return null;let J=H1.dirname($);if(H1.basename(J)!=="Contents")return null;let q=H1.dirname(J);if(!q.endsWith(".app"))return null;return q}async function dz(Q){IY("open",["-gj",Q],{stdio:"ignore",detached:!0}).unref();let J=Date.now()+3000,q=null;while(Date.now()<J){if(q=lz(),q)break;await new Promise((V)=>setTimeout(V,100))}if(!q)return{ok:!1,reason:`Launched ${Q} but couldn't find the resulting process. Check ${M8()}.`};let Y={pid:q,lstart:RY(q)};return await CY(I8(),JSON.stringify(Y)),{ok:!0,pid:q,alreadyRunning:!1}}function lz(){try{let Q=T8("pgrep",["-f","petdex-desktop"],{encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trim();if(!Q)return null;let $=Q.split(`
410
+ `).filter((q)=>q.length>0),J=Number($[$.length-1]);return Number.isFinite(J)&&J>0?J:null}catch{return null}}var vY=7777;async function C8(Q={}){let $=Q.sidecarPort??vY,J=Q.portWaitTimeoutMs??5000,q=Q1();if(q.state==="stopped")return{ok:!1,reason:"petdex-desktop is not running"};if(q.state==="stale")return D6(),{ok:!1,reason:`petdex-desktop is not running (stale pid ${q.pid} cleared)`};let Y=q.pid,V=AY();if(V===null||!xY(V))return D6(),{ok:!1,reason:`petdex-desktop exited before stop (pid ${Y} no longer alive)`};if(process.platform==="win32")try{T8("taskkill",["/pid",String(Y),"/t","/f"],{stdio:"ignore",timeout:5000})}catch{if(!TQ(Y)){D6();let K=await P8($,{timeoutMs:J});return{ok:!0,pid:Y,portReleased:K}}return{ok:!1,reason:`taskkill failed and pid ${Y} is still alive`}}else try{process.kill(Y,"SIGTERM")}catch(K){if(D6(),K.code==="ESRCH"){let G=await P8($,{timeoutMs:J});return{ok:!0,pid:Y,portReleased:G}}return{ok:!1,reason:`Failed to signal pid ${Y}: ${K.message}`}}D6();let X=await P8($,{timeoutMs:J});return{ok:!0,pid:Y,portReleased:X}}async function EY(){let Q=await w6();if(!Q.ok)console.error(`${k0.default.red("✗")} ${Q.reason}`),process.exit(1);if(Q.alreadyRunning)console.log(`${k0.default.dim("•")} petdex-desktop already running (pid ${Q.pid})`);else console.log(`${k0.default.green("✓")} petdex-desktop started (pid ${Q.pid})`),console.log(k0.default.dim(` log: ${M8()}`))}async function SY(){let Q=await C8();if(!Q.ok)console.error(`${k0.default.dim("•")} ${Q.reason}`),process.exit(Q.reason.includes("not running")?0:1);if(Q.portReleased)console.log(`${k0.default.green("✓")} stopped pid ${Q.pid}`);else console.log(`${k0.default.yellow("!")} stopped pid ${Q.pid}, but :${vY} still busy`),console.log(k0.default.dim(" if 'petdex desktop start' fails with EADDRINUSE, wait a moment and retry"))}async function P8(Q,$={}){let J=$.timeoutMs??1e4,q=$.intervalMs??100,Y=$.host??"127.0.0.1",{createConnection:V}=await import("node:net"),X=Date.now()+J;while(Date.now()<X){if(await new Promise((W)=>{let G=V({host:Y,port:Q}),U=(z)=>{G.removeAllListeners(),G.destroy(),W(z)};G.once("connect",()=>U(!1)),G.once("error",(z)=>{U(z.code==="ECONNREFUSED")}),G.setTimeout(q,()=>U(!1))}))return!0;await new Promise((W)=>setTimeout(W,q))}return!1}function kY(){let Q=Q1();switch(Q.state){case"running":console.log(`${k0.default.green("●")} running (pid ${Q.pid})`);break;case"stopped":console.log(`${k0.default.dim("○")} stopped`);break;case"stale":console.log(`${k0.default.yellow("?")} pid ${Q.pid} written but not alive (run \`petdex desktop start\` to restart)`);break}}a1();var S=u0(R1(),1);import{existsSync as IH,readFileSync as tY}from"node:fs";import{mkdir as TH,writeFile as CH}from"node:fs/promises";import{homedir as eY}from"node:os";import hQ from"node:path";import{spawn as oz}from"node:child_process";import{randomUUID as yY}from"node:crypto";import{existsSync as iz,mkdirSync as nz,readFileSync as rz,writeFileSync as az}from"node:fs";import{homedir as sz}from"node:os";import gY from"node:path";function p2(){let Q=process.env.HOME??sz();return gY.join(Q,".petdex","telemetry.json")}var tz=process.env.PETDEX_TELEMETRY_URL??"https://petdex.crafter.run/api/telemetry/event",ez=2000;function d2(){if(!iz(p2()))return{kind:"missing"};let Q;try{Q=rz(p2(),"utf8")}catch($){return{kind:"error",reason:`read failed: ${$.message}`}}try{return{kind:"ok",config:JSON.parse(Q)}}catch($){return{kind:"error",reason:`parse failed: ${$.message}`}}}function CQ(Q){try{return nz(gY.dirname(p2()),{recursive:!0}),az(p2(),`${JSON.stringify(Q,null,2)}
411
+ `),!0}catch{return!1}}function _Y(){if(process.env.PETDEX_TELEMETRY==="0")return null;let Q=d2();if(Q.kind==="ok")return Q.config;if(Q.kind==="error")return null;let $={install_id:yY(),enabled:!0,notice_seen:!1,first_seen:new Date().toISOString()};return CQ($)?$:null}function bY(){if(process.env.PETDEX_TELEMETRY==="0")return!1;let Q=d2();if(Q.kind==="missing")return!0;if(Q.kind==="error")return!1;return Q.config.enabled}function hY(Q){let $=d2(),J;if($.kind==="ok")J=$.config,J.enabled=Q;else J={install_id:yY(),enabled:Q,notice_seen:!0,first_seen:new Date().toISOString()};return CQ(J)}function fY(){let Q=d2();return{enabled:bY(),install_id:Q.kind==="ok"?Q.config.install_id:null}}function mY(){if(process.env.PETDEX_TELEMETRY==="0")return;let Q=_Y();if(!Q)return;if(Q.notice_seen)return;console.log(["","petdex collects anonymous usage stats (install volume, OS, agents wired up).","No personal data, no file contents. Disable any time:"," petdex telemetry off","Details: https://petdex.crafter.run/legal/telemetry",""].join(`
412
+ `)),Q.notice_seen=!0,CQ(Q)}function P0(Q,$={}){if(!bY())return;let J=_Y();if(!J)return;let q=JSON.stringify({install_id:J.install_id,event:Q,...$});try{let Y=`
292
413
  const controller = new AbortController();
293
- const t = setTimeout(() => controller.abort(), ${Nz});
294
- fetch(${JSON.stringify(Bz)}, {
414
+ const t = setTimeout(() => controller.abort(), ${ez});
415
+ fetch(${JSON.stringify(tz)}, {
295
416
  method: "POST",
296
417
  headers: { "content-type": "application/json" },
297
- body: ${JSON.stringify(V)},
418
+ body: ${JSON.stringify(q)},
298
419
  signal: controller.signal,
299
420
  }).catch(() => {}).finally(() => clearTimeout(t));
300
- `;zz(process.execPath,["-e",Y],{detached:!0,stdio:"ignore"}).unref()}catch{}}var I1=process.env.PETDEX_URL??"https://petdex.crafter.run",Dz="https://clerk.petdex.crafter.run",hz="LcThwEayl6KAA1Qm",Jq=["profile","email","openid","offline_access"];async function _z(){let $=process.env.CLERK_ISSUER,Q=process.env.CLERK_OAUTH_CLIENT_ID;if($&&Q)return{issuer:$,clientId:Q,scopes:Jq};try{let q=await fetch(`${I1}/api/cli/auth-config`,{signal:AbortSignal.timeout(3000)});if(q.ok){let V=await q.json(),Y=typeof V.issuer==="string"?V.issuer:null,X=typeof V.clientId==="string"?V.clientId:null,J=Array.isArray(V.scopes)?V.scopes.filter((G)=>typeof G==="string"):null;if(Y&&X)return{issuer:$??Y,clientId:Q??X,scopes:J&&J.length>0?J:Jq}}}catch{}return{issuer:$??Dz,clientId:Q??hz,scopes:Jq}}var T8=null;async function R8(){if(T8)return T8;let $=await _z();return T8=new j8({clientId:$.clientId,issuer:$.issuer,scopes:$.scopes,storage:"keychain",keychainService:"petdex-cli"}),T8}var U$="0.3.9";bz().catch(($)=>{Y1(`petdex: ${$.message}`),process.exit(1)});async function bz(){let $=process.argv.slice(2),Q=$[0];if(Q==="bubble"){let{runBubble:V}=await Promise.resolve().then(() => (NY(),BY));await V($.slice(1));return}if(!Q||Q==="--help"||Q==="-h"||Q==="help"){wY();return}if(!new Set(["version","--version","-v","telemetry"]).has(Q))WY();switch(Q){case"login":await fz();break;case"logout":await mz();break;case"whoami":await cz();break;case"submit":await oz($.slice(1));break;case"install":await dz($.slice(1));break;case"list":await lz();break;case"hooks":await VH($.slice(1));break;case"desktop":await KH($.slice(1));break;case"init":await YH();break;case"up":await EY();break;case"down":await yY();break;case"toggle":await GH();break;case"update":await sJ($.slice(1));break;case"doctor":await _J();break;case"telemetry":WH($.slice(1));break;case"version":case"--version":case"-v":console.log(U$);break;default:console.error(j.default.red(`Unknown command: ${Q}`)),wY(),process.exit(1)}}function wY(){let $=j.default.cyan,Q=j.default.dim;console.log(["",` ${j.default.bold(j.default.magenta("petdex"))} ${Q(U$)} ${Q("Codex pet gallery CLI")}`,"",` ${$("Usage")}`," petdex <command> [args]","",` ${$("Commands")}`,` ${j.default.bold("init")} First-run setup: wires hooks across your agents AND wakes the mascot ${j.default.green("(start here)")}`,` ${j.default.bold("login")} Sign in with Clerk OAuth`,` ${j.default.bold("logout")} Clear stored credentials`,` ${j.default.bold("whoami")} Show signed-in user`,` ${j.default.bold("submit")} <path> Submit a pet folder, zip, or parent of pets (bulk)`,` ${j.default.bold("install")} <slug...> Install one or more pets into ~/.petdex/pets and ~/.codex/pets`,` ${j.default.bold("install desktop")} Install the petdex-desktop binary (alternative to the .dmg)`,` ${j.default.bold("list")} List approved pets`,` ${j.default.bold("hooks install")} Wire petdex-desktop into your coding agents`,` ${j.default.bold("toggle")} One-shot wake/sleep. Flips the mascot on or off depending on current state`,` ${j.default.bold("up")} Force-wake the mascot. Enables hooks AND launches petdex-desktop`,` ${j.default.bold("down")} Force-sleep the mascot. Disables hooks AND stops petdex-desktop`,` ${j.default.bold("desktop")} <cmd> Manage petdex-desktop (start | stop | status)`,` ${j.default.bold("update")} Pull the latest petdex-desktop release and restart`,` ${j.default.bold("doctor")} Diagnose install/runtime/agents and surface fixes`,` ${j.default.bold("telemetry")} [on|off|status] Manage anonymous usage telemetry`,"",` ${$("Examples")}`,` ${Q("$")} petdex init ${Q("# after dragging Petdex.app from the .dmg → just run this")}`,` ${Q("$")} petdex login`,` ${Q("$")} petdex submit ~/.codex/pets/boba ${Q("# single folder")}`,` ${Q("$")} petdex install boba ${Q("# install a pet by slug")}`,` ${Q("$")} petdex install boba doraemon mochi ${Q("# install several at once")}`,` ${Q("$")} petdex toggle ${Q("# wake or sleep the mascot")}`,` ${Q("$")} petdex doctor ${Q("# diagnose install + agents")}`,` ${Q("$")} petdex update ${Q("# pull the latest release")}`,"",` ${Q("Gallery & docs:")} ${j.default.underline(I1)}`,""].join(`
301
- `))}async function fz(){A1(j.default.bgMagenta(j.default.white(" petdex login ")));let $=H1();$.start("Opening your browser to sign in with Clerk");try{let Q=await R8(),{user:q}=await Q.login(),V=xY(q.email,q.username,q.sub)??"unknown";$.stop(`${j.default.green("✓ ")}Signed in as ${j.default.cyan(V)}`),F1(`Try ${j.default.cyan("petdex submit ~/.codex/pets")} to share your pets.`)}catch(Q){throw $.stop(j.default.red("× login failed")),Error(ez(Q.message))}}async function mz(){await(await R8()).logout(),console.log(`${j.default.green("✓ ")}Signed out`)}async function cz(){try{let Q=await(await R8()).whoami();if(!Q)throw Error("not signed in");let q=[F8(Q.given_name),F8(Q.family_name)].filter(Boolean).join(" ");T1([`${j.default.dim("user: ")}${Q.sub}`,`${j.default.dim("email: ")}${Q.email??"—"}`,`${j.default.dim("name: ")}${q||"—"}`,`${j.default.dim("username:")}${F8(Q.preferred_username)??"—"}`].join(`
302
- `),"Signed in")}catch{Y1(`Not signed in. Run ${j.default.cyan("petdex login")}.`),process.exit(1)}}async function pz(){let $=await fetch(`${I1}/api/manifest`);if(!$.ok)throw Error(`manifest fetch ${$.status}`);return(await $.json()).pets}async function uz($){let Q=$.slug;if(!r$($.spritesheetUrl)||!r$($.petJsonUrl))throw Error(`untrusted asset host for ${Q} (admin needs to re-upload)`);let q=J1.join(CY(),".petdex","pets",Q),V=J1.join(CY(),".codex","pets",Q);await Promise.all([IY(q,{recursive:!0}),IY(V,{recursive:!0})]);let Y=$.spritesheetUrl.endsWith(".png")?"png":"webp",X=async(U)=>{let K=await fetch(U);if(!K.ok)throw Error(`download ${U} -> ${K.status} ${K.statusText}`);return K.arrayBuffer()},[J,G]=await Promise.all([X($.petJsonUrl),X($.spritesheetUrl)]);await Promise.all([w8(J1.join(q,"pet.json"),Buffer.from(J)),w8(J1.join(q,`spritesheet.${Y}`),Buffer.from(G)),w8(J1.join(V,"pet.json"),Buffer.from(J)),w8(J1.join(V,`spritesheet.${Y}`),Buffer.from(G))]),fetch(`${I1}/install/${Q}`,{method:"GET"}).catch(()=>{})}async function dz($){let Q=$[0];if(!Q)Y1(`Usage: ${j.default.cyan("petdex install <slug> [slug...]")} or ${j.default.cyan("petdex install desktop")}`),process.exit(1);if(Q==="desktop"){let{tag:W}=await pQ();Y6("cli_install_desktop_success",{cli_version:U$,os:process.platform,arch:process.arch,binary_version:W.replace(/^desktop-v/,"")});return}let q=Array.from(new Set($)),V=H1();V.start(q.length===1?`Resolving ${q[0]}`:`Resolving ${q.length} pets`);let Y;try{Y=await pz()}catch(W){throw V.stop(j.default.red("manifest failed")),W}let X=[],J=[];for(let W of q){let Z=Y.find((z)=>z.slug===W);if(Z)X.push(Z);else J.push(W)}if(X.length===0)V.stop(j.default.red("none found")),Y1(`No pets matched. Try ${j.default.cyan("petdex list")} to see what's available.`),process.exit(1);let G=[],U=[];for(let W=0;W<X.length;W++){let Z=X[W];V.message(X.length===1?`Downloading ${Z.slug}`:`Downloading ${Z.slug} (${W+1}/${X.length})`);try{await uz(Z),G.push(Z.displayName)}catch(z){U.push({slug:Z.slug,reason:z instanceof Error?z.message:String(z)})}}if(G.length===X.length)V.stop(G.length===1?`Installed ${j.default.cyan(G[0])}`:`Installed ${j.default.cyan(G.length)} pets`);else if(G.length>0)V.stop(`Installed ${j.default.cyan(G.length)} of ${X.length} (${j.default.red(`${U.length} failed`)})`);else V.stop(j.default.red("all failed"));let K=[];if(G.length>0)K.push("Paths:"),K.push(` ${j.default.dim("~/.petdex/pets/")} (Petdex Desktop)`),K.push(` ${j.default.dim("~/.codex/pets/")} (Codex Desktop)`),K.push(""),K.push("Activate in Petdex Desktop: right-click the mascot."),K.push("Activate in Codex Desktop:"),K.push(` ${j.default.cyan("Settings -> Appearance -> Pets")}`);if(J.length>0){if(K.length>0)K.push("");K.push(j.default.yellow("Skipped (slug not found):"));for(let W of J)K.push(` ${W}`)}if(U.length>0){if(K.length>0)K.push("");K.push(j.default.red("Failed:"));for(let W of U)K.push(` ${W.slug}: ${W.reason}`)}if(K.length>0)T1(K.join(`
303
- `),"Next steps");if(U.length>0&&G.length===0)process.exit(1)}async function lz(){let $=H1();$.start("Fetching gallery");let Q=await fetch(`${I1}/api/manifest`);if(!Q.ok)throw $.stop(j.default.red("failed")),Error(`failed to fetch manifest: ${Q.status}`);let q=await Q.json();$.stop(`${q.total} pets`);let V=q.pets.map((Y)=>{let X=Y.submittedBy?j.default.dim(` by ${Y.submittedBy}`):"";return` ${j.default.cyan(Y.slug.padEnd(26))} ${Y.displayName}${X}`});console.log(V.join(`
421
+ `;oz(process.execPath,["-e",Y],{detached:!0,stdio:"ignore"}).unref()}catch{}}var i2=7777,AH="x-petdex-update-token",DH=hQ.join(eY(),".petdex","runtime","update-token"),Q3=hQ.join(eY(),".petdex","version");async function wH(Q={}){let $=Q.port??i2,J=Q.timeoutMs??2000,q=Q.tokenPath??DH,Y;try{Y=tY(q,"utf8").trim()}catch{return!1}if(!Y)return!1;let V=new AbortController,X=setTimeout(()=>V.abort(),J);try{return(await fetch(`http://127.0.0.1:${$}/update/handoff`,{method:"POST",headers:{[AH]:Y},signal:V.signal})).ok}catch{return!1}finally{clearTimeout(X)}}function RH(Q=Q3){if(!IH(Q))return null;try{return tY(Q,"utf8").trim()||null}catch{return null}}async function bQ(Q,$){await TH(hQ.dirname(Q),{recursive:!0}),await CH(Q,`${$}
422
+ `)}async function $3(Q=[],$,J={}){let q={fetchLatestRelease:FQ,desktopBinPath:E0,appBundleRootFor:NY,desktopStatus:Q1,stopDesktop:C8,updateAppBundleFromDmg:NQ,resolveDesktopInstallPlan:f2,installAppBundleFromDmg:BQ,stageDesktopAssets:LQ,commitDesktopAssets:OQ,requestSidecarHandoff:wH,waitForPortRelease:P8,startDesktop:w6,hookRefresh:xH,versionFile:Q3,...J},Y=Date.now(),V=Q.includes("--force"),X=Q.includes("--silent"),K=(M)=>{if(X)console.log(`[petdex update] ${M}`);else A0(S.default.bgMagenta(S.default.white(` ${M} `)))},W=(M)=>{if(X)console.log(M);else o.info(M)},G=(M)=>{if(X)console.warn(M);else o.warn(M)},U=(M)=>{if(X)console.log(M);else D0(M)},z=()=>{if(X)return{start:(C)=>console.log(C),stop:(C)=>console.log(C)};let M=H0();return{start:(C)=>M.start(C),stop:(C)=>M.stop(C)}};K("petdex update");let j=RH(q.versionFile);W(j?`Installed: ${X?j:S.default.cyan(j)}`:"No installed version recorded - treating as fresh install.");let H=z();H.start("Checking GitHub for the latest release");let F;try{F=await q.fetchLatestRelease()}catch(M){throw H.stop(X?"failed":S.default.red("failed")),Error(`Could not reach GitHub. Check your connection.
423
+ ${M.message}`)}if(H.stop(X?`Latest: ${F.tag_name}`:`${S.default.green("✓")} Latest: ${S.default.bold(F.tag_name)}`),!V&&j&&j===F.tag_name){U(X?"Already up to date.":`${S.default.green("✓")} Already up to date.`);return}let N=q.desktopBinPath(),T=q.appBundleRootFor(N),P=q.desktopStatus().state==="running";if(T){if(P)W(X?"Stopping running petdex-desktop":`${S.default.dim("•")} Stopping running petdex-desktop`),await q.stopDesktop();let M=z();M.start(`Downloading ${F.tag_name} DMG`);let C;try{C=await q.updateAppBundleFromDmg(F,T)}catch(x){throw M.stop(X?"failed":S.default.red("failed")),x}M.stop(X?`Replaced ${T} (${R6(C.dmgAsset.size)})`:`${S.default.green("✓")} Replaced ${S.default.bold(T)} (${R6(C.dmgAsset.size)})`),await bQ(q.versionFile,F.tag_name),P0("cli_update_applied",{cli_version:$,from_version:j??void 0,to_version:F.tag_name,duration_ms:Date.now()-Y}),await q.hookRefresh(W,G,X);let D=j?`${j} -> ${F.tag_name}`:F.tag_name;U(X?`${D} (relaunch Petdex from /Applications to use it)`:`${S.default.green("✓")} ${D}
424
+ ${S.default.dim(" Relaunch Petdex from /Applications to use it.")}`);return}let L=q.resolveDesktopInstallPlan(F);if(L.kind==="unsupported")throw m2(L);if(L.kind==="macos-dmg"){if(P)W(X?"Stopping running petdex-desktop":`${S.default.dim("•")} Stopping running petdex-desktop`),await q.stopDesktop();let M=z();M.start(`Installing ${F.tag_name} app`);let C;try{C=await q.installAppBundleFromDmg(F,c2())}catch(x){throw M.stop(X?"failed":S.default.red("failed")),x}M.stop(X?`Installed ${C.appBundleRoot} (${R6(C.dmgAsset.size)})`:`${S.default.green("✓")} Installed ${S.default.bold(C.appBundleRoot)} (${R6(C.dmgAsset.size)})`),await bQ(q.versionFile,F.tag_name),P0("cli_update_applied",{cli_version:$,from_version:j??void 0,to_version:F.tag_name,duration_ms:Date.now()-Y}),await q.hookRefresh(W,G,X);let D=j?`${j} -> ${F.tag_name}`:F.tag_name;U(X?`${D} (run petdex up to launch the app)`:`${S.default.green("✓")} ${D}
425
+ ${S.default.dim(" Run petdex up to launch the app.")}`);return}let A=z();A.start(`Downloading ${F.tag_name}`);let B;try{B=await q.stageDesktopAssets(F)}catch(M){throw A.stop(X?"failed":S.default.red("failed")),M}if(A.stop(X?`Downloaded ${F.tag_name} (${R6(B.binAsset.size)})`:`${S.default.green("✓")} Downloaded ${S.default.bold(F.tag_name)} (${R6(B.binAsset.size)})`),P){W(X?"Stopping running petdex-desktop":`${S.default.dim("•")} Stopping running petdex-desktop`);let M=await q.stopDesktop();if(process.platform==="win32"&&!M.ok){let C=q.desktopStatus();if(C.state==="running"&&TQ(C.pid))throw Error("Cannot replace petdex-desktop-win32-x64.exe: process is still running. Run `petdex desktop stop` first.")}}if(process.platform==="win32"&&P)await new Promise((M)=>setTimeout(M,500));if(await q.commitDesktopAssets(B),await bQ(q.versionFile,F.tag_name),P){W(X?"Asking sidecar to release port":`${S.default.dim("•")} Asking sidecar to release port`);let M=await q.requestSidecarHandoff();if(W(X?M?"Sidecar acknowledged handoff":"Sidecar handoff unavailable, falling back to port wait":M?`${S.default.dim("•")} Sidecar acknowledged handoff`:`${S.default.dim("•")} Sidecar handoff unavailable, falling back to port wait`),!await q.waitForPortRelease(i2,{timeoutMs:1e4})){G(X?`Port ${i2} still in use after 10s. Run 'petdex desktop stop && petdex desktop start' to recover.`:`${S.default.yellow("!")} Port ${i2} still in use after 10s. Run \`petdex desktop stop && petdex desktop start\` to recover.`);return}W(X?"Restarting petdex-desktop":`${S.default.dim("•")} Restarting petdex-desktop`);let D=await q.startDesktop();if(D.ok)W(X?`Restarted (pid ${D.pid})`:`${S.default.green("✓")} Restarted (pid ${D.pid})`);else G(X?`Could not restart: ${D.reason}. Run 'petdex desktop start' manually.`:`${S.default.yellow("!")} Could not restart: ${D.reason}. Run \`petdex desktop start\` manually.`)}P0("cli_update_applied",{cli_version:$,from_version:j??void 0,to_version:F.tag_name,duration_ms:Date.now()-Y}),await q.hookRefresh(W,G,X);let O=j?`${j} -> ${F.tag_name}`:F.tag_name;U(X?O:`${S.default.green("✓")} ${O}`)}async function xH(Q,$,J){try{let{runRefresh:q}=await Promise.resolve().then(() => (_Q(),gQ)),Y=await q();if(Y.refreshed.length>0)Q(J?`Refreshed hooks for: ${Y.refreshed.join(", ")}`:`Refreshed hooks for ${S.default.cyan(Y.refreshed.join(", "))}`)}catch(q){$(`Hook refresh failed: ${q.message}`)}}function R6(Q){if(Q<1024)return`${Q} B`;if(Q<1048576)return`${(Q/1024).toFixed(1)} KB`;return`${(Q/1024/1024).toFixed(1)} MB`}yQ();a1();F8();var Y0=u0(R1(),1);import{existsSync as k1}from"node:fs";import{readFile as mQ,rm as cQ,stat as vH,writeFile as uQ}from"node:fs/promises";import J3 from"node:path";wQ();async function q3(Q={}){A0(Y0.default.bgMagenta(Y0.default.white(" petdex hooks uninstall ")));let J=(await EH()).filter((V)=>V.installed);if(J.length===0)return D0(Y0.default.dim("No agent configs found. Nothing to uninstall.")),{uninstalledAgents:[]};let q=[],Y=[];for(let{agent:V}of J)try{let X=await kH(V);if(X.removed){Y.push(V.id);let K=X.backupPath?` ${Y0.default.dim(`(backup: ${J3.basename(X.backupPath)})`)}`:"";q.push(` ${Y0.default.green("✓")} ${Y0.default.bold(V.displayName)}${K}`)}else q.push(` ${Y0.default.dim("•")} ${Y0.default.bold(V.displayName)} ${Y0.default.dim("(no petdex entries found)")}`);if(V.id!=="antigravity")await l2(V)}catch(X){q.push(` ${Y0.default.red("✗")} ${Y0.default.bold(V.displayName)} ${Y0.default.red(X instanceof Error?X.message:String(X))}`)}if(_0(q.join(`
426
+ `),"Done"),Q.removeToken)try{await cQ(L8(),{force:!0}),o.info(`${Y0.default.green("✓")} Removed ${L8()}`)}catch{}else if(k1(L8()))o.info(Y0.default.dim(`Token file at ${L8()} kept. Pass --remove-token to delete it.`));return D0(`${Y0.default.green("✓")} Done. Run ${Y0.default.cyan("petdex hooks install")} to wire petdex back in.`),{uninstalledAgents:Y}}async function EH(){return Promise.all(z1.map(async(Q)=>({agent:Q,installed:Q.id==="antigravity"?SH():k1(Q.configDir)})))}function SH(){return v1().some((Q)=>k1(J3.dirname(Q)))||k1(E1())}async function kH(Q){if(Q.id==="opencode"){if(!k1(Q.configFile))return{removed:!1,backupPath:null};let V=await fQ(Q.configFile);return await cQ(Q.configFile,{force:!0}),{removed:!0,backupPath:V}}if(Q.id==="antigravity"){let V=!1;for(let X of v1())try{if(k1(X)){let K=await mQ(X,"utf8"),W=JSON.parse(K),G=W.mcpServers??{};if(G.petdex){let{petdex:U,...z}=G;W.mcpServers=z,await fQ(X),await uQ(X,`${JSON.stringify(W,null,2)}
427
+ `,"utf8"),V=!0}}}catch{}try{let X=E1(),K=!1;try{await vH(X),K=!0}catch{}if(K)await cQ(X,{recursive:!0,force:!0}),V=!0}catch{}return{removed:V,backupPath:null}}if(!k1(Q.configFile))return{removed:!1,backupPath:null};let $;try{$=await mQ(Q.configFile,"utf8")}catch(V){throw Error(`Could not read ${Q.configFile}: ${V.message}`)}let J;try{J=JSON.parse($)}catch(V){throw Error(`Refusing to overwrite ${Q.configFile}: invalid JSON (${V.message}). Hand-edit the file to remove petdex entries.`)}let q=yH(J);if(!q.changed)return{removed:!1,backupPath:null};let Y=await fQ(Q.configFile);return await uQ(Q.configFile,`${JSON.stringify(q.value,null,2)}
428
+ `,"utf8"),{removed:!0,backupPath:Y}}function yH(Q){let $={...Q},J=$.hooks;if(!J||typeof J!=="object"||Array.isArray(J))return{value:$,changed:!1};let q=!1,Y={};for(let[V,X]of Object.entries(J)){if(!Array.isArray(X)){Y[V]=X;continue}let K=X.filter((W)=>!gH(W));if(K.length!==X.length)q=!0;if(K.length>0)Y[V]=K}if(!q)return{value:$,changed:!1};if(Object.keys(Y).length===0){let{hooks:V,...X}=$;return{value:X,changed:!0}}return $.hooks=Y,{value:$,changed:!0}}function gH(Q){if(typeof Q!=="object"||Q==null)return!1;return _H(Q).some((J)=>J.includes(`localhost:${H8}/state`)||J.includes(n1))}function _H(Q){let $=[];function J(q){if(typeof q==="string"){$.push(q);return}if(Array.isArray(q)){for(let Y of q)J(Y);return}if(typeof q==="object"&&q!=null)for(let Y of Object.values(q))J(Y)}return J(Q),$}async function fQ(Q){if(!k1(Q))return null;let $=new Date().toISOString().replace(/[:.]/g,"-"),J=`${Q}.${$}.bak`,q=await mQ(Q);return await uQ(J,q),J}var V0=process.env.PETDEX_URL??"https://petdex.crafter.run",WF="https://clerk.petdex.crafter.run",UF="LcThwEayl6KAA1Qm",iQ=["profile","email","openid","offline_access"];async function jF(){let Q=process.env.CLERK_ISSUER,$=process.env.CLERK_OAUTH_CLIENT_ID;if(Q&&$)return{issuer:Q,clientId:$,scopes:iQ};try{let J=await fetch(`${V0}/api/cli/auth-config`,{signal:AbortSignal.timeout(3000)});if(J.ok){let q=await J.json(),Y=typeof q.issuer==="string"?q.issuer:null,V=typeof q.clientId==="string"?q.clientId:null,X=Array.isArray(q.scopes)?q.scopes.filter((K)=>typeof K==="string"):null;if(Y&&V)return{issuer:Q??Y,clientId:$??V,scopes:X&&X.length>0?X:iQ}}}catch{}return{issuer:Q??WF,clientId:$??UF,scopes:iQ}}var r2=null;async function v8(){if(r2)return r2;let Q=await jF();return r2=new y2({clientId:Q.clientId,issuer:Q.issuer,scopes:Q.scopes,storage:"keychain",keychainService:"petdex-cli"}),r2}var c0="0.4.1";ZF().catch((Q)=>{r(`petdex: ${Q.message}`),process.exit(1)});async function ZF(){let Q=process.argv.slice(2),$=Q[0];if($==="bubble"){let{runBubble:q}=await Promise.resolve().then(() => (H3(),z3));await q(Q.slice(1));return}if($==="mcp-server"){let{runMcpServer:q}=await Promise.resolve().then(() => (M3(),B3));await q();return}if(!$||$==="--help"||$==="-h"||$==="help"){C3();return}if(!new Set(["version","--version","-v","telemetry"]).has($))mY();switch($){case"login":await zF();break;case"logout":await HF();break;case"whoami":await FF();break;case"submit":await MF(Q.slice(1));break;case"edit":await PF(Q.slice(1));break;case"install":await NF(Q.slice(1));break;case"list":await BF();break;case"hooks":await EF(Q.slice(1));break;case"desktop":await _F(Q.slice(1));break;case"init":await kF();break;case"up":await k3();break;case"down":await y3();break;case"toggle":await gF();break;case"update":await $3(Q.slice(1),c0);break;case"doctor":await PY();break;case"telemetry":bF(Q.slice(1));break;case"version":case"--version":case"-v":console.log(c0);break;default:console.error(Z.default.red(`Unknown command: ${$}`)),C3(),process.exit(1)}}function C3(){let Q=Z.default.cyan,$=Z.default.dim;console.log(["",` ${Z.default.bold(Z.default.magenta("petdex"))} ${$(c0)} ${$("Codex pet gallery CLI")}`,"",` ${Q("Usage")}`," petdex <command> [args]","",` ${Q("Commands")}`,` ${Z.default.bold("init")} First-run setup: wires hooks across your agents AND wakes the mascot ${Z.default.green("(start here)")}`,` ${Z.default.bold("login")} Sign in with Clerk OAuth`,` ${Z.default.bold("logout")} Clear stored credentials`,` ${Z.default.bold("whoami")} Show signed-in user`,` ${Z.default.bold("submit")} <path> Submit a pet folder, zip, or parent of pets (bulk)`,` ${Z.default.bold("edit")} <slug> Edit a pet you own (--desc, --displayName, --sprite, --meta, --zip)`,` ${Z.default.bold("install")} <slug...> Install one or more pets into ~/.petdex/pets and ~/.codex/pets`,` ${Z.default.bold("install desktop")} Install the petdex-desktop binary (alternative to the .dmg)`,` ${Z.default.bold("list")} List approved pets`,` ${Z.default.bold("mcp-server")} Start the MCP protocol server for Antigravity integration`,` ${Z.default.bold("hooks install")} Wire petdex-desktop into your coding agents`,` ${Z.default.bold("toggle")} One-shot wake/sleep. Flips the mascot on or off depending on current state`,` ${Z.default.bold("up")} Force-wake the mascot. Enables hooks AND launches petdex-desktop`,` ${Z.default.bold("down")} Force-sleep the mascot. Disables hooks AND stops petdex-desktop`,` ${Z.default.bold("desktop")} <cmd> Manage petdex-desktop (start | stop | status)`,` ${Z.default.bold("update")} Pull the latest petdex-desktop release and restart`,` ${Z.default.bold("doctor")} Diagnose install/runtime/agents and surface fixes`,` ${Z.default.bold("telemetry")} [on|off|status] Manage anonymous usage telemetry`,"",` ${Q("Examples")}`,` ${$("$")} petdex init ${$("# after dragging Petdex.app from the .dmg → just run this")}`,` ${$("$")} petdex login`,` ${$("$")} petdex submit ~/.codex/pets/boba ${$("# single folder")}`,` ${$("$")} petdex install boba ${$("# install a pet by slug")}`,` ${$("$")} petdex install boba doraemon mochi ${$("# install several at once")}`,` ${$("$")} petdex toggle ${$("# wake or sleep the mascot")}`,` ${$("$")} petdex doctor ${$("# diagnose install + agents")}`,` ${$("$")} petdex update ${$("# pull the latest release")}`,"",` ${$("Gallery & docs:")} ${Z.default.underline(V0)}`,""].join(`
429
+ `))}async function zF(){A0(Z.default.bgMagenta(Z.default.white(" petdex login ")));let Q=H0();Q.start("Opening your browser to sign in with Clerk");try{let $=await v8(),{user:J}=await $.login(),q=v3(J.email,J.username,J.sub)??"unknown";Q.stop(`${Z.default.green("✓ ")}Signed in as ${Z.default.cyan(q)}`),D0(`Try ${Z.default.cyan("petdex submit ~/.codex/pets")} to share your pets.`)}catch($){throw Q.stop(Z.default.red("× login failed")),Error(RF($.message))}}async function HF(){await(await v8()).logout(),console.log(`${Z.default.green("✓ ")}Signed out`)}async function FF(){try{let $=await(await v8()).whoami();if(!$)throw Error("not signed in");let J=[s2($.given_name),s2($.family_name)].filter(Boolean).join(" ");_0([`${Z.default.dim("user: ")}${$.sub}`,`${Z.default.dim("email: ")}${$.email??"—"}`,`${Z.default.dim("name: ")}${J||"—"}`,`${Z.default.dim("username:")}${s2($.preferred_username)??"—"}`].join(`
430
+ `),"Signed in")}catch{r(`Not signed in. Run ${Z.default.cyan("petdex login")}.`),process.exit(1)}}async function LF(){let Q=await fetch(`${V0}/api/manifest`);if(!Q.ok)throw Error(`manifest fetch ${Q.status}`);return(await Q.json()).pets}async function OF(Q){let $=Q.slug;if(!N8(Q.spritesheetUrl)||!N8(Q.petJsonUrl))throw Error(`untrusted asset host for ${$} (admin needs to re-upload)`);let J=j0.join(T3(),".petdex","pets",$),q=j0.join(T3(),".codex","pets",$);await Promise.all([I3(J,{recursive:!0}),I3(q,{recursive:!0})]);let Y=Q.spritesheetUrl.endsWith(".png")?"png":"webp",V=async(W)=>{let G=await fetch(W);if(!G.ok)throw Error(`download ${W} -> ${G.status} ${G.statusText}`);return G.arrayBuffer()},[X,K]=await Promise.all([V(Q.petJsonUrl),V(Q.spritesheetUrl)]);await Promise.all([n2(j0.join(J,"pet.json"),Buffer.from(X)),n2(j0.join(J,`spritesheet.${Y}`),Buffer.from(K)),n2(j0.join(q,"pet.json"),Buffer.from(X)),n2(j0.join(q,`spritesheet.${Y}`),Buffer.from(K))]),fetch(`${V0}/install/${$}`,{method:"GET"}).catch(()=>{})}async function NF(Q){let $=Q[0];if(!$)r(`Usage: ${Z.default.cyan("petdex install <slug> [slug...]")} or ${Z.default.cyan("petdex install desktop")}`),process.exit(1);if($==="desktop"){let{tag:U}=await PQ();P0("cli_install_desktop_success",{cli_version:c0,os:process.platform,arch:process.arch,binary_version:U.replace(/^desktop-v/,"")});return}let J=Array.from(new Set(Q)),q=H0();q.start(J.length===1?`Resolving ${J[0]}`:`Resolving ${J.length} pets`);let Y;try{Y=await LF()}catch(U){throw q.stop(Z.default.red("manifest failed")),U}let V=[],X=[];for(let U of J){let z=Y.find((j)=>j.slug===U);if(z)V.push(z);else X.push(U)}if(V.length===0)q.stop(Z.default.red("none found")),r(`No pets matched. Try ${Z.default.cyan("petdex list")} to see what's available.`),process.exit(1);let K=[],W=[];for(let U=0;U<V.length;U++){let z=V[U];q.message(V.length===1?`Downloading ${z.slug}`:`Downloading ${z.slug} (${U+1}/${V.length})`);try{await OF(z),K.push(z.displayName)}catch(j){W.push({slug:z.slug,reason:j instanceof Error?j.message:String(j)})}}if(K.length===V.length)q.stop(K.length===1?`Installed ${Z.default.cyan(K[0])}`:`Installed ${Z.default.cyan(K.length)} pets`);else if(K.length>0)q.stop(`Installed ${Z.default.cyan(K.length)} of ${V.length} (${Z.default.red(`${W.length} failed`)})`);else q.stop(Z.default.red("all failed"));let G=[];if(K.length>0)G.push("Paths:"),G.push(` ${Z.default.dim("~/.petdex/pets/")} (Petdex Desktop)`),G.push(` ${Z.default.dim("~/.codex/pets/")} (Codex Desktop)`),G.push(""),G.push("Activate in Petdex Desktop: right-click the mascot."),G.push("Activate in Codex Desktop:"),G.push(` ${Z.default.cyan("Settings -> Appearance -> Pets")}`);if(X.length>0){if(G.length>0)G.push("");G.push(Z.default.yellow("Skipped (slug not found):"));for(let U of X)G.push(` ${U}`)}if(W.length>0){if(G.length>0)G.push("");G.push(Z.default.red("Failed:"));for(let U of W)G.push(` ${U.slug}: ${U.reason}`)}if(G.length>0)_0(G.join(`
431
+ `),"Next steps");if(W.length>0&&K.length===0)process.exit(1)}async function BF(){let Q=H0();Q.start("Fetching gallery");let $=await fetch(`${V0}/api/manifest`);if(!$.ok)throw Q.stop(Z.default.red("failed")),Error(`failed to fetch manifest: ${$.status}`);let J=await $.json();Q.stop(`${J.total} pets`);let q=J.pets.map((Y)=>{let V=Y.submittedBy?Z.default.dim(` by ${Y.submittedBy}`):"";return` ${Z.default.cyan(Y.slug.padEnd(26))} ${Y.displayName}${V}`});console.log(q.join(`
304
432
  `)),console.log(`
305
- ${j.default.dim("Install with")} ${j.default.cyan("petdex install <slug>")}
306
- ${j.default.dim("Browse:")} ${j.default.underline(I1)}`)}async function oz($){let q=$.filter((L)=>!L.startsWith("--"))[0];if(!q)Y1(`Usage: ${j.default.cyan("petdex submit <path> [--force]")}`),process.exit(1);let V=await R8(),Y;try{let L=await V.getAccessToken();if(!L)Y1(`Not signed in. Run ${j.default.cyan("petdex login")}.`),process.exit(1);Y=L}catch{Y1(`Not signed in. Run ${j.default.cyan("petdex login")}.`),process.exit(1)}let X=I1;try{X=QH(await V.whoami())}catch{}let J=J1.resolve(q),G=await vY(J).catch(()=>null);if(!G)Y1(`No such file or directory: ${q}`),process.exit(1);A1(j.default.bgMagenta(j.default.white(" petdex submit ")));let U=H1();U.start(`Scanning ${J}`);let K=await iz(J,G.isDirectory());if(U.stop(K.length>0?`${K.length} pet${K.length===1?"":"s"} found`:j.default.red("no pets found")),K.length===0)Y1("A pet folder must contain pet.json and spritesheet.{webp,png}."),process.exit(1);let Z=$.includes("--force")?new Map:await tz(K,Y),z=K,H=0;if(Z.size>0){let L=K.filter((M)=>Z.has(X6(M.petIdHint))),C=K.filter((M)=>!Z.has(X6(M.petIdHint)));T1(L.map((M)=>{let R=Z.get(X6(M.petIdHint))?.status??"unknown";return`${j.default.yellow("•")} ${j.default.bold(M.label)} ${j.default.dim(`(${R})`)}`}).join(`
307
- `),`${L.length} already submitted by you`);let O=await Dq({message:"How should we handle these duplicates?",options:[{value:"skip",label:"Skip duplicates (recommended)"},{value:"resubmit",label:"Submit all anyway (will create -2 / -3 slugs)"},{value:"cancel",label:"Cancel"}],initialValue:"skip"});if(q0(O)||O==="cancel")Y1("Aborted."),process.exit(1);if(O==="skip"){if(z=C,H=L.length,z.length===0){F1(`Nothing new to submit. Track approval at ${j.default.underline(X)}.`);return}}}if(z.length>1){let L=await M6({message:`Submit ${j.default.bold(String(z.length))} pet${z.length===1?"":"s"}?`});if(q0(L)||!L)Y1("Aborted."),process.exit(1)}let I=0,N=0,w=[];for(let L of z){let C=H1();C.start(`Submitting ${j.default.cyan(L.label)}`);try{let O=await V.getAccessToken();if(!O)throw Error("session expired");Y=O;let M=await rz(L,Y);X=$H(M.profileUrl)??X,C.stop(`${j.default.green("✓")} ${j.default.cyan(L.label)} → ${az(M)}`),I++}catch(O){let M=O.message;C.stop(`${j.default.red("×")} ${j.default.cyan(L.label)} ${j.default.red(M.slice(0,60))}`),w.push({label:L.label,error:M}),N++}}if(w.length>0)T1(w.map((L)=>`${j.default.red("•")} ${j.default.bold(L.label)}: ${L.error}`).join(`
308
- `),"Failures");let P=H>0?`, ${j.default.yellow(String(H))} skipped`:"";if(F1([`${j.default.green(String(I))} submitted${P}, ${N>0?j.default.red(String(N)):j.default.dim(String(N))} failed.`,`Held submissions stay visible at ${j.default.underline(X)}.`].join(`
309
- `)),N>0)process.exit(1)}async function iz($,Q){if(!Q){if(!$.endsWith(".zip"))throw Error(`Expected a .zip file or a folder, got: ${$}`);let X=await nz($);return X?[X]:[]}if(await A8(J1.join($,"pet.json"))){let X=await TY($);return X?[X]:[]}let V=await gz($,{withFileTypes:!0}),Y=[];for(let X of V){if(!X.isDirectory())continue;let J=J1.join($,X.name),G=await TY(J);if(G)Y.push(G)}return Y}async function TY($){let Q=J1.join($,"pet.json");if(!await A8(Q))return null;let q=J1.join($,"spritesheet.webp"),V="webp";if(!await A8(q)){let W=J1.join($,"spritesheet.png");if(!await A8(W))return null;q=W,V="png"}let Y=await Xq(Q,"utf8"),X={};try{X=JSON.parse(Y)}catch{throw Error(`pet.json in ${$} is not valid JSON`)}let J=await Xq(q),G=new Gq.default;G.file("pet.json",Y),G.file(`spritesheet.${V}`,J);let U=Buffer.from(await G.generateAsync({type:"uint8array",compression:"DEFLATE"})),K=J1.basename($);return{label:K,source:"folder",petJson:Y,petJsonObj:X,zipBuffer:U,zipFileName:`${K}.zip`,spritesheetBuffer:J,spritesheetExt:V,petIdHint:typeof X.id==="string"?X.id:K}}async function nz($){let Q=await Xq($),q=await Gq.default.loadAsync(Q),V=q.file("pet.json"),Y=q.file("spritesheet.webp"),X=q.file("spritesheet.png"),J=Y??X,G=Y?"webp":"png";if(!V||!J)throw Error(`Zip is missing pet.json or spritesheet.{webp,png}: ${$}`);let U=await V.async("string"),K={};try{K=JSON.parse(U)}catch{throw Error("pet.json in zip is not valid JSON")}let W=Buffer.from(await J.async("uint8array")),Z=J1.basename($,".zip");return{label:Z,source:"zip",petJson:U,petJsonObj:K,zipBuffer:Q,zipFileName:J1.basename($),spritesheetBuffer:W,spritesheetExt:G,petIdHint:typeof K.id==="string"?K.id:Z}}async function rz($,Q){let{width:q,height:V}=qH($.spritesheetBuffer);if(q===0||V===0)throw Error("spritesheet dimensions could not be parsed");let Y=await fetch(`${I1}/api/cli/submit`,{method:"POST",headers:{Authorization:`Bearer ${Q}`,"Content-Type":"application/json"},body:JSON.stringify({slugHint:X6($.petIdHint),petId:$.petIdHint,spritesheetExt:$.spritesheetExt})});if(!Y.ok){let H=await Y.text().catch(()=>"");throw Error(`presign ${Y.status} ${H.slice(0,100)}`)}let X=await Y.json(),J=(H)=>{let I=X.files.find((N)=>N.role===H);if(!I)throw Error(`presign response missing ${H}`);return I},G=J("zip"),U=J("sprite"),K=J("petjson"),W=$.spritesheetExt==="png"?"image/png":"image/webp";await Promise.all([Yq(G.uploadUrl,$.zipBuffer,"application/zip"),Yq(U.uploadUrl,$.spritesheetBuffer,W),Yq(K.uploadUrl,Buffer.from($.petJson,"utf8"),"application/json")]);let Z=await fetch(`${I1}/api/cli/submit/register`,{method:"POST",headers:{Authorization:`Bearer ${Q}`,"Content-Type":"application/json"},body:JSON.stringify({zipUrl:G.publicUrl,spritesheetUrl:U.publicUrl,petJsonUrl:K.publicUrl,petId:$.petIdHint,displayName:AY($.petJsonObj.displayName,"Untitled pet"),description:AY($.petJsonObj.description,"A Codex-compatible digital pet."),spritesheetWidth:q,spritesheetHeight:V})});if(!Z.ok){let H=await Z.text().catch(()=>"");throw Error(`register ${Z.status} ${H.slice(0,100)}`)}return await Z.json()}function az($){let Q=j.default.dim($.slug),q=sz($.review);if($.review.decision==="approved")return`${Q} ${j.default.green("approved")}`;if($.review.decision==="rejected")return`${Q} ${j.default.red("rejected")}${q?j.default.dim(`: ${q}`):""}`;return`${Q} ${j.default.yellow("held for review")}${q?j.default.dim(`: ${q}`):""}`}function sz($){let Q=$.reasonCode??"";if(Q.startsWith("duplicate_"))return $.summary??"appears to duplicate an existing pet";if(Q.startsWith("policy_"))return"possible policy issue";if(Q.startsWith("asset_"))return"package file or spritesheet issue";if(Q==="review_timeout")return"automated review timed out";if(Q==="review_error"||Q==="review_failed")return"automated review failed";if($.decision==="rejected")return"high-confidence automated review issue";if($.decision==="hold")return"not confident enough to approve automatically";return null}async function Yq($,Q,q){let V=await fetch($,{method:"PUT",headers:{"Content-Type":q},body:Q});if(!V.ok)throw Error(`R2 PUT ${V.status}`)}async function tz($,Q){let q=new Map;if($.length===0)return q;try{let V=await fetch(`${I1}/api/cli/submit/check`,{method:"POST",headers:{Authorization:`Bearer ${Q}`,"Content-Type":"application/json"},body:JSON.stringify({candidates:$.map((X)=>({petId:X.petIdHint,slugHint:X6(X.petIdHint)}))}),signal:AbortSignal.timeout(8000)});if(!V.ok)return q;let Y=await V.json();for(let X of Y.existing??[])if(X&&typeof X.slug==="string")q.set(X.slug,X)}catch{}return q}function ez($){let Q=$.toLowerCase();if(Q.includes("invalid_client")||Q.includes("client does not exist"))return["Clerk OAuth rejected this CLI build (invalid_client).","This usually means your installed CLI is out of date. Try:"," npm cache clean --force && npx -y petdex@latest login","If it still fails: https://github.com/crafter-station/petdex/issues"].join(`
310
- `);if(Q.includes("invalid_grant")||Q.includes("does not match the redirect"))return["OAuth callback was rejected by Clerk (invalid_grant).","Common cause: you closed the browser before approving, or the local","callback server timed out. Try `petdex login` again."].join(`
311
- `);if(Q.includes("redirect_uri")&&Q.includes("pre-registered"))return["Clerk OAuth rejected the local callback URL.","The petdex OAuth Application needs http://127.0.0.1 in its allowed","redirect URLs. Please file an issue:"," https://github.com/crafter-station/petdex/issues"].join(`
312
- `);return $}async function A8($){try{return await vY($),!0}catch{return!1}}function AY($,Q){if(typeof $==="string"&&$.trim())return $.trim();return Q}function F8($){return typeof $==="string"&&$.trim()?$.trim():null}function xY(...$){for(let Q of $){let q=F8(Q);if(q)return q}return null}function SY($){let Q=I1.replace(/\/+$/,""),q=$.startsWith("/")?$:`/${$}`;return`${Q}${q}`}function $H($){if(!$)return null;if($.startsWith("http://")||$.startsWith("https://"))return $;return SY($)}function QH($){let Q=xY($?.preferred_username,$?.username)??(typeof $?.sub==="string"?$.sub.slice(-8).toLowerCase():null);return Q?SY(`/u/${encodeURIComponent(Q.toLowerCase())}`):I1}function X6($){return $.toLowerCase().trim().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,40)}function qH($){if($.length>24&&$[0]===137&&$[1]===80&&$[2]===78&&$[3]===71)return{width:$.readUInt32BE(16),height:$.readUInt32BE(20)};if($.length>30&&$.slice(0,4).toString()==="RIFF"&&$.slice(8,12).toString()==="WEBP"){let Q=$.slice(12,16).toString();if(Q==="VP8X")return{width:(($[24]|$[25]<<8|$[26]<<16)>>>0)+1,height:(($[27]|$[28]<<8|$[29]<<16)>>>0)+1};if(Q==="VP8L"){let q=$[22],V=$[23],Y=$[24];return{width:(($[21]|(q&63)<<8)>>>0)+1,height:((q>>6|V<<2|(Y&15)<<10)>>>0)+1}}if(Q==="VP8 "){for(let q=23;q<Math.min(60,$.length-7);q++)if($[q]===157&&$[q+1]===1&&$[q+2]===42)return{width:($[q+3]|$[q+4]<<8)&16383,height:($[q+5]|$[q+6]<<8)&16383}}}return{width:0,height:0}}async function VH($){let Q=$[0];if(!Q||Q==="--help"||Q==="-h"||Q==="help"){FY();return}switch(Q){case"install":{let{installedAgents:q}=await sQ();if(q.length>0)Y6("cli_hooks_install_success",{cli_version:U$,agents:q}),console.log(""),console.log(`${j.default.green("✓")} ${j.default.bold("All set.")} Open your agent and run ${j.default.cyan("/petdex")} to wake the mascot.`);break}case"toggle":case"on":case"off":case"status":{JH(Q);break}case"uninstall":{let q=$.includes("--remove-token");await qY({removeToken:q});break}case"refresh":{let{runRefresh:q}=await Promise.resolve().then(() => (Qq(),$q)),V=await q();if(V.binaryPersisted)console.log(`${j.default.green("✓")} Snapshotted petdex binary at ${j.default.dim("~/.petdex/bin/petdex.js")}`);else if(V.binaryReason)console.log(`${j.default.yellow("!")} Binary snapshot skipped: ${V.binaryReason}`);for(let X of V.refreshed)console.log(`${j.default.green("✓")} Refreshed ${X}`);for(let{id:X,reason:J}of V.skipped){if(J==="not installed")continue;console.log(`${j.default.yellow("!")} Skipped ${X}: ${J}`)}let Y=V.refreshed.length;if(console.log(""),Y===0)console.log(`${j.default.dim("No wired agents found. Run")} ${j.default.cyan("petdex init")} ${j.default.dim("first.")}`);else console.log(`${j.default.green("✓")} ${j.default.bold(`${Y} agent${Y===1?"":"s"} refreshed.`)} Restart your agent to load the new hooks.`);break}default:console.error(j.default.red(`Unknown hooks command: ${Q}`)),FY(),process.exit(1)}}function JH($){let Q;if($==="toggle")Q=hJ();else if($==="on")Q=K$("on");else if($==="off")Q=K$("off");else Q=G$();if(Q==="on")console.log(`${j.default.green("●")} Petdex hooks are ${j.default.bold("ENABLED")}`),console.log(j.default.dim(" agent tool calls will animate the mascot when petdex-desktop is running"));else console.log(`${j.default.yellow("○")} Petdex hooks are ${j.default.bold("DISABLED")}`),console.log(j.default.dim(" agent hooks short-circuit before any network call. Re-enable: petdex hooks on"))}async function YH(){let $=m1();if(!kz($)){console.log(j.default.dim(`${j.default.yellow("!")} No desktop binary found. Installing the bare binary at ${j.default.cyan("~/.petdex/bin/")}...`)),console.log(j.default.dim(` (For the proper macOS app icon, download the DMG from ${j.default.cyan("https://petdex.crafter.run/download")} instead.)`)),console.log("");try{await pQ()}catch(Y){console.error(`${j.default.red("✗")} Could not install desktop: ${Y.message}`),console.error(j.default.dim(` You can still proceed by downloading the DMG: ${j.default.cyan("https://petdex.crafter.run/download")}`))}}else{let Y=$.includes("/Petdex.app/Contents/MacOS/");console.log(`${j.default.green("●")} Desktop already installed at ${j.default.cyan(XH($))}${Y?j.default.dim(" (DMG)"):j.default.dim(" (bare)")}`)}let{installedAgents:q}=await sQ();if(q.length>0)Y6("cli_hooks_install_success",{cli_version:U$,agents:q});let V=c1();if(V.state==="running")console.log(`${j.default.green("●")} Desktop already running (pid ${V.pid})`);else{let Y=await Y$();if(Y.ok)console.log(Y.alreadyRunning?`${j.default.dim("•")} Desktop already running (pid ${Y.pid})`:`${j.default.green("✓")} Desktop started (pid ${Y.pid})`);else console.log(`${j.default.yellow("!")} Could not start desktop: ${Y.reason}`),console.log(j.default.dim(` Open ${j.default.cyan("/Applications/Petdex.app")} once manually, then re-run ${j.default.cyan("petdex up")}.`))}console.log(""),console.log(`${j.default.green("✓")} ${j.default.bold("All set.")} Open your agent and run ${j.default.cyan("/petdex")} to wake the mascot.`),console.log(j.default.dim(` Or from a shell: ${j.default.cyan("petdex up")} (force-wake) · ${j.default.cyan("petdex toggle")} (smart wake/sleep)`))}function XH($){let Q=process.env.HOME;if(Q&&$.startsWith(Q))return`~${$.slice(Q.length)}`;return $}async function EY(){K$("on"),console.log(`${j.default.green("●")} Hooks ${j.default.bold("ENABLED")}`);let $=c1();if($.state==="running"){console.log(`${j.default.green("●")} Desktop already running (pid ${$.pid})`);return}let Q=await Y$();if(Q.ok)console.log(Q.alreadyRunning?`${j.default.dim("•")} Desktop already running (pid ${Q.pid})`:`${j.default.green("✓")} Desktop started (pid ${Q.pid})`);else console.log(`${j.default.yellow("!")} ${Q.reason}`),console.log(j.default.dim(` Install the binary first: ${j.default.cyan("petdex install desktop")}`))}async function GH(){let $=G$()==="on",Q=c1().state==="running";if($&&Q)await yY();else await EY()}async function yY(){if(K$("off"),console.log(`${j.default.yellow("○")} Hooks ${j.default.bold("DISABLED")}`),c1().state==="stopped"){console.log(`${j.default.dim("•")} Desktop wasn't running`);return}let Q=await X$();if(Q.ok)console.log(`${j.default.green("✓")} Desktop stopped (pid ${Q.pid})`);else console.log(`${j.default.dim("•")} ${Q.reason}`)}function FY(){let $=j.default.cyan,Q=j.default.dim;console.log(["",` ${j.default.bold(j.default.magenta("petdex hooks"))}`,"",` ${$("Usage")}`," petdex hooks <command>","",` ${$("Commands")}`,` ${j.default.bold("install")} Wire petdex into your coding agents`,` ${j.default.bold("refresh")} Re-write hook configs + slash commands for already-wired agents (non-interactive)`,` ${j.default.bold("uninstall")} Remove petdex from your agent configs (--remove-token also drops the auth token)`,` ${j.default.bold("toggle")} Flip the killswitch. Disable/enable hooks without restarting agents`,` ${j.default.bold("on")} Enable hooks (clears the killswitch)`,` ${j.default.bold("off")} Disable hooks (sets the killswitch, agent tool calls become no-ops)`,` ${j.default.bold("status")} Show whether hooks are currently enabled`,"",` ${$("Examples")}`,` ${Q("$")} petdex hooks install`,` ${Q("$")} petdex hooks toggle`,` ${Q("$")} petdex hooks status`,""].join(`
313
- `))}async function KH($){let Q=$[0];if(!Q||Q==="--help"||Q==="-h"||Q==="help"){RY();return}switch(Q){case"start":await EJ(),Y6("cli_desktop_start_success",{cli_version:U$});break;case"stop":await yJ();break;case"status":kJ();break;default:console.error(j.default.red(`Unknown desktop command: ${Q}`)),RY(),process.exit(1)}}function RY(){let $=j.default.cyan,Q=j.default.dim;console.log(["",` ${j.default.bold(j.default.magenta("petdex desktop"))}`,"",` ${$("Usage")}`," petdex desktop <command>","",` ${$("Commands")}`,` ${j.default.bold("start")} Launch petdex-desktop in the background`,` ${j.default.bold("stop")} Terminate the running petdex-desktop process`,` ${j.default.bold("status")} Show whether petdex-desktop is running`,"",` ${$("Examples")}`,` ${Q("$")} petdex desktop start`,` ${Q("$")} petdex desktop status`,` ${Q("$")} petdex desktop stop`,""].join(`
314
- `))}function WH($){let Q=$[0];if(Q==="on"||Q==="off"){let q=Q==="on";if(GY(q))console.log(q?"Telemetry enabled":"Telemetry disabled");else console.error(j.default.red(`${j.default.bold("Failed to persist preference.")} ~/.petdex/telemetry.json is not writable. Check filesystem permissions, then run \`petdex telemetry ${Q}\` again.`)),process.exit(1)}else if(Q==="status"||!Q){let q=KY();if(console.log(`Status: ${q.enabled?"enabled":"disabled"}`),q.install_id)console.log(`Install ID: ${q.install_id}`)}else console.error(j.default.red(`Unknown telemetry subcommand: ${Q}`)),console.error("Use: petdex telemetry [on|off|status]"),process.exit(1)}
433
+ ${Z.default.dim("Install with")} ${Z.default.cyan("petdex install <slug>")}
434
+ ${Z.default.dim("Browse:")} ${Z.default.underline(V0)}`)}async function MF(Q){let J=Q.filter((L)=>!L.startsWith("--"))[0];if(!J)r(`Usage: ${Z.default.cyan("petdex submit <path> [--force]")}`),process.exit(1);let q=await v8(),Y;try{let L=await q.getAccessToken();if(!L)r(`Not signed in. Run ${Z.default.cyan("petdex login")}.`),process.exit(1);Y=L}catch{r(`Not signed in. Run ${Z.default.cyan("petdex login")}.`),process.exit(1)}let V=V0;try{V=vF(await q.whoami())}catch{}let X=j0.resolve(J),K=await x3(X).catch(()=>null);if(!K)r(`No such file or directory: ${J}`),process.exit(1);A0(Z.default.bgMagenta(Z.default.white(" petdex submit ")));let W=H0();W.start(`Scanning ${X}`);let G=await IF(X,K.isDirectory());if(W.stop(G.length>0?`${G.length} pet${G.length===1?"":"s"} found`:Z.default.red("no pets found")),G.length===0)r("A pet folder must contain pet.json and spritesheet.{webp,png}."),process.exit(1);let z=Q.includes("--force")?new Map:await wF(G,Y),j=G,H=0;if(z.size>0){let L=G.filter((O)=>z.has(x8(O.petIdHint))),A=G.filter((O)=>!z.has(x8(O.petIdHint)));_0(L.map((O)=>{let C=z.get(x8(O.petIdHint))?.status??"unknown";return`${Z.default.yellow("•")} ${Z.default.bold(O.label)} ${Z.default.dim(`(${C})`)}`}).join(`
435
+ `),`${L.length} already submitted by you`);let B=await v7({message:"How should we handle these duplicates?",options:[{value:"skip",label:"Skip duplicates (recommended)"},{value:"resubmit",label:"Submit all anyway (will create -2 / -3 slugs)"},{value:"cancel",label:"Cancel"}],initialValue:"skip"});if(L1(B)||B==="cancel")r("Aborted."),process.exit(1);if(B==="skip"){if(j=A,H=L.length,j.length===0){D0(`Nothing new to submit. Track approval at ${Z.default.underline(V)}.`);return}}}if(j.length>1){let L=await f8({message:`Submit ${Z.default.bold(String(j.length))} pet${j.length===1?"":"s"}?`});if(L1(L)||!L)r("Aborted."),process.exit(1)}let F=0,N=0,T=[];for(let L of j){let A=H0();A.start(`Submitting ${Z.default.cyan(L.label)}`);try{let B=await q.getAccessToken();if(!B)throw Error("session expired");Y=B;let O=await CF(L,Y);V=xF(O.profileUrl)??V,A.stop(`${Z.default.green("✓")} ${Z.default.cyan(L.label)} → ${AF(O)}`),F++}catch(B){let O=B.message;A.stop(`${Z.default.red("×")} ${Z.default.cyan(L.label)} ${Z.default.red(O.slice(0,60))}`),T.push({label:L.label,error:O}),N++}}if(T.length>0)_0(T.map((L)=>`${Z.default.red("•")} ${Z.default.bold(L.label)}: ${L.error}`).join(`
436
+ `),"Failures");let P=H>0?`, ${Z.default.yellow(String(H))} skipped`:"";if(D0([`${Z.default.green(String(F))} submitted${P}, ${N>0?Z.default.red(String(N)):Z.default.dim(String(N))} failed.`,`Held submissions stay visible at ${Z.default.underline(V)}.`].join(`
437
+ `)),N>0)process.exit(1)}async function PF(Q){let J=Q.filter((L)=>!L.startsWith("--"))[0];if(!J)r(`Usage: ${Z.default.cyan('petdex edit <slug> [--desc "..."] [--displayName "..."] [--sprite ./new.webp] [--meta ./pet.json] [--zip ./pet.zip]')}`),process.exit(1);let q=await v8(),Y;try{let L=await q.getAccessToken();if(!L)r(`Not signed in. Run ${Z.default.cyan("petdex login")}.`),process.exit(1);Y=L}catch{r(`Not signed in. Run ${Z.default.cyan("petdex login")}.`),process.exit(1)}function V(L){let A=Q.indexOf(L);if(A===-1)return null;let B=Q[A+1];return typeof B==="string"&&!B.startsWith("--")?B:null}let X=V("--desc"),K=V("--displayName"),W=V("--sprite"),G=V("--meta"),U=V("--zip");if(!X&&!K&&!W&&!G&&!U)r("Nothing to edit. Provide at least one flag."),process.exit(1);A0(Z.default.bgMagenta(Z.default.white(" petdex edit ")));let z=H0();z.start(`Resolving ${J}`);let j=await fetch(`${V0}/api/pets/${J}`,{headers:{Authorization:`Bearer ${Y}`}});if(!j.ok)z.stop(Z.default.red("not found")),r(`Pet "${J}" not found or you don't own it.`),process.exit(1);let F=(await j.json()).id;if(!F)z.stop(Z.default.red("could not resolve pet id")),process.exit(1);z.stop(`Found ${Z.default.cyan(J)}`);let N={};if(X)N.description=X;if(K)N.displayName=K;if(W||G||U){z.start("Uploading assets");let L=await fetch(`${V0}/api/cli/edit-presign`,{method:"POST",headers:{Authorization:`Bearer ${Y}`,"Content-Type":"application/json"},body:JSON.stringify({petId:F,hasSprite:Boolean(W),hasMeta:Boolean(G),hasZip:Boolean(U)})});if(L.ok){let A=await L.json(),B=(O)=>A.files?.find((M)=>M.role===O)??null;if(W){let O=await import("node:fs/promises").then((D)=>D.readFile(W)),M=W.endsWith(".png")?"image/png":"image/webp",C=B("sprite");if(C){await x6(C.uploadUrl,O,M);let{width:D,height:x}=S3(O);if(N.spritesheetUrl=C.publicUrl,D)N.spritesheetWidth=D;if(x)N.spritesheetHeight=x}}if(G){let O=await import("node:fs/promises").then((C)=>C.readFile(G)),M=B("petjson");if(M)await x6(M.uploadUrl,O,"application/json"),N.petJsonUrl=M.publicUrl}if(U){let O=await import("node:fs/promises").then((C)=>C.readFile(U)),M=B("zip");if(M)await x6(M.uploadUrl,O,"application/zip"),N.zipUrl=M.publicUrl}z.stop("Assets uploaded")}else z.stop(Z.default.yellow("presign endpoint unavailable, skipping asset upload"))}z.start("Submitting edit");let T=await fetch(`${V0}/api/my-pets/${F}/edit`,{method:"PATCH",headers:{Authorization:`Bearer ${Y}`,"Content-Type":"application/json",Origin:V0},body:JSON.stringify(N)});if(!T.ok){let L=await T.text().catch(()=>"");z.stop(Z.default.red(`edit failed: ${T.status}`)),r(L.slice(0,120)),process.exit(1)}let P=await T.json();z.stop(P.status==="auto_approved"?`${Z.default.green("✓")} Edit auto-approved and live`:`${Z.default.yellow("·")} Edit queued for admin review`),P0("cli_edit_invoked",{cli_version:c0}),D0(`Gallery: ${Z.default.underline(`${V0}/pets/${J}`)}`)}async function IF(Q,$){if(!$){if(!Q.endsWith(".zip"))throw Error(`Expected a .zip file or a folder, got: ${Q}`);let V=await TF(Q);return V?[V]:[]}if(await a2(j0.join(Q,"pet.json"))){let V=await A3(Q);return V?[V]:[]}let q=await GF(Q,{withFileTypes:!0}),Y=[];for(let V of q){if(!V.isDirectory())continue;let X=j0.join(Q,V.name),K=await A3(X);if(K)Y.push(K)}return Y}async function A3(Q){let $=j0.join(Q,"pet.json");if(!await a2($))return null;let J=j0.join(Q,"spritesheet.webp"),q="webp";if(!await a2(J)){let U=j0.join(Q,"spritesheet.png");if(!await a2(U))return null;J=U,q="png"}let Y=await nQ($,"utf8"),V={};try{V=JSON.parse(Y)}catch{throw Error(`pet.json in ${Q} is not valid JSON`)}let X=await nQ(J),K=new rQ.default;K.file("pet.json",Y),K.file(`spritesheet.${q}`,X);let W=Buffer.from(await K.generateAsync({type:"uint8array",compression:"DEFLATE"})),G=j0.basename(Q);return{label:G,source:"folder",petJson:Y,petJsonObj:V,zipBuffer:W,zipFileName:`${G}.zip`,spritesheetBuffer:X,spritesheetExt:q,petIdHint:typeof V.id==="string"?V.id:G}}async function TF(Q){let $=await nQ(Q),J=await rQ.default.loadAsync($),q=J.file("pet.json"),Y=J.file("spritesheet.webp"),V=J.file("spritesheet.png"),X=Y??V,K=Y?"webp":"png";if(!q||!X)throw Error(`Zip is missing pet.json or spritesheet.{webp,png}: ${Q}`);let W=await q.async("string"),G={};try{G=JSON.parse(W)}catch{throw Error("pet.json in zip is not valid JSON")}let U=Buffer.from(await X.async("uint8array")),z=j0.basename(Q,".zip");return{label:z,source:"zip",petJson:W,petJsonObj:G,zipBuffer:$,zipFileName:j0.basename(Q),spritesheetBuffer:U,spritesheetExt:K,petIdHint:typeof G.id==="string"?G.id:z}}async function CF(Q,$){let{width:J,height:q}=S3(Q.spritesheetBuffer);if(J===0||q===0)throw Error("spritesheet dimensions could not be parsed");let Y=await fetch(`${V0}/api/cli/submit`,{method:"POST",headers:{Authorization:`Bearer ${$}`,"Content-Type":"application/json"},body:JSON.stringify({slugHint:x8(Q.petIdHint),petId:Q.petIdHint,spritesheetExt:Q.spritesheetExt})});if(!Y.ok){let H=await Y.text().catch(()=>"");throw Error(`presign ${Y.status} ${H.slice(0,100)}`)}let V=await Y.json(),X=(H)=>{let F=V.files.find((N)=>N.role===H);if(!F)throw Error(`presign response missing ${H}`);return F},K=X("zip"),W=X("sprite"),G=X("petjson"),U=Q.spritesheetExt==="png"?"image/png":"image/webp";await Promise.all([x6(K.uploadUrl,Q.zipBuffer,"application/zip"),x6(W.uploadUrl,Q.spritesheetBuffer,U),x6(G.uploadUrl,Buffer.from(Q.petJson,"utf8"),"application/json")]);let z=await fetch(`${V0}/api/cli/submit/register`,{method:"POST",headers:{Authorization:`Bearer ${$}`,"Content-Type":"application/json"},body:JSON.stringify({zipUrl:K.publicUrl,spritesheetUrl:W.publicUrl,petJsonUrl:G.publicUrl,petId:Q.petIdHint,displayName:D3(Q.petJsonObj.displayName,"Untitled pet"),description:D3(Q.petJsonObj.description,"A Codex-compatible digital pet."),spritesheetWidth:J,spritesheetHeight:q})});if(!z.ok){let H=await z.text().catch(()=>"");throw Error(`register ${z.status} ${H.slice(0,100)}`)}return await z.json()}function AF(Q){let $=Z.default.dim(Q.slug),J=DF(Q.review);if(Q.review.decision==="approved")return`${$} ${Z.default.green("approved")}`;if(Q.review.decision==="rejected")return`${$} ${Z.default.red("rejected")}${J?Z.default.dim(`: ${J}`):""}`;return`${$} ${Z.default.yellow("held for review")}${J?Z.default.dim(`: ${J}`):""}`}function DF(Q){let $=Q.reasonCode??"";if($.startsWith("duplicate_"))return Q.summary??"appears to duplicate an existing pet";if($.startsWith("policy_"))return"possible policy issue";if($.startsWith("asset_"))return"package file or spritesheet issue";if($==="review_timeout")return"automated review timed out";if($==="review_error"||$==="review_failed")return"automated review failed";if(Q.decision==="rejected")return"high-confidence automated review issue";if(Q.decision==="hold")return"not confident enough to approve automatically";return null}async function x6(Q,$,J){let q=await fetch(Q,{method:"PUT",headers:{"Content-Type":J},body:$});if(!q.ok)throw Error(`R2 PUT ${q.status}`)}async function wF(Q,$){let J=new Map;if(Q.length===0)return J;try{let q=await fetch(`${V0}/api/cli/submit/check`,{method:"POST",headers:{Authorization:`Bearer ${$}`,"Content-Type":"application/json"},body:JSON.stringify({candidates:Q.map((V)=>({petId:V.petIdHint,slugHint:x8(V.petIdHint)}))}),signal:AbortSignal.timeout(8000)});if(!q.ok)return J;let Y=await q.json();for(let V of Y.existing??[])if(V&&typeof V.slug==="string")J.set(V.slug,V)}catch{}return J}function RF(Q){let $=Q.toLowerCase();if($.includes("invalid_client")||$.includes("client does not exist"))return["Clerk OAuth rejected this CLI build (invalid_client).","This usually means your installed CLI is out of date. Try:"," npm cache clean --force && npx -y petdex@latest login","If it still fails: https://github.com/crafter-station/petdex/issues"].join(`
438
+ `);if($.includes("invalid_grant")||$.includes("does not match the redirect"))return["OAuth callback was rejected by Clerk (invalid_grant).","Common cause: you closed the browser before approving, or the local","callback server timed out. Try `petdex login` again."].join(`
439
+ `);if($.includes("redirect_uri")&&$.includes("pre-registered"))return["Clerk OAuth rejected the local callback URL.","The petdex OAuth Application needs http://127.0.0.1 in its allowed","redirect URLs. Please file an issue:"," https://github.com/crafter-station/petdex/issues"].join(`
440
+ `);return Q}async function a2(Q){try{return await x3(Q),!0}catch{return!1}}function D3(Q,$){if(typeof Q==="string"&&Q.trim())return Q.trim();return $}function s2(Q){return typeof Q==="string"&&Q.trim()?Q.trim():null}function v3(...Q){for(let $ of Q){let J=s2($);if(J)return J}return null}function E3(Q){let $=V0.replace(/\/+$/,""),J=Q.startsWith("/")?Q:`/${Q}`;return`${$}${J}`}function xF(Q){if(!Q)return null;if(Q.startsWith("http://")||Q.startsWith("https://"))return Q;return E3(Q)}function vF(Q){let $=v3(Q?.preferred_username,Q?.username)??(typeof Q?.sub==="string"?Q.sub.slice(-8).toLowerCase():null);return $?E3(`/u/${encodeURIComponent($.toLowerCase())}`):V0}function x8(Q){return Q.toLowerCase().trim().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,40)}function S3(Q){if(Q.length>24&&Q[0]===137&&Q[1]===80&&Q[2]===78&&Q[3]===71)return{width:Q.readUInt32BE(16),height:Q.readUInt32BE(20)};if(Q.length>30&&Q.slice(0,4).toString()==="RIFF"&&Q.slice(8,12).toString()==="WEBP"){let $=Q.slice(12,16).toString();if($==="VP8X")return{width:((Q[24]|Q[25]<<8|Q[26]<<16)>>>0)+1,height:((Q[27]|Q[28]<<8|Q[29]<<16)>>>0)+1};if($==="VP8L"){let J=Q[22],q=Q[23],Y=Q[24];return{width:((Q[21]|(J&63)<<8)>>>0)+1,height:((J>>6|q<<2|(Y&15)<<10)>>>0)+1}}if($==="VP8 "){for(let J=23;J<Math.min(60,Q.length-7);J++)if(Q[J]===157&&Q[J+1]===1&&Q[J+2]===42)return{width:(Q[J+3]|Q[J+4]<<8)&16383,height:(Q[J+5]|Q[J+6]<<8)&16383}}}return{width:0,height:0}}async function EF(Q){let $=Q[0];if(!$||$==="--help"||$==="-h"||$==="help"){w3();return}switch($){case"install":{let{installedAgents:J}=await SQ();if(J.length>0)P0("cli_hooks_install_success",{cli_version:c0,agents:J}),console.log(""),console.log(`${Z.default.green("✓")} ${Z.default.bold("All set.")} Open your agent and run ${Z.default.cyan("/petdex")} to wake the mascot.`);break}case"toggle":case"on":case"off":case"status":{SF($);break}case"uninstall":{let J=Q.includes("--remove-token");await q3({removeToken:J});break}case"refresh":{let{runRefresh:J}=await Promise.resolve().then(() => (_Q(),gQ)),q=await J();if(q.binaryPersisted)console.log(`${Z.default.green("✓")} Snapshotted petdex binary at ${Z.default.dim("~/.petdex/bin/petdex.js")}`);else if(q.binaryReason)console.log(`${Z.default.yellow("!")} Binary snapshot skipped: ${q.binaryReason}`);for(let V of q.refreshed)console.log(`${Z.default.green("✓")} Refreshed ${V}`);for(let{id:V,reason:X}of q.skipped){if(X==="not installed")continue;console.log(`${Z.default.yellow("!")} Skipped ${V}: ${X}`)}let Y=q.refreshed.length;if(console.log(""),Y===0)console.log(`${Z.default.dim("No wired agents found. Run")} ${Z.default.cyan("petdex init")} ${Z.default.dim("first.")}`);else console.log(`${Z.default.green("✓")} ${Z.default.bold(`${Y} agent${Y===1?"":"s"} refreshed.`)} Restart your agent to load the new hooks.`);break}default:console.error(Z.default.red(`Unknown hooks command: ${$}`)),w3(),process.exit(1)}}function SF(Q){let $;if(Q==="toggle")$=ZY();else if(Q==="on")$=T6("on");else if(Q==="off")$=T6("off");else $=I6();if($==="on")console.log(`${Z.default.green("●")} Petdex hooks are ${Z.default.bold("ENABLED")}`),console.log(Z.default.dim(" agent tool calls will animate the mascot when petdex-desktop is running"));else console.log(`${Z.default.yellow("○")} Petdex hooks are ${Z.default.bold("DISABLED")}`),console.log(Z.default.dim(" agent hooks short-circuit before any network call. Re-enable: petdex hooks on"))}async function kF(){P0("cli_init_started",{cli_version:c0,os:process.platform,arch:process.arch});let Q=E0(),$=P3(Q),J=$,q=null;if(!$){console.log(Z.default.dim(`${Z.default.yellow("!")} No desktop app found. Installing Petdex Desktop...`)),console.log("");try{await PQ(),J=P3(E0())}catch(K){q=K.message,console.error(`${Z.default.red("✗")} Could not install desktop: ${q}`),console.error(Z.default.dim(" Continuing with hooks-only setup."))}}else{let K=Q.includes("/Petdex.app/Contents/MacOS/");console.log(`${Z.default.green("●")} Desktop already installed at ${Z.default.cyan(yF(Q))}${K?Z.default.dim(" (DMG)"):Z.default.dim(" (bare)")}`)}let Y=await MQ(),{installedAgents:V}=await SQ(),X=!1;if(J){let K=Q1();if(K.state==="running")X=!0,console.log(`${Z.default.green("●")} Desktop already running (pid ${K.pid})`);else{let W=await w6();if(W.ok){if(X=!0,!W.alreadyRunning)P0("cli_desktop_start_success",{cli_version:c0});console.log(W.alreadyRunning?`${Z.default.dim("•")} Desktop already running (pid ${W.pid})`:`${Z.default.green("✓")} Desktop started (pid ${W.pid})`)}else console.log(`${Z.default.yellow("!")} Could not start desktop: ${W.reason}`),console.log(Z.default.dim(` Open ${Z.default.cyan("/Applications/Petdex.app")} once manually, then re-run ${Z.default.cyan("petdex up")}.`))}}if(console.log(""),console.log(Z.default.bold("Setup summary")),console.log(J?`${Z.default.green("✓")} Desktop installed${X?" and running":""}`:`${Z.default.yellow("!")} Desktop not installed`),console.log(Y.status==="installed"?`${Z.default.green("✓")} Starter pet installed: ${Y.slug}`:Y.status==="present"?`${Z.default.green("✓")} Pet library ready`:`${Z.default.yellow("!")} No starter pet installed`),console.log(V.length>0?`${Z.default.green("✓")} Hooks installed for ${V.join(", ")}`:`${Z.default.yellow("!")} No agent hooks installed`),q)console.log(Z.default.dim(` Desktop install issue: ${q}`));if(J)console.log(""),console.log(`${Z.default.green("✓")} ${Z.default.bold("All set.")} Open your agent and run ${Z.default.cyan("/petdex")} to wake the mascot.`),console.log(Z.default.dim(` Or from a shell: ${Z.default.cyan("petdex up")} (force-wake) · ${Z.default.cyan("petdex toggle")} (smart wake/sleep)`));else console.log(""),console.log(`${Z.default.yellow("!")} Hooks-only setup finished. Desktop still needs a supported build for this platform.`),console.log(Z.default.dim(` Try again later with ${Z.default.cyan("petdex update")}.`))}function yF(Q){let $=process.env.HOME;if($&&Q.startsWith($))return`~${Q.slice($.length)}`;return Q}async function k3(){P0("cli_up_invoked",{cli_version:c0}),T6("on"),console.log(`${Z.default.green("●")} Hooks ${Z.default.bold("ENABLED")}`);let Q=Q1();if(Q.state==="running"){console.log(`${Z.default.green("●")} Desktop already running (pid ${Q.pid})`);return}let $=await w6();if($.ok){if(!$.alreadyRunning)P0("cli_desktop_start_success",{cli_version:c0});console.log($.alreadyRunning?`${Z.default.dim("•")} Desktop already running (pid ${$.pid})`:`${Z.default.green("✓")} Desktop started (pid ${$.pid})`)}else console.log(`${Z.default.yellow("!")} ${$.reason}`),console.log(Z.default.dim(` Install the binary first: ${Z.default.cyan("petdex install desktop")}`))}async function gF(){let Q=I6()==="on",$=Q1().state==="running";if(Q&&$)await y3();else await k3()}async function y3(){if(T6("off"),console.log(`${Z.default.yellow("○")} Hooks ${Z.default.bold("DISABLED")}`),Q1().state==="stopped"){console.log(`${Z.default.dim("•")} Desktop wasn't running`);return}let $=await C8();if($.ok)console.log(`${Z.default.green("✓")} Desktop stopped (pid ${$.pid})`);else console.log(`${Z.default.dim("•")} ${$.reason}`)}function w3(){let Q=Z.default.cyan,$=Z.default.dim;console.log(["",` ${Z.default.bold(Z.default.magenta("petdex hooks"))}`,"",` ${Q("Usage")}`," petdex hooks <command>","",` ${Q("Commands")}`,` ${Z.default.bold("install")} Wire petdex into your coding agents`,` ${Z.default.bold("refresh")} Re-write hook configs + slash commands for already-wired agents (non-interactive)`,` ${Z.default.bold("uninstall")} Remove petdex from your agent configs (--remove-token also drops the auth token)`,` ${Z.default.bold("toggle")} Flip the killswitch. Disable/enable hooks without restarting agents`,` ${Z.default.bold("on")} Enable hooks (clears the killswitch)`,` ${Z.default.bold("off")} Disable hooks (sets the killswitch, agent tool calls become no-ops)`,` ${Z.default.bold("status")} Show whether hooks are currently enabled`,"",` ${Q("Examples")}`,` ${$("$")} petdex hooks install`,` ${$("$")} petdex hooks toggle`,` ${$("$")} petdex hooks status`,""].join(`
441
+ `))}async function _F(Q){let $=Q[0];if(!$||$==="--help"||$==="-h"||$==="help"){R3();return}switch($){case"start":await EY(),P0("cli_desktop_start_success",{cli_version:c0});break;case"stop":await SY();break;case"status":kY();break;default:console.error(Z.default.red(`Unknown desktop command: ${$}`)),R3(),process.exit(1)}}function R3(){let Q=Z.default.cyan,$=Z.default.dim;console.log(["",` ${Z.default.bold(Z.default.magenta("petdex desktop"))}`,"",` ${Q("Usage")}`," petdex desktop <command>","",` ${Q("Commands")}`,` ${Z.default.bold("start")} Launch petdex-desktop in the background`,` ${Z.default.bold("stop")} Terminate the running petdex-desktop process`,` ${Z.default.bold("status")} Show whether petdex-desktop is running`,"",` ${Q("Examples")}`,` ${$("$")} petdex desktop start`,` ${$("$")} petdex desktop status`,` ${$("$")} petdex desktop stop`,""].join(`
442
+ `))}function bF(Q){let $=Q[0];if($==="on"||$==="off"){let J=$==="on";if(hY(J))console.log(J?"Telemetry enabled":"Telemetry disabled");else console.error(Z.default.red(`${Z.default.bold("Failed to persist preference.")} ~/.petdex/telemetry.json is not writable. Check filesystem permissions, then run \`petdex telemetry ${$}\` again.`)),process.exit(1)}else if($==="status"||!$){let J=fY();if(console.log(`Status: ${J.enabled?"enabled":"disabled"}`),J.install_id)console.log(`Install ID: ${J.install_id}`)}else console.error(Z.default.red(`Unknown telemetry subcommand: ${$}`)),console.error("Use: petdex telemetry [on|off|status]"),process.exit(1)}