petdex 0.4.2 → 0.4.3

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 +3 -3
  2. package/dist/petdex.js +103 -103
  3. package/package.json +1 -1
package/dist/petdex.js CHANGED
@@ -1,81 +1,81 @@
1
1
  #!/usr/bin/env node
2
- import{createRequire as s3}from"node:module";var u3=Object.create;var{getPrototypeOf:p3,defineProperty:e2,getOwnPropertyNames:d3}=Object;var l3=Object.prototype.hasOwnProperty;function o3(Q){return this[Q]}var i3,n3,p0=(Q,$,q)=>{var J=Q!=null&&typeof Q==="object";if(J){var Y=$?i3??=new WeakMap:n3??=new WeakMap,V=Y.get(Q);if(V)return V}q=Q!=null?u3(p3(Q)):{};let X=$||!Q||!Q.__esModule?e2(q,"default",{value:Q,enumerable:!0}):q;for(let K of d3(Q))if(!l3.call(X,K))e2(X,K,{get:o3.bind(Q,K),enumerable:!0});if(J)Y.set(Q,X);return X};var w=(Q,$)=>()=>($||Q(($={exports:{}}).exports,$),$.exports);var r3=(Q)=>Q;function a3(Q,$){this[Q]=r3.bind(null,$)}var E8=(Q,$)=>{for(var q in $)e2(Q,q,{get:$[q],enumerable:!0,configurable:!0,set:a3.bind($,q)})};var H0=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var _=s3(import.meta.url);var eQ,Q7=(Q)=>{return Q===12288||Q>=65281&&Q<=65376||Q>=65504&&Q<=65510},$7=(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 q7=H0(()=>{eQ=(()=>{let Q=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return($)=>{let q=0;Q.lastIndex=0;while(Q.test($))q+=1;return $.length-q}})()});var t3,e3,J7,QV,Y7,$V,qV,JV,V7=(Q,$={},q={})=>{let J=$.limit??1/0,Y=$.ellipsis??"",V=$?.ellipsisWidth??(Y?V7(Y,JV,q).width:0),X=0,K=q.controlWidth??0,W=q.tabWidth??8,G=q.emojiWidth??2,U=2,z=q.regularWidth??1,Z=q.wideWidth??2,H=[[$V,z],[t3,0],[e3,K],[QV,W],[Y7,G],[J7,Z]],F=0,N=0,C=Q.length,P=0,L=!1,A=C,B=Math.max(0,J-V),O=0,M=0,T=0,D=0;Q:while(!0){if(M>O||N>=C&&N>F){let x=Q.slice(O,M)||Q.slice(F,N);P=0;for(let v of x.replaceAll(qV,"")){let R=v.codePointAt(0)||0;if(Q7(R))D=2;else if($7(R))D=Z;else D=z;if(T+D>B)A=Math.min(A,Math.max(O,F)+P);if(T+D>J){L=!0;break Q}P+=v.length,T+=D}O=M=0}if(N>=C)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===J7?eQ(Q.slice(N,R.lastIndex)):R===Y7?1:R.lastIndex-N,D=P*$0,T+D>B)A=Math.min(A,N+Math.floor((B-T)/$0));if(T+D>J){L=!0;break Q}T+=D,O=F,M=N,N=F=R.lastIndex;continue Q}}N+=1}return{width:L?B:T,index:L?A:C,truncated:L,ellipsed:L&&J>=V}},X7;var K7=H0(()=>{q7();t3=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,e3=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,J7=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu,QV=/\t{1,1000}/y,Y7=/[\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,$V=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,qV=/\p{M}+/gu,JV={limit:1/0,ellipsis:""},X7=V7});var YV,VV=(Q,$={})=>{return X7(Q,YV,$).width},W0;var Q5=H0(()=>{K7();YV={limit:1/0,ellipsis:"",ellipsisWidth:0},W0=VV});function d0(Q,$,q){return String(Q).normalize().split(UV).map((J)=>WV(J,$,q)).join(`
3
- `)}var k8="\x1B",Z7="›",XV=39,q5="\x07",z7="[",KV="]",H7="m",J5,G7,W7=(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},U7=(Q)=>`${k8}${z7}${Q}${H7}`,j7=(Q)=>`${k8}${J5}${Q}${q5}`,$5=(Q,$,q)=>{let J=$[Symbol.iterator](),Y=!1,V=!1,X=Q.at(-1),K=X===void 0?0:W0(X),W=J.next(),G=J.next(),U=0;while(!W.done){let z=W.value,Z=W0(z);if(K+Z<=q)Q[Q.length-1]+=z;else Q.push(z),K=0;if(z===k8||z===Z7)Y=!0,V=$.startsWith(J5,U+1);if(Y){if(V){if(z===q5)Y=!1,V=!1}else if(z===H7)Y=!1}else if(K+=Z,K===q&&!G.done)Q.push(""),K=0;W=G,G=J.next(),U+=z.length}if(X=Q.at(-1),!K&&X!==void 0&&X.length&&Q.length>1)Q[Q.length-2]+=Q.pop()},GV=(Q)=>{let $=Q.split(" "),q=$.length;while(q){if(W0($[q-1]))break;q--}if(q===$.length)return Q;return $.slice(0,q).join(" ")+$.slice(q).join("")},WV=(Q,$,q={})=>{if(q.trim!==!1&&Q.trim()==="")return"";let J="",Y,V,X=Q.split(" "),K=[""],W=0;for(let z=0;z<X.length;z++){let Z=X[z];if(q.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>=$&&(q.wordWrap===!1||q.trim===!1))K.push(""),W=0;if(W||q.trim===!1)K[K.length-1]+=" ",W++}let H=W0(Z);if(q.hard&&H>$){let F=$-W,N=1+Math.floor((H-F-1)/$);if(Math.floor((H-1)/$)<N)K.push("");$5(K,Z,$),W=W0(K.at(-1)??"");continue}if(W+H>$&&W&&H){if(q.wordWrap===!1&&W<$){$5(K,Z,$),W=W0(K.at(-1)??"");continue}K.push(""),W=0}if(W+H>$&&q.wordWrap===!1){$5(K,Z,$),W=W0(K.at(-1)??"");continue}K[K.length-1]+=Z,W+=H}if(q.trim!==!1)K=K.map((z)=>GV(z));let G=K.join(`
4
- `),U=!1;for(let z=0;z<G.length;z++){let Z=G[z];if(J+=Z,!U){if(U=Z>="\uD800"&&Z<="\uDBFF",U)continue}else U=!1;if(Z===k8||Z===Z7){G7.lastIndex=z+1;let F=G7.exec(G)?.groups;if(F?.code!==void 0){let N=Number.parseFloat(F.code);Y=N===XV?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)J+=j7("");let H=Y?W7(Y):void 0;if(Y&&H)J+=U7(H)}else if(Z===`
6
- `){if(Y&&W7(Y))J+=U7(Y);if(V)J+=j7(V)}}return J},UV;var Y5=H0(()=>{Q5();J5=`${KV}8;;`,G7=new RegExp(`(?:\\${z7}(?<code>\\d+)m|\\${J5}(?<uri>.*)${q5})`,"y"),UV=/\r?\n/});var X5=w((YL,F7)=>{var V5={to(Q,$){if(!$)return`\x1B[${Q+1}G`;return`\x1B[${$+1};${Q+1}H`},move(Q,$){let q="";if(Q<0)q+=`\x1B[${-Q}D`;else if(Q>0)q+=`\x1B[${Q}C`;if($<0)q+=`\x1B[${-$}A`;else if($>0)q+=`\x1B[${$}B`;return q},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"},jV={up:(Q=1)=>"\x1B[S".repeat(Q),down:(Q=1)=>"\x1B[T".repeat(Q)},ZV={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 q=0;q<Q;q++)$+=this.line+(q<Q-1?V5.up():"");if(Q)$+=V5.left;return $}};F7.exports={cursor:V5,scroll:jV,erase:ZV,beep:"\x07"}});import{styleText as G5}from"node:util";import{stdout as j5,stdin as B7}from"node:process";import*as L1 from"node:readline";import zV from"node:readline";import{ReadStream as L7}from"node:tty";function Y1(Q,$,q){if(!q.some((X)=>!X.disabled))return Q;let J=Q+$,Y=Math.max(q.length-1,0),V=J<0?Y:J>Y?0:J;return q[V].disabled?Y1(V,$<0?-1:1,q):V}function y8(Q,$,q,J){let Y=J.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+q)),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 Z5(Q,$){if(typeof Q=="string")return r.aliases.get(Q)===$;for(let q of Q)if(q!==void 0&&Z5(q,$))return!0;return!1}function LV(Q,$){if(Q===$)return;let q=Q.split(`
2
+ import{createRequire as KV}from"node:module";var s3=Object.create;var{getPrototypeOf:t3,defineProperty:e2,getOwnPropertyNames:e3}=Object;var QV=Object.prototype.hasOwnProperty;function $V(Q){return this[Q]}var qV,JV,p0=(Q,$,q)=>{var J=Q!=null&&typeof Q==="object";if(J){var Y=$?qV??=new WeakMap:JV??=new WeakMap,V=Y.get(Q);if(V)return V}q=Q!=null?s3(t3(Q)):{};let K=$||!Q||!Q.__esModule?e2(q,"default",{value:Q,enumerable:!0}):q;for(let X of e3(Q))if(!QV.call(K,X))e2(K,X,{get:$V.bind(Q,X),enumerable:!0});if(J)Y.set(Q,K);return K};var D=(Q,$)=>()=>($||Q(($={exports:{}}).exports,$),$.exports);var YV=(Q)=>Q;function VV(Q,$){this[Q]=YV.bind(null,$)}var E8=(Q,$)=>{for(var q in $)e2(Q,q,{get:$[q],enumerable:!0,configurable:!0,set:VV.bind($,q)})};var z0=(Q,$)=>()=>(Q&&($=Q(Q=0)),$);var _=KV(import.meta.url);var eQ,Q7=(Q)=>{return Q===12288||Q>=65281&&Q<=65376||Q>=65504&&Q<=65510},$7=(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 q7=z0(()=>{eQ=(()=>{let Q=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return($)=>{let q=0;Q.lastIndex=0;while(Q.test($))q+=1;return $.length-q}})()});var XV,GV,J7,WV,Y7,jV,ZV,UV,V7=(Q,$={},q={})=>{let J=$.limit??1/0,Y=$.ellipsis??"",V=$?.ellipsisWidth??(Y?V7(Y,UV,q).width:0),K=0,X=q.controlWidth??0,W=q.tabWidth??8,G=q.emojiWidth??2,j=2,H=q.regularWidth??1,U=q.wideWidth??2,z=[[jV,H],[XV,0],[GV,X],[WV,W],[Y7,G],[J7,U]],F=0,N=0,C=Q.length,P=0,L=!1,A=C,B=Math.max(0,J-V),O=0,M=0,T=0,w=0;Q:while(!0){if(M>O||N>=C&&N>F){let x=Q.slice(O,M)||Q.slice(F,N);P=0;for(let v of x.replaceAll(ZV,"")){let R=v.codePointAt(0)||0;if(Q7(R))w=2;else if($7(R))w=U;else w=H;if(T+w>B)A=Math.min(A,Math.max(O,F)+P);if(T+w>J){L=!0;break Q}P+=v.length,T+=w}O=M=0}if(N>=C)break Q;for(let x=0,v=z.length;x<v;x++){let[R,q0]=z[x];if(R.lastIndex=N,R.test(Q)){if(P=R===J7?eQ(Q.slice(N,R.lastIndex)):R===Y7?1:R.lastIndex-N,w=P*q0,T+w>B)A=Math.min(A,N+Math.floor((B-T)/q0));if(T+w>J){L=!0;break Q}T+=w,O=F,M=N,N=F=R.lastIndex;continue Q}}N+=1}return{width:L?B:T,index:L?A:C,truncated:L,ellipsed:L&&J>=V}},K7;var X7=z0(()=>{q7();XV=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,GV=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,J7=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu,WV=/\t{1,1000}/y,Y7=/[\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,jV=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,ZV=/\p{M}+/gu,UV={limit:1/0,ellipsis:""},K7=V7});var HV,zV=(Q,$={})=>{return K7(Q,HV,$).width},W0;var Q5=z0(()=>{X7();HV={limit:1/0,ellipsis:"",ellipsisWidth:0},W0=zV});function d0(Q,$,q){return String(Q).normalize().split(BV).map((J)=>NV(J,$,q)).join(`
3
+ `)}var k8="\x1B",U7="›",FV=39,q5="\x07",H7="[",LV="]",z7="m",J5,G7,W7=(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},j7=(Q)=>`${k8}${H7}${Q}${z7}`,Z7=(Q)=>`${k8}${J5}${Q}${q5}`,$5=(Q,$,q)=>{let J=$[Symbol.iterator](),Y=!1,V=!1,K=Q.at(-1),X=K===void 0?0:W0(K),W=J.next(),G=J.next(),j=0;while(!W.done){let H=W.value,U=W0(H);if(X+U<=q)Q[Q.length-1]+=H;else Q.push(H),X=0;if(H===k8||H===U7)Y=!0,V=$.startsWith(J5,j+1);if(Y){if(V){if(H===q5)Y=!1,V=!1}else if(H===z7)Y=!1}else if(X+=U,X===q&&!G.done)Q.push(""),X=0;W=G,G=J.next(),j+=H.length}if(K=Q.at(-1),!X&&K!==void 0&&K.length&&Q.length>1)Q[Q.length-2]+=Q.pop()},OV=(Q)=>{let $=Q.split(" "),q=$.length;while(q){if(W0($[q-1]))break;q--}if(q===$.length)return Q;return $.slice(0,q).join(" ")+$.slice(q).join("")},NV=(Q,$,q={})=>{if(q.trim!==!1&&Q.trim()==="")return"";let J="",Y,V,K=Q.split(" "),X=[""],W=0;for(let H=0;H<K.length;H++){let U=K[H];if(q.trim!==!1){let F=X.at(-1)??"",N=F.trimStart();if(F.length!==N.length)X[X.length-1]=N,W=W0(N)}if(H!==0){if(W>=$&&(q.wordWrap===!1||q.trim===!1))X.push(""),W=0;if(W||q.trim===!1)X[X.length-1]+=" ",W++}let z=W0(U);if(q.hard&&z>$){let F=$-W,N=1+Math.floor((z-F-1)/$);if(Math.floor((z-1)/$)<N)X.push("");$5(X,U,$),W=W0(X.at(-1)??"");continue}if(W+z>$&&W&&z){if(q.wordWrap===!1&&W<$){$5(X,U,$),W=W0(X.at(-1)??"");continue}X.push(""),W=0}if(W+z>$&&q.wordWrap===!1){$5(X,U,$),W=W0(X.at(-1)??"");continue}X[X.length-1]+=U,W+=z}if(q.trim!==!1)X=X.map((H)=>OV(H));let G=X.join(`
4
+ `),j=!1;for(let H=0;H<G.length;H++){let U=G[H];if(J+=U,!j){if(j=U>="\uD800"&&U<="\uDBFF",j)continue}else j=!1;if(U===k8||U===U7){G7.lastIndex=H+1;let F=G7.exec(G)?.groups;if(F?.code!==void 0){let N=Number.parseFloat(F.code);Y=N===FV?void 0:N}else if(F?.uri!==void 0)V=F.uri.length===0?void 0:F.uri}if(G[H+1]===`
5
+ `){if(V)J+=Z7("");let z=Y?W7(Y):void 0;if(Y&&z)J+=j7(z)}else if(U===`
6
+ `){if(Y&&W7(Y))J+=j7(Y);if(V)J+=Z7(V)}}return J},BV;var Y5=z0(()=>{Q5();J5=`${LV}8;;`,G7=new RegExp(`(?:\\${H7}(?<code>\\d+)m|\\${J5}(?<uri>.*)${q5})`,"y"),BV=/\r?\n/});var K5=D((zL,F7)=>{var V5={to(Q,$){if(!$)return`\x1B[${Q+1}G`;return`\x1B[${$+1};${Q+1}H`},move(Q,$){let q="";if(Q<0)q+=`\x1B[${-Q}D`;else if(Q>0)q+=`\x1B[${Q}C`;if($<0)q+=`\x1B[${-$}A`;else if($>0)q+=`\x1B[${$}B`;return q},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"},MV={up:(Q=1)=>"\x1B[S".repeat(Q),down:(Q=1)=>"\x1B[T".repeat(Q)},PV={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 q=0;q<Q;q++)$+=this.line+(q<Q-1?V5.up():"");if(Q)$+=V5.left;return $}};F7.exports={cursor:V5,scroll:MV,erase:PV,beep:"\x07"}});import{styleText as G5}from"node:util";import{stdout as Z5,stdin as B7}from"node:process";import*as L1 from"node:readline";import IV from"node:readline";import{ReadStream as L7}from"node:tty";function Y1(Q,$,q){if(!q.some((K)=>!K.disabled))return Q;let J=Q+$,Y=Math.max(q.length-1,0),V=J<0?Y:J>Y?0:J;return q[V].disabled?Y1(V,$<0?-1:1,q):V}function y8(Q,$,q,J){let Y=J.split(`
7
+ `),V=0,K=Q;for(let W of Y){if(K<=W.length)break;K-=W.length+1,V++}for(V=Math.max(0,Math.min(Y.length-1,V+q)),K=Math.min(K,Y[V].length)+$;K<0&&V>0;)V--,K+=Y[V].length+1;for(;K>Y[V].length&&V<Y.length-1;)K-=Y[V].length+1,V++;K=Math.max(0,Math.min(Y[V].length,K));let X=0;for(let W=0;W<V;W++)X+=Y[W].length+1;return X+K}function U5(Q,$){if(typeof Q=="string")return r.aliases.get(Q)===$;for(let q of Q)if(q!==void 0&&U5(q,$))return!0;return!1}function AV(Q,$){if(Q===$)return;let q=Q.split(`
8
8
  `),J=$.split(`
9
- `),Y=Math.max(q.length,J.length),V=[];for(let X=0;X<Y;X++)q[X]!==J[X]&&V.push(X);return{lines:V,numLinesBefore:q.length,numLinesAfter:J.length,numLines:Y}}function V1(Q){return Q===W5}function g8(Q,$){let q=Q;q.isTTY&&q.setRawMode($)}function M7({input:Q=B7,output:$=j5,overwrite:q=!0,hideCursor:J=!0}={}){let Y=L1.createInterface({input:Q,output:$,prompt:"",tabSize:1});L1.emitKeypressEvents(Q,Y),Q instanceof L7&&Q.isTTY&&Q.setRawMode(!0);let V=(X,{name:K,sequence:W})=>{let G=String(X);if(Z5([G,K,W],"cancel")){J&&$.write(X0.cursor.show),process.exit(0);return}if(!q)return;L1.moveCursor($,K==="return"?0:-1,K==="return"?-1:0,()=>{L1.clearLine($,1,()=>{Q.once("keypress",V)})})};return J&&$.write(X0.cursor.hide),Q.once("keypress",V),()=>{Q.off("keypress",V),J&&$.write(X0.cursor.show),Q instanceof L7&&Q.isTTY&&!OV&&Q.setRawMode(!1),Y.terminal=!1,Y.close()}}function O1(Q,$,q,J=q,Y){let V=S6(Q??j5);return d0($,V-q.length,{hard:!0,trim:!1}).split(`
10
- `).map((X,K)=>{let W=Y?Y(X,K):X;return`${K===0?J:q}${W}`}).join(`
11
- `)}function NV(Q,$){if(Q===void 0||$.length===0)return 0;let q=$.findIndex((J)=>J.value===Q);return q!==-1?q:0}function BV(Q,$){return($.label??String($.value)).toLowerCase().includes(Q.toLowerCase())}function MV(Q,$){if($)return Q?$:$[0]}function O7(Q){return[...Q].map(($)=>IV[$])}function CV(Q){let $=new Intl.DateTimeFormat(Q,{year:"numeric",month:"2-digit",day:"2-digit"}).formatToParts(new Date(2000,0,15)),q=[],J="/";for(let Y of $)Y.type==="literal"?J=Y.value.trim()||Y.value:(Y.type==="year"||Y.type==="month"||Y.type==="day")&&q.push({type:Y.type,len:Y.type==="year"?4:2});return{segments:q,separator:J}}function K5(Q){return Number.parseInt((Q||"0").replace(/_/g,"0"),10)||0}function _8(Q){return{year:K5(Q.year),month:K5(Q.month),day:K5(Q.day)}}function U5(Q,$){return new Date(Q||2001,$||1,0).getDate()}function P7(Q){let{year:$,month:q,day:J}=_8(Q);if(!$||$<0||$>9999||!q||q<1||q>12||!J||J<1)return;let Y=new Date(Date.UTC($,q-1,J));if(!(Y.getUTCFullYear()!==$||Y.getUTCMonth()!==q-1||Y.getUTCDate()!==J))return{year:$,month:q,day:J}}function N7(Q){let $=P7(Q);return $?new Date(Date.UTC($.year,$.month-1,$.day)):void 0}function TV(Q,$,q,J){let Y=q?{year:q.getUTCFullYear(),month:q.getUTCMonth()+1,day:q.getUTCDate()}:null,V=J?{year:J.getUTCFullYear(),month:J.getUTCMonth()+1,day:J.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:U5($.year,$.month)}}var X0,HV,FV,r,OV,W5,S6=(Q)=>("columns"in Q)&&typeof Q.columns=="number"?Q.columns:80,z5=(Q)=>("rows"in Q)&&typeof Q.rows=="number"?Q.rows:20,g1=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:q=B7,output:J=j5,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=q,this.output=J}unsubscribe(){this._subscribers.clear()}setSubscriber(Q,$){let q=this._subscribers.get(Q)??[];q.push($),this._subscribers.set(Q,q)}on(Q,$){this.setSubscriber(Q,{cb:$})}once(Q,$){this.setSubscriber(Q,{cb:$,once:!0})}emit(Q,...$){let q=this._subscribers.get(Q)??[],J=[];for(let Y of q)Y.cb(...$),Y.once&&J.push(()=>q.splice(q.indexOf(Y),1));for(let Y of J)Y()}prompt(){return new Promise((Q)=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state="cancel",this.close(),Q(W5);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}this.rl=zV.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),g8(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),g8(this.input,!1),Q(this.value)}),this.once("cancel",()=>{this.output.write(X0.cursor.show),this.output.off("resize",this.render),g8(this.input,!1),Q(W5)})})}_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&&r.aliases.has($.name)&&this.emit("cursor",r.aliases.get($.name)),r.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 q=this.opts.validate(this.value);q&&(this.error=q instanceof Error?q.message:q,this.state="error",this.rl?.write(this.userInput))}this.state!=="error"&&(this.state="submit")}Z5([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(`
9
+ `),Y=Math.max(q.length,J.length),V=[];for(let K=0;K<Y;K++)q[K]!==J[K]&&V.push(K);return{lines:V,numLinesBefore:q.length,numLinesAfter:J.length,numLines:Y}}function V1(Q){return Q===W5}function g8(Q,$){let q=Q;q.isTTY&&q.setRawMode($)}function M7({input:Q=B7,output:$=Z5,overwrite:q=!0,hideCursor:J=!0}={}){let Y=L1.createInterface({input:Q,output:$,prompt:"",tabSize:1});L1.emitKeypressEvents(Q,Y),Q instanceof L7&&Q.isTTY&&Q.setRawMode(!0);let V=(K,{name:X,sequence:W})=>{let G=String(K);if(U5([G,X,W],"cancel")){J&&$.write(K0.cursor.show),process.exit(0);return}if(!q)return;L1.moveCursor($,X==="return"?0:-1,X==="return"?-1:0,()=>{L1.clearLine($,1,()=>{Q.once("keypress",V)})})};return J&&$.write(K0.cursor.hide),Q.once("keypress",V),()=>{Q.off("keypress",V),J&&$.write(K0.cursor.show),Q instanceof L7&&Q.isTTY&&!wV&&Q.setRawMode(!1),Y.terminal=!1,Y.close()}}function O1(Q,$,q,J=q,Y){let V=S6(Q??Z5);return d0($,V-q.length,{hard:!0,trim:!1}).split(`
10
+ `).map((K,X)=>{let W=Y?Y(K,X):K;return`${X===0?J:q}${W}`}).join(`
11
+ `)}function DV(Q,$){if(Q===void 0||$.length===0)return 0;let q=$.findIndex((J)=>J.value===Q);return q!==-1?q:0}function RV(Q,$){return($.label??String($.value)).toLowerCase().includes(Q.toLowerCase())}function xV(Q,$){if($)return Q?$:$[0]}function O7(Q){return[...Q].map(($)=>SV[$])}function EV(Q){let $=new Intl.DateTimeFormat(Q,{year:"numeric",month:"2-digit",day:"2-digit"}).formatToParts(new Date(2000,0,15)),q=[],J="/";for(let Y of $)Y.type==="literal"?J=Y.value.trim()||Y.value:(Y.type==="year"||Y.type==="month"||Y.type==="day")&&q.push({type:Y.type,len:Y.type==="year"?4:2});return{segments:q,separator:J}}function X5(Q){return Number.parseInt((Q||"0").replace(/_/g,"0"),10)||0}function _8(Q){return{year:X5(Q.year),month:X5(Q.month),day:X5(Q.day)}}function j5(Q,$){return new Date(Q||2001,$||1,0).getDate()}function P7(Q){let{year:$,month:q,day:J}=_8(Q);if(!$||$<0||$>9999||!q||q<1||q>12||!J||J<1)return;let Y=new Date(Date.UTC($,q-1,J));if(!(Y.getUTCFullYear()!==$||Y.getUTCMonth()!==q-1||Y.getUTCDate()!==J))return{year:$,month:q,day:J}}function N7(Q){let $=P7(Q);return $?new Date(Date.UTC($.year,$.month-1,$.day)):void 0}function kV(Q,$,q,J){let Y=q?{year:q.getUTCFullYear(),month:q.getUTCMonth()+1,day:q.getUTCDate()}:null,V=J?{year:J.getUTCFullYear(),month:J.getUTCMonth()+1,day:J.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:j5($.year,$.month)}}var K0,CV,TV,r,wV,W5,S6=(Q)=>("columns"in Q)&&typeof Q.columns=="number"?Q.columns:80,H5=(Q)=>("rows"in Q)&&typeof Q.rows=="number"?Q.rows:20,g1=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:q=B7,output:J=Z5,render:Y,signal:V,...K}=Q;this.opts=K,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=q,this.output=J}unsubscribe(){this._subscribers.clear()}setSubscriber(Q,$){let q=this._subscribers.get(Q)??[];q.push($),this._subscribers.set(Q,q)}on(Q,$){this.setSubscriber(Q,{cb:$})}once(Q,$){this.setSubscriber(Q,{cb:$,once:!0})}emit(Q,...$){let q=this._subscribers.get(Q)??[],J=[];for(let Y of q)Y.cb(...$),Y.once&&J.push(()=>q.splice(q.indexOf(Y),1));for(let Y of J)Y()}prompt(){return new Promise((Q)=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state="cancel",this.close(),Q(W5);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}this.rl=IV.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),g8(this.input,!0),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write(K0.cursor.show),this.output.off("resize",this.render),g8(this.input,!1),Q(this.value)}),this.once("cancel",()=>{this.output.write(K0.cursor.show),this.output.off("resize",this.render),g8(this.input,!1),Q(W5)})})}_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&&r.aliases.has($.name)&&this.emit("cursor",r.aliases.get($.name)),r.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 q=this.opts.validate(this.value);q&&(this.error=q instanceof Error?q.message:q,this.state="error",this.rl?.write(this.userInput))}this.state!=="error"&&(this.state="submit")}U5([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
12
  `),g8(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let Q=d0(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=d0(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 $=LV(this._prevFrame,Q),q=z5(this.output);if(this.restoreCursor(),$){let J=Math.max(0,$.numLinesAfter-q),Y=Math.max(0,$.numLinesBefore-q),V=$.lines.find((X)=>X>=J);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(J<Y)V=J;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}}},PV,H5,IV,I7,C7,T7,A7,F5;var L5=H0(()=>{Y5();X0=p0(X5(),1);HV=["up","down","left","right","space","enter","cancel"],FV=["January","February","March","April","May","June","July","August","September","October","November","December"],r={actions:new Set(HV),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:[...FV],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)}`}}};OV=globalThis.process.platform.startsWith("win"),W5=Symbol("clack:cancel");PV=class extends g1{filteredOptions;multiple;isNavigating=!1;selectedValues=[];focusedValue;#$=0;#Y="";#Q;#V;#K;get cursor(){return this.#$}get userInputWithCursor(){if(!this.userInput)return G5(["inverse","hidden"],"_");if(this._cursor>=this.userInput.length)return`${this.userInput}█`;let Q=this.userInput.slice(0,this._cursor),[$,...q]=this.userInput.slice(this._cursor);return`${Q}${G5("inverse",$)}${q.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??BV;let q;if(Q.initialValue&&Array.isArray(Q.initialValue)?this.multiple?q=Q.initialValue:q=Q.initialValue.slice(0,1):!this.multiple&&this.options.length>0&&(q=[this.options[0].value]),q)for(let J of q){let Y=$.findIndex((V)=>V.value===J);Y!==-1&&(this.toggleSelected(J),this.#$=Y)}this.focusedValue=this.options[this.#$]?.value,this.on("key",(J,Y)=>this.#q(J,Y)),this.on("userInput",(J)=>this.#J(J))}_isActionKey(Q,$){return Q==="\t"||this.multiple&&this.isNavigating&&$.name==="space"&&Q!==void 0&&Q!==""}#q(Q,$){let q=$.name==="up",J=$.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}q||J?(this.#$=Y1(this.#$,q?-1:1,this.filteredOptions),this.focusedValue=this.filteredOptions[this.#$]?.value,this.multiple||(this.selectedValues=[this.focusedValue]),this.isNavigating=!0):Y?this.value=MV(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])}#J(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 q=NV(this.focusedValue,this.filteredOptions);this.#$=Y1(q,0,this.filteredOptions);let J=this.filteredOptions[this.#$];J&&!J.disabled?this.focusedValue=J.value:this.focusedValue=void 0,this.multiple||(this.focusedValue!==void 0?this.toggleSelected(this.focusedValue):this.deselectAll())}}};H5=class H5 extends g1{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})}};IV={Y:{type:"year",len:4},M:{type:"month",len:2},D:{type:"day",len:2}};I7=class I7 extends g1{#$;#Y;#Q;#V;#K;#q={segmentIndex:0,positionInSegment:0};#J=!0;#X=null;inlineError="";get segmentCursor(){return{...this.#q}}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(N7(this.#Q)??void 0)}constructor(Q){let $=Q.format?{segments:O7(Q.format),separator:Q.separator??"/"}:CV(Q.locale),q=Q.separator??$.separator,J=Q.format?O7(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=J.map((K)=>V[K.type]).join(q);super({...Q,initialUserInput:X},!1),this.#$=J,this.#Y=q,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.#q.segmentIndex,this.#$.length-1)),$=this.#$[Q];if($)return this.#q.positionInSegment=Math.max(0,Math.min(this.#q.positionInSegment,$.len-1)),{segment:$,index:Q}}#U(Q){this.inlineError="",this.#X=null;let $=this.#W();$&&(this.#q.segmentIndex=Math.max(0,Math.min(this.#$.length-1,$.index+Q)),this.#q.positionInSegment=0,this.#J=!0)}#Z(Q){let $=this.#W();if(!$)return;let{segment:q}=$,J=this.#Q[q.type],Y=!J||J.replace(/_/g,"")==="",V=Number.parseInt((J||"0").replace(/_/g,"0"),10)||0,X=TV(q.type,_8(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,[q.type]:K.toString().padStart(q.len,"0")},this.#J=!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 q=this.#W();if(!q)return;if(!this.#Q[q.segment.type].replace(/_/g,"")){this.#U(-1);return}this.#Q[q.segment.type]="_".repeat(q.segment.len),this.#J=!0,this.#q.positionInSegment=0,this.#G();return}if($?.name==="tab"){this.inlineError="";let q=this.#W();if(!q)return;let J=$.shift?-1:1,Y=q.index+J;Y>=0&&Y<this.#$.length&&(this.#q.segmentIndex=Y,this.#q.positionInSegment=0,this.#J=!0);return}if(Q&&/^[0-9]$/.test(Q)){let q=this.#W();if(!q)return;let{segment:J}=q,Y=!this.#Q[J.type].replace(/_/g,"");if(this.#J&&this.#X!==null&&!Y){let Z=this.#X+Q,H={...this.#Q,[J.type]:Z},F=this.#z(H,J);if(F){this.inlineError=F,this.#X=null,this.#J=!1;return}this.inlineError="",this.#Q[J.type]=Z,this.#X=null,this.#J=!1,this.#G(),q.index<this.#$.length-1&&(this.#q.segmentIndex=q.index+1,this.#q.positionInSegment=0,this.#J=!0);return}this.#J&&!Y&&(this.#Q[J.type]="_".repeat(J.len),this.#q.positionInSegment=0),this.#J=!1,this.#X=null;let V=this.#Q[J.type],X=V.indexOf("_"),K=X>=0?X:Math.min(this.#q.positionInSegment,J.len-1);if(K<0||K>=J.len)return;let W=V.slice(0,K)+Q+V.slice(K+1),G=!1;if(K===0&&V==="__"&&(J.type==="month"||J.type==="day")){let Z=Number.parseInt(Q,10);W=`0${Q}`,G=Z<=(J.type==="month"?1:2)}if(J.type==="year"&&(W=(V.replace(/_/g,"")+Q).padStart(J.len,"_")),!W.includes("_")){let Z={...this.#Q,[J.type]:W},H=this.#z(Z,J);if(H){this.inlineError=H;return}}this.inlineError="",this.#Q[J.type]=W;let U=W.includes("_")?void 0:P7(this.#Q);if(U){let{year:Z,month:H}=U,F=U5(Z,H);this.#Q={year:String(Math.max(0,Math.min(9999,Z))).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.#J=!0,this.#X=Q):z>=0?this.#q.positionInSegment=z:X>=0&&q.index<this.#$.length-1?(this.#q.segmentIndex=q.index+1,this.#q.positionInSegment=0,this.#J=!0):this.#q.positionInSegment=Math.min(K+1,J.len-1)}}#z(Q,$){let{month:q,day:J}=_8(Q);if($.type==="month"&&(q<0||q>12))return r.date.messages.invalidMonth;if($.type==="day"&&(J<0||J>31))return r.date.messages.invalidDay(31,"any month")}#L(Q){let{year:$,month:q,day:J}=_8(this.#Q);if($&&q&&J){let Y=U5($,q);this.#Q={...this.#Q,day:String(Math.min(J,Y)).padStart(2,"0")}}this.value=N7(this.#Q)??Q.defaultValue??void 0}};C7=class C7 extends g1{options;cursor=0;#$;getGroupItems(Q){return this.options.filter(($)=>$.group===Q)}isGroupSelected(Q){let $=this.getGroupItems(Q),q=this.value;return q===void 0?!1:$.every((J)=>q.includes(J.value))}toggleValue(){let Q=this.options[this.cursor];if(this.value===void 0&&(this.value=[]),Q.group===!0){let $=Q.value,q=this.getGroupItems($);this.isGroupSelected($)?this.value=this.value.filter((J)=>q.findIndex((Y)=>Y.value===J)===-1):this.value=[...this.value,...q.map((J)=>J.value)],this.value=Array.from(new Set(this.value))}else{let $=this.value.includes(Q.value);this.value=$?this.value.filter((q)=>q!==Q.value):[...this.value,Q.value]}}constructor(Q){super(Q,!1);let{options:$}=Q;this.#$=Q.selectableGroups!==!1,this.options=Object.entries($).flatMap(([q,J])=>[{value:q,group:!0,label:q},...J.map((Y)=>({...Y,group:q}))]),this.value=[...Q.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:q})=>q===Q.cursorAt),this.#$?0:1),this.on("cursor",(q)=>{switch(q){case"left":case"up":{this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;let J=this.options[this.cursor]?.group===!0;!this.#$&&J&&(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 J=this.options[this.cursor]?.group===!0;!this.#$&&J&&(this.cursor=this.cursor===this.options.length-1?0:this.cursor+1);break}case"space":this.toggleValue();break}})}};T7=class T7 extends g1{#$=!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),q=Q[this.cursor],J=Q.slice(this.cursor+1);return q===`
13
+ `).length-1;this.output.write(K0.cursor.move(-999,Q*-1))}render(){let Q=d0(this._render(this)??"",process.stdout.columns,{hard:!0,trim:!1});if(Q!==this._prevFrame){if(this.state==="initial")this.output.write(K0.cursor.hide);else{let $=AV(this._prevFrame,Q),q=H5(this.output);if(this.restoreCursor(),$){let J=Math.max(0,$.numLinesAfter-q),Y=Math.max(0,$.numLinesBefore-q),V=$.lines.find((K)=>K>=J);if(V===void 0){this._prevFrame=Q;return}if($.lines.length===1){this.output.write(K0.cursor.move(0,V-Y)),this.output.write(K0.erase.lines(1));let K=Q.split(`
14
+ `);this.output.write(K[V]),this._prevFrame=Q,this.output.write(K0.cursor.move(0,K.length-V-1));return}else if($.lines.length>1){if(J<Y)V=J;else{let X=V-Y;X>0&&this.output.write(K0.cursor.move(0,X))}this.output.write(K0.erase.down());let K=Q.split(`
15
+ `).slice(V);this.output.write(K.join(`
16
+ `)),this._prevFrame=Q;return}}this.output.write(K0.erase.down())}this.output.write(Q),this.state==="initial"&&(this.state="active"),this._prevFrame=Q}}},vV,z5,SV,I7,C7,T7,A7,F5;var L5=z0(()=>{Y5();K0=p0(K5(),1);CV=["up","down","left","right","space","enter","cancel"],TV=["January","February","March","April","May","June","July","August","September","October","November","December"],r={actions:new Set(CV),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:[...TV],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)}`}}};wV=globalThis.process.platform.startsWith("win"),W5=Symbol("clack:cancel");vV=class extends g1{filteredOptions;multiple;isNavigating=!1;selectedValues=[];focusedValue;#$=0;#Y="";#Q;#V;#X;get cursor(){return this.#$}get userInputWithCursor(){if(!this.userInput)return G5(["inverse","hidden"],"_");if(this._cursor>=this.userInput.length)return`${this.userInput}█`;let Q=this.userInput.slice(0,this._cursor),[$,...q]=this.userInput.slice(this._cursor);return`${Q}${G5("inverse",$)}${q.join("")}`}get options(){return typeof this.#V=="function"?this.#V():this.#V}constructor(Q){super(Q),this.#V=Q.options,this.#X=Q.placeholder;let $=this.options;this.filteredOptions=[...$],this.multiple=Q.multiple===!0,this.#Q=typeof Q.options=="function"?Q.filter:Q.filter??RV;let q;if(Q.initialValue&&Array.isArray(Q.initialValue)?this.multiple?q=Q.initialValue:q=Q.initialValue.slice(0,1):!this.multiple&&this.options.length>0&&(q=[this.options[0].value]),q)for(let J of q){let Y=$.findIndex((V)=>V.value===J);Y!==-1&&(this.toggleSelected(J),this.#$=Y)}this.focusedValue=this.options[this.#$]?.value,this.on("key",(J,Y)=>this.#q(J,Y)),this.on("userInput",(J)=>this.#J(J))}_isActionKey(Q,$){return Q==="\t"||this.multiple&&this.isNavigating&&$.name==="space"&&Q!==void 0&&Q!==""}#q(Q,$){let q=$.name==="up",J=$.name==="down",Y=$.name==="return",V=this.userInput===""||this.userInput==="\t",K=this.#X,X=this.options,W=K!==void 0&&K!==""&&X.some((G)=>!G.disabled&&(this.#Q?this.#Q(K,G):!0));if($.name==="tab"&&V&&W){this.userInput==="\t"&&this._clearUserInput(),this._setUserInput(K,!0),this.isNavigating=!1;return}q||J?(this.#$=Y1(this.#$,q?-1:1,this.filteredOptions),this.focusedValue=this.filteredOptions[this.#$]?.value,this.multiple||(this.selectedValues=[this.focusedValue]),this.isNavigating=!0):Y?this.value=xV(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])}#J(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 q=DV(this.focusedValue,this.filteredOptions);this.#$=Y1(q,0,this.filteredOptions);let J=this.filteredOptions[this.#$];J&&!J.disabled?this.focusedValue=J.value:this.focusedValue=void 0,this.multiple||(this.focusedValue!==void 0?this.toggleSelected(this.focusedValue):this.deselectAll())}}};z5=class z5 extends g1{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(K0.cursor.move(0,-1)),this.value=$,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}};SV={Y:{type:"year",len:4},M:{type:"month",len:2},D:{type:"day",len:2}};I7=class I7 extends g1{#$;#Y;#Q;#V;#X;#q={segmentIndex:0,positionInSegment:0};#J=!0;#K=null;inlineError="";get segmentCursor(){return{...this.#q}}get segmentValues(){return{...this.#Q}}get segments(){return this.#$}get separator(){return this.#Y}get formattedValue(){return this.#Z(this.#Q)}#Z(Q){return this.#$.map(($)=>Q[$.type]).join(this.#Y)}#G(){this._setUserInput(this.#Z(this.#Q)),this._setValue(N7(this.#Q)??void 0)}constructor(Q){let $=Q.format?{segments:O7(Q.format),separator:Q.separator??"/"}:EV(Q.locale),q=Q.separator??$.separator,J=Q.format?O7(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:"__"},K=J.map((X)=>V[X.type]).join(q);super({...Q,initialUserInput:K},!1),this.#$=J,this.#Y=q,this.#Q=V,this.#V=Q.minDate,this.#X=Q.maxDate,this.#G(),this.on("cursor",(X)=>this.#z(X)),this.on("key",(X,W)=>this.#F(X,W)),this.on("finalize",()=>this.#L(Q))}#W(){let Q=Math.max(0,Math.min(this.#q.segmentIndex,this.#$.length-1)),$=this.#$[Q];if($)return this.#q.positionInSegment=Math.max(0,Math.min(this.#q.positionInSegment,$.len-1)),{segment:$,index:Q}}#j(Q){this.inlineError="",this.#K=null;let $=this.#W();$&&(this.#q.segmentIndex=Math.max(0,Math.min(this.#$.length-1,$.index+Q)),this.#q.positionInSegment=0,this.#J=!0)}#U(Q){let $=this.#W();if(!$)return;let{segment:q}=$,J=this.#Q[q.type],Y=!J||J.replace(/_/g,"")==="",V=Number.parseInt((J||"0").replace(/_/g,"0"),10)||0,K=kV(q.type,_8(this.#Q),this.#V,this.#X),X;Y?X=Q===1?K.min:K.max:X=Math.max(Math.min(K.max,V+Q),K.min),this.#Q={...this.#Q,[q.type]:X.toString().padStart(q.len,"0")},this.#J=!0,this.#K=null,this.#G()}#z(Q){if(Q)switch(Q){case"right":return this.#j(1);case"left":return this.#j(-1);case"up":return this.#U(1);case"down":return this.#U(-1)}}#F(Q,$){if($?.name==="backspace"||$?.sequence===""||$?.sequence==="\b"||Q===""||Q==="\b"){this.inlineError="";let q=this.#W();if(!q)return;if(!this.#Q[q.segment.type].replace(/_/g,"")){this.#j(-1);return}this.#Q[q.segment.type]="_".repeat(q.segment.len),this.#J=!0,this.#q.positionInSegment=0,this.#G();return}if($?.name==="tab"){this.inlineError="";let q=this.#W();if(!q)return;let J=$.shift?-1:1,Y=q.index+J;Y>=0&&Y<this.#$.length&&(this.#q.segmentIndex=Y,this.#q.positionInSegment=0,this.#J=!0);return}if(Q&&/^[0-9]$/.test(Q)){let q=this.#W();if(!q)return;let{segment:J}=q,Y=!this.#Q[J.type].replace(/_/g,"");if(this.#J&&this.#K!==null&&!Y){let U=this.#K+Q,z={...this.#Q,[J.type]:U},F=this.#H(z,J);if(F){this.inlineError=F,this.#K=null,this.#J=!1;return}this.inlineError="",this.#Q[J.type]=U,this.#K=null,this.#J=!1,this.#G(),q.index<this.#$.length-1&&(this.#q.segmentIndex=q.index+1,this.#q.positionInSegment=0,this.#J=!0);return}this.#J&&!Y&&(this.#Q[J.type]="_".repeat(J.len),this.#q.positionInSegment=0),this.#J=!1,this.#K=null;let V=this.#Q[J.type],K=V.indexOf("_"),X=K>=0?K:Math.min(this.#q.positionInSegment,J.len-1);if(X<0||X>=J.len)return;let W=V.slice(0,X)+Q+V.slice(X+1),G=!1;if(X===0&&V==="__"&&(J.type==="month"||J.type==="day")){let U=Number.parseInt(Q,10);W=`0${Q}`,G=U<=(J.type==="month"?1:2)}if(J.type==="year"&&(W=(V.replace(/_/g,"")+Q).padStart(J.len,"_")),!W.includes("_")){let U={...this.#Q,[J.type]:W},z=this.#H(U,J);if(z){this.inlineError=z;return}}this.inlineError="",this.#Q[J.type]=W;let j=W.includes("_")?void 0:P7(this.#Q);if(j){let{year:U,month:z}=j,F=j5(U,z);this.#Q={year:String(Math.max(0,Math.min(9999,U))).padStart(4,"0"),month:String(Math.max(1,Math.min(12,z))).padStart(2,"0"),day:String(Math.max(1,Math.min(F,j.day))).padStart(2,"0")}}this.#G();let H=W.indexOf("_");G?(this.#J=!0,this.#K=Q):H>=0?this.#q.positionInSegment=H:K>=0&&q.index<this.#$.length-1?(this.#q.segmentIndex=q.index+1,this.#q.positionInSegment=0,this.#J=!0):this.#q.positionInSegment=Math.min(X+1,J.len-1)}}#H(Q,$){let{month:q,day:J}=_8(Q);if($.type==="month"&&(q<0||q>12))return r.date.messages.invalidMonth;if($.type==="day"&&(J<0||J>31))return r.date.messages.invalidDay(31,"any month")}#L(Q){let{year:$,month:q,day:J}=_8(this.#Q);if($&&q&&J){let Y=j5($,q);this.#Q={...this.#Q,day:String(Math.min(J,Y)).padStart(2,"0")}}this.value=N7(this.#Q)??Q.defaultValue??void 0}};C7=class C7 extends g1{options;cursor=0;#$;getGroupItems(Q){return this.options.filter(($)=>$.group===Q)}isGroupSelected(Q){let $=this.getGroupItems(Q),q=this.value;return q===void 0?!1:$.every((J)=>q.includes(J.value))}toggleValue(){let Q=this.options[this.cursor];if(this.value===void 0&&(this.value=[]),Q.group===!0){let $=Q.value,q=this.getGroupItems($);this.isGroupSelected($)?this.value=this.value.filter((J)=>q.findIndex((Y)=>Y.value===J)===-1):this.value=[...this.value,...q.map((J)=>J.value)],this.value=Array.from(new Set(this.value))}else{let $=this.value.includes(Q.value);this.value=$?this.value.filter((q)=>q!==Q.value):[...this.value,Q.value]}}constructor(Q){super(Q,!1);let{options:$}=Q;this.#$=Q.selectableGroups!==!1,this.options=Object.entries($).flatMap(([q,J])=>[{value:q,group:!0,label:q},...J.map((Y)=>({...Y,group:q}))]),this.value=[...Q.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:q})=>q===Q.cursorAt),this.#$?0:1),this.on("cursor",(q)=>{switch(q){case"left":case"up":{this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;let J=this.options[this.cursor]?.group===!0;!this.#$&&J&&(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 J=this.options[this.cursor]?.group===!0;!this.#$&&J&&(this.cursor=this.cursor===this.options.length-1?0:this.cursor+1);break}case"space":this.toggleValue();break}})}};T7=class T7 extends g1{#$=!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),q=Q[this.cursor],J=Q.slice(this.cursor+1);return q===`
17
17
  `?`${$}█
18
18
  ${J}`:`${$}${G5("inverse",q)}${J}`}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=y8(this._cursor,0,-1,$);return;case"down":this._cursor=y8(this._cursor,0,1,$);return;case"left":this._cursor=y8(this._cursor,-1,0,$);return;case"right":this._cursor=y8(this._cursor,1,0,$);return}}_shouldSubmit(Q,$){if(this.#Y)return this.focused==="submit"?!0:(this.#Q(`
19
19
  `),this._cursor++,!1);let q=this.#$;return this.#$=!0,q?(this.userInput[this.cursor-1]===`
20
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",($,q)=>{if(q?.name&&r.actions.has(q.name)){this.#V(q.name);return}if($==="\t"&&this.#Y){this.focused=this.focused==="editor"?"submit":"editor";return}if(q?.name!=="return"){if(this.#$=!1,q?.name==="backspace"&&this.cursor>0){this._setUserInput(this.userInput.slice(0,this.cursor-1)+this.userInput.slice(this.cursor)),this._cursor--;return}if(q?.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="")})}};A7=class extends g1{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((q)=>q.value)}toggleInvert(){let Q=this.value;if(!Q)return;let $=this._enabledOptions.filter((q)=>!Q.includes(q.value));this.value=$.map((q)=>q.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:q})=>q===Q.cursorAt),0);this.cursor=this.options[$].disabled?Y1($,1,this.options):$,this.on("key",(q)=>{q==="a"&&this.toggleAll(),q==="i"&&this.toggleInvert()}),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;case"space":this.toggleValue();break}})}};F5=class F5 extends g1{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:J})=>J===Q.initialValue),q=$===-1?0:$;this.cursor=this.options[q].disabled?Y1(q,1,this.options):q,this.changeValue(),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}this.changeValue()})}}});import{styleText as I,stripVTControlCharacters as ML}from"node:util";import D0 from"node:process";function AV(){return D0.platform!=="win32"?D0.env.TERM!=="linux":!!D0.env.CI||!!D0.env.WT_SESSION||!!D0.env.TERMINUS_SUBLIME||D0.env.ConEmuTask==="{cmd::Cmder}"||D0.env.TERM_PROGRAM==="Terminus-Sublime"||D0.env.TERM_PROGRAM==="vscode"||D0.env.TERM==="xterm-256color"||D0.env.TERM==="alacritty"||D0.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var k6,O5,DV=()=>process.env.CI==="true",b=(Q,$)=>O5?Q:$,wV,x7,v7,f8,RV,y,s1,TL,AL,N5,h8,xV,D7,w7,DL,R7,vV,SV,EV,kV,wL,yV,gV,_V,bV,M5=(Q)=>{switch(Q){case"initial":case"active":return I("cyan",wV);case"cancel":return I("red",x7);case"error":return I("yellow",v7);case"submit":return I("green",f8)}},S7=(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)}},hV=(Q,$,q,J,Y)=>{let V=$,X=0;for(let K=q;K<J;K++){let W=Q[K];if(V=V-W.length,X++,V<=Y)break}return{lineCount:V,removals:X}},B5=({cursor:Q,options:$,style:q,output:J=process.stdout,maxItems:Y=Number.POSITIVE_INFINITY,columnPadding:V=0,rowPadding:X=4})=>{let K=S6(J)-V,W=z5(J),G=I("dim","..."),U=Math.max(W-X,0),z=Math.max(Math.min(Y,U),5),Z=0;Q>=z-3&&(Z=Math.max(Math.min(Q-z+3,$.length-z),0));let H=z<$.length&&Z>0,F=z<$.length&&Z+z<$.length,N=Math.min(Z+z,$.length),C=[],P=0;H&&P++,F&&P++;let L=Z+(H?1:0),A=N-(F?1:0);for(let O=L;O<A;O++){let M=d0(q($[O],O===Q),K,{hard:!0,trim:!1}).split(`
22
- `);C.push(M),P+=M.length}if(P>U){let O=0,M=0,T=P,D=Q-L,x=(v,R)=>hV(C,T,v,R,U);H?({lineCount:T,removals:O}=x(0,D),T>U&&({lineCount:T,removals:M}=x(D+1,C.length))):({lineCount:T,removals:M}=x(D+1,C.length),T>U&&({lineCount:T,removals:O}=x(0,D))),O>0&&(H=!0,C.splice(0,O)),M>0&&(F=!0,C.splice(C.length-M,M))}let B=[];H&&B.push(G);for(let O of C)for(let M of O)B.push(M);return F&&B.push(G),B},m8=(Q)=>{let $=Q.active??"Yes",q=Q.inactive??"No";return new H5({active:$,inactive:q,signal:Q.signal,input:Q.input,output:Q.output,initialValue:Q.initialValue??!0,render(){let J=Q.withGuide??r.withGuide,Y=`${M5(this.state)} `,V=J?`${I("gray",y)} `:"",X=O1(Q.output,Q.message,V,Y),K=`${J?`${I("gray",y)}
23
- `:""}${X}
24
- `,W=this.value?$:q;switch(this.state){case"submit":{let G=J?`${I("gray",y)} `:"";return`${K}${G}${I("dim",W)}`}case"cancel":{let G=J?`${I("gray",y)} `:"";return`${K}${G}${I(["strikethrough","dim"],W)}${J?`
25
- ${I("gray",y)}`:""}`}default:{let G=J?`${I("cyan",y)} `:"",U=J?I("cyan",s1):"";return`${K}${G}${this.value?`${I("green",N5)} ${$}`:`${I("dim",h8)} ${I("dim",$)}`}${Q.vertical?J?`
21
+ `),this._cursor++,!1)}constructor(Q){super(Q,!1),this.#Y=Q.showSubmit??!1,this.on("key",($,q)=>{if(q?.name&&r.actions.has(q.name)){this.#V(q.name);return}if($==="\t"&&this.#Y){this.focused=this.focused==="editor"?"submit":"editor";return}if(q?.name!=="return"){if(this.#$=!1,q?.name==="backspace"&&this.cursor>0){this._setUserInput(this.userInput.slice(0,this.cursor-1)+this.userInput.slice(this.cursor)),this._cursor--;return}if(q?.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="")})}};A7=class extends g1{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((q)=>q.value)}toggleInvert(){let Q=this.value;if(!Q)return;let $=this._enabledOptions.filter((q)=>!Q.includes(q.value));this.value=$.map((q)=>q.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:q})=>q===Q.cursorAt),0);this.cursor=this.options[$].disabled?Y1($,1,this.options):$,this.on("key",(q)=>{q==="a"&&this.toggleAll(),q==="i"&&this.toggleInvert()}),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;case"space":this.toggleValue();break}})}};F5=class F5 extends g1{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:J})=>J===Q.initialValue),q=$===-1?0:$;this.cursor=this.options[q].disabled?Y1(q,1,this.options):q,this.changeValue(),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}this.changeValue()})}}});import{styleText as I,stripVTControlCharacters as vL}from"node:util";import w0 from"node:process";function yV(){return w0.platform!=="win32"?w0.env.TERM!=="linux":!!w0.env.CI||!!w0.env.WT_SESSION||!!w0.env.TERMINUS_SUBLIME||w0.env.ConEmuTask==="{cmd::Cmder}"||w0.env.TERM_PROGRAM==="Terminus-Sublime"||w0.env.TERM_PROGRAM==="vscode"||w0.env.TERM==="xterm-256color"||w0.env.TERM==="alacritty"||w0.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var k6,O5,gV=()=>process.env.CI==="true",b=(Q,$)=>O5?Q:$,_V,x7,v7,f8,bV,y,s1,yL,gL,N5,h8,hV,w7,D7,_L,R7,fV,mV,cV,uV,bL,pV,dV,lV,oV,M5=(Q)=>{switch(Q){case"initial":case"active":return I("cyan",_V);case"cancel":return I("red",x7);case"error":return I("yellow",v7);case"submit":return I("green",f8)}},S7=(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)}},iV=(Q,$,q,J,Y)=>{let V=$,K=0;for(let X=q;X<J;X++){let W=Q[X];if(V=V-W.length,K++,V<=Y)break}return{lineCount:V,removals:K}},B5=({cursor:Q,options:$,style:q,output:J=process.stdout,maxItems:Y=Number.POSITIVE_INFINITY,columnPadding:V=0,rowPadding:K=4})=>{let X=S6(J)-V,W=H5(J),G=I("dim","..."),j=Math.max(W-K,0),H=Math.max(Math.min(Y,j),5),U=0;Q>=H-3&&(U=Math.max(Math.min(Q-H+3,$.length-H),0));let z=H<$.length&&U>0,F=H<$.length&&U+H<$.length,N=Math.min(U+H,$.length),C=[],P=0;z&&P++,F&&P++;let L=U+(z?1:0),A=N-(F?1:0);for(let O=L;O<A;O++){let M=d0(q($[O],O===Q),X,{hard:!0,trim:!1}).split(`
22
+ `);C.push(M),P+=M.length}if(P>j){let O=0,M=0,T=P,w=Q-L,x=(v,R)=>iV(C,T,v,R,j);z?({lineCount:T,removals:O}=x(0,w),T>j&&({lineCount:T,removals:M}=x(w+1,C.length))):({lineCount:T,removals:M}=x(w+1,C.length),T>j&&({lineCount:T,removals:O}=x(0,w))),O>0&&(z=!0,C.splice(0,O)),M>0&&(F=!0,C.splice(C.length-M,M))}let B=[];z&&B.push(G);for(let O of C)for(let M of O)B.push(M);return F&&B.push(G),B},m8=(Q)=>{let $=Q.active??"Yes",q=Q.inactive??"No";return new z5({active:$,inactive:q,signal:Q.signal,input:Q.input,output:Q.output,initialValue:Q.initialValue??!0,render(){let J=Q.withGuide??r.withGuide,Y=`${M5(this.state)} `,V=J?`${I("gray",y)} `:"",K=O1(Q.output,Q.message,V,Y),X=`${J?`${I("gray",y)}
23
+ `:""}${K}
24
+ `,W=this.value?$:q;switch(this.state){case"submit":{let G=J?`${I("gray",y)} `:"";return`${X}${G}${I("dim",W)}`}case"cancel":{let G=J?`${I("gray",y)} `:"";return`${X}${G}${I(["strikethrough","dim"],W)}${J?`
25
+ ${I("gray",y)}`:""}`}default:{let G=J?`${I("cyan",y)} `:"",j=J?I("cyan",s1):"";return`${X}${G}${this.value?`${I("green",N5)} ${$}`:`${I("dim",h8)} ${I("dim",$)}`}${Q.vertical?J?`
26
26
  ${I("cyan",y)} `:`
27
27
  `:` ${I("dim","/")} `}${this.value?`${I("dim",h8)} ${I("dim",q)}`:`${I("green",N5)} ${q}`}
28
- ${U}
28
+ ${j}
29
29
  `}}}}).prompt()},i,d=(Q="",$)=>{let q=$?.output??process.stdout,J=$?.withGuide??r.withGuide?`${I("gray",s1)} `:"";q.write(`${J}${I("red",Q)}
30
30
 
31
- `)},N0=(Q="",$)=>{let q=$?.output??process.stdout,J=$?.withGuide??r.withGuide?`${I("gray",RV)} `:"";q.write(`${J}${Q}
32
- `)},w0=(Q="",$)=>{let q=$?.output??process.stdout,J=$?.withGuide??r.withGuide?`${I("gray",y)}
31
+ `)},N0=(Q="",$)=>{let q=$?.output??process.stdout,J=$?.withGuide??r.withGuide?`${I("gray",bV)} `:"";q.write(`${J}${Q}
32
+ `)},D0=(Q="",$)=>{let q=$?.output??process.stdout,J=$?.withGuide??r.withGuide?`${I("gray",y)}
33
33
  ${I("gray",s1)} `:"";q.write(`${J}${Q}
34
34
 
35
35
  `)},E6=(Q,$)=>Q.split(`
36
36
  `).map((q)=>$(q)).join(`
37
- `),E7=(Q)=>{let $=(J,Y)=>{let V=J.label??String(J.value);return Y==="disabled"?`${I("gray",w7)} ${E6(V,(X)=>I(["strikethrough","gray"],X))}${J.hint?` ${I("dim",`(${J.hint??"disabled"})`)}`:""}`:Y==="active"?`${I("cyan",xV)} ${V}${J.hint?` ${I("dim",`(${J.hint})`)}`:""}`:Y==="selected"?`${I("green",D7)} ${E6(V,(X)=>I("dim",X))}${J.hint?` ${I("dim",`(${J.hint})`)}`:""}`:Y==="cancelled"?`${E6(V,(X)=>I(["strikethrough","dim"],X))}`:Y==="active-selected"?`${I("green",D7)} ${V}${J.hint?` ${I("dim",`(${J.hint})`)}`:""}`:Y==="submitted"?`${E6(V,(X)=>I("dim",X))}`:`${I("dim",w7)} ${E6(V,(X)=>I("dim",X))}`},q=Q.required??!0;return new A7({options:Q.options,signal:Q.signal,input:Q.input,output:Q.output,initialValues:Q.initialValues,required:q,cursorAt:Q.cursorAt,validate(J){if(q&&(J===void 0||J.length===0))return`Please select at least one option.
37
+ `),E7=(Q)=>{let $=(J,Y)=>{let V=J.label??String(J.value);return Y==="disabled"?`${I("gray",D7)} ${E6(V,(K)=>I(["strikethrough","gray"],K))}${J.hint?` ${I("dim",`(${J.hint??"disabled"})`)}`:""}`:Y==="active"?`${I("cyan",hV)} ${V}${J.hint?` ${I("dim",`(${J.hint})`)}`:""}`:Y==="selected"?`${I("green",w7)} ${E6(V,(K)=>I("dim",K))}${J.hint?` ${I("dim",`(${J.hint})`)}`:""}`:Y==="cancelled"?`${E6(V,(K)=>I(["strikethrough","dim"],K))}`:Y==="active-selected"?`${I("green",w7)} ${V}${J.hint?` ${I("dim",`(${J.hint})`)}`:""}`:Y==="submitted"?`${E6(V,(K)=>I("dim",K))}`:`${I("dim",D7)} ${E6(V,(K)=>I("dim",K))}`},q=Q.required??!0;return new A7({options:Q.options,signal:Q.signal,input:Q.input,output:Q.output,initialValues:Q.initialValues,required:q,cursorAt:Q.cursorAt,validate(J){if(q&&(J===void 0||J.length===0))return`Please select at least one option.
38
38
  ${I("reset",I("dim",`Press ${I(["gray","bgWhite","inverse"]," space ")} to select, ${I("gray",I("bgWhite",I("inverse"," enter ")))} to submit`))}`},render(){let J=Q.withGuide??r.withGuide,Y=O1(Q.output,Q.message,J?`${S7(this.state)} `:"",`${M5(this.state)} `),V=`${J?`${I("gray",y)}
39
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,J?`${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,J?`${I("gray",y)} `:"");return`${V}${G}${J?`
40
+ `,K=this.value??[],X=(W,G)=>{if(W.disabled)return $(W,"disabled");let j=K.includes(W.value);return G&&j?$(W,"active-selected"):j?$(W,"selected"):$(W,G?"active":"inactive")};switch(this.state){case"submit":{let W=this.options.filter(({value:j})=>K.includes(j)).map((j)=>$(j,"submitted")).join(I("dim",", "))||I("dim","none"),G=O1(Q.output,W,J?`${I("gray",y)} `:"");return`${V}${G}`}case"cancel":{let W=this.options.filter(({value:j})=>K.includes(j)).map((j)=>$(j,"cancelled")).join(I("dim",", "));if(W.trim()==="")return`${V}${I("gray",y)}`;let G=O1(Q.output,W,J?`${I("gray",y)} `:"");return`${V}${G}${J?`
41
41
  ${I("gray",y)}`:""}`}case"error":{let W=J?`${I("yellow",y)} `:"",G=this.error.split(`
42
- `).map((Z,H)=>H===0?`${J?`${I("yellow",s1)} `:""}${I("yellow",Z)}`:` ${Z}`).join(`
43
- `),U=V.split(`
44
- `).length,z=G.split(`
45
- `).length+1;return`${V}${W}${B5({output:Q.output,options:this.options,cursor:this.cursor,maxItems:Q.maxItems,columnPadding:W.length,rowPadding:U+z,style:K}).join(`
42
+ `).map((U,z)=>z===0?`${J?`${I("yellow",s1)} `:""}${I("yellow",U)}`:` ${U}`).join(`
43
+ `),j=V.split(`
44
+ `).length,H=G.split(`
45
+ `).length+1;return`${V}${W}${B5({output:Q.output,options:this.options,cursor:this.cursor,maxItems:Q.maxItems,columnPadding:W.length,rowPadding:j+H,style:X}).join(`
46
46
  ${W}`)}
47
47
  ${G}
48
48
  `}default:{let W=J?`${I("cyan",y)} `:"",G=V.split(`
49
- `).length,U=J?2:1;return`${V}${W}${B5({output:Q.output,options:this.options,cursor:this.cursor,maxItems:Q.maxItems,columnPadding:W.length,rowPadding:G+U,style:K}).join(`
49
+ `).length,j=J?2:1;return`${V}${W}${B5({output:Q.output,options:this.options,cursor:this.cursor,maxItems:Q.maxItems,columnPadding:W.length,rowPadding:G+j,style:X}).join(`
50
50
  ${W}`)}
51
51
  ${J?I("cyan",s1):""}
52
- `}}}}).prompt()},fV=(Q)=>I("dim",Q),mV=(Q,$,q)=>{let J={hard:!0,trim:!1},Y=d0(Q,$,J).split(`
53
- `),V=Y.reduce((W,G)=>Math.max(W0(G),W),0),X=Y.map(q).reduce((W,G)=>Math.max(W0(G),W),0),K=$-(X-V);return d0(Q,K,J)},b0=(Q="",$="",q)=>{let J=q?.output??D0.stdout,Y=q?.withGuide??r.withGuide,V=q?.format??fV,X=["",...mV(Q,S6(J)-6,V).split(`
54
- `).map(V),""],K=W0($),W=Math.max(X.reduce((Z,H)=>{let F=W0(H);return F>Z?F:Z},0),K)+2,G=X.map((Z)=>`${I("gray",y)} ${Z}${" ".repeat(W-W0(Z))}${I("gray",y)}`).join(`
55
- `),U=Y?`${I("gray",y)}
56
- `:"",z=Y?SV:kV;J.write(`${U}${I("green",f8)} ${I("reset",$)} ${I("gray",R7.repeat(Math.max(W-K-1,1))+vV)}
52
+ `}}}}).prompt()},nV=(Q)=>I("dim",Q),rV=(Q,$,q)=>{let J={hard:!0,trim:!1},Y=d0(Q,$,J).split(`
53
+ `),V=Y.reduce((W,G)=>Math.max(W0(G),W),0),K=Y.map(q).reduce((W,G)=>Math.max(W0(G),W),0),X=$-(K-V);return d0(Q,X,J)},b0=(Q="",$="",q)=>{let J=q?.output??w0.stdout,Y=q?.withGuide??r.withGuide,V=q?.format??nV,K=["",...rV(Q,S6(J)-6,V).split(`
54
+ `).map(V),""],X=W0($),W=Math.max(K.reduce((U,z)=>{let F=W0(z);return F>U?F:U},0),X)+2,G=K.map((U)=>`${I("gray",y)} ${U}${" ".repeat(W-W0(U))}${I("gray",y)}`).join(`
55
+ `),j=Y?`${I("gray",y)}
56
+ `:"",H=Y?mV:uV;J.write(`${j}${I("green",f8)} ${I("reset",$)} ${I("gray",R7.repeat(Math.max(W-X-1,1))+fV)}
57
57
  ${G}
58
- ${I("gray",z+R7.repeat(W+2)+EV)}
59
- `)},cV=(Q)=>I("magenta",Q),U0=({indicator:Q="dots",onCancel:$,output:q=process.stdout,cancelMessage:J,errorMessage:Y,frames:V=O5?["◒","◐","◓","◑"]:["•","o","O","0"],delay:X=O5?80:120,signal:K,...W}={})=>{let G=DV(),U,z,Z=!1,H=!1,F="",N,C=performance.now(),P=S6(q),L=W?.styleFrame??cV,A=(h)=>{let G0=h>1?Y??r.messages.error:J??r.messages.cancel;H=h===1,Z&&(T0(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)},T=()=>{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&&q.write(`
58
+ ${I("gray",H+R7.repeat(W+2)+cV)}
59
+ `)},aV=(Q)=>I("magenta",Q),j0=({indicator:Q="dots",onCancel:$,output:q=process.stdout,cancelMessage:J,errorMessage:Y,frames:V=O5?["◒","◐","◓","◑"]:["•","o","O","0"],delay:K=O5?80:120,signal:X,...W}={})=>{let G=gV(),j,H,U=!1,z=!1,F="",N,C=performance.now(),P=S6(q),L=W?.styleFrame??aV,A=(h)=>{let G0=h>1?Y??r.messages.error:J??r.messages.cancel;z=h===1,U&&(T0(G0,h),z&&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),X&&X.addEventListener("abort",O)},T=()=>{process.removeListener("uncaughtExceptionMonitor",B),process.removeListener("unhandledRejection",B),process.removeListener("SIGINT",O),process.removeListener("SIGTERM",O),process.removeListener("exit",A),X&&X.removeEventListener("abort",O)},w=()=>{if(N===void 0)return;G&&q.write(`
60
60
  `);let h=d0(N,P,{hard:!0,trim:!1}).split(`
61
- `);h.length>1&&q.write(k6.cursor.up(h.length-1)),q.write(k6.cursor.to(0)),q.write(k6.erase.down())},x=(h)=>h.replace(/\.+$/,""),v=(h)=>{let G0=(performance.now()-h)/1000,A0=Math.floor(G0/60),z0=Math.floor(G0%60);return A0>0?`[${A0}m ${z0}s]`:`[${z0}s]`},R=W.withGuide??r.withGuide,$0=(h="")=>{Z=!0,U=M7({output:q}),F=x(h),C=performance.now(),R&&q.write(`${I("gray",y)}
62
- `);let G0=0,A0=0;M(),z=setInterval(()=>{if(G&&F===N)return;D(),N=F;let z0=L(V[G0]),J1;if(G)J1=`${z0} ${F}...`;else if(Q==="timer")J1=`${z0} ${F} ${v(C)}`;else{let c3=".".repeat(Math.floor(A0)).slice(0,3);J1=`${z0} ${F}${c3}`}let m3=d0(J1,P,{hard:!0,trim:!1});q.write(m3),G0=G0+1<V.length?G0+1:0,A0=A0<4?A0+0.125:0},X)},T0=(h="",G0=0,A0=!1)=>{if(!Z)return;Z=!1,clearInterval(z),D();let z0=G0===0?I("green",f8):G0===1?I("red",x7):I("red",v7);F=h??F,A0||(Q==="timer"?q.write(`${z0} ${F} ${v(C)}
63
- `):q.write(`${z0} ${F}
64
- `)),T(),U()};return{start:$0,stop:(h="")=>T0(h,0),message:(h="")=>{F=x(h??F)},cancel:(h="")=>T0(h,1),error:(h="")=>T0(h,2),clear:()=>T0("",0,!0),get isCancelled(){return H}}},RL,b8=(Q,$)=>Q.includes(`
61
+ `);h.length>1&&q.write(k6.cursor.up(h.length-1)),q.write(k6.cursor.to(0)),q.write(k6.erase.down())},x=(h)=>h.replace(/\.+$/,""),v=(h)=>{let G0=(performance.now()-h)/1000,A0=Math.floor(G0/60),H0=Math.floor(G0%60);return A0>0?`[${A0}m ${H0}s]`:`[${H0}s]`},R=W.withGuide??r.withGuide,q0=(h="")=>{U=!0,j=M7({output:q}),F=x(h),C=performance.now(),R&&q.write(`${I("gray",y)}
62
+ `);let G0=0,A0=0;M(),H=setInterval(()=>{if(G&&F===N)return;w(),N=F;let H0=L(V[G0]),J1;if(G)J1=`${H0} ${F}...`;else if(Q==="timer")J1=`${H0} ${F} ${v(C)}`;else{let a3=".".repeat(Math.floor(A0)).slice(0,3);J1=`${H0} ${F}${a3}`}let r3=d0(J1,P,{hard:!0,trim:!1});q.write(r3),G0=G0+1<V.length?G0+1:0,A0=A0<4?A0+0.125:0},K)},T0=(h="",G0=0,A0=!1)=>{if(!U)return;U=!1,clearInterval(H),w();let H0=G0===0?I("green",f8):G0===1?I("red",x7):I("red",v7);F=h??F,A0||(Q==="timer"?q.write(`${H0} ${F} ${v(C)}
63
+ `):q.write(`${H0} ${F}
64
+ `)),T(),j()};return{start:q0,stop:(h="")=>T0(h,0),message:(h="")=>{F=x(h??F)},cancel:(h="")=>T0(h,1),error:(h="")=>T0(h,2),clear:()=>T0("",0,!0),get isCancelled(){return z}}},hL,b8=(Q,$)=>Q.includes(`
65
65
  `)?Q.split(`
66
66
  `).map((q)=>$(q)).join(`
67
- `):$(Q),P5=(Q)=>{let $=(q,J)=>{let Y=q.label??String(q.value);switch(J){case"disabled":return`${I("gray",h8)} ${b8(Y,(V)=>I("gray",V))}${q.hint?` ${I("dim",`(${q.hint??"disabled"})`)}`:""}`;case"selected":return`${b8(Y,(V)=>I("dim",V))}`;case"active":return`${I("green",N5)} ${Y}${q.hint?` ${I("dim",`(${q.hint})`)}`:""}`;case"cancelled":return`${b8(Y,(V)=>I(["strikethrough","dim"],V))}`;default:return`${I("dim",h8)} ${b8(Y,(V)=>I("dim",V))}`}};return new F5({options:Q.options,signal:Q.signal,input:Q.input,output:Q.output,initialValue:Q.initialValue,render(){let q=Q.withGuide??r.withGuide,J=`${M5(this.state)} `,Y=`${S7(this.state)} `,V=O1(Q.output,Q.message,Y,J),X=`${q?`${I("gray",y)}
67
+ `):$(Q),P5=(Q)=>{let $=(q,J)=>{let Y=q.label??String(q.value);switch(J){case"disabled":return`${I("gray",h8)} ${b8(Y,(V)=>I("gray",V))}${q.hint?` ${I("dim",`(${q.hint??"disabled"})`)}`:""}`;case"selected":return`${b8(Y,(V)=>I("dim",V))}`;case"active":return`${I("green",N5)} ${Y}${q.hint?` ${I("dim",`(${q.hint})`)}`:""}`;case"cancelled":return`${b8(Y,(V)=>I(["strikethrough","dim"],V))}`;default:return`${I("dim",h8)} ${b8(Y,(V)=>I("dim",V))}`}};return new F5({options:Q.options,signal:Q.signal,input:Q.input,output:Q.output,initialValue:Q.initialValue,render(){let q=Q.withGuide??r.withGuide,J=`${M5(this.state)} `,Y=`${S7(this.state)} `,V=O1(Q.output,Q.message,Y,J),K=`${q?`${I("gray",y)}
68
68
  `:""}${V}
69
- `;switch(this.state){case"submit":{let K=q?`${I("gray",y)} `:"",W=O1(Q.output,$(this.options[this.cursor],"selected"),K);return`${X}${W}`}case"cancel":{let K=q?`${I("gray",y)} `:"",W=O1(Q.output,$(this.options[this.cursor],"cancelled"),K);return`${X}${W}${q?`
70
- ${I("gray",y)}`:""}`}default:{let K=q?`${I("cyan",y)} `:"",W=q?I("cyan",s1):"",G=X.split(`
71
- `).length,U=q?2:1;return`${X}${K}${B5({output:Q.output,cursor:this.cursor,options:this.options,maxItems:Q.maxItems,columnPadding:K.length,rowPadding:G+U,style:(z,Z)=>$(z,z.disabled?"disabled":Z?"active":"inactive")}).join(`
72
- ${K}`)}
69
+ `;switch(this.state){case"submit":{let X=q?`${I("gray",y)} `:"",W=O1(Q.output,$(this.options[this.cursor],"selected"),X);return`${K}${W}`}case"cancel":{let X=q?`${I("gray",y)} `:"",W=O1(Q.output,$(this.options[this.cursor],"cancelled"),X);return`${K}${W}${q?`
70
+ ${I("gray",y)}`:""}`}default:{let X=q?`${I("cyan",y)} `:"",W=q?I("cyan",s1):"",G=K.split(`
71
+ `).length,j=q?2:1;return`${K}${X}${B5({output:Q.output,cursor:this.cursor,options:this.options,maxItems:Q.maxItems,columnPadding:X.length,rowPadding:G+j,style:(H,U)=>$(H,H.disabled?"disabled":U?"active":"inactive")}).join(`
72
+ ${X}`)}
73
73
  ${W}
74
- `}}}}).prompt()},xL;var t1=H0(()=>{L5();L5();Y5();Q5();k6=p0(X5(),1);O5=AV(),wV=b("◆","*"),x7=b("■","x"),v7=b("▲","x"),f8=b("◇","o"),RV=b("┌","T"),y=b("│","|"),s1=b("└","—"),TL=b("┐","T"),AL=b("┘","—"),N5=b("●",">"),h8=b("○"," "),xV=b("◻","[•]"),D7=b("◼","[+]"),w7=b("◻","[ ]"),DL=b("▪","•"),R7=b("─","-"),vV=b("╮","+"),SV=b("├","+"),EV=b("╯","+"),kV=b("╰","+"),wL=b("╭","+"),yV=b("●","•"),gV=b("◆","*"),_V=b("▲","!"),bV=b("■","x"),i={message:(Q=[],{symbol:$=I("gray",y),secondarySymbol:q=I("gray",y),output:J=process.stdout,spacing:Y=1,withGuide:V}={})=>{let X=[],K=V??r.withGuide,W=K?q:"",G=K?`${$} `:"",U=K?`${q} `:"";for(let Z=0;Z<Y;Z++)X.push(W);let z=Array.isArray(Q)?Q:Q.split(`
75
- `);if(z.length>0){let[Z,...H]=z;Z.length>0?X.push(`${G}${Z}`):X.push(K?$:"");for(let F of H)F.length>0?X.push(`${U}${F}`):X.push(K?q:"")}J.write(`${X.join(`
74
+ `}}}}).prompt()},fL;var t1=z0(()=>{L5();L5();Y5();Q5();k6=p0(K5(),1);O5=yV(),_V=b("◆","*"),x7=b("■","x"),v7=b("▲","x"),f8=b("◇","o"),bV=b("┌","T"),y=b("│","|"),s1=b("└","—"),yL=b("┐","T"),gL=b("┘","—"),N5=b("●",">"),h8=b("○"," "),hV=b("◻","[•]"),w7=b("◼","[+]"),D7=b("◻","[ ]"),_L=b("▪","•"),R7=b("─","-"),fV=b("╮","+"),mV=b("├","+"),cV=b("╯","+"),uV=b("╰","+"),bL=b("╭","+"),pV=b("●","•"),dV=b("◆","*"),lV=b("▲","!"),oV=b("■","x"),i={message:(Q=[],{symbol:$=I("gray",y),secondarySymbol:q=I("gray",y),output:J=process.stdout,spacing:Y=1,withGuide:V}={})=>{let K=[],X=V??r.withGuide,W=X?q:"",G=X?`${$} `:"",j=X?`${q} `:"";for(let U=0;U<Y;U++)K.push(W);let H=Array.isArray(Q)?Q:Q.split(`
75
+ `);if(H.length>0){let[U,...z]=H;U.length>0?K.push(`${G}${U}`):K.push(X?$:"");for(let F of z)F.length>0?K.push(`${j}${F}`):K.push(X?q:"")}J.write(`${K.join(`
76
76
  `)}
77
- `)},info:(Q,$)=>{i.message(Q,{...$,symbol:I("blue",yV)})},success:(Q,$)=>{i.message(Q,{...$,symbol:I("green",gV)})},step:(Q,$)=>{i.message(Q,{...$,symbol:I("green",f8)})},warn:(Q,$)=>{i.message(Q,{...$,symbol:I("yellow",_V)})},warning:(Q,$)=>{i.warn(Q,$)},error:(Q,$)=>{i.message(Q,{...$,symbol:I("red",bV)})}},RL={light:b("─","-"),heavy:b("━","="),block:b("█","#")},xL=`${I("gray",y)} `});var g6=w((SL,I5)=>{if(typeof process>"u"||!process.version||process.version.indexOf("v0.")===0||process.version.indexOf("v1.")===0&&process.version.indexOf("v1.8.")!==0)I5.exports={nextTick:uV};else I5.exports=process;function uV(Q,$,q,J){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,$,q)});case 4:return process.nextTick(function(){Q.call(null,$,q,J)});default:V=Array(Y-1),X=0;while(X<V.length)V[X++]=arguments[X];return process.nextTick(function(){Q.apply(null,V)})}}});var y7=w((EL,k7)=>{var pV={}.toString;k7.exports=Array.isArray||function(Q){return pV.call(Q)=="[object Array]"}});var _6=w((C5,_7)=>{var c8=_("buffer"),X1=c8.Buffer;function g7(Q,$){for(var q in Q)$[q]=Q[q]}if(X1.from&&X1.alloc&&X1.allocUnsafe&&X1.allocUnsafeSlow)_7.exports=c8;else g7(c8,C5),C5.Buffer=e1;function e1(Q,$,q){return X1(Q,$,q)}g7(X1,e1);e1.from=function(Q,$,q){if(typeof Q==="number")throw TypeError("Argument must not be a number");return X1(Q,$,q)};e1.alloc=function(Q,$,q){if(typeof Q!=="number")throw TypeError("Argument must be a number");var J=X1(Q);if($!==void 0)if(typeof q==="string")J.fill($,q);else J.fill($);else J.fill(0);return J};e1.allocUnsafe=function(Q){if(typeof Q!=="number")throw TypeError("Argument must be a number");return X1(Q)};e1.allocUnsafeSlow=function(Q){if(typeof Q!=="number")throw TypeError("Argument must be a number");return c8.SlowBuffer(Q)}});var Q6=w((YX)=>{function dV(Q){if(Array.isArray)return Array.isArray(Q);return u8(Q)==="[object Array]"}YX.isArray=dV;function lV(Q){return typeof Q==="boolean"}YX.isBoolean=lV;function oV(Q){return Q===null}YX.isNull=oV;function iV(Q){return Q==null}YX.isNullOrUndefined=iV;function nV(Q){return typeof Q==="number"}YX.isNumber=nV;function rV(Q){return typeof Q==="string"}YX.isString=rV;function aV(Q){return typeof Q==="symbol"}YX.isSymbol=aV;function sV(Q){return Q===void 0}YX.isUndefined=sV;function tV(Q){return u8(Q)==="[object RegExp]"}YX.isRegExp=tV;function eV(Q){return typeof Q==="object"&&Q!==null}YX.isObject=eV;function QX(Q){return u8(Q)==="[object Date]"}YX.isDate=QX;function $X(Q){return u8(Q)==="[object Error]"||Q instanceof Error}YX.isError=$X;function qX(Q){return typeof Q==="function"}YX.isFunction=qX;function JX(Q){return Q===null||typeof Q==="boolean"||typeof Q==="number"||typeof Q==="string"||typeof Q==="symbol"||typeof Q>"u"}YX.isPrimitive=JX;YX.isBuffer=_("buffer").Buffer.isBuffer;function u8(Q){return Object.prototype.toString.call(Q)}});var b7=w((yL,T5)=>{if(typeof Object.create==="function")T5.exports=function($,q){if(q)$.super_=q,$.prototype=Object.create(q.prototype,{constructor:{value:$,enumerable:!1,writable:!0,configurable:!0}})};else T5.exports=function($,q){if(q){$.super_=q;var J=function(){};J.prototype=q.prototype,$.prototype=new J,$.prototype.constructor=$}}});var $6=w((gL,A5)=>{try{if(p8=_("util"),typeof p8.inherits!=="function")throw"";A5.exports=p8.inherits}catch(Q){A5.exports=b7()}var p8});var f7=w((_L,D5)=>{function MX(Q,$){if(!(Q instanceof $))throw TypeError("Cannot call a class as a function")}var h7=_6().Buffer,b6=_("util");function PX(Q,$,q){Q.copy($,q)}D5.exports=function(){function Q(){MX(this,Q),this.head=null,this.tail=null,this.length=0}return Q.prototype.push=function(q){var J={data:q,next:null};if(this.length>0)this.tail.next=J;else this.head=J;this.tail=J,++this.length},Q.prototype.unshift=function(q){var J={data:q,next:this.head};if(this.length===0)this.tail=J;this.head=J,++this.length},Q.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},Q.prototype.clear=function(){this.head=this.tail=null,this.length=0},Q.prototype.join=function(q){if(this.length===0)return"";var J=this.head,Y=""+J.data;while(J=J.next)Y+=q+J.data;return Y},Q.prototype.concat=function(q){if(this.length===0)return h7.alloc(0);var J=h7.allocUnsafe(q>>>0),Y=this.head,V=0;while(Y)PX(Y.data,J,V),V+=Y.data.length,Y=Y.next;return J},Q}();if(b6&&b6.inspect&&b6.inspect.custom)D5.exports.prototype[b6.inspect.custom]=function(){var Q=b6.inspect({length:this.length});return this.constructor.name+" "+Q}});var w5=w((bL,m7)=>{var d8=g6();function IX(Q,$){var q=this,J=this._readableState&&this._readableState.destroyed,Y=this._writableState&&this._writableState.destroyed;if(J||Y){if($)$(Q);else if(Q){if(!this._writableState)d8.nextTick(l8,this,Q);else if(!this._writableState.errorEmitted)this._writableState.errorEmitted=!0,d8.nextTick(l8,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(!q._writableState)d8.nextTick(l8,q,V);else if(!q._writableState.errorEmitted)q._writableState.errorEmitted=!0,d8.nextTick(l8,q,V)}else if($)$(V)}),this}function CX(){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 l8(Q,$){Q.emit("error",$)}m7.exports={destroy:IX,undestroy:CX}});var u7=w((hL,c7)=>{c7.exports=_("util").deprecate});var x5=w((fL,a7)=>{var _1=g6();a7.exports=a;function d7(Q){var $=this;this.next=null,this.entry=null,this.finish=function(){cX($,Q)}}var TX=["v0.10","v0.9."].indexOf(process.version.slice(0,5))>-1?setImmediate:_1.nextTick,q6;a.WritableState=f6;var l7=Object.create(Q6());l7.inherits=$6();var AX={deprecate:u7()},o7=_("stream"),i8=_6().Buffer,DX=(typeof global<"u"?global:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function wX(Q){return i8.from(Q)}function RX(Q){return i8.isBuffer(Q)||Q instanceof DX}var i7=w5();l7.inherits(a,o7);function xX(){}function f6(Q,$){q6=q6||b1(),Q=Q||{};var q=$ instanceof q6;if(this.objectMode=!!Q.objectMode,q)this.objectMode=this.objectMode||!!Q.writableObjectMode;var{highWaterMark:J,writableHighWaterMark:Y}=Q,V=this.objectMode?16:16384;if(J||J===0)this.highWaterMark=J;else if(q&&(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){_X($,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 d7(this)}f6.prototype.getBuffer=function(){var $=this.bufferedRequest,q=[];while($)q.push($),$=$.next;return q};(function(){try{Object.defineProperty(f6.prototype,"buffer",{get:AX.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(Q){}})();var o8;if(typeof Symbol==="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]==="function")o8=Function.prototype[Symbol.hasInstance],Object.defineProperty(a,Symbol.hasInstance,{value:function(Q){if(o8.call(this,Q))return!0;if(this!==a)return!1;return Q&&Q._writableState instanceof f6}});else o8=function(Q){return Q instanceof this};function a(Q){if(q6=q6||b1(),!o8.call(a,this)&&!(this instanceof q6))return new a(Q);if(this._writableState=new f6(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}o7.call(this)}a.prototype.pipe=function(){this.emit("error",Error("Cannot pipe, not readable"))};function vX(Q,$){var q=Error("write after end");Q.emit("error",q),_1.nextTick($,q)}function SX(Q,$,q,J){var Y=!0,V=!1;if(q===null)V=TypeError("May not write null values to stream");else if(typeof q!=="string"&&q!==void 0&&!$.objectMode)V=TypeError("Invalid non-string/buffer chunk");if(V)Q.emit("error",V),_1.nextTick(J,V),Y=!1;return Y}a.prototype.write=function(Q,$,q){var J=this._writableState,Y=!1,V=!J.objectMode&&RX(Q);if(V&&!i8.isBuffer(Q))Q=wX(Q);if(typeof $==="function")q=$,$=null;if(V)$="buffer";else if(!$)$=J.defaultEncoding;if(typeof q!=="function")q=xX;if(J.ended)vX(this,q);else if(V||SX(this,J,Q,q))J.pendingcb++,Y=kX(this,J,V,Q,$,q);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)n7(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 EX(Q,$,q){if(!Q.objectMode&&Q.decodeStrings!==!1&&typeof $==="string")$=i8.from($,q);return $}Object.defineProperty(a.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function kX(Q,$,q,J,Y,V){if(!q){var X=EX($,J,Y);if(J!==X)q=!0,Y="buffer",J=X}var K=$.objectMode?1:J.length;$.length+=K;var W=$.length<$.highWaterMark;if(!W)$.needDrain=!0;if($.writing||$.corked){var G=$.lastBufferedRequest;if($.lastBufferedRequest={chunk:J,encoding:Y,isBuf:q,callback:V,next:null},G)G.next=$.lastBufferedRequest;else $.bufferedRequest=$.lastBufferedRequest;$.bufferedRequestCount+=1}else R5(Q,$,!1,K,J,Y,V);return W}function R5(Q,$,q,J,Y,V,X){if($.writelen=J,$.writecb=X,$.writing=!0,$.sync=!0,q)Q._writev(Y,$.onwrite);else Q._write(Y,V,$.onwrite);$.sync=!1}function yX(Q,$,q,J,Y){if(--$.pendingcb,q)_1.nextTick(Y,J),_1.nextTick(h6,Q,$),Q._writableState.errorEmitted=!0,Q.emit("error",J);else Y(J),Q._writableState.errorEmitted=!0,Q.emit("error",J),h6(Q,$)}function gX(Q){Q.writing=!1,Q.writecb=null,Q.length-=Q.writelen,Q.writelen=0}function _X(Q,$){var q=Q._writableState,J=q.sync,Y=q.writecb;if(gX(q),$)yX(Q,q,J,$,Y);else{var V=r7(q);if(!V&&!q.corked&&!q.bufferProcessing&&q.bufferedRequest)n7(Q,q);if(J)TX(p7,Q,q,V,Y);else p7(Q,q,V,Y)}}function p7(Q,$,q,J){if(!q)bX(Q,$);$.pendingcb--,J(),h6(Q,$)}function bX(Q,$){if($.length===0&&$.needDrain)$.needDrain=!1,Q.emit("drain")}function n7(Q,$){$.bufferProcessing=!0;var q=$.bufferedRequest;if(Q._writev&&q&&q.next){var J=$.bufferedRequestCount,Y=Array(J),V=$.corkedRequestsFree;V.entry=q;var X=0,K=!0;while(q){if(Y[X]=q,!q.isBuf)K=!1;q=q.next,X+=1}if(Y.allBuffers=K,R5(Q,$,!0,$.length,Y,"",V.finish),$.pendingcb++,$.lastBufferedRequest=null,V.next)$.corkedRequestsFree=V.next,V.next=null;else $.corkedRequestsFree=new d7($);$.bufferedRequestCount=0}else{while(q){var{chunk:W,encoding:G,callback:U}=q,z=$.objectMode?1:W.length;if(R5(Q,$,!1,z,W,G,U),q=q.next,$.bufferedRequestCount--,$.writing)break}if(q===null)$.lastBufferedRequest=null}$.bufferedRequest=q,$.bufferProcessing=!1}a.prototype._write=function(Q,$,q){q(Error("_write() is not implemented"))};a.prototype._writev=null;a.prototype.end=function(Q,$,q){var J=this._writableState;if(typeof Q==="function")q=Q,Q=null,$=null;else if(typeof $==="function")q=$,$=null;if(Q!==null&&Q!==void 0)this.write(Q,$);if(J.corked)J.corked=1,this.uncork();if(!J.ending)mX(this,J,q)};function r7(Q){return Q.ending&&Q.length===0&&Q.bufferedRequest===null&&!Q.finished&&!Q.writing}function hX(Q,$){Q._final(function(q){if($.pendingcb--,q)Q.emit("error",q);$.prefinished=!0,Q.emit("prefinish"),h6(Q,$)})}function fX(Q,$){if(!$.prefinished&&!$.finalCalled)if(typeof Q._final==="function")$.pendingcb++,$.finalCalled=!0,_1.nextTick(hX,Q,$);else $.prefinished=!0,Q.emit("prefinish")}function h6(Q,$){var q=r7($);if(q){if(fX(Q,$),$.pendingcb===0)$.finished=!0,Q.emit("finish")}return q}function mX(Q,$,q){if($.ending=!0,h6(Q,$),q)if($.finished)_1.nextTick(q);else Q.once("finish",q);$.ended=!0,Q.writable=!1}function cX(Q,$,q){var J=Q.entry;Q.entry=null;while(J){var Y=J.callback;$.pendingcb--,Y(q),J=J.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=i7.destroy;a.prototype._undestroy=i7.undestroy;a.prototype._destroy=function(Q,$){this.end(),$(Q)}});var b1=w((mL,Q4)=>{var s7=g6(),uX=Object.keys||function(Q){var $=[];for(var q in Q)$.push(q);return $};Q4.exports=K1;var t7=Object.create(Q6());t7.inherits=$6();var e7=S5(),v5=x5();t7.inherits(K1,e7);{n8=uX(v5.prototype);for(m6=0;m6<n8.length;m6++)if(c6=n8[m6],!K1.prototype[c6])K1.prototype[c6]=v5.prototype[c6]}var n8,c6,m6;function K1(Q){if(!(this instanceof K1))return new K1(Q);if(e7.call(this,Q),v5.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",pX)}Object.defineProperty(K1.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function pX(){if(this.allowHalfOpen||this._writableState.ended)return;s7.nextTick(dX,this)}function dX(Q){Q.end()}Object.defineProperty(K1.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}});K1.prototype._destroy=function(Q,$){this.push(null),this.end(),s7.nextTick($,Q)}});var y5=w((YK)=>{var k5=_6().Buffer,$4=k5.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 lX(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 oX(Q){var $=lX(Q);if(typeof $!=="string"&&(k5.isEncoding===$4||!$4(Q)))throw Error("Unknown encoding: "+Q);return $||Q}YK.StringDecoder=u6;function u6(Q){this.encoding=oX(Q);var $;switch(this.encoding){case"utf16le":this.text=tX,this.end=eX,$=4;break;case"utf8":this.fillLast=rX,$=4;break;case"base64":this.text=QK,this.end=$K,$=3;break;default:this.write=qK,this.end=JK;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=k5.allocUnsafe($)}u6.prototype.write=function(Q){if(Q.length===0)return"";var $,q;if(this.lastNeed){if($=this.fillLast(Q),$===void 0)return"";q=this.lastNeed,this.lastNeed=0}else q=0;if(q<Q.length)return $?$+this.text(Q,q):this.text(Q,q);return $||""};u6.prototype.end=sX;u6.prototype.text=aX;u6.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 E5(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 iX(Q,$,q){var J=$.length-1;if(J<q)return 0;var Y=E5($[J]);if(Y>=0){if(Y>0)Q.lastNeed=Y-1;return Y}if(--J<q||Y===-2)return 0;if(Y=E5($[J]),Y>=0){if(Y>0)Q.lastNeed=Y-2;return Y}if(--J<q||Y===-2)return 0;if(Y=E5($[J]),Y>=0){if(Y>0)if(Y===2)Y=0;else Q.lastNeed=Y-3;return Y}return 0}function nX(Q,$,q){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 rX(Q){var $=this.lastTotal-this.lastNeed,q=nX(this,Q,$);if(q!==void 0)return q;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 aX(Q,$){var q=iX(this,Q,$);if(!this.lastNeed)return Q.toString("utf8",$);this.lastTotal=q;var J=Q.length-(q-this.lastNeed);return Q.copy(this.lastChar,0,J),Q.toString("utf8",$,J)}function sX(Q){var $=Q&&Q.length?this.write(Q):"";if(this.lastNeed)return $+"�";return $}function tX(Q,$){if((Q.length-$)%2===0){var q=Q.toString("utf16le",$);if(q){var J=q.charCodeAt(q.length-1);if(J>=55296&&J<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=Q[Q.length-2],this.lastChar[1]=Q[Q.length-1],q.slice(0,-1)}return q}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=Q[Q.length-1],Q.toString("utf16le",$,Q.length-1)}function eX(Q){var $=Q&&Q.length?this.write(Q):"";if(this.lastNeed){var q=this.lastTotal-this.lastNeed;return $+this.lastChar.toString("utf16le",0,q)}return $}function QK(Q,$){var q=(Q.length-$)%3;if(q===0)return Q.toString("base64",$);if(this.lastNeed=3-q,this.lastTotal=3,q===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-q)}function $K(Q){var $=Q&&Q.length?this.write(Q):"";if(this.lastNeed)return $+this.lastChar.toString("base64",0,3-this.lastNeed);return $}function qK(Q){return Q.toString(this.encoding)}function JK(Q){return Q&&Q.length?this.write(Q):""}});var S5=w((pL,z4)=>{var Y6=g6();z4.exports=c;var XK=y7(),p6;c.ReadableState=G4;var uL=_("events").EventEmitter,V4=function(Q,$){return Q.listeners($).length},f5=_("stream"),d6=_6().Buffer,KK=(typeof global<"u"?global:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function GK(Q){return d6.from(Q)}function WK(Q){return d6.isBuffer(Q)||Q instanceof KK}var X4=Object.create(Q6());X4.inherits=$6();var g5=_("util"),g=void 0;if(g5&&g5.debuglog)g=g5.debuglog("stream");else g=function(){};var UK=f7(),K4=w5(),J6;X4.inherits(c,f5);var _5=["error","close","destroy","pause","resume"];function jK(Q,$,q){if(typeof Q.prependListener==="function")return Q.prependListener($,q);if(!Q._events||!Q._events[$])Q.on($,q);else if(XK(Q._events[$]))Q._events[$].unshift(q);else Q._events[$]=[q,Q._events[$]]}function G4(Q,$){p6=p6||b1(),Q=Q||{};var q=$ instanceof p6;if(this.objectMode=!!Q.objectMode,q)this.objectMode=this.objectMode||!!Q.readableObjectMode;var{highWaterMark:J,readableHighWaterMark:Y}=Q,V=this.objectMode?16:16384;if(J||J===0)this.highWaterMark=J;else if(q&&(Y||Y===0))this.highWaterMark=Y;else this.highWaterMark=V;if(this.highWaterMark=Math.floor(this.highWaterMark),this.buffer=new UK,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(!J6)J6=y5().StringDecoder;this.decoder=new J6(Q.encoding),this.encoding=Q.encoding}}function c(Q){if(p6=p6||b1(),!(this instanceof c))return new c(Q);if(this._readableState=new G4(Q,this),this.readable=!0,Q){if(typeof Q.read==="function")this._read=Q.read;if(typeof Q.destroy==="function")this._destroy=Q.destroy}f5.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=K4.destroy;c.prototype._undestroy=K4.undestroy;c.prototype._destroy=function(Q,$){this.push(null),$(Q)};c.prototype.push=function(Q,$){var q=this._readableState,J;if(!q.objectMode){if(typeof Q==="string"){if($=$||q.defaultEncoding,$!==q.encoding)Q=d6.from(Q,$),$="";J=!0}}else J=!0;return W4(this,Q,$,!1,J)};c.prototype.unshift=function(Q){return W4(this,Q,null,!0,!1)};function W4(Q,$,q,J,Y){var V=Q._readableState;if($===null)V.reading=!1,FK(Q,V);else{var X;if(!Y)X=ZK(V,$);if(X)Q.emit("error",X);else if(V.objectMode||$&&$.length>0){if(typeof $!=="string"&&!V.objectMode&&Object.getPrototypeOf($)!==d6.prototype)$=GK($);if(J)if(V.endEmitted)Q.emit("error",Error("stream.unshift() after end event"));else b5(Q,V,$,!0);else if(V.ended)Q.emit("error",Error("stream.push() after EOF"));else if(V.reading=!1,V.decoder&&!q)if($=V.decoder.write($),V.objectMode||$.length!==0)b5(Q,V,$,!1);else U4(Q,V);else b5(Q,V,$,!1)}else if(!J)V.reading=!1}return zK(V)}function b5(Q,$,q,J){if($.flowing&&$.length===0&&!$.sync)Q.emit("data",q),Q.read(0);else{if($.length+=$.objectMode?1:q.length,J)$.buffer.unshift(q);else $.buffer.push(q);if($.needReadable)r8(Q)}U4(Q,$)}function ZK(Q,$){var q;if(!WK($)&&typeof $!=="string"&&$!==void 0&&!Q.objectMode)q=TypeError("Invalid non-string/buffer chunk");return q}function zK(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(!J6)J6=y5().StringDecoder;return this._readableState.decoder=new J6(Q),this._readableState.encoding=Q,this};var q4=8388608;function HK(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 J4(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=HK(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,q=Q;if(Q!==0)$.emittedReadable=!1;if(Q===0&&$.needReadable&&($.length>=$.highWaterMark||$.ended)){if(g("read: emitReadable",$.length,$.ended),$.length===0&&$.ended)h5(this);else r8(this);return null}if(Q=J4(Q,$),Q===0&&$.ended){if($.length===0)h5(this);return null}var J=$.needReadable;if(g("need readable",J),$.length===0||$.length-Q<$.highWaterMark)J=!0,g("length less than watermark",J);if($.ended||$.reading)J=!1,g("reading or ended",J);else if(J){if(g("do read"),$.reading=!0,$.sync=!0,$.length===0)$.needReadable=!0;if(this._read($.highWaterMark),$.sync=!1,!$.reading)Q=J4(q,$)}var Y;if(Q>0)Y=j4(Q,$);else Y=null;if(Y===null)$.needReadable=!0,Q=0;else $.length-=Q;if($.length===0){if(!$.ended)$.needReadable=!0;if(q!==Q&&$.ended)h5(this)}if(Y!==null)this.emit("data",Y);return Y};function FK(Q,$){if($.ended)return;if($.decoder){var q=$.decoder.end();if(q&&q.length)$.buffer.push(q),$.length+=$.objectMode?1:q.length}$.ended=!0,r8(Q)}function r8(Q){var $=Q._readableState;if($.needReadable=!1,!$.emittedReadable)if(g("emitReadable",$.flowing),$.emittedReadable=!0,$.sync)Y6.nextTick(Y4,Q);else Y4(Q)}function Y4(Q){g("emit readable"),Q.emit("readable"),m5(Q)}function U4(Q,$){if(!$.readingMore)$.readingMore=!0,Y6.nextTick(LK,Q,$)}function LK(Q,$){var q=$.length;while(!$.reading&&!$.flowing&&!$.ended&&$.length<$.highWaterMark)if(g("maybeReadMore read 0"),Q.read(0),q===$.length)break;else q=$.length;$.readingMore=!1}c.prototype._read=function(Q){this.emit("error",Error("_read() is not implemented"))};c.prototype.pipe=function(Q,$){var q=this,J=this._readableState;switch(J.pipesCount){case 0:J.pipes=Q;break;case 1:J.pipes=[J.pipes,Q];break;default:J.pipes.push(Q);break}J.pipesCount+=1,g("pipe count=%d opts=%j",J.pipesCount,$);var Y=(!$||$.end!==!1)&&Q!==process.stdout&&Q!==process.stderr,V=Y?K:C;if(J.endEmitted)Y6.nextTick(V);else q.once("end",V);Q.on("unpipe",X);function X(P,L){if(g("onunpipe"),P===q){if(L&&L.hasUnpiped===!1)L.hasUnpiped=!0,U()}}function K(){g("onend"),Q.end()}var W=OK(q);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),q.removeListener("end",K),q.removeListener("end",C),q.removeListener("data",Z),G=!0,J.awaitDrain&&(!Q._writableState||Q._writableState.needDrain))W()}var z=!1;q.on("data",Z);function Z(P){g("ondata"),z=!1;var L=Q.write(P);if(L===!1&&!z){if((J.pipesCount===1&&J.pipes===Q||J.pipesCount>1&&Z4(J.pipes,Q)!==-1)&&!G)g("false write response, pause",J.awaitDrain),J.awaitDrain++,z=!0;q.pause()}}function H(P){if(g("onerror",P),C(),Q.removeListener("error",H),V4(Q,"error")===0)Q.emit("error",P)}jK(Q,"error",H);function F(){Q.removeListener("finish",N),C()}Q.once("close",F);function N(){g("onfinish"),Q.removeListener("close",F),C()}Q.once("finish",N);function C(){g("unpipe"),q.unpipe(Q)}if(Q.emit("pipe",q),!J.flowing)g("pipe resume"),q.resume();return Q};function OK(Q){return function(){var $=Q._readableState;if(g("pipeOnDrain",$.awaitDrain),$.awaitDrain)$.awaitDrain--;if($.awaitDrain===0&&V4(Q,"data"))$.flowing=!0,m5(Q)}}c.prototype.unpipe=function(Q){var $=this._readableState,q={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,q);return this}if(!Q){var{pipes:J,pipesCount:Y}=$;$.pipes=null,$.pipesCount=0,$.flowing=!1;for(var V=0;V<Y;V++)J[V].emit("unpipe",this,{hasUnpiped:!1});return this}var X=Z4($.pipes,Q);if(X===-1)return this;if($.pipes.splice(X,1),$.pipesCount-=1,$.pipesCount===1)$.pipes=$.pipes[0];return Q.emit("unpipe",this,q),this};c.prototype.on=function(Q,$){var q=f5.prototype.on.call(this,Q,$);if(Q==="data"){if(this._readableState.flowing!==!1)this.resume()}else if(Q==="readable"){var J=this._readableState;if(!J.endEmitted&&!J.readableListening){if(J.readableListening=J.needReadable=!0,J.emittedReadable=!1,!J.reading)Y6.nextTick(NK,this);else if(J.length)r8(this)}}return q};c.prototype.addListener=c.prototype.on;function NK(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,BK(this,Q);return this};function BK(Q,$){if(!$.resumeScheduled)$.resumeScheduled=!0,Y6.nextTick(MK,Q,$)}function MK(Q,$){if(!$.reading)g("resume read 0"),Q.read(0);if($.resumeScheduled=!1,$.awaitDrain=0,Q.emit("resume"),m5(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 m5(Q){var $=Q._readableState;g("flow",$.flowing);while($.flowing&&Q.read()!==null);}c.prototype.wrap=function(Q){var $=this,q=this._readableState,J=!1;Q.on("end",function(){if(g("wrapped end"),q.decoder&&!q.ended){var X=q.decoder.end();if(X&&X.length)$.push(X)}$.push(null)}),Q.on("data",function(X){if(g("wrapped data"),q.decoder)X=q.decoder.write(X);if(q.objectMode&&(X===null||X===void 0))return;else if(!q.objectMode&&(!X||!X.length))return;var K=$.push(X);if(!K)J=!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<_5.length;V++)Q.on(_5[V],this.emit.bind(this,_5[V]));return this._read=function(X){if(g("wrapped _read",X),J)J=!1,Q.resume()},this};Object.defineProperty(c.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}});c._fromList=j4;function j4(Q,$){if($.length===0)return null;var q;if($.objectMode)q=$.buffer.shift();else if(!Q||Q>=$.length){if($.decoder)q=$.buffer.join("");else if($.buffer.length===1)q=$.buffer.head.data;else q=$.buffer.concat($.length);$.buffer.clear()}else q=PK(Q,$.buffer,$.decoder);return q}function PK(Q,$,q){var J;if(Q<$.head.data.length)J=$.head.data.slice(0,Q),$.head.data=$.head.data.slice(Q);else if(Q===$.head.data.length)J=$.shift();else J=q?IK(Q,$):CK(Q,$);return J}function IK(Q,$){var q=$.head,J=1,Y=q.data;Q-=Y.length;while(q=q.next){var V=q.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(++J,q.next)$.head=q.next;else $.head=$.tail=null;else $.head=q,q.data=V.slice(X);break}++J}return $.length-=J,Y}function CK(Q,$){var q=d6.allocUnsafe(Q),J=$.head,Y=1;J.data.copy(q),Q-=J.data.length;while(J=J.next){var V=J.data,X=Q>V.length?V.length:Q;if(V.copy(q,q.length-Q,0,X),Q-=X,Q===0){if(X===V.length)if(++Y,J.next)$.head=J.next;else $.head=$.tail=null;else $.head=J,J.data=V.slice(X);break}++Y}return $.length-=Y,q}function h5(Q){var $=Q._readableState;if($.length>0)throw Error('"endReadable()" called on non-empty stream');if(!$.endEmitted)$.ended=!0,Y6.nextTick(TK,$,Q)}function TK(Q,$){if(!Q.endEmitted&&Q.length===0)Q.endEmitted=!0,$.readable=!1,$.emit("end")}function Z4(Q,$){for(var q=0,J=Q.length;q<J;q++)if(Q[q]===$)return q;return-1}});var c5=w((dL,L4)=>{L4.exports=G1;var a8=b1(),F4=Object.create(Q6());F4.inherits=$6();F4.inherits(G1,a8);function AK(Q,$){var q=this._transformState;q.transforming=!1;var J=q.writecb;if(!J)return this.emit("error",Error("write callback called multiple times"));if(q.writechunk=null,q.writecb=null,$!=null)this.push($);J(Q);var Y=this._readableState;if(Y.reading=!1,Y.needReadable||Y.length<Y.highWaterMark)this._read(Y.highWaterMark)}function G1(Q){if(!(this instanceof G1))return new G1(Q);if(a8.call(this,Q),this._transformState={afterTransform:AK.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",DK)}function DK(){var Q=this;if(typeof this._flush==="function")this._flush(function($,q){H4(Q,$,q)});else H4(this,null,null)}G1.prototype.push=function(Q,$){return this._transformState.needTransform=!1,a8.prototype.push.call(this,Q,$)};G1.prototype._transform=function(Q,$,q){throw Error("_transform() is not implemented")};G1.prototype._write=function(Q,$,q){var J=this._transformState;if(J.writecb=q,J.writechunk=Q,J.writeencoding=$,!J.transforming){var Y=this._readableState;if(J.needTransform||Y.needReadable||Y.length<Y.highWaterMark)this._read(Y.highWaterMark)}};G1.prototype._read=function(Q){var $=this._transformState;if($.writechunk!==null&&$.writecb&&!$.transforming)$.transforming=!0,this._transform($.writechunk,$.writeencoding,$.afterTransform);else $.needTransform=!0};G1.prototype._destroy=function(Q,$){var q=this;a8.prototype._destroy.call(this,Q,function(J){$(J),q.emit("close")})};function H4(Q,$,q){if($)return Q.emit("error",$);if(q!=null)Q.push(q);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 M4=w((lL,B4)=>{B4.exports=l6;var O4=c5(),N4=Object.create(Q6());N4.inherits=$6();N4.inherits(l6,O4);function l6(Q){if(!(this instanceof l6))return new l6(Q);O4.call(this,Q)}l6.prototype._transform=function(Q,$,q){q(null,Q)}});var u5=w((J0,s8)=>{var l0=_("stream");if(process.env.READABLE_STREAM==="disable"&&l0)s8.exports=l0,J0=s8.exports=l0.Readable,J0.Readable=l0.Readable,J0.Writable=l0.Writable,J0.Duplex=l0.Duplex,J0.Transform=l0.Transform,J0.PassThrough=l0.PassThrough,J0.Stream=l0;else J0=s8.exports=S5(),J0.Stream=l0||J0,J0.Readable=J0,J0.Writable=x5(),J0.Duplex=b1(),J0.Transform=c5(),J0.PassThrough=M4()});var W1=w((RK)=>{RK.base64=!0;RK.array=!0;RK.string=!0;RK.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u";RK.nodebuffer=typeof Buffer<"u";RK.uint8array=typeof Uint8Array<"u";if(typeof ArrayBuffer>"u")RK.blob=!1;else{t8=new ArrayBuffer(0);try{RK.blob=new Blob([t8],{type:"application/zip"}).size===0}catch(Q){try{d5=self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder,e8=new d5,e8.append(t8),RK.blob=e8.getBlob("application/zip").size===0}catch($){RK.blob=!1}}}var t8,d5,e8;try{RK.nodestream=!!u5().Readable}catch(Q){RK.nodestream=!1}});var l5=w((bK)=>{var gK=l(),_K=W1(),o0="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";bK.encode=function(Q){var $=[],q,J,Y,V,X,K,W,G=0,U=Q.length,z=U,Z=gK.getTypeOf(Q)!=="string";while(G<Q.length){if(z=U-G,!Z)q=Q.charCodeAt(G++),J=G<U?Q.charCodeAt(G++):0,Y=G<U?Q.charCodeAt(G++):0;else q=Q[G++],J=G<U?Q[G++]:0,Y=G<U?Q[G++]:0;V=q>>2,X=(q&3)<<4|J>>4,K=z>1?(J&15)<<2|Y>>6:64,W=z>2?Y&63:64,$.push(o0.charAt(V)+o0.charAt(X)+o0.charAt(K)+o0.charAt(W))}return $.join("")};bK.decode=function(Q){var $,q,J,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)===o0.charAt(64))z--;if(Q.charAt(Q.length-2)===o0.charAt(64))z--;if(z%1!==0)throw Error("Invalid base64 input, bad content length.");var Z;if(_K.uint8array)Z=new Uint8Array(z|0);else Z=Array(z|0);while(W<Q.length){if(Y=o0.indexOf(Q.charAt(W++)),V=o0.indexOf(Q.charAt(W++)),X=o0.indexOf(Q.charAt(W++)),K=o0.indexOf(Q.charAt(W++)),$=Y<<2|V>>4,q=(V&15)<<4|X>>2,J=(X&3)<<6|K,Z[G++]=$,X!==64)Z[G++]=q;if(K!==64)Z[G++]=J}return Z}});var o6=w((nL,P4)=>{P4.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 T4=w((aL,C4)=>{var rL=global.MutationObserver||global.WebKitMutationObserver,I4;I4=function(){process.nextTick(dK)};var mK,cK,uK,pK,o5,i6=[];function dK(){o5=!0;var Q,$,q=i6.length;while(q){$=i6,i6=[],Q=-1;while(++Q<q)$[Q]();q=i6.length}o5=!1}C4.exports=lK;function lK(Q){if(i6.push(Q)===1&&!o5)I4()}});var S4=w((sL,v4)=>{var A4=T4();function X6(){}var K0={},D4=["REJECTED"],i5=["FULFILLED"],w4=["PENDING"];V6=["UNHANDLED"];var V6;v4.exports=N1;function N1(Q){if(typeof Q!=="function")throw TypeError("resolver must be a function");if(this.state=w4,this.queue=[],this.outcome=void 0,this.handled=V6,Q!==X6)R4(this,Q)}N1.prototype.finally=function(Q){if(typeof Q!=="function")return this;var $=this.constructor;return this.then(q,J);function q(Y){function V(){return Y}return $.resolve(Q()).then(V)}function J(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===i5||typeof $!=="function"&&this.state===D4)return this;var q=new this.constructor(X6);if(this.handled===V6)this.handled=null;if(this.state!==w4){var J=this.state===i5?Q:$;n5(q,J,this.outcome)}else this.queue.push(new n6(q,Q,$));return q};function n6(Q,$,q){if(this.promise=Q,typeof $==="function")this.onFulfilled=$,this.callFulfilled=this.otherCallFulfilled;if(typeof q==="function")this.onRejected=q,this.callRejected=this.otherCallRejected}n6.prototype.callFulfilled=function(Q){K0.resolve(this.promise,Q)};n6.prototype.otherCallFulfilled=function(Q){n5(this.promise,this.onFulfilled,Q)};n6.prototype.callRejected=function(Q){K0.reject(this.promise,Q)};n6.prototype.otherCallRejected=function(Q){n5(this.promise,this.onRejected,Q)};function n5(Q,$,q){A4(function(){var J;try{J=$(q)}catch(Y){return K0.reject(Q,Y)}if(J===Q)K0.reject(Q,TypeError("Cannot resolve promise with itself"));else K0.resolve(Q,J)})}K0.resolve=function(Q,$){var q=x4(oK,$);if(q.status==="error")return K0.reject(Q,q.value);var J=q.value;if(J)R4(Q,J);else{Q.state=i5,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=D4,Q.outcome=$,Q.handled===V6)A4(function(){if(Q.handled===V6)process.emit("unhandledRejection",$,Q)});var q=-1,J=Q.queue.length;while(++q<J)Q.queue[q].callRejected($);return Q};function oK(Q){var $=Q&&Q.then;if(Q&&(typeof Q==="object"||typeof Q==="function")&&typeof $==="function")return function(){$.apply(Q,arguments)}}function R4(Q,$){var q=!1;function J(K){if(q)return;q=!0,K0.reject(Q,K)}function Y(K){if(q)return;q=!0,K0.resolve(Q,K)}function V(){$(Y,J)}var X=x4(V);if(X.status==="error")J(X.value)}function x4(Q,$){var q={};try{q.value=Q($),q.status="success"}catch(J){q.status="error",q.value=J}return q}N1.resolve=iK;function iK(Q){if(Q instanceof this)return Q;return K0.resolve(new this(X6),Q)}N1.reject=nK;function nK(Q){var $=new this(X6);return K0.reject($,Q)}N1.all=rK;function rK(Q){var $=this;if(Object.prototype.toString.call(Q)!=="[object Array]")return this.reject(TypeError("must be an array"));var q=Q.length,J=!1;if(!q)return this.resolve([]);var Y=Array(q),V=0,X=-1,K=new this(X6);while(++X<q)W(Q[X],X);return K;function W(G,U){$.resolve(G).then(z,function(Z){if(!J)J=!0,K0.reject(K,Z)});function z(Z){if(Y[U]=Z,++V===q&&!J)J=!0,K0.resolve(K,Y)}}}N1.race=aK;function aK(Q){var $=this;if(Object.prototype.toString.call(Q)!=="[object Array]")return this.reject(TypeError("must be an array"));var q=Q.length,J=!1;if(!q)return this.resolve([]);var Y=-1,V=new this(X6);while(++Y<q)X(Q[Y]);return V;function X(K){$.resolve(K).then(function(W){if(!J)J=!0,K0.resolve(V,W)},function(W){if(!J)J=!0,K0.reject(V,W)})}}});var K6=w((tL,E4)=>{var r5=null;if(typeof Promise<"u")r5=Promise;else r5=S4();E4.exports={Promise:r5}});var y4=w((k4)=>{(function(Q,$){if(Q.setImmediate)return;var q=1,J={},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 J[q]=O,X(q),q++}function W(L){delete J[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=J[L];if(A){Y=!0;try{G(A)}finally{W(L),Y=!1}}}}function z(){X=function(L){process.nextTick(function(){U(L)})}}function Z(){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 C(){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(Z())H();else if(Q.MessageChannel)F();else if(V&&"onreadystatechange"in V.createElement("script"))N();else C();P.setImmediate=K,P.clearImmediate=W})(typeof self>"u"?typeof global>"u"?k4:global:self)});var l=w((eK)=>{var B1=W1(),sK=l5(),G6=o6(),a5=K6();y4();function tK(Q){var $=null;if(B1.uint8array)$=new Uint8Array(Q.length);else $=Array(Q.length);return $2(Q,$)}eK.newBlob=function(Q,$){eK.checkSupport("blob");try{return new Blob([Q],{type:$})}catch(Y){try{var q=self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder,J=new q;return J.append(Q),J.getBlob($)}catch(V){throw Error("Bug : can't construct the Blob.")}}};function r6(Q){return Q}function $2(Q,$){for(var q=0;q<Q.length;++q)$[q]=Q.charCodeAt(q)&255;return $}var Q2={stringifyByChunk:function(Q,$,q){var J=[],Y=0,V=Q.length;if(V<=q)return String.fromCharCode.apply(null,Q);while(Y<V){if($==="array"||$==="nodebuffer")J.push(String.fromCharCode.apply(null,Q.slice(Y,Math.min(Y+q,V))));else J.push(String.fromCharCode.apply(null,Q.subarray(Y,Math.min(Y+q,V))));Y+=q}return J.join("")},stringifyByChar:function(Q){var $="";for(var q=0;q<Q.length;q++)$+=String.fromCharCode(Q[q]);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,G6.allocBuffer(1)).length===1}catch(Q){return!1}}()}};function a6(Q){var $=65536,q=eK.getTypeOf(Q),J=!0;if(q==="uint8array")J=Q2.applyCanBeUsed.uint8array;else if(q==="nodebuffer")J=Q2.applyCanBeUsed.nodebuffer;if(J)while($>1)try{return Q2.stringifyByChunk(Q,q,$)}catch(Y){$=Math.floor($/2)}return Q2.stringifyByChar(Q)}eK.applyFromCharCode=a6;function q2(Q,$){for(var q=0;q<Q.length;q++)$[q]=Q[q];return $}var M1={};M1.string={string:r6,array:function(Q){return $2(Q,Array(Q.length))},arraybuffer:function(Q){return M1.string.uint8array(Q).buffer},uint8array:function(Q){return $2(Q,new Uint8Array(Q.length))},nodebuffer:function(Q){return $2(Q,G6.allocBuffer(Q.length))}};M1.array={string:a6,array:r6,arraybuffer:function(Q){return new Uint8Array(Q).buffer},uint8array:function(Q){return new Uint8Array(Q)},nodebuffer:function(Q){return G6.newBufferFrom(Q)}};M1.arraybuffer={string:function(Q){return a6(new Uint8Array(Q))},array:function(Q){return q2(new Uint8Array(Q),Array(Q.byteLength))},arraybuffer:r6,uint8array:function(Q){return new Uint8Array(Q)},nodebuffer:function(Q){return G6.newBufferFrom(new Uint8Array(Q))}};M1.uint8array={string:a6,array:function(Q){return q2(Q,Array(Q.length))},arraybuffer:function(Q){return Q.buffer},uint8array:r6,nodebuffer:function(Q){return G6.newBufferFrom(Q)}};M1.nodebuffer={string:a6,array:function(Q){return q2(Q,Array(Q.length))},arraybuffer:function(Q){return M1.nodebuffer.uint8array(Q).buffer},uint8array:function(Q){return q2(Q,new Uint8Array(Q.length))},nodebuffer:r6};eK.transformTo=function(Q,$){if(!$)$="";if(!Q)return $;eK.checkSupport(Q);var q=eK.getTypeOf($),J=M1[q][Q]($);return J};eK.resolve=function(Q){var $=Q.split("/"),q=[];for(var J=0;J<$.length;J++){var Y=$[J];if(Y==="."||Y===""&&J!==0&&J!==$.length-1)continue;else if(Y==="..")q.pop();else q.push(Y)}return q.join("/")};eK.getTypeOf=function(Q){if(typeof Q==="string")return"string";if(Object.prototype.toString.call(Q)==="[object Array]")return"array";if(B1.nodebuffer&&G6.isBuffer(Q))return"nodebuffer";if(B1.uint8array&&Q instanceof Uint8Array)return"uint8array";if(B1.arraybuffer&&Q instanceof ArrayBuffer)return"arraybuffer"};eK.checkSupport=function(Q){var $=B1[Q.toLowerCase()];if(!$)throw Error(Q+" is not supported by this platform")};eK.MAX_VALUE_16BITS=65535;eK.MAX_VALUE_32BITS=-1;eK.pretty=function(Q){var $="",q,J;for(J=0;J<(Q||"").length;J++)q=Q.charCodeAt(J),$+="\\x"+(q<16?"0":"")+q.toString(16).toUpperCase();return $};eK.delay=function(Q,$,q){setImmediate(function(){Q.apply(q||null,$||[])})};eK.inherits=function(Q,$){var q=function(){};q.prototype=$.prototype,Q.prototype=new q};eK.extend=function(){var Q={},$,q;for($=0;$<arguments.length;$++)for(q in arguments[$])if(Object.prototype.hasOwnProperty.call(arguments[$],q)&&typeof Q[q]>"u")Q[q]=arguments[$][q];return Q};eK.prepareContent=function(Q,$,q,J,Y){var V=a5.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 a5.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=eK.getTypeOf(X);if(!K)return a5.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=eK.transformTo("uint8array",X);else if(K==="string"){if(Y)X=sK.decode(X);else if(q){if(J!==!0)X=tK(X)}}return X})}});var B0=w(($O,h4)=>{function b4(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}b4.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 q=0;q<this._listeners[Q].length;q++)this._listeners[Q][q].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(q){$.processChunk(q)}),Q.on("end",function(){$.end()}),Q.on("error",function(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 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}};h4.exports=b4});var U6=w((HG)=>{var W6=l(),h1=W1(),UG=o6(),J2=B0(),s6=Array(256);for(i0=0;i0<256;i0++)s6[i0]=i0>=252?6:i0>=248?5:i0>=240?4:i0>=224?3:i0>=192?2:1;var i0;s6[254]=s6[254]=1;var jG=function(Q){var $,q,J,Y,V,X=Q.length,K=0;for(Y=0;Y<X;Y++){if(q=Q.charCodeAt(Y),(q&64512)===55296&&Y+1<X){if(J=Q.charCodeAt(Y+1),(J&64512)===56320)q=65536+(q-55296<<10)+(J-56320),Y++}K+=q<128?1:q<2048?2:q<65536?3:4}if(h1.uint8array)$=new Uint8Array(K);else $=Array(K);for(V=0,Y=0;V<K;Y++){if(q=Q.charCodeAt(Y),(q&64512)===55296&&Y+1<X){if(J=Q.charCodeAt(Y+1),(J&64512)===56320)q=65536+(q-55296<<10)+(J-56320),Y++}if(q<128)$[V++]=q;else if(q<2048)$[V++]=192|q>>>6,$[V++]=128|q&63;else if(q<65536)$[V++]=224|q>>>12,$[V++]=128|q>>>6&63,$[V++]=128|q&63;else $[V++]=240|q>>>18,$[V++]=128|q>>>12&63,$[V++]=128|q>>>6&63,$[V++]=128|q&63}return $},ZG=function(Q,$){var q;if($=$||Q.length,$>Q.length)$=Q.length;q=$-1;while(q>=0&&(Q[q]&192)===128)q--;if(q<0)return $;if(q===0)return $;return q+s6[Q[q]]>$?q:$},zG=function(Q){var $,q,J,Y,V=Q.length,X=Array(V*2);for(q=0,$=0;$<V;){if(J=Q[$++],J<128){X[q++]=J;continue}if(Y=s6[J],Y>4){X[q++]=65533,$+=Y-1;continue}J&=Y===2?31:Y===3?15:7;while(Y>1&&$<V)J=J<<6|Q[$++]&63,Y--;if(Y>1){X[q++]=65533;continue}if(J<65536)X[q++]=J;else J-=65536,X[q++]=55296|J>>10&1023,X[q++]=56320|J&1023}if(X.length!==q)if(X.subarray)X=X.subarray(0,q);else X.length=q;return W6.applyFromCharCode(X)};HG.utf8encode=function($){if(h1.nodebuffer)return UG.newBufferFrom($,"utf-8");return jG($)};HG.utf8decode=function($){if(h1.nodebuffer)return W6.transformTo("nodebuffer",$).toString("utf-8");return $=W6.transformTo(h1.uint8array?"uint8array":"array",$),zG($)};function Y2(){J2.call(this,"utf-8 decode"),this.leftOver=null}W6.inherits(Y2,J2);Y2.prototype.processChunk=function(Q){var $=W6.transformTo(h1.uint8array?"uint8array":"array",Q.data);if(this.leftOver&&this.leftOver.length){if(h1.uint8array){var q=$;$=new Uint8Array(q.length+this.leftOver.length),$.set(this.leftOver,0),$.set(q,this.leftOver.length)}else $=this.leftOver.concat($);this.leftOver=null}var J=ZG($),Y=$;if(J!==$.length)if(h1.uint8array)Y=$.subarray(0,J),this.leftOver=$.subarray(J,$.length);else Y=$.slice(0,J),this.leftOver=$.slice(J,$.length);this.push({data:HG.utf8decode(Y),meta:Q.meta})};Y2.prototype.flush=function(){if(this.leftOver&&this.leftOver.length)this.push({data:HG.utf8decode(this.leftOver),meta:{}}),this.leftOver=null};HG.Utf8DecodeWorker=Y2;function t5(){J2.call(this,"utf-8 encode")}W6.inherits(t5,J2);t5.prototype.processChunk=function(Q){this.push({data:HG.utf8encode(Q.data),meta:Q.meta})};HG.Utf8EncodeWorker=t5});var p4=w((JO,u4)=>{var m4=B0(),c4=l();function Q9(Q){m4.call(this,"ConvertWorker to "+Q),this.destType=Q}c4.inherits(Q9,m4);Q9.prototype.processChunk=function(Q){this.push({data:c4.transformTo(this.destType,Q.data),meta:Q.meta})};u4.exports=Q9});var o4=w((YO,l4)=>{var d4=u5().Readable,OG=l();OG.inherits($9,d4);function $9(Q,$,q){d4.call(this,$),this._helper=Q;var J=this;Q.on("data",function(Y,V){if(!J.push(Y))J._helper.pause();if(q)q(V)}).on("error",function(Y){J.emit("error",Y)}).on("end",function(){J.push(null)})}$9.prototype._read=function(){this._helper.resume()};l4.exports=$9});var q9=w((VO,r4)=>{var f1=l(),NG=p4(),BG=B0(),MG=l5(),PG=W1(),IG=K6(),i4=null;if(PG.nodestream)try{i4=o4()}catch(Q){}function CG(Q,$,q){switch(Q){case"blob":return f1.newBlob(f1.transformTo("arraybuffer",$),q);case"base64":return MG.encode($);default:return f1.transformTo(Q,$)}}function TG(Q,$){var q,J=0,Y=null,V=0;for(q=0;q<$.length;q++)V+=$[q].length;switch(Q){case"string":return $.join("");case"array":return Array.prototype.concat.apply([],$);case"uint8array":Y=new Uint8Array(V);for(q=0;q<$.length;q++)Y.set($[q],J),J+=$[q].length;return Y;case"nodebuffer":return Buffer.concat($);default:throw Error("concat : unsupported type '"+Q+"'")}}function AG(Q,$){return new IG.Promise(function(q,J){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=[],J(W)}).on("end",function(){try{var W=CG(X,TG(V,Y),K);q(W)}catch(G){J(G)}Y=[]}).resume()})}function n4(Q,$,q){var J=$;switch($){case"blob":case"arraybuffer":J="uint8array";break;case"base64":J="string";break}try{this._internalType=J,this._outputType=$,this._mimeType=q,f1.checkSupport(J),this._worker=Q.pipe(new NG(J)),Q.lock()}catch(Y){this._worker=new BG("error"),this._worker.error(Y)}}n4.prototype={accumulate:function(Q){return AG(this,Q)},on:function(Q,$){var q=this;if(Q==="data")this._worker.on(Q,function(J){$.call(q,J.data,J.meta)});else this._worker.on(Q,function(){f1.delay($,arguments,q)});return this},resume:function(){return f1.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(Q){if(f1.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw Error(this._outputType+" is not supported by this method");return new i4(this,{objectMode:this._outputType!=="nodebuffer"},Q)}};r4.exports=n4});var J9=w((DG)=>{DG.base64=!1;DG.binary=!1;DG.dir=!1;DG.createFolders=!0;DG.date=null;DG.compression=null;DG.compressionOptions=null;DG.comment=null;DG.unixPermissions=null;DG.dosPermissions=null});var Y9=w((KO,a4)=>{var V2=l(),X2=B0(),bG=16384;function j6(Q){X2.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(q){if($.dataIsReady=!0,$.data=q,$.max=q&&q.length||0,$.type=V2.getTypeOf(q),!$.isPaused)$._tickAndRepeat()},function(q){$.error(q)})}V2.inherits(j6,X2);j6.prototype.cleanUp=function(){X2.prototype.cleanUp.call(this),this.data=null};j6.prototype.resume=function(){if(!X2.prototype.resume.call(this))return!1;if(!this._tickScheduled&&this.dataIsReady)this._tickScheduled=!0,V2.delay(this._tickAndRepeat,[],this);return!0};j6.prototype._tickAndRepeat=function(){if(this._tickScheduled=!1,this.isPaused||this.isFinished)return;if(this._tick(),!this.isFinished)V2.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0};j6.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var Q=bG,$=null,q=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,q);break;case"uint8array":$=this.data.subarray(this.index,q);break;case"array":case"nodebuffer":$=this.data.slice(this.index,q);break}return this.index=q,this.push({data:$,meta:{percent:this.max?this.index/this.max*100:0}})}};a4.exports=j6});var K2=w((GO,t4)=>{var hG=l();function fG(){var Q,$=[];for(var q=0;q<256;q++){Q=q;for(var J=0;J<8;J++)Q=Q&1?3988292384^Q>>>1:Q>>>1;$[q]=Q}return $}var s4=fG();function mG(Q,$,q,J){var Y=s4,V=J+q;Q=Q^-1;for(var X=J;X<V;X++)Q=Q>>>8^Y[(Q^$[X])&255];return Q^-1}function cG(Q,$,q,J){var Y=s4,V=J+q;Q=Q^-1;for(var X=J;X<V;X++)Q=Q>>>8^Y[(Q^$.charCodeAt(X))&255];return Q^-1}t4.exports=function($,q){if(typeof $>"u"||!$.length)return 0;var J=hG.getTypeOf($)!=="string";if(J)return mG(q|0,$,$.length,0);else return cG(q|0,$,$.length,0)}});var X9=w((WO,Q$)=>{var e4=B0(),uG=K2(),pG=l();function V9(){e4.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}pG.inherits(V9,e4);V9.prototype.processChunk=function(Q){this.streamInfo.crc32=uG(Q.data,this.streamInfo.crc32||0),this.push(Q)};Q$.exports=V9});var q$=w((UO,$$)=>{var dG=l(),K9=B0();function G9(Q){K9.call(this,"DataLengthProbe for "+Q),this.propName=Q,this.withStreamInfo(Q,0)}dG.inherits(G9,K9);G9.prototype.processChunk=function(Q){if(Q){var $=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=$+Q.data.length}K9.prototype.processChunk.call(this,Q)};$$.exports=G9});var G2=w((jO,V$)=>{var J$=K6(),Y$=Y9(),lG=X9(),W9=q$();function U9(Q,$,q,J,Y){this.compressedSize=Q,this.uncompressedSize=$,this.crc32=q,this.compression=J,this.compressedContent=Y}U9.prototype={getContentWorker:function(){var Q=new Y$(J$.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new W9("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 Y$(J$.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}};U9.createWorkerFrom=function(Q,$,q){return Q.pipe(new lG).pipe(new W9("uncompressedSize")).pipe($.compressWorker(q)).pipe(new W9("compressedSize")).withStreamInfo("compression",$)};V$.exports=U9});var W$=w((ZO,G$)=>{var oG=q9(),iG=Y9(),j9=U6(),Z9=G2(),X$=B0(),z9=function(Q,$,q){this.name=Q,this.dir=q.dir,this.date=q.date,this.comment=q.comment,this.unixPermissions=q.unixPermissions,this.dosPermissions=q.dosPermissions,this._data=$,this._dataBinary=q.binary,this.options={compression:q.compression,compressionOptions:q.compressionOptions}};z9.prototype={internalStream:function(Q){var $=null,q="string";try{if(!Q)throw Error("No output type specified.");q=Q.toLowerCase();var J=q==="string"||q==="text";if(q==="binarystring"||q==="text")q="string";$=this._decompressWorker();var Y=!this._dataBinary;if(Y&&!J)$=$.pipe(new j9.Utf8EncodeWorker);if(!Y&&J)$=$.pipe(new j9.Utf8DecodeWorker)}catch(V){$=new X$("error"),$.error(V)}return new oG($,q,"")},async:function(Q,$){return this.internalStream(Q).accumulate($)},nodeStream:function(Q,$){return this.internalStream(Q||"nodebuffer").toNodejsStream($)},_compressWorker:function(Q,$){if(this._data instanceof Z9&&this._data.compression.magic===Q.magic)return this._data.getCompressedWorker();else{var q=this._decompressWorker();if(!this._dataBinary)q=q.pipe(new j9.Utf8EncodeWorker);return Z9.createWorkerFrom(q,Q,$)}},_decompressWorker:function(){if(this._data instanceof Z9)return this._data.getContentWorker();else if(this._data instanceof X$)return this._data;else return new iG(this._data)}};var K$=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],nG=function(){throw Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")};for(t6=0;t6<K$.length;t6++)z9.prototype[K$[t6]]=nG;var t6;G$.exports=z9});var U1=w((H9)=>{var tG=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";function eG(Q,$){return Object.prototype.hasOwnProperty.call(Q,$)}H9.assign=function(Q){var $=Array.prototype.slice.call(arguments,1);while($.length){var q=$.shift();if(!q)continue;if(typeof q!=="object")throw TypeError(q+"must be non-object");for(var J in q)if(eG(q,J))Q[J]=q[J]}return Q};H9.shrinkBuf=function(Q,$){if(Q.length===$)return Q;if(Q.subarray)return Q.subarray(0,$);return Q.length=$,Q};var QW={arraySet:function(Q,$,q,J,Y){if($.subarray&&Q.subarray){Q.set($.subarray(q,q+J),Y);return}for(var V=0;V<J;V++)Q[Y+V]=$[q+V]},flattenChunks:function(Q){var $,q,J,Y,V,X;J=0;for($=0,q=Q.length;$<q;$++)J+=Q[$].length;X=new Uint8Array(J),Y=0;for($=0,q=Q.length;$<q;$++)V=Q[$],X.set(V,Y),Y+=V.length;return X}},$W={arraySet:function(Q,$,q,J,Y){for(var V=0;V<J;V++)Q[Y+V]=$[q+V]},flattenChunks:function(Q){return[].concat.apply([],Q)}};H9.setTyped=function(Q){if(Q)H9.Buf8=Uint8Array,H9.Buf16=Uint16Array,H9.Buf32=Int32Array,H9.assign(H9,QW);else H9.Buf8=Array,H9.Buf16=Array,H9.Buf32=Array,H9.assign(H9,$W)};H9.setTyped(tG)});var k$=w((TW)=>{var JW=U1(),YW=4,j$=0,Z$=1,VW=2;function z6(Q){var $=Q.length;while(--$>=0)Q[$]=0}var XW=0,N$=1,KW=2,GW=3,WW=258,I9=29,Y8=256,Q8=Y8+1+I9,Z6=30,C9=19,B$=2*Q8+1,m1=15,L9=16,UW=7,T9=256,M$=16,P$=17,I$=18,M9=[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],W2=[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],jW=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],C$=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],ZW=512,j1=Array((Q8+2)*2);z6(j1);var e6=Array(Z6*2);z6(e6);var $8=Array(ZW);z6($8);var q8=Array(WW-GW+1);z6(q8);var A9=Array(I9);z6(A9);var U2=Array(Z6);z6(U2);function O9(Q,$,q,J,Y){this.static_tree=Q,this.extra_bits=$,this.extra_base=q,this.elems=J,this.max_length=Y,this.has_stree=Q&&Q.length}var T$,A$,D$;function N9(Q,$){this.dyn_tree=Q,this.max_code=0,this.stat_desc=$}function w$(Q){return Q<256?$8[Q]:$8[256+(Q>>>7)]}function J8(Q,$){Q.pending_buf[Q.pending++]=$&255,Q.pending_buf[Q.pending++]=$>>>8&255}function F0(Q,$,q){if(Q.bi_valid>L9-q)Q.bi_buf|=$<<Q.bi_valid&65535,J8(Q,Q.bi_buf),Q.bi_buf=$>>L9-Q.bi_valid,Q.bi_valid+=q-L9;else Q.bi_buf|=$<<Q.bi_valid&65535,Q.bi_valid+=q}function n0(Q,$,q){F0(Q,q[$*2],q[$*2+1])}function R$(Q,$){var q=0;do q|=Q&1,Q>>>=1,q<<=1;while(--$>0);return q>>>1}function zW(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 HW(Q,$){var{dyn_tree:q,max_code:J}=$,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,Z,H,F,N=0;for(Z=0;Z<=m1;Z++)Q.bl_count[Z]=0;q[Q.heap[Q.heap_max]*2+1]=0;for(G=Q.heap_max+1;G<B$;G++){if(U=Q.heap[G],Z=q[q[U*2+1]*2+1]+1,Z>W)Z=W,N++;if(q[U*2+1]=Z,U>J)continue;if(Q.bl_count[Z]++,H=0,U>=K)H=X[U-K];if(F=q[U*2],Q.opt_len+=F*(Z+H),V)Q.static_len+=F*(Y[U*2+1]+H)}if(N===0)return;do{Z=W-1;while(Q.bl_count[Z]===0)Z--;Q.bl_count[Z]--,Q.bl_count[Z+1]+=2,Q.bl_count[W]--,N-=2}while(N>0);for(Z=W;Z!==0;Z--){U=Q.bl_count[Z];while(U!==0){if(z=Q.heap[--G],z>J)continue;if(q[z*2+1]!==Z)Q.opt_len+=(Z-q[z*2+1])*q[z*2],q[z*2+1]=Z;U--}}}function x$(Q,$,q){var J=Array(m1+1),Y=0,V,X;for(V=1;V<=m1;V++)J[V]=Y=Y+q[V-1]<<1;for(X=0;X<=$;X++){var K=Q[X*2+1];if(K===0)continue;Q[X*2]=R$(J[K]++,K)}}function FW(){var Q,$,q,J,Y,V=Array(m1+1);q=0;for(J=0;J<I9-1;J++){A9[J]=q;for(Q=0;Q<1<<M9[J];Q++)q8[q++]=J}q8[q-1]=J,Y=0;for(J=0;J<16;J++){U2[J]=Y;for(Q=0;Q<1<<W2[J];Q++)$8[Y++]=J}Y>>=7;for(;J<Z6;J++){U2[J]=Y<<7;for(Q=0;Q<1<<W2[J]-7;Q++)$8[256+Y++]=J}for($=0;$<=m1;$++)V[$]=0;Q=0;while(Q<=143)j1[Q*2+1]=8,Q++,V[8]++;while(Q<=255)j1[Q*2+1]=9,Q++,V[9]++;while(Q<=279)j1[Q*2+1]=7,Q++,V[7]++;while(Q<=287)j1[Q*2+1]=8,Q++,V[8]++;x$(j1,Q8+1,V);for(Q=0;Q<Z6;Q++)e6[Q*2+1]=5,e6[Q*2]=R$(Q,5);T$=new O9(j1,M9,Y8+1,Q8,m1),A$=new O9(e6,W2,0,Z6,m1),D$=new O9([],jW,0,C9,UW)}function v$(Q){var $;for($=0;$<Q8;$++)Q.dyn_ltree[$*2]=0;for($=0;$<Z6;$++)Q.dyn_dtree[$*2]=0;for($=0;$<C9;$++)Q.bl_tree[$*2]=0;Q.dyn_ltree[T9*2]=1,Q.opt_len=Q.static_len=0,Q.last_lit=Q.matches=0}function S$(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 LW(Q,$,q,J){if(S$(Q),J)J8(Q,q),J8(Q,~q);JW.arraySet(Q.pending_buf,Q.window,$,q,Q.pending),Q.pending+=q}function z$(Q,$,q,J){var Y=$*2,V=q*2;return Q[Y]<Q[V]||Q[Y]===Q[V]&&J[$]<=J[q]}function B9(Q,$,q){var J=Q.heap[q],Y=q<<1;while(Y<=Q.heap_len){if(Y<Q.heap_len&&z$($,Q.heap[Y+1],Q.heap[Y],Q.depth))Y++;if(z$($,J,Q.heap[Y],Q.depth))break;Q.heap[q]=Q.heap[Y],q=Y,Y<<=1}Q.heap[q]=J}function H$(Q,$,q){var J,Y,V=0,X,K;if(Q.last_lit!==0)do if(J=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++,J===0)n0(Q,Y,$);else{if(X=q8[Y],n0(Q,X+Y8+1,$),K=M9[X],K!==0)Y-=A9[X],F0(Q,Y,K);if(J--,X=w$(J),n0(Q,X,q),K=W2[X],K!==0)J-=U2[X],F0(Q,J,K)}while(V<Q.last_lit);n0(Q,T9,$)}function P9(Q,$){var q=$.dyn_tree,J=$.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=B$;for(X=0;X<V;X++)if(q[X*2]!==0)Q.heap[++Q.heap_len]=W=X,Q.depth[X]=0;else q[X*2+1]=0;while(Q.heap_len<2)if(G=Q.heap[++Q.heap_len]=W<2?++W:0,q[G*2]=1,Q.depth[G]=0,Q.opt_len--,Y)Q.static_len-=J[G*2+1];$.max_code=W;for(X=Q.heap_len>>1;X>=1;X--)B9(Q,q,X);G=V;do X=Q.heap[1],Q.heap[1]=Q.heap[Q.heap_len--],B9(Q,q,1),K=Q.heap[1],Q.heap[--Q.heap_max]=X,Q.heap[--Q.heap_max]=K,q[G*2]=q[X*2]+q[K*2],Q.depth[G]=(Q.depth[X]>=Q.depth[K]?Q.depth[X]:Q.depth[K])+1,q[X*2+1]=q[K*2+1]=G,Q.heap[1]=G++,B9(Q,q,1);while(Q.heap_len>=2);Q.heap[--Q.heap_max]=Q.heap[1],HW(Q,$),x$(q,W,Q.bl_count)}function F$(Q,$,q){var J,Y=-1,V,X=$[1],K=0,W=7,G=4;if(X===0)W=138,G=3;$[(q+1)*2+1]=65535;for(J=0;J<=q;J++){if(V=X,X=$[(J+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[M$*2]++}else if(K<=10)Q.bl_tree[P$*2]++;else Q.bl_tree[I$*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 L$(Q,$,q){var J,Y=-1,V,X=$[1],K=0,W=7,G=4;if(X===0)W=138,G=3;for(J=0;J<=q;J++){if(V=X,X=$[(J+1)*2+1],++K<W&&V===X)continue;else if(K<G)do n0(Q,V,Q.bl_tree);while(--K!==0);else if(V!==0){if(V!==Y)n0(Q,V,Q.bl_tree),K--;n0(Q,M$,Q.bl_tree),F0(Q,K-3,2)}else if(K<=10)n0(Q,P$,Q.bl_tree),F0(Q,K-3,3);else n0(Q,I$,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 OW(Q){var $;F$(Q,Q.dyn_ltree,Q.l_desc.max_code),F$(Q,Q.dyn_dtree,Q.d_desc.max_code),P9(Q,Q.bl_desc);for($=C9-1;$>=3;$--)if(Q.bl_tree[C$[$]*2+1]!==0)break;return Q.opt_len+=3*($+1)+5+5+4,$}function NW(Q,$,q,J){var Y;F0(Q,$-257,5),F0(Q,q-1,5),F0(Q,J-4,4);for(Y=0;Y<J;Y++)F0(Q,Q.bl_tree[C$[Y]*2+1],3);L$(Q,Q.dyn_ltree,$-1),L$(Q,Q.dyn_dtree,q-1)}function BW(Q){var $=4093624447,q;for(q=0;q<=31;q++,$>>>=1)if($&1&&Q.dyn_ltree[q*2]!==0)return j$;if(Q.dyn_ltree[18]!==0||Q.dyn_ltree[20]!==0||Q.dyn_ltree[26]!==0)return Z$;for(q=32;q<Y8;q++)if(Q.dyn_ltree[q*2]!==0)return Z$;return j$}var O$=!1;function MW(Q){if(!O$)FW(),O$=!0;Q.l_desc=new N9(Q.dyn_ltree,T$),Q.d_desc=new N9(Q.dyn_dtree,A$),Q.bl_desc=new N9(Q.bl_tree,D$),Q.bi_buf=0,Q.bi_valid=0,v$(Q)}function E$(Q,$,q,J){F0(Q,(XW<<1)+(J?1:0),3),LW(Q,$,q,!0)}function PW(Q){F0(Q,N$<<1,3),n0(Q,T9,j1),zW(Q)}function IW(Q,$,q,J){var Y,V,X=0;if(Q.level>0){if(Q.strm.data_type===VW)Q.strm.data_type=BW(Q);if(P9(Q,Q.l_desc),P9(Q,Q.d_desc),X=OW(Q),Y=Q.opt_len+3+7>>>3,V=Q.static_len+3+7>>>3,V<=Y)Y=V}else Y=V=q+5;if(q+4<=Y&&$!==-1)E$(Q,$,q,J);else if(Q.strategy===YW||V===Y)F0(Q,(N$<<1)+(J?1:0),3),H$(Q,j1,e6);else F0(Q,(KW<<1)+(J?1:0),3),NW(Q,Q.l_desc.max_code+1,Q.d_desc.max_code+1,X+1),H$(Q,Q.dyn_ltree,Q.dyn_dtree);if(v$(Q),J)S$(Q)}function CW(Q,$,q){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]=q&255,Q.last_lit++,$===0)Q.dyn_ltree[q*2]++;else Q.matches++,$--,Q.dyn_ltree[(q8[q]+Y8+1)*2]++,Q.dyn_dtree[w$($)*2]++;return Q.last_lit===Q.lit_bufsize-1}TW._tr_init=MW;TW._tr_stored_block=E$;TW._tr_flush_block=IW;TW._tr_tally=CW;TW._tr_align=PW});var D9=w((FO,y$)=>{function vW(Q,$,q,J){var Y=Q&65535|0,V=Q>>>16&65535|0,X=0;while(q!==0){X=q>2000?2000:q,q-=X;do Y=Y+$[J++]|0,V=V+Y|0;while(--X);Y%=65521,V%=65521}return Y|V<<16|0}y$.exports=vW});var w9=w((LO,g$)=>{function SW(){var Q,$=[];for(var q=0;q<256;q++){Q=q;for(var J=0;J<8;J++)Q=Q&1?3988292384^Q>>>1:Q>>>1;$[q]=Q}return $}var EW=SW();function kW(Q,$,q,J){var Y=EW,V=J+q;Q^=-1;for(var X=J;X<V;X++)Q=Q>>>8^Y[(Q^$[X])&255];return Q^-1}g$.exports=kW});var j2=w((OO,_$)=>{_$.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 l$=w((ZU)=>{var j0=U1(),R0=k$(),m$=D9(),P1=w9(),yW=j2(),d1=0,gW=1,_W=3,D1=4,b$=5,a0=0,h$=1,x0=-2,bW=-3,R9=-5,hW=-1,fW=1,Z2=2,mW=3,cW=4,uW=0,pW=2,L2=8,dW=9,lW=15,oW=8,iW=29,nW=256,v9=nW+1+iW,rW=30,aW=19,sW=2*v9+1,tW=15,S=3,T1=258,h0=T1+S+1,eW=32,O2=42,S9=69,z2=73,H2=91,F2=103,c1=113,X8=666,t=1,K8=2,u1=3,L6=4,QU=3;function A1(Q,$){return Q.msg=yW[$],$}function f$(Q){return(Q<<1)-(Q>4?9:0)}function C1(Q){var $=Q.length;while(--$>=0)Q[$]=0}function I1(Q){var $=Q.state,q=$.pending;if(q>Q.avail_out)q=Q.avail_out;if(q===0)return;if(j0.arraySet(Q.output,$.pending_buf,$.pending_out,q,Q.next_out),Q.next_out+=q,$.pending_out+=q,Q.total_out+=q,Q.avail_out-=q,$.pending-=q,$.pending===0)$.pending_out=0}function Y0(Q,$){R0._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 V8(Q,$){Q.pending_buf[Q.pending++]=$>>>8&255,Q.pending_buf[Q.pending++]=$&255}function $U(Q,$,q,J){var Y=Q.avail_in;if(Y>J)Y=J;if(Y===0)return 0;if(Q.avail_in-=Y,j0.arraySet($,Q.input,Q.next_in,Y,q),Q.state.wrap===1)Q.adler=m$(Q.adler,$,Y,q);else if(Q.state.wrap===2)Q.adler=P1(Q.adler,$,Y,q);return Q.next_in+=Y,Q.total_in+=Y,Y}function c$(Q,$){var{max_chain_length:q,strstart:J}=Q,Y,V,X=Q.prev_length,K=Q.nice_match,W=Q.strstart>Q.w_size-h0?Q.strstart-(Q.w_size-h0):0,G=Q.window,U=Q.w_mask,z=Q.prev,Z=Q.strstart+T1,H=G[J+X-1],F=G[J+X];if(Q.prev_length>=Q.good_match)q>>=2;if(K>Q.lookahead)K=Q.lookahead;do{if(Y=$,G[Y+X]!==F||G[Y+X-1]!==H||G[Y]!==G[J]||G[++Y]!==G[J+1])continue;J+=2,Y++;do;while(G[++J]===G[++Y]&&G[++J]===G[++Y]&&G[++J]===G[++Y]&&G[++J]===G[++Y]&&G[++J]===G[++Y]&&G[++J]===G[++Y]&&G[++J]===G[++Y]&&G[++J]===G[++Y]&&J<Z);if(V=T1-(Z-J),J=Z-T1,V>X){if(Q.match_start=$,X=V,V>=K)break;H=G[J+X-1],F=G[J+X]}}while(($=z[$&U])>W&&--q!==0);if(X<=Q.lookahead)return X;return Q.lookahead}function p1(Q){var $=Q.w_size,q,J,Y,V,X;do{if(V=Q.window_size-Q.lookahead-Q.strstart,Q.strstart>=$+($-h0)){j0.arraySet(Q.window,Q.window,$,$,0),Q.match_start-=$,Q.strstart-=$,Q.block_start-=$,J=Q.hash_size,q=J;do Y=Q.head[--q],Q.head[q]=Y>=$?Y-$:0;while(--J);J=$,q=J;do Y=Q.prev[--q],Q.prev[q]=Y>=$?Y-$:0;while(--J);V+=$}if(Q.strm.avail_in===0)break;if(J=$U(Q.strm,Q.window,Q.strstart+Q.lookahead,V),Q.lookahead+=J,Q.lookahead+Q.insert>=S){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+S-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<S)break}}while(Q.lookahead<h0&&Q.strm.avail_in!==0)}function qU(Q,$){var q=65535;if(q>Q.pending_buf_size-5)q=Q.pending_buf_size-5;for(;;){if(Q.lookahead<=1){if(p1(Q),Q.lookahead===0&&$===d1)return t;if(Q.lookahead===0)break}Q.strstart+=Q.lookahead,Q.lookahead=0;var J=Q.block_start+q;if(Q.strstart===0||Q.strstart>=J){if(Q.lookahead=Q.strstart-J,Q.strstart=J,Y0(Q,!1),Q.strm.avail_out===0)return t}if(Q.strstart-Q.block_start>=Q.w_size-h0){if(Y0(Q,!1),Q.strm.avail_out===0)return t}}if(Q.insert=0,$===D1){if(Y0(Q,!0),Q.strm.avail_out===0)return u1;return L6}if(Q.strstart>Q.block_start){if(Y0(Q,!1),Q.strm.avail_out===0)return t}return t}function x9(Q,$){var q,J;for(;;){if(Q.lookahead<h0){if(p1(Q),Q.lookahead<h0&&$===d1)return t;if(Q.lookahead===0)break}if(q=0,Q.lookahead>=S)Q.ins_h=(Q.ins_h<<Q.hash_shift^Q.window[Q.strstart+S-1])&Q.hash_mask,q=Q.prev[Q.strstart&Q.w_mask]=Q.head[Q.ins_h],Q.head[Q.ins_h]=Q.strstart;if(q!==0&&Q.strstart-q<=Q.w_size-h0)Q.match_length=c$(Q,q);if(Q.match_length>=S)if(J=R0._tr_tally(Q,Q.strstart-Q.match_start,Q.match_length-S),Q.lookahead-=Q.match_length,Q.match_length<=Q.max_lazy_match&&Q.lookahead>=S){Q.match_length--;do Q.strstart++,Q.ins_h=(Q.ins_h<<Q.hash_shift^Q.window[Q.strstart+S-1])&Q.hash_mask,q=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 J=R0._tr_tally(Q,0,Q.window[Q.strstart]),Q.lookahead--,Q.strstart++;if(J){if(Y0(Q,!1),Q.strm.avail_out===0)return t}}if(Q.insert=Q.strstart<S-1?Q.strstart:S-1,$===D1){if(Y0(Q,!0),Q.strm.avail_out===0)return u1;return L6}if(Q.last_lit){if(Y0(Q,!1),Q.strm.avail_out===0)return t}return K8}function H6(Q,$){var q,J,Y;for(;;){if(Q.lookahead<h0){if(p1(Q),Q.lookahead<h0&&$===d1)return t;if(Q.lookahead===0)break}if(q=0,Q.lookahead>=S)Q.ins_h=(Q.ins_h<<Q.hash_shift^Q.window[Q.strstart+S-1])&Q.hash_mask,q=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=S-1,q!==0&&Q.prev_length<Q.max_lazy_match&&Q.strstart-q<=Q.w_size-h0){if(Q.match_length=c$(Q,q),Q.match_length<=5&&(Q.strategy===fW||Q.match_length===S&&Q.strstart-Q.match_start>4096))Q.match_length=S-1}if(Q.prev_length>=S&&Q.match_length<=Q.prev_length){Y=Q.strstart+Q.lookahead-S,J=R0._tr_tally(Q,Q.strstart-1-Q.prev_match,Q.prev_length-S),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+S-1])&Q.hash_mask,q=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=S-1,Q.strstart++,J){if(Y0(Q,!1),Q.strm.avail_out===0)return t}}else if(Q.match_available){if(J=R0._tr_tally(Q,0,Q.window[Q.strstart-1]),J)Y0(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)J=R0._tr_tally(Q,0,Q.window[Q.strstart-1]),Q.match_available=0;if(Q.insert=Q.strstart<S-1?Q.strstart:S-1,$===D1){if(Y0(Q,!0),Q.strm.avail_out===0)return u1;return L6}if(Q.last_lit){if(Y0(Q,!1),Q.strm.avail_out===0)return t}return K8}function JU(Q,$){var q,J,Y,V,X=Q.window;for(;;){if(Q.lookahead<=T1){if(p1(Q),Q.lookahead<=T1&&$===d1)return t;if(Q.lookahead===0)break}if(Q.match_length=0,Q.lookahead>=S&&Q.strstart>0){if(Y=Q.strstart-1,J=X[Y],J===X[++Y]&&J===X[++Y]&&J===X[++Y]){V=Q.strstart+T1;do;while(J===X[++Y]&&J===X[++Y]&&J===X[++Y]&&J===X[++Y]&&J===X[++Y]&&J===X[++Y]&&J===X[++Y]&&J===X[++Y]&&Y<V);if(Q.match_length=T1-(V-Y),Q.match_length>Q.lookahead)Q.match_length=Q.lookahead}}if(Q.match_length>=S)q=R0._tr_tally(Q,1,Q.match_length-S),Q.lookahead-=Q.match_length,Q.strstart+=Q.match_length,Q.match_length=0;else q=R0._tr_tally(Q,0,Q.window[Q.strstart]),Q.lookahead--,Q.strstart++;if(q){if(Y0(Q,!1),Q.strm.avail_out===0)return t}}if(Q.insert=0,$===D1){if(Y0(Q,!0),Q.strm.avail_out===0)return u1;return L6}if(Q.last_lit){if(Y0(Q,!1),Q.strm.avail_out===0)return t}return K8}function YU(Q,$){var q;for(;;){if(Q.lookahead===0){if(p1(Q),Q.lookahead===0){if($===d1)return t;break}}if(Q.match_length=0,q=R0._tr_tally(Q,0,Q.window[Q.strstart]),Q.lookahead--,Q.strstart++,q){if(Y0(Q,!1),Q.strm.avail_out===0)return t}}if(Q.insert=0,$===D1){if(Y0(Q,!0),Q.strm.avail_out===0)return u1;return L6}if(Q.last_lit){if(Y0(Q,!1),Q.strm.avail_out===0)return t}return K8}function r0(Q,$,q,J,Y){this.good_length=Q,this.max_lazy=$,this.nice_length=q,this.max_chain=J,this.func=Y}var F6;F6=[new r0(0,0,0,0,qU),new r0(4,4,8,4,x9),new r0(4,5,16,8,x9),new r0(4,6,32,32,x9),new r0(4,4,16,16,H6),new r0(8,16,32,32,H6),new r0(8,16,128,128,H6),new r0(8,32,128,256,H6),new r0(32,128,258,1024,H6),new r0(32,258,258,4096,H6)];function VU(Q){Q.window_size=2*Q.w_size,C1(Q.head),Q.max_lazy_match=F6[Q.level].max_lazy,Q.good_match=F6[Q.level].good_length,Q.nice_match=F6[Q.level].nice_length,Q.max_chain_length=F6[Q.level].max_chain,Q.strstart=0,Q.block_start=0,Q.lookahead=0,Q.insert=0,Q.match_length=Q.prev_length=S-1,Q.match_available=0,Q.ins_h=0}function XU(){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=L2,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 j0.Buf16(sW*2),this.dyn_dtree=new j0.Buf16((2*rW+1)*2),this.bl_tree=new j0.Buf16((2*aW+1)*2),C1(this.dyn_ltree),C1(this.dyn_dtree),C1(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new j0.Buf16(tW+1),this.heap=new j0.Buf16(2*v9+1),C1(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new j0.Buf16(2*v9+1),C1(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 u$(Q){var $;if(!Q||!Q.state)return A1(Q,x0);if(Q.total_in=Q.total_out=0,Q.data_type=pW,$=Q.state,$.pending=0,$.pending_out=0,$.wrap<0)$.wrap=-$.wrap;return $.status=$.wrap?O2:c1,Q.adler=$.wrap===2?0:1,$.last_flush=d1,R0._tr_init($),a0}function p$(Q){var $=u$(Q);if($===a0)VU(Q.state);return $}function KU(Q,$){if(!Q||!Q.state)return x0;if(Q.state.wrap!==2)return x0;return Q.state.gzhead=$,a0}function d$(Q,$,q,J,Y,V){if(!Q)return x0;var X=1;if($===hW)$=6;if(J<0)X=0,J=-J;else if(J>15)X=2,J-=16;if(Y<1||Y>dW||q!==L2||J<8||J>15||$<0||$>9||V<0||V>cW)return A1(Q,x0);if(J===8)J=9;var K=new XU;return Q.state=K,K.strm=Q,K.wrap=X,K.gzhead=null,K.w_bits=J,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+S-1)/S),K.window=new j0.Buf8(K.w_size*2),K.head=new j0.Buf16(K.hash_size),K.prev=new j0.Buf16(K.w_size),K.lit_bufsize=1<<Y+6,K.pending_buf_size=K.lit_bufsize*4,K.pending_buf=new j0.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=q,p$(Q)}function GU(Q,$){return d$(Q,$,L2,lW,oW,uW)}function WU(Q,$){var q,J,Y,V;if(!Q||!Q.state||$>b$||$<0)return Q?A1(Q,x0):x0;if(J=Q.state,!Q.output||!Q.input&&Q.avail_in!==0||J.status===X8&&$!==D1)return A1(Q,Q.avail_out===0?R9:x0);if(J.strm=Q,q=J.last_flush,J.last_flush=$,J.status===O2)if(J.wrap===2)if(Q.adler=0,k(J,31),k(J,139),k(J,8),!J.gzhead)k(J,0),k(J,0),k(J,0),k(J,0),k(J,0),k(J,J.level===9?2:J.strategy>=Z2||J.level<2?4:0),k(J,QU),J.status=c1;else{if(k(J,(J.gzhead.text?1:0)+(J.gzhead.hcrc?2:0)+(!J.gzhead.extra?0:4)+(!J.gzhead.name?0:8)+(!J.gzhead.comment?0:16)),k(J,J.gzhead.time&255),k(J,J.gzhead.time>>8&255),k(J,J.gzhead.time>>16&255),k(J,J.gzhead.time>>24&255),k(J,J.level===9?2:J.strategy>=Z2||J.level<2?4:0),k(J,J.gzhead.os&255),J.gzhead.extra&&J.gzhead.extra.length)k(J,J.gzhead.extra.length&255),k(J,J.gzhead.extra.length>>8&255);if(J.gzhead.hcrc)Q.adler=P1(Q.adler,J.pending_buf,J.pending,0);J.gzindex=0,J.status=S9}else{var X=L2+(J.w_bits-8<<4)<<8,K=-1;if(J.strategy>=Z2||J.level<2)K=0;else if(J.level<6)K=1;else if(J.level===6)K=2;else K=3;if(X|=K<<6,J.strstart!==0)X|=eW;if(X+=31-X%31,J.status=c1,V8(J,X),J.strstart!==0)V8(J,Q.adler>>>16),V8(J,Q.adler&65535);Q.adler=1}if(J.status===S9)if(J.gzhead.extra){Y=J.pending;while(J.gzindex<(J.gzhead.extra.length&65535)){if(J.pending===J.pending_buf_size){if(J.gzhead.hcrc&&J.pending>Y)Q.adler=P1(Q.adler,J.pending_buf,J.pending-Y,Y);if(I1(Q),Y=J.pending,J.pending===J.pending_buf_size)break}k(J,J.gzhead.extra[J.gzindex]&255),J.gzindex++}if(J.gzhead.hcrc&&J.pending>Y)Q.adler=P1(Q.adler,J.pending_buf,J.pending-Y,Y);if(J.gzindex===J.gzhead.extra.length)J.gzindex=0,J.status=z2}else J.status=z2;if(J.status===z2)if(J.gzhead.name){Y=J.pending;do{if(J.pending===J.pending_buf_size){if(J.gzhead.hcrc&&J.pending>Y)Q.adler=P1(Q.adler,J.pending_buf,J.pending-Y,Y);if(I1(Q),Y=J.pending,J.pending===J.pending_buf_size){V=1;break}}if(J.gzindex<J.gzhead.name.length)V=J.gzhead.name.charCodeAt(J.gzindex++)&255;else V=0;k(J,V)}while(V!==0);if(J.gzhead.hcrc&&J.pending>Y)Q.adler=P1(Q.adler,J.pending_buf,J.pending-Y,Y);if(V===0)J.gzindex=0,J.status=H2}else J.status=H2;if(J.status===H2)if(J.gzhead.comment){Y=J.pending;do{if(J.pending===J.pending_buf_size){if(J.gzhead.hcrc&&J.pending>Y)Q.adler=P1(Q.adler,J.pending_buf,J.pending-Y,Y);if(I1(Q),Y=J.pending,J.pending===J.pending_buf_size){V=1;break}}if(J.gzindex<J.gzhead.comment.length)V=J.gzhead.comment.charCodeAt(J.gzindex++)&255;else V=0;k(J,V)}while(V!==0);if(J.gzhead.hcrc&&J.pending>Y)Q.adler=P1(Q.adler,J.pending_buf,J.pending-Y,Y);if(V===0)J.status=F2}else J.status=F2;if(J.status===F2)if(J.gzhead.hcrc){if(J.pending+2>J.pending_buf_size)I1(Q);if(J.pending+2<=J.pending_buf_size)k(J,Q.adler&255),k(J,Q.adler>>8&255),Q.adler=0,J.status=c1}else J.status=c1;if(J.pending!==0){if(I1(Q),Q.avail_out===0)return J.last_flush=-1,a0}else if(Q.avail_in===0&&f$($)<=f$(q)&&$!==D1)return A1(Q,R9);if(J.status===X8&&Q.avail_in!==0)return A1(Q,R9);if(Q.avail_in!==0||J.lookahead!==0||$!==d1&&J.status!==X8){var W=J.strategy===Z2?YU(J,$):J.strategy===mW?JU(J,$):F6[J.level].func(J,$);if(W===u1||W===L6)J.status=X8;if(W===t||W===u1){if(Q.avail_out===0)J.last_flush=-1;return a0}if(W===K8){if($===gW)R0._tr_align(J);else if($!==b$){if(R0._tr_stored_block(J,0,0,!1),$===_W){if(C1(J.head),J.lookahead===0)J.strstart=0,J.block_start=0,J.insert=0}}if(I1(Q),Q.avail_out===0)return J.last_flush=-1,a0}}if($!==D1)return a0;if(J.wrap<=0)return h$;if(J.wrap===2)k(J,Q.adler&255),k(J,Q.adler>>8&255),k(J,Q.adler>>16&255),k(J,Q.adler>>24&255),k(J,Q.total_in&255),k(J,Q.total_in>>8&255),k(J,Q.total_in>>16&255),k(J,Q.total_in>>24&255);else V8(J,Q.adler>>>16),V8(J,Q.adler&65535);if(I1(Q),J.wrap>0)J.wrap=-J.wrap;return J.pending!==0?a0:h$}function UU(Q){var $;if(!Q||!Q.state)return x0;if($=Q.state.status,$!==O2&&$!==S9&&$!==z2&&$!==H2&&$!==F2&&$!==c1&&$!==X8)return A1(Q,x0);return Q.state=null,$===c1?A1(Q,bW):a0}function jU(Q,$){var q=$.length,J,Y,V,X,K,W,G,U;if(!Q||!Q.state)return x0;if(J=Q.state,X=J.wrap,X===2||X===1&&J.status!==O2||J.lookahead)return x0;if(X===1)Q.adler=m$(Q.adler,$,q,0);if(J.wrap=0,q>=J.w_size){if(X===0)C1(J.head),J.strstart=0,J.block_start=0,J.insert=0;U=new j0.Buf8(J.w_size),j0.arraySet(U,$,q-J.w_size,J.w_size,0),$=U,q=J.w_size}K=Q.avail_in,W=Q.next_in,G=Q.input,Q.avail_in=q,Q.next_in=0,Q.input=$,p1(J);while(J.lookahead>=S){Y=J.strstart,V=J.lookahead-(S-1);do J.ins_h=(J.ins_h<<J.hash_shift^J.window[Y+S-1])&J.hash_mask,J.prev[Y&J.w_mask]=J.head[J.ins_h],J.head[J.ins_h]=Y,Y++;while(--V);J.strstart=Y,J.lookahead=S-1,p1(J)}return J.strstart+=J.lookahead,J.block_start=J.strstart,J.insert=J.lookahead,J.lookahead=0,J.match_length=J.prev_length=S-1,J.match_available=0,Q.next_in=W,Q.input=G,Q.avail_in=K,J.wrap=X,a0}ZU.deflateInit=GU;ZU.deflateInit2=d$;ZU.deflateReset=p$;ZU.deflateResetKeep=u$;ZU.deflateSetHeader=KU;ZU.deflate=WU;ZU.deflateEnd=UU;ZU.deflateSetDictionary=jU;ZU.deflateInfo="pako deflate (from Nodeca project)"});var E9=w((IU)=>{var N2=U1(),o$=!0,i$=!0;try{String.fromCharCode.apply(null,[0])}catch(Q){o$=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(Q){i$=!1}var G8=new N2.Buf8(256);for(s0=0;s0<256;s0++)G8[s0]=s0>=252?6:s0>=248?5:s0>=240?4:s0>=224?3:s0>=192?2:1;var s0;G8[254]=G8[254]=1;IU.string2buf=function(Q){var $,q,J,Y,V,X=Q.length,K=0;for(Y=0;Y<X;Y++){if(q=Q.charCodeAt(Y),(q&64512)===55296&&Y+1<X){if(J=Q.charCodeAt(Y+1),(J&64512)===56320)q=65536+(q-55296<<10)+(J-56320),Y++}K+=q<128?1:q<2048?2:q<65536?3:4}$=new N2.Buf8(K);for(V=0,Y=0;V<K;Y++){if(q=Q.charCodeAt(Y),(q&64512)===55296&&Y+1<X){if(J=Q.charCodeAt(Y+1),(J&64512)===56320)q=65536+(q-55296<<10)+(J-56320),Y++}if(q<128)$[V++]=q;else if(q<2048)$[V++]=192|q>>>6,$[V++]=128|q&63;else if(q<65536)$[V++]=224|q>>>12,$[V++]=128|q>>>6&63,$[V++]=128|q&63;else $[V++]=240|q>>>18,$[V++]=128|q>>>12&63,$[V++]=128|q>>>6&63,$[V++]=128|q&63}return $};function n$(Q,$){if($<65534){if(Q.subarray&&i$||!Q.subarray&&o$)return String.fromCharCode.apply(null,N2.shrinkBuf(Q,$))}var q="";for(var J=0;J<$;J++)q+=String.fromCharCode(Q[J]);return q}IU.buf2binstring=function(Q){return n$(Q,Q.length)};IU.binstring2buf=function(Q){var $=new N2.Buf8(Q.length);for(var q=0,J=$.length;q<J;q++)$[q]=Q.charCodeAt(q);return $};IU.buf2string=function(Q,$){var q,J,Y,V,X=$||Q.length,K=Array(X*2);for(J=0,q=0;q<X;){if(Y=Q[q++],Y<128){K[J++]=Y;continue}if(V=G8[Y],V>4){K[J++]=65533,q+=V-1;continue}Y&=V===2?31:V===3?15:7;while(V>1&&q<X)Y=Y<<6|Q[q++]&63,V--;if(V>1){K[J++]=65533;continue}if(Y<65536)K[J++]=Y;else Y-=65536,K[J++]=55296|Y>>10&1023,K[J++]=56320|Y&1023}return n$(K,J)};IU.utf8border=function(Q,$){var q;if($=$||Q.length,$>Q.length)$=Q.length;q=$-1;while(q>=0&&(Q[q]&192)===128)q--;if(q<0)return $;if(q===0)return $;return q+G8[Q[q]]>$?q:$}});var k9=w((MO,r$)=>{function RU(){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}r$.exports=RU});var e$=w((_U)=>{var W8=l$(),U8=U1(),g9=E9(),_9=j2(),xU=k9(),t$=Object.prototype.toString,vU=0,y9=4,O6=0,a$=1,s$=2,SU=-1,EU=0,kU=8;function l1(Q){if(!(this instanceof l1))return new l1(Q);this.options=U8.assign({level:SU,method:kU,chunkSize:16384,windowBits:15,memLevel:8,strategy:EU,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 xU,this.strm.avail_out=0;var q=W8.deflateInit2(this.strm,$.level,$.method,$.windowBits,$.memLevel,$.strategy);if(q!==O6)throw Error(_9[q]);if($.header)W8.deflateSetHeader(this.strm,$.header);if($.dictionary){var J;if(typeof $.dictionary==="string")J=g9.string2buf($.dictionary);else if(t$.call($.dictionary)==="[object ArrayBuffer]")J=new Uint8Array($.dictionary);else J=$.dictionary;if(q=W8.deflateSetDictionary(this.strm,J),q!==O6)throw Error(_9[q]);this._dict_set=!0}}l1.prototype.push=function(Q,$){var q=this.strm,J=this.options.chunkSize,Y,V;if(this.ended)return!1;if(V=$===~~$?$:$===!0?y9:vU,typeof Q==="string")q.input=g9.string2buf(Q);else if(t$.call(Q)==="[object ArrayBuffer]")q.input=new Uint8Array(Q);else q.input=Q;q.next_in=0,q.avail_in=q.input.length;do{if(q.avail_out===0)q.output=new U8.Buf8(J),q.next_out=0,q.avail_out=J;if(Y=W8.deflate(q,V),Y!==a$&&Y!==O6)return this.onEnd(Y),this.ended=!0,!1;if(q.avail_out===0||q.avail_in===0&&(V===y9||V===s$))if(this.options.to==="string")this.onData(g9.buf2binstring(U8.shrinkBuf(q.output,q.next_out)));else this.onData(U8.shrinkBuf(q.output,q.next_out))}while((q.avail_in>0||q.avail_out===0)&&Y!==a$);if(V===y9)return Y=W8.deflateEnd(this.strm),this.onEnd(Y),this.ended=!0,Y===O6;if(V===s$)return this.onEnd(O6),q.avail_out=0,!0;return!0};l1.prototype.onData=function(Q){this.chunks.push(Q)};l1.prototype.onEnd=function(Q){if(Q===O6)if(this.options.to==="string")this.result=this.chunks.join("");else this.result=U8.flattenChunks(this.chunks);this.chunks=[],this.err=Q,this.msg=this.strm.msg};function b9(Q,$){var q=new l1($);if(q.push(Q,!0),q.err)throw q.msg||_9[q.err];return q.result}function yU(Q,$){return $=$||{},$.raw=!0,b9(Q,$)}function gU(Q,$){return $=$||{},$.gzip=!0,b9(Q,$)}_U.Deflate=l1;_U.deflate=b9;_U.deflateRaw=yU;_U.gzip=gU});var $q=w((IO,Qq)=>{var B2=30,cU=12;Qq.exports=function($,q){var J,Y,V,X,K,W,G,U,z,Z,H,F,N,C,P,L,A,B,O,M,T,D,x,v,R;J=$.state,Y=$.next_in,v=$.input,V=Y+($.avail_in-5),X=$.next_out,R=$.output,K=X-(q-$.avail_out),W=X+($.avail_out-257),G=J.dmax,U=J.wsize,z=J.whave,Z=J.wnext,H=J.window,F=J.hold,N=J.bits,C=J.lencode,P=J.distcode,L=(1<<J.lenbits)-1,A=(1<<J.distbits)-1;Q:do{if(N<15)F+=v[Y++]<<N,N+=8,F+=v[Y++]<<N,N+=8;B=C[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];q:for(;;){if(O=B>>>24,F>>>=O,N-=O,O=B>>>16&255,O&16){if(T=B&65535,O&=15,N<O){if(F+=v[Y++]<<N,N+=8,N<O)F+=v[Y++]<<N,N+=8}if(T+=F&(1<<O)-1,T>G){$.msg="invalid distance too far back",J.mode=B2;break Q}if(F>>>=O,N-=O,O=X-K,T>O){if(O=T-O,O>z){if(J.sane){$.msg="invalid distance too far back",J.mode=B2;break Q}}if(D=0,x=H,Z===0){if(D+=U-O,O<M){M-=O;do R[X++]=H[D++];while(--O);D=X-T,x=R}}else if(Z<O){if(D+=U+Z-O,O-=Z,O<M){M-=O;do R[X++]=H[D++];while(--O);if(D=0,Z<M){O=Z,M-=O;do R[X++]=H[D++];while(--O);D=X-T,x=R}}}else if(D+=Z-O,O<M){M-=O;do R[X++]=H[D++];while(--O);D=X-T,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-T;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 q}else{$.msg="invalid distance code",J.mode=B2;break Q}break}}else if((O&64)===0){B=C[(B&65535)+(F&(1<<O)-1)];continue $}else if(O&32){J.mode=cU;break Q}else{$.msg="invalid literal/length code",J.mode=B2;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),J.hold=F,J.bits=N;return}});var Gq=w((CO,Kq)=>{var qq=U1(),N6=15,Jq=852,Yq=592,Vq=0,h9=1,Xq=2,uU=[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],pU=[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],dU=[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],lU=[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];Kq.exports=function($,q,J,Y,V,X,K,W){var G=W.bits,U=0,z=0,Z=0,H=0,F=0,N=0,C=0,P=0,L=0,A=0,B,O,M,T,D,x=null,v=0,R,$0=new qq.Buf16(N6+1),T0=new qq.Buf16(N6+1),h=null,G0=0,A0,z0,J1;for(U=0;U<=N6;U++)$0[U]=0;for(z=0;z<Y;z++)$0[q[J+z]]++;F=G;for(H=N6;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(Z=1;Z<H;Z++)if($0[Z]!==0)break;if(F<Z)F=Z;P=1;for(U=1;U<=N6;U++)if(P<<=1,P-=$0[U],P<0)return-1;if(P>0&&($===Vq||H!==1))return-1;T0[1]=0;for(U=1;U<N6;U++)T0[U+1]=T0[U]+$0[U];for(z=0;z<Y;z++)if(q[J+z]!==0)K[T0[q[J+z]]++]=z;if($===Vq)x=h=K,R=19;else if($===h9)x=uU,v-=257,h=pU,G0-=257,R=256;else x=dU,h=lU,R=-1;if(A=0,z=0,U=Z,D=X,N=F,C=0,M=-1,L=1<<F,T=L-1,$===h9&&L>Jq||$===Xq&&L>Yq)return 1;for(;;){if(A0=U-C,K[z]<R)z0=0,J1=K[z];else if(K[z]>R)z0=h[G0+K[z]],J1=x[v+K[z]];else z0=96,J1=0;B=1<<U-C,O=1<<N,Z=O;do O-=B,V[D+(A>>C)+O]=A0<<24|z0<<16|J1|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=q[J+K[z]]}if(U>F&&(A&T)!==M){if(C===0)C=F;D+=Z,N=U-C,P=1<<N;while(N+C<H){if(P-=$0[N+C],P<=0)break;N++,P<<=1}if(L+=1<<N,$===h9&&L>Jq||$===Xq&&L>Yq)return 1;M=A&T,V[M]=F<<24|N<<16|D-X|0}}if(A!==0)V[D+A]=U-C<<24|4194304|0;return W.bits=F,0}});var pq=w((Uj)=>{var M0=U1(),d9=D9(),t0=w9(),oU=$q(),j8=Gq(),iU=0,yq=1,gq=2,Wq=4,nU=5,M2=6,o1=0,rU=1,aU=2,v0=-2,_q=-3,l9=-4,sU=-5,Uq=8,bq=1,jq=2,Zq=3,zq=4,Hq=5,Fq=6,Lq=7,Oq=8,Nq=9,Bq=10,C2=11,Z1=12,f9=13,Mq=14,m9=15,Pq=16,Iq=17,Cq=18,Tq=19,P2=20,I2=21,Aq=22,Dq=23,wq=24,Rq=25,xq=26,c9=27,vq=28,Sq=29,p=30,o9=31,tU=32,eU=852,Qj=592,$j=15,qj=$j;function Eq(Q){return(Q>>>24&255)+(Q>>>8&65280)+((Q&65280)<<8)+((Q&255)<<24)}function Jj(){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 M0.Buf16(320),this.work=new M0.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function hq(Q){var $;if(!Q||!Q.state)return v0;if($=Q.state,Q.total_in=Q.total_out=$.total=0,Q.msg="",$.wrap)Q.adler=$.wrap&1;return $.mode=bq,$.last=0,$.havedict=0,$.dmax=32768,$.head=null,$.hold=0,$.bits=0,$.lencode=$.lendyn=new M0.Buf32(eU),$.distcode=$.distdyn=new M0.Buf32(Qj),$.sane=1,$.back=-1,o1}function fq(Q){var $;if(!Q||!Q.state)return v0;return $=Q.state,$.wsize=0,$.whave=0,$.wnext=0,hq(Q)}function mq(Q,$){var q,J;if(!Q||!Q.state)return v0;if(J=Q.state,$<0)q=0,$=-$;else if(q=($>>4)+1,$<48)$&=15;if($&&($<8||$>15))return v0;if(J.window!==null&&J.wbits!==$)J.window=null;return J.wrap=q,J.wbits=$,fq(Q)}function cq(Q,$){var q,J;if(!Q)return v0;if(J=new Jj,Q.state=J,J.window=null,q=mq(Q,$),q!==o1)Q.state=null;return q}function Yj(Q){return cq(Q,qj)}var kq=!0,u9,p9;function Vj(Q){if(kq){var $;u9=new M0.Buf32(512),p9=new M0.Buf32(32),$=0;while($<144)Q.lens[$++]=8;while($<256)Q.lens[$++]=9;while($<280)Q.lens[$++]=7;while($<288)Q.lens[$++]=8;j8(yq,Q.lens,0,288,u9,0,Q.work,{bits:9}),$=0;while($<32)Q.lens[$++]=5;j8(gq,Q.lens,0,32,p9,0,Q.work,{bits:5}),kq=!1}Q.lencode=u9,Q.lenbits=9,Q.distcode=p9,Q.distbits=5}function uq(Q,$,q,J){var Y,V=Q.state;if(V.window===null)V.wsize=1<<V.wbits,V.wnext=0,V.whave=0,V.window=new M0.Buf8(V.wsize);if(J>=V.wsize)M0.arraySet(V.window,$,q-V.wsize,V.wsize,0),V.wnext=0,V.whave=V.wsize;else{if(Y=V.wsize-V.wnext,Y>J)Y=J;if(M0.arraySet(V.window,$,q-J,Y,V.wnext),J-=Y,J)M0.arraySet(V.window,$,q-J,J,0),V.wnext=J,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 Xj(Q,$){var q,J,Y,V,X,K,W,G,U,z,Z,H,F,N,C=0,P,L,A,B,O,M,T,D,x=new M0.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 v0;if(q=Q.state,q.mode===Z1)q.mode=f9;X=Q.next_out,Y=Q.output,W=Q.avail_out,V=Q.next_in,J=Q.input,K=Q.avail_in,G=q.hold,U=q.bits,z=K,Z=W,D=o1;Q:for(;;)switch(q.mode){case bq:if(q.wrap===0){q.mode=f9;break}while(U<16){if(K===0)break Q;K--,G+=J[V++]<<U,U+=8}if(q.wrap&2&&G===35615){q.check=0,x[0]=G&255,x[1]=G>>>8&255,q.check=t0(q.check,x,2,0),G=0,U=0,q.mode=jq;break}if(q.flags=0,q.head)q.head.done=!1;if(!(q.wrap&1)||(((G&255)<<8)+(G>>8))%31){Q.msg="incorrect header check",q.mode=p;break}if((G&15)!==Uq){Q.msg="unknown compression method",q.mode=p;break}if(G>>>=4,U-=4,T=(G&15)+8,q.wbits===0)q.wbits=T;else if(T>q.wbits){Q.msg="invalid window size",q.mode=p;break}q.dmax=1<<T,Q.adler=q.check=1,q.mode=G&512?Bq:Z1,G=0,U=0;break;case jq:while(U<16){if(K===0)break Q;K--,G+=J[V++]<<U,U+=8}if(q.flags=G,(q.flags&255)!==Uq){Q.msg="unknown compression method",q.mode=p;break}if(q.flags&57344){Q.msg="unknown header flags set",q.mode=p;break}if(q.head)q.head.text=G>>8&1;if(q.flags&512)x[0]=G&255,x[1]=G>>>8&255,q.check=t0(q.check,x,2,0);G=0,U=0,q.mode=Zq;case Zq:while(U<32){if(K===0)break Q;K--,G+=J[V++]<<U,U+=8}if(q.head)q.head.time=G;if(q.flags&512)x[0]=G&255,x[1]=G>>>8&255,x[2]=G>>>16&255,x[3]=G>>>24&255,q.check=t0(q.check,x,4,0);G=0,U=0,q.mode=zq;case zq:while(U<16){if(K===0)break Q;K--,G+=J[V++]<<U,U+=8}if(q.head)q.head.xflags=G&255,q.head.os=G>>8;if(q.flags&512)x[0]=G&255,x[1]=G>>>8&255,q.check=t0(q.check,x,2,0);G=0,U=0,q.mode=Hq;case Hq:if(q.flags&1024){while(U<16){if(K===0)break Q;K--,G+=J[V++]<<U,U+=8}if(q.length=G,q.head)q.head.extra_len=G;if(q.flags&512)x[0]=G&255,x[1]=G>>>8&255,q.check=t0(q.check,x,2,0);G=0,U=0}else if(q.head)q.head.extra=null;q.mode=Fq;case Fq:if(q.flags&1024){if(H=q.length,H>K)H=K;if(H){if(q.head){if(T=q.head.extra_len-q.length,!q.head.extra)q.head.extra=Array(q.head.extra_len);M0.arraySet(q.head.extra,J,V,H,T)}if(q.flags&512)q.check=t0(q.check,J,H,V);K-=H,V+=H,q.length-=H}if(q.length)break Q}q.length=0,q.mode=Lq;case Lq:if(q.flags&2048){if(K===0)break Q;H=0;do if(T=J[V+H++],q.head&&T&&q.length<65536)q.head.name+=String.fromCharCode(T);while(T&&H<K);if(q.flags&512)q.check=t0(q.check,J,H,V);if(K-=H,V+=H,T)break Q}else if(q.head)q.head.name=null;q.length=0,q.mode=Oq;case Oq:if(q.flags&4096){if(K===0)break Q;H=0;do if(T=J[V+H++],q.head&&T&&q.length<65536)q.head.comment+=String.fromCharCode(T);while(T&&H<K);if(q.flags&512)q.check=t0(q.check,J,H,V);if(K-=H,V+=H,T)break Q}else if(q.head)q.head.comment=null;q.mode=Nq;case Nq:if(q.flags&512){while(U<16){if(K===0)break Q;K--,G+=J[V++]<<U,U+=8}if(G!==(q.check&65535)){Q.msg="header crc mismatch",q.mode=p;break}G=0,U=0}if(q.head)q.head.hcrc=q.flags>>9&1,q.head.done=!0;Q.adler=q.check=0,q.mode=Z1;break;case Bq:while(U<32){if(K===0)break Q;K--,G+=J[V++]<<U,U+=8}Q.adler=q.check=Eq(G),G=0,U=0,q.mode=C2;case C2:if(q.havedict===0)return Q.next_out=X,Q.avail_out=W,Q.next_in=V,Q.avail_in=K,q.hold=G,q.bits=U,aU;Q.adler=q.check=1,q.mode=Z1;case Z1:if($===nU||$===M2)break Q;case f9:if(q.last){G>>>=U&7,U-=U&7,q.mode=c9;break}while(U<3){if(K===0)break Q;K--,G+=J[V++]<<U,U+=8}switch(q.last=G&1,G>>>=1,U-=1,G&3){case 0:q.mode=Mq;break;case 1:if(Vj(q),q.mode=P2,$===M2){G>>>=2,U-=2;break Q}break;case 2:q.mode=Iq;break;case 3:Q.msg="invalid block type",q.mode=p}G>>>=2,U-=2;break;case Mq:G>>>=U&7,U-=U&7;while(U<32){if(K===0)break Q;K--,G+=J[V++]<<U,U+=8}if((G&65535)!==(G>>>16^65535)){Q.msg="invalid stored block lengths",q.mode=p;break}if(q.length=G&65535,G=0,U=0,q.mode=m9,$===M2)break Q;case m9:q.mode=Pq;case Pq:if(H=q.length,H){if(H>K)H=K;if(H>W)H=W;if(H===0)break Q;M0.arraySet(Y,J,V,H,X),K-=H,V+=H,W-=H,X+=H,q.length-=H;break}q.mode=Z1;break;case Iq:while(U<14){if(K===0)break Q;K--,G+=J[V++]<<U,U+=8}if(q.nlen=(G&31)+257,G>>>=5,U-=5,q.ndist=(G&31)+1,G>>>=5,U-=5,q.ncode=(G&15)+4,G>>>=4,U-=4,q.nlen>286||q.ndist>30){Q.msg="too many length or distance symbols",q.mode=p;break}q.have=0,q.mode=Cq;case Cq:while(q.have<q.ncode){while(U<3){if(K===0)break Q;K--,G+=J[V++]<<U,U+=8}q.lens[$0[q.have++]]=G&7,G>>>=3,U-=3}while(q.have<19)q.lens[$0[q.have++]]=0;if(q.lencode=q.lendyn,q.lenbits=7,v={bits:q.lenbits},D=j8(iU,q.lens,0,19,q.lencode,0,q.work,v),q.lenbits=v.bits,D){Q.msg="invalid code lengths set",q.mode=p;break}q.have=0,q.mode=Tq;case Tq:while(q.have<q.nlen+q.ndist){for(;;){if(C=q.lencode[G&(1<<q.lenbits)-1],P=C>>>24,L=C>>>16&255,A=C&65535,P<=U)break;if(K===0)break Q;K--,G+=J[V++]<<U,U+=8}if(A<16)G>>>=P,U-=P,q.lens[q.have++]=A;else{if(A===16){R=P+2;while(U<R){if(K===0)break Q;K--,G+=J[V++]<<U,U+=8}if(G>>>=P,U-=P,q.have===0){Q.msg="invalid bit length repeat",q.mode=p;break}T=q.lens[q.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+=J[V++]<<U,U+=8}G>>>=P,U-=P,T=0,H=3+(G&7),G>>>=3,U-=3}else{R=P+7;while(U<R){if(K===0)break Q;K--,G+=J[V++]<<U,U+=8}G>>>=P,U-=P,T=0,H=11+(G&127),G>>>=7,U-=7}if(q.have+H>q.nlen+q.ndist){Q.msg="invalid bit length repeat",q.mode=p;break}while(H--)q.lens[q.have++]=T}}if(q.mode===p)break;if(q.lens[256]===0){Q.msg="invalid code -- missing end-of-block",q.mode=p;break}if(q.lenbits=9,v={bits:q.lenbits},D=j8(yq,q.lens,0,q.nlen,q.lencode,0,q.work,v),q.lenbits=v.bits,D){Q.msg="invalid literal/lengths set",q.mode=p;break}if(q.distbits=6,q.distcode=q.distdyn,v={bits:q.distbits},D=j8(gq,q.lens,q.nlen,q.ndist,q.distcode,0,q.work,v),q.distbits=v.bits,D){Q.msg="invalid distances set",q.mode=p;break}if(q.mode=P2,$===M2)break Q;case P2:q.mode=I2;case I2:if(K>=6&&W>=258){if(Q.next_out=X,Q.avail_out=W,Q.next_in=V,Q.avail_in=K,q.hold=G,q.bits=U,oU(Q,Z),X=Q.next_out,Y=Q.output,W=Q.avail_out,V=Q.next_in,J=Q.input,K=Q.avail_in,G=q.hold,U=q.bits,q.mode===Z1)q.back=-1;break}q.back=0;for(;;){if(C=q.lencode[G&(1<<q.lenbits)-1],P=C>>>24,L=C>>>16&255,A=C&65535,P<=U)break;if(K===0)break Q;K--,G+=J[V++]<<U,U+=8}if(L&&(L&240)===0){B=P,O=L,M=A;for(;;){if(C=q.lencode[M+((G&(1<<B+O)-1)>>B)],P=C>>>24,L=C>>>16&255,A=C&65535,B+P<=U)break;if(K===0)break Q;K--,G+=J[V++]<<U,U+=8}G>>>=B,U-=B,q.back+=B}if(G>>>=P,U-=P,q.back+=P,q.length=A,L===0){q.mode=xq;break}if(L&32){q.back=-1,q.mode=Z1;break}if(L&64){Q.msg="invalid literal/length code",q.mode=p;break}q.extra=L&15,q.mode=Aq;case Aq:if(q.extra){R=q.extra;while(U<R){if(K===0)break Q;K--,G+=J[V++]<<U,U+=8}q.length+=G&(1<<q.extra)-1,G>>>=q.extra,U-=q.extra,q.back+=q.extra}q.was=q.length,q.mode=Dq;case Dq:for(;;){if(C=q.distcode[G&(1<<q.distbits)-1],P=C>>>24,L=C>>>16&255,A=C&65535,P<=U)break;if(K===0)break Q;K--,G+=J[V++]<<U,U+=8}if((L&240)===0){B=P,O=L,M=A;for(;;){if(C=q.distcode[M+((G&(1<<B+O)-1)>>B)],P=C>>>24,L=C>>>16&255,A=C&65535,B+P<=U)break;if(K===0)break Q;K--,G+=J[V++]<<U,U+=8}G>>>=B,U-=B,q.back+=B}if(G>>>=P,U-=P,q.back+=P,L&64){Q.msg="invalid distance code",q.mode=p;break}q.offset=A,q.extra=L&15,q.mode=wq;case wq:if(q.extra){R=q.extra;while(U<R){if(K===0)break Q;K--,G+=J[V++]<<U,U+=8}q.offset+=G&(1<<q.extra)-1,G>>>=q.extra,U-=q.extra,q.back+=q.extra}if(q.offset>q.dmax){Q.msg="invalid distance too far back",q.mode=p;break}q.mode=Rq;case Rq:if(W===0)break Q;if(H=Z-W,q.offset>H){if(H=q.offset-H,H>q.whave){if(q.sane){Q.msg="invalid distance too far back",q.mode=p;break}}if(H>q.wnext)H-=q.wnext,F=q.wsize-H;else F=q.wnext-H;if(H>q.length)H=q.length;N=q.window}else N=Y,F=X-q.offset,H=q.length;if(H>W)H=W;W-=H,q.length-=H;do Y[X++]=N[F++];while(--H);if(q.length===0)q.mode=I2;break;case xq:if(W===0)break Q;Y[X++]=q.length,W--,q.mode=I2;break;case c9:if(q.wrap){while(U<32){if(K===0)break Q;K--,G|=J[V++]<<U,U+=8}if(Z-=W,Q.total_out+=Z,q.total+=Z,Z)Q.adler=q.check=q.flags?t0(q.check,Y,Z,X-Z):d9(q.check,Y,Z,X-Z);if(Z=W,(q.flags?G:Eq(G))!==q.check){Q.msg="incorrect data check",q.mode=p;break}G=0,U=0}q.mode=vq;case vq:if(q.wrap&&q.flags){while(U<32){if(K===0)break Q;K--,G+=J[V++]<<U,U+=8}if(G!==(q.total&4294967295)){Q.msg="incorrect length check",q.mode=p;break}G=0,U=0}q.mode=Sq;case Sq:D=rU;break Q;case p:D=_q;break Q;case o9:return l9;case tU:default:return v0}if(Q.next_out=X,Q.avail_out=W,Q.next_in=V,Q.avail_in=K,q.hold=G,q.bits=U,q.wsize||Z!==Q.avail_out&&q.mode<p&&(q.mode<c9||$!==Wq)){if(uq(Q,Q.output,Q.next_out,Z-Q.avail_out))return q.mode=o9,l9}if(z-=Q.avail_in,Z-=Q.avail_out,Q.total_in+=z,Q.total_out+=Z,q.total+=Z,q.wrap&&Z)Q.adler=q.check=q.flags?t0(q.check,Y,Z,Q.next_out-Z):d9(q.check,Y,Z,Q.next_out-Z);if(Q.data_type=q.bits+(q.last?64:0)+(q.mode===Z1?128:0)+(q.mode===P2||q.mode===m9?256:0),(z===0&&Z===0||$===Wq)&&D===o1)D=sU;return D}function Kj(Q){if(!Q||!Q.state)return v0;var $=Q.state;if($.window)$.window=null;return Q.state=null,o1}function Gj(Q,$){var q;if(!Q||!Q.state)return v0;if(q=Q.state,(q.wrap&2)===0)return v0;return q.head=$,$.done=!1,o1}function Wj(Q,$){var q=$.length,J,Y,V;if(!Q||!Q.state)return v0;if(J=Q.state,J.wrap!==0&&J.mode!==C2)return v0;if(J.mode===C2){if(Y=1,Y=d9(Y,$,q,0),Y!==J.check)return _q}if(V=uq(Q,$,q,q),V)return J.mode=o9,l9;return J.havedict=1,o1}Uj.inflateReset=fq;Uj.inflateReset2=mq;Uj.inflateResetKeep=hq;Uj.inflateInit=Yj;Uj.inflateInit2=cq;Uj.inflate=Xj;Uj.inflateEnd=Kj;Uj.inflateGetHeader=Gj;Uj.inflateSetDictionary=Wj;Uj.inflateInfo="pako inflate (from Nodeca project)"});var i9=w((AO,dq)=>{dq.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 oq=w((DO,lq)=>{function Pj(){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}lq.exports=Pj});var nq=w((Aj)=>{var B6=pq(),Z8=U1(),T2=E9(),n=i9(),n9=j2(),Ij=k9(),Cj=oq(),iq=Object.prototype.toString;function i1(Q){if(!(this instanceof i1))return new i1(Q);this.options=Z8.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 Ij,this.strm.avail_out=0;var q=B6.inflateInit2(this.strm,$.windowBits);if(q!==n.Z_OK)throw Error(n9[q]);if(this.header=new Cj,B6.inflateGetHeader(this.strm,this.header),$.dictionary){if(typeof $.dictionary==="string")$.dictionary=T2.string2buf($.dictionary);else if(iq.call($.dictionary)==="[object ArrayBuffer]")$.dictionary=new Uint8Array($.dictionary);if($.raw){if(q=B6.inflateSetDictionary(this.strm,$.dictionary),q!==n.Z_OK)throw Error(n9[q])}}}i1.prototype.push=function(Q,$){var q=this.strm,J=this.options.chunkSize,Y=this.options.dictionary,V,X,K,W,G,U=!1;if(this.ended)return!1;if(X=$===~~$?$:$===!0?n.Z_FINISH:n.Z_NO_FLUSH,typeof Q==="string")q.input=T2.binstring2buf(Q);else if(iq.call(Q)==="[object ArrayBuffer]")q.input=new Uint8Array(Q);else q.input=Q;q.next_in=0,q.avail_in=q.input.length;do{if(q.avail_out===0)q.output=new Z8.Buf8(J),q.next_out=0,q.avail_out=J;if(V=B6.inflate(q,n.Z_NO_FLUSH),V===n.Z_NEED_DICT&&Y)V=B6.inflateSetDictionary(this.strm,Y);if(V===n.Z_BUF_ERROR&&U===!0)V=n.Z_OK,U=!1;if(V!==n.Z_STREAM_END&&V!==n.Z_OK)return this.onEnd(V),this.ended=!0,!1;if(q.next_out){if(q.avail_out===0||V===n.Z_STREAM_END||q.avail_in===0&&(X===n.Z_FINISH||X===n.Z_SYNC_FLUSH))if(this.options.to==="string"){if(K=T2.utf8border(q.output,q.next_out),W=q.next_out-K,G=T2.buf2string(q.output,K),q.next_out=W,q.avail_out=J-W,W)Z8.arraySet(q.output,q.output,K,W,0);this.onData(G)}else this.onData(Z8.shrinkBuf(q.output,q.next_out))}if(q.avail_in===0&&q.avail_out===0)U=!0}while((q.avail_in>0||q.avail_out===0)&&V!==n.Z_STREAM_END);if(V===n.Z_STREAM_END)X=n.Z_FINISH;if(X===n.Z_FINISH)return V=B6.inflateEnd(this.strm),this.onEnd(V),this.ended=!0,V===n.Z_OK;if(X===n.Z_SYNC_FLUSH)return this.onEnd(n.Z_OK),q.avail_out=0,!0;return!0};i1.prototype.onData=function(Q){this.chunks.push(Q)};i1.prototype.onEnd=function(Q){if(Q===n.Z_OK)if(this.options.to==="string")this.result=this.chunks.join("");else this.result=Z8.flattenChunks(this.chunks);this.chunks=[],this.err=Q,this.msg=this.strm.msg};function r9(Q,$){var q=new i1($);if(q.push(Q,!0),q.err)throw q.msg||n9[q.err];return q.result}function Tj(Q,$){return $=$||{},$.raw=!0,r9(Q,$)}Aj.Inflate=i1;Aj.inflate=r9;Aj.inflateRaw=Tj;Aj.ungzip=r9});var sq=w((RO,aq)=>{var vj=U1().assign,Sj=e$(),Ej=nq(),kj=i9(),rq={};vj(rq,Sj,Ej,kj);aq.exports=rq});var eq=w((bj)=>{var yj=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",gj=sq(),tq=l(),A2=B0(),_j=yj?"uint8array":"array";bj.magic="\b\x00";function n1(Q,$){A2.call(this,"FlateWorker/"+Q),this._pako=null,this._pakoAction=Q,this._pakoOptions=$,this.meta={}}tq.inherits(n1,A2);n1.prototype.processChunk=function(Q){if(this.meta=Q.meta,this._pako===null)this._createPako();this._pako.push(tq.transformTo(_j,Q.data),!1)};n1.prototype.flush=function(){if(A2.prototype.flush.call(this),this._pako===null)this._createPako();this._pako.push([],!0)};n1.prototype.cleanUp=function(){A2.prototype.cleanUp.call(this),this._pako=null};n1.prototype._createPako=function(){this._pako=new gj[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var Q=this;this._pako.onData=function($){Q.push({data:$,meta:Q.meta})}};bj.compressWorker=function(Q){return new n1("Deflate",Q)};bj.uncompressWorker=function(){return new n1("Inflate",{})}});var a9=w((cj)=>{var QJ=B0();cj.STORE={magic:"\x00\x00",compressWorker:function(){return new QJ("STORE compression")},uncompressWorker:function(){return new QJ("STORE decompression")}};cj.DEFLATE=eq()});var s9=w((dj)=>{dj.LOCAL_FILE_HEADER="PK\x03\x04";dj.CENTRAL_FILE_HEADER="PK\x01\x02";dj.CENTRAL_DIRECTORY_END="PK\x05\x06";dj.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x06\x07";dj.ZIP64_CENTRAL_DIRECTORY_END="PK\x06\x06";dj.DATA_DESCRIPTOR="PK\x07\b"});var YJ=w((EO,JJ)=>{var M6=l(),P6=B0(),t9=U6(),$J=K2(),D2=s9(),m=function(Q,$){var q="",J;for(J=0;J<$;J++)q+=String.fromCharCode(Q&255),Q=Q>>>8;return q},sj=function(Q,$){var q=Q;if(!Q)q=$?16893:33204;return(q&65535)<<16},tj=function(Q){return(Q||0)&63},qJ=function(Q,$,q,J,Y,V){var{file:X,compression:K}=Q,W=V!==t9.utf8encode,G=M6.transformTo("string",V(X.name)),U=M6.transformTo("string",t9.utf8encode(X.name)),z=X.comment,Z=M6.transformTo("string",V(z)),H=M6.transformTo("string",t9.utf8encode(z)),F=U.length!==X.name.length,N=H.length!==z.length,C,P,L="",A="",B="",O=X.dir,M=X.date,T={crc32:0,compressedSize:0,uncompressedSize:0};if(!$||q)T.crc32=Q.crc32,T.compressedSize=Q.compressedSize,T.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|=sj(X.unixPermissions,O);else v=20,x|=tj(X.dosPermissions,O);if(C=M.getUTCHours(),C=C<<6,C=C|M.getUTCMinutes(),C=C<<5,C=C|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($J(G),4)+U,L+="up"+m(A.length,2)+A;if(N)B=m(1,1)+m($J(Z),4)+H,L+="uc"+m(B.length,2)+B;var R="";R+=`
78
- \x00`,R+=m(D,2),R+=K.magic,R+=m(C,2),R+=m(P,2),R+=m(T.crc32,4),R+=m(T.compressedSize,4),R+=m(T.uncompressedSize,4),R+=m(G.length,2),R+=m(L.length,2);var $0=D2.LOCAL_FILE_HEADER+R+G+L,T0=D2.CENTRAL_FILE_HEADER+m(v,2)+R+m(Z.length,2)+"\x00\x00\x00\x00"+m(x,4)+m(J,4)+G+L+Z;return{fileRecord:$0,dirRecord:T0}},ej=function(Q,$,q,J,Y){var V="",X=M6.transformTo("string",Y(J));return V=D2.CENTRAL_DIRECTORY_END+"\x00\x00\x00\x00"+m(Q,2)+m(Q,2)+m($,4)+m(q,4)+m(X.length,2)+X,V},QZ=function(Q){var $="";return $=D2.DATA_DESCRIPTOR+m(Q.crc32,4)+m(Q.compressedSize,4)+m(Q.uncompressedSize,4),$};function f0(Q,$,q,J){P6.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=$,this.zipPlatform=q,this.encodeFileName=J,this.streamFiles=Q,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}M6.inherits(f0,P6);f0.prototype.push=function(Q){var $=Q.meta.percent||0,q=this.entriesCount,J=this._sources.length;if(this.accumulate)this.contentBuffer.push(Q);else this.bytesWritten+=Q.data.length,P6.prototype.push.call(this,{data:Q.data,meta:{currentFile:this.currentFile,percent:q?($+100*(q-J-1))/q:100}})};f0.prototype.openedSource=function(Q){this.currentSourceOffset=this.bytesWritten,this.currentFile=Q.file.name;var $=this.streamFiles&&!Q.file.dir;if($){var q=qJ(Q,$,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:q.fileRecord,meta:{percent:0}})}else this.accumulate=!0};f0.prototype.closedSource=function(Q){this.accumulate=!1;var $=this.streamFiles&&!Q.file.dir,q=qJ(Q,$,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(q.dirRecord),$)this.push({data:QZ(Q),meta:{percent:100}});else{this.push({data:q.fileRecord,meta:{percent:0}});while(this.contentBuffer.length)this.push(this.contentBuffer.shift())}this.currentFile=null};f0.prototype.flush=function(){var Q=this.bytesWritten;for(var $=0;$<this.dirRecords.length;$++)this.push({data:this.dirRecords[$],meta:{percent:100}});var q=this.bytesWritten-Q,J=ej(this.dirRecords.length,q,Q,this.zipComment,this.encodeFileName);this.push({data:J,meta:{percent:100}})};f0.prototype.prepareNextSource=function(){if(this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused)this.previous.pause();else this.previous.resume()};f0.prototype.registerPrevious=function(Q){this._sources.push(Q);var $=this;return Q.on("data",function(q){$.processChunk(q)}),Q.on("end",function(){if($.closedSource($.previous.streamInfo),$._sources.length)$.prepareNextSource();else $.end()}),Q.on("error",function(q){$.error(q)}),this};f0.prototype.resume=function(){if(!P6.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};f0.prototype.error=function(Q){var $=this._sources;if(!P6.prototype.error.call(this,Q))return!1;for(var q=0;q<$.length;q++)try{$[q].error(Q)}catch(J){}return!0};f0.prototype.lock=function(){P6.prototype.lock.call(this);var Q=this._sources;for(var $=0;$<Q.length;$++)Q[$].lock()};JJ.exports=f0});var VJ=w((YZ)=>{var $Z=a9(),qZ=YJ(),JZ=function(Q,$){var q=Q||$,J=$Z[q];if(!J)throw Error(q+" is not a valid compression method !");return J};YZ.generateWorker=function(Q,$,q){var J=new qZ($.streamFiles,q,$.platform,$.encodeFileName),Y=0;try{Q.forEach(function(V,X){Y++;var K=JZ(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(J)}),J.entriesCount=Y}catch(V){J.error(V)}return J}});var KJ=w((yO,XJ)=>{var XZ=l(),w2=B0();function z8(Q,$){w2.call(this,"Nodejs stream input adapter for "+Q),this._upstreamEnded=!1,this._bindStream($)}XZ.inherits(z8,w2);z8.prototype._bindStream=function(Q){var $=this;this._stream=Q,Q.pause(),Q.on("data",function(q){$.push({data:q,meta:{percent:0}})}).on("error",function(q){if($.isPaused)this.generatedError=q;else $.error(q)}).on("end",function(){if($.isPaused)$._upstreamEnded=!0;else $.end()})};z8.prototype.pause=function(){if(!w2.prototype.pause.call(this))return!1;return this._stream.pause(),!0};z8.prototype.resume=function(){if(!w2.prototype.resume.call(this))return!1;if(this._upstreamEnded)this.end();else this._stream.resume();return!0};XJ.exports=z8});var OJ=w((gO,LJ)=>{var KZ=U6(),H8=l(),jJ=B0(),GZ=q9(),ZJ=J9(),GJ=G2(),WZ=W$(),UZ=VJ(),WJ=o6(),jZ=KJ(),zJ=function(Q,$,q){var J=H8.getTypeOf($),Y,V=H8.extend(q||{},ZJ);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=HJ(Q);if(V.createFolders&&(Y=ZZ(Q)))FJ.call(this,Y,!0);var X=J==="string"&&V.binary===!1&&V.base64===!1;if(!q||typeof q.binary>"u")V.binary=!X;var K=$ instanceof GJ&&$.uncompressedSize===0;if(K||V.dir||!$||$.length===0)V.base64=!1,V.binary=!0,$="",V.compression="STORE",J="string";var W=null;if($ instanceof GJ||$ instanceof jJ)W=$;else if(WJ.isNode&&WJ.isStream($))W=new jZ(Q,$);else W=H8.prepareContent(Q,$,V.binary,V.optimizedBinaryString,V.base64);var G=new WZ(Q,W,V);this.files[Q]=G},ZZ=function(Q){if(Q.slice(-1)==="/")Q=Q.substring(0,Q.length-1);var $=Q.lastIndexOf("/");return $>0?Q.substring(0,$):""},HJ=function(Q){if(Q.slice(-1)!=="/")Q+="/";return Q},FJ=function(Q,$){if($=typeof $<"u"?$:ZJ.createFolders,Q=HJ(Q),!this.files[Q])zJ.call(this,Q,null,{dir:!0,createFolders:$});return this.files[Q]};function UJ(Q){return Object.prototype.toString.call(Q)==="[object RegExp]"}var zZ={load:function(){throw Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(Q){var $,q,J;for($ in this.files)if(J=this.files[$],q=$.slice(this.root.length,$.length),q&&$.slice(0,this.root.length)===this.root)Q(q,J)},filter:function(Q){var $=[];return this.forEach(function(q,J){if(Q(q,J))$.push(J)}),$},file:function(Q,$,q){if(arguments.length===1)if(UJ(Q)){var J=Q;return this.filter(function(V,X){return!X.dir&&J.test(V)})}else{var Y=this.files[this.root+Q];if(Y&&!Y.dir)return Y;else return null}else Q=this.root+Q,zJ.call(this,Q,$,q);return this},folder:function(Q){if(!Q)return this;if(UJ(Q))return this.filter(function(Y,V){return V.dir&&Q.test(Y)});var $=this.root+Q,q=FJ.call(this,$),J=this.clone();return J.root=q.name,J},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 q=this.filter(function(Y,V){return V.name.slice(0,Q.length)===Q});for(var J=0;J<q.length;J++)delete this.files[q[J].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 $,q={};try{if(q=H8.extend(Q||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:KZ.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(H8.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 J=q.comment||this.comment||"";$=UZ.generateWorker(this,q,J)}catch(Y){$=new jJ("error"),$.error(Y)}return new GZ($,q.type||"string",q.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($)}};LJ.exports=zZ});var e9=w((_O,BJ)=>{var HZ=l();function NJ(Q){this.data=Q,this.length=Q.length,this.index=0,this.zero=0}NJ.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,q;this.checkOffset(Q);for(q=this.index+Q-1;q>=this.index;q--)$=($<<8)+this.byteAt(q);return this.index+=Q,$},readString:function(Q){return HZ.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))}};BJ.exports=NJ});var QQ=w((bO,PJ)=>{var MJ=e9(),FZ=l();function I6(Q){MJ.call(this,Q);for(var $=0;$<this.data.length;$++)Q[$]=Q[$]&255}FZ.inherits(I6,MJ);I6.prototype.byteAt=function(Q){return this.data[this.zero+Q]};I6.prototype.lastIndexOfSignature=function(Q){var $=Q.charCodeAt(0),q=Q.charCodeAt(1),J=Q.charCodeAt(2),Y=Q.charCodeAt(3);for(var V=this.length-4;V>=0;--V)if(this.data[V]===$&&this.data[V+1]===q&&this.data[V+2]===J&&this.data[V+3]===Y)return V-this.zero;return-1};I6.prototype.readAndCheckSignature=function(Q){var $=Q.charCodeAt(0),q=Q.charCodeAt(1),J=Q.charCodeAt(2),Y=Q.charCodeAt(3),V=this.readData(4);return $===V[0]&&q===V[1]&&J===V[2]&&Y===V[3]};I6.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,$};PJ.exports=I6});var TJ=w((hO,CJ)=>{var IJ=e9(),LZ=l();function C6(Q){IJ.call(this,Q)}LZ.inherits(C6,IJ);C6.prototype.byteAt=function(Q){return this.data.charCodeAt(this.zero+Q)};C6.prototype.lastIndexOfSignature=function(Q){return this.data.lastIndexOf(Q)-this.zero};C6.prototype.readAndCheckSignature=function(Q){var $=this.readData(4);return Q===$};C6.prototype.readData=function(Q){this.checkOffset(Q);var $=this.data.slice(this.zero+this.index,this.zero+this.index+Q);return this.index+=Q,$};CJ.exports=C6});var qQ=w((fO,DJ)=>{var AJ=QQ(),OZ=l();function $Q(Q){AJ.call(this,Q)}OZ.inherits($Q,AJ);$Q.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,$};DJ.exports=$Q});var xJ=w((mO,RJ)=>{var wJ=qQ(),NZ=l();function JQ(Q){wJ.call(this,Q)}NZ.inherits(JQ,wJ);JQ.prototype.readData=function(Q){this.checkOffset(Q);var $=this.data.slice(this.zero+this.index,this.zero+this.index+Q);return this.index+=Q,$};RJ.exports=JQ});var YQ=w((cO,SJ)=>{var R2=l(),vJ=W1(),BZ=QQ(),MZ=TJ(),PZ=xJ(),IZ=qQ();SJ.exports=function(Q){var $=R2.getTypeOf(Q);if(R2.checkSupport($),$==="string"&&!vJ.uint8array)return new MZ(Q);if($==="nodebuffer")return new PZ(Q);if(vJ.uint8array)return new IZ(R2.transformTo("uint8array",Q));return new BZ(R2.transformTo("array",Q))}});var gJ=w((uO,yJ)=>{var VQ=YQ(),w1=l(),CZ=G2(),EJ=K2(),x2=U6(),v2=a9(),TZ=W1(),AZ=0,DZ=3,wZ=function(Q){for(var $ in v2){if(!Object.prototype.hasOwnProperty.call(v2,$))continue;if(v2[$].magic===Q)return v2[$]}return null};function kJ(Q,$){this.options=Q,this.loadOptions=$}kJ.prototype={isEncrypted:function(){return(this.bitFlag&1)===1},useUTF8:function(){return(this.bitFlag&2048)===2048},readLocalPart:function(Q){var $,q;if(Q.skip(22),this.fileNameLength=Q.readInt(2),q=Q.readInt(2),this.fileName=Q.readData(this.fileNameLength),Q.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($=wZ(this.compressionMethod),$===null)throw Error("Corrupted zip : compression "+w1.pretty(this.compressionMethod)+" unknown (inner file : "+w1.transformTo("string",this.fileName)+")");this.decompressed=new CZ(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===AZ)this.dosPermissions=this.externalFileAttributes&63;if(Q===DZ)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=VQ(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,q,J,Y;if(!this.extraFields)this.extraFields={};while(Q.index+4<$)q=Q.readInt(2),J=Q.readInt(2),Y=Q.readData(J),this.extraFields[q]={id:q,length:J,value:Y};Q.setIndex($)},handleUTF8:function(){var Q=TZ.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=x2.utf8decode(this.fileName),this.fileCommentStr=x2.utf8decode(this.fileComment);else{var $=this.findExtraFieldUnicodePath();if($!==null)this.fileNameStr=$;else{var q=w1.transformTo(Q,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(q)}var J=this.findExtraFieldUnicodeComment();if(J!==null)this.fileCommentStr=J;else{var Y=w1.transformTo(Q,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(Y)}}},findExtraFieldUnicodePath:function(){var Q=this.extraFields[28789];if(Q){var $=VQ(Q.value);if($.readInt(1)!==1)return null;if(EJ(this.fileName)!==$.readInt(4))return null;return x2.utf8decode($.readData(Q.length-5))}return null},findExtraFieldUnicodeComment:function(){var Q=this.extraFields[25461];if(Q){var $=VQ(Q.value);if($.readInt(1)!==1)return null;if(EJ(this.fileComment)!==$.readInt(4))return null;return x2.utf8decode($.readData(Q.length-5))}return null}};yJ.exports=kJ});var hJ=w((pO,bJ)=>{var RZ=YQ(),z1=l(),m0=s9(),xZ=gJ(),vZ=W1();function _J(Q){this.files=[],this.loadOptions=Q}_J.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 q=this.reader.index;this.reader.setIndex(Q);var J=this.reader.readString(4),Y=J===$;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 Q=this.reader.readData(this.zipCommentLength),$=vZ.uint8array?"uint8array":"array",q=z1.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 Q=this.zip64EndOfCentralSize-44,$=0,q,J,Y;while($<Q)q=this.reader.readInt(2),J=this.reader.readInt(4),Y=this.reader.readData(J),this.zip64ExtensibleData[q]={id:q,length:J,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(m0.LOCAL_FILE_HEADER),$.readLocalPart(this.reader),$.handleUTF8(),$.processAttributes()},readCentralDir:function(){var Q;this.reader.setIndex(this.centralDirOffset);while(this.reader.readAndCheckSignature(m0.CENTRAL_FILE_HEADER))Q=new xZ({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(m0.CENTRAL_DIRECTORY_END);if(Q<0){var $=!this.isSignature(0,m0.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 q=Q;if(this.checkSignature(m0.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(m0.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(m0.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,m0.ZIP64_CENTRAL_DIRECTORY_END)){if(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(m0.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(m0.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var J=this.centralDirOffset+this.centralDirSize;if(this.zip64)J+=20,J+=12+this.zip64EndOfCentralSize;var Y=q-J;if(Y>0)if(this.isSignature(q,m0.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=RZ(Q)},load:function(Q){this.prepareReader(Q),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}};bJ.exports=_J});var cJ=w((dO,mJ)=>{var XQ=l(),S2=K6(),SZ=U6(),EZ=hJ(),kZ=X9(),fJ=o6();function yZ(Q){return new S2.Promise(function($,q){var J=Q.decompressed.getContentWorker().pipe(new kZ);J.on("error",function(Y){q(Y)}).on("end",function(){if(J.streamInfo.crc32!==Q.decompressed.crc32)q(Error("Corrupted zip : CRC32 mismatch"));else $()}).resume()})}mJ.exports=function(Q,$){var q=this;if($=XQ.extend($||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:SZ.utf8decode}),fJ.isNode&&fJ.isStream(Q))return S2.Promise.reject(Error("JSZip can't accept a stream when loading a zip file."));return XQ.prepareContent("the loaded zip file",Q,!0,$.optimizedBinaryString,$.base64).then(function(J){var Y=new EZ($);return Y.load(J),Y}).then(function(Y){var V=[S2.Promise.resolve(Y)],X=Y.files;if($.checkCRC32)for(var K=0;K<X.length;K++)V.push(yZ(X[K]));return S2.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=XQ.resolve(W.fileNameStr);if(q.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)q.file(U).unsafeOriginalName=G}if(V.zipComment.length)q.comment=V.zipComment;return q})}});var pJ=w((lO,uJ)=>{function S0(){if(!(this instanceof S0))return new S0;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 S0;for(var $ in this)if(typeof this[$]!=="function")Q[$]=this[$];return Q}}S0.prototype=OJ();S0.prototype.loadAsync=cJ();S0.support=W1();S0.defaults=J9();S0.version="3.10.1";S0.loadAsync=function(Q,$){return new S0().loadAsync(Q,$)};S0.external=K6();uJ.exports=S0});var R1=w((oO,KQ)=>{var k2=process||{},dJ=k2.argv||[],E2=k2.env||{},gZ=!(!!E2.NO_COLOR||dJ.includes("--no-color"))&&(!!E2.FORCE_COLOR||dJ.includes("--color")||k2.platform==="win32"||(k2.stdout||{}).isTTY&&E2.TERM!=="dumb"||!!E2.CI),_Z=(Q,$,q=Q)=>(J)=>{let Y=""+J,V=Y.indexOf($,Q.length);return~V?Q+bZ(Y,$,q,V)+$:Q+Y+$},bZ=(Q,$,q,J)=>{let Y="",V=0;do Y+=Q.substring(V,J)+q,V=J+$.length,J=Q.indexOf($,V);while(~J);return Y+Q.substring(V)},lJ=(Q=gZ)=>{let $=Q?_Z:()=>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")}};KQ.exports=lJ();KQ.exports.createColors=lJ});import{homedir as $z}from"node:os";import u from"node:path";function qz(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"),q=u.join(e,".gemini","antigravity","mcp_config.json"),J=u.join(e,".antigravity","mcp_config.json");if(process.platform==="win32")return[$,q,J];return[q,J,$]}async function UY(){let{stat:Q}=await import("node:fs/promises"),[$,...q]=v1();for(let J of[$,...q])try{return await Q(J),J}catch{}return $}function jY(){let[Q]=v1();return Q}function Jz(){return u.dirname(jY())}function S1(){return u.join(e,".gemini","antigravity","skills","petdex")}function P0(Q,$,q,J){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",` ${Yz(Q,q,J)};`,"fi"].join(" ")}`}function Yz(Q,$,q){let J=q!=null?`{"state":"${$}","duration":${q},"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 ${r1}`,'-H "Content-Type: application/json"','-H "X-Petdex-Update-Token: $T"',`--data-raw '${J}'`,">/dev/null 2>&1 || true"].join(" ")}function Vz(){let Q=r1.replace(/\/state$/,"/bubble");return String.raw`// petdex hook plugin. Auto-generated by 'petdex hooks install'.
77
+ `)},info:(Q,$)=>{i.message(Q,{...$,symbol:I("blue",pV)})},success:(Q,$)=>{i.message(Q,{...$,symbol:I("green",dV)})},step:(Q,$)=>{i.message(Q,{...$,symbol:I("green",f8)})},warn:(Q,$)=>{i.message(Q,{...$,symbol:I("yellow",lV)})},warning:(Q,$)=>{i.warn(Q,$)},error:(Q,$)=>{i.message(Q,{...$,symbol:I("red",oV)})}},hL={light:b("─","-"),heavy:b("━","="),block:b("█","#")},fL=`${I("gray",y)} `});var g6=D((cL,I5)=>{if(typeof process>"u"||!process.version||process.version.indexOf("v0.")===0||process.version.indexOf("v1.")===0&&process.version.indexOf("v1.8.")!==0)I5.exports={nextTick:sV};else I5.exports=process;function sV(Q,$,q,J){if(typeof Q!=="function")throw TypeError('"callback" argument must be a function');var Y=arguments.length,V,K;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,$,q)});case 4:return process.nextTick(function(){Q.call(null,$,q,J)});default:V=Array(Y-1),K=0;while(K<V.length)V[K++]=arguments[K];return process.nextTick(function(){Q.apply(null,V)})}}});var y7=D((uL,k7)=>{var tV={}.toString;k7.exports=Array.isArray||function(Q){return tV.call(Q)=="[object Array]"}});var _6=D((C5,_7)=>{var c8=_("buffer"),K1=c8.Buffer;function g7(Q,$){for(var q in Q)$[q]=Q[q]}if(K1.from&&K1.alloc&&K1.allocUnsafe&&K1.allocUnsafeSlow)_7.exports=c8;else g7(c8,C5),C5.Buffer=e1;function e1(Q,$,q){return K1(Q,$,q)}g7(K1,e1);e1.from=function(Q,$,q){if(typeof Q==="number")throw TypeError("Argument must not be a number");return K1(Q,$,q)};e1.alloc=function(Q,$,q){if(typeof Q!=="number")throw TypeError("Argument must be a number");var J=K1(Q);if($!==void 0)if(typeof q==="string")J.fill($,q);else J.fill($);else J.fill(0);return J};e1.allocUnsafe=function(Q){if(typeof Q!=="number")throw TypeError("Argument must be a number");return K1(Q)};e1.allocUnsafeSlow=function(Q){if(typeof Q!=="number")throw TypeError("Argument must be a number");return c8.SlowBuffer(Q)}});var Q6=D((HK)=>{function eV(Q){if(Array.isArray)return Array.isArray(Q);return u8(Q)==="[object Array]"}HK.isArray=eV;function QK(Q){return typeof Q==="boolean"}HK.isBoolean=QK;function $K(Q){return Q===null}HK.isNull=$K;function qK(Q){return Q==null}HK.isNullOrUndefined=qK;function JK(Q){return typeof Q==="number"}HK.isNumber=JK;function YK(Q){return typeof Q==="string"}HK.isString=YK;function VK(Q){return typeof Q==="symbol"}HK.isSymbol=VK;function KK(Q){return Q===void 0}HK.isUndefined=KK;function XK(Q){return u8(Q)==="[object RegExp]"}HK.isRegExp=XK;function GK(Q){return typeof Q==="object"&&Q!==null}HK.isObject=GK;function WK(Q){return u8(Q)==="[object Date]"}HK.isDate=WK;function jK(Q){return u8(Q)==="[object Error]"||Q instanceof Error}HK.isError=jK;function ZK(Q){return typeof Q==="function"}HK.isFunction=ZK;function UK(Q){return Q===null||typeof Q==="boolean"||typeof Q==="number"||typeof Q==="string"||typeof Q==="symbol"||typeof Q>"u"}HK.isPrimitive=UK;HK.isBuffer=_("buffer").Buffer.isBuffer;function u8(Q){return Object.prototype.toString.call(Q)}});var b7=D((dL,T5)=>{if(typeof Object.create==="function")T5.exports=function($,q){if(q)$.super_=q,$.prototype=Object.create(q.prototype,{constructor:{value:$,enumerable:!1,writable:!0,configurable:!0}})};else T5.exports=function($,q){if(q){$.super_=q;var J=function(){};J.prototype=q.prototype,$.prototype=new J,$.prototype.constructor=$}}});var $6=D((lL,A5)=>{try{if(p8=_("util"),typeof p8.inherits!=="function")throw"";A5.exports=p8.inherits}catch(Q){A5.exports=b7()}var p8});var f7=D((oL,w5)=>{function xK(Q,$){if(!(Q instanceof $))throw TypeError("Cannot call a class as a function")}var h7=_6().Buffer,b6=_("util");function vK(Q,$,q){Q.copy($,q)}w5.exports=function(){function Q(){xK(this,Q),this.head=null,this.tail=null,this.length=0}return Q.prototype.push=function(q){var J={data:q,next:null};if(this.length>0)this.tail.next=J;else this.head=J;this.tail=J,++this.length},Q.prototype.unshift=function(q){var J={data:q,next:this.head};if(this.length===0)this.tail=J;this.head=J,++this.length},Q.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},Q.prototype.clear=function(){this.head=this.tail=null,this.length=0},Q.prototype.join=function(q){if(this.length===0)return"";var J=this.head,Y=""+J.data;while(J=J.next)Y+=q+J.data;return Y},Q.prototype.concat=function(q){if(this.length===0)return h7.alloc(0);var J=h7.allocUnsafe(q>>>0),Y=this.head,V=0;while(Y)vK(Y.data,J,V),V+=Y.data.length,Y=Y.next;return J},Q}();if(b6&&b6.inspect&&b6.inspect.custom)w5.exports.prototype[b6.inspect.custom]=function(){var Q=b6.inspect({length:this.length});return this.constructor.name+" "+Q}});var D5=D((iL,m7)=>{var d8=g6();function SK(Q,$){var q=this,J=this._readableState&&this._readableState.destroyed,Y=this._writableState&&this._writableState.destroyed;if(J||Y){if($)$(Q);else if(Q){if(!this._writableState)d8.nextTick(l8,this,Q);else if(!this._writableState.errorEmitted)this._writableState.errorEmitted=!0,d8.nextTick(l8,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(!q._writableState)d8.nextTick(l8,q,V);else if(!q._writableState.errorEmitted)q._writableState.errorEmitted=!0,d8.nextTick(l8,q,V)}else if($)$(V)}),this}function EK(){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 l8(Q,$){Q.emit("error",$)}m7.exports={destroy:SK,undestroy:EK}});var u7=D((nL,c7)=>{c7.exports=_("util").deprecate});var x5=D((rL,a7)=>{var _1=g6();a7.exports=a;function d7(Q){var $=this;this.next=null,this.entry=null,this.finish=function(){aK($,Q)}}var kK=["v0.10","v0.9."].indexOf(process.version.slice(0,5))>-1?setImmediate:_1.nextTick,q6;a.WritableState=f6;var l7=Object.create(Q6());l7.inherits=$6();var yK={deprecate:u7()},o7=_("stream"),i8=_6().Buffer,gK=(typeof global<"u"?global:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function _K(Q){return i8.from(Q)}function bK(Q){return i8.isBuffer(Q)||Q instanceof gK}var i7=D5();l7.inherits(a,o7);function hK(){}function f6(Q,$){q6=q6||b1(),Q=Q||{};var q=$ instanceof q6;if(this.objectMode=!!Q.objectMode,q)this.objectMode=this.objectMode||!!Q.writableObjectMode;var{highWaterMark:J,writableHighWaterMark:Y}=Q,V=this.objectMode?16:16384;if(J||J===0)this.highWaterMark=J;else if(q&&(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 K=Q.decodeStrings===!1;this.decodeStrings=!K,this.defaultEncoding=Q.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(X){lK($,X)},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 d7(this)}f6.prototype.getBuffer=function(){var $=this.bufferedRequest,q=[];while($)q.push($),$=$.next;return q};(function(){try{Object.defineProperty(f6.prototype,"buffer",{get:yK.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(Q){}})();var o8;if(typeof Symbol==="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]==="function")o8=Function.prototype[Symbol.hasInstance],Object.defineProperty(a,Symbol.hasInstance,{value:function(Q){if(o8.call(this,Q))return!0;if(this!==a)return!1;return Q&&Q._writableState instanceof f6}});else o8=function(Q){return Q instanceof this};function a(Q){if(q6=q6||b1(),!o8.call(a,this)&&!(this instanceof q6))return new a(Q);if(this._writableState=new f6(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}o7.call(this)}a.prototype.pipe=function(){this.emit("error",Error("Cannot pipe, not readable"))};function fK(Q,$){var q=Error("write after end");Q.emit("error",q),_1.nextTick($,q)}function mK(Q,$,q,J){var Y=!0,V=!1;if(q===null)V=TypeError("May not write null values to stream");else if(typeof q!=="string"&&q!==void 0&&!$.objectMode)V=TypeError("Invalid non-string/buffer chunk");if(V)Q.emit("error",V),_1.nextTick(J,V),Y=!1;return Y}a.prototype.write=function(Q,$,q){var J=this._writableState,Y=!1,V=!J.objectMode&&bK(Q);if(V&&!i8.isBuffer(Q))Q=_K(Q);if(typeof $==="function")q=$,$=null;if(V)$="buffer";else if(!$)$=J.defaultEncoding;if(typeof q!=="function")q=hK;if(J.ended)fK(this,q);else if(V||mK(this,J,Q,q))J.pendingcb++,Y=uK(this,J,V,Q,$,q);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)n7(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 cK(Q,$,q){if(!Q.objectMode&&Q.decodeStrings!==!1&&typeof $==="string")$=i8.from($,q);return $}Object.defineProperty(a.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function uK(Q,$,q,J,Y,V){if(!q){var K=cK($,J,Y);if(J!==K)q=!0,Y="buffer",J=K}var X=$.objectMode?1:J.length;$.length+=X;var W=$.length<$.highWaterMark;if(!W)$.needDrain=!0;if($.writing||$.corked){var G=$.lastBufferedRequest;if($.lastBufferedRequest={chunk:J,encoding:Y,isBuf:q,callback:V,next:null},G)G.next=$.lastBufferedRequest;else $.bufferedRequest=$.lastBufferedRequest;$.bufferedRequestCount+=1}else R5(Q,$,!1,X,J,Y,V);return W}function R5(Q,$,q,J,Y,V,K){if($.writelen=J,$.writecb=K,$.writing=!0,$.sync=!0,q)Q._writev(Y,$.onwrite);else Q._write(Y,V,$.onwrite);$.sync=!1}function pK(Q,$,q,J,Y){if(--$.pendingcb,q)_1.nextTick(Y,J),_1.nextTick(h6,Q,$),Q._writableState.errorEmitted=!0,Q.emit("error",J);else Y(J),Q._writableState.errorEmitted=!0,Q.emit("error",J),h6(Q,$)}function dK(Q){Q.writing=!1,Q.writecb=null,Q.length-=Q.writelen,Q.writelen=0}function lK(Q,$){var q=Q._writableState,J=q.sync,Y=q.writecb;if(dK(q),$)pK(Q,q,J,$,Y);else{var V=r7(q);if(!V&&!q.corked&&!q.bufferProcessing&&q.bufferedRequest)n7(Q,q);if(J)kK(p7,Q,q,V,Y);else p7(Q,q,V,Y)}}function p7(Q,$,q,J){if(!q)oK(Q,$);$.pendingcb--,J(),h6(Q,$)}function oK(Q,$){if($.length===0&&$.needDrain)$.needDrain=!1,Q.emit("drain")}function n7(Q,$){$.bufferProcessing=!0;var q=$.bufferedRequest;if(Q._writev&&q&&q.next){var J=$.bufferedRequestCount,Y=Array(J),V=$.corkedRequestsFree;V.entry=q;var K=0,X=!0;while(q){if(Y[K]=q,!q.isBuf)X=!1;q=q.next,K+=1}if(Y.allBuffers=X,R5(Q,$,!0,$.length,Y,"",V.finish),$.pendingcb++,$.lastBufferedRequest=null,V.next)$.corkedRequestsFree=V.next,V.next=null;else $.corkedRequestsFree=new d7($);$.bufferedRequestCount=0}else{while(q){var{chunk:W,encoding:G,callback:j}=q,H=$.objectMode?1:W.length;if(R5(Q,$,!1,H,W,G,j),q=q.next,$.bufferedRequestCount--,$.writing)break}if(q===null)$.lastBufferedRequest=null}$.bufferedRequest=q,$.bufferProcessing=!1}a.prototype._write=function(Q,$,q){q(Error("_write() is not implemented"))};a.prototype._writev=null;a.prototype.end=function(Q,$,q){var J=this._writableState;if(typeof Q==="function")q=Q,Q=null,$=null;else if(typeof $==="function")q=$,$=null;if(Q!==null&&Q!==void 0)this.write(Q,$);if(J.corked)J.corked=1,this.uncork();if(!J.ending)rK(this,J,q)};function r7(Q){return Q.ending&&Q.length===0&&Q.bufferedRequest===null&&!Q.finished&&!Q.writing}function iK(Q,$){Q._final(function(q){if($.pendingcb--,q)Q.emit("error",q);$.prefinished=!0,Q.emit("prefinish"),h6(Q,$)})}function nK(Q,$){if(!$.prefinished&&!$.finalCalled)if(typeof Q._final==="function")$.pendingcb++,$.finalCalled=!0,_1.nextTick(iK,Q,$);else $.prefinished=!0,Q.emit("prefinish")}function h6(Q,$){var q=r7($);if(q){if(nK(Q,$),$.pendingcb===0)$.finished=!0,Q.emit("finish")}return q}function rK(Q,$,q){if($.ending=!0,h6(Q,$),q)if($.finished)_1.nextTick(q);else Q.once("finish",q);$.ended=!0,Q.writable=!1}function aK(Q,$,q){var J=Q.entry;Q.entry=null;while(J){var Y=J.callback;$.pendingcb--,Y(q),J=J.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=i7.destroy;a.prototype._undestroy=i7.undestroy;a.prototype._destroy=function(Q,$){this.end(),$(Q)}});var b1=D((aL,Q4)=>{var s7=g6(),sK=Object.keys||function(Q){var $=[];for(var q in Q)$.push(q);return $};Q4.exports=X1;var t7=Object.create(Q6());t7.inherits=$6();var e7=S5(),v5=x5();t7.inherits(X1,e7);{n8=sK(v5.prototype);for(m6=0;m6<n8.length;m6++)if(c6=n8[m6],!X1.prototype[c6])X1.prototype[c6]=v5.prototype[c6]}var n8,c6,m6;function X1(Q){if(!(this instanceof X1))return new X1(Q);if(e7.call(this,Q),v5.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",tK)}Object.defineProperty(X1.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function tK(){if(this.allowHalfOpen||this._writableState.ended)return;s7.nextTick(eK,this)}function eK(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(),s7.nextTick($,Q)}});var y5=D((HX)=>{var k5=_6().Buffer,$4=k5.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 QX(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 $X(Q){var $=QX(Q);if(typeof $!=="string"&&(k5.isEncoding===$4||!$4(Q)))throw Error("Unknown encoding: "+Q);return $||Q}HX.StringDecoder=u6;function u6(Q){this.encoding=$X(Q);var $;switch(this.encoding){case"utf16le":this.text=XX,this.end=GX,$=4;break;case"utf8":this.fillLast=YX,$=4;break;case"base64":this.text=WX,this.end=jX,$=3;break;default:this.write=ZX,this.end=UX;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=k5.allocUnsafe($)}u6.prototype.write=function(Q){if(Q.length===0)return"";var $,q;if(this.lastNeed){if($=this.fillLast(Q),$===void 0)return"";q=this.lastNeed,this.lastNeed=0}else q=0;if(q<Q.length)return $?$+this.text(Q,q):this.text(Q,q);return $||""};u6.prototype.end=KX;u6.prototype.text=VX;u6.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 E5(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 qX(Q,$,q){var J=$.length-1;if(J<q)return 0;var Y=E5($[J]);if(Y>=0){if(Y>0)Q.lastNeed=Y-1;return Y}if(--J<q||Y===-2)return 0;if(Y=E5($[J]),Y>=0){if(Y>0)Q.lastNeed=Y-2;return Y}if(--J<q||Y===-2)return 0;if(Y=E5($[J]),Y>=0){if(Y>0)if(Y===2)Y=0;else Q.lastNeed=Y-3;return Y}return 0}function JX(Q,$,q){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 YX(Q){var $=this.lastTotal-this.lastNeed,q=JX(this,Q,$);if(q!==void 0)return q;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 VX(Q,$){var q=qX(this,Q,$);if(!this.lastNeed)return Q.toString("utf8",$);this.lastTotal=q;var J=Q.length-(q-this.lastNeed);return Q.copy(this.lastChar,0,J),Q.toString("utf8",$,J)}function KX(Q){var $=Q&&Q.length?this.write(Q):"";if(this.lastNeed)return $+"�";return $}function XX(Q,$){if((Q.length-$)%2===0){var q=Q.toString("utf16le",$);if(q){var J=q.charCodeAt(q.length-1);if(J>=55296&&J<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=Q[Q.length-2],this.lastChar[1]=Q[Q.length-1],q.slice(0,-1)}return q}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=Q[Q.length-1],Q.toString("utf16le",$,Q.length-1)}function GX(Q){var $=Q&&Q.length?this.write(Q):"";if(this.lastNeed){var q=this.lastTotal-this.lastNeed;return $+this.lastChar.toString("utf16le",0,q)}return $}function WX(Q,$){var q=(Q.length-$)%3;if(q===0)return Q.toString("base64",$);if(this.lastNeed=3-q,this.lastTotal=3,q===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-q)}function jX(Q){var $=Q&&Q.length?this.write(Q):"";if(this.lastNeed)return $+this.lastChar.toString("base64",0,3-this.lastNeed);return $}function ZX(Q){return Q.toString(this.encoding)}function UX(Q){return Q&&Q.length?this.write(Q):""}});var S5=D((eL,H4)=>{var Y6=g6();H4.exports=c;var FX=y7(),p6;c.ReadableState=G4;var tL=_("events").EventEmitter,V4=function(Q,$){return Q.listeners($).length},f5=_("stream"),d6=_6().Buffer,LX=(typeof global<"u"?global:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function OX(Q){return d6.from(Q)}function NX(Q){return d6.isBuffer(Q)||Q instanceof LX}var K4=Object.create(Q6());K4.inherits=$6();var g5=_("util"),g=void 0;if(g5&&g5.debuglog)g=g5.debuglog("stream");else g=function(){};var BX=f7(),X4=D5(),J6;K4.inherits(c,f5);var _5=["error","close","destroy","pause","resume"];function MX(Q,$,q){if(typeof Q.prependListener==="function")return Q.prependListener($,q);if(!Q._events||!Q._events[$])Q.on($,q);else if(FX(Q._events[$]))Q._events[$].unshift(q);else Q._events[$]=[q,Q._events[$]]}function G4(Q,$){p6=p6||b1(),Q=Q||{};var q=$ instanceof p6;if(this.objectMode=!!Q.objectMode,q)this.objectMode=this.objectMode||!!Q.readableObjectMode;var{highWaterMark:J,readableHighWaterMark:Y}=Q,V=this.objectMode?16:16384;if(J||J===0)this.highWaterMark=J;else if(q&&(Y||Y===0))this.highWaterMark=Y;else this.highWaterMark=V;if(this.highWaterMark=Math.floor(this.highWaterMark),this.buffer=new BX,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(!J6)J6=y5().StringDecoder;this.decoder=new J6(Q.encoding),this.encoding=Q.encoding}}function c(Q){if(p6=p6||b1(),!(this instanceof c))return new c(Q);if(this._readableState=new G4(Q,this),this.readable=!0,Q){if(typeof Q.read==="function")this._read=Q.read;if(typeof Q.destroy==="function")this._destroy=Q.destroy}f5.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=X4.destroy;c.prototype._undestroy=X4.undestroy;c.prototype._destroy=function(Q,$){this.push(null),$(Q)};c.prototype.push=function(Q,$){var q=this._readableState,J;if(!q.objectMode){if(typeof Q==="string"){if($=$||q.defaultEncoding,$!==q.encoding)Q=d6.from(Q,$),$="";J=!0}}else J=!0;return W4(this,Q,$,!1,J)};c.prototype.unshift=function(Q){return W4(this,Q,null,!0,!1)};function W4(Q,$,q,J,Y){var V=Q._readableState;if($===null)V.reading=!1,TX(Q,V);else{var K;if(!Y)K=PX(V,$);if(K)Q.emit("error",K);else if(V.objectMode||$&&$.length>0){if(typeof $!=="string"&&!V.objectMode&&Object.getPrototypeOf($)!==d6.prototype)$=OX($);if(J)if(V.endEmitted)Q.emit("error",Error("stream.unshift() after end event"));else b5(Q,V,$,!0);else if(V.ended)Q.emit("error",Error("stream.push() after EOF"));else if(V.reading=!1,V.decoder&&!q)if($=V.decoder.write($),V.objectMode||$.length!==0)b5(Q,V,$,!1);else j4(Q,V);else b5(Q,V,$,!1)}else if(!J)V.reading=!1}return IX(V)}function b5(Q,$,q,J){if($.flowing&&$.length===0&&!$.sync)Q.emit("data",q),Q.read(0);else{if($.length+=$.objectMode?1:q.length,J)$.buffer.unshift(q);else $.buffer.push(q);if($.needReadable)r8(Q)}j4(Q,$)}function PX(Q,$){var q;if(!NX($)&&typeof $!=="string"&&$!==void 0&&!Q.objectMode)q=TypeError("Invalid non-string/buffer chunk");return q}function IX(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(!J6)J6=y5().StringDecoder;return this._readableState.decoder=new J6(Q),this._readableState.encoding=Q,this};var q4=8388608;function CX(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 J4(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=CX(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,q=Q;if(Q!==0)$.emittedReadable=!1;if(Q===0&&$.needReadable&&($.length>=$.highWaterMark||$.ended)){if(g("read: emitReadable",$.length,$.ended),$.length===0&&$.ended)h5(this);else r8(this);return null}if(Q=J4(Q,$),Q===0&&$.ended){if($.length===0)h5(this);return null}var J=$.needReadable;if(g("need readable",J),$.length===0||$.length-Q<$.highWaterMark)J=!0,g("length less than watermark",J);if($.ended||$.reading)J=!1,g("reading or ended",J);else if(J){if(g("do read"),$.reading=!0,$.sync=!0,$.length===0)$.needReadable=!0;if(this._read($.highWaterMark),$.sync=!1,!$.reading)Q=J4(q,$)}var Y;if(Q>0)Y=Z4(Q,$);else Y=null;if(Y===null)$.needReadable=!0,Q=0;else $.length-=Q;if($.length===0){if(!$.ended)$.needReadable=!0;if(q!==Q&&$.ended)h5(this)}if(Y!==null)this.emit("data",Y);return Y};function TX(Q,$){if($.ended)return;if($.decoder){var q=$.decoder.end();if(q&&q.length)$.buffer.push(q),$.length+=$.objectMode?1:q.length}$.ended=!0,r8(Q)}function r8(Q){var $=Q._readableState;if($.needReadable=!1,!$.emittedReadable)if(g("emitReadable",$.flowing),$.emittedReadable=!0,$.sync)Y6.nextTick(Y4,Q);else Y4(Q)}function Y4(Q){g("emit readable"),Q.emit("readable"),m5(Q)}function j4(Q,$){if(!$.readingMore)$.readingMore=!0,Y6.nextTick(AX,Q,$)}function AX(Q,$){var q=$.length;while(!$.reading&&!$.flowing&&!$.ended&&$.length<$.highWaterMark)if(g("maybeReadMore read 0"),Q.read(0),q===$.length)break;else q=$.length;$.readingMore=!1}c.prototype._read=function(Q){this.emit("error",Error("_read() is not implemented"))};c.prototype.pipe=function(Q,$){var q=this,J=this._readableState;switch(J.pipesCount){case 0:J.pipes=Q;break;case 1:J.pipes=[J.pipes,Q];break;default:J.pipes.push(Q);break}J.pipesCount+=1,g("pipe count=%d opts=%j",J.pipesCount,$);var Y=(!$||$.end!==!1)&&Q!==process.stdout&&Q!==process.stderr,V=Y?X:C;if(J.endEmitted)Y6.nextTick(V);else q.once("end",V);Q.on("unpipe",K);function K(P,L){if(g("onunpipe"),P===q){if(L&&L.hasUnpiped===!1)L.hasUnpiped=!0,j()}}function X(){g("onend"),Q.end()}var W=wX(q);Q.on("drain",W);var G=!1;function j(){if(g("cleanup"),Q.removeListener("close",F),Q.removeListener("finish",N),Q.removeListener("drain",W),Q.removeListener("error",z),Q.removeListener("unpipe",K),q.removeListener("end",X),q.removeListener("end",C),q.removeListener("data",U),G=!0,J.awaitDrain&&(!Q._writableState||Q._writableState.needDrain))W()}var H=!1;q.on("data",U);function U(P){g("ondata"),H=!1;var L=Q.write(P);if(L===!1&&!H){if((J.pipesCount===1&&J.pipes===Q||J.pipesCount>1&&U4(J.pipes,Q)!==-1)&&!G)g("false write response, pause",J.awaitDrain),J.awaitDrain++,H=!0;q.pause()}}function z(P){if(g("onerror",P),C(),Q.removeListener("error",z),V4(Q,"error")===0)Q.emit("error",P)}MX(Q,"error",z);function F(){Q.removeListener("finish",N),C()}Q.once("close",F);function N(){g("onfinish"),Q.removeListener("close",F),C()}Q.once("finish",N);function C(){g("unpipe"),q.unpipe(Q)}if(Q.emit("pipe",q),!J.flowing)g("pipe resume"),q.resume();return Q};function wX(Q){return function(){var $=Q._readableState;if(g("pipeOnDrain",$.awaitDrain),$.awaitDrain)$.awaitDrain--;if($.awaitDrain===0&&V4(Q,"data"))$.flowing=!0,m5(Q)}}c.prototype.unpipe=function(Q){var $=this._readableState,q={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,q);return this}if(!Q){var{pipes:J,pipesCount:Y}=$;$.pipes=null,$.pipesCount=0,$.flowing=!1;for(var V=0;V<Y;V++)J[V].emit("unpipe",this,{hasUnpiped:!1});return this}var K=U4($.pipes,Q);if(K===-1)return this;if($.pipes.splice(K,1),$.pipesCount-=1,$.pipesCount===1)$.pipes=$.pipes[0];return Q.emit("unpipe",this,q),this};c.prototype.on=function(Q,$){var q=f5.prototype.on.call(this,Q,$);if(Q==="data"){if(this._readableState.flowing!==!1)this.resume()}else if(Q==="readable"){var J=this._readableState;if(!J.endEmitted&&!J.readableListening){if(J.readableListening=J.needReadable=!0,J.emittedReadable=!1,!J.reading)Y6.nextTick(DX,this);else if(J.length)r8(this)}}return q};c.prototype.addListener=c.prototype.on;function DX(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,RX(this,Q);return this};function RX(Q,$){if(!$.resumeScheduled)$.resumeScheduled=!0,Y6.nextTick(xX,Q,$)}function xX(Q,$){if(!$.reading)g("resume read 0"),Q.read(0);if($.resumeScheduled=!1,$.awaitDrain=0,Q.emit("resume"),m5(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 m5(Q){var $=Q._readableState;g("flow",$.flowing);while($.flowing&&Q.read()!==null);}c.prototype.wrap=function(Q){var $=this,q=this._readableState,J=!1;Q.on("end",function(){if(g("wrapped end"),q.decoder&&!q.ended){var K=q.decoder.end();if(K&&K.length)$.push(K)}$.push(null)}),Q.on("data",function(K){if(g("wrapped data"),q.decoder)K=q.decoder.write(K);if(q.objectMode&&(K===null||K===void 0))return;else if(!q.objectMode&&(!K||!K.length))return;var X=$.push(K);if(!X)J=!0,Q.pause()});for(var Y in Q)if(this[Y]===void 0&&typeof Q[Y]==="function")this[Y]=function(K){return function(){return Q[K].apply(Q,arguments)}}(Y);for(var V=0;V<_5.length;V++)Q.on(_5[V],this.emit.bind(this,_5[V]));return this._read=function(K){if(g("wrapped _read",K),J)J=!1,Q.resume()},this};Object.defineProperty(c.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}});c._fromList=Z4;function Z4(Q,$){if($.length===0)return null;var q;if($.objectMode)q=$.buffer.shift();else if(!Q||Q>=$.length){if($.decoder)q=$.buffer.join("");else if($.buffer.length===1)q=$.buffer.head.data;else q=$.buffer.concat($.length);$.buffer.clear()}else q=vX(Q,$.buffer,$.decoder);return q}function vX(Q,$,q){var J;if(Q<$.head.data.length)J=$.head.data.slice(0,Q),$.head.data=$.head.data.slice(Q);else if(Q===$.head.data.length)J=$.shift();else J=q?SX(Q,$):EX(Q,$);return J}function SX(Q,$){var q=$.head,J=1,Y=q.data;Q-=Y.length;while(q=q.next){var V=q.data,K=Q>V.length?V.length:Q;if(K===V.length)Y+=V;else Y+=V.slice(0,Q);if(Q-=K,Q===0){if(K===V.length)if(++J,q.next)$.head=q.next;else $.head=$.tail=null;else $.head=q,q.data=V.slice(K);break}++J}return $.length-=J,Y}function EX(Q,$){var q=d6.allocUnsafe(Q),J=$.head,Y=1;J.data.copy(q),Q-=J.data.length;while(J=J.next){var V=J.data,K=Q>V.length?V.length:Q;if(V.copy(q,q.length-Q,0,K),Q-=K,Q===0){if(K===V.length)if(++Y,J.next)$.head=J.next;else $.head=$.tail=null;else $.head=J,J.data=V.slice(K);break}++Y}return $.length-=Y,q}function h5(Q){var $=Q._readableState;if($.length>0)throw Error('"endReadable()" called on non-empty stream');if(!$.endEmitted)$.ended=!0,Y6.nextTick(kX,$,Q)}function kX(Q,$){if(!Q.endEmitted&&Q.length===0)Q.endEmitted=!0,$.readable=!1,$.emit("end")}function U4(Q,$){for(var q=0,J=Q.length;q<J;q++)if(Q[q]===$)return q;return-1}});var c5=D((QO,L4)=>{L4.exports=G1;var a8=b1(),F4=Object.create(Q6());F4.inherits=$6();F4.inherits(G1,a8);function yX(Q,$){var q=this._transformState;q.transforming=!1;var J=q.writecb;if(!J)return this.emit("error",Error("write callback called multiple times"));if(q.writechunk=null,q.writecb=null,$!=null)this.push($);J(Q);var Y=this._readableState;if(Y.reading=!1,Y.needReadable||Y.length<Y.highWaterMark)this._read(Y.highWaterMark)}function G1(Q){if(!(this instanceof G1))return new G1(Q);if(a8.call(this,Q),this._transformState={afterTransform:yX.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",gX)}function gX(){var Q=this;if(typeof this._flush==="function")this._flush(function($,q){z4(Q,$,q)});else z4(this,null,null)}G1.prototype.push=function(Q,$){return this._transformState.needTransform=!1,a8.prototype.push.call(this,Q,$)};G1.prototype._transform=function(Q,$,q){throw Error("_transform() is not implemented")};G1.prototype._write=function(Q,$,q){var J=this._transformState;if(J.writecb=q,J.writechunk=Q,J.writeencoding=$,!J.transforming){var Y=this._readableState;if(J.needTransform||Y.needReadable||Y.length<Y.highWaterMark)this._read(Y.highWaterMark)}};G1.prototype._read=function(Q){var $=this._transformState;if($.writechunk!==null&&$.writecb&&!$.transforming)$.transforming=!0,this._transform($.writechunk,$.writeencoding,$.afterTransform);else $.needTransform=!0};G1.prototype._destroy=function(Q,$){var q=this;a8.prototype._destroy.call(this,Q,function(J){$(J),q.emit("close")})};function z4(Q,$,q){if($)return Q.emit("error",$);if(q!=null)Q.push(q);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 M4=D(($O,B4)=>{B4.exports=l6;var O4=c5(),N4=Object.create(Q6());N4.inherits=$6();N4.inherits(l6,O4);function l6(Q){if(!(this instanceof l6))return new l6(Q);O4.call(this,Q)}l6.prototype._transform=function(Q,$,q){q(null,Q)}});var u5=D((J0,s8)=>{var l0=_("stream");if(process.env.READABLE_STREAM==="disable"&&l0)s8.exports=l0,J0=s8.exports=l0.Readable,J0.Readable=l0.Readable,J0.Writable=l0.Writable,J0.Duplex=l0.Duplex,J0.Transform=l0.Transform,J0.PassThrough=l0.PassThrough,J0.Stream=l0;else J0=s8.exports=S5(),J0.Stream=l0||J0,J0.Readable=J0,J0.Writable=x5(),J0.Duplex=b1(),J0.Transform=c5(),J0.PassThrough=M4()});var W1=D((bX)=>{bX.base64=!0;bX.array=!0;bX.string=!0;bX.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u";bX.nodebuffer=typeof Buffer<"u";bX.uint8array=typeof Uint8Array<"u";if(typeof ArrayBuffer>"u")bX.blob=!1;else{t8=new ArrayBuffer(0);try{bX.blob=new Blob([t8],{type:"application/zip"}).size===0}catch(Q){try{d5=self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder,e8=new d5,e8.append(t8),bX.blob=e8.getBlob("application/zip").size===0}catch($){bX.blob=!1}}}var t8,d5,e8;try{bX.nodestream=!!u5().Readable}catch(Q){bX.nodestream=!1}});var l5=D((oX)=>{var dX=l(),lX=W1(),o0="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";oX.encode=function(Q){var $=[],q,J,Y,V,K,X,W,G=0,j=Q.length,H=j,U=dX.getTypeOf(Q)!=="string";while(G<Q.length){if(H=j-G,!U)q=Q.charCodeAt(G++),J=G<j?Q.charCodeAt(G++):0,Y=G<j?Q.charCodeAt(G++):0;else q=Q[G++],J=G<j?Q[G++]:0,Y=G<j?Q[G++]:0;V=q>>2,K=(q&3)<<4|J>>4,X=H>1?(J&15)<<2|Y>>6:64,W=H>2?Y&63:64,$.push(o0.charAt(V)+o0.charAt(K)+o0.charAt(X)+o0.charAt(W))}return $.join("")};oX.decode=function(Q){var $,q,J,Y,V,K,X,W=0,G=0,j="data:";if(Q.substr(0,j.length)===j)throw Error("Invalid base64 input, it looks like a data url.");Q=Q.replace(/[^A-Za-z0-9+/=]/g,"");var H=Q.length*3/4;if(Q.charAt(Q.length-1)===o0.charAt(64))H--;if(Q.charAt(Q.length-2)===o0.charAt(64))H--;if(H%1!==0)throw Error("Invalid base64 input, bad content length.");var U;if(lX.uint8array)U=new Uint8Array(H|0);else U=Array(H|0);while(W<Q.length){if(Y=o0.indexOf(Q.charAt(W++)),V=o0.indexOf(Q.charAt(W++)),K=o0.indexOf(Q.charAt(W++)),X=o0.indexOf(Q.charAt(W++)),$=Y<<2|V>>4,q=(V&15)<<4|K>>2,J=(K&3)<<6|X,U[G++]=$,K!==64)U[G++]=q;if(X!==64)U[G++]=J}return U}});var o6=D((YO,P4)=>{P4.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 T4=D((KO,C4)=>{var VO=global.MutationObserver||global.WebKitMutationObserver,I4;I4=function(){process.nextTick(eX)};var rX,aX,sX,tX,o5,i6=[];function eX(){o5=!0;var Q,$,q=i6.length;while(q){$=i6,i6=[],Q=-1;while(++Q<q)$[Q]();q=i6.length}o5=!1}C4.exports=QG;function QG(Q){if(i6.push(Q)===1&&!o5)I4()}});var S4=D((XO,v4)=>{var A4=T4();function K6(){}var X0={},w4=["REJECTED"],i5=["FULFILLED"],D4=["PENDING"];V6=["UNHANDLED"];var V6;v4.exports=N1;function N1(Q){if(typeof Q!=="function")throw TypeError("resolver must be a function");if(this.state=D4,this.queue=[],this.outcome=void 0,this.handled=V6,Q!==K6)R4(this,Q)}N1.prototype.finally=function(Q){if(typeof Q!=="function")return this;var $=this.constructor;return this.then(q,J);function q(Y){function V(){return Y}return $.resolve(Q()).then(V)}function J(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===i5||typeof $!=="function"&&this.state===w4)return this;var q=new this.constructor(K6);if(this.handled===V6)this.handled=null;if(this.state!==D4){var J=this.state===i5?Q:$;n5(q,J,this.outcome)}else this.queue.push(new n6(q,Q,$));return q};function n6(Q,$,q){if(this.promise=Q,typeof $==="function")this.onFulfilled=$,this.callFulfilled=this.otherCallFulfilled;if(typeof q==="function")this.onRejected=q,this.callRejected=this.otherCallRejected}n6.prototype.callFulfilled=function(Q){X0.resolve(this.promise,Q)};n6.prototype.otherCallFulfilled=function(Q){n5(this.promise,this.onFulfilled,Q)};n6.prototype.callRejected=function(Q){X0.reject(this.promise,Q)};n6.prototype.otherCallRejected=function(Q){n5(this.promise,this.onRejected,Q)};function n5(Q,$,q){A4(function(){var J;try{J=$(q)}catch(Y){return X0.reject(Q,Y)}if(J===Q)X0.reject(Q,TypeError("Cannot resolve promise with itself"));else X0.resolve(Q,J)})}X0.resolve=function(Q,$){var q=x4($G,$);if(q.status==="error")return X0.reject(Q,q.value);var J=q.value;if(J)R4(Q,J);else{Q.state=i5,Q.outcome=$;var Y=-1,V=Q.queue.length;while(++Y<V)Q.queue[Y].callFulfilled($)}return Q};X0.reject=function(Q,$){if(Q.state=w4,Q.outcome=$,Q.handled===V6)A4(function(){if(Q.handled===V6)process.emit("unhandledRejection",$,Q)});var q=-1,J=Q.queue.length;while(++q<J)Q.queue[q].callRejected($);return Q};function $G(Q){var $=Q&&Q.then;if(Q&&(typeof Q==="object"||typeof Q==="function")&&typeof $==="function")return function(){$.apply(Q,arguments)}}function R4(Q,$){var q=!1;function J(X){if(q)return;q=!0,X0.reject(Q,X)}function Y(X){if(q)return;q=!0,X0.resolve(Q,X)}function V(){$(Y,J)}var K=x4(V);if(K.status==="error")J(K.value)}function x4(Q,$){var q={};try{q.value=Q($),q.status="success"}catch(J){q.status="error",q.value=J}return q}N1.resolve=qG;function qG(Q){if(Q instanceof this)return Q;return X0.resolve(new this(K6),Q)}N1.reject=JG;function JG(Q){var $=new this(K6);return X0.reject($,Q)}N1.all=YG;function YG(Q){var $=this;if(Object.prototype.toString.call(Q)!=="[object Array]")return this.reject(TypeError("must be an array"));var q=Q.length,J=!1;if(!q)return this.resolve([]);var Y=Array(q),V=0,K=-1,X=new this(K6);while(++K<q)W(Q[K],K);return X;function W(G,j){$.resolve(G).then(H,function(U){if(!J)J=!0,X0.reject(X,U)});function H(U){if(Y[j]=U,++V===q&&!J)J=!0,X0.resolve(X,Y)}}}N1.race=VG;function VG(Q){var $=this;if(Object.prototype.toString.call(Q)!=="[object Array]")return this.reject(TypeError("must be an array"));var q=Q.length,J=!1;if(!q)return this.resolve([]);var Y=-1,V=new this(K6);while(++Y<q)K(Q[Y]);return V;function K(X){$.resolve(X).then(function(W){if(!J)J=!0,X0.resolve(V,W)},function(W){if(!J)J=!0,X0.reject(V,W)})}}});var X6=D((GO,E4)=>{var r5=null;if(typeof Promise<"u")r5=Promise;else r5=S4();E4.exports={Promise:r5}});var y4=D((k4)=>{(function(Q,$){if(Q.setImmediate)return;var q=1,J={},Y=!1,V=Q.document,K;function X(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 J[q]=O,K(q),q++}function W(L){delete J[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 j(L){if(Y)setTimeout(j,0,L);else{var A=J[L];if(A){Y=!0;try{G(A)}finally{W(L),Y=!1}}}}function H(){K=function(L){process.nextTick(function(){j(L)})}}function U(){if(Q.postMessage&&!Q.importScripts){var L=!0,A=Q.onmessage;return Q.onmessage=function(){L=!1},Q.postMessage("","*"),Q.onmessage=A,L}}function z(){var L="setImmediate$"+Math.random()+"$",A=function(B){if(B.source===Q&&typeof B.data==="string"&&B.data.indexOf(L)===0)j(+B.data.slice(L.length))};if(Q.addEventListener)Q.addEventListener("message",A,!1);else Q.attachEvent("onmessage",A);K=function(B){Q.postMessage(L+B,"*")}}function F(){var L=new MessageChannel;L.port1.onmessage=function(A){var B=A.data;j(B)},K=function(A){L.port2.postMessage(A)}}function N(){var L=V.documentElement;K=function(A){var B=V.createElement("script");B.onreadystatechange=function(){j(A),B.onreadystatechange=null,L.removeChild(B),B=null},L.appendChild(B)}}function C(){K=function(L){setTimeout(j,0,L)}}var P=Object.getPrototypeOf&&Object.getPrototypeOf(Q);if(P=P&&P.setTimeout?P:Q,{}.toString.call(Q.process)==="[object process]")H();else if(U())z();else if(Q.MessageChannel)F();else if(V&&"onreadystatechange"in V.createElement("script"))N();else C();P.setImmediate=X,P.clearImmediate=W})(typeof self>"u"?typeof global>"u"?k4:global:self)});var l=D((GG)=>{var B1=W1(),KG=l5(),G6=o6(),a5=X6();y4();function XG(Q){var $=null;if(B1.uint8array)$=new Uint8Array(Q.length);else $=Array(Q.length);return $2(Q,$)}GG.newBlob=function(Q,$){GG.checkSupport("blob");try{return new Blob([Q],{type:$})}catch(Y){try{var q=self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder,J=new q;return J.append(Q),J.getBlob($)}catch(V){throw Error("Bug : can't construct the Blob.")}}};function r6(Q){return Q}function $2(Q,$){for(var q=0;q<Q.length;++q)$[q]=Q.charCodeAt(q)&255;return $}var Q2={stringifyByChunk:function(Q,$,q){var J=[],Y=0,V=Q.length;if(V<=q)return String.fromCharCode.apply(null,Q);while(Y<V){if($==="array"||$==="nodebuffer")J.push(String.fromCharCode.apply(null,Q.slice(Y,Math.min(Y+q,V))));else J.push(String.fromCharCode.apply(null,Q.subarray(Y,Math.min(Y+q,V))));Y+=q}return J.join("")},stringifyByChar:function(Q){var $="";for(var q=0;q<Q.length;q++)$+=String.fromCharCode(Q[q]);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,G6.allocBuffer(1)).length===1}catch(Q){return!1}}()}};function a6(Q){var $=65536,q=GG.getTypeOf(Q),J=!0;if(q==="uint8array")J=Q2.applyCanBeUsed.uint8array;else if(q==="nodebuffer")J=Q2.applyCanBeUsed.nodebuffer;if(J)while($>1)try{return Q2.stringifyByChunk(Q,q,$)}catch(Y){$=Math.floor($/2)}return Q2.stringifyByChar(Q)}GG.applyFromCharCode=a6;function q2(Q,$){for(var q=0;q<Q.length;q++)$[q]=Q[q];return $}var M1={};M1.string={string:r6,array:function(Q){return $2(Q,Array(Q.length))},arraybuffer:function(Q){return M1.string.uint8array(Q).buffer},uint8array:function(Q){return $2(Q,new Uint8Array(Q.length))},nodebuffer:function(Q){return $2(Q,G6.allocBuffer(Q.length))}};M1.array={string:a6,array:r6,arraybuffer:function(Q){return new Uint8Array(Q).buffer},uint8array:function(Q){return new Uint8Array(Q)},nodebuffer:function(Q){return G6.newBufferFrom(Q)}};M1.arraybuffer={string:function(Q){return a6(new Uint8Array(Q))},array:function(Q){return q2(new Uint8Array(Q),Array(Q.byteLength))},arraybuffer:r6,uint8array:function(Q){return new Uint8Array(Q)},nodebuffer:function(Q){return G6.newBufferFrom(new Uint8Array(Q))}};M1.uint8array={string:a6,array:function(Q){return q2(Q,Array(Q.length))},arraybuffer:function(Q){return Q.buffer},uint8array:r6,nodebuffer:function(Q){return G6.newBufferFrom(Q)}};M1.nodebuffer={string:a6,array:function(Q){return q2(Q,Array(Q.length))},arraybuffer:function(Q){return M1.nodebuffer.uint8array(Q).buffer},uint8array:function(Q){return q2(Q,new Uint8Array(Q.length))},nodebuffer:r6};GG.transformTo=function(Q,$){if(!$)$="";if(!Q)return $;GG.checkSupport(Q);var q=GG.getTypeOf($),J=M1[q][Q]($);return J};GG.resolve=function(Q){var $=Q.split("/"),q=[];for(var J=0;J<$.length;J++){var Y=$[J];if(Y==="."||Y===""&&J!==0&&J!==$.length-1)continue;else if(Y==="..")q.pop();else q.push(Y)}return q.join("/")};GG.getTypeOf=function(Q){if(typeof Q==="string")return"string";if(Object.prototype.toString.call(Q)==="[object Array]")return"array";if(B1.nodebuffer&&G6.isBuffer(Q))return"nodebuffer";if(B1.uint8array&&Q instanceof Uint8Array)return"uint8array";if(B1.arraybuffer&&Q instanceof ArrayBuffer)return"arraybuffer"};GG.checkSupport=function(Q){var $=B1[Q.toLowerCase()];if(!$)throw Error(Q+" is not supported by this platform")};GG.MAX_VALUE_16BITS=65535;GG.MAX_VALUE_32BITS=-1;GG.pretty=function(Q){var $="",q,J;for(J=0;J<(Q||"").length;J++)q=Q.charCodeAt(J),$+="\\x"+(q<16?"0":"")+q.toString(16).toUpperCase();return $};GG.delay=function(Q,$,q){setImmediate(function(){Q.apply(q||null,$||[])})};GG.inherits=function(Q,$){var q=function(){};q.prototype=$.prototype,Q.prototype=new q};GG.extend=function(){var Q={},$,q;for($=0;$<arguments.length;$++)for(q in arguments[$])if(Object.prototype.hasOwnProperty.call(arguments[$],q)&&typeof Q[q]>"u")Q[q]=arguments[$][q];return Q};GG.prepareContent=function(Q,$,q,J,Y){var V=a5.Promise.resolve($).then(function(K){var X=B1.blob&&(K instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(K))!==-1);if(X&&typeof FileReader<"u")return new a5.Promise(function(W,G){var j=new FileReader;j.onload=function(H){W(H.target.result)},j.onerror=function(H){G(H.target.error)},j.readAsArrayBuffer(K)});else return K});return V.then(function(K){var X=GG.getTypeOf(K);if(!X)return a5.Promise.reject(Error("Can't read the data of '"+Q+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"));if(X==="arraybuffer")K=GG.transformTo("uint8array",K);else if(X==="string"){if(Y)K=KG.decode(K);else if(q){if(J!==!0)K=XG(K)}}return K})}});var B0=D((ZO,h4)=>{function b4(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}b4.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 q=0;q<this._listeners[Q].length;q++)this._listeners[Q][q].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(q){$.processChunk(q)}),Q.on("end",function(){$.end()}),Q.on("error",function(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 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}};h4.exports=b4});var j6=D((CG)=>{var W6=l(),h1=W1(),BG=o6(),J2=B0(),s6=Array(256);for(i0=0;i0<256;i0++)s6[i0]=i0>=252?6:i0>=248?5:i0>=240?4:i0>=224?3:i0>=192?2:1;var i0;s6[254]=s6[254]=1;var MG=function(Q){var $,q,J,Y,V,K=Q.length,X=0;for(Y=0;Y<K;Y++){if(q=Q.charCodeAt(Y),(q&64512)===55296&&Y+1<K){if(J=Q.charCodeAt(Y+1),(J&64512)===56320)q=65536+(q-55296<<10)+(J-56320),Y++}X+=q<128?1:q<2048?2:q<65536?3:4}if(h1.uint8array)$=new Uint8Array(X);else $=Array(X);for(V=0,Y=0;V<X;Y++){if(q=Q.charCodeAt(Y),(q&64512)===55296&&Y+1<K){if(J=Q.charCodeAt(Y+1),(J&64512)===56320)q=65536+(q-55296<<10)+(J-56320),Y++}if(q<128)$[V++]=q;else if(q<2048)$[V++]=192|q>>>6,$[V++]=128|q&63;else if(q<65536)$[V++]=224|q>>>12,$[V++]=128|q>>>6&63,$[V++]=128|q&63;else $[V++]=240|q>>>18,$[V++]=128|q>>>12&63,$[V++]=128|q>>>6&63,$[V++]=128|q&63}return $},PG=function(Q,$){var q;if($=$||Q.length,$>Q.length)$=Q.length;q=$-1;while(q>=0&&(Q[q]&192)===128)q--;if(q<0)return $;if(q===0)return $;return q+s6[Q[q]]>$?q:$},IG=function(Q){var $,q,J,Y,V=Q.length,K=Array(V*2);for(q=0,$=0;$<V;){if(J=Q[$++],J<128){K[q++]=J;continue}if(Y=s6[J],Y>4){K[q++]=65533,$+=Y-1;continue}J&=Y===2?31:Y===3?15:7;while(Y>1&&$<V)J=J<<6|Q[$++]&63,Y--;if(Y>1){K[q++]=65533;continue}if(J<65536)K[q++]=J;else J-=65536,K[q++]=55296|J>>10&1023,K[q++]=56320|J&1023}if(K.length!==q)if(K.subarray)K=K.subarray(0,q);else K.length=q;return W6.applyFromCharCode(K)};CG.utf8encode=function($){if(h1.nodebuffer)return BG.newBufferFrom($,"utf-8");return MG($)};CG.utf8decode=function($){if(h1.nodebuffer)return W6.transformTo("nodebuffer",$).toString("utf-8");return $=W6.transformTo(h1.uint8array?"uint8array":"array",$),IG($)};function Y2(){J2.call(this,"utf-8 decode"),this.leftOver=null}W6.inherits(Y2,J2);Y2.prototype.processChunk=function(Q){var $=W6.transformTo(h1.uint8array?"uint8array":"array",Q.data);if(this.leftOver&&this.leftOver.length){if(h1.uint8array){var q=$;$=new Uint8Array(q.length+this.leftOver.length),$.set(this.leftOver,0),$.set(q,this.leftOver.length)}else $=this.leftOver.concat($);this.leftOver=null}var J=PG($),Y=$;if(J!==$.length)if(h1.uint8array)Y=$.subarray(0,J),this.leftOver=$.subarray(J,$.length);else Y=$.slice(0,J),this.leftOver=$.slice(J,$.length);this.push({data:CG.utf8decode(Y),meta:Q.meta})};Y2.prototype.flush=function(){if(this.leftOver&&this.leftOver.length)this.push({data:CG.utf8decode(this.leftOver),meta:{}}),this.leftOver=null};CG.Utf8DecodeWorker=Y2;function t5(){J2.call(this,"utf-8 encode")}W6.inherits(t5,J2);t5.prototype.processChunk=function(Q){this.push({data:CG.utf8encode(Q.data),meta:Q.meta})};CG.Utf8EncodeWorker=t5});var p4=D((HO,u4)=>{var m4=B0(),c4=l();function Q9(Q){m4.call(this,"ConvertWorker to "+Q),this.destType=Q}c4.inherits(Q9,m4);Q9.prototype.processChunk=function(Q){this.push({data:c4.transformTo(this.destType,Q.data),meta:Q.meta})};u4.exports=Q9});var o4=D((zO,l4)=>{var d4=u5().Readable,wG=l();wG.inherits($9,d4);function $9(Q,$,q){d4.call(this,$),this._helper=Q;var J=this;Q.on("data",function(Y,V){if(!J.push(Y))J._helper.pause();if(q)q(V)}).on("error",function(Y){J.emit("error",Y)}).on("end",function(){J.push(null)})}$9.prototype._read=function(){this._helper.resume()};l4.exports=$9});var q9=D((FO,r4)=>{var f1=l(),DG=p4(),RG=B0(),xG=l5(),vG=W1(),SG=X6(),i4=null;if(vG.nodestream)try{i4=o4()}catch(Q){}function EG(Q,$,q){switch(Q){case"blob":return f1.newBlob(f1.transformTo("arraybuffer",$),q);case"base64":return xG.encode($);default:return f1.transformTo(Q,$)}}function kG(Q,$){var q,J=0,Y=null,V=0;for(q=0;q<$.length;q++)V+=$[q].length;switch(Q){case"string":return $.join("");case"array":return Array.prototype.concat.apply([],$);case"uint8array":Y=new Uint8Array(V);for(q=0;q<$.length;q++)Y.set($[q],J),J+=$[q].length;return Y;case"nodebuffer":return Buffer.concat($);default:throw Error("concat : unsupported type '"+Q+"'")}}function yG(Q,$){return new SG.Promise(function(q,J){var Y=[],V=Q._internalType,K=Q._outputType,X=Q._mimeType;Q.on("data",function(W,G){if(Y.push(W),$)$(G)}).on("error",function(W){Y=[],J(W)}).on("end",function(){try{var W=EG(K,kG(V,Y),X);q(W)}catch(G){J(G)}Y=[]}).resume()})}function n4(Q,$,q){var J=$;switch($){case"blob":case"arraybuffer":J="uint8array";break;case"base64":J="string";break}try{this._internalType=J,this._outputType=$,this._mimeType=q,f1.checkSupport(J),this._worker=Q.pipe(new DG(J)),Q.lock()}catch(Y){this._worker=new RG("error"),this._worker.error(Y)}}n4.prototype={accumulate:function(Q){return yG(this,Q)},on:function(Q,$){var q=this;if(Q==="data")this._worker.on(Q,function(J){$.call(q,J.data,J.meta)});else this._worker.on(Q,function(){f1.delay($,arguments,q)});return this},resume:function(){return f1.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(Q){if(f1.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw Error(this._outputType+" is not supported by this method");return new i4(this,{objectMode:this._outputType!=="nodebuffer"},Q)}};r4.exports=n4});var J9=D((gG)=>{gG.base64=!1;gG.binary=!1;gG.dir=!1;gG.createFolders=!0;gG.date=null;gG.compression=null;gG.compressionOptions=null;gG.comment=null;gG.unixPermissions=null;gG.dosPermissions=null});var Y9=D((OO,a4)=>{var V2=l(),K2=B0(),oG=16384;function Z6(Q){K2.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(q){if($.dataIsReady=!0,$.data=q,$.max=q&&q.length||0,$.type=V2.getTypeOf(q),!$.isPaused)$._tickAndRepeat()},function(q){$.error(q)})}V2.inherits(Z6,K2);Z6.prototype.cleanUp=function(){K2.prototype.cleanUp.call(this),this.data=null};Z6.prototype.resume=function(){if(!K2.prototype.resume.call(this))return!1;if(!this._tickScheduled&&this.dataIsReady)this._tickScheduled=!0,V2.delay(this._tickAndRepeat,[],this);return!0};Z6.prototype._tickAndRepeat=function(){if(this._tickScheduled=!1,this.isPaused||this.isFinished)return;if(this._tick(),!this.isFinished)V2.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0};Z6.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var Q=oG,$=null,q=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,q);break;case"uint8array":$=this.data.subarray(this.index,q);break;case"array":case"nodebuffer":$=this.data.slice(this.index,q);break}return this.index=q,this.push({data:$,meta:{percent:this.max?this.index/this.max*100:0}})}};a4.exports=Z6});var X2=D((NO,t4)=>{var iG=l();function nG(){var Q,$=[];for(var q=0;q<256;q++){Q=q;for(var J=0;J<8;J++)Q=Q&1?3988292384^Q>>>1:Q>>>1;$[q]=Q}return $}var s4=nG();function rG(Q,$,q,J){var Y=s4,V=J+q;Q=Q^-1;for(var K=J;K<V;K++)Q=Q>>>8^Y[(Q^$[K])&255];return Q^-1}function aG(Q,$,q,J){var Y=s4,V=J+q;Q=Q^-1;for(var K=J;K<V;K++)Q=Q>>>8^Y[(Q^$.charCodeAt(K))&255];return Q^-1}t4.exports=function($,q){if(typeof $>"u"||!$.length)return 0;var J=iG.getTypeOf($)!=="string";if(J)return rG(q|0,$,$.length,0);else return aG(q|0,$,$.length,0)}});var K9=D((BO,Q$)=>{var e4=B0(),sG=X2(),tG=l();function V9(){e4.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}tG.inherits(V9,e4);V9.prototype.processChunk=function(Q){this.streamInfo.crc32=sG(Q.data,this.streamInfo.crc32||0),this.push(Q)};Q$.exports=V9});var q$=D((MO,$$)=>{var eG=l(),X9=B0();function G9(Q){X9.call(this,"DataLengthProbe for "+Q),this.propName=Q,this.withStreamInfo(Q,0)}eG.inherits(G9,X9);G9.prototype.processChunk=function(Q){if(Q){var $=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=$+Q.data.length}X9.prototype.processChunk.call(this,Q)};$$.exports=G9});var G2=D((PO,V$)=>{var J$=X6(),Y$=Y9(),QW=K9(),W9=q$();function j9(Q,$,q,J,Y){this.compressedSize=Q,this.uncompressedSize=$,this.crc32=q,this.compression=J,this.compressedContent=Y}j9.prototype={getContentWorker:function(){var Q=new Y$(J$.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new W9("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 Y$(J$.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}};j9.createWorkerFrom=function(Q,$,q){return Q.pipe(new QW).pipe(new W9("uncompressedSize")).pipe($.compressWorker(q)).pipe(new W9("compressedSize")).withStreamInfo("compression",$)};V$.exports=j9});var W$=D((IO,G$)=>{var $W=q9(),qW=Y9(),Z9=j6(),U9=G2(),K$=B0(),H9=function(Q,$,q){this.name=Q,this.dir=q.dir,this.date=q.date,this.comment=q.comment,this.unixPermissions=q.unixPermissions,this.dosPermissions=q.dosPermissions,this._data=$,this._dataBinary=q.binary,this.options={compression:q.compression,compressionOptions:q.compressionOptions}};H9.prototype={internalStream:function(Q){var $=null,q="string";try{if(!Q)throw Error("No output type specified.");q=Q.toLowerCase();var J=q==="string"||q==="text";if(q==="binarystring"||q==="text")q="string";$=this._decompressWorker();var Y=!this._dataBinary;if(Y&&!J)$=$.pipe(new Z9.Utf8EncodeWorker);if(!Y&&J)$=$.pipe(new Z9.Utf8DecodeWorker)}catch(V){$=new K$("error"),$.error(V)}return new $W($,q,"")},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 q=this._decompressWorker();if(!this._dataBinary)q=q.pipe(new Z9.Utf8EncodeWorker);return U9.createWorkerFrom(q,Q,$)}},_decompressWorker:function(){if(this._data instanceof U9)return this._data.getContentWorker();else if(this._data instanceof K$)return this._data;else return new qW(this._data)}};var X$=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],JW=function(){throw Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")};for(t6=0;t6<X$.length;t6++)H9.prototype[X$[t6]]=JW;var t6;G$.exports=H9});var j1=D((z9)=>{var XW=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";function GW(Q,$){return Object.prototype.hasOwnProperty.call(Q,$)}z9.assign=function(Q){var $=Array.prototype.slice.call(arguments,1);while($.length){var q=$.shift();if(!q)continue;if(typeof q!=="object")throw TypeError(q+"must be non-object");for(var J in q)if(GW(q,J))Q[J]=q[J]}return Q};z9.shrinkBuf=function(Q,$){if(Q.length===$)return Q;if(Q.subarray)return Q.subarray(0,$);return Q.length=$,Q};var WW={arraySet:function(Q,$,q,J,Y){if($.subarray&&Q.subarray){Q.set($.subarray(q,q+J),Y);return}for(var V=0;V<J;V++)Q[Y+V]=$[q+V]},flattenChunks:function(Q){var $,q,J,Y,V,K;J=0;for($=0,q=Q.length;$<q;$++)J+=Q[$].length;K=new Uint8Array(J),Y=0;for($=0,q=Q.length;$<q;$++)V=Q[$],K.set(V,Y),Y+=V.length;return K}},jW={arraySet:function(Q,$,q,J,Y){for(var V=0;V<J;V++)Q[Y+V]=$[q+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,WW);else z9.Buf8=Array,z9.Buf16=Array,z9.Buf32=Array,z9.assign(z9,jW)};z9.setTyped(XW)});var k$=D((kW)=>{var UW=j1(),HW=4,Z$=0,U$=1,zW=2;function H6(Q){var $=Q.length;while(--$>=0)Q[$]=0}var FW=0,N$=1,LW=2,OW=3,NW=258,I9=29,Y8=256,Q8=Y8+1+I9,U6=30,C9=19,B$=2*Q8+1,m1=15,L9=16,BW=7,T9=256,M$=16,P$=17,I$=18,M9=[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],W2=[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],MW=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],C$=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],PW=512,Z1=Array((Q8+2)*2);H6(Z1);var e6=Array(U6*2);H6(e6);var $8=Array(PW);H6($8);var q8=Array(NW-OW+1);H6(q8);var A9=Array(I9);H6(A9);var j2=Array(U6);H6(j2);function O9(Q,$,q,J,Y){this.static_tree=Q,this.extra_bits=$,this.extra_base=q,this.elems=J,this.max_length=Y,this.has_stree=Q&&Q.length}var T$,A$,w$;function N9(Q,$){this.dyn_tree=Q,this.max_code=0,this.stat_desc=$}function D$(Q){return Q<256?$8[Q]:$8[256+(Q>>>7)]}function J8(Q,$){Q.pending_buf[Q.pending++]=$&255,Q.pending_buf[Q.pending++]=$>>>8&255}function F0(Q,$,q){if(Q.bi_valid>L9-q)Q.bi_buf|=$<<Q.bi_valid&65535,J8(Q,Q.bi_buf),Q.bi_buf=$>>L9-Q.bi_valid,Q.bi_valid+=q-L9;else Q.bi_buf|=$<<Q.bi_valid&65535,Q.bi_valid+=q}function n0(Q,$,q){F0(Q,q[$*2],q[$*2+1])}function R$(Q,$){var q=0;do q|=Q&1,Q>>>=1,q<<=1;while(--$>0);return q>>>1}function IW(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 CW(Q,$){var{dyn_tree:q,max_code:J}=$,Y=$.stat_desc.static_tree,V=$.stat_desc.has_stree,K=$.stat_desc.extra_bits,X=$.stat_desc.extra_base,W=$.stat_desc.max_length,G,j,H,U,z,F,N=0;for(U=0;U<=m1;U++)Q.bl_count[U]=0;q[Q.heap[Q.heap_max]*2+1]=0;for(G=Q.heap_max+1;G<B$;G++){if(j=Q.heap[G],U=q[q[j*2+1]*2+1]+1,U>W)U=W,N++;if(q[j*2+1]=U,j>J)continue;if(Q.bl_count[U]++,z=0,j>=X)z=K[j-X];if(F=q[j*2],Q.opt_len+=F*(U+z),V)Q.static_len+=F*(Y[j*2+1]+z)}if(N===0)return;do{U=W-1;while(Q.bl_count[U]===0)U--;Q.bl_count[U]--,Q.bl_count[U+1]+=2,Q.bl_count[W]--,N-=2}while(N>0);for(U=W;U!==0;U--){j=Q.bl_count[U];while(j!==0){if(H=Q.heap[--G],H>J)continue;if(q[H*2+1]!==U)Q.opt_len+=(U-q[H*2+1])*q[H*2],q[H*2+1]=U;j--}}}function x$(Q,$,q){var J=Array(m1+1),Y=0,V,K;for(V=1;V<=m1;V++)J[V]=Y=Y+q[V-1]<<1;for(K=0;K<=$;K++){var X=Q[K*2+1];if(X===0)continue;Q[K*2]=R$(J[X]++,X)}}function TW(){var Q,$,q,J,Y,V=Array(m1+1);q=0;for(J=0;J<I9-1;J++){A9[J]=q;for(Q=0;Q<1<<M9[J];Q++)q8[q++]=J}q8[q-1]=J,Y=0;for(J=0;J<16;J++){j2[J]=Y;for(Q=0;Q<1<<W2[J];Q++)$8[Y++]=J}Y>>=7;for(;J<U6;J++){j2[J]=Y<<7;for(Q=0;Q<1<<W2[J]-7;Q++)$8[256+Y++]=J}for($=0;$<=m1;$++)V[$]=0;Q=0;while(Q<=143)Z1[Q*2+1]=8,Q++,V[8]++;while(Q<=255)Z1[Q*2+1]=9,Q++,V[9]++;while(Q<=279)Z1[Q*2+1]=7,Q++,V[7]++;while(Q<=287)Z1[Q*2+1]=8,Q++,V[8]++;x$(Z1,Q8+1,V);for(Q=0;Q<U6;Q++)e6[Q*2+1]=5,e6[Q*2]=R$(Q,5);T$=new O9(Z1,M9,Y8+1,Q8,m1),A$=new O9(e6,W2,0,U6,m1),w$=new O9([],MW,0,C9,BW)}function v$(Q){var $;for($=0;$<Q8;$++)Q.dyn_ltree[$*2]=0;for($=0;$<U6;$++)Q.dyn_dtree[$*2]=0;for($=0;$<C9;$++)Q.bl_tree[$*2]=0;Q.dyn_ltree[T9*2]=1,Q.opt_len=Q.static_len=0,Q.last_lit=Q.matches=0}function S$(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 AW(Q,$,q,J){if(S$(Q),J)J8(Q,q),J8(Q,~q);UW.arraySet(Q.pending_buf,Q.window,$,q,Q.pending),Q.pending+=q}function H$(Q,$,q,J){var Y=$*2,V=q*2;return Q[Y]<Q[V]||Q[Y]===Q[V]&&J[$]<=J[q]}function B9(Q,$,q){var J=Q.heap[q],Y=q<<1;while(Y<=Q.heap_len){if(Y<Q.heap_len&&H$($,Q.heap[Y+1],Q.heap[Y],Q.depth))Y++;if(H$($,J,Q.heap[Y],Q.depth))break;Q.heap[q]=Q.heap[Y],q=Y,Y<<=1}Q.heap[q]=J}function z$(Q,$,q){var J,Y,V=0,K,X;if(Q.last_lit!==0)do if(J=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++,J===0)n0(Q,Y,$);else{if(K=q8[Y],n0(Q,K+Y8+1,$),X=M9[K],X!==0)Y-=A9[K],F0(Q,Y,X);if(J--,K=D$(J),n0(Q,K,q),X=W2[K],X!==0)J-=j2[K],F0(Q,J,X)}while(V<Q.last_lit);n0(Q,T9,$)}function P9(Q,$){var q=$.dyn_tree,J=$.stat_desc.static_tree,Y=$.stat_desc.has_stree,V=$.stat_desc.elems,K,X,W=-1,G;Q.heap_len=0,Q.heap_max=B$;for(K=0;K<V;K++)if(q[K*2]!==0)Q.heap[++Q.heap_len]=W=K,Q.depth[K]=0;else q[K*2+1]=0;while(Q.heap_len<2)if(G=Q.heap[++Q.heap_len]=W<2?++W:0,q[G*2]=1,Q.depth[G]=0,Q.opt_len--,Y)Q.static_len-=J[G*2+1];$.max_code=W;for(K=Q.heap_len>>1;K>=1;K--)B9(Q,q,K);G=V;do K=Q.heap[1],Q.heap[1]=Q.heap[Q.heap_len--],B9(Q,q,1),X=Q.heap[1],Q.heap[--Q.heap_max]=K,Q.heap[--Q.heap_max]=X,q[G*2]=q[K*2]+q[X*2],Q.depth[G]=(Q.depth[K]>=Q.depth[X]?Q.depth[K]:Q.depth[X])+1,q[K*2+1]=q[X*2+1]=G,Q.heap[1]=G++,B9(Q,q,1);while(Q.heap_len>=2);Q.heap[--Q.heap_max]=Q.heap[1],CW(Q,$),x$(q,W,Q.bl_count)}function F$(Q,$,q){var J,Y=-1,V,K=$[1],X=0,W=7,G=4;if(K===0)W=138,G=3;$[(q+1)*2+1]=65535;for(J=0;J<=q;J++){if(V=K,K=$[(J+1)*2+1],++X<W&&V===K)continue;else if(X<G)Q.bl_tree[V*2]+=X;else if(V!==0){if(V!==Y)Q.bl_tree[V*2]++;Q.bl_tree[M$*2]++}else if(X<=10)Q.bl_tree[P$*2]++;else Q.bl_tree[I$*2]++;if(X=0,Y=V,K===0)W=138,G=3;else if(V===K)W=6,G=3;else W=7,G=4}}function L$(Q,$,q){var J,Y=-1,V,K=$[1],X=0,W=7,G=4;if(K===0)W=138,G=3;for(J=0;J<=q;J++){if(V=K,K=$[(J+1)*2+1],++X<W&&V===K)continue;else if(X<G)do n0(Q,V,Q.bl_tree);while(--X!==0);else if(V!==0){if(V!==Y)n0(Q,V,Q.bl_tree),X--;n0(Q,M$,Q.bl_tree),F0(Q,X-3,2)}else if(X<=10)n0(Q,P$,Q.bl_tree),F0(Q,X-3,3);else n0(Q,I$,Q.bl_tree),F0(Q,X-11,7);if(X=0,Y=V,K===0)W=138,G=3;else if(V===K)W=6,G=3;else W=7,G=4}}function wW(Q){var $;F$(Q,Q.dyn_ltree,Q.l_desc.max_code),F$(Q,Q.dyn_dtree,Q.d_desc.max_code),P9(Q,Q.bl_desc);for($=C9-1;$>=3;$--)if(Q.bl_tree[C$[$]*2+1]!==0)break;return Q.opt_len+=3*($+1)+5+5+4,$}function DW(Q,$,q,J){var Y;F0(Q,$-257,5),F0(Q,q-1,5),F0(Q,J-4,4);for(Y=0;Y<J;Y++)F0(Q,Q.bl_tree[C$[Y]*2+1],3);L$(Q,Q.dyn_ltree,$-1),L$(Q,Q.dyn_dtree,q-1)}function RW(Q){var $=4093624447,q;for(q=0;q<=31;q++,$>>>=1)if($&1&&Q.dyn_ltree[q*2]!==0)return Z$;if(Q.dyn_ltree[18]!==0||Q.dyn_ltree[20]!==0||Q.dyn_ltree[26]!==0)return U$;for(q=32;q<Y8;q++)if(Q.dyn_ltree[q*2]!==0)return U$;return Z$}var O$=!1;function xW(Q){if(!O$)TW(),O$=!0;Q.l_desc=new N9(Q.dyn_ltree,T$),Q.d_desc=new N9(Q.dyn_dtree,A$),Q.bl_desc=new N9(Q.bl_tree,w$),Q.bi_buf=0,Q.bi_valid=0,v$(Q)}function E$(Q,$,q,J){F0(Q,(FW<<1)+(J?1:0),3),AW(Q,$,q,!0)}function vW(Q){F0(Q,N$<<1,3),n0(Q,T9,Z1),IW(Q)}function SW(Q,$,q,J){var Y,V,K=0;if(Q.level>0){if(Q.strm.data_type===zW)Q.strm.data_type=RW(Q);if(P9(Q,Q.l_desc),P9(Q,Q.d_desc),K=wW(Q),Y=Q.opt_len+3+7>>>3,V=Q.static_len+3+7>>>3,V<=Y)Y=V}else Y=V=q+5;if(q+4<=Y&&$!==-1)E$(Q,$,q,J);else if(Q.strategy===HW||V===Y)F0(Q,(N$<<1)+(J?1:0),3),z$(Q,Z1,e6);else F0(Q,(LW<<1)+(J?1:0),3),DW(Q,Q.l_desc.max_code+1,Q.d_desc.max_code+1,K+1),z$(Q,Q.dyn_ltree,Q.dyn_dtree);if(v$(Q),J)S$(Q)}function EW(Q,$,q){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]=q&255,Q.last_lit++,$===0)Q.dyn_ltree[q*2]++;else Q.matches++,$--,Q.dyn_ltree[(q8[q]+Y8+1)*2]++,Q.dyn_dtree[D$($)*2]++;return Q.last_lit===Q.lit_bufsize-1}kW._tr_init=xW;kW._tr_stored_block=E$;kW._tr_flush_block=SW;kW._tr_tally=EW;kW._tr_align=vW});var w9=D((AO,y$)=>{function fW(Q,$,q,J){var Y=Q&65535|0,V=Q>>>16&65535|0,K=0;while(q!==0){K=q>2000?2000:q,q-=K;do Y=Y+$[J++]|0,V=V+Y|0;while(--K);Y%=65521,V%=65521}return Y|V<<16|0}y$.exports=fW});var D9=D((wO,g$)=>{function mW(){var Q,$=[];for(var q=0;q<256;q++){Q=q;for(var J=0;J<8;J++)Q=Q&1?3988292384^Q>>>1:Q>>>1;$[q]=Q}return $}var cW=mW();function uW(Q,$,q,J){var Y=cW,V=J+q;Q^=-1;for(var K=J;K<V;K++)Q=Q>>>8^Y[(Q^$[K])&255];return Q^-1}g$.exports=uW});var Z2=D((DO,_$)=>{_$.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 l$=D((Pj)=>{var Z0=j1(),R0=k$(),m$=w9(),P1=D9(),pW=Z2(),d1=0,dW=1,lW=3,w1=4,b$=5,a0=0,h$=1,x0=-2,oW=-3,R9=-5,iW=-1,nW=1,U2=2,rW=3,aW=4,sW=0,tW=2,L2=8,eW=9,Qj=15,$j=8,qj=29,Jj=256,v9=Jj+1+qj,Yj=30,Vj=19,Kj=2*v9+1,Xj=15,S=3,T1=258,h0=T1+S+1,Gj=32,O2=42,S9=69,H2=73,z2=91,F2=103,c1=113,K8=666,t=1,X8=2,u1=3,L6=4,Wj=3;function A1(Q,$){return Q.msg=pW[$],$}function f$(Q){return(Q<<1)-(Q>4?9:0)}function C1(Q){var $=Q.length;while(--$>=0)Q[$]=0}function I1(Q){var $=Q.state,q=$.pending;if(q>Q.avail_out)q=Q.avail_out;if(q===0)return;if(Z0.arraySet(Q.output,$.pending_buf,$.pending_out,q,Q.next_out),Q.next_out+=q,$.pending_out+=q,Q.total_out+=q,Q.avail_out-=q,$.pending-=q,$.pending===0)$.pending_out=0}function Y0(Q,$){R0._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 V8(Q,$){Q.pending_buf[Q.pending++]=$>>>8&255,Q.pending_buf[Q.pending++]=$&255}function jj(Q,$,q,J){var Y=Q.avail_in;if(Y>J)Y=J;if(Y===0)return 0;if(Q.avail_in-=Y,Z0.arraySet($,Q.input,Q.next_in,Y,q),Q.state.wrap===1)Q.adler=m$(Q.adler,$,Y,q);else if(Q.state.wrap===2)Q.adler=P1(Q.adler,$,Y,q);return Q.next_in+=Y,Q.total_in+=Y,Y}function c$(Q,$){var{max_chain_length:q,strstart:J}=Q,Y,V,K=Q.prev_length,X=Q.nice_match,W=Q.strstart>Q.w_size-h0?Q.strstart-(Q.w_size-h0):0,G=Q.window,j=Q.w_mask,H=Q.prev,U=Q.strstart+T1,z=G[J+K-1],F=G[J+K];if(Q.prev_length>=Q.good_match)q>>=2;if(X>Q.lookahead)X=Q.lookahead;do{if(Y=$,G[Y+K]!==F||G[Y+K-1]!==z||G[Y]!==G[J]||G[++Y]!==G[J+1])continue;J+=2,Y++;do;while(G[++J]===G[++Y]&&G[++J]===G[++Y]&&G[++J]===G[++Y]&&G[++J]===G[++Y]&&G[++J]===G[++Y]&&G[++J]===G[++Y]&&G[++J]===G[++Y]&&G[++J]===G[++Y]&&J<U);if(V=T1-(U-J),J=U-T1,V>K){if(Q.match_start=$,K=V,V>=X)break;z=G[J+K-1],F=G[J+K]}}while(($=H[$&j])>W&&--q!==0);if(K<=Q.lookahead)return K;return Q.lookahead}function p1(Q){var $=Q.w_size,q,J,Y,V,K;do{if(V=Q.window_size-Q.lookahead-Q.strstart,Q.strstart>=$+($-h0)){Z0.arraySet(Q.window,Q.window,$,$,0),Q.match_start-=$,Q.strstart-=$,Q.block_start-=$,J=Q.hash_size,q=J;do Y=Q.head[--q],Q.head[q]=Y>=$?Y-$:0;while(--J);J=$,q=J;do Y=Q.prev[--q],Q.prev[q]=Y>=$?Y-$:0;while(--J);V+=$}if(Q.strm.avail_in===0)break;if(J=jj(Q.strm,Q.window,Q.strstart+Q.lookahead,V),Q.lookahead+=J,Q.lookahead+Q.insert>=S){K=Q.strstart-Q.insert,Q.ins_h=Q.window[K],Q.ins_h=(Q.ins_h<<Q.hash_shift^Q.window[K+1])&Q.hash_mask;while(Q.insert)if(Q.ins_h=(Q.ins_h<<Q.hash_shift^Q.window[K+S-1])&Q.hash_mask,Q.prev[K&Q.w_mask]=Q.head[Q.ins_h],Q.head[Q.ins_h]=K,K++,Q.insert--,Q.lookahead+Q.insert<S)break}}while(Q.lookahead<h0&&Q.strm.avail_in!==0)}function Zj(Q,$){var q=65535;if(q>Q.pending_buf_size-5)q=Q.pending_buf_size-5;for(;;){if(Q.lookahead<=1){if(p1(Q),Q.lookahead===0&&$===d1)return t;if(Q.lookahead===0)break}Q.strstart+=Q.lookahead,Q.lookahead=0;var J=Q.block_start+q;if(Q.strstart===0||Q.strstart>=J){if(Q.lookahead=Q.strstart-J,Q.strstart=J,Y0(Q,!1),Q.strm.avail_out===0)return t}if(Q.strstart-Q.block_start>=Q.w_size-h0){if(Y0(Q,!1),Q.strm.avail_out===0)return t}}if(Q.insert=0,$===w1){if(Y0(Q,!0),Q.strm.avail_out===0)return u1;return L6}if(Q.strstart>Q.block_start){if(Y0(Q,!1),Q.strm.avail_out===0)return t}return t}function x9(Q,$){var q,J;for(;;){if(Q.lookahead<h0){if(p1(Q),Q.lookahead<h0&&$===d1)return t;if(Q.lookahead===0)break}if(q=0,Q.lookahead>=S)Q.ins_h=(Q.ins_h<<Q.hash_shift^Q.window[Q.strstart+S-1])&Q.hash_mask,q=Q.prev[Q.strstart&Q.w_mask]=Q.head[Q.ins_h],Q.head[Q.ins_h]=Q.strstart;if(q!==0&&Q.strstart-q<=Q.w_size-h0)Q.match_length=c$(Q,q);if(Q.match_length>=S)if(J=R0._tr_tally(Q,Q.strstart-Q.match_start,Q.match_length-S),Q.lookahead-=Q.match_length,Q.match_length<=Q.max_lazy_match&&Q.lookahead>=S){Q.match_length--;do Q.strstart++,Q.ins_h=(Q.ins_h<<Q.hash_shift^Q.window[Q.strstart+S-1])&Q.hash_mask,q=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 J=R0._tr_tally(Q,0,Q.window[Q.strstart]),Q.lookahead--,Q.strstart++;if(J){if(Y0(Q,!1),Q.strm.avail_out===0)return t}}if(Q.insert=Q.strstart<S-1?Q.strstart:S-1,$===w1){if(Y0(Q,!0),Q.strm.avail_out===0)return u1;return L6}if(Q.last_lit){if(Y0(Q,!1),Q.strm.avail_out===0)return t}return X8}function z6(Q,$){var q,J,Y;for(;;){if(Q.lookahead<h0){if(p1(Q),Q.lookahead<h0&&$===d1)return t;if(Q.lookahead===0)break}if(q=0,Q.lookahead>=S)Q.ins_h=(Q.ins_h<<Q.hash_shift^Q.window[Q.strstart+S-1])&Q.hash_mask,q=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=S-1,q!==0&&Q.prev_length<Q.max_lazy_match&&Q.strstart-q<=Q.w_size-h0){if(Q.match_length=c$(Q,q),Q.match_length<=5&&(Q.strategy===nW||Q.match_length===S&&Q.strstart-Q.match_start>4096))Q.match_length=S-1}if(Q.prev_length>=S&&Q.match_length<=Q.prev_length){Y=Q.strstart+Q.lookahead-S,J=R0._tr_tally(Q,Q.strstart-1-Q.prev_match,Q.prev_length-S),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+S-1])&Q.hash_mask,q=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=S-1,Q.strstart++,J){if(Y0(Q,!1),Q.strm.avail_out===0)return t}}else if(Q.match_available){if(J=R0._tr_tally(Q,0,Q.window[Q.strstart-1]),J)Y0(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)J=R0._tr_tally(Q,0,Q.window[Q.strstart-1]),Q.match_available=0;if(Q.insert=Q.strstart<S-1?Q.strstart:S-1,$===w1){if(Y0(Q,!0),Q.strm.avail_out===0)return u1;return L6}if(Q.last_lit){if(Y0(Q,!1),Q.strm.avail_out===0)return t}return X8}function Uj(Q,$){var q,J,Y,V,K=Q.window;for(;;){if(Q.lookahead<=T1){if(p1(Q),Q.lookahead<=T1&&$===d1)return t;if(Q.lookahead===0)break}if(Q.match_length=0,Q.lookahead>=S&&Q.strstart>0){if(Y=Q.strstart-1,J=K[Y],J===K[++Y]&&J===K[++Y]&&J===K[++Y]){V=Q.strstart+T1;do;while(J===K[++Y]&&J===K[++Y]&&J===K[++Y]&&J===K[++Y]&&J===K[++Y]&&J===K[++Y]&&J===K[++Y]&&J===K[++Y]&&Y<V);if(Q.match_length=T1-(V-Y),Q.match_length>Q.lookahead)Q.match_length=Q.lookahead}}if(Q.match_length>=S)q=R0._tr_tally(Q,1,Q.match_length-S),Q.lookahead-=Q.match_length,Q.strstart+=Q.match_length,Q.match_length=0;else q=R0._tr_tally(Q,0,Q.window[Q.strstart]),Q.lookahead--,Q.strstart++;if(q){if(Y0(Q,!1),Q.strm.avail_out===0)return t}}if(Q.insert=0,$===w1){if(Y0(Q,!0),Q.strm.avail_out===0)return u1;return L6}if(Q.last_lit){if(Y0(Q,!1),Q.strm.avail_out===0)return t}return X8}function Hj(Q,$){var q;for(;;){if(Q.lookahead===0){if(p1(Q),Q.lookahead===0){if($===d1)return t;break}}if(Q.match_length=0,q=R0._tr_tally(Q,0,Q.window[Q.strstart]),Q.lookahead--,Q.strstart++,q){if(Y0(Q,!1),Q.strm.avail_out===0)return t}}if(Q.insert=0,$===w1){if(Y0(Q,!0),Q.strm.avail_out===0)return u1;return L6}if(Q.last_lit){if(Y0(Q,!1),Q.strm.avail_out===0)return t}return X8}function r0(Q,$,q,J,Y){this.good_length=Q,this.max_lazy=$,this.nice_length=q,this.max_chain=J,this.func=Y}var F6;F6=[new r0(0,0,0,0,Zj),new r0(4,4,8,4,x9),new r0(4,5,16,8,x9),new r0(4,6,32,32,x9),new r0(4,4,16,16,z6),new r0(8,16,32,32,z6),new r0(8,16,128,128,z6),new r0(8,32,128,256,z6),new r0(32,128,258,1024,z6),new r0(32,258,258,4096,z6)];function zj(Q){Q.window_size=2*Q.w_size,C1(Q.head),Q.max_lazy_match=F6[Q.level].max_lazy,Q.good_match=F6[Q.level].good_length,Q.nice_match=F6[Q.level].nice_length,Q.max_chain_length=F6[Q.level].max_chain,Q.strstart=0,Q.block_start=0,Q.lookahead=0,Q.insert=0,Q.match_length=Q.prev_length=S-1,Q.match_available=0,Q.ins_h=0}function Fj(){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=L2,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 Z0.Buf16(Kj*2),this.dyn_dtree=new Z0.Buf16((2*Yj+1)*2),this.bl_tree=new Z0.Buf16((2*Vj+1)*2),C1(this.dyn_ltree),C1(this.dyn_dtree),C1(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Z0.Buf16(Xj+1),this.heap=new Z0.Buf16(2*v9+1),C1(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Z0.Buf16(2*v9+1),C1(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 u$(Q){var $;if(!Q||!Q.state)return A1(Q,x0);if(Q.total_in=Q.total_out=0,Q.data_type=tW,$=Q.state,$.pending=0,$.pending_out=0,$.wrap<0)$.wrap=-$.wrap;return $.status=$.wrap?O2:c1,Q.adler=$.wrap===2?0:1,$.last_flush=d1,R0._tr_init($),a0}function p$(Q){var $=u$(Q);if($===a0)zj(Q.state);return $}function Lj(Q,$){if(!Q||!Q.state)return x0;if(Q.state.wrap!==2)return x0;return Q.state.gzhead=$,a0}function d$(Q,$,q,J,Y,V){if(!Q)return x0;var K=1;if($===iW)$=6;if(J<0)K=0,J=-J;else if(J>15)K=2,J-=16;if(Y<1||Y>eW||q!==L2||J<8||J>15||$<0||$>9||V<0||V>aW)return A1(Q,x0);if(J===8)J=9;var X=new Fj;return Q.state=X,X.strm=Q,X.wrap=K,X.gzhead=null,X.w_bits=J,X.w_size=1<<X.w_bits,X.w_mask=X.w_size-1,X.hash_bits=Y+7,X.hash_size=1<<X.hash_bits,X.hash_mask=X.hash_size-1,X.hash_shift=~~((X.hash_bits+S-1)/S),X.window=new Z0.Buf8(X.w_size*2),X.head=new Z0.Buf16(X.hash_size),X.prev=new Z0.Buf16(X.w_size),X.lit_bufsize=1<<Y+6,X.pending_buf_size=X.lit_bufsize*4,X.pending_buf=new Z0.Buf8(X.pending_buf_size),X.d_buf=1*X.lit_bufsize,X.l_buf=3*X.lit_bufsize,X.level=$,X.strategy=V,X.method=q,p$(Q)}function Oj(Q,$){return d$(Q,$,L2,Qj,$j,sW)}function Nj(Q,$){var q,J,Y,V;if(!Q||!Q.state||$>b$||$<0)return Q?A1(Q,x0):x0;if(J=Q.state,!Q.output||!Q.input&&Q.avail_in!==0||J.status===K8&&$!==w1)return A1(Q,Q.avail_out===0?R9:x0);if(J.strm=Q,q=J.last_flush,J.last_flush=$,J.status===O2)if(J.wrap===2)if(Q.adler=0,k(J,31),k(J,139),k(J,8),!J.gzhead)k(J,0),k(J,0),k(J,0),k(J,0),k(J,0),k(J,J.level===9?2:J.strategy>=U2||J.level<2?4:0),k(J,Wj),J.status=c1;else{if(k(J,(J.gzhead.text?1:0)+(J.gzhead.hcrc?2:0)+(!J.gzhead.extra?0:4)+(!J.gzhead.name?0:8)+(!J.gzhead.comment?0:16)),k(J,J.gzhead.time&255),k(J,J.gzhead.time>>8&255),k(J,J.gzhead.time>>16&255),k(J,J.gzhead.time>>24&255),k(J,J.level===9?2:J.strategy>=U2||J.level<2?4:0),k(J,J.gzhead.os&255),J.gzhead.extra&&J.gzhead.extra.length)k(J,J.gzhead.extra.length&255),k(J,J.gzhead.extra.length>>8&255);if(J.gzhead.hcrc)Q.adler=P1(Q.adler,J.pending_buf,J.pending,0);J.gzindex=0,J.status=S9}else{var K=L2+(J.w_bits-8<<4)<<8,X=-1;if(J.strategy>=U2||J.level<2)X=0;else if(J.level<6)X=1;else if(J.level===6)X=2;else X=3;if(K|=X<<6,J.strstart!==0)K|=Gj;if(K+=31-K%31,J.status=c1,V8(J,K),J.strstart!==0)V8(J,Q.adler>>>16),V8(J,Q.adler&65535);Q.adler=1}if(J.status===S9)if(J.gzhead.extra){Y=J.pending;while(J.gzindex<(J.gzhead.extra.length&65535)){if(J.pending===J.pending_buf_size){if(J.gzhead.hcrc&&J.pending>Y)Q.adler=P1(Q.adler,J.pending_buf,J.pending-Y,Y);if(I1(Q),Y=J.pending,J.pending===J.pending_buf_size)break}k(J,J.gzhead.extra[J.gzindex]&255),J.gzindex++}if(J.gzhead.hcrc&&J.pending>Y)Q.adler=P1(Q.adler,J.pending_buf,J.pending-Y,Y);if(J.gzindex===J.gzhead.extra.length)J.gzindex=0,J.status=H2}else J.status=H2;if(J.status===H2)if(J.gzhead.name){Y=J.pending;do{if(J.pending===J.pending_buf_size){if(J.gzhead.hcrc&&J.pending>Y)Q.adler=P1(Q.adler,J.pending_buf,J.pending-Y,Y);if(I1(Q),Y=J.pending,J.pending===J.pending_buf_size){V=1;break}}if(J.gzindex<J.gzhead.name.length)V=J.gzhead.name.charCodeAt(J.gzindex++)&255;else V=0;k(J,V)}while(V!==0);if(J.gzhead.hcrc&&J.pending>Y)Q.adler=P1(Q.adler,J.pending_buf,J.pending-Y,Y);if(V===0)J.gzindex=0,J.status=z2}else J.status=z2;if(J.status===z2)if(J.gzhead.comment){Y=J.pending;do{if(J.pending===J.pending_buf_size){if(J.gzhead.hcrc&&J.pending>Y)Q.adler=P1(Q.adler,J.pending_buf,J.pending-Y,Y);if(I1(Q),Y=J.pending,J.pending===J.pending_buf_size){V=1;break}}if(J.gzindex<J.gzhead.comment.length)V=J.gzhead.comment.charCodeAt(J.gzindex++)&255;else V=0;k(J,V)}while(V!==0);if(J.gzhead.hcrc&&J.pending>Y)Q.adler=P1(Q.adler,J.pending_buf,J.pending-Y,Y);if(V===0)J.status=F2}else J.status=F2;if(J.status===F2)if(J.gzhead.hcrc){if(J.pending+2>J.pending_buf_size)I1(Q);if(J.pending+2<=J.pending_buf_size)k(J,Q.adler&255),k(J,Q.adler>>8&255),Q.adler=0,J.status=c1}else J.status=c1;if(J.pending!==0){if(I1(Q),Q.avail_out===0)return J.last_flush=-1,a0}else if(Q.avail_in===0&&f$($)<=f$(q)&&$!==w1)return A1(Q,R9);if(J.status===K8&&Q.avail_in!==0)return A1(Q,R9);if(Q.avail_in!==0||J.lookahead!==0||$!==d1&&J.status!==K8){var W=J.strategy===U2?Hj(J,$):J.strategy===rW?Uj(J,$):F6[J.level].func(J,$);if(W===u1||W===L6)J.status=K8;if(W===t||W===u1){if(Q.avail_out===0)J.last_flush=-1;return a0}if(W===X8){if($===dW)R0._tr_align(J);else if($!==b$){if(R0._tr_stored_block(J,0,0,!1),$===lW){if(C1(J.head),J.lookahead===0)J.strstart=0,J.block_start=0,J.insert=0}}if(I1(Q),Q.avail_out===0)return J.last_flush=-1,a0}}if($!==w1)return a0;if(J.wrap<=0)return h$;if(J.wrap===2)k(J,Q.adler&255),k(J,Q.adler>>8&255),k(J,Q.adler>>16&255),k(J,Q.adler>>24&255),k(J,Q.total_in&255),k(J,Q.total_in>>8&255),k(J,Q.total_in>>16&255),k(J,Q.total_in>>24&255);else V8(J,Q.adler>>>16),V8(J,Q.adler&65535);if(I1(Q),J.wrap>0)J.wrap=-J.wrap;return J.pending!==0?a0:h$}function Bj(Q){var $;if(!Q||!Q.state)return x0;if($=Q.state.status,$!==O2&&$!==S9&&$!==H2&&$!==z2&&$!==F2&&$!==c1&&$!==K8)return A1(Q,x0);return Q.state=null,$===c1?A1(Q,oW):a0}function Mj(Q,$){var q=$.length,J,Y,V,K,X,W,G,j;if(!Q||!Q.state)return x0;if(J=Q.state,K=J.wrap,K===2||K===1&&J.status!==O2||J.lookahead)return x0;if(K===1)Q.adler=m$(Q.adler,$,q,0);if(J.wrap=0,q>=J.w_size){if(K===0)C1(J.head),J.strstart=0,J.block_start=0,J.insert=0;j=new Z0.Buf8(J.w_size),Z0.arraySet(j,$,q-J.w_size,J.w_size,0),$=j,q=J.w_size}X=Q.avail_in,W=Q.next_in,G=Q.input,Q.avail_in=q,Q.next_in=0,Q.input=$,p1(J);while(J.lookahead>=S){Y=J.strstart,V=J.lookahead-(S-1);do J.ins_h=(J.ins_h<<J.hash_shift^J.window[Y+S-1])&J.hash_mask,J.prev[Y&J.w_mask]=J.head[J.ins_h],J.head[J.ins_h]=Y,Y++;while(--V);J.strstart=Y,J.lookahead=S-1,p1(J)}return J.strstart+=J.lookahead,J.block_start=J.strstart,J.insert=J.lookahead,J.lookahead=0,J.match_length=J.prev_length=S-1,J.match_available=0,Q.next_in=W,Q.input=G,Q.avail_in=X,J.wrap=K,a0}Pj.deflateInit=Oj;Pj.deflateInit2=d$;Pj.deflateReset=p$;Pj.deflateResetKeep=u$;Pj.deflateSetHeader=Lj;Pj.deflate=Nj;Pj.deflateEnd=Bj;Pj.deflateSetDictionary=Mj;Pj.deflateInfo="pako deflate (from Nodeca project)"});var E9=D((Sj)=>{var N2=j1(),o$=!0,i$=!0;try{String.fromCharCode.apply(null,[0])}catch(Q){o$=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(Q){i$=!1}var G8=new N2.Buf8(256);for(s0=0;s0<256;s0++)G8[s0]=s0>=252?6:s0>=248?5:s0>=240?4:s0>=224?3:s0>=192?2:1;var s0;G8[254]=G8[254]=1;Sj.string2buf=function(Q){var $,q,J,Y,V,K=Q.length,X=0;for(Y=0;Y<K;Y++){if(q=Q.charCodeAt(Y),(q&64512)===55296&&Y+1<K){if(J=Q.charCodeAt(Y+1),(J&64512)===56320)q=65536+(q-55296<<10)+(J-56320),Y++}X+=q<128?1:q<2048?2:q<65536?3:4}$=new N2.Buf8(X);for(V=0,Y=0;V<X;Y++){if(q=Q.charCodeAt(Y),(q&64512)===55296&&Y+1<K){if(J=Q.charCodeAt(Y+1),(J&64512)===56320)q=65536+(q-55296<<10)+(J-56320),Y++}if(q<128)$[V++]=q;else if(q<2048)$[V++]=192|q>>>6,$[V++]=128|q&63;else if(q<65536)$[V++]=224|q>>>12,$[V++]=128|q>>>6&63,$[V++]=128|q&63;else $[V++]=240|q>>>18,$[V++]=128|q>>>12&63,$[V++]=128|q>>>6&63,$[V++]=128|q&63}return $};function n$(Q,$){if($<65534){if(Q.subarray&&i$||!Q.subarray&&o$)return String.fromCharCode.apply(null,N2.shrinkBuf(Q,$))}var q="";for(var J=0;J<$;J++)q+=String.fromCharCode(Q[J]);return q}Sj.buf2binstring=function(Q){return n$(Q,Q.length)};Sj.binstring2buf=function(Q){var $=new N2.Buf8(Q.length);for(var q=0,J=$.length;q<J;q++)$[q]=Q.charCodeAt(q);return $};Sj.buf2string=function(Q,$){var q,J,Y,V,K=$||Q.length,X=Array(K*2);for(J=0,q=0;q<K;){if(Y=Q[q++],Y<128){X[J++]=Y;continue}if(V=G8[Y],V>4){X[J++]=65533,q+=V-1;continue}Y&=V===2?31:V===3?15:7;while(V>1&&q<K)Y=Y<<6|Q[q++]&63,V--;if(V>1){X[J++]=65533;continue}if(Y<65536)X[J++]=Y;else Y-=65536,X[J++]=55296|Y>>10&1023,X[J++]=56320|Y&1023}return n$(X,J)};Sj.utf8border=function(Q,$){var q;if($=$||Q.length,$>Q.length)$=Q.length;q=$-1;while(q>=0&&(Q[q]&192)===128)q--;if(q<0)return $;if(q===0)return $;return q+G8[Q[q]]>$?q:$}});var k9=D((vO,r$)=>{function bj(){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}r$.exports=bj});var e$=D((lj)=>{var W8=l$(),j8=j1(),g9=E9(),_9=Z2(),hj=k9(),t$=Object.prototype.toString,fj=0,y9=4,O6=0,a$=1,s$=2,mj=-1,cj=0,uj=8;function l1(Q){if(!(this instanceof l1))return new l1(Q);this.options=j8.assign({level:mj,method:uj,chunkSize:16384,windowBits:15,memLevel:8,strategy:cj,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 hj,this.strm.avail_out=0;var q=W8.deflateInit2(this.strm,$.level,$.method,$.windowBits,$.memLevel,$.strategy);if(q!==O6)throw Error(_9[q]);if($.header)W8.deflateSetHeader(this.strm,$.header);if($.dictionary){var J;if(typeof $.dictionary==="string")J=g9.string2buf($.dictionary);else if(t$.call($.dictionary)==="[object ArrayBuffer]")J=new Uint8Array($.dictionary);else J=$.dictionary;if(q=W8.deflateSetDictionary(this.strm,J),q!==O6)throw Error(_9[q]);this._dict_set=!0}}l1.prototype.push=function(Q,$){var q=this.strm,J=this.options.chunkSize,Y,V;if(this.ended)return!1;if(V=$===~~$?$:$===!0?y9:fj,typeof Q==="string")q.input=g9.string2buf(Q);else if(t$.call(Q)==="[object ArrayBuffer]")q.input=new Uint8Array(Q);else q.input=Q;q.next_in=0,q.avail_in=q.input.length;do{if(q.avail_out===0)q.output=new j8.Buf8(J),q.next_out=0,q.avail_out=J;if(Y=W8.deflate(q,V),Y!==a$&&Y!==O6)return this.onEnd(Y),this.ended=!0,!1;if(q.avail_out===0||q.avail_in===0&&(V===y9||V===s$))if(this.options.to==="string")this.onData(g9.buf2binstring(j8.shrinkBuf(q.output,q.next_out)));else this.onData(j8.shrinkBuf(q.output,q.next_out))}while((q.avail_in>0||q.avail_out===0)&&Y!==a$);if(V===y9)return Y=W8.deflateEnd(this.strm),this.onEnd(Y),this.ended=!0,Y===O6;if(V===s$)return this.onEnd(O6),q.avail_out=0,!0;return!0};l1.prototype.onData=function(Q){this.chunks.push(Q)};l1.prototype.onEnd=function(Q){if(Q===O6)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 b9(Q,$){var q=new l1($);if(q.push(Q,!0),q.err)throw q.msg||_9[q.err];return q.result}function pj(Q,$){return $=$||{},$.raw=!0,b9(Q,$)}function dj(Q,$){return $=$||{},$.gzip=!0,b9(Q,$)}lj.Deflate=l1;lj.deflate=b9;lj.deflateRaw=pj;lj.gzip=dj});var $q=D((EO,Qq)=>{var B2=30,aj=12;Qq.exports=function($,q){var J,Y,V,K,X,W,G,j,H,U,z,F,N,C,P,L,A,B,O,M,T,w,x,v,R;J=$.state,Y=$.next_in,v=$.input,V=Y+($.avail_in-5),K=$.next_out,R=$.output,X=K-(q-$.avail_out),W=K+($.avail_out-257),G=J.dmax,j=J.wsize,H=J.whave,U=J.wnext,z=J.window,F=J.hold,N=J.bits,C=J.lencode,P=J.distcode,L=(1<<J.lenbits)-1,A=(1<<J.distbits)-1;Q:do{if(N<15)F+=v[Y++]<<N,N+=8,F+=v[Y++]<<N,N+=8;B=C[F&L];$:for(;;){if(O=B>>>24,F>>>=O,N-=O,O=B>>>16&255,O===0)R[K++]=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];q:for(;;){if(O=B>>>24,F>>>=O,N-=O,O=B>>>16&255,O&16){if(T=B&65535,O&=15,N<O){if(F+=v[Y++]<<N,N+=8,N<O)F+=v[Y++]<<N,N+=8}if(T+=F&(1<<O)-1,T>G){$.msg="invalid distance too far back",J.mode=B2;break Q}if(F>>>=O,N-=O,O=K-X,T>O){if(O=T-O,O>H){if(J.sane){$.msg="invalid distance too far back",J.mode=B2;break Q}}if(w=0,x=z,U===0){if(w+=j-O,O<M){M-=O;do R[K++]=z[w++];while(--O);w=K-T,x=R}}else if(U<O){if(w+=j+U-O,O-=U,O<M){M-=O;do R[K++]=z[w++];while(--O);if(w=0,U<M){O=U,M-=O;do R[K++]=z[w++];while(--O);w=K-T,x=R}}}else if(w+=U-O,O<M){M-=O;do R[K++]=z[w++];while(--O);w=K-T,x=R}while(M>2)R[K++]=x[w++],R[K++]=x[w++],R[K++]=x[w++],M-=3;if(M){if(R[K++]=x[w++],M>1)R[K++]=x[w++]}}else{w=K-T;do R[K++]=R[w++],R[K++]=R[w++],R[K++]=R[w++],M-=3;while(M>2);if(M){if(R[K++]=R[w++],M>1)R[K++]=R[w++]}}}else if((O&64)===0){B=P[(B&65535)+(F&(1<<O)-1)];continue q}else{$.msg="invalid distance code",J.mode=B2;break Q}break}}else if((O&64)===0){B=C[(B&65535)+(F&(1<<O)-1)];continue $}else if(O&32){J.mode=aj;break Q}else{$.msg="invalid literal/length code",J.mode=B2;break Q}break}}while(Y<V&&K<W);M=N>>3,Y-=M,N-=M<<3,F&=(1<<N)-1,$.next_in=Y,$.next_out=K,$.avail_in=Y<V?5+(V-Y):5-(Y-V),$.avail_out=K<W?257+(W-K):257-(K-W),J.hold=F,J.bits=N;return}});var Gq=D((kO,Xq)=>{var qq=j1(),N6=15,Jq=852,Yq=592,Vq=0,h9=1,Kq=2,sj=[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],tj=[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],ej=[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],QZ=[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];Xq.exports=function($,q,J,Y,V,K,X,W){var G=W.bits,j=0,H=0,U=0,z=0,F=0,N=0,C=0,P=0,L=0,A=0,B,O,M,T,w,x=null,v=0,R,q0=new qq.Buf16(N6+1),T0=new qq.Buf16(N6+1),h=null,G0=0,A0,H0,J1;for(j=0;j<=N6;j++)q0[j]=0;for(H=0;H<Y;H++)q0[q[J+H]]++;F=G;for(z=N6;z>=1;z--)if(q0[z]!==0)break;if(F>z)F=z;if(z===0)return V[K++]=20971520,V[K++]=20971520,W.bits=1,0;for(U=1;U<z;U++)if(q0[U]!==0)break;if(F<U)F=U;P=1;for(j=1;j<=N6;j++)if(P<<=1,P-=q0[j],P<0)return-1;if(P>0&&($===Vq||z!==1))return-1;T0[1]=0;for(j=1;j<N6;j++)T0[j+1]=T0[j]+q0[j];for(H=0;H<Y;H++)if(q[J+H]!==0)X[T0[q[J+H]]++]=H;if($===Vq)x=h=X,R=19;else if($===h9)x=sj,v-=257,h=tj,G0-=257,R=256;else x=ej,h=QZ,R=-1;if(A=0,H=0,j=U,w=K,N=F,C=0,M=-1,L=1<<F,T=L-1,$===h9&&L>Jq||$===Kq&&L>Yq)return 1;for(;;){if(A0=j-C,X[H]<R)H0=0,J1=X[H];else if(X[H]>R)H0=h[G0+X[H]],J1=x[v+X[H]];else H0=96,J1=0;B=1<<j-C,O=1<<N,U=O;do O-=B,V[w+(A>>C)+O]=A0<<24|H0<<16|J1|0;while(O!==0);B=1<<j-1;while(A&B)B>>=1;if(B!==0)A&=B-1,A+=B;else A=0;if(H++,--q0[j]===0){if(j===z)break;j=q[J+X[H]]}if(j>F&&(A&T)!==M){if(C===0)C=F;w+=U,N=j-C,P=1<<N;while(N+C<z){if(P-=q0[N+C],P<=0)break;N++,P<<=1}if(L+=1<<N,$===h9&&L>Jq||$===Kq&&L>Yq)return 1;M=A&T,V[M]=F<<24|N<<16|w-K|0}}if(A!==0)V[w+A]=j-C<<24|4194304|0;return W.bits=F,0}});var pq=D((BZ)=>{var M0=j1(),d9=w9(),t0=D9(),$Z=$q(),Z8=Gq(),qZ=0,yq=1,gq=2,Wq=4,JZ=5,M2=6,o1=0,YZ=1,VZ=2,v0=-2,_q=-3,l9=-4,KZ=-5,jq=8,bq=1,Zq=2,Uq=3,Hq=4,zq=5,Fq=6,Lq=7,Oq=8,Nq=9,Bq=10,C2=11,U1=12,f9=13,Mq=14,m9=15,Pq=16,Iq=17,Cq=18,Tq=19,P2=20,I2=21,Aq=22,wq=23,Dq=24,Rq=25,xq=26,c9=27,vq=28,Sq=29,p=30,o9=31,XZ=32,GZ=852,WZ=592,jZ=15,ZZ=jZ;function Eq(Q){return(Q>>>24&255)+(Q>>>8&65280)+((Q&65280)<<8)+((Q&255)<<24)}function UZ(){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 M0.Buf16(320),this.work=new M0.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function hq(Q){var $;if(!Q||!Q.state)return v0;if($=Q.state,Q.total_in=Q.total_out=$.total=0,Q.msg="",$.wrap)Q.adler=$.wrap&1;return $.mode=bq,$.last=0,$.havedict=0,$.dmax=32768,$.head=null,$.hold=0,$.bits=0,$.lencode=$.lendyn=new M0.Buf32(GZ),$.distcode=$.distdyn=new M0.Buf32(WZ),$.sane=1,$.back=-1,o1}function fq(Q){var $;if(!Q||!Q.state)return v0;return $=Q.state,$.wsize=0,$.whave=0,$.wnext=0,hq(Q)}function mq(Q,$){var q,J;if(!Q||!Q.state)return v0;if(J=Q.state,$<0)q=0,$=-$;else if(q=($>>4)+1,$<48)$&=15;if($&&($<8||$>15))return v0;if(J.window!==null&&J.wbits!==$)J.window=null;return J.wrap=q,J.wbits=$,fq(Q)}function cq(Q,$){var q,J;if(!Q)return v0;if(J=new UZ,Q.state=J,J.window=null,q=mq(Q,$),q!==o1)Q.state=null;return q}function HZ(Q){return cq(Q,ZZ)}var kq=!0,u9,p9;function zZ(Q){if(kq){var $;u9=new M0.Buf32(512),p9=new M0.Buf32(32),$=0;while($<144)Q.lens[$++]=8;while($<256)Q.lens[$++]=9;while($<280)Q.lens[$++]=7;while($<288)Q.lens[$++]=8;Z8(yq,Q.lens,0,288,u9,0,Q.work,{bits:9}),$=0;while($<32)Q.lens[$++]=5;Z8(gq,Q.lens,0,32,p9,0,Q.work,{bits:5}),kq=!1}Q.lencode=u9,Q.lenbits=9,Q.distcode=p9,Q.distbits=5}function uq(Q,$,q,J){var Y,V=Q.state;if(V.window===null)V.wsize=1<<V.wbits,V.wnext=0,V.whave=0,V.window=new M0.Buf8(V.wsize);if(J>=V.wsize)M0.arraySet(V.window,$,q-V.wsize,V.wsize,0),V.wnext=0,V.whave=V.wsize;else{if(Y=V.wsize-V.wnext,Y>J)Y=J;if(M0.arraySet(V.window,$,q-J,Y,V.wnext),J-=Y,J)M0.arraySet(V.window,$,q-J,J,0),V.wnext=J,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 FZ(Q,$){var q,J,Y,V,K,X,W,G,j,H,U,z,F,N,C=0,P,L,A,B,O,M,T,w,x=new M0.Buf8(4),v,R,q0=[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 v0;if(q=Q.state,q.mode===U1)q.mode=f9;K=Q.next_out,Y=Q.output,W=Q.avail_out,V=Q.next_in,J=Q.input,X=Q.avail_in,G=q.hold,j=q.bits,H=X,U=W,w=o1;Q:for(;;)switch(q.mode){case bq:if(q.wrap===0){q.mode=f9;break}while(j<16){if(X===0)break Q;X--,G+=J[V++]<<j,j+=8}if(q.wrap&2&&G===35615){q.check=0,x[0]=G&255,x[1]=G>>>8&255,q.check=t0(q.check,x,2,0),G=0,j=0,q.mode=Zq;break}if(q.flags=0,q.head)q.head.done=!1;if(!(q.wrap&1)||(((G&255)<<8)+(G>>8))%31){Q.msg="incorrect header check",q.mode=p;break}if((G&15)!==jq){Q.msg="unknown compression method",q.mode=p;break}if(G>>>=4,j-=4,T=(G&15)+8,q.wbits===0)q.wbits=T;else if(T>q.wbits){Q.msg="invalid window size",q.mode=p;break}q.dmax=1<<T,Q.adler=q.check=1,q.mode=G&512?Bq:U1,G=0,j=0;break;case Zq:while(j<16){if(X===0)break Q;X--,G+=J[V++]<<j,j+=8}if(q.flags=G,(q.flags&255)!==jq){Q.msg="unknown compression method",q.mode=p;break}if(q.flags&57344){Q.msg="unknown header flags set",q.mode=p;break}if(q.head)q.head.text=G>>8&1;if(q.flags&512)x[0]=G&255,x[1]=G>>>8&255,q.check=t0(q.check,x,2,0);G=0,j=0,q.mode=Uq;case Uq:while(j<32){if(X===0)break Q;X--,G+=J[V++]<<j,j+=8}if(q.head)q.head.time=G;if(q.flags&512)x[0]=G&255,x[1]=G>>>8&255,x[2]=G>>>16&255,x[3]=G>>>24&255,q.check=t0(q.check,x,4,0);G=0,j=0,q.mode=Hq;case Hq:while(j<16){if(X===0)break Q;X--,G+=J[V++]<<j,j+=8}if(q.head)q.head.xflags=G&255,q.head.os=G>>8;if(q.flags&512)x[0]=G&255,x[1]=G>>>8&255,q.check=t0(q.check,x,2,0);G=0,j=0,q.mode=zq;case zq:if(q.flags&1024){while(j<16){if(X===0)break Q;X--,G+=J[V++]<<j,j+=8}if(q.length=G,q.head)q.head.extra_len=G;if(q.flags&512)x[0]=G&255,x[1]=G>>>8&255,q.check=t0(q.check,x,2,0);G=0,j=0}else if(q.head)q.head.extra=null;q.mode=Fq;case Fq:if(q.flags&1024){if(z=q.length,z>X)z=X;if(z){if(q.head){if(T=q.head.extra_len-q.length,!q.head.extra)q.head.extra=Array(q.head.extra_len);M0.arraySet(q.head.extra,J,V,z,T)}if(q.flags&512)q.check=t0(q.check,J,z,V);X-=z,V+=z,q.length-=z}if(q.length)break Q}q.length=0,q.mode=Lq;case Lq:if(q.flags&2048){if(X===0)break Q;z=0;do if(T=J[V+z++],q.head&&T&&q.length<65536)q.head.name+=String.fromCharCode(T);while(T&&z<X);if(q.flags&512)q.check=t0(q.check,J,z,V);if(X-=z,V+=z,T)break Q}else if(q.head)q.head.name=null;q.length=0,q.mode=Oq;case Oq:if(q.flags&4096){if(X===0)break Q;z=0;do if(T=J[V+z++],q.head&&T&&q.length<65536)q.head.comment+=String.fromCharCode(T);while(T&&z<X);if(q.flags&512)q.check=t0(q.check,J,z,V);if(X-=z,V+=z,T)break Q}else if(q.head)q.head.comment=null;q.mode=Nq;case Nq:if(q.flags&512){while(j<16){if(X===0)break Q;X--,G+=J[V++]<<j,j+=8}if(G!==(q.check&65535)){Q.msg="header crc mismatch",q.mode=p;break}G=0,j=0}if(q.head)q.head.hcrc=q.flags>>9&1,q.head.done=!0;Q.adler=q.check=0,q.mode=U1;break;case Bq:while(j<32){if(X===0)break Q;X--,G+=J[V++]<<j,j+=8}Q.adler=q.check=Eq(G),G=0,j=0,q.mode=C2;case C2:if(q.havedict===0)return Q.next_out=K,Q.avail_out=W,Q.next_in=V,Q.avail_in=X,q.hold=G,q.bits=j,VZ;Q.adler=q.check=1,q.mode=U1;case U1:if($===JZ||$===M2)break Q;case f9:if(q.last){G>>>=j&7,j-=j&7,q.mode=c9;break}while(j<3){if(X===0)break Q;X--,G+=J[V++]<<j,j+=8}switch(q.last=G&1,G>>>=1,j-=1,G&3){case 0:q.mode=Mq;break;case 1:if(zZ(q),q.mode=P2,$===M2){G>>>=2,j-=2;break Q}break;case 2:q.mode=Iq;break;case 3:Q.msg="invalid block type",q.mode=p}G>>>=2,j-=2;break;case Mq:G>>>=j&7,j-=j&7;while(j<32){if(X===0)break Q;X--,G+=J[V++]<<j,j+=8}if((G&65535)!==(G>>>16^65535)){Q.msg="invalid stored block lengths",q.mode=p;break}if(q.length=G&65535,G=0,j=0,q.mode=m9,$===M2)break Q;case m9:q.mode=Pq;case Pq:if(z=q.length,z){if(z>X)z=X;if(z>W)z=W;if(z===0)break Q;M0.arraySet(Y,J,V,z,K),X-=z,V+=z,W-=z,K+=z,q.length-=z;break}q.mode=U1;break;case Iq:while(j<14){if(X===0)break Q;X--,G+=J[V++]<<j,j+=8}if(q.nlen=(G&31)+257,G>>>=5,j-=5,q.ndist=(G&31)+1,G>>>=5,j-=5,q.ncode=(G&15)+4,G>>>=4,j-=4,q.nlen>286||q.ndist>30){Q.msg="too many length or distance symbols",q.mode=p;break}q.have=0,q.mode=Cq;case Cq:while(q.have<q.ncode){while(j<3){if(X===0)break Q;X--,G+=J[V++]<<j,j+=8}q.lens[q0[q.have++]]=G&7,G>>>=3,j-=3}while(q.have<19)q.lens[q0[q.have++]]=0;if(q.lencode=q.lendyn,q.lenbits=7,v={bits:q.lenbits},w=Z8(qZ,q.lens,0,19,q.lencode,0,q.work,v),q.lenbits=v.bits,w){Q.msg="invalid code lengths set",q.mode=p;break}q.have=0,q.mode=Tq;case Tq:while(q.have<q.nlen+q.ndist){for(;;){if(C=q.lencode[G&(1<<q.lenbits)-1],P=C>>>24,L=C>>>16&255,A=C&65535,P<=j)break;if(X===0)break Q;X--,G+=J[V++]<<j,j+=8}if(A<16)G>>>=P,j-=P,q.lens[q.have++]=A;else{if(A===16){R=P+2;while(j<R){if(X===0)break Q;X--,G+=J[V++]<<j,j+=8}if(G>>>=P,j-=P,q.have===0){Q.msg="invalid bit length repeat",q.mode=p;break}T=q.lens[q.have-1],z=3+(G&3),G>>>=2,j-=2}else if(A===17){R=P+3;while(j<R){if(X===0)break Q;X--,G+=J[V++]<<j,j+=8}G>>>=P,j-=P,T=0,z=3+(G&7),G>>>=3,j-=3}else{R=P+7;while(j<R){if(X===0)break Q;X--,G+=J[V++]<<j,j+=8}G>>>=P,j-=P,T=0,z=11+(G&127),G>>>=7,j-=7}if(q.have+z>q.nlen+q.ndist){Q.msg="invalid bit length repeat",q.mode=p;break}while(z--)q.lens[q.have++]=T}}if(q.mode===p)break;if(q.lens[256]===0){Q.msg="invalid code -- missing end-of-block",q.mode=p;break}if(q.lenbits=9,v={bits:q.lenbits},w=Z8(yq,q.lens,0,q.nlen,q.lencode,0,q.work,v),q.lenbits=v.bits,w){Q.msg="invalid literal/lengths set",q.mode=p;break}if(q.distbits=6,q.distcode=q.distdyn,v={bits:q.distbits},w=Z8(gq,q.lens,q.nlen,q.ndist,q.distcode,0,q.work,v),q.distbits=v.bits,w){Q.msg="invalid distances set",q.mode=p;break}if(q.mode=P2,$===M2)break Q;case P2:q.mode=I2;case I2:if(X>=6&&W>=258){if(Q.next_out=K,Q.avail_out=W,Q.next_in=V,Q.avail_in=X,q.hold=G,q.bits=j,$Z(Q,U),K=Q.next_out,Y=Q.output,W=Q.avail_out,V=Q.next_in,J=Q.input,X=Q.avail_in,G=q.hold,j=q.bits,q.mode===U1)q.back=-1;break}q.back=0;for(;;){if(C=q.lencode[G&(1<<q.lenbits)-1],P=C>>>24,L=C>>>16&255,A=C&65535,P<=j)break;if(X===0)break Q;X--,G+=J[V++]<<j,j+=8}if(L&&(L&240)===0){B=P,O=L,M=A;for(;;){if(C=q.lencode[M+((G&(1<<B+O)-1)>>B)],P=C>>>24,L=C>>>16&255,A=C&65535,B+P<=j)break;if(X===0)break Q;X--,G+=J[V++]<<j,j+=8}G>>>=B,j-=B,q.back+=B}if(G>>>=P,j-=P,q.back+=P,q.length=A,L===0){q.mode=xq;break}if(L&32){q.back=-1,q.mode=U1;break}if(L&64){Q.msg="invalid literal/length code",q.mode=p;break}q.extra=L&15,q.mode=Aq;case Aq:if(q.extra){R=q.extra;while(j<R){if(X===0)break Q;X--,G+=J[V++]<<j,j+=8}q.length+=G&(1<<q.extra)-1,G>>>=q.extra,j-=q.extra,q.back+=q.extra}q.was=q.length,q.mode=wq;case wq:for(;;){if(C=q.distcode[G&(1<<q.distbits)-1],P=C>>>24,L=C>>>16&255,A=C&65535,P<=j)break;if(X===0)break Q;X--,G+=J[V++]<<j,j+=8}if((L&240)===0){B=P,O=L,M=A;for(;;){if(C=q.distcode[M+((G&(1<<B+O)-1)>>B)],P=C>>>24,L=C>>>16&255,A=C&65535,B+P<=j)break;if(X===0)break Q;X--,G+=J[V++]<<j,j+=8}G>>>=B,j-=B,q.back+=B}if(G>>>=P,j-=P,q.back+=P,L&64){Q.msg="invalid distance code",q.mode=p;break}q.offset=A,q.extra=L&15,q.mode=Dq;case Dq:if(q.extra){R=q.extra;while(j<R){if(X===0)break Q;X--,G+=J[V++]<<j,j+=8}q.offset+=G&(1<<q.extra)-1,G>>>=q.extra,j-=q.extra,q.back+=q.extra}if(q.offset>q.dmax){Q.msg="invalid distance too far back",q.mode=p;break}q.mode=Rq;case Rq:if(W===0)break Q;if(z=U-W,q.offset>z){if(z=q.offset-z,z>q.whave){if(q.sane){Q.msg="invalid distance too far back",q.mode=p;break}}if(z>q.wnext)z-=q.wnext,F=q.wsize-z;else F=q.wnext-z;if(z>q.length)z=q.length;N=q.window}else N=Y,F=K-q.offset,z=q.length;if(z>W)z=W;W-=z,q.length-=z;do Y[K++]=N[F++];while(--z);if(q.length===0)q.mode=I2;break;case xq:if(W===0)break Q;Y[K++]=q.length,W--,q.mode=I2;break;case c9:if(q.wrap){while(j<32){if(X===0)break Q;X--,G|=J[V++]<<j,j+=8}if(U-=W,Q.total_out+=U,q.total+=U,U)Q.adler=q.check=q.flags?t0(q.check,Y,U,K-U):d9(q.check,Y,U,K-U);if(U=W,(q.flags?G:Eq(G))!==q.check){Q.msg="incorrect data check",q.mode=p;break}G=0,j=0}q.mode=vq;case vq:if(q.wrap&&q.flags){while(j<32){if(X===0)break Q;X--,G+=J[V++]<<j,j+=8}if(G!==(q.total&4294967295)){Q.msg="incorrect length check",q.mode=p;break}G=0,j=0}q.mode=Sq;case Sq:w=YZ;break Q;case p:w=_q;break Q;case o9:return l9;case XZ:default:return v0}if(Q.next_out=K,Q.avail_out=W,Q.next_in=V,Q.avail_in=X,q.hold=G,q.bits=j,q.wsize||U!==Q.avail_out&&q.mode<p&&(q.mode<c9||$!==Wq)){if(uq(Q,Q.output,Q.next_out,U-Q.avail_out))return q.mode=o9,l9}if(H-=Q.avail_in,U-=Q.avail_out,Q.total_in+=H,Q.total_out+=U,q.total+=U,q.wrap&&U)Q.adler=q.check=q.flags?t0(q.check,Y,U,Q.next_out-U):d9(q.check,Y,U,Q.next_out-U);if(Q.data_type=q.bits+(q.last?64:0)+(q.mode===U1?128:0)+(q.mode===P2||q.mode===m9?256:0),(H===0&&U===0||$===Wq)&&w===o1)w=KZ;return w}function LZ(Q){if(!Q||!Q.state)return v0;var $=Q.state;if($.window)$.window=null;return Q.state=null,o1}function OZ(Q,$){var q;if(!Q||!Q.state)return v0;if(q=Q.state,(q.wrap&2)===0)return v0;return q.head=$,$.done=!1,o1}function NZ(Q,$){var q=$.length,J,Y,V;if(!Q||!Q.state)return v0;if(J=Q.state,J.wrap!==0&&J.mode!==C2)return v0;if(J.mode===C2){if(Y=1,Y=d9(Y,$,q,0),Y!==J.check)return _q}if(V=uq(Q,$,q,q),V)return J.mode=o9,l9;return J.havedict=1,o1}BZ.inflateReset=fq;BZ.inflateReset2=mq;BZ.inflateResetKeep=hq;BZ.inflateInit=HZ;BZ.inflateInit2=cq;BZ.inflate=FZ;BZ.inflateEnd=LZ;BZ.inflateGetHeader=OZ;BZ.inflateSetDictionary=NZ;BZ.inflateInfo="pako inflate (from Nodeca project)"});var i9=D((gO,dq)=>{dq.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 oq=D((_O,lq)=>{function vZ(){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}lq.exports=vZ});var nq=D((yZ)=>{var B6=pq(),U8=j1(),T2=E9(),n=i9(),n9=Z2(),SZ=k9(),EZ=oq(),iq=Object.prototype.toString;function i1(Q){if(!(this instanceof i1))return new i1(Q);this.options=U8.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 SZ,this.strm.avail_out=0;var q=B6.inflateInit2(this.strm,$.windowBits);if(q!==n.Z_OK)throw Error(n9[q]);if(this.header=new EZ,B6.inflateGetHeader(this.strm,this.header),$.dictionary){if(typeof $.dictionary==="string")$.dictionary=T2.string2buf($.dictionary);else if(iq.call($.dictionary)==="[object ArrayBuffer]")$.dictionary=new Uint8Array($.dictionary);if($.raw){if(q=B6.inflateSetDictionary(this.strm,$.dictionary),q!==n.Z_OK)throw Error(n9[q])}}}i1.prototype.push=function(Q,$){var q=this.strm,J=this.options.chunkSize,Y=this.options.dictionary,V,K,X,W,G,j=!1;if(this.ended)return!1;if(K=$===~~$?$:$===!0?n.Z_FINISH:n.Z_NO_FLUSH,typeof Q==="string")q.input=T2.binstring2buf(Q);else if(iq.call(Q)==="[object ArrayBuffer]")q.input=new Uint8Array(Q);else q.input=Q;q.next_in=0,q.avail_in=q.input.length;do{if(q.avail_out===0)q.output=new U8.Buf8(J),q.next_out=0,q.avail_out=J;if(V=B6.inflate(q,n.Z_NO_FLUSH),V===n.Z_NEED_DICT&&Y)V=B6.inflateSetDictionary(this.strm,Y);if(V===n.Z_BUF_ERROR&&j===!0)V=n.Z_OK,j=!1;if(V!==n.Z_STREAM_END&&V!==n.Z_OK)return this.onEnd(V),this.ended=!0,!1;if(q.next_out){if(q.avail_out===0||V===n.Z_STREAM_END||q.avail_in===0&&(K===n.Z_FINISH||K===n.Z_SYNC_FLUSH))if(this.options.to==="string"){if(X=T2.utf8border(q.output,q.next_out),W=q.next_out-X,G=T2.buf2string(q.output,X),q.next_out=W,q.avail_out=J-W,W)U8.arraySet(q.output,q.output,X,W,0);this.onData(G)}else this.onData(U8.shrinkBuf(q.output,q.next_out))}if(q.avail_in===0&&q.avail_out===0)j=!0}while((q.avail_in>0||q.avail_out===0)&&V!==n.Z_STREAM_END);if(V===n.Z_STREAM_END)K=n.Z_FINISH;if(K===n.Z_FINISH)return V=B6.inflateEnd(this.strm),this.onEnd(V),this.ended=!0,V===n.Z_OK;if(K===n.Z_SYNC_FLUSH)return this.onEnd(n.Z_OK),q.avail_out=0,!0;return!0};i1.prototype.onData=function(Q){this.chunks.push(Q)};i1.prototype.onEnd=function(Q){if(Q===n.Z_OK)if(this.options.to==="string")this.result=this.chunks.join("");else this.result=U8.flattenChunks(this.chunks);this.chunks=[],this.err=Q,this.msg=this.strm.msg};function r9(Q,$){var q=new i1($);if(q.push(Q,!0),q.err)throw q.msg||n9[q.err];return q.result}function kZ(Q,$){return $=$||{},$.raw=!0,r9(Q,$)}yZ.Inflate=i1;yZ.inflate=r9;yZ.inflateRaw=kZ;yZ.ungzip=r9});var sq=D((hO,aq)=>{var fZ=j1().assign,mZ=e$(),cZ=nq(),uZ=i9(),rq={};fZ(rq,mZ,cZ,uZ);aq.exports=rq});var eq=D((oZ)=>{var pZ=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",dZ=sq(),tq=l(),A2=B0(),lZ=pZ?"uint8array":"array";oZ.magic="\b\x00";function n1(Q,$){A2.call(this,"FlateWorker/"+Q),this._pako=null,this._pakoAction=Q,this._pakoOptions=$,this.meta={}}tq.inherits(n1,A2);n1.prototype.processChunk=function(Q){if(this.meta=Q.meta,this._pako===null)this._createPako();this._pako.push(tq.transformTo(lZ,Q.data),!1)};n1.prototype.flush=function(){if(A2.prototype.flush.call(this),this._pako===null)this._createPako();this._pako.push([],!0)};n1.prototype.cleanUp=function(){A2.prototype.cleanUp.call(this),this._pako=null};n1.prototype._createPako=function(){this._pako=new dZ[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var Q=this;this._pako.onData=function($){Q.push({data:$,meta:Q.meta})}};oZ.compressWorker=function(Q){return new n1("Deflate",Q)};oZ.uncompressWorker=function(){return new n1("Inflate",{})}});var a9=D((aZ)=>{var QJ=B0();aZ.STORE={magic:"\x00\x00",compressWorker:function(){return new QJ("STORE compression")},uncompressWorker:function(){return new QJ("STORE decompression")}};aZ.DEFLATE=eq()});var s9=D((eZ)=>{eZ.LOCAL_FILE_HEADER="PK\x03\x04";eZ.CENTRAL_FILE_HEADER="PK\x01\x02";eZ.CENTRAL_DIRECTORY_END="PK\x05\x06";eZ.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x06\x07";eZ.ZIP64_CENTRAL_DIRECTORY_END="PK\x06\x06";eZ.DATA_DESCRIPTOR="PK\x07\b"});var YJ=D((uO,JJ)=>{var M6=l(),P6=B0(),t9=j6(),$J=X2(),w2=s9(),m=function(Q,$){var q="",J;for(J=0;J<$;J++)q+=String.fromCharCode(Q&255),Q=Q>>>8;return q},KU=function(Q,$){var q=Q;if(!Q)q=$?16893:33204;return(q&65535)<<16},XU=function(Q){return(Q||0)&63},qJ=function(Q,$,q,J,Y,V){var{file:K,compression:X}=Q,W=V!==t9.utf8encode,G=M6.transformTo("string",V(K.name)),j=M6.transformTo("string",t9.utf8encode(K.name)),H=K.comment,U=M6.transformTo("string",V(H)),z=M6.transformTo("string",t9.utf8encode(H)),F=j.length!==K.name.length,N=z.length!==H.length,C,P,L="",A="",B="",O=K.dir,M=K.date,T={crc32:0,compressedSize:0,uncompressedSize:0};if(!$||q)T.crc32=Q.crc32,T.compressedSize=Q.compressedSize,T.uncompressedSize=Q.uncompressedSize;var w=0;if($)w|=8;if(!W&&(F||N))w|=2048;var x=0,v=0;if(O)x|=16;if(Y==="UNIX")v=798,x|=KU(K.unixPermissions,O);else v=20,x|=XU(K.dosPermissions,O);if(C=M.getUTCHours(),C=C<<6,C=C|M.getUTCMinutes(),C=C<<5,C=C|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($J(G),4)+j,L+="up"+m(A.length,2)+A;if(N)B=m(1,1)+m($J(U),4)+z,L+="uc"+m(B.length,2)+B;var R="";R+=`
78
+ \x00`,R+=m(w,2),R+=X.magic,R+=m(C,2),R+=m(P,2),R+=m(T.crc32,4),R+=m(T.compressedSize,4),R+=m(T.uncompressedSize,4),R+=m(G.length,2),R+=m(L.length,2);var q0=w2.LOCAL_FILE_HEADER+R+G+L,T0=w2.CENTRAL_FILE_HEADER+m(v,2)+R+m(U.length,2)+"\x00\x00\x00\x00"+m(x,4)+m(J,4)+G+L+U;return{fileRecord:q0,dirRecord:T0}},GU=function(Q,$,q,J,Y){var V="",K=M6.transformTo("string",Y(J));return V=w2.CENTRAL_DIRECTORY_END+"\x00\x00\x00\x00"+m(Q,2)+m(Q,2)+m($,4)+m(q,4)+m(K.length,2)+K,V},WU=function(Q){var $="";return $=w2.DATA_DESCRIPTOR+m(Q.crc32,4)+m(Q.compressedSize,4)+m(Q.uncompressedSize,4),$};function f0(Q,$,q,J){P6.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=$,this.zipPlatform=q,this.encodeFileName=J,this.streamFiles=Q,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}M6.inherits(f0,P6);f0.prototype.push=function(Q){var $=Q.meta.percent||0,q=this.entriesCount,J=this._sources.length;if(this.accumulate)this.contentBuffer.push(Q);else this.bytesWritten+=Q.data.length,P6.prototype.push.call(this,{data:Q.data,meta:{currentFile:this.currentFile,percent:q?($+100*(q-J-1))/q:100}})};f0.prototype.openedSource=function(Q){this.currentSourceOffset=this.bytesWritten,this.currentFile=Q.file.name;var $=this.streamFiles&&!Q.file.dir;if($){var q=qJ(Q,$,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:q.fileRecord,meta:{percent:0}})}else this.accumulate=!0};f0.prototype.closedSource=function(Q){this.accumulate=!1;var $=this.streamFiles&&!Q.file.dir,q=qJ(Q,$,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(q.dirRecord),$)this.push({data:WU(Q),meta:{percent:100}});else{this.push({data:q.fileRecord,meta:{percent:0}});while(this.contentBuffer.length)this.push(this.contentBuffer.shift())}this.currentFile=null};f0.prototype.flush=function(){var Q=this.bytesWritten;for(var $=0;$<this.dirRecords.length;$++)this.push({data:this.dirRecords[$],meta:{percent:100}});var q=this.bytesWritten-Q,J=GU(this.dirRecords.length,q,Q,this.zipComment,this.encodeFileName);this.push({data:J,meta:{percent:100}})};f0.prototype.prepareNextSource=function(){if(this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused)this.previous.pause();else this.previous.resume()};f0.prototype.registerPrevious=function(Q){this._sources.push(Q);var $=this;return Q.on("data",function(q){$.processChunk(q)}),Q.on("end",function(){if($.closedSource($.previous.streamInfo),$._sources.length)$.prepareNextSource();else $.end()}),Q.on("error",function(q){$.error(q)}),this};f0.prototype.resume=function(){if(!P6.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};f0.prototype.error=function(Q){var $=this._sources;if(!P6.prototype.error.call(this,Q))return!1;for(var q=0;q<$.length;q++)try{$[q].error(Q)}catch(J){}return!0};f0.prototype.lock=function(){P6.prototype.lock.call(this);var Q=this._sources;for(var $=0;$<Q.length;$++)Q[$].lock()};JJ.exports=f0});var VJ=D((HU)=>{var jU=a9(),ZU=YJ(),UU=function(Q,$){var q=Q||$,J=jU[q];if(!J)throw Error(q+" is not a valid compression method !");return J};HU.generateWorker=function(Q,$,q){var J=new ZU($.streamFiles,q,$.platform,$.encodeFileName),Y=0;try{Q.forEach(function(V,K){Y++;var X=UU(K.options.compression,$.compression),W=K.options.compressionOptions||$.compressionOptions||{},G=K.dir,j=K.date;K._compressWorker(X,W).withStreamInfo("file",{name:V,dir:G,date:j,comment:K.comment||"",unixPermissions:K.unixPermissions,dosPermissions:K.dosPermissions}).pipe(J)}),J.entriesCount=Y}catch(V){J.error(V)}return J}});var XJ=D((dO,KJ)=>{var FU=l(),D2=B0();function H8(Q,$){D2.call(this,"Nodejs stream input adapter for "+Q),this._upstreamEnded=!1,this._bindStream($)}FU.inherits(H8,D2);H8.prototype._bindStream=function(Q){var $=this;this._stream=Q,Q.pause(),Q.on("data",function(q){$.push({data:q,meta:{percent:0}})}).on("error",function(q){if($.isPaused)this.generatedError=q;else $.error(q)}).on("end",function(){if($.isPaused)$._upstreamEnded=!0;else $.end()})};H8.prototype.pause=function(){if(!D2.prototype.pause.call(this))return!1;return this._stream.pause(),!0};H8.prototype.resume=function(){if(!D2.prototype.resume.call(this))return!1;if(this._upstreamEnded)this.end();else this._stream.resume();return!0};KJ.exports=H8});var OJ=D((lO,LJ)=>{var LU=j6(),z8=l(),ZJ=B0(),OU=q9(),UJ=J9(),GJ=G2(),NU=W$(),BU=VJ(),WJ=o6(),MU=XJ(),HJ=function(Q,$,q){var J=z8.getTypeOf($),Y,V=z8.extend(q||{},UJ);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=zJ(Q);if(V.createFolders&&(Y=PU(Q)))FJ.call(this,Y,!0);var K=J==="string"&&V.binary===!1&&V.base64===!1;if(!q||typeof q.binary>"u")V.binary=!K;var X=$ instanceof GJ&&$.uncompressedSize===0;if(X||V.dir||!$||$.length===0)V.base64=!1,V.binary=!0,$="",V.compression="STORE",J="string";var W=null;if($ instanceof GJ||$ instanceof ZJ)W=$;else if(WJ.isNode&&WJ.isStream($))W=new MU(Q,$);else W=z8.prepareContent(Q,$,V.binary,V.optimizedBinaryString,V.base64);var G=new NU(Q,W,V);this.files[Q]=G},PU=function(Q){if(Q.slice(-1)==="/")Q=Q.substring(0,Q.length-1);var $=Q.lastIndexOf("/");return $>0?Q.substring(0,$):""},zJ=function(Q){if(Q.slice(-1)!=="/")Q+="/";return Q},FJ=function(Q,$){if($=typeof $<"u"?$:UJ.createFolders,Q=zJ(Q),!this.files[Q])HJ.call(this,Q,null,{dir:!0,createFolders:$});return this.files[Q]};function jJ(Q){return Object.prototype.toString.call(Q)==="[object RegExp]"}var IU={load:function(){throw Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(Q){var $,q,J;for($ in this.files)if(J=this.files[$],q=$.slice(this.root.length,$.length),q&&$.slice(0,this.root.length)===this.root)Q(q,J)},filter:function(Q){var $=[];return this.forEach(function(q,J){if(Q(q,J))$.push(J)}),$},file:function(Q,$,q){if(arguments.length===1)if(jJ(Q)){var J=Q;return this.filter(function(V,K){return!K.dir&&J.test(V)})}else{var Y=this.files[this.root+Q];if(Y&&!Y.dir)return Y;else return null}else Q=this.root+Q,HJ.call(this,Q,$,q);return this},folder:function(Q){if(!Q)return this;if(jJ(Q))return this.filter(function(Y,V){return V.dir&&Q.test(Y)});var $=this.root+Q,q=FJ.call(this,$),J=this.clone();return J.root=q.name,J},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 q=this.filter(function(Y,V){return V.name.slice(0,Q.length)===Q});for(var J=0;J<q.length;J++)delete this.files[q[J].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 $,q={};try{if(q=z8.extend(Q||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:LU.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(z8.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 J=q.comment||this.comment||"";$=BU.generateWorker(this,q,J)}catch(Y){$=new ZJ("error"),$.error(Y)}return new OU($,q.type||"string",q.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($)}};LJ.exports=IU});var e9=D((oO,BJ)=>{var CU=l();function NJ(Q){this.data=Q,this.length=Q.length,this.index=0,this.zero=0}NJ.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,q;this.checkOffset(Q);for(q=this.index+Q-1;q>=this.index;q--)$=($<<8)+this.byteAt(q);return this.index+=Q,$},readString:function(Q){return CU.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))}};BJ.exports=NJ});var QQ=D((iO,PJ)=>{var MJ=e9(),TU=l();function I6(Q){MJ.call(this,Q);for(var $=0;$<this.data.length;$++)Q[$]=Q[$]&255}TU.inherits(I6,MJ);I6.prototype.byteAt=function(Q){return this.data[this.zero+Q]};I6.prototype.lastIndexOfSignature=function(Q){var $=Q.charCodeAt(0),q=Q.charCodeAt(1),J=Q.charCodeAt(2),Y=Q.charCodeAt(3);for(var V=this.length-4;V>=0;--V)if(this.data[V]===$&&this.data[V+1]===q&&this.data[V+2]===J&&this.data[V+3]===Y)return V-this.zero;return-1};I6.prototype.readAndCheckSignature=function(Q){var $=Q.charCodeAt(0),q=Q.charCodeAt(1),J=Q.charCodeAt(2),Y=Q.charCodeAt(3),V=this.readData(4);return $===V[0]&&q===V[1]&&J===V[2]&&Y===V[3]};I6.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,$};PJ.exports=I6});var TJ=D((nO,CJ)=>{var IJ=e9(),AU=l();function C6(Q){IJ.call(this,Q)}AU.inherits(C6,IJ);C6.prototype.byteAt=function(Q){return this.data.charCodeAt(this.zero+Q)};C6.prototype.lastIndexOfSignature=function(Q){return this.data.lastIndexOf(Q)-this.zero};C6.prototype.readAndCheckSignature=function(Q){var $=this.readData(4);return Q===$};C6.prototype.readData=function(Q){this.checkOffset(Q);var $=this.data.slice(this.zero+this.index,this.zero+this.index+Q);return this.index+=Q,$};CJ.exports=C6});var qQ=D((rO,wJ)=>{var AJ=QQ(),wU=l();function $Q(Q){AJ.call(this,Q)}wU.inherits($Q,AJ);$Q.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,$};wJ.exports=$Q});var xJ=D((aO,RJ)=>{var DJ=qQ(),DU=l();function JQ(Q){DJ.call(this,Q)}DU.inherits(JQ,DJ);JQ.prototype.readData=function(Q){this.checkOffset(Q);var $=this.data.slice(this.zero+this.index,this.zero+this.index+Q);return this.index+=Q,$};RJ.exports=JQ});var YQ=D((sO,SJ)=>{var R2=l(),vJ=W1(),RU=QQ(),xU=TJ(),vU=xJ(),SU=qQ();SJ.exports=function(Q){var $=R2.getTypeOf(Q);if(R2.checkSupport($),$==="string"&&!vJ.uint8array)return new xU(Q);if($==="nodebuffer")return new vU(Q);if(vJ.uint8array)return new SU(R2.transformTo("uint8array",Q));return new RU(R2.transformTo("array",Q))}});var gJ=D((tO,yJ)=>{var VQ=YQ(),D1=l(),EU=G2(),EJ=X2(),x2=j6(),v2=a9(),kU=W1(),yU=0,gU=3,_U=function(Q){for(var $ in v2){if(!Object.prototype.hasOwnProperty.call(v2,$))continue;if(v2[$].magic===Q)return v2[$]}return null};function kJ(Q,$){this.options=Q,this.loadOptions=$}kJ.prototype={isEncrypted:function(){return(this.bitFlag&1)===1},useUTF8:function(){return(this.bitFlag&2048)===2048},readLocalPart:function(Q){var $,q;if(Q.skip(22),this.fileNameLength=Q.readInt(2),q=Q.readInt(2),this.fileName=Q.readData(this.fileNameLength),Q.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($=_U(this.compressionMethod),$===null)throw Error("Corrupted zip : compression "+D1.pretty(this.compressionMethod)+" unknown (inner file : "+D1.transformTo("string",this.fileName)+")");this.decompressed=new EU(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===yU)this.dosPermissions=this.externalFileAttributes&63;if(Q===gU)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=VQ(this.extraFields[1].value);if(this.uncompressedSize===D1.MAX_VALUE_32BITS)this.uncompressedSize=Q.readInt(8);if(this.compressedSize===D1.MAX_VALUE_32BITS)this.compressedSize=Q.readInt(8);if(this.localHeaderOffset===D1.MAX_VALUE_32BITS)this.localHeaderOffset=Q.readInt(8);if(this.diskNumberStart===D1.MAX_VALUE_32BITS)this.diskNumberStart=Q.readInt(4)},readExtraFields:function(Q){var $=Q.index+this.extraFieldsLength,q,J,Y;if(!this.extraFields)this.extraFields={};while(Q.index+4<$)q=Q.readInt(2),J=Q.readInt(2),Y=Q.readData(J),this.extraFields[q]={id:q,length:J,value:Y};Q.setIndex($)},handleUTF8:function(){var Q=kU.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=x2.utf8decode(this.fileName),this.fileCommentStr=x2.utf8decode(this.fileComment);else{var $=this.findExtraFieldUnicodePath();if($!==null)this.fileNameStr=$;else{var q=D1.transformTo(Q,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(q)}var J=this.findExtraFieldUnicodeComment();if(J!==null)this.fileCommentStr=J;else{var Y=D1.transformTo(Q,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(Y)}}},findExtraFieldUnicodePath:function(){var Q=this.extraFields[28789];if(Q){var $=VQ(Q.value);if($.readInt(1)!==1)return null;if(EJ(this.fileName)!==$.readInt(4))return null;return x2.utf8decode($.readData(Q.length-5))}return null},findExtraFieldUnicodeComment:function(){var Q=this.extraFields[25461];if(Q){var $=VQ(Q.value);if($.readInt(1)!==1)return null;if(EJ(this.fileComment)!==$.readInt(4))return null;return x2.utf8decode($.readData(Q.length-5))}return null}};yJ.exports=kJ});var hJ=D((eO,bJ)=>{var bU=YQ(),H1=l(),m0=s9(),hU=gJ(),fU=W1();function _J(Q){this.files=[],this.loadOptions=Q}_J.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 ("+H1.pretty($)+", expected "+H1.pretty(Q)+")")}},isSignature:function(Q,$){var q=this.reader.index;this.reader.setIndex(Q);var J=this.reader.readString(4),Y=J===$;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 Q=this.reader.readData(this.zipCommentLength),$=fU.uint8array?"uint8array":"array",q=H1.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 Q=this.zip64EndOfCentralSize-44,$=0,q,J,Y;while($<Q)q=this.reader.readInt(2),J=this.reader.readInt(4),Y=this.reader.readData(J),this.zip64ExtensibleData[q]={id:q,length:J,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(m0.LOCAL_FILE_HEADER),$.readLocalPart(this.reader),$.handleUTF8(),$.processAttributes()},readCentralDir:function(){var Q;this.reader.setIndex(this.centralDirOffset);while(this.reader.readAndCheckSignature(m0.CENTRAL_FILE_HEADER))Q=new hU({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(m0.CENTRAL_DIRECTORY_END);if(Q<0){var $=!this.isSignature(0,m0.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 q=Q;if(this.checkSignature(m0.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===H1.MAX_VALUE_16BITS||this.diskWithCentralDirStart===H1.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===H1.MAX_VALUE_16BITS||this.centralDirRecords===H1.MAX_VALUE_16BITS||this.centralDirSize===H1.MAX_VALUE_32BITS||this.centralDirOffset===H1.MAX_VALUE_32BITS){if(this.zip64=!0,Q=this.reader.lastIndexOfSignature(m0.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(m0.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,m0.ZIP64_CENTRAL_DIRECTORY_END)){if(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(m0.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(m0.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var J=this.centralDirOffset+this.centralDirSize;if(this.zip64)J+=20,J+=12+this.zip64EndOfCentralSize;var Y=q-J;if(Y>0)if(this.isSignature(q,m0.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=bU(Q)},load:function(Q){this.prepareReader(Q),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}};bJ.exports=_J});var cJ=D((QN,mJ)=>{var KQ=l(),S2=X6(),mU=j6(),cU=hJ(),uU=K9(),fJ=o6();function pU(Q){return new S2.Promise(function($,q){var J=Q.decompressed.getContentWorker().pipe(new uU);J.on("error",function(Y){q(Y)}).on("end",function(){if(J.streamInfo.crc32!==Q.decompressed.crc32)q(Error("Corrupted zip : CRC32 mismatch"));else $()}).resume()})}mJ.exports=function(Q,$){var q=this;if($=KQ.extend($||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:mU.utf8decode}),fJ.isNode&&fJ.isStream(Q))return S2.Promise.reject(Error("JSZip can't accept a stream when loading a zip file."));return KQ.prepareContent("the loaded zip file",Q,!0,$.optimizedBinaryString,$.base64).then(function(J){var Y=new cU($);return Y.load(J),Y}).then(function(Y){var V=[S2.Promise.resolve(Y)],K=Y.files;if($.checkCRC32)for(var X=0;X<K.length;X++)V.push(pU(K[X]));return S2.Promise.all(V)}).then(function(Y){var V=Y.shift(),K=V.files;for(var X=0;X<K.length;X++){var W=K[X],G=W.fileNameStr,j=KQ.resolve(W.fileNameStr);if(q.file(j,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)q.file(j).unsafeOriginalName=G}if(V.zipComment.length)q.comment=V.zipComment;return q})}});var pJ=D(($N,uJ)=>{function S0(){if(!(this instanceof S0))return new S0;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 S0;for(var $ in this)if(typeof this[$]!=="function")Q[$]=this[$];return Q}}S0.prototype=OJ();S0.prototype.loadAsync=cJ();S0.support=W1();S0.defaults=J9();S0.version="3.10.1";S0.loadAsync=function(Q,$){return new S0().loadAsync(Q,$)};S0.external=X6();uJ.exports=S0});var R1=D((qN,XQ)=>{var k2=process||{},dJ=k2.argv||[],E2=k2.env||{},dU=!(!!E2.NO_COLOR||dJ.includes("--no-color"))&&(!!E2.FORCE_COLOR||dJ.includes("--color")||k2.platform==="win32"||(k2.stdout||{}).isTTY&&E2.TERM!=="dumb"||!!E2.CI),lU=(Q,$,q=Q)=>(J)=>{let Y=""+J,V=Y.indexOf($,Q.length);return~V?Q+oU(Y,$,q,V)+$:Q+Y+$},oU=(Q,$,q,J)=>{let Y="",V=0;do Y+=Q.substring(V,J)+q,V=J+$.length,J=Q.indexOf($,V);while(~J);return Y+Q.substring(V)},lJ=(Q=dU)=>{let $=Q?lU:()=>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")}};XQ.exports=lJ();XQ.exports.createColors=lJ});import{homedir as jH}from"node:os";import u from"node:path";function ZH(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"),q=u.join(e,".gemini","antigravity","mcp_config.json"),J=u.join(e,".antigravity","mcp_config.json");if(process.platform==="win32")return[$,q,J];return[q,J,$]}async function jY(){let{stat:Q}=await import("node:fs/promises"),[$,...q]=v1();for(let J of[$,...q])try{return await Q(J),J}catch{}return $}function ZY(){let[Q]=v1();return Q}function UH(){return u.dirname(ZY())}function S1(){return u.join(e,".gemini","antigravity","skills","petdex")}function P0(Q,$,q,J){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",` ${HH(Q,q,J)};`,"fi"].join(" ")}`}function HH(Q,$,q){let J=q!=null?`{"state":"${$}","duration":${q},"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 ${r1}`,'-H "Content-Type: application/json"','-H "X-Petdex-Update-Token: $T"',`--data-raw '${J}'`,">/dev/null 2>&1 || true"].join(" ")}function zH(){let Q=r1.replace(/\/state$/,"/bubble");return String.raw`// petdex hook plugin. Auto-generated by 'petdex hooks install'.
79
79
  // Forwards OpenCode lifecycle events to the petdex desktop mascot via HTTP.
80
80
  // Edit STATE_MAP below to customize which state each event triggers.
81
81
 
@@ -239,25 +239,25 @@ const PetdexPlugin = {
239
239
 
240
240
  export default PetdexPlugin;
241
241
  export { PetdexPlugin };
242
- `}function x1(Q){if(Q.startsWith(e))return`~${Q.slice(e.length)}`;return Q}function Xz(Q){let $=Q.split(`
243
- `),q=/^\s*\[([^[\]]+)\]\s*(?:#.*)?$/,J=/^\s*codex_hooks\s*=\s*(.+?)\s*(?:#.*)?$/,Y=null,V=null;for(let X=0;X<$.length;X+=1){let K=$[X],W=K.match(q);if(W){if(Y=W[1].trim(),Y==="features"&&V===null)V=X;continue}if(Y!=="features")continue;let G=K.match(J);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 Kz(Q,$){if($.state==="enabled"||$.state==="missing-file")return Q;let q=Q.split(`
244
- `);if($.state==="wrong-value"){let Y=q[$.replaceLine],V=/^(\s*codex_hooks\s*=\s*)([^#\n]+?)(\s*(?:#.*)?)$/,X=Y.match(V);return q[$.replaceLine]=X?`${X[1]}true${X[3]}`:"codex_hooks = true",q.join(`
242
+ `}function x1(Q){if(Q.startsWith(e))return`~${Q.slice(e.length)}`;return Q}function FH(Q){let $=Q.split(`
243
+ `),q=/^\s*\[([^[\]]+)\]\s*(?:#.*)?$/,J=/^\s*codex_hooks\s*=\s*(.+?)\s*(?:#.*)?$/,Y=null,V=null;for(let K=0;K<$.length;K+=1){let X=$[K],W=X.match(q);if(W){if(Y=W[1].trim(),Y==="features"&&V===null)V=K;continue}if(Y!=="features")continue;let G=X.match(J);if(!G)continue;if(G[1].trim()==="true")return{state:"enabled"};return{state:"wrong-value",replaceLine:K}}if(V===null)return{state:"no-features-section"};return{state:"no-key",insertAfterLine:V}}function LH(Q,$){if($.state==="enabled"||$.state==="missing-file")return Q;let q=Q.split(`
244
+ `);if($.state==="wrong-value"){let Y=q[$.replaceLine],V=/^(\s*codex_hooks\s*=\s*)([^#\n]+?)(\s*(?:#.*)?)$/,K=Y.match(V);return q[$.replaceLine]=K?`${K[1]}true${K[3]}`:"codex_hooks = true",q.join(`
245
245
  `)}if($.state==="no-key")return q.splice($.insertAfterLine+1,0,"codex_hooks = true"),q.join(`
246
246
  `);let J=Q.endsWith(`
247
247
  `)||Q.length===0?"":`
248
248
  `;return`${Q}${J}
249
249
  [features]
250
250
  codex_hooks = true
251
- `}var F8=7777,r1,e,_2,H1;var L8=H0(()=>{r1=`http://127.0.0.1:${F8}/state`,e=$z(),_2=qz();H1=[{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:P0("claude-code","user-prompt","jumping",800)}]}],PreToolUse:[{hooks:[{type:"command",command:P0("claude-code","pre","running")}]}],PostToolUse:[{hooks:[{type:"command",command:P0("claude-code","post","idle")}]}],Notification:[{hooks:[{type:"command",command:P0("claude-code","notification","waiting")}]}],Stop:[{hooks:[{type:"command",command:P0("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"),q=!0,J="";try{J=await Q($,"utf8")}catch(X){let K=X.code;if(K==="ENOENT")q=!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=q?Xz(J):{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}),!q)try{return await X($,`[features]
251
+ `}var F8=7777,r1,e,_2,z1;var L8=z0(()=>{r1=`http://127.0.0.1:${F8}/state`,e=jH(),_2=ZH();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:P0("claude-code","user-prompt","jumping",800)}]}],PreToolUse:[{hooks:[{type:"command",command:P0("claude-code","pre","running")}]}],PostToolUse:[{hooks:[{type:"command",command:P0("claude-code","post","idle")}]}],Notification:[{hooks:[{type:"command",command:P0("claude-code","notification","waiting")}]}],Stop:[{hooks:[{type:"command",command:P0("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"),q=!0,J="";try{J=await Q($,"utf8")}catch(K){let X=K.code;if(X==="ENOENT")q=!1;else return[{level:"warn",message:`Could not read ${$} (${X??"io_error"}). Make sure [features] codex_hooks = true is set there before Codex picks up the hooks.`}]}let Y=q?FH(J):{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:K,mkdir:X}=await import("node:fs/promises");if(await X(u.dirname($),{recursive:!0}),!q)try{return await K($,`[features]
252
252
  codex_hooks = true
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,J)}catch(z){return{ok:!1,message:`Backup failed: ${z.message}`}}let U=Kz(J,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:P0("codex","user-prompt","jumping",800)}]}],PreToolUse:[{hooks:[{type:"command",command:P0("codex","pre","running")}]}],PostToolUse:[{hooks:[{type:"command",command:P0("codex","post","idle")}]}],PermissionRequest:[{hooks:[{type:"command",command:P0("codex","notification","waiting")}]}],Stop:[{hooks:[{type:"command",command:P0("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:P0("gemini","pre","running")}]}],AfterTool:[{hooks:[{type:"command",command:P0("gemini","post","idle")}]}],SessionEnd:[{hooks:[{type:"command",command:P0("gemini","stop","waving",1500)}]}]}}}},{id:"opencode",displayName:"OpenCode",configDir:_2,configFile:u.join(_2,"plugins","petdex.js"),slashCommandPath:u.join(_2,"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 Vz()},async postInstallChecks(){return[{level:"info",message:`OpenCode plugin installed at ${x1(u.join(_2,"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:Jz(),configFile:jY(),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.
253
+ `,"utf8"),{ok:!0,message:`Created ${x1($)} with [features] codex_hooks = true`}}catch(H){return{ok:!1,message:`Write failed: ${H.message}`}}let W=new Date().toISOString().replace(/[:.]/g,"-"),G=`${$}.${W}.bak`;try{await K(G,J)}catch(H){return{ok:!1,message:`Backup failed: ${H.message}`}}let j=LH(J,Y);try{return await K($,j,"utf8"),{ok:!0,message:`codex_hooks = true set in ${x1($)} (backup: ${u.basename(G)})`}}catch(H){return{ok:!1,message:`Write failed: ${H.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:P0("codex","user-prompt","jumping",800)}]}],PreToolUse:[{hooks:[{type:"command",command:P0("codex","pre","running")}]}],PostToolUse:[{hooks:[{type:"command",command:P0("codex","post","idle")}]}],PermissionRequest:[{hooks:[{type:"command",command:P0("codex","notification","waiting")}]}],Stop:[{hooks:[{type:"command",command:P0("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:P0("gemini","pre","running")}]}],AfterTool:[{hooks:[{type:"command",command:P0("gemini","post","idle")}]}],SessionEnd:[{hooks:[{type:"command",command:P0("gemini","stop","waving",1500)}]}]}}}},{id:"opencode",displayName:"OpenCode",configDir:_2,configFile:u.join(_2,"plugins","petdex.js"),slashCommandPath:u.join(_2,"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 zH()},async postInstallChecks(){return[{level:"info",message:`OpenCode plugin installed at ${x1(u.join(_2,"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:UH(),configFile:ZY(),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
254
 
255
255
  To activate:
256
256
  1. Open Antigravity → Agent Panel → ... → MCP Servers
257
257
  2. Verify "petdex" MCP server is listed and running
258
258
  3. The Petdex Agent Skill is installed at ~/.gemini/antigravity/skills/petdex/
259
259
 
260
- The agent should start updating the mascot automatically when working in this project.`}]}}]});var iY={};E8(iY,{persistRunningBinary:()=>D8,PERSIST_PATH:()=>g0,PERSIST_DIR:()=>RQ});import{copyFile as WH,mkdir as UH}from"node:fs/promises";import{homedir as jH}from"node:os";import{join as oY}from"node:path";async function D8(){let Q=process.argv[1];if(!Q)return{ok:!1,path:g0,reason:"no argv[1]"};try{await UH(RQ,{recursive:!0}),await WH(Q,g0);let{chmod:$}=await import("node:fs/promises");try{await $(g0,493)}catch{}return{ok:!0,path:g0}}catch($){return{ok:!1,path:g0,reason:$.message}}}var RQ,g0;var w8=H0(()=>{RQ=oY(jH(),".petdex","bin"),g0=oY(RQ,"petdex.js")});function nY(){return`---
260
+ The agent should start updating the mascot automatically when working in this project.`}]}}]});var sY={};E8(sY,{persistRunningBinary:()=>w8,PERSIST_PATH:()=>g0,PERSIST_DIR:()=>RQ});import{copyFile as Bz,mkdir as Mz}from"node:fs/promises";import{homedir as Pz}from"node:os";import{join as aY}from"node:path";async function w8(){let Q=process.argv[1];if(!Q)return{ok:!1,path:g0,reason:"no argv[1]"};try{await Mz(RQ,{recursive:!0}),await Bz(Q,g0);let{chmod:$}=await import("node:fs/promises");try{await $(g0,493)}catch{}return{ok:!0,path:g0}}catch($){return{ok:!1,path:g0,reason:$.message}}}var RQ,g0;var D8=z0(()=>{RQ=aY(Pz(),".petdex","bin"),g0=aY(RQ,"petdex.js")});function tY(){return`---
261
261
  name: petdex
262
262
  description: >
263
263
  Coordinates with the petdex desktop mascot to reflect agent activity.
@@ -336,7 +336,7 @@ The server command is installed with the same Node.js runtime that ran
336
336
 
337
337
  Make sure petdex-desktop is running (\`petdex up\`) for the mascot to
338
338
  appear.
339
- `}function rY(){return{mcpServers:{petdex:{command:process.execPath,args:[g0,"mcp-server"]}}}}var aY=H0(()=>{w8()});import{mkdir as ZH,rm as xQ,writeFile as zH}from"node:fs/promises";import{homedir as HH}from"node:os";import sY from"node:path";async function eY(Q){if(await ZH(sY.dirname(Q.slashCommandPath),{recursive:!0}),await zH(Q.slashCommandPath,Q.id==="gemini"?LH:FH,"utf8"),Q.id==="gemini")await xQ(tY,{force:!0})}async function o2(Q){try{if(await xQ(Q.slashCommandPath,{force:!0}),Q.id==="gemini")await xQ(tY,{force:!0})}catch{}}var $1='node "$HOME/.petdex/bin/petdex.js"',FH,LH,tY;var vQ=H0(()=>{FH=`---
339
+ `}function eY(){return{mcpServers:{petdex:{command:process.execPath,args:[g0,"mcp-server"]}}}}var Q3=z0(()=>{D8()});import{mkdir as Iz,rm as xQ,writeFile as Cz}from"node:fs/promises";import{homedir as Tz}from"node:os";import $3 from"node:path";async function J3(Q){if(await Iz($3.dirname(Q.slashCommandPath),{recursive:!0}),await Cz(Q.slashCommandPath,Q.id==="gemini"?wz:Az,"utf8"),Q.id==="gemini")await xQ(q3,{force:!0})}async function o2(Q){try{if(await xQ(Q.slashCommandPath,{force:!0}),Q.id==="gemini")await xQ(q3,{force:!0})}catch{}}var $1='node "$HOME/.petdex/bin/petdex.js"',Az,wz,q3;var vQ=z0(()=>{Az=`---
340
340
  description: Wake or sleep the petdex mascot. Toggles the floating pet on/off
341
341
  ---
342
342
 
@@ -355,7 +355,7 @@ Show the command output verbatim to the user. Don't reinterpret, don't explain.
355
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.
356
356
 
357
357
  Arguments: \`$ARGUMENTS\`
358
- `,LH=`description = "Wake or sleep the petdex mascot. Toggles the floating pet on/off"
358
+ `,wz=`description = "Wake or sleep the petdex mascot. Toggles the floating pet on/off"
359
359
 
360
360
  prompt = """
361
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.
@@ -374,70 +374,70 @@ If \`$HOME/.petdex/bin/petdex.js\` doesn't exist, the user hasn't run \`petdex h
374
374
 
375
375
  Arguments: \`{{args}}\`
376
376
  """
377
- `,tY=sY.join(HH(),".gemini","antigravity","global_workflows","petdex.md")});import{spawnSync as OH}from"node:child_process";import{mkdir as SQ,readFile as yQ,rm as NH,stat as Q3,writeFile as R8}from"node:fs/promises";import{homedir as BH}from"node:os";import i2 from"node:path";async function PH(){return Promise.all(H1.map(async(Q)=>({agent:Q,installed:await $3(Q.configDir)})))}async function $3(Q){try{return await Q3(Q),!0}catch{return!1}}async function gQ(){N0(s.default.bgMagenta(s.default.white(" petdex hooks install ")));try{let{persistRunningBinary:W}=await Promise.resolve().then(() => (w8(),iY)),G=await W();if(!G.ok&&G.reason)i.warn(`Could not persist petdex binary (${G.reason}). Bubbles will be disabled.`)}catch(W){i.warn(`Could not persist petdex binary (${W.message}). Bubbles will be disabled.`)}let Q=await PH(),$=Q.some((W)=>W.installed);i.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 q=await E7({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(V1(q)||q.length===0)return d("No agents selected. Bye."),{installedAgents:[]};let J=[],Y=[],V=[],X=q,K=new Set(X);for(let W of X){let G=H1.find((U)=>U.id===W);if(!G)continue;try{if(await _Q(G,{installSlashCommand:IH(G,K)}),V.push(G.id),J.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){J.push(` ${s.default.red("✗")} ${s.default.bold(G.displayName)} ${s.default.red(U instanceof Error?U.message:String(U))}`)}}b0(J.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(i.warn(`${z} ${s.default.bold(W)}
379
- ${U.message}`),U.fix){let Z=await m8({message:U.fix.prompt,initialValue:!0});if(!V1(Z)&&Z){let H=await U.fix.apply();if(H.ok)i.info(`${s.default.green("✓")} ${H.message}`);else i.warn(`${s.default.red("✗")} ${H.message}`)}}}return{installedAgents:V}}function IH(Q,$){return Q.id!=="antigravity"&&!(Q.id==="gemini"&&$.has("antigravity"))}async function _Q(Q,$={}){await SQ(i2.dirname(Q.configFile),{recursive:!0});let q=Q.build();if(Q.id!=="antigravity")if($.installSlashCommand===!1)await o2(Q);else await eY(Q);if(Q.id==="opencode"){let K=await kQ(Q.configFile);return await R8(Q.configFile,q,"utf8"),{backupPath:K}}if(Q.id==="antigravity")return await wH(),{backupPath:null};let J=await EQ(Q.configFile);if(J.kind==="error")throw Error(`Refusing to overwrite ${Q.configFile}: ${J.message}.
380
- Fix the file (or rename it) and run \`petdex hooks install\` again.`);let Y=J.kind==="ok"?await kQ(Q.configFile):null,V=J.kind==="ok"?J.value:{},X=CH(V,q);return await R8(Q.configFile,`${JSON.stringify(X,null,2)}
381
- `,"utf8"),{backupPath:Y}}async function EQ(Q){let $;try{$=await yQ(Q,"utf8")}catch(q){let J=q.code;if(J==="ENOENT")return{kind:"missing"};return{kind:"error",message:`read failed (${J??q.name}): ${q.message}`}}try{return{kind:"ok",value:JSON.parse($)}}catch(q){return{kind:"error",message:`JSON parse failed: ${q.message}`}}}async function kQ(Q){if(!await $3(Q))return null;let $=new Date().toISOString().replace(/[:.]/g,"-"),q=`${Q}.${$}.bak`,J=await yQ(Q);return await R8(q,J),q}function CH(Q,$){let q={...Q},J=$.hooks??{},V={...q.hooks??{}};for(let[X,K]of Object.entries(J)){let G=(Array.isArray(V[X])?V[X]:[]).filter((U)=>!TH(U));V[X]=[...G,...K]}return q.hooks=V,q}function TH(Q){if(typeof Q!=="object"||Q==null)return!1;return AH(Q).some((q)=>q.includes(`localhost:${F8}/state`)||q.includes(r1))}function AH(Q){let $=[];function q(J){if(typeof J==="string"){$.push(J);return}if(Array.isArray(J)){for(let Y of J)q(Y);return}if(typeof J==="object"&&J!=null)for(let Y of Object.values(J))q(Y)}return q(Q),$}async function DH(){try{await Q3(g0);let Q=OH(process.execPath,[g0,"mcp-server"],{encoding:"utf8",input:"",timeout:5000});return Q.status===0&&Q.stdout===""}catch{return!1}}async function wH(){if(await D8().catch(()=>{}),!await DH())throw Error(`Petdex persisted binary missing or not functional: ${g0}.
377
+ `,q3=$3.join(Tz(),".gemini","antigravity","global_workflows","petdex.md")});import{spawnSync as Dz}from"node:child_process";import{mkdir as SQ,readFile as yQ,rm as Rz,stat as Y3,writeFile as R8}from"node:fs/promises";import{homedir as xz}from"node:os";import i2 from"node:path";async function Sz(){return Promise.all(z1.map(async(Q)=>({agent:Q,installed:await V3(Q.configDir)})))}async function V3(Q){try{return await Y3(Q),!0}catch{return!1}}async function gQ(){N0(s.default.bgMagenta(s.default.white(" petdex hooks install ")));try{let{persistRunningBinary:W}=await Promise.resolve().then(() => (D8(),sY)),G=await W();if(!G.ok&&G.reason)i.warn(`Could not persist petdex binary (${G.reason}). Bubbles will be disabled.`)}catch(W){i.warn(`Could not persist petdex binary (${W.message}). Bubbles will be disabled.`)}let Q=await Sz(),$=Q.some((W)=>W.installed);i.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 j=G?s.default.green("●"):s.default.dim("○"),H=G?s.default.dim("installed"):s.default.dim("not found");console.log(` ${j} ${s.default.bold(W.displayName)} ${H}`)}let q=await E7({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(V1(q)||q.length===0)return d("No agents selected. Bye."),{installedAgents:[]};let J=[],Y=[],V=[],K=q,X=new Set(K);for(let W of K){let G=z1.find((j)=>j.id===W);if(!G)continue;try{if(await _Q(G,{installSlashCommand:Ez(G,X)}),V.push(G.id),J.push(` ${s.default.green("✓")} ${s.default.bold(G.displayName)}`),G.postInstallChecks)try{let j=await G.postInstallChecks();if(j.length>0)Y.push({agent:G.displayName,notes:j})}catch{}}catch(j){J.push(` ${s.default.red("✗")} ${s.default.bold(G.displayName)} ${s.default.red(j instanceof Error?j.message:String(j))}`)}}b0(J.join(`
378
+ `),"Done");for(let{agent:W,notes:G}of Y)for(let j of G){let H=j.level==="action"?s.default.bgYellow(s.default.black(" action needed ")):j.level==="warn"?s.default.yellow("!"):s.default.cyan("i");if(i.warn(`${H} ${s.default.bold(W)}
379
+ ${j.message}`),j.fix){let U=await m8({message:j.fix.prompt,initialValue:!0});if(!V1(U)&&U){let z=await j.fix.apply();if(z.ok)i.info(`${s.default.green("✓")} ${z.message}`);else i.warn(`${s.default.red("✗")} ${z.message}`)}}}return{installedAgents:V}}function Ez(Q,$){return Q.id!=="antigravity"&&!(Q.id==="gemini"&&$.has("antigravity"))}async function _Q(Q,$={}){await SQ(i2.dirname(Q.configFile),{recursive:!0});let q=Q.build();if(Q.id!=="antigravity")if($.installSlashCommand===!1)await o2(Q);else await J3(Q);if(Q.id==="opencode"){let X=await kQ(Q.configFile);return await R8(Q.configFile,q,"utf8"),{backupPath:X}}if(Q.id==="antigravity")return await bz(),{backupPath:null};let J=await EQ(Q.configFile);if(J.kind==="error")throw Error(`Refusing to overwrite ${Q.configFile}: ${J.message}.
380
+ Fix the file (or rename it) and run \`petdex hooks install\` again.`);let Y=J.kind==="ok"?await kQ(Q.configFile):null,V=J.kind==="ok"?J.value:{},K=kz(V,q);return await R8(Q.configFile,`${JSON.stringify(K,null,2)}
381
+ `,"utf8"),{backupPath:Y}}async function EQ(Q){let $;try{$=await yQ(Q,"utf8")}catch(q){let J=q.code;if(J==="ENOENT")return{kind:"missing"};return{kind:"error",message:`read failed (${J??q.name}): ${q.message}`}}try{return{kind:"ok",value:JSON.parse($)}}catch(q){return{kind:"error",message:`JSON parse failed: ${q.message}`}}}async function kQ(Q){if(!await V3(Q))return null;let $=new Date().toISOString().replace(/[:.]/g,"-"),q=`${Q}.${$}.bak`,J=await yQ(Q);return await R8(q,J),q}function kz(Q,$){let q={...Q},J=$.hooks??{},V={...q.hooks??{}};for(let[K,X]of Object.entries(J)){let G=(Array.isArray(V[K])?V[K]:[]).filter((j)=>!yz(j));V[K]=[...G,...X]}return q.hooks=V,q}function yz(Q){if(typeof Q!=="object"||Q==null)return!1;return gz(Q).some((q)=>q.includes(`localhost:${F8}/state`)||q.includes(r1))}function gz(Q){let $=[];function q(J){if(typeof J==="string"){$.push(J);return}if(Array.isArray(J)){for(let Y of J)q(Y);return}if(typeof J==="object"&&J!=null)for(let Y of Object.values(J))q(Y)}return q(Q),$}async function _z(){try{await Y3(g0);let Q=Dz(process.execPath,[g0,"mcp-server"],{encoding:"utf8",input:"",timeout:5000});return Q.status===0&&Q.stdout===""}catch{return!1}}async function bz(){if(await w8().catch(()=>{}),!await _z())throw Error(`Petdex persisted binary missing or not functional: ${g0}.
382
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 UY();await SQ(i2.dirname($),{recursive:!0});let q=rY(),J=await RH($);if(J.kind==="error")throw Error(`Refusing to overwrite ${$}: ${J.message}.
384
- Fix the file (or rename it) and run \`petdex hooks install\` again.`);if(J.kind==="ok")await kQ($);let Y=J.kind==="ok"?J.value:{},V=Y.mcpServers??{},X={...Y,mcpServers:{...V,...q.mcpServers}};await R8($,`${JSON.stringify(X,null,2)}
385
- `,"utf8");let K=S1();await SQ(K,{recursive:!0}),await R8(i2.join(K,"SKILL.md"),nY(),"utf8"),await NH(MH,{recursive:!0,force:!0})}async function RH(Q){try{if((await yQ(Q,"utf8")).trim()==="")return{kind:"missing"}}catch{return EQ(Q)}return EQ(Q)}var s,MH;var bQ=H0(()=>{t1();L8();aY();w8();vQ();s=p0(R1(),1),MH=i2.join(BH(),".antigravity","skills","petdex")});var hQ={};E8(hQ,{runRefresh:()=>vH});import{existsSync as q3}from"node:fs";function xH(Q){return q3(Q.configFile)||q3(Q.slashCommandPath)}async function vH(){let Q={refreshed:[],skipped:[],binaryPersisted:!1};try{let $=await D8();if(Q.binaryPersisted=$.ok,!$.ok)Q.binaryReason=$.reason}catch($){Q.binaryReason=$.message}for(let $ of H1){if(!xH($)){Q.skipped.push({id:$.id,reason:"not installed"});continue}try{await _Q($),Q.refreshed.push($.id)}catch(q){Q.skipped.push({id:$.id,reason:q.message})}}return Q}var fQ=H0(()=>{L8();bQ();w8()});function iH(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 q1(Q,$){if(Q==null||typeof Q!=="object")return null;let q=Q[$];return typeof q==="string"?q:null}function W3(Q){let $=Math.max(Q.lastIndexOf("/"),Q.lastIndexOf("\\"));return $>=0?Q.slice($+1):Q}function c0(Q,$=40){if(Q.length<=$)return Q;return`${Q.slice(0,$-1)}…`}function U3(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:q,toolInput:J}=Q,Y=iH($),V=q==="done";switch(Y){case"read":{let X=q1(J,"file_path")??q1(J,"path"),K=X?c0(W3(X)):null;if(K)return V?`Read ${K}`:`Reading ${K}`;return V?"Read file":"Reading file"}case"edit":case"write":{let X=q1(J,"file_path")??q1(J,"path"),K=X?c0(W3(X)):null;if(K)return V?`Edited ${K}`:`Editing ${K}`;return V?"Edited file":"Editing file"}case"bash":{let X=q1(J,"command");if(X){let K=c0(X.split(/\s+/)[0]??X,24);return V?`Ran ${K}`:`Running ${K}`}return V?"Ran command":"Running command"}case"grep":{let X=q1(J,"pattern");if(X)return V?`Searched "${c0(X,28)}"`:`Searching "${c0(X,28)}"`;return V?"Searched files":"Searching files"}case"glob":{let X=q1(J,"pattern");if(X)return V?`Listed ${c0(X,28)}`:`Listing ${c0(X,28)}`;return V?"Listed files":"Listing files"}case"webfetch":{let X=q1(J,"url");if(X)try{let K=new URL(X).hostname;return V?`Fetched ${c0(K,28)}`:`Fetching ${c0(K,28)}`}catch{}return V?"Fetched web":"Searching web"}case"task":{let X=q1(J,"description")??q1(J,"subject");if(X)return V?"Subagent done":`Spawning ${c0(X,28)}`;return V?"Subagent done":"Spawning subagent"}default:{let X=c0($,28);return V?`Called ${X}`:`Calling ${X}`}}}var N3={};E8(N3,{stateForEvent:()=>F3,runBubble:()=>JF,eventFromArgs:()=>O3});import{existsSync as nH,readFileSync as rH}from"node:fs";import{homedir as aH}from"node:os";import{join as oQ}from"node:path";function F3(Q,$){let q=Q[0];if(q==="pre"){if($){let J=$.toLowerCase();if(J==="read"||J==="grep"||J==="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 $F(){if(process.stdin.isTTY)return"";return await new Promise((Q)=>{let $="",q=!1;process.stdin.setEncoding("utf8"),process.stdin.on("data",(J)=>{if(q)return;if($.length+J.length>j3){$+=J.slice(0,j3-$.length),q=!0;return}$+=J}),process.stdin.on("end",()=>Q($)),process.stdin.on("error",()=>Q($))})}function L3(Q){if(!Q.trim())return{toolName:null,toolInput:void 0,agentSource:null};try{let $=JSON.parse(Q),q=typeof $.tool_name==="string"?$.tool_name:null,J=$.tool_input,Y=typeof $.agent_source==="string"?$.agent_source:null;return{toolName:q,toolInput:J,agentSource:Y}}catch{return{toolName:null,toolInput:void 0,agentSource:null}}}function O3(Q,$){let q=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 J=q==="pre"?"running":q==="post"?"done":null;if(!J)return null;let{toolName:Y,toolInput:V}=L3($);if(!Y)return{kind:"tool",phase:J,toolName:"tool",toolInput:void 0};return{kind:"tool",phase:J,toolName:Y,toolInput:V}}function qF(){try{let Q=rH(sH,"utf8").trim();return Q.length>0?Q:null}catch{return null}}async function Z3(Q,$,q){let J=new AbortController,Y=setTimeout(()=>J.abort(),300);try{await fetch(Q,{method:"POST",headers:{"Content-Type":"application/json","X-Petdex-Update-Token":q},body:JSON.stringify($),signal:J.signal})}catch{}finally{clearTimeout(Y)}}async function JF(Q){if(nH(tH))return;let $=Q[1]??null,q=await $F(),J=O3(Q,q);if(!J)return;let{toolName:Y,agentSource:V}=L3(q),X=V??$,K=U3(J),W=F3(Q,Y),G=qF();if(!G)return;let U=[];if(K)U.push(Z3(eH,{text:K,agent_source:X},G));if(W)U.push(Z3(QF,{state:W,agent_source:X},G));await Promise.all(U)}var z3,sH,tH,H3="http://127.0.0.1:7777",eH,QF,j3=65536;var B3=H0(()=>{z3=oQ(aH(),".petdex","runtime"),sH=oQ(z3,"update-token"),tH=oQ(z3,"hooks-disabled"),eH=`${H3}/bubble`,QF=`${H3}/state`});var T3={};E8(T3,{runMcpServer:()=>zF});import{readFile as P3}from"node:fs/promises";import{homedir as I3}from"node:os";import C3 from"node:path";async function WF(){try{return(await P3(XF,"utf8")).trim()}catch{return null}}async function UF(){try{return await P3(KF),!0}catch{return!1}}async function M3(Q,$){let q=await WF();if(!q)return{ok:!1,status:0};try{let J=await fetch(Q,{method:"POST",headers:{"Content-Type":"application/json","X-Petdex-Update-Token":q},body:JSON.stringify($),signal:AbortSignal.timeout(300)});return{ok:J.ok,status:J.status}}catch{return{ok:!1,status:0}}}function _0(Q){let $=JSON.stringify(Q);if(iQ==="jsonl"){process.stdout.write(`${$}
383
+ Run \`npx petdex@latest hooks install\` to persist a fresh binary, then re-run.`);let $=await jY();await SQ(i2.dirname($),{recursive:!0});let q=eY(),J=await hz($);if(J.kind==="error")throw Error(`Refusing to overwrite ${$}: ${J.message}.
384
+ Fix the file (or rename it) and run \`petdex hooks install\` again.`);if(J.kind==="ok")await kQ($);let Y=J.kind==="ok"?J.value:{},V=Y.mcpServers??{},K={...Y,mcpServers:{...V,...q.mcpServers}};await R8($,`${JSON.stringify(K,null,2)}
385
+ `,"utf8");let X=S1();await SQ(X,{recursive:!0}),await R8(i2.join(X,"SKILL.md"),tY(),"utf8"),await Rz(vz,{recursive:!0,force:!0})}async function hz(Q){try{if((await yQ(Q,"utf8")).trim()==="")return{kind:"missing"}}catch{return EQ(Q)}return EQ(Q)}var s,vz;var bQ=z0(()=>{t1();L8();Q3();D8();vQ();s=p0(R1(),1),vz=i2.join(xz(),".antigravity","skills","petdex")});var hQ={};E8(hQ,{runRefresh:()=>mz});import{existsSync as K3}from"node:fs";function fz(Q){return K3(Q.configFile)||K3(Q.slashCommandPath)}async function mz(){let Q={refreshed:[],skipped:[],binaryPersisted:!1};try{let $=await w8();if(Q.binaryPersisted=$.ok,!$.ok)Q.binaryReason=$.reason}catch($){Q.binaryReason=$.message}for(let $ of z1){if(!fz($)){Q.skipped.push({id:$.id,reason:"not installed"});continue}try{await _Q($),Q.refreshed.push($.id)}catch(q){Q.skipped.push({id:$.id,reason:q.message})}}return Q}var fQ=z0(()=>{L8();bQ();D8()});function JF(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 q1(Q,$){if(Q==null||typeof Q!=="object")return null;let q=Q[$];return typeof q==="string"?q:null}function H3(Q){let $=Math.max(Q.lastIndexOf("/"),Q.lastIndexOf("\\"));return $>=0?Q.slice($+1):Q}function c0(Q,$=40){if(Q.length<=$)return Q;return`${Q.slice(0,$-1)}…`}function z3(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:q,toolInput:J}=Q,Y=JF($),V=q==="done";switch(Y){case"read":{let K=q1(J,"file_path")??q1(J,"path"),X=K?c0(H3(K)):null;if(X)return V?`Read ${X}`:`Reading ${X}`;return V?"Read file":"Reading file"}case"edit":case"write":{let K=q1(J,"file_path")??q1(J,"path"),X=K?c0(H3(K)):null;if(X)return V?`Edited ${X}`:`Editing ${X}`;return V?"Edited file":"Editing file"}case"bash":{let K=q1(J,"command");if(K){let X=c0(K.split(/\s+/)[0]??K,24);return V?`Ran ${X}`:`Running ${X}`}return V?"Ran command":"Running command"}case"grep":{let K=q1(J,"pattern");if(K)return V?`Searched "${c0(K,28)}"`:`Searching "${c0(K,28)}"`;return V?"Searched files":"Searching files"}case"glob":{let K=q1(J,"pattern");if(K)return V?`Listed ${c0(K,28)}`:`Listing ${c0(K,28)}`;return V?"Listed files":"Listing files"}case"webfetch":{let K=q1(J,"url");if(K)try{let X=new URL(K).hostname;return V?`Fetched ${c0(X,28)}`:`Fetching ${c0(X,28)}`}catch{}return V?"Fetched web":"Searching web"}case"task":{let K=q1(J,"description")??q1(J,"subject");if(K)return V?"Subagent done":`Spawning ${c0(K,28)}`;return V?"Subagent done":"Spawning subagent"}default:{let K=c0($,28);return V?`Called ${K}`:`Calling ${K}`}}}var I3={};E8(I3,{stateForEvent:()=>B3,runBubble:()=>HF,eventFromArgs:()=>P3});import{existsSync as YF,readFileSync as VF}from"node:fs";import{homedir as KF}from"node:os";import{join as oQ}from"node:path";function B3(Q,$){let q=Q[0];if(q==="pre"){if($){let J=$.toLowerCase();if(J==="read"||J==="grep"||J==="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 ZF(){if(process.stdin.isTTY)return"";return await new Promise((Q)=>{let $="",q=!1;process.stdin.setEncoding("utf8"),process.stdin.on("data",(J)=>{if(q)return;if($.length+J.length>F3){$+=J.slice(0,F3-$.length),q=!0;return}$+=J}),process.stdin.on("end",()=>Q($)),process.stdin.on("error",()=>Q($))})}function M3(Q){if(!Q.trim())return{toolName:null,toolInput:void 0,agentSource:null};try{let $=JSON.parse(Q),q=typeof $.tool_name==="string"?$.tool_name:null,J=$.tool_input,Y=typeof $.agent_source==="string"?$.agent_source:null;return{toolName:q,toolInput:J,agentSource:Y}}catch{return{toolName:null,toolInput:void 0,agentSource:null}}}function P3(Q,$){let q=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 J=q==="pre"?"running":q==="post"?"done":null;if(!J)return null;let{toolName:Y,toolInput:V}=M3($);if(!Y)return{kind:"tool",phase:J,toolName:"tool",toolInput:void 0};return{kind:"tool",phase:J,toolName:Y,toolInput:V}}function UF(){try{let Q=VF(XF,"utf8").trim();return Q.length>0?Q:null}catch{return null}}async function L3(Q,$,q){let J=new AbortController,Y=setTimeout(()=>J.abort(),300);try{await fetch(Q,{method:"POST",headers:{"Content-Type":"application/json","X-Petdex-Update-Token":q},body:JSON.stringify($),signal:J.signal})}catch{}finally{clearTimeout(Y)}}async function HF(Q){if(YF(GF))return;let $=Q[1]??null,q=await ZF(),J=P3(Q,q);if(!J)return;let{toolName:Y,agentSource:V}=M3(q),K=V??$,X=z3(J),W=B3(Q,Y),G=UF();if(!G)return;let j=[];if(X)j.push(L3(WF,{text:X,agent_source:K},G));if(W)j.push(L3(jF,{state:W,agent_source:K},G));await Promise.all(j)}var O3,XF,GF,N3="http://127.0.0.1:7777",WF,jF,F3=65536;var C3=z0(()=>{O3=oQ(KF(),".petdex","runtime"),XF=oQ(O3,"update-token"),GF=oQ(O3,"hooks-disabled"),WF=`${N3}/bubble`,jF=`${N3}/state`});var R3={};E8(R3,{runMcpServer:()=>CF});import{readFile as A3}from"node:fs/promises";import{homedir as w3}from"node:os";import D3 from"node:path";async function BF(){try{return(await A3(LF,"utf8")).trim()}catch{return null}}async function MF(){try{return await A3(OF),!0}catch{return!1}}async function T3(Q,$){let q=await BF();if(!q)return{ok:!1,status:0};try{let J=await fetch(Q,{method:"POST",headers:{"Content-Type":"application/json","X-Petdex-Update-Token":q},body:JSON.stringify($),signal:AbortSignal.timeout(300)});return{ok:J.ok,status:J.status}}catch{return{ok:!1,status:0}}}function _0(Q){let $=JSON.stringify(Q);if(iQ==="jsonl"){process.stdout.write(`${$}
386
386
  `);return}let J=`Content-Length: ${new TextEncoder().encode($).length}\r
387
387
  \r
388
- `;process.stdout.write(J),process.stdout.write($)}function x8(Q,$,q){return{jsonrpc:"2.0",id:Q,error:{code:$,message:q}}}async function ZF(Q){let{id:$,method:q,params:J}=Q;switch(q){case"initialize":{let Y=J?.protocolVersion??"2025-03-26";_0({jsonrpc:"2.0",id:$,result:{protocolVersion:Y,capabilities:{tools:{listChanged:!1}},serverInfo:{name:"petdex-mcp-server",version:GF}}});return}case"tools/list":{_0({jsonrpc:"2.0",id:$,result:{tools:jF}});return}case"tools/call":{let Y=J?.name,V=J?.arguments??{};if(await UF()){_0({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){_0(x8($,-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 M3(YF,K);_0({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){_0(x8($,-32602,"Missing required argument: text"));return}let K=await M3(VF,{text:X,agent_source:"antigravity"});_0({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(`${rQ}/health`,{signal:AbortSignal.timeout(500)})).ok}catch{X=!1}_0({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:{_0(x8($,-32601,`Unknown tool: ${Y}`));return}}}case"notifications/initialized":return;default:_0(x8($,-32601,`Unknown method: ${q}`))}}async function zF(){let Q=new Uint8Array(0),$=0,q=!1,J=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=FF(Q);if(G===123||G===91){let B=nQ(Q,new Uint8Array([10]));if(B===-1)break;let O=LF(Q.slice(0,B));Q=Q.slice(B+1);let M=J.decode(O).trim();if(!M)continue;iQ="jsonl",V(M);continue}let U=HF(Q),z=U.index;if(z===-1)break;let Z=Q.slice(0,z),F=J.decode(Z).match(/Content-Length:\s*(\d+)/i);if(!F){Q=Q.slice(z+U.length);continue}let N=parseInt(F[1],10),C=z+U.length,P=C+N;if(Q.length<P)break;let L=Q.slice(C,P),A=J.decode(L);Q=Q.slice(P),iQ="framed",V(A)}}),process.stdin.on("end",()=>{q=!0,Y(),setTimeout(()=>process.exit(0),3000).unref()});function V(X){try{let K=JSON.parse(X);$++,ZF(K).catch((W)=>{_0(x8(K.id,-32603,`Internal error: ${W.message}`))}).finally(()=>{if($--,q)Y()})}catch(K){_0({jsonrpc:"2.0",id:null,error:{code:-32700,message:`Parse error: ${K.message}`}})}}}function nQ(Q,$){Q:for(let q=0;q<=Q.length-$.length;q++){for(let J=0;J<$.length;J++)if(Q[q+J]!==$[J])continue Q;return q}return-1}function HF(Q){let $=nQ(Q,new Uint8Array([13,10,13,10]));if($!==-1)return{index:$,length:4};let q=nQ(Q,new Uint8Array([10,10]));if(q!==-1)return{index:q,length:2};return{index:-1,length:0}}function FF(Q){for(let $ of Q)if($!==32&&$!==9&&$!==10&&$!==13)return $;return null}function LF(Q){if(Q.at(-1)===13)return Q.slice(0,-1);return Q}var rQ="http://127.0.0.1:7777",YF,VF,XF,KF,GF="0.1.0",iQ="framed",jF;var A3=H0(()=>{YF=`${rQ}/state`,VF=`${rQ}/bubble`,XF=C3.join(I3(),".petdex","runtime","update-token"),KF=C3.join(I3(),".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:{}}}]});t1();var tQ=p0(pJ(),1),j=p0(R1(),1);import{existsSync as D3}from"node:fs";import{mkdir as w3,readdir as OF,readFile as sQ,stat as y3,writeFile as r2}from"node:fs/promises";import{homedir as R3}from"node:os";import Z0 from"node:path";import{spawn as sZ}from"node:child_process";import{createServer as hZ}from"node:http";class f extends Error{code;constructor(Q,$){super($);this.name="ClerkCliAuthError",this.code=Q}}var fZ=`<!doctype html>
388
+ `;process.stdout.write(J),process.stdout.write($)}function x8(Q,$,q){return{jsonrpc:"2.0",id:Q,error:{code:$,message:q}}}async function IF(Q){let{id:$,method:q,params:J}=Q;switch(q){case"initialize":{let Y=J?.protocolVersion??"2025-03-26";_0({jsonrpc:"2.0",id:$,result:{protocolVersion:Y,capabilities:{tools:{listChanged:!1}},serverInfo:{name:"petdex-mcp-server",version:NF}}});return}case"tools/list":{_0({jsonrpc:"2.0",id:$,result:{tools:PF}});return}case"tools/call":{let Y=J?.name,V=J?.arguments??{};if(await MF()){_0({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 K=V.state;if(!K){_0(x8($,-32602,"Missing required argument: state"));return}let X={state:K,agent_source:"antigravity"};if(typeof V.duration==="number")X.duration=V.duration;let W=await T3(zF,X);_0({jsonrpc:"2.0",id:$,result:{content:[{type:"text",text:W.ok?`Pet state set to "${K}"`:"Sidecar unreachable — is petdex-desktop running?"}]}});return}case"petdex_show_bubble":{let K=V.text;if(!K){_0(x8($,-32602,"Missing required argument: text"));return}let X=await T3(FF,{text:K,agent_source:"antigravity"});_0({jsonrpc:"2.0",id:$,result:{content:[{type:"text",text:X.ok?`Bubble shown: "${K}"`:"Sidecar unreachable — is petdex-desktop running?"}]}});return}case"petdex_status":{let K=!1;try{K=(await fetch(`${rQ}/health`,{signal:AbortSignal.timeout(500)})).ok}catch{K=!1}_0({jsonrpc:"2.0",id:$,result:{content:[{type:"text",text:K?"Petdex desktop is reachable.":"Petdex desktop not detected. Start it with `petdex up`."}]}});return}default:{_0(x8($,-32601,`Unknown tool: ${Y}`));return}}}case"notifications/initialized":return;default:_0(x8($,-32601,`Unknown method: ${q}`))}}async function CF(){let Q=new Uint8Array(0),$=0,q=!1,J=new TextDecoder;function Y(){if($===0)process.exit(0)}process.stdin.on("data",(K)=>{let X=typeof K==="string"?new TextEncoder().encode(K):K,W=new Uint8Array(Q.length+X.length);W.set(Q),W.set(X,Q.length),Q=W;while(!0){let G=AF(Q);if(G===123||G===91){let B=nQ(Q,new Uint8Array([10]));if(B===-1)break;let O=wF(Q.slice(0,B));Q=Q.slice(B+1);let M=J.decode(O).trim();if(!M)continue;iQ="jsonl",V(M);continue}let j=TF(Q),H=j.index;if(H===-1)break;let U=Q.slice(0,H),F=J.decode(U).match(/Content-Length:\s*(\d+)/i);if(!F){Q=Q.slice(H+j.length);continue}let N=parseInt(F[1],10),C=H+j.length,P=C+N;if(Q.length<P)break;let L=Q.slice(C,P),A=J.decode(L);Q=Q.slice(P),iQ="framed",V(A)}}),process.stdin.on("end",()=>{q=!0,Y(),setTimeout(()=>process.exit(0),3000).unref()});function V(K){try{let X=JSON.parse(K);$++,IF(X).catch((W)=>{_0(x8(X.id,-32603,`Internal error: ${W.message}`))}).finally(()=>{if($--,q)Y()})}catch(X){_0({jsonrpc:"2.0",id:null,error:{code:-32700,message:`Parse error: ${X.message}`}})}}}function nQ(Q,$){Q:for(let q=0;q<=Q.length-$.length;q++){for(let J=0;J<$.length;J++)if(Q[q+J]!==$[J])continue Q;return q}return-1}function TF(Q){let $=nQ(Q,new Uint8Array([13,10,13,10]));if($!==-1)return{index:$,length:4};let q=nQ(Q,new Uint8Array([10,10]));if(q!==-1)return{index:q,length:2};return{index:-1,length:0}}function AF(Q){for(let $ of Q)if($!==32&&$!==9&&$!==10&&$!==13)return $;return null}function wF(Q){if(Q.at(-1)===13)return Q.slice(0,-1);return Q}var rQ="http://127.0.0.1:7777",zF,FF,LF,OF,NF="0.1.0",iQ="framed",PF;var x3=z0(()=>{zF=`${rQ}/state`,FF=`${rQ}/bubble`,LF=D3.join(w3(),".petdex","runtime","update-token"),OF=D3.join(w3(),".petdex","runtime","hooks-disabled");PF=[{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:{}}}]});t1();var tQ=p0(pJ(),1),Z=p0(R1(),1);import{existsSync as v3}from"node:fs";import{mkdir as S3,readdir as DF,readFile as sQ,stat as c3,writeFile as r2}from"node:fs/promises";import{homedir as E3}from"node:os";import U0 from"node:path";import{spawn as KH}from"node:child_process";import{createServer as iU}from"node:http";class f extends Error{code;constructor(Q,$){super($);this.name="ClerkCliAuthError",this.code=Q}}var nU=`<!doctype html>
389
389
  <html>
390
390
  <head><meta charset="utf-8"><title>Authentication complete</title></head>
391
391
  <body><h1>Authentication complete</h1><p>You can close this tab and return to your terminal.</p></body>
392
- </html>`,mZ=`<!doctype html>
392
+ </html>`,rU=`<!doctype html>
393
393
  <html>
394
394
  <head><meta charset="utf-8"><title>Authentication failed</title></head>
395
395
  <body><h1>Authentication failed</h1><p>You can close this tab and return to your terminal.</p></body>
396
- </html>`;function GQ(Q,$){return new f(Q,$)}function oJ(Q){let{expectedState:$,port:q=0,timeoutMs:J=120000,successHtml:Y=fZ,errorHtml:V=mZ}=Q,X,K=!1,W=!1,G,U,z=new Promise((F,N)=>{G=F,U=N}),Z=(F)=>{if(W)return;W=!0,F.close()},H=hZ((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 C=new URL(F.url,"http://127.0.0.1");if(C.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=C.searchParams.get("code"),L=C.searchParams.get("state"),A=C.searchParams.get("error"),B=C.searchParams.get("error_description")??A,O=(M,T,D)=>{if(K=!0,X)clearTimeout(X);N.writeHead(M,{"Content-Type":"text/html; charset=utf-8"}),N.end(T,()=>{if(D)U(D);else if(P&&L)G({code:P,state:L});Z(H)})};if(A){O(400,V,GQ("token_exchange",`OAuth authorization failed: ${B??"unknown error"}`));return}if(L!==$){O(400,V,GQ("state_mismatch","OAuth callback state did not match."));return}if(!P){O(400,V,GQ("token_exchange","OAuth callback did not include an authorization code."));return}O(200,Y)});return new Promise((F,N)=>{H.once("error",(C)=>{N(new f("config",`Failed to start local auth callback server: ${C.message}`))}),H.listen(q,"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 ${J}ms.`)),Z(H)},J),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."));Z(H)}})})})}import{chmod as cZ,mkdir as uZ,readFile as pZ,writeFile as dZ}from"node:fs/promises";import{homedir as lZ}from"node:os";import{dirname as oZ,join as iZ}from"node:path";function iJ(Q,$){if($ instanceof f)return $;let q=$ instanceof Error?$.message:String($);return new f("storage",`${Q}: ${q}`)}function rJ(Q){return Q?.environment??"default"}function nZ(Q){return iZ(lZ(),".config","clerk-cli-auth",`${Q}.json`)}class aJ{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 sJ{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 pZ(this.filePath,"utf8");if(!Q.trim())return{};let $=JSON.parse(Q);if(!$||typeof $!=="object"||Array.isArray($))return{};let q={};for(let[J,Y]of Object.entries($))if(typeof Y==="string")q[J]=Y;return q}catch(Q){if(Q.code==="ENOENT")return{};throw iJ(`Failed to read credential file ${this.filePath}`,Q)}}async writeAll(Q){try{await uZ(oZ(this.filePath),{recursive:!0}),await dZ(this.filePath,`${JSON.stringify(Q,null,2)}
397
- `,{mode:384}),await cZ(this.filePath,384)}catch($){throw iJ(`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 q=await this.readAll();q[Q]=$,await this.writeAll(q)})}async delete(Q){return this.enqueue(async()=>{let $=await this.readAll();delete $[Q],await this.writeAll($)})}}class tJ{service;environment;fallback;keyringPromise=null;constructor(Q,$,q){this.service=Q;this.environment=$;this.fallback=q}account(Q){return`${this.environment}:${Q}`}warnFallback(Q,$){let q=$ instanceof Error?$.message:String($);if(Q==="initialization"&&q.includes("Cannot find package"))return;console.warn(`Keychain ${Q} failed; falling back to file store. ${q}`)}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 q=await this.loadKeyring();if(!q){await this.fallback.set(Q,$);return}new q.Entry(this.service,this.account(Q)).setPassword($)}catch(q){this.warnFallback("set",q),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 nJ(Q){let $=rJ(Q);return new sJ(Q?.filePath??nZ($))}function eJ(Q,$){if(Q==="memory")return new aJ;if(Q==="file")return nJ($);let q=nJ($),J=$?.keychainService??"clerk-cli-auth",Y=rJ($);return new tJ(J,Y,q)}import{createHash as rZ,randomBytes as QY}from"node:crypto";function WQ(Q){return Q.toString("base64url")}function $Y(){return WQ(QY(32))}async function qY(Q){return WQ(rZ("sha256").update(Q).digest())}function JY(){return WQ(QY(32))}function YY(Q,$){return`${Q.replace(/\/+$/,"")}${$}`}async function VY(Q){if((Q.headers.get("content-type")??"").includes("application/json"))return Q.json();return Q.text()}function XY(Q,$){if(typeof Q==="string"&&Q.trim())return Q.trim();if(Q&&typeof Q==="object"){let q=Q;for(let J of["error_description","message","error"]){let Y=q[J];if(typeof Y==="string"&&Y.trim())return Y.trim()}}return $}function aZ(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 KY(Q,$){let q;try{q=await fetch(YY(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 J;try{J=await VY(q)}catch(Y){throw new f("token_exchange",`Token response could not be parsed: ${Y.message}`)}if(!q.ok)throw new f("token_exchange",XY(J,`Token request failed with HTTP ${q.status}.`));if(!J||typeof J!=="object")throw new f("token_exchange","Token response was not JSON.");return aZ(J)}async function GY(Q){let $=new URLSearchParams({grant_type:"authorization_code",client_id:Q.clientId,code:Q.code,code_verifier:Q.codeVerifier,redirect_uri:Q.redirectUri});return KY(Q.issuer,$)}async function WY(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 KY(Q.issuer,$)}async function UQ(Q){let $;try{$=await fetch(YY(Q.issuer,"/oauth/userinfo"),{headers:{Authorization:`Bearer ${Q.accessToken}`}})}catch(Y){throw new f("userinfo",`Userinfo request failed: ${Y.message}`)}let q;try{q=await VY($)}catch(Y){throw new f("userinfo",`Userinfo response could not be parsed: ${Y.message}`)}if(!$.ok)throw new f("userinfo",XY(q,`Userinfo request failed with HTTP ${$.status}.`));if(!q||typeof q!=="object")throw new f("userinfo","Userinfo response was not JSON.");let J=q;if(typeof J.sub!=="string"||J.sub.length===0)throw new f("userinfo","Userinfo response did not include sub.");return J}var tZ=["profile","email","openid","offline_access"];function eZ(Q){let $=Q.trim().replace(/\/+$/,"");try{let q=new URL($);if(q.protocol!=="http:"&&q.protocol!=="https:")throw Error("issuer must use http or https");return $}catch(q){throw new f("config",`issuer must be a valid URL: ${q.message}`)}}function y2(Q,$){if($ instanceof f)return $;let q=$ instanceof Error?$.message:String($);return new f("storage",`Failed to ${Q}: ${q}`)}async function Qz(Q){console.log(`Open this URL to sign in:
398
- ${Q}`);let $=process.platform,q=$==="darwin"?"open":$==="win32"?"cmd":"xdg-open",J=$==="win32"?["/c","start","",Q]:[Q];await new Promise((Y)=>{let V=sZ(q,J,{detached:!0,stdio:"ignore"});V.once("error",()=>Y()),V.unref(),Y()})}class g2{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",q=typeof Q.storage==="object"&&Q.storage!==null?Q.storage:eJ(Q.storage??"keychain",{environment:$,keychainService:Q.keychainService});this.config={clientId:Q.clientId,issuer:eZ(Q.issuer),scopes:Q.scopes??tZ,storage:q,keychainService:Q.keychainService??"clerk-cli-auth",environment:$,callbackPort:Q.callbackPort??0,timeoutMs:Q.timeoutMs??120000,openBrowser:Q.openBrowser}}async login(){let Q=$Y(),$=await qY(Q),q=JY(),J=await oJ({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",J.redirectUri),Y.searchParams.set("scope",this.config.scopes.join(" ")),Y.searchParams.set("state",q),Y.searchParams.set("code_challenge",$),Y.searchParams.set("code_challenge_method","S256");try{await(this.config.openBrowser??Qz)(Y.toString())}catch(W){throw new f("config",`Failed to open authorization URL: ${W.message}`)}let{code:V}=await J.waitForCallback(),X=await GY({issuer:this.config.issuer,clientId:this.config.clientId,code:V,codeVerifier:Q,redirectUri:J.redirectUri});await this.setJson("tokens",X);let K=await UQ({issuer:this.config.issuer,accessToken:X.accessToken});return await this.setJson("user",K),{tokens:X,user:K}}finally{J.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 q=await WY({issuer:this.config.issuer,clientId:this.config.clientId,refreshToken:Q.refreshToken,scopes:this.config.scopes}),J={...Q,...q,refreshToken:q.refreshToken??Q.refreshToken};return await this.setJson("tokens",J),J.accessToken}async whoami(){let Q=await this.getJson("user");if(Q)return Q;let $=await this.getAccessToken();if(!$)return null;let q=await UQ({issuer:this.config.issuer,accessToken:$});return await this.setJson("user",q),q}async logout(){try{await Promise.all([this.config.storage.delete("tokens"),this.config.storage.delete("user")])}catch(Q){throw y2("clear stored credentials",Q)}}async getTokenSet(){return this.getJson("tokens")}async getJson(Q){let $;try{$=await this.config.storage.get(Q)}catch(q){throw y2(`read ${Q}`,q)}if(!$)return null;try{return JSON.parse($)}catch(q){throw y2(`parse stored ${Q}`,q)}}async setJson(Q,$){try{await this.config.storage.set(Q,JSON.stringify($))}catch(q){throw y2(`write ${Q}`,q)}}}L8();var L0=p0(R1(),1);import{execSync as xz}from"node:child_process";import{existsSync as O0,readFileSync as p2,statSync as AQ}from"node:fs";import{homedir as vz}from"node:os";import E1 from"node:path";import{existsSync as Gz,mkdirSync as Wz,unlinkSync as Uz,writeFileSync as jz}from"node:fs";import{homedir as Zz}from"node:os";import jQ from"node:path";function ZY(){return process.env.HOME??Zz()}function zY(){return jQ.join(ZY(),".petdex","runtime","hooks-disabled")}function O8(){return jQ.join(ZY(),".petdex","runtime","update-token")}function T6(){return Gz(zY())?"off":"on"}function A6(Q){let $=zY();if(Q==="off")Wz(jQ.dirname($),{recursive:!0}),jz($,`# Petdex hook killswitch.
396
+ </html>`;function GQ(Q,$){return new f(Q,$)}function oJ(Q){let{expectedState:$,port:q=0,timeoutMs:J=120000,successHtml:Y=nU,errorHtml:V=rU}=Q,K,X=!1,W=!1,G,j,H=new Promise((F,N)=>{G=F,j=N}),U=(F)=>{if(W)return;W=!0,F.close()},z=iU((F,N)=>{if(X){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 C=new URL(F.url,"http://127.0.0.1");if(C.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=C.searchParams.get("code"),L=C.searchParams.get("state"),A=C.searchParams.get("error"),B=C.searchParams.get("error_description")??A,O=(M,T,w)=>{if(X=!0,K)clearTimeout(K);N.writeHead(M,{"Content-Type":"text/html; charset=utf-8"}),N.end(T,()=>{if(w)j(w);else if(P&&L)G({code:P,state:L});U(z)})};if(A){O(400,V,GQ("token_exchange",`OAuth authorization failed: ${B??"unknown error"}`));return}if(L!==$){O(400,V,GQ("state_mismatch","OAuth callback state did not match."));return}if(!P){O(400,V,GQ("token_exchange","OAuth callback did not include an authorization code."));return}O(200,Y)});return new Promise((F,N)=>{z.once("error",(C)=>{N(new f("config",`Failed to start local auth callback server: ${C.message}`))}),z.listen(q,"127.0.0.1",()=>{let P=z.address().port,L=`http://127.0.0.1:${P}/callback`;K=setTimeout(()=>{if(X)return;X=!0,j(new f("timeout",`OAuth callback timed out after ${J}ms.`)),U(z)},J),F({port:P,redirectUri:L,waitForCallback:()=>H,close:()=>{if(K)clearTimeout(K);if(!X)X=!0,j(new f("timeout","OAuth callback server was closed."));U(z)}})})})}import{chmod as aU,mkdir as sU,readFile as tU,writeFile as eU}from"node:fs/promises";import{homedir as QH}from"node:os";import{dirname as $H,join as qH}from"node:path";function iJ(Q,$){if($ instanceof f)return $;let q=$ instanceof Error?$.message:String($);return new f("storage",`${Q}: ${q}`)}function rJ(Q){return Q?.environment??"default"}function JH(Q){return qH(QH(),".config","clerk-cli-auth",`${Q}.json`)}class aJ{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 sJ{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 tU(this.filePath,"utf8");if(!Q.trim())return{};let $=JSON.parse(Q);if(!$||typeof $!=="object"||Array.isArray($))return{};let q={};for(let[J,Y]of Object.entries($))if(typeof Y==="string")q[J]=Y;return q}catch(Q){if(Q.code==="ENOENT")return{};throw iJ(`Failed to read credential file ${this.filePath}`,Q)}}async writeAll(Q){try{await sU($H(this.filePath),{recursive:!0}),await eU(this.filePath,`${JSON.stringify(Q,null,2)}
397
+ `,{mode:384}),await aU(this.filePath,384)}catch($){throw iJ(`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 q=await this.readAll();q[Q]=$,await this.writeAll(q)})}async delete(Q){return this.enqueue(async()=>{let $=await this.readAll();delete $[Q],await this.writeAll($)})}}class tJ{service;environment;fallback;keyringPromise=null;constructor(Q,$,q){this.service=Q;this.environment=$;this.fallback=q}account(Q){return`${this.environment}:${Q}`}warnFallback(Q,$){let q=$ instanceof Error?$.message:String($);if(Q==="initialization"&&q.includes("Cannot find package"))return;console.warn(`Keychain ${Q} failed; falling back to file store. ${q}`)}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 q=await this.loadKeyring();if(!q){await this.fallback.set(Q,$);return}new q.Entry(this.service,this.account(Q)).setPassword($)}catch(q){this.warnFallback("set",q),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 nJ(Q){let $=rJ(Q);return new sJ(Q?.filePath??JH($))}function eJ(Q,$){if(Q==="memory")return new aJ;if(Q==="file")return nJ($);let q=nJ($),J=$?.keychainService??"clerk-cli-auth",Y=rJ($);return new tJ(J,Y,q)}import{createHash as YH,randomBytes as QY}from"node:crypto";function WQ(Q){return Q.toString("base64url")}function $Y(){return WQ(QY(32))}async function qY(Q){return WQ(YH("sha256").update(Q).digest())}function JY(){return WQ(QY(32))}function YY(Q,$){return`${Q.replace(/\/+$/,"")}${$}`}async function VY(Q){if((Q.headers.get("content-type")??"").includes("application/json"))return Q.json();return Q.text()}function KY(Q,$){if(typeof Q==="string"&&Q.trim())return Q.trim();if(Q&&typeof Q==="object"){let q=Q;for(let J of["error_description","message","error"]){let Y=q[J];if(typeof Y==="string"&&Y.trim())return Y.trim()}}return $}function VH(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 XY(Q,$){let q;try{q=await fetch(YY(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 J;try{J=await VY(q)}catch(Y){throw new f("token_exchange",`Token response could not be parsed: ${Y.message}`)}if(!q.ok)throw new f("token_exchange",KY(J,`Token request failed with HTTP ${q.status}.`));if(!J||typeof J!=="object")throw new f("token_exchange","Token response was not JSON.");return VH(J)}async function GY(Q){let $=new URLSearchParams({grant_type:"authorization_code",client_id:Q.clientId,code:Q.code,code_verifier:Q.codeVerifier,redirect_uri:Q.redirectUri});return XY(Q.issuer,$)}async function WY(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 XY(Q.issuer,$)}async function jQ(Q){let $;try{$=await fetch(YY(Q.issuer,"/oauth/userinfo"),{headers:{Authorization:`Bearer ${Q.accessToken}`}})}catch(Y){throw new f("userinfo",`Userinfo request failed: ${Y.message}`)}let q;try{q=await VY($)}catch(Y){throw new f("userinfo",`Userinfo response could not be parsed: ${Y.message}`)}if(!$.ok)throw new f("userinfo",KY(q,`Userinfo request failed with HTTP ${$.status}.`));if(!q||typeof q!=="object")throw new f("userinfo","Userinfo response was not JSON.");let J=q;if(typeof J.sub!=="string"||J.sub.length===0)throw new f("userinfo","Userinfo response did not include sub.");return J}var XH=["profile","email","openid","offline_access"];function GH(Q){let $=Q.trim().replace(/\/+$/,"");try{let q=new URL($);if(q.protocol!=="http:"&&q.protocol!=="https:")throw Error("issuer must use http or https");return $}catch(q){throw new f("config",`issuer must be a valid URL: ${q.message}`)}}function y2(Q,$){if($ instanceof f)return $;let q=$ instanceof Error?$.message:String($);return new f("storage",`Failed to ${Q}: ${q}`)}async function WH(Q){console.log(`Open this URL to sign in:
398
+ ${Q}`);let $=process.platform,q=$==="darwin"?"open":$==="win32"?"cmd":"xdg-open",J=$==="win32"?["/c","start","",Q]:[Q];await new Promise((Y)=>{let V=KH(q,J,{detached:!0,stdio:"ignore"});V.once("error",()=>Y()),V.unref(),Y()})}class g2{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",q=typeof Q.storage==="object"&&Q.storage!==null?Q.storage:eJ(Q.storage??"keychain",{environment:$,keychainService:Q.keychainService});this.config={clientId:Q.clientId,issuer:GH(Q.issuer),scopes:Q.scopes??XH,storage:q,keychainService:Q.keychainService??"clerk-cli-auth",environment:$,callbackPort:Q.callbackPort??0,timeoutMs:Q.timeoutMs??120000,openBrowser:Q.openBrowser}}async login(){let Q=$Y(),$=await qY(Q),q=JY(),J=await oJ({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",J.redirectUri),Y.searchParams.set("scope",this.config.scopes.join(" ")),Y.searchParams.set("state",q),Y.searchParams.set("code_challenge",$),Y.searchParams.set("code_challenge_method","S256");try{await(this.config.openBrowser??WH)(Y.toString())}catch(W){throw new f("config",`Failed to open authorization URL: ${W.message}`)}let{code:V}=await J.waitForCallback(),K=await GY({issuer:this.config.issuer,clientId:this.config.clientId,code:V,codeVerifier:Q,redirectUri:J.redirectUri});await this.setJson("tokens",K);let X=await jQ({issuer:this.config.issuer,accessToken:K.accessToken});return await this.setJson("user",X),{tokens:K,user:X}}finally{J.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 q=await WY({issuer:this.config.issuer,clientId:this.config.clientId,refreshToken:Q.refreshToken,scopes:this.config.scopes}),J={...Q,...q,refreshToken:q.refreshToken??Q.refreshToken};return await this.setJson("tokens",J),J.accessToken}async whoami(){let Q=await this.getJson("user");if(Q)return Q;let $=await this.getAccessToken();if(!$)return null;let q=await jQ({issuer:this.config.issuer,accessToken:$});return await this.setJson("user",q),q}async logout(){try{await Promise.all([this.config.storage.delete("tokens"),this.config.storage.delete("user")])}catch(Q){throw y2("clear stored credentials",Q)}}async getTokenSet(){return this.getJson("tokens")}async getJson(Q){let $;try{$=await this.config.storage.get(Q)}catch(q){throw y2(`read ${Q}`,q)}if(!$)return null;try{return JSON.parse($)}catch(q){throw y2(`parse stored ${Q}`,q)}}async setJson(Q,$){try{await this.config.storage.set(Q,JSON.stringify($))}catch(q){throw y2(`write ${Q}`,q)}}}L8();var L0=p0(R1(),1);import{execSync as fH}from"node:child_process";import{existsSync as O0,readFileSync as p2,statSync as AQ}from"node:fs";import{homedir as mH}from"node:os";import E1 from"node:path";import{existsSync as OH,mkdirSync as NH,unlinkSync as BH,writeFileSync as MH}from"node:fs";import{homedir as PH}from"node:os";import ZQ from"node:path";function UY(){return process.env.HOME??PH()}function HY(){return ZQ.join(UY(),".petdex","runtime","hooks-disabled")}function O8(){return ZQ.join(UY(),".petdex","runtime","update-token")}function T6(){return OH(HY())?"off":"on"}function A6(Q){let $=HY();if(Q==="off")NH(ZQ.dirname($),{recursive:!0}),MH($,`# Petdex hook killswitch.
399
399
  # Hooks are DISABLED while this file exists.
400
400
  # Re-enable: petdex hooks on (or /petdex from inside your agent).
401
- `,{mode:384});else try{Uz($)}catch{}return Q}function HY(){return A6(T6()==="on"?"off":"on")}import{randomBytes as OY}from"node:crypto";import{existsSync as FQ,statSync as zz}from"node:fs";import{chmod as Hz,mkdir as D6,rename as N8,rm as e0,writeFile as b2}from"node:fs/promises";import{homedir as h2,arch as Fz,platform as w6}from"node:os";import Q0 from"node:path";t1();var o=p0(R1(),1),Lz="https://api.github.com/repos/crafter-station/petdex/releases",FY=30,Oz=5,LY="desktop-v",NY="petdex-desktop-sidecar.js";function LQ(){let Q=w6(),$=Fz(),q=Q==="darwin"?"darwin":Q==="linux"?"linux":Q==="win32"?"win32":Q,J=$==="arm64"?"arm64":$==="x64"?"x64":$;return{osLabel:q,archLabel:J,assetSuffix:`${q}-${J}`}}function E0(){let Q=w6()==="win32"?".exe":"";if(w6()==="darwin"){let $=I0(),q=["/Applications/Petdex.app/Contents/MacOS/petdex-desktop",Q0.join($,"Applications","Petdex.app","Contents","MacOS","petdex-desktop")];for(let J of q)if(FQ(J))return J}return Q0.join(h2(),".petdex","bin",`petdex-desktop${Q}`)}function f2(){if(w6()==="darwin"){let Q=I0(),$=["/Applications/Petdex.app/Contents/Resources/sidecar/server.js",Q0.join(Q,"Applications","Petdex.app","Contents","Resources","sidecar","server.js")];for(let q of $)if(FQ(q))return q}return Q0.join(h2(),".petdex","sidecar","server.js")}async function OQ(Q={}){let $=Q.fetchOverride??fetch,q=Q.maxPages??Oz,J=0;for(let Y=1;Y<=q;Y++){let V=`${Lz}?per_page=${FY}&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;J+=K.length;let W=K.find((G)=>!G.draft&&!G.prerelease&&typeof G.tag_name==="string"&&G.tag_name.startsWith(LY));if(W)return W;if(K.length<FY)break}throw Error(`No ${LY}* release found in the last ${J} releases (scanned ${q} page(s))`)}function Nz(Q){return Q.assets.find(($)=>$.name===NY)??null}function m2(Q,$=LQ()){let q=`petdex-desktop-${$.assetSuffix}`,J=Q.assets.find((Y)=>Y.name===q)??Q.assets.find((Y)=>Y.name.startsWith(q));if(J)return{kind:"bare",target:$,binAsset:J,sidecarAsset:Nz(Q)};if($.osLabel==="darwin"){let Y=BY(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 c2(Q){if(Q.kind!=="unsupported")return Error("Desktop install plan is supported");return Error(`${Q.reason}
402
- ${Q.hint}`)}function BY(Q,$){let q=`Petdex-${$}.dmg`;return Q.assets.find((J)=>J.name===q)??null}function MY(Q){let q=Q.indexOf("/Contents/MacOS/");if(q===-1)return null;return Q.slice(0,q)}async function HQ(Q,$,q){let J=await fetch(Q);if(!J.ok||!J.body)throw Error(`download ${Q} → ${J.status}`);let Y=Buffer.from(await J.arrayBuffer()),V=`${$}.tmp`;try{if(await b2(V,Y),q!==void 0)await Hz(V,q);if(w6()==="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 e0(V,{force:!0})}catch{}throw X}}async function Bz(Q){let $=[];for(let q of Q){let J=null;try{let Y=`${q.destPath}.prev`;try{await N8(q.destPath,Y),J=Y}catch(V){if(V.code!=="ENOENT")throw V}await N8(q.tmpPath,q.destPath),$.push({dest:q.destPath,backup:J})}catch(Y){if(J)try{await e0(q.destPath,{force:!0}),await N8(J,q.destPath)}catch{}for(let V of $.reverse())try{if(V.backup)await e0(V.dest,{force:!0}),await N8(V.backup,V.dest);else await e0(V.dest,{force:!0})}catch{}for(let V of Q)try{await e0(V.tmpPath,{force:!0})}catch{}throw Y}}for(let q of $){if(!q.backup)continue;try{await e0(q.backup,{force:!0})}catch{}}}async function NQ(Q){let $=m2(Q);if($.kind==="unsupported")throw c2($);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:q,sidecarAsset:J}=$,Y=E0(),V=f2();await D6(Q0.dirname(Y),{recursive:!0}),await D6(Q0.dirname(V),{recursive:!0});let X=[];try{if(X.push(await HQ(q.browser_download_url,Y,493)),J)X.push(await HQ(J.browser_download_url,V))}catch(K){for(let W of X)try{await e0(W.tmpPath,{force:!0})}catch{}throw K}return{binAsset:q,sidecarAsset:J,staged:X}}async function BQ(Q){await Bz(Q.staged)}async function Mz(Q){let $=await NQ(Q);return await BQ($),{binAsset:$.binAsset,sidecarAsset:$.sidecarAsset}}async function MQ(Q,$){let q=LQ(),J=BY(Q,q.archLabel);if(!J)throw Error(`No DMG asset (Petdex-${q.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-${OY(8).toString("hex")}-${J.name}`),K=await HQ(J.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=Pz(U.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 F=G("ditto",[Z,$],{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 e0(X,{force:!0})}catch{}}return{appBundleRoot:$,dmgAsset:J}}function u2(){return Q0.join(I0(),"Applications","Petdex.app")}async function PQ(Q,$=u2()){return await D6(Q0.dirname($),{recursive:!0}),MQ(Q,$)}function Pz(Q){let $=Q.split(`
403
- `),q=null;for(let J of $){let Y=J.indexOf("/Volumes/");if(Y===-1)continue;let V=J.slice(Y).trim();if(!q||V.length>q.length)q=V}return q}var Iz="boba",Cz=process.env.PETDEX_URL??"https://petdex.crafter.run",Tz=new Set(["petdex-assets.raillyhugo.workers.dev","pub-94495283df974cfea5e98d6a9e3fa462.r2.dev","yu2vz9gndp.ufs.sh"]);function B8(Q){try{let $=new URL(Q);if($.protocol!=="https:")return!1;return Tz.has($.hostname)}catch{return!1}}function I0(){if(w6()==="win32")return process.env.USERPROFILE??process.env.HOME??h2();return process.env.HOME??process.env.USERPROFILE??h2()}function PY(){return Q0.join(I0(),".petdex","pets")}function IY(){return Q0.join(I0(),".codex","pets")}var Az=16777216;function IQ(Q){for(let $ of["spritesheet.webp","spritesheet.png"]){let q=Q0.join(Q,$);try{let J=zz(q);if(J.isFile()&&J.size>0&&J.size<=Az)return!0}catch{}}return!1}async function Dz(){let{readdir:Q}=await import("node:fs/promises");for(let $ of[PY(),IY()]){let q;try{q=await Q($)}catch{continue}for(let J of q)if(IQ(Q0.join($,J)))return!0}return!1}async function CQ(){if(await Dz())return{status:"present"};let Q=await wz();return Q?{status:"installed",slug:Q}:{status:"missing"}}async function wz(Q={}){let $=Q.fetchOverride??fetch,q=Q.petdexUrl??Cz,J=`${q.replace(/\/+$/,"")}/`,Y;try{let W=await $(`${q}/api/manifest`,{signal:AbortSignal.timeout(8000)});if(!W.ok)return null;let G=await W.json();Y=Array.isArray(G?.pets)?G.pets:[]}catch{return null}if(Y.length===0)return null;let V=[],X=new Set,K=Y.find((W)=>W.slug===Iz);if(K)V.push(K),X.add(K.slug);for(let W of Y)if(!X.has(W.slug))V.push(W),X.add(W.slug);for(let W of V){let G=await Rz(W,$,J);if(G)return G}return null}async function Rz(Q,$,q){if(!B8(Q.spritesheetUrl)||!B8(Q.petJsonUrl))return null;let J=Q.spritesheetUrl.endsWith(".png")?"png":"webp",Y=[Q0.join(PY(),Q.slug),Q0.join(IY(),Q.slug)];for(let U of Y)if(FQ(U))return null;let V=async(U)=>{let z=await $(U,{headers:{Referer:q},signal:AbortSignal.timeout(15000)});if(!z.ok)throw Error(`download ${U} → ${z.status}`);return z.arrayBuffer()},X,K;try{[X,K]=await Promise.all([V(Q.petJsonUrl),V(Q.spritesheetUrl)])}catch{return null}let W=[],G=[];try{for(let U of Y){let z=`${U}.partial-${OY(6).toString("hex")}`;await D6(z,{recursive:!0}),W.push(z),await Promise.all([b2(Q0.join(z,"pet.json"),Buffer.from(X)),b2(Q0.join(z,`spritesheet.${J}`),Buffer.from(K))]),await D6(Q0.dirname(U),{recursive:!0}),await N8(z,U),W.pop(),G.push(U)}return Q.slug}catch{return await Promise.all([...W.map((U)=>e0(U,{recursive:!0,force:!0})),...G.map((U)=>e0(U,{recursive:!0,force:!0}))]),null}}async function TQ(){N0(o.default.bgMagenta(o.default.white(" petdex install desktop ")));let Q=LQ();i.info(`Platform: ${o.default.cyan(`${Q.osLabel} ${Q.archLabel}`)}`);let $=U0();$.start("Looking up the latest release");let q;try{q=await OQ()}catch(W){throw $.stop(o.default.red("failed")),Error(`Could not reach GitHub. Check your connection.
404
- ${W.message}`)}$.stop(`${o.default.green("✓")} Latest: ${o.default.bold(q.tag_name)}`);let J=m2(q);if(J.kind==="unsupported")throw c2(J);if(J.kind==="bare"){let W=U0();W.start("Downloading desktop binary and sidecar");let G;try{G=await Mz(q)}catch(Z){throw W.stop(o.default.red("failed")),Z}let U=E0(),z=G.sidecarAsset?`
405
- ${o.default.dim("•")} Sidecar at ${o.default.cyan(zQ(f2()))} (${ZQ(G.sidecarAsset.size)})`:`
406
- ${o.default.yellow("!")} No sidecar in this release. Hooks won't reach the mascot until a release ships ${NY}.`;W.stop(`${o.default.green("✓")} Binary at ${o.default.cyan(zQ(U))} (${ZQ(G.binAsset.size)})${z}`)}else{let W=U0();W.start("Installing macOS app from DMG");try{await PQ(q)}catch(G){throw W.stop(o.default.red("failed")),G}W.stop(`${o.default.green("✓")} App at ${o.default.cyan(zQ(u2()))} (${ZQ(J.dmgAsset.size)})`)}let Y=Q0.join(I0(),".petdex","version");await D6(Q0.dirname(Y),{recursive:!0}),await b2(Y,`${q.tag_name}
407
- `);let V=U0();V.start("Checking starter pet");let X=await CQ();if(X.status==="installed")V.stop(`${o.default.green("✓")} Starter pet: ${o.default.bold(X.slug)}`);else if(X.status==="present")V.stop(`${o.default.green("✓")} Pet library ready`);else V.stop(`${o.default.yellow("!")} Could not download a starter pet. Run \`petdex install <slug>\` before \`petdex desktop start\`.`);let K=["Run it with:",` ${o.default.cyan("petdex desktop start")}`,"","Or wire it into your coding agents:",` ${o.default.cyan("petdex hooks install")}`];return b0(K.join(`
408
- `),"Next"),w0(`${o.default.green("✓")} ${q.tag_name}`),{tag:q.tag_name}}function ZQ(Q){if(Q<1024)return`${Q} B`;if(Q<1048576)return`${(Q/1024).toFixed(1)} KB`;return`${(Q/1024/1024).toFixed(1)} MB`}function zQ(Q){let $=I0();if(Q.startsWith($))return`~${Q.slice($.length)}`;return Q}function M8(){return process.env.HOME??vz()}function Sz(){return E1.join(M8(),".petdex","runtime","update-token")}function Ez(){return E1.join(M8(),".petdex","desktop.pid")}function kz(){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(!(AQ(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 yz(){let Q=f2();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 gz(){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 _z(){let Q=Ez();if(!O0(Q))return{status:"info",label:"PID file",detail:"not present (desktop not running)"};let $;try{$=p2(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 q=JSON.parse($);if(typeof q.pid!=="number"||typeof q.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 ${q.pid}, started ${q.lstart}`}}catch{return{status:"warn",label:"PID file",detail:"JSON parse failed",hint:`Delete it: rm ${Q}`}}}function bz(){let Q=Sz();if(!O0(Q))return{status:"info",label:"Update token",detail:"absent (will be created when sidecar starts)"};try{if(p2(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 J=AQ(Q).mode&511;if(J!==384)return{status:"warn",label:"Update token",detail:`present, mode ${J.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 hz(){if(T6()==="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 fz(){let Q=[];for(let $ of H1){let q=$.id==="antigravity"?(()=>{let X=v1(),[K]=X;return X.find((W)=>O0(W))??K})():$.configFile,J=O0(q),Y=O0($.slashCommandPath);if(!mz($)){Q.push({status:"info",label:$.displayName,detail:"not installed on this machine"});continue}let V=!1;if(J)try{let X=p2(q,"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(S1());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 mz(Q){if(Q.id!=="antigravity")return O0(Q.configDir);return v1().some(($)=>O0(E1.dirname($)))||O0(S1())}function cz(){let Q=E1.join(M8(),".codex","config.toml");if(!O0(Q))return{status:"info",label:"Codex codex_hooks flag",detail:"config.toml absent (Codex not installed?)"};try{let $=p2(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 uz(){let Q=[E1.join(M8(),".petdex","pets"),E1.join(M8(),".codex","pets")],$=0;for(let q of Q){if(!O0(q))continue;try{let{readdirSync:J}=_("node:fs"),Y=J(q);for(let V of Y){let X=E1.join(q,V);for(let K of["spritesheet.webp","spritesheet.png"]){let W=E1.join(X,K);if(!O0(W))continue;try{let G=AQ(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 pz(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 k0(Q){let $=Q.detail?` ${L0.default.dim(Q.detail)}`:"";if(console.log(` ${pz(Q.status)} ${L0.default.bold(Q.label)}${$}`),Q.hint)console.log(` ${L0.default.cyan("→")} ${Q.hint}`)}async function CY(){console.log(L0.default.bgMagenta(L0.default.white(" petdex doctor "))),console.log(""),console.log(L0.default.bold("Install")),k0(kz()),k0(yz()),k0(uz()),console.log(""),console.log(L0.default.bold("Runtime")),k0(await gz()),k0(_z()),k0(bz()),k0(hz()),console.log(""),console.log(L0.default.bold("Agents"));for(let $ of fz())k0($);k0(cz()),console.log(""),console.log(L0.default.bold("Network"));let Q=null;try{Q=xz("lsof -nP -iTCP:7777 -sTCP:LISTEN 2>/dev/null || true",{encoding:"utf8"}).trim()}catch{Q=null}if(Q===null)k0({status:"info",label:":7777 listener",detail:"lsof unavailable"});else if(Q.length===0)k0({status:"info",label:":7777 listener",detail:"nothing bound (sidecar offline)"});else{let $=Q.split(`
409
- `).length-1;k0({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 y0=p0(R1(),1);import{execFileSync as T8,spawn as TY}from"node:child_process";import{existsSync as AY,readFileSync as dz,unlinkSync as lz}from"node:fs";import{mkdir as oz,writeFile as DY}from"node:fs/promises";import F1 from"node:path";function C8(){return F1.join(I0(),".petdex","desktop.pid")}function P8(){return F1.join(I0(),".petdex","desktop.log")}function wY(){if(!AY(C8()))return null;let Q;try{Q=dz(C8(),"utf8").trim()}catch{return null}if(Q.startsWith("{")){try{let q=JSON.parse(Q);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 $=Number(Q);if(Number.isFinite($)&&$>0)return{pid:$,lstart:""};return null}function RY(Q){if(process.platform==="win32")return null;try{let q=T8("ps",["-p",String(Q),"-o","lstart="],{encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trim();return q.length>0?q:null}catch{return null}}function xY(Q){try{let q=T8("tasklist",["/fi",`PID eq ${Q}`,"/fo","csv","/nh"],{encoding:"utf8",stdio:["ignore","pipe","ignore"]}).match(/^"([^"]+)"/m);return q?q[1].toLowerCase():null}catch{return null}}function vY(Q){if(process.platform==="win32")return F1.basename(E0()).toLowerCase();return RY(Q)??""}function DQ(Q){if(process.platform==="win32")return xY(Q)!==null;try{return T8("ps",["-p",String(Q)],{stdio:["ignore","ignore","ignore"]}),!0}catch{return!1}}function SY(Q){if(Q.lstart.length===0)return!1;if(process.platform==="win32"){let q=xY(Q.pid);return q!==null&&q===Q.lstart}let $=RY(Q.pid);return $!==null&&$===Q.lstart}function R6(){try{lz(C8())}catch{}}function Q1(){let Q=wY();if(Q==null)return{state:"stopped"};if(SY(Q))return{state:"running",pid:Q.pid};return{state:"stale",pid:Q.pid}}async function k1(){let Q=Q1();if(Q.state==="running")return{ok:!0,pid:Q.pid,alreadyRunning:!0};if(Q.state==="stale")R6();let $=E0();if(!AY($))return{ok:!1,reason:`petdex-desktop binary not found at ${$}. Run \`petdex install desktop\` first.`};await oz(F1.dirname(P8()),{recursive:!0});let q=await import("node:fs").then((K)=>K.openSync(P8(),"a")),J=await import("node:fs").then((K)=>K.openSync(P8(),"a")),Y=iz($);if(Y)return nz(Y);let V=TY($,[],{detached:!0,stdio:["ignore",q,J]});if(V.unref(),!V.pid)return{ok:!1,reason:"Failed to spawn petdex-desktop"};let X={pid:V.pid,lstart:vY(V.pid)};return await DY(C8(),JSON.stringify(X)),{ok:!0,pid:V.pid,alreadyRunning:!1}}function iz(Q){let $=F1.dirname(Q);if(F1.basename($)!=="MacOS")return null;let q=F1.dirname($);if(F1.basename(q)!=="Contents")return null;let J=F1.dirname(q);if(!J.endsWith(".app"))return null;return J}async function nz(Q){TY("open",["-gj",Q],{stdio:"ignore",detached:!0}).unref();let q=Date.now()+3000,J=null;while(Date.now()<q){if(J=rz(),J)break;await new Promise((V)=>setTimeout(V,100))}if(!J)return{ok:!1,reason:`Launched ${Q} but couldn't find the resulting process. Check ${P8()}.`};let Y={pid:J,lstart:vY(J)};return await DY(C8(),JSON.stringify(Y)),{ok:!0,pid:J,alreadyRunning:!1}}function rz(){try{let Q=T8("pgrep",["-f","petdex-desktop"],{encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trim();if(!Q)return null;let $=Q.split(`
410
- `).filter((J)=>J.length>0),q=Number($[$.length-1]);return Number.isFinite(q)&&q>0?q:null}catch{return null}}var EY=7777;async function a1(Q={}){let $=Q.sidecarPort??EY,q=Q.portWaitTimeoutMs??5000,J=Q1();if(J.state==="stopped")return{ok:!1,reason:"petdex-desktop is not running"};if(J.state==="stale")return R6(),{ok:!1,reason:`petdex-desktop is not running (stale pid ${J.pid} cleared)`};let Y=J.pid,V=wY();if(V===null||!SY(V))return R6(),{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(!DQ(Y)){R6();let K=await I8($,{timeoutMs:q});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(R6(),K.code==="ESRCH"){let G=await I8($,{timeoutMs:q});return{ok:!0,pid:Y,portReleased:G}}return{ok:!1,reason:`Failed to signal pid ${Y}: ${K.message}`}}R6();let X=await I8($,{timeoutMs:q});return{ok:!0,pid:Y,portReleased:X}}async function kY(){let Q=await k1();if(!Q.ok)console.error(`${y0.default.red("✗")} ${Q.reason}`),process.exit(1);if(Q.alreadyRunning)console.log(`${y0.default.dim("•")} petdex-desktop already running (pid ${Q.pid})`);else console.log(`${y0.default.green("✓")} petdex-desktop started (pid ${Q.pid})`),console.log(y0.default.dim(` log: ${P8()}`))}async function yY(){let Q=await a1();if(!Q.ok)console.error(`${y0.default.dim("•")} ${Q.reason}`),process.exit(Q.reason.includes("not running")?0:1);if(Q.portReleased)console.log(`${y0.default.green("✓")} stopped pid ${Q.pid}`);else console.log(`${y0.default.yellow("!")} stopped pid ${Q.pid}, but :${EY} still busy`),console.log(y0.default.dim(" if 'petdex desktop start' fails with EADDRINUSE, wait a moment and retry"))}async function I8(Q,$={}){let q=$.timeoutMs??1e4,J=$.intervalMs??100,Y=$.host??"127.0.0.1",{createConnection:V}=await import("node:net"),X=Date.now()+q;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(J,()=>U(!1))}))return!0;await new Promise((W)=>setTimeout(W,J))}return!1}function gY(){let Q=Q1();switch(Q.state){case"running":console.log(`${y0.default.green("●")} running (pid ${Q.pid})`);break;case"stopped":console.log(`${y0.default.dim("○")} stopped`);break;case"stale":console.log(`${y0.default.yellow("?")} pid ${Q.pid} written but not alive (run \`petdex desktop start\` to restart)`);break}}import{mkdir as az,readdir as sz,writeFile as tz}from"node:fs/promises";import A8 from"node:path";function ez(Q=I0()){return[A8.join(Q,".petdex","pets"),A8.join(Q,".codex","pets")]}function QH(Q=I0()){return A8.join(Q,".petdex","active.json")}async function _Y(Q=ez()){let $=new Set;for(let q of Q)try{let J=await sz(q,{withFileTypes:!0});for(let Y of J){if(!Y.isDirectory())continue;if(IQ(A8.join(q,Y.name)))$.add(Y.name)}}catch{}return[...$].sort()}async function bY(Q,$=QH()){await az(A8.dirname($),{recursive:!0}),await tz($,`${JSON.stringify({slug:Q})}
411
- `,"utf8")}async function hY(Q={stopDesktop:a1,startDesktop:k1}){let $=await Q.stopDesktop();if(!$.ok&&!$.reason.includes("not running"))return{status:"manual_restart_required",reason:$.reason};if($.ok&&!$.portReleased)return{status:"manual_restart_required",reason:"desktop sidecar port is still busy"};let q=await Q.startDesktop();if(!q.ok)return{status:"manual_restart_required",reason:q.reason};return{status:"reloaded"}}t1();var E=p0(R1(),1);import{existsSync as SH,readFileSync as J3}from"node:fs";import{mkdir as EH,writeFile as kH}from"node:fs/promises";import{homedir as Y3}from"node:os";import cQ from"node:path";import{spawn as $H}from"node:child_process";import{randomUUID as fY}from"node:crypto";import{existsSync as qH,mkdirSync as JH,readFileSync as YH,writeFileSync as VH}from"node:fs";import{homedir as XH}from"node:os";import mY from"node:path";function d2(){let Q=process.env.HOME??XH();return mY.join(Q,".petdex","telemetry.json")}var KH=process.env.PETDEX_TELEMETRY_URL??"https://petdex.crafter.run/api/telemetry/event",GH=2000;function l2(){if(!qH(d2()))return{kind:"missing"};let Q;try{Q=YH(d2(),"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 wQ(Q){try{return JH(mY.dirname(d2()),{recursive:!0}),VH(d2(),`${JSON.stringify(Q,null,2)}
412
- `),!0}catch{return!1}}function cY(){if(process.env.PETDEX_TELEMETRY==="0")return null;let Q=l2();if(Q.kind==="ok")return Q.config;if(Q.kind==="error")return null;let $={install_id:fY(),enabled:!0,notice_seen:!1,first_seen:new Date().toISOString()};return wQ($)?$:null}function uY(){if(process.env.PETDEX_TELEMETRY==="0")return!1;let Q=l2();if(Q.kind==="missing")return!0;if(Q.kind==="error")return!1;return Q.config.enabled}function pY(Q){let $=l2(),q;if($.kind==="ok")q=$.config,q.enabled=Q;else q={install_id:fY(),enabled:Q,notice_seen:!0,first_seen:new Date().toISOString()};return wQ(q)}function dY(){let Q=l2();return{enabled:uY(),install_id:Q.kind==="ok"?Q.config.install_id:null}}function lY(){if(process.env.PETDEX_TELEMETRY==="0")return;let Q=cY();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(`
413
- `)),Q.notice_seen=!0,wQ(Q)}function C0(Q,$={}){if(!uY())return;let q=cY();if(!q)return;let J=JSON.stringify({install_id:q.install_id,event:Q,...$});try{let Y=`
401
+ `,{mode:384});else try{BH($)}catch{}return Q}function zY(){return A6(T6()==="on"?"off":"on")}import{randomBytes as MY}from"node:crypto";import{existsSync as FQ,statSync as IH}from"node:fs";import{chmod as CH,mkdir as w6,rename as N8,rm as e0,writeFile as b2}from"node:fs/promises";import{homedir as h2,arch as TH,platform as D6}from"node:os";import Q0 from"node:path";t1();var o=p0(R1(),1),AH="https://api.github.com/repos/crafter-station/petdex/releases",FY=30,wH=5,LY="desktop-v",PY="petdex-desktop-sidecar.js";function LQ(){let Q=D6(),$=TH(),q=Q==="darwin"?"darwin":Q==="linux"?"linux":Q==="win32"?"win32":Q,J=$==="arm64"?"arm64":$==="x64"?"x64":$;return{osLabel:q,archLabel:J,assetSuffix:`${q}-${J}`}}function E0(){let Q=D6()==="win32"?".exe":"";if(D6()==="darwin"){let $=I0(),q=["/Applications/Petdex.app/Contents/MacOS/petdex-desktop",Q0.join($,"Applications","Petdex.app","Contents","MacOS","petdex-desktop")];for(let J of q)if(FQ(J))return J}return Q0.join(h2(),".petdex","bin",`petdex-desktop${Q}`)}function f2(){if(D6()==="darwin"){let Q=I0(),$=["/Applications/Petdex.app/Contents/Resources/sidecar/server.js",Q0.join(Q,"Applications","Petdex.app","Contents","Resources","sidecar","server.js")];for(let q of $)if(FQ(q))return q}return Q0.join(h2(),".petdex","sidecar","server.js")}async function OQ(Q={}){let $=Q.fetchOverride??fetch,q=Q.maxPages??wH,J=0;for(let Y=1;Y<=q;Y++){let V=`${AH}?per_page=${FY}&page=${Y}`,K=await $(V,{headers:{Accept:"application/vnd.github+json"}});if(!K.ok)throw Error(`GitHub API ${K.status}`);let X=await K.json();if(!Array.isArray(X)||X.length===0)break;J+=X.length;let W=X.find((G)=>!G.draft&&!G.prerelease&&typeof G.tag_name==="string"&&G.tag_name.startsWith(LY));if(W)return W;if(X.length<FY)break}throw Error(`No ${LY}* release found in the last ${J} releases (scanned ${q} page(s))`)}function DH(Q){return Q.assets.find(($)=>$.name===PY)??null}function m2(Q,$=LQ()){let q=`petdex-desktop-${$.assetSuffix}`,J=Q.assets.find((Y)=>Y.name===q)??Q.assets.find((Y)=>Y.name.startsWith(q));if(J)return{kind:"bare",target:$,binAsset:J,sidecarAsset:DH(Q)};if($.osLabel==="darwin"){let Y=IY(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 c2(Q){if(Q.kind!=="unsupported")return Error("Desktop install plan is supported");return Error(`${Q.reason}
402
+ ${Q.hint}`)}function IY(Q,$){let q=`Petdex-${$}.dmg`;return Q.assets.find((J)=>J.name===q)??null}function CY(Q){let q=Q.indexOf("/Contents/MacOS/");if(q===-1)return null;return Q.slice(0,q)}async function zQ(Q,$,q){let J=await fetch(Q);if(!J.ok||!J.body)throw Error(`download ${Q} → ${J.status}`);let Y=Buffer.from(await J.arrayBuffer()),V=`${$}.tmp`;try{if(await b2(V,Y),q!==void 0)await CH(V,q);if(D6()==="darwin")try{let{spawnSync:K}=await import("node:child_process");K("xattr",["-d","com.apple.quarantine",V],{stdio:"ignore"})}catch{}return{tmpPath:V,destPath:$}}catch(K){try{await e0(V,{force:!0})}catch{}throw K}}async function RH(Q){let $=[];for(let q of Q){let J=null;try{let Y=`${q.destPath}.prev`;try{await N8(q.destPath,Y),J=Y}catch(V){if(V.code!=="ENOENT")throw V}await N8(q.tmpPath,q.destPath),$.push({dest:q.destPath,backup:J})}catch(Y){if(J)try{await e0(q.destPath,{force:!0}),await N8(J,q.destPath)}catch{}for(let V of $.reverse())try{if(V.backup)await e0(V.dest,{force:!0}),await N8(V.backup,V.dest);else await e0(V.dest,{force:!0})}catch{}for(let V of Q)try{await e0(V.tmpPath,{force:!0})}catch{}throw Y}}for(let q of $){if(!q.backup)continue;try{await e0(q.backup,{force:!0})}catch{}}}async function NQ(Q){let $=m2(Q);if($.kind==="unsupported")throw c2($);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:q,sidecarAsset:J}=$,Y=E0(),V=f2();await w6(Q0.dirname(Y),{recursive:!0}),await w6(Q0.dirname(V),{recursive:!0});let K=[];try{if(K.push(await zQ(q.browser_download_url,Y,493)),J)K.push(await zQ(J.browser_download_url,V))}catch(X){for(let W of K)try{await e0(W.tmpPath,{force:!0})}catch{}throw X}return{binAsset:q,sidecarAsset:J,staged:K}}async function BQ(Q){await RH(Q.staged)}async function xH(Q){let $=await NQ(Q);return await BQ($),{binAsset:$.binAsset,sidecarAsset:$.sidecarAsset}}async function MQ(Q,$){let q=LQ(),J=IY(Q,q.archLabel);if(!J)throw Error(`No DMG asset (Petdex-${q.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"),K=Y(V(),`petdex-${MY(8).toString("hex")}-${J.name}`),X=await zQ(J.browser_download_url,K),{rename:W}=await import("node:fs/promises");await W(X.tmpPath,K);let{spawnSync:G}=await import("node:child_process"),j=G("hdiutil",["attach","-nobrowse","-quiet",K],{encoding:"utf8"});if(j.status!==0)throw Error(`hdiutil attach failed (exit ${j.status}): ${j.stderr||j.stdout||"no output"}`);let H=vH(j.stdout)??"/Volumes/Petdex";try{let U=`${H}/Petdex.app`,{existsSync:z}=await import("node:fs");if(!z(U))throw Error(`mounted DMG at ${H} does not contain Petdex.app — is the release shape unchanged?`);let F=G("ditto",[U,$],{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",H],{encoding:"utf8"});try{await e0(K,{force:!0})}catch{}}return{appBundleRoot:$,dmgAsset:J}}function u2(){return Q0.join(I0(),"Applications","Petdex.app")}async function PQ(Q,$=u2()){return await w6(Q0.dirname($),{recursive:!0}),MQ(Q,$)}function vH(Q){let $=Q.split(`
403
+ `),q=null;for(let J of $){let Y=J.indexOf("/Volumes/");if(Y===-1)continue;let V=J.slice(Y).trim();if(!q||V.length>q.length)q=V}return q}var SH="boba",TY="https://petdex.crafter.run",EH=process.env.PETDEX_URL??TY,kH=new Set(["assets.petdex.dev","petdex-assets.raillyhugo.workers.dev","pub-94495283df974cfea5e98d6a9e3fa462.r2.dev"]);function B8(Q){try{let $=new URL(Q);if($.protocol!=="https:")return!1;return kH.has($.hostname)}catch{return!1}}function I0(){if(D6()==="win32")return process.env.USERPROFILE??process.env.HOME??h2();return process.env.HOME??process.env.USERPROFILE??h2()}function AY(){return Q0.join(I0(),".petdex","pets")}function wY(){return Q0.join(I0(),".codex","pets")}var yH=16777216;function IQ(Q){for(let $ of["spritesheet.webp","spritesheet.png"]){let q=Q0.join(Q,$);try{let J=IH(q);if(J.isFile()&&J.size>0&&J.size<=yH)return!0}catch{}}return!1}async function gH(){let{readdir:Q}=await import("node:fs/promises");for(let $ of[AY(),wY()]){let q;try{q=await Q($)}catch{continue}for(let J of q)if(IQ(Q0.join($,J)))return!0}return!1}async function CQ(){if(await gH())return{status:"present"};let Q=await _H();return Q?{status:"installed",slug:Q}:{status:"missing"}}async function _H(Q={}){let $=Q.fetchOverride??fetch,q=Q.petdexUrl??EH,J=`${q.replace(/\/+$/,"")}/`,Y;try{Y=await bH($,q)}catch{return null}if(Y.length===0)return null;let V=[],K=new Set,X=Y.find((W)=>W.slug===SH);if(X)V.push(X),K.add(X.slug);for(let W of Y)if(!K.has(W.slug))V.push(W),K.add(W.slug);for(let W of V){let G=await hH(W,$,J);if(G)return G}return null}async function bH(Q,$){let q=await OY(Q,NY($)).catch(()=>null);if(q&&q.length>0)return q;let J=`${$}/api/manifest/v2`;if(NY($)!==J){let K=await OY(Q,J).catch(()=>null);if(K&&K.length>0)return K}let Y=await Q(`${$}/api/manifest`,{signal:AbortSignal.timeout(8000)});if(!Y.ok)return[];let V=await Y.json();return Array.isArray(V?.pets)?V.pets:[]}async function OY(Q,$){let q=await Q($,{signal:AbortSignal.timeout(8000)});if(!q.ok)return[];let J=await q.json();if(!Array.isArray(J.pets))return[];let Y=typeof J.assetBase==="string"?J.assetBase.replace(/\/+$/,""):"";return J.pets.flatMap((V)=>{let[K,X,,,W,G]=V,j=BY(Y,W),H=BY(Y,G);if(!K||!X||!j||!H)return[];return[{slug:K,displayName:X,spritesheetUrl:j,petJsonUrl:H}]})}function NY(Q){let $=Q.replace(/\/+$/,"");if($===TY||$==="https://petdex.dev"||$==="https://www.petdex.dev")return"https://assets.petdex.dev/manifests/petdex-v2.json";return`${$}/api/manifest/v2`}function BY(Q,$){if(!$)return null;if(/^https:\/\//.test($))return $;if(!Q)return null;return`${Q}/${$.replace(/^\/+/,"")}`}async function hH(Q,$,q){if(!B8(Q.spritesheetUrl)||!B8(Q.petJsonUrl))return null;let J=Q.spritesheetUrl.endsWith(".png")?"png":"webp",Y=[Q0.join(AY(),Q.slug),Q0.join(wY(),Q.slug)];for(let j of Y)if(FQ(j))return null;let V=async(j)=>{let H=await $(j,{headers:{Referer:q},signal:AbortSignal.timeout(15000)});if(!H.ok)throw Error(`download ${j} → ${H.status}`);return H.arrayBuffer()},K,X;try{[K,X]=await Promise.all([V(Q.petJsonUrl),V(Q.spritesheetUrl)])}catch{return null}let W=[],G=[];try{for(let j of Y){let H=`${j}.partial-${MY(6).toString("hex")}`;await w6(H,{recursive:!0}),W.push(H),await Promise.all([b2(Q0.join(H,"pet.json"),Buffer.from(K)),b2(Q0.join(H,`spritesheet.${J}`),Buffer.from(X))]),await w6(Q0.dirname(j),{recursive:!0}),await N8(H,j),W.pop(),G.push(j)}return Q.slug}catch{return await Promise.all([...W.map((j)=>e0(j,{recursive:!0,force:!0})),...G.map((j)=>e0(j,{recursive:!0,force:!0}))]),null}}async function TQ(){N0(o.default.bgMagenta(o.default.white(" petdex install desktop ")));let Q=LQ();i.info(`Platform: ${o.default.cyan(`${Q.osLabel} ${Q.archLabel}`)}`);let $=j0();$.start("Looking up the latest release");let q;try{q=await OQ()}catch(W){throw $.stop(o.default.red("failed")),Error(`Could not reach GitHub. Check your connection.
404
+ ${W.message}`)}$.stop(`${o.default.green("✓")} Latest: ${o.default.bold(q.tag_name)}`);let J=m2(q);if(J.kind==="unsupported")throw c2(J);if(J.kind==="bare"){let W=j0();W.start("Downloading desktop binary and sidecar");let G;try{G=await xH(q)}catch(U){throw W.stop(o.default.red("failed")),U}let j=E0(),H=G.sidecarAsset?`
405
+ ${o.default.dim("•")} Sidecar at ${o.default.cyan(HQ(f2()))} (${UQ(G.sidecarAsset.size)})`:`
406
+ ${o.default.yellow("!")} No sidecar in this release. Hooks won't reach the mascot until a release ships ${PY}.`;W.stop(`${o.default.green("✓")} Binary at ${o.default.cyan(HQ(j))} (${UQ(G.binAsset.size)})${H}`)}else{let W=j0();W.start("Installing macOS app from DMG");try{await PQ(q)}catch(G){throw W.stop(o.default.red("failed")),G}W.stop(`${o.default.green("✓")} App at ${o.default.cyan(HQ(u2()))} (${UQ(J.dmgAsset.size)})`)}let Y=Q0.join(I0(),".petdex","version");await w6(Q0.dirname(Y),{recursive:!0}),await b2(Y,`${q.tag_name}
407
+ `);let V=j0();V.start("Checking starter pet");let K=await CQ();if(K.status==="installed")V.stop(`${o.default.green("✓")} Starter pet: ${o.default.bold(K.slug)}`);else if(K.status==="present")V.stop(`${o.default.green("✓")} Pet library ready`);else V.stop(`${o.default.yellow("!")} Could not download a starter pet. Run \`petdex install <slug>\` before \`petdex desktop start\`.`);let X=["Run it with:",` ${o.default.cyan("petdex desktop start")}`,"","Or wire it into your coding agents:",` ${o.default.cyan("petdex hooks install")}`];return b0(X.join(`
408
+ `),"Next"),D0(`${o.default.green("✓")} ${q.tag_name}`),{tag:q.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 HQ(Q){let $=I0();if(Q.startsWith($))return`~${Q.slice($.length)}`;return Q}function M8(){return process.env.HOME??mH()}function cH(){return E1.join(M8(),".petdex","runtime","update-token")}function uH(){return E1.join(M8(),".petdex","desktop.pid")}function pH(){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(!(AQ(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 dH(){let Q=f2();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 lH(){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 oH(){let Q=uH();if(!O0(Q))return{status:"info",label:"PID file",detail:"not present (desktop not running)"};let $;try{$=p2(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 q=JSON.parse($);if(typeof q.pid!=="number"||typeof q.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 ${q.pid}, started ${q.lstart}`}}catch{return{status:"warn",label:"PID file",detail:"JSON parse failed",hint:`Delete it: rm ${Q}`}}}function iH(){let Q=cH();if(!O0(Q))return{status:"info",label:"Update token",detail:"absent (will be created when sidecar starts)"};try{if(p2(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 J=AQ(Q).mode&511;if(J!==384)return{status:"warn",label:"Update token",detail:`present, mode ${J.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 nH(){if(T6()==="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 rH(){let Q=[];for(let $ of z1){let q=$.id==="antigravity"?(()=>{let K=v1(),[X]=K;return K.find((W)=>O0(W))??X})():$.configFile,J=O0(q),Y=O0($.slashCommandPath);if(!aH($)){Q.push({status:"info",label:$.displayName,detail:"not installed on this machine"});continue}let V=!1;if(J)try{let K=p2(q,"utf8");if($.id==="antigravity")V=K.includes('"petdex"')||K.includes("petdex");else V=K.includes("127.0.0.1:7777/state")||K.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 K=O0(S1());Q.push({status:K?"ok":"warn",label:$.displayName,detail:K?"MCP server + Skill installed":"MCP server configured, but Skill not found",hint:K?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 aH(Q){if(Q.id!=="antigravity")return O0(Q.configDir);return v1().some(($)=>O0(E1.dirname($)))||O0(S1())}function sH(){let Q=E1.join(M8(),".codex","config.toml");if(!O0(Q))return{status:"info",label:"Codex codex_hooks flag",detail:"config.toml absent (Codex not installed?)"};try{let $=p2(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 tH(){let Q=[E1.join(M8(),".petdex","pets"),E1.join(M8(),".codex","pets")],$=0;for(let q of Q){if(!O0(q))continue;try{let{readdirSync:J}=_("node:fs"),Y=J(q);for(let V of Y){let K=E1.join(q,V);for(let X of["spritesheet.webp","spritesheet.png"]){let W=E1.join(K,X);if(!O0(W))continue;try{let G=AQ(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 eH(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 k0(Q){let $=Q.detail?` ${L0.default.dim(Q.detail)}`:"";if(console.log(` ${eH(Q.status)} ${L0.default.bold(Q.label)}${$}`),Q.hint)console.log(` ${L0.default.cyan("→")} ${Q.hint}`)}async function DY(){console.log(L0.default.bgMagenta(L0.default.white(" petdex doctor "))),console.log(""),console.log(L0.default.bold("Install")),k0(pH()),k0(dH()),k0(tH()),console.log(""),console.log(L0.default.bold("Runtime")),k0(await lH()),k0(oH()),k0(iH()),k0(nH()),console.log(""),console.log(L0.default.bold("Agents"));for(let $ of rH())k0($);k0(sH()),console.log(""),console.log(L0.default.bold("Network"));let Q=null;try{Q=fH("lsof -nP -iTCP:7777 -sTCP:LISTEN 2>/dev/null || true",{encoding:"utf8"}).trim()}catch{Q=null}if(Q===null)k0({status:"info",label:":7777 listener",detail:"lsof unavailable"});else if(Q.length===0)k0({status:"info",label:":7777 listener",detail:"nothing bound (sidecar offline)"});else{let $=Q.split(`
409
+ `).length-1;k0({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 y0=p0(R1(),1);import{execFileSync as T8,spawn as RY}from"node:child_process";import{existsSync as xY,readFileSync as Qz,unlinkSync as $z}from"node:fs";import{mkdir as qz,writeFile as vY}from"node:fs/promises";import F1 from"node:path";function C8(){return F1.join(I0(),".petdex","desktop.pid")}function P8(){return F1.join(I0(),".petdex","desktop.log")}function SY(){if(!xY(C8()))return null;let Q;try{Q=Qz(C8(),"utf8").trim()}catch{return null}if(Q.startsWith("{")){try{let q=JSON.parse(Q);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 $=Number(Q);if(Number.isFinite($)&&$>0)return{pid:$,lstart:""};return null}function EY(Q){if(process.platform==="win32")return null;try{let q=T8("ps",["-p",String(Q),"-o","lstart="],{encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trim();return q.length>0?q:null}catch{return null}}function kY(Q){try{let q=T8("tasklist",["/fi",`PID eq ${Q}`,"/fo","csv","/nh"],{encoding:"utf8",stdio:["ignore","pipe","ignore"]}).match(/^"([^"]+)"/m);return q?q[1].toLowerCase():null}catch{return null}}function yY(Q){if(process.platform==="win32")return F1.basename(E0()).toLowerCase();return EY(Q)??""}function wQ(Q){if(process.platform==="win32")return kY(Q)!==null;try{return T8("ps",["-p",String(Q)],{stdio:["ignore","ignore","ignore"]}),!0}catch{return!1}}function gY(Q){if(Q.lstart.length===0)return!1;if(process.platform==="win32"){let q=kY(Q.pid);return q!==null&&q===Q.lstart}let $=EY(Q.pid);return $!==null&&$===Q.lstart}function R6(){try{$z(C8())}catch{}}function Q1(){let Q=SY();if(Q==null)return{state:"stopped"};if(gY(Q))return{state:"running",pid:Q.pid};return{state:"stale",pid:Q.pid}}async function k1(){let Q=Q1();if(Q.state==="running")return{ok:!0,pid:Q.pid,alreadyRunning:!0};if(Q.state==="stale")R6();let $=E0();if(!xY($))return{ok:!1,reason:`petdex-desktop binary not found at ${$}. Run \`petdex install desktop\` first.`};await qz(F1.dirname(P8()),{recursive:!0});let q=await import("node:fs").then((X)=>X.openSync(P8(),"a")),J=await import("node:fs").then((X)=>X.openSync(P8(),"a")),Y=Jz($);if(Y)return Yz(Y);let V=RY($,[],{detached:!0,stdio:["ignore",q,J]});if(V.unref(),!V.pid)return{ok:!1,reason:"Failed to spawn petdex-desktop"};let K={pid:V.pid,lstart:yY(V.pid)};return await vY(C8(),JSON.stringify(K)),{ok:!0,pid:V.pid,alreadyRunning:!1}}function Jz(Q){let $=F1.dirname(Q);if(F1.basename($)!=="MacOS")return null;let q=F1.dirname($);if(F1.basename(q)!=="Contents")return null;let J=F1.dirname(q);if(!J.endsWith(".app"))return null;return J}async function Yz(Q){RY("open",["-gj",Q],{stdio:"ignore",detached:!0}).unref();let q=Date.now()+3000,J=null;while(Date.now()<q){if(J=Vz(),J)break;await new Promise((V)=>setTimeout(V,100))}if(!J)return{ok:!1,reason:`Launched ${Q} but couldn't find the resulting process. Check ${P8()}.`};let Y={pid:J,lstart:yY(J)};return await vY(C8(),JSON.stringify(Y)),{ok:!0,pid:J,alreadyRunning:!1}}function Vz(){try{let Q=T8("pgrep",["-f","petdex-desktop"],{encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trim();if(!Q)return null;let $=Q.split(`
410
+ `).filter((J)=>J.length>0),q=Number($[$.length-1]);return Number.isFinite(q)&&q>0?q:null}catch{return null}}var _Y=7777;async function a1(Q={}){let $=Q.sidecarPort??_Y,q=Q.portWaitTimeoutMs??5000,J=Q1();if(J.state==="stopped")return{ok:!1,reason:"petdex-desktop is not running"};if(J.state==="stale")return R6(),{ok:!1,reason:`petdex-desktop is not running (stale pid ${J.pid} cleared)`};let Y=J.pid,V=SY();if(V===null||!gY(V))return R6(),{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(!wQ(Y)){R6();let X=await I8($,{timeoutMs:q});return{ok:!0,pid:Y,portReleased:X}}return{ok:!1,reason:`taskkill failed and pid ${Y} is still alive`}}else try{process.kill(Y,"SIGTERM")}catch(X){if(R6(),X.code==="ESRCH"){let G=await I8($,{timeoutMs:q});return{ok:!0,pid:Y,portReleased:G}}return{ok:!1,reason:`Failed to signal pid ${Y}: ${X.message}`}}R6();let K=await I8($,{timeoutMs:q});return{ok:!0,pid:Y,portReleased:K}}async function bY(){let Q=await k1();if(!Q.ok)console.error(`${y0.default.red("✗")} ${Q.reason}`),process.exit(1);if(Q.alreadyRunning)console.log(`${y0.default.dim("•")} petdex-desktop already running (pid ${Q.pid})`);else console.log(`${y0.default.green("✓")} petdex-desktop started (pid ${Q.pid})`),console.log(y0.default.dim(` log: ${P8()}`))}async function hY(){let Q=await a1();if(!Q.ok)console.error(`${y0.default.dim("•")} ${Q.reason}`),process.exit(Q.reason.includes("not running")?0:1);if(Q.portReleased)console.log(`${y0.default.green("✓")} stopped pid ${Q.pid}`);else console.log(`${y0.default.yellow("!")} stopped pid ${Q.pid}, but :${_Y} still busy`),console.log(y0.default.dim(" if 'petdex desktop start' fails with EADDRINUSE, wait a moment and retry"))}async function I8(Q,$={}){let q=$.timeoutMs??1e4,J=$.intervalMs??100,Y=$.host??"127.0.0.1",{createConnection:V}=await import("node:net"),K=Date.now()+q;while(Date.now()<K){if(await new Promise((W)=>{let G=V({host:Y,port:Q}),j=(H)=>{G.removeAllListeners(),G.destroy(),W(H)};G.once("connect",()=>j(!1)),G.once("error",(H)=>{j(H.code==="ECONNREFUSED")}),G.setTimeout(J,()=>j(!1))}))return!0;await new Promise((W)=>setTimeout(W,J))}return!1}function fY(){let Q=Q1();switch(Q.state){case"running":console.log(`${y0.default.green("●")} running (pid ${Q.pid})`);break;case"stopped":console.log(`${y0.default.dim("○")} stopped`);break;case"stale":console.log(`${y0.default.yellow("?")} pid ${Q.pid} written but not alive (run \`petdex desktop start\` to restart)`);break}}import{mkdir as Kz,readdir as Xz,writeFile as Gz}from"node:fs/promises";import A8 from"node:path";function Wz(Q=I0()){return[A8.join(Q,".petdex","pets"),A8.join(Q,".codex","pets")]}function jz(Q=I0()){return A8.join(Q,".petdex","active.json")}async function mY(Q=Wz()){let $=new Set;for(let q of Q)try{let J=await Xz(q,{withFileTypes:!0});for(let Y of J){if(!Y.isDirectory())continue;if(IQ(A8.join(q,Y.name)))$.add(Y.name)}}catch{}return[...$].sort()}async function cY(Q,$=jz()){await Kz(A8.dirname($),{recursive:!0}),await Gz($,`${JSON.stringify({slug:Q})}
411
+ `,"utf8")}async function uY(Q={stopDesktop:a1,startDesktop:k1}){let $=await Q.stopDesktop();if(!$.ok&&!$.reason.includes("not running"))return{status:"manual_restart_required",reason:$.reason};if($.ok&&!$.portReleased)return{status:"manual_restart_required",reason:"desktop sidecar port is still busy"};let q=await Q.startDesktop();if(!q.ok)return{status:"manual_restart_required",reason:q.reason};return{status:"reloaded"}}t1();var E=p0(R1(),1);import{existsSync as cz,readFileSync as X3}from"node:fs";import{mkdir as uz,writeFile as pz}from"node:fs/promises";import{homedir as G3}from"node:os";import cQ from"node:path";import{spawn as Zz}from"node:child_process";import{randomUUID as pY}from"node:crypto";import{existsSync as Uz,mkdirSync as Hz,readFileSync as zz,writeFileSync as Fz}from"node:fs";import{homedir as Lz}from"node:os";import dY from"node:path";function d2(){let Q=process.env.HOME??Lz();return dY.join(Q,".petdex","telemetry.json")}var Oz=process.env.PETDEX_TELEMETRY_URL??"https://petdex.crafter.run/api/telemetry/event",Nz=2000;function l2(){if(!Uz(d2()))return{kind:"missing"};let Q;try{Q=zz(d2(),"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 DQ(Q){try{return Hz(dY.dirname(d2()),{recursive:!0}),Fz(d2(),`${JSON.stringify(Q,null,2)}
412
+ `),!0}catch{return!1}}function lY(){if(process.env.PETDEX_TELEMETRY==="0")return null;let Q=l2();if(Q.kind==="ok")return Q.config;if(Q.kind==="error")return null;let $={install_id:pY(),enabled:!0,notice_seen:!1,first_seen:new Date().toISOString()};return DQ($)?$:null}function oY(){if(process.env.PETDEX_TELEMETRY==="0")return!1;let Q=l2();if(Q.kind==="missing")return!0;if(Q.kind==="error")return!1;return Q.config.enabled}function iY(Q){let $=l2(),q;if($.kind==="ok")q=$.config,q.enabled=Q;else q={install_id:pY(),enabled:Q,notice_seen:!0,first_seen:new Date().toISOString()};return DQ(q)}function nY(){let Q=l2();return{enabled:oY(),install_id:Q.kind==="ok"?Q.config.install_id:null}}function rY(){if(process.env.PETDEX_TELEMETRY==="0")return;let Q=lY();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(`
413
+ `)),Q.notice_seen=!0,DQ(Q)}function C0(Q,$={}){if(!oY())return;let q=lY();if(!q)return;let J=JSON.stringify({install_id:q.install_id,event:Q,...$});try{let Y=`
414
414
  const controller = new AbortController();
415
- const t = setTimeout(() => controller.abort(), ${GH});
416
- fetch(${JSON.stringify(KH)}, {
415
+ const t = setTimeout(() => controller.abort(), ${Nz});
416
+ fetch(${JSON.stringify(Oz)}, {
417
417
  method: "POST",
418
418
  headers: { "content-type": "application/json" },
419
419
  body: ${JSON.stringify(J)},
420
420
  signal: controller.signal,
421
421
  }).catch(() => {}).finally(() => clearTimeout(t));
422
- `;$H(process.execPath,["-e",Y],{detached:!0,stdio:"ignore"}).unref()}catch{}}var n2=7777,yH="x-petdex-update-token",gH=cQ.join(Y3(),".petdex","runtime","update-token"),V3=cQ.join(Y3(),".petdex","version");async function _H(Q={}){let $=Q.port??n2,q=Q.timeoutMs??2000,J=Q.tokenPath??gH,Y;try{Y=J3(J,"utf8").trim()}catch{return!1}if(!Y)return!1;let V=new AbortController,X=setTimeout(()=>V.abort(),q);try{return(await fetch(`http://127.0.0.1:${$}/update/handoff`,{method:"POST",headers:{[yH]:Y},signal:V.signal})).ok}catch{return!1}finally{clearTimeout(X)}}function bH(Q=V3){if(!SH(Q))return null;try{return J3(Q,"utf8").trim()||null}catch{return null}}async function mQ(Q,$){await EH(cQ.dirname(Q),{recursive:!0}),await kH(Q,`${$}
423
- `)}async function X3(Q=[],$,q={}){let J={fetchLatestRelease:OQ,desktopBinPath:E0,appBundleRootFor:MY,desktopStatus:Q1,stopDesktop:a1,updateAppBundleFromDmg:MQ,resolveDesktopInstallPlan:m2,installAppBundleFromDmg:PQ,stageDesktopAssets:NQ,commitDesktopAssets:BQ,requestSidecarHandoff:_H,waitForPortRelease:I8,startDesktop:k1,hookRefresh:hH,versionFile:V3,...q},Y=Date.now(),V=Q.includes("--force"),X=Q.includes("--silent"),K=(M)=>{if(X)console.log(`[petdex update] ${M}`);else N0(E.default.bgMagenta(E.default.white(` ${M} `)))},W=(M)=>{if(X)console.log(M);else i.info(M)},G=(M)=>{if(X)console.warn(M);else i.warn(M)},U=(M)=>{if(X)console.log(M);else w0(M)},z=()=>{if(X)return{start:(T)=>console.log(T),stop:(T)=>console.log(T)};let M=U0();return{start:(T)=>M.start(T),stop:(T)=>M.stop(T)}};K("petdex update");let Z=bH(J.versionFile);W(Z?`Installed: ${X?Z:E.default.cyan(Z)}`:"No installed version recorded - treating as fresh install.");let H=z();H.start("Checking GitHub for the latest release");let F;try{F=await J.fetchLatestRelease()}catch(M){throw H.stop(X?"failed":E.default.red("failed")),Error(`Could not reach GitHub. Check your connection.
424
- ${M.message}`)}if(H.stop(X?`Latest: ${F.tag_name}`:`${E.default.green("✓")} Latest: ${E.default.bold(F.tag_name)}`),!V&&Z&&Z===F.tag_name){U(X?"Already up to date.":`${E.default.green("✓")} Already up to date.`);return}let N=J.desktopBinPath(),C=J.appBundleRootFor(N),P=J.desktopStatus().state==="running";if(C){if(P)W(X?"Stopping running petdex-desktop":`${E.default.dim("•")} Stopping running petdex-desktop`),await J.stopDesktop();let M=z();M.start(`Downloading ${F.tag_name} DMG`);let T;try{T=await J.updateAppBundleFromDmg(F,C)}catch(x){throw M.stop(X?"failed":E.default.red("failed")),x}M.stop(X?`Replaced ${C} (${x6(T.dmgAsset.size)})`:`${E.default.green("✓")} Replaced ${E.default.bold(C)} (${x6(T.dmgAsset.size)})`),await mQ(J.versionFile,F.tag_name),C0("cli_update_applied",{cli_version:$,from_version:Z??void 0,to_version:F.tag_name,duration_ms:Date.now()-Y}),await J.hookRefresh(W,G,X);let D=Z?`${Z} -> ${F.tag_name}`:F.tag_name;U(X?`${D} (relaunch Petdex from /Applications to use it)`:`${E.default.green("✓")} ${D}
425
- ${E.default.dim(" Relaunch Petdex from /Applications to use it.")}`);return}let L=J.resolveDesktopInstallPlan(F);if(L.kind==="unsupported")throw c2(L);if(L.kind==="macos-dmg"){if(P)W(X?"Stopping running petdex-desktop":`${E.default.dim("•")} Stopping running petdex-desktop`),await J.stopDesktop();let M=z();M.start(`Installing ${F.tag_name} app`);let T;try{T=await J.installAppBundleFromDmg(F,u2())}catch(x){throw M.stop(X?"failed":E.default.red("failed")),x}M.stop(X?`Installed ${T.appBundleRoot} (${x6(T.dmgAsset.size)})`:`${E.default.green("✓")} Installed ${E.default.bold(T.appBundleRoot)} (${x6(T.dmgAsset.size)})`),await mQ(J.versionFile,F.tag_name),C0("cli_update_applied",{cli_version:$,from_version:Z??void 0,to_version:F.tag_name,duration_ms:Date.now()-Y}),await J.hookRefresh(W,G,X);let D=Z?`${Z} -> ${F.tag_name}`:F.tag_name;U(X?`${D} (run petdex up to launch the app)`:`${E.default.green("✓")} ${D}
426
- ${E.default.dim(" Run petdex up to launch the app.")}`);return}let A=z();A.start(`Downloading ${F.tag_name}`);let B;try{B=await J.stageDesktopAssets(F)}catch(M){throw A.stop(X?"failed":E.default.red("failed")),M}if(A.stop(X?`Downloaded ${F.tag_name} (${x6(B.binAsset.size)})`:`${E.default.green("✓")} Downloaded ${E.default.bold(F.tag_name)} (${x6(B.binAsset.size)})`),P){W(X?"Stopping running petdex-desktop":`${E.default.dim("•")} Stopping running petdex-desktop`);let M=await J.stopDesktop();if(process.platform==="win32"&&!M.ok){let T=J.desktopStatus();if(T.state==="running"&&DQ(T.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 J.commitDesktopAssets(B),await mQ(J.versionFile,F.tag_name),P){W(X?"Asking sidecar to release port":`${E.default.dim("•")} Asking sidecar to release port`);let M=await J.requestSidecarHandoff();if(W(X?M?"Sidecar acknowledged handoff":"Sidecar handoff unavailable, falling back to port wait":M?`${E.default.dim("•")} Sidecar acknowledged handoff`:`${E.default.dim("•")} Sidecar handoff unavailable, falling back to port wait`),!await J.waitForPortRelease(n2,{timeoutMs:1e4})){G(X?`Port ${n2} still in use after 10s. Run 'petdex desktop stop && petdex desktop start' to recover.`:`${E.default.yellow("!")} Port ${n2} still in use after 10s. Run \`petdex desktop stop && petdex desktop start\` to recover.`);return}W(X?"Restarting petdex-desktop":`${E.default.dim("•")} Restarting petdex-desktop`);let D=await J.startDesktop();if(D.ok)W(X?`Restarted (pid ${D.pid})`:`${E.default.green("✓")} Restarted (pid ${D.pid})`);else G(X?`Could not restart: ${D.reason}. Run 'petdex desktop start' manually.`:`${E.default.yellow("!")} Could not restart: ${D.reason}. Run \`petdex desktop start\` manually.`)}C0("cli_update_applied",{cli_version:$,from_version:Z??void 0,to_version:F.tag_name,duration_ms:Date.now()-Y}),await J.hookRefresh(W,G,X);let O=Z?`${Z} -> ${F.tag_name}`:F.tag_name;U(X?O:`${E.default.green("✓")} ${O}`)}async function hH(Q,$,q){try{let{runRefresh:J}=await Promise.resolve().then(() => (fQ(),hQ)),Y=await J();if(Y.refreshed.length>0)Q(q?`Refreshed hooks for: ${Y.refreshed.join(", ")}`:`Refreshed hooks for ${E.default.cyan(Y.refreshed.join(", "))}`)}catch(J){$(`Hook refresh failed: ${J.message}`)}}function x6(Q){if(Q<1024)return`${Q} B`;if(Q<1048576)return`${(Q/1024).toFixed(1)} KB`;return`${(Q/1024/1024).toFixed(1)} MB`}bQ();t1();L8();var V0=p0(R1(),1);import{existsSync as y1}from"node:fs";import{readFile as pQ,rm as dQ,stat as fH,writeFile as lQ}from"node:fs/promises";import K3 from"node:path";vQ();async function G3(Q={}){N0(V0.default.bgMagenta(V0.default.white(" petdex hooks uninstall ")));let q=(await mH()).filter((V)=>V.installed);if(q.length===0)return w0(V0.default.dim("No agent configs found. Nothing to uninstall.")),{uninstalledAgents:[]};let J=[],Y=[];for(let{agent:V}of q)try{let X=await uH(V);if(X.removed){Y.push(V.id);let K=X.backupPath?` ${V0.default.dim(`(backup: ${K3.basename(X.backupPath)})`)}`:"";J.push(` ${V0.default.green("✓")} ${V0.default.bold(V.displayName)}${K}`)}else J.push(` ${V0.default.dim("•")} ${V0.default.bold(V.displayName)} ${V0.default.dim("(no petdex entries found)")}`);if(V.id!=="antigravity")await o2(V)}catch(X){J.push(` ${V0.default.red("✗")} ${V0.default.bold(V.displayName)} ${V0.default.red(X instanceof Error?X.message:String(X))}`)}if(b0(J.join(`
427
- `),"Done"),Q.removeToken)try{await dQ(O8(),{force:!0}),i.info(`${V0.default.green("✓")} Removed ${O8()}`)}catch{}else if(y1(O8()))i.info(V0.default.dim(`Token file at ${O8()} kept. Pass --remove-token to delete it.`));return w0(`${V0.default.green("✓")} Done. Run ${V0.default.cyan("petdex hooks install")} to wire petdex back in.`),{uninstalledAgents:Y}}async function mH(){return Promise.all(H1.map(async(Q)=>({agent:Q,installed:Q.id==="antigravity"?cH():y1(Q.configDir)})))}function cH(){return v1().some((Q)=>y1(K3.dirname(Q)))||y1(S1())}async function uH(Q){if(Q.id==="opencode"){if(!y1(Q.configFile))return{removed:!1,backupPath:null};let V=await uQ(Q.configFile);return await dQ(Q.configFile,{force:!0}),{removed:!0,backupPath:V}}if(Q.id==="antigravity"){let V=!1;for(let X of v1())try{if(y1(X)){let K=await pQ(X,"utf8"),W=JSON.parse(K),G=W.mcpServers??{};if(G.petdex){let{petdex:U,...z}=G;W.mcpServers=z,await uQ(X),await lQ(X,`${JSON.stringify(W,null,2)}
428
- `,"utf8"),V=!0}}}catch{}try{let X=S1(),K=!1;try{await fH(X),K=!0}catch{}if(K)await dQ(X,{recursive:!0,force:!0}),V=!0}catch{}return{removed:V,backupPath:null}}if(!y1(Q.configFile))return{removed:!1,backupPath:null};let $;try{$=await pQ(Q.configFile,"utf8")}catch(V){throw Error(`Could not read ${Q.configFile}: ${V.message}`)}let q;try{q=JSON.parse($)}catch(V){throw Error(`Refusing to overwrite ${Q.configFile}: invalid JSON (${V.message}). Hand-edit the file to remove petdex entries.`)}let J=pH(q);if(!J.changed)return{removed:!1,backupPath:null};let Y=await uQ(Q.configFile);return await lQ(Q.configFile,`${JSON.stringify(J.value,null,2)}
429
- `,"utf8"),{removed:!0,backupPath:Y}}function pH(Q){let $={...Q},q=$.hooks;if(!q||typeof q!=="object"||Array.isArray(q))return{value:$,changed:!1};let J=!1,Y={};for(let[V,X]of Object.entries(q)){if(!Array.isArray(X)){Y[V]=X;continue}let K=X.filter((W)=>!dH(W));if(K.length!==X.length)J=!0;if(K.length>0)Y[V]=K}if(!J)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 dH(Q){if(typeof Q!=="object"||Q==null)return!1;return lH(Q).some((q)=>q.includes(`localhost:${F8}/state`)||q.includes(r1))}function lH(Q){let $=[];function q(J){if(typeof J==="string"){$.push(J);return}if(Array.isArray(J)){for(let Y of J)q(Y);return}if(typeof J==="object"&&J!=null)for(let Y of Object.values(J))q(Y)}return q(Q),$}async function uQ(Q){if(!y1(Q))return null;let $=new Date().toISOString().replace(/[:.]/g,"-"),q=`${Q}.${$}.bak`,J=await pQ(Q);return await lQ(q,J),q}var q0=process.env.PETDEX_URL??"https://petdex.crafter.run",NF=`${q0.replace(/\/+$/,"")}/`,BF="https://clerk.petdex.crafter.run",MF="LcThwEayl6KAA1Qm",aQ=["profile","email","openid","offline_access"];async function PF(){let Q=process.env.CLERK_ISSUER,$=process.env.CLERK_OAUTH_CLIENT_ID;if(Q&&$)return{issuer:Q,clientId:$,scopes:aQ};try{let q=await fetch(`${q0}/api/cli/auth-config`,{signal:AbortSignal.timeout(3000)});if(q.ok){let J=await q.json(),Y=typeof J.issuer==="string"?J.issuer:null,V=typeof J.clientId==="string"?J.clientId:null,X=Array.isArray(J.scopes)?J.scopes.filter((K)=>typeof K==="string"):null;if(Y&&V)return{issuer:Q??Y,clientId:$??V,scopes:X&&X.length>0?X:aQ}}}catch{}return{issuer:Q??BF,clientId:$??MF,scopes:aQ}}var a2=null;async function S8(){if(a2)return a2;let Q=await PF();return a2=new g2({clientId:Q.clientId,issuer:Q.issuer,scopes:Q.scopes,storage:"keychain",keychainService:"petdex-cli"}),a2}var u0="0.4.2";IF().catch((Q)=>{d(`petdex: ${Q.message}`),process.exit(1)});async function IF(){let Q=process.argv.slice(2),$=Q[0];if($==="bubble"){let{runBubble:J}=await Promise.resolve().then(() => (B3(),N3));await J(Q.slice(1));return}if($==="mcp-server"){let{runMcpServer:J}=await Promise.resolve().then(() => (A3(),T3));await J();return}if(!$||$==="--help"||$==="-h"||$==="help"){x3();return}if(!new Set(["version","--version","-v","telemetry"]).has($))lY();switch($){case"login":await CF();break;case"logout":await TF();break;case"whoami":await AF();break;case"submit":await SF(Q.slice(1));break;case"edit":await EF(Q.slice(1));break;case"install":await RF(Q.slice(1));break;case"list":await xF();break;case"select":await vF(Q.slice(1));break;case"hooks":await uF(Q.slice(1));break;case"desktop":await iF(Q.slice(1));break;case"init":await dF();break;case"up":await h3();break;case"down":await f3();break;case"toggle":await oF();break;case"update":await X3(Q.slice(1),u0);break;case"doctor":await CY();break;case"telemetry":nF(Q.slice(1));break;case"version":case"--version":case"-v":console.log(u0);break;default:console.error(j.default.red(`Unknown command: ${$}`)),x3(),process.exit(1)}}function x3(){let Q=j.default.cyan,$=j.default.dim;console.log(["",` ${j.default.bold(j.default.magenta("petdex"))} ${$(u0)} ${$("Codex pet gallery CLI")}`,"",` ${Q("Usage")}`," petdex <command> [args]","",` ${Q("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("edit")} <slug> Edit a pet you own (--desc, --displayName, --sprite, --meta, --zip)`,` ${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("select")} [slug] Set the active pet shown by the desktop mascot`,` ${j.default.bold("mcp-server")} Start the MCP protocol server for Antigravity integration`,` ${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`,"",` ${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 select ${$("# pick active mascot from installed pets")}`,` ${$("$")} petdex select boba ${$("# set active mascot directly")}`,` ${$("$")} petdex toggle ${$("# wake or sleep the mascot")}`,` ${$("$")} petdex doctor ${$("# diagnose install + agents")}`,` ${$("$")} petdex update ${$("# pull the latest release")}`,"",` ${$("Gallery & docs:")} ${j.default.underline(q0)}`,""].join(`
430
- `))}async function CF(){N0(j.default.bgMagenta(j.default.white(" petdex login ")));let Q=U0();Q.start("Opening your browser to sign in with Clerk");try{let $=await S8(),{user:q}=await $.login(),J=g3(q.email,q.username,q.sub)??"unknown";Q.stop(`${j.default.green("✓ ")}Signed in as ${j.default.cyan(J)}`),w0(`Try ${j.default.cyan("petdex submit ~/.codex/pets")} to share your pets.`)}catch($){throw Q.stop(j.default.red("× login failed")),Error(fF($.message))}}async function TF(){await(await S8()).logout(),console.log(`${j.default.green("✓ ")}Signed out`)}async function AF(){try{let $=await(await S8()).whoami();if(!$)throw Error("not signed in");let q=[t2($.given_name),t2($.family_name)].filter(Boolean).join(" ");b0([`${j.default.dim("user: ")}${$.sub}`,`${j.default.dim("email: ")}${$.email??"—"}`,`${j.default.dim("name: ")}${q||"—"}`,`${j.default.dim("username:")}${t2($.preferred_username)??"—"}`].join(`
431
- `),"Signed in")}catch{d(`Not signed in. Run ${j.default.cyan("petdex login")}.`),process.exit(1)}}async function DF(){let Q=await fetch(`${q0}/api/manifest`);if(!Q.ok)throw Error(`manifest fetch ${Q.status}`);return(await Q.json()).pets}async function wF(Q){let $=Q.slug;if(!B8(Q.spritesheetUrl)||!B8(Q.petJsonUrl))throw Error(`untrusted asset host for ${$} (admin needs to re-upload)`);let q=Z0.join(R3(),".petdex","pets",$),J=Z0.join(R3(),".codex","pets",$);await Promise.all([w3(q,{recursive:!0}),w3(J,{recursive:!0})]);let Y=Q.spritesheetUrl.endsWith(".png")?"png":"webp",V=async(W)=>{let G=await fetch(W,{headers:{Referer:NF}});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([r2(Z0.join(q,"pet.json"),Buffer.from(X)),r2(Z0.join(q,`spritesheet.${Y}`),Buffer.from(K)),r2(Z0.join(J,"pet.json"),Buffer.from(X)),r2(Z0.join(J,`spritesheet.${Y}`),Buffer.from(K))]),fetch(`${q0}/install/${$}`,{method:"GET"}).catch(()=>{})}async function RF(Q){let $=Q[0];if(!$)d(`Usage: ${j.default.cyan("petdex install <slug> [slug...]")} or ${j.default.cyan("petdex install desktop")}`),process.exit(1);if($==="desktop"){let{tag:U}=await TQ();C0("cli_install_desktop_success",{cli_version:u0,os:process.platform,arch:process.arch,binary_version:U.replace(/^desktop-v/,"")});return}let q=Array.from(new Set(Q)),J=U0();J.start(q.length===1?`Resolving ${q[0]}`:`Resolving ${q.length} pets`);let Y;try{Y=await DF()}catch(U){throw J.stop(j.default.red("manifest failed")),U}let V=[],X=[];for(let U of q){let z=Y.find((Z)=>Z.slug===U);if(z)V.push(z);else X.push(U)}if(V.length===0)J.stop(j.default.red("none found")),d(`No pets matched. Try ${j.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];J.message(V.length===1?`Downloading ${z.slug}`:`Downloading ${z.slug} (${U+1}/${V.length})`);try{await wF(z),K.push(z.displayName)}catch(Z){W.push({slug:z.slug,reason:Z instanceof Error?Z.message:String(Z)})}}if(K.length===V.length)J.stop(K.length===1?`Installed ${j.default.cyan(K[0])}`:`Installed ${j.default.cyan(K.length)} pets`);else if(K.length>0)J.stop(`Installed ${j.default.cyan(K.length)} of ${V.length} (${j.default.red(`${W.length} failed`)})`);else J.stop(j.default.red("all failed"));let G=[];if(K.length>0)G.push("Paths:"),G.push(` ${j.default.dim("~/.petdex/pets/")} (Petdex Desktop)`),G.push(` ${j.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(` ${j.default.cyan("Settings -> Appearance -> Pets")}`);if(X.length>0){if(G.length>0)G.push("");G.push(j.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(j.default.red("Failed:"));for(let U of W)G.push(` ${U.slug}: ${U.reason}`)}if(G.length>0)b0(G.join(`
432
- `),"Next steps");if(W.length>0&&K.length===0)process.exit(1)}async function xF(){let Q=U0();Q.start("Fetching gallery");let $=await fetch(`${q0}/api/manifest`);if(!$.ok)throw Q.stop(j.default.red("failed")),Error(`failed to fetch manifest: ${$.status}`);let q=await $.json();Q.stop(`${q.total} pets`);let J=q.pets.map((Y)=>{let V=Y.submittedBy?j.default.dim(` by ${Y.submittedBy}`):"";return` ${j.default.cyan(Y.slug.padEnd(26))} ${Y.displayName}${V}`});console.log(J.join(`
422
+ `;Zz(process.execPath,["-e",Y],{detached:!0,stdio:"ignore"}).unref()}catch{}}var n2=7777,dz="x-petdex-update-token",lz=cQ.join(G3(),".petdex","runtime","update-token"),W3=cQ.join(G3(),".petdex","version");async function oz(Q={}){let $=Q.port??n2,q=Q.timeoutMs??2000,J=Q.tokenPath??lz,Y;try{Y=X3(J,"utf8").trim()}catch{return!1}if(!Y)return!1;let V=new AbortController,K=setTimeout(()=>V.abort(),q);try{return(await fetch(`http://127.0.0.1:${$}/update/handoff`,{method:"POST",headers:{[dz]:Y},signal:V.signal})).ok}catch{return!1}finally{clearTimeout(K)}}function iz(Q=W3){if(!cz(Q))return null;try{return X3(Q,"utf8").trim()||null}catch{return null}}async function mQ(Q,$){await uz(cQ.dirname(Q),{recursive:!0}),await pz(Q,`${$}
423
+ `)}async function j3(Q=[],$,q={}){let J={fetchLatestRelease:OQ,desktopBinPath:E0,appBundleRootFor:CY,desktopStatus:Q1,stopDesktop:a1,updateAppBundleFromDmg:MQ,resolveDesktopInstallPlan:m2,installAppBundleFromDmg:PQ,stageDesktopAssets:NQ,commitDesktopAssets:BQ,requestSidecarHandoff:oz,waitForPortRelease:I8,startDesktop:k1,hookRefresh:nz,versionFile:W3,...q},Y=Date.now(),V=Q.includes("--force"),K=Q.includes("--silent"),X=(M)=>{if(K)console.log(`[petdex update] ${M}`);else N0(E.default.bgMagenta(E.default.white(` ${M} `)))},W=(M)=>{if(K)console.log(M);else i.info(M)},G=(M)=>{if(K)console.warn(M);else i.warn(M)},j=(M)=>{if(K)console.log(M);else D0(M)},H=()=>{if(K)return{start:(T)=>console.log(T),stop:(T)=>console.log(T)};let M=j0();return{start:(T)=>M.start(T),stop:(T)=>M.stop(T)}};X("petdex update");let U=iz(J.versionFile);W(U?`Installed: ${K?U:E.default.cyan(U)}`:"No installed version recorded - treating as fresh install.");let z=H();z.start("Checking GitHub for the latest release");let F;try{F=await J.fetchLatestRelease()}catch(M){throw z.stop(K?"failed":E.default.red("failed")),Error(`Could not reach GitHub. Check your connection.
424
+ ${M.message}`)}if(z.stop(K?`Latest: ${F.tag_name}`:`${E.default.green("✓")} Latest: ${E.default.bold(F.tag_name)}`),!V&&U&&U===F.tag_name){j(K?"Already up to date.":`${E.default.green("✓")} Already up to date.`);return}let N=J.desktopBinPath(),C=J.appBundleRootFor(N),P=J.desktopStatus().state==="running";if(C){if(P)W(K?"Stopping running petdex-desktop":`${E.default.dim("•")} Stopping running petdex-desktop`),await J.stopDesktop();let M=H();M.start(`Downloading ${F.tag_name} DMG`);let T;try{T=await J.updateAppBundleFromDmg(F,C)}catch(x){throw M.stop(K?"failed":E.default.red("failed")),x}M.stop(K?`Replaced ${C} (${x6(T.dmgAsset.size)})`:`${E.default.green("✓")} Replaced ${E.default.bold(C)} (${x6(T.dmgAsset.size)})`),await mQ(J.versionFile,F.tag_name),C0("cli_update_applied",{cli_version:$,from_version:U??void 0,to_version:F.tag_name,duration_ms:Date.now()-Y}),await J.hookRefresh(W,G,K);let w=U?`${U} -> ${F.tag_name}`:F.tag_name;j(K?`${w} (relaunch Petdex from /Applications to use it)`:`${E.default.green("✓")} ${w}
425
+ ${E.default.dim(" Relaunch Petdex from /Applications to use it.")}`);return}let L=J.resolveDesktopInstallPlan(F);if(L.kind==="unsupported")throw c2(L);if(L.kind==="macos-dmg"){if(P)W(K?"Stopping running petdex-desktop":`${E.default.dim("•")} Stopping running petdex-desktop`),await J.stopDesktop();let M=H();M.start(`Installing ${F.tag_name} app`);let T;try{T=await J.installAppBundleFromDmg(F,u2())}catch(x){throw M.stop(K?"failed":E.default.red("failed")),x}M.stop(K?`Installed ${T.appBundleRoot} (${x6(T.dmgAsset.size)})`:`${E.default.green("✓")} Installed ${E.default.bold(T.appBundleRoot)} (${x6(T.dmgAsset.size)})`),await mQ(J.versionFile,F.tag_name),C0("cli_update_applied",{cli_version:$,from_version:U??void 0,to_version:F.tag_name,duration_ms:Date.now()-Y}),await J.hookRefresh(W,G,K);let w=U?`${U} -> ${F.tag_name}`:F.tag_name;j(K?`${w} (run petdex up to launch the app)`:`${E.default.green("✓")} ${w}
426
+ ${E.default.dim(" Run petdex up to launch the app.")}`);return}let A=H();A.start(`Downloading ${F.tag_name}`);let B;try{B=await J.stageDesktopAssets(F)}catch(M){throw A.stop(K?"failed":E.default.red("failed")),M}if(A.stop(K?`Downloaded ${F.tag_name} (${x6(B.binAsset.size)})`:`${E.default.green("✓")} Downloaded ${E.default.bold(F.tag_name)} (${x6(B.binAsset.size)})`),P){W(K?"Stopping running petdex-desktop":`${E.default.dim("•")} Stopping running petdex-desktop`);let M=await J.stopDesktop();if(process.platform==="win32"&&!M.ok){let T=J.desktopStatus();if(T.state==="running"&&wQ(T.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 J.commitDesktopAssets(B),await mQ(J.versionFile,F.tag_name),P){W(K?"Asking sidecar to release port":`${E.default.dim("•")} Asking sidecar to release port`);let M=await J.requestSidecarHandoff();if(W(K?M?"Sidecar acknowledged handoff":"Sidecar handoff unavailable, falling back to port wait":M?`${E.default.dim("•")} Sidecar acknowledged handoff`:`${E.default.dim("•")} Sidecar handoff unavailable, falling back to port wait`),!await J.waitForPortRelease(n2,{timeoutMs:1e4})){G(K?`Port ${n2} still in use after 10s. Run 'petdex desktop stop && petdex desktop start' to recover.`:`${E.default.yellow("!")} Port ${n2} still in use after 10s. Run \`petdex desktop stop && petdex desktop start\` to recover.`);return}W(K?"Restarting petdex-desktop":`${E.default.dim("•")} Restarting petdex-desktop`);let w=await J.startDesktop();if(w.ok)W(K?`Restarted (pid ${w.pid})`:`${E.default.green("✓")} Restarted (pid ${w.pid})`);else G(K?`Could not restart: ${w.reason}. Run 'petdex desktop start' manually.`:`${E.default.yellow("!")} Could not restart: ${w.reason}. Run \`petdex desktop start\` manually.`)}C0("cli_update_applied",{cli_version:$,from_version:U??void 0,to_version:F.tag_name,duration_ms:Date.now()-Y}),await J.hookRefresh(W,G,K);let O=U?`${U} -> ${F.tag_name}`:F.tag_name;j(K?O:`${E.default.green("✓")} ${O}`)}async function nz(Q,$,q){try{let{runRefresh:J}=await Promise.resolve().then(() => (fQ(),hQ)),Y=await J();if(Y.refreshed.length>0)Q(q?`Refreshed hooks for: ${Y.refreshed.join(", ")}`:`Refreshed hooks for ${E.default.cyan(Y.refreshed.join(", "))}`)}catch(J){$(`Hook refresh failed: ${J.message}`)}}function x6(Q){if(Q<1024)return`${Q} B`;if(Q<1048576)return`${(Q/1024).toFixed(1)} KB`;return`${(Q/1024/1024).toFixed(1)} MB`}bQ();t1();L8();var V0=p0(R1(),1);import{existsSync as y1}from"node:fs";import{readFile as pQ,rm as dQ,stat as rz,writeFile as lQ}from"node:fs/promises";import Z3 from"node:path";vQ();async function U3(Q={}){N0(V0.default.bgMagenta(V0.default.white(" petdex hooks uninstall ")));let q=(await az()).filter((V)=>V.installed);if(q.length===0)return D0(V0.default.dim("No agent configs found. Nothing to uninstall.")),{uninstalledAgents:[]};let J=[],Y=[];for(let{agent:V}of q)try{let K=await tz(V);if(K.removed){Y.push(V.id);let X=K.backupPath?` ${V0.default.dim(`(backup: ${Z3.basename(K.backupPath)})`)}`:"";J.push(` ${V0.default.green("✓")} ${V0.default.bold(V.displayName)}${X}`)}else J.push(` ${V0.default.dim("•")} ${V0.default.bold(V.displayName)} ${V0.default.dim("(no petdex entries found)")}`);if(V.id!=="antigravity")await o2(V)}catch(K){J.push(` ${V0.default.red("✗")} ${V0.default.bold(V.displayName)} ${V0.default.red(K instanceof Error?K.message:String(K))}`)}if(b0(J.join(`
427
+ `),"Done"),Q.removeToken)try{await dQ(O8(),{force:!0}),i.info(`${V0.default.green("✓")} Removed ${O8()}`)}catch{}else if(y1(O8()))i.info(V0.default.dim(`Token file at ${O8()} kept. Pass --remove-token to delete it.`));return D0(`${V0.default.green("✓")} Done. Run ${V0.default.cyan("petdex hooks install")} to wire petdex back in.`),{uninstalledAgents:Y}}async function az(){return Promise.all(z1.map(async(Q)=>({agent:Q,installed:Q.id==="antigravity"?sz():y1(Q.configDir)})))}function sz(){return v1().some((Q)=>y1(Z3.dirname(Q)))||y1(S1())}async function tz(Q){if(Q.id==="opencode"){if(!y1(Q.configFile))return{removed:!1,backupPath:null};let V=await uQ(Q.configFile);return await dQ(Q.configFile,{force:!0}),{removed:!0,backupPath:V}}if(Q.id==="antigravity"){let V=!1;for(let K of v1())try{if(y1(K)){let X=await pQ(K,"utf8"),W=JSON.parse(X),G=W.mcpServers??{};if(G.petdex){let{petdex:j,...H}=G;W.mcpServers=H,await uQ(K),await lQ(K,`${JSON.stringify(W,null,2)}
428
+ `,"utf8"),V=!0}}}catch{}try{let K=S1(),X=!1;try{await rz(K),X=!0}catch{}if(X)await dQ(K,{recursive:!0,force:!0}),V=!0}catch{}return{removed:V,backupPath:null}}if(!y1(Q.configFile))return{removed:!1,backupPath:null};let $;try{$=await pQ(Q.configFile,"utf8")}catch(V){throw Error(`Could not read ${Q.configFile}: ${V.message}`)}let q;try{q=JSON.parse($)}catch(V){throw Error(`Refusing to overwrite ${Q.configFile}: invalid JSON (${V.message}). Hand-edit the file to remove petdex entries.`)}let J=ez(q);if(!J.changed)return{removed:!1,backupPath:null};let Y=await uQ(Q.configFile);return await lQ(Q.configFile,`${JSON.stringify(J.value,null,2)}
429
+ `,"utf8"),{removed:!0,backupPath:Y}}function ez(Q){let $={...Q},q=$.hooks;if(!q||typeof q!=="object"||Array.isArray(q))return{value:$,changed:!1};let J=!1,Y={};for(let[V,K]of Object.entries(q)){if(!Array.isArray(K)){Y[V]=K;continue}let X=K.filter((W)=>!QF(W));if(X.length!==K.length)J=!0;if(X.length>0)Y[V]=X}if(!J)return{value:$,changed:!1};if(Object.keys(Y).length===0){let{hooks:V,...K}=$;return{value:K,changed:!0}}return $.hooks=Y,{value:$,changed:!0}}function QF(Q){if(typeof Q!=="object"||Q==null)return!1;return $F(Q).some((q)=>q.includes(`localhost:${F8}/state`)||q.includes(r1))}function $F(Q){let $=[];function q(J){if(typeof J==="string"){$.push(J);return}if(Array.isArray(J)){for(let Y of J)q(Y);return}if(typeof J==="object"&&J!=null)for(let Y of Object.values(J))q(Y)}return q(Q),$}async function uQ(Q){if(!y1(Q))return null;let $=new Date().toISOString().replace(/[:.]/g,"-"),q=`${Q}.${$}.bak`,J=await pQ(Q);return await lQ(q,J),q}var u3="https://petdex.crafter.run",$0=process.env.PETDEX_URL??u3,RF=`${$0.replace(/\/+$/,"")}/`,k3=process.env.PETDEX_MANIFEST_V2_URL??_F($0),xF="https://clerk.petdex.crafter.run",vF="LcThwEayl6KAA1Qm",aQ=["profile","email","openid","offline_access"];async function SF(){let Q=process.env.CLERK_ISSUER,$=process.env.CLERK_OAUTH_CLIENT_ID;if(Q&&$)return{issuer:Q,clientId:$,scopes:aQ};try{let q=await fetch(`${$0}/api/cli/auth-config`,{signal:AbortSignal.timeout(3000)});if(q.ok){let J=await q.json(),Y=typeof J.issuer==="string"?J.issuer:null,V=typeof J.clientId==="string"?J.clientId:null,K=Array.isArray(J.scopes)?J.scopes.filter((X)=>typeof X==="string"):null;if(Y&&V)return{issuer:Q??Y,clientId:$??V,scopes:K&&K.length>0?K:aQ}}}catch{}return{issuer:Q??xF,clientId:$??vF,scopes:aQ}}var a2=null;async function S8(){if(a2)return a2;let Q=await SF();return a2=new g2({clientId:Q.clientId,issuer:Q.issuer,scopes:Q.scopes,storage:"keychain",keychainService:"petdex-cli"}),a2}var u0="0.4.2";EF().catch((Q)=>{d(`petdex: ${Q.message}`),process.exit(1)});async function EF(){let Q=process.argv.slice(2),$=Q[0];if($==="bubble"){let{runBubble:J}=await Promise.resolve().then(() => (C3(),I3));await J(Q.slice(1));return}if($==="mcp-server"){let{runMcpServer:J}=await Promise.resolve().then(() => (x3(),R3));await J();return}if(!$||$==="--help"||$==="-h"||$==="help"){y3();return}if(!new Set(["version","--version","-v","telemetry"]).has($))rY();switch($){case"login":await kF();break;case"logout":await yF();break;case"whoami":await gF();break;case"submit":await cF(Q.slice(1));break;case"edit":await uF(Q.slice(1));break;case"install":await hF(Q.slice(1));break;case"list":await fF();break;case"select":await mF(Q.slice(1));break;case"hooks":await tF(Q.slice(1));break;case"desktop":await JL(Q.slice(1));break;case"init":await QL();break;case"up":await i3();break;case"down":await n3();break;case"toggle":await qL();break;case"update":await j3(Q.slice(1),u0);break;case"doctor":await DY();break;case"telemetry":YL(Q.slice(1));break;case"version":case"--version":case"-v":console.log(u0);break;default:console.error(Z.default.red(`Unknown command: ${$}`)),y3(),process.exit(1)}}function y3(){let Q=Z.default.cyan,$=Z.default.dim;console.log(["",` ${Z.default.bold(Z.default.magenta("petdex"))} ${$(u0)} ${$("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("select")} [slug] Set the active pet shown by the desktop mascot`,` ${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 select ${$("# pick active mascot from installed pets")}`,` ${$("$")} petdex select boba ${$("# set active mascot directly")}`,` ${$("$")} petdex toggle ${$("# wake or sleep the mascot")}`,` ${$("$")} petdex doctor ${$("# diagnose install + agents")}`,` ${$("$")} petdex update ${$("# pull the latest release")}`,"",` ${$("Gallery & docs:")} ${Z.default.underline($0)}`,""].join(`
430
+ `))}async function kF(){N0(Z.default.bgMagenta(Z.default.white(" petdex login ")));let Q=j0();Q.start("Opening your browser to sign in with Clerk");try{let $=await S8(),{user:q}=await $.login(),J=d3(q.email,q.username,q.sub)??"unknown";Q.stop(`${Z.default.green("✓ ")}Signed in as ${Z.default.cyan(J)}`),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 yF(){await(await S8()).logout(),console.log(`${Z.default.green("✓ ")}Signed out`)}async function gF(){try{let $=await(await S8()).whoami();if(!$)throw Error("not signed in");let q=[t2($.given_name),t2($.family_name)].filter(Boolean).join(" ");b0([`${Z.default.dim("user: ")}${$.sub}`,`${Z.default.dim("email: ")}${$.email??"—"}`,`${Z.default.dim("name: ")}${q||"—"}`,`${Z.default.dim("username:")}${t2($.preferred_username)??"—"}`].join(`
431
+ `),"Signed in")}catch{d(`Not signed in. Run ${Z.default.cyan("petdex login")}.`),process.exit(1)}}async function p3(){let Q=await g3(k3).catch(()=>null);if(Q&&Q.length>0)return Q;let $=`${$0}/api/manifest/v2`;if(k3!==$){let Y=await g3($).catch(()=>null);if(Y&&Y.length>0)return Y}let q=await fetch(`${$0}/api/manifest`);if(!q.ok)throw Error(`manifest fetch ${q.status}`);return(await q.json()).pets}async function g3(Q){let $=await fetch(Q);if(!$.ok)return null;let q=await $.json();if(!Array.isArray(q.pets))return null;let J=typeof q.assetBase==="string"?q.assetBase.replace(/\/+$/,""):"";return q.pets.flatMap((Y)=>{let[V,K,X,W,G,j]=Y,H=_3(J,G),U=_3(J,j);if(!V||!K||!H||!U)return[];return[{slug:V,displayName:K,kind:X,submittedBy:W,spritesheetUrl:H,petJsonUrl:U}]})}function _F(Q){let $=Q.replace(/\/+$/,"");if($===u3||$==="https://petdex.dev"||$==="https://www.petdex.dev")return"https://assets.petdex.dev/manifests/petdex-v2.json";return`${$}/api/manifest/v2`}function _3(Q,$){if(!$)return null;if(/^https:\/\//.test($))return $;if(!Q)return null;return`${Q}/${$.replace(/^\/+/,"")}`}async function bF(Q){let $=Q.slug;if(!B8(Q.spritesheetUrl)||!B8(Q.petJsonUrl))throw Error(`untrusted asset host for ${$} (admin needs to re-upload)`);let q=U0.join(E3(),".petdex","pets",$),J=U0.join(E3(),".codex","pets",$);await Promise.all([S3(q,{recursive:!0}),S3(J,{recursive:!0})]);let Y=Q.spritesheetUrl.endsWith(".png")?"png":"webp",V=async(W)=>{let G=await fetch(W,{headers:{Referer:RF}});if(!G.ok)throw Error(`download ${W} -> ${G.status} ${G.statusText}`);return G.arrayBuffer()},[K,X]=await Promise.all([V(Q.petJsonUrl),V(Q.spritesheetUrl)]);await Promise.all([r2(U0.join(q,"pet.json"),Buffer.from(K)),r2(U0.join(q,`spritesheet.${Y}`),Buffer.from(X)),r2(U0.join(J,"pet.json"),Buffer.from(K)),r2(U0.join(J,`spritesheet.${Y}`),Buffer.from(X))]),fetch(`${$0}/install/${$}`,{method:"GET"}).catch(()=>{})}async function hF(Q){let $=Q[0];if(!$)d(`Usage: ${Z.default.cyan("petdex install <slug> [slug...]")} or ${Z.default.cyan("petdex install desktop")}`),process.exit(1);if($==="desktop"){let{tag:j}=await TQ();C0("cli_install_desktop_success",{cli_version:u0,os:process.platform,arch:process.arch,binary_version:j.replace(/^desktop-v/,"")});return}let q=Array.from(new Set(Q)),J=j0();J.start(q.length===1?`Resolving ${q[0]}`:`Resolving ${q.length} pets`);let Y;try{Y=await p3()}catch(j){throw J.stop(Z.default.red("manifest failed")),j}let V=[],K=[];for(let j of q){let H=Y.find((U)=>U.slug===j);if(H)V.push(H);else K.push(j)}if(V.length===0)J.stop(Z.default.red("none found")),d(`No pets matched. Try ${Z.default.cyan("petdex list")} to see what's available.`),process.exit(1);let X=[],W=[];for(let j=0;j<V.length;j++){let H=V[j];J.message(V.length===1?`Downloading ${H.slug}`:`Downloading ${H.slug} (${j+1}/${V.length})`);try{await bF(H),X.push(H.displayName)}catch(U){W.push({slug:H.slug,reason:U instanceof Error?U.message:String(U)})}}if(X.length===V.length)J.stop(X.length===1?`Installed ${Z.default.cyan(X[0])}`:`Installed ${Z.default.cyan(X.length)} pets`);else if(X.length>0)J.stop(`Installed ${Z.default.cyan(X.length)} of ${V.length} (${Z.default.red(`${W.length} failed`)})`);else J.stop(Z.default.red("all failed"));let G=[];if(X.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(K.length>0){if(G.length>0)G.push("");G.push(Z.default.yellow("Skipped (slug not found):"));for(let j of K)G.push(` ${j}`)}if(W.length>0){if(G.length>0)G.push("");G.push(Z.default.red("Failed:"));for(let j of W)G.push(` ${j.slug}: ${j.reason}`)}if(G.length>0)b0(G.join(`
432
+ `),"Next steps");if(W.length>0&&X.length===0)process.exit(1)}async function fF(){let Q=j0();Q.start("Fetching gallery");let $;try{$=await p3()}catch(J){throw Q.stop(Z.default.red("failed")),J}Q.stop(`${$.length} pets`);let q=$.map((J)=>{let Y=J.submittedBy?Z.default.dim(` by ${J.submittedBy}`):"";return` ${Z.default.cyan(J.slug.padEnd(26))} ${J.displayName}${Y}`});console.log(q.join(`
433
433
  `)),console.log(`
434
- ${j.default.dim("Install with")} ${j.default.cyan("petdex install <slug>")}
435
- ${j.default.dim("Browse:")} ${j.default.underline(q0)}`)}async function vF(Q){N0(j.default.bgMagenta(j.default.white(" petdex select ")));let $=await _Y();if($.length===0)d(`No usable pets installed. Run ${j.default.cyan("petdex install <slug>")} first.`),process.exit(1);let q=Q[0];if(!q){let V=await P5({message:"Which pet should the desktop mascot show?",options:$.map((X)=>({value:X,label:X}))});if(V1(V))d("Cancelled."),process.exit(0);q=V}else if(!$.includes(q))d(`${j.default.cyan(q)} is not installed. Run ${j.default.cyan(`petdex install ${q}`)} first.`),process.exit(1);await bY(q);let J=U0();J.start("Reloading desktop…");let Y=await hY();if(Y.status==="reloaded")J.stop(`${j.default.green("✓")} Active pet set to ${j.default.cyan(q)}`);else J.stop(`${j.default.green("✓")} Active pet set to ${j.default.cyan(q)}. ${j.default.yellow("Restart the desktop to see the change.")} ${j.default.dim(Y.reason)}`)}async function SF(Q){let q=Q.filter((L)=>!L.startsWith("--"))[0];if(!q)d(`Usage: ${j.default.cyan("petdex submit <path> [--force]")}`),process.exit(1);let J=await S8(),Y;try{let L=await J.getAccessToken();if(!L)d(`Not signed in. Run ${j.default.cyan("petdex login")}.`),process.exit(1);Y=L}catch{d(`Not signed in. Run ${j.default.cyan("petdex login")}.`),process.exit(1)}let V=q0;try{V=cF(await J.whoami())}catch{}let X=Z0.resolve(q),K=await y3(X).catch(()=>null);if(!K)d(`No such file or directory: ${q}`),process.exit(1);N0(j.default.bgMagenta(j.default.white(" petdex submit ")));let W=U0();W.start(`Scanning ${X}`);let G=await kF(X,K.isDirectory());if(W.stop(G.length>0?`${G.length} pet${G.length===1?"":"s"} found`:j.default.red("no pets found")),G.length===0)d("A pet folder must contain pet.json and spritesheet.{webp,png}."),process.exit(1);let z=Q.includes("--force")?new Map:await hF(G,Y),Z=G,H=0;if(z.size>0){let L=G.filter((O)=>z.has(v8(O.petIdHint))),A=G.filter((O)=>!z.has(v8(O.petIdHint)));b0(L.map((O)=>{let T=z.get(v8(O.petIdHint))?.status??"unknown";return`${j.default.yellow("•")} ${j.default.bold(O.label)} ${j.default.dim(`(${T})`)}`}).join(`
436
- `),`${L.length} already submitted by you`);let B=await P5({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(V1(B)||B==="cancel")d("Aborted."),process.exit(1);if(B==="skip"){if(Z=A,H=L.length,Z.length===0){w0(`Nothing new to submit. Track approval at ${j.default.underline(V)}.`);return}}}if(Z.length>1){let L=await m8({message:`Submit ${j.default.bold(String(Z.length))} pet${Z.length===1?"":"s"}?`});if(V1(L)||!L)d("Aborted."),process.exit(1)}let F=0,N=0,C=[];for(let L of Z){let A=U0();A.start(`Submitting ${j.default.cyan(L.label)}`);try{let B=await J.getAccessToken();if(!B)throw Error("session expired");Y=B;let O=await gF(L,Y);V=mF(O.profileUrl)??V,A.stop(`${j.default.green("✓")} ${j.default.cyan(L.label)} → ${_F(O)}`),F++}catch(B){let O=B.message;A.stop(`${j.default.red("×")} ${j.default.cyan(L.label)} ${j.default.red(O.slice(0,60))}`),C.push({label:L.label,error:O}),N++}}if(C.length>0)b0(C.map((L)=>`${j.default.red("•")} ${j.default.bold(L.label)}: ${L.error}`).join(`
437
- `),"Failures");let P=H>0?`, ${j.default.yellow(String(H))} skipped`:"";if(w0([`${j.default.green(String(F))} submitted${P}, ${N>0?j.default.red(String(N)):j.default.dim(String(N))} failed.`,`Held submissions stay visible at ${j.default.underline(V)}.`].join(`
438
- `)),N>0)process.exit(1)}async function EF(Q){let q=Q.filter((L)=>!L.startsWith("--"))[0];if(!q)d(`Usage: ${j.default.cyan('petdex edit <slug> [--desc "..."] [--displayName "..."] [--sprite ./new.webp] [--meta ./pet.json] [--zip ./pet.zip]')}`),process.exit(1);let J=await S8(),Y;try{let L=await J.getAccessToken();if(!L)d(`Not signed in. Run ${j.default.cyan("petdex login")}.`),process.exit(1);Y=L}catch{d(`Not signed in. Run ${j.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)d("Nothing to edit. Provide at least one flag."),process.exit(1);N0(j.default.bgMagenta(j.default.white(" petdex edit ")));let z=U0();z.start(`Resolving ${q}`);let Z=await fetch(`${q0}/api/pets/${q}`,{headers:{Authorization:`Bearer ${Y}`}});if(!Z.ok)z.stop(j.default.red("not found")),d(`Pet "${q}" not found or you don't own it.`),process.exit(1);let F=(await Z.json()).id;if(!F)z.stop(j.default.red("could not resolve pet id")),process.exit(1);z.stop(`Found ${j.default.cyan(q)}`);let N={};if(X)N.description=X;if(K)N.displayName=K;if(W||G||U){z.start("Uploading assets");let L=await fetch(`${q0}/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",T=B("sprite");if(T){await v6(T.uploadUrl,O,M);let{width:D,height:x}=b3(O);if(N.spritesheetUrl=T.publicUrl,D)N.spritesheetWidth=D;if(x)N.spritesheetHeight=x}}if(G){let O=await import("node:fs/promises").then((T)=>T.readFile(G)),M=B("petjson");if(M)await v6(M.uploadUrl,O,"application/json"),N.petJsonUrl=M.publicUrl}if(U){let O=await import("node:fs/promises").then((T)=>T.readFile(U)),M=B("zip");if(M)await v6(M.uploadUrl,O,"application/zip"),N.zipUrl=M.publicUrl}z.stop("Assets uploaded")}else z.stop(j.default.yellow("presign endpoint unavailable, skipping asset upload"))}z.start("Submitting edit");let C=await fetch(`${q0}/api/my-pets/${F}/edit`,{method:"PATCH",headers:{Authorization:`Bearer ${Y}`,"Content-Type":"application/json",Origin:q0},body:JSON.stringify(N)});if(!C.ok){let L=await C.text().catch(()=>"");z.stop(j.default.red(`edit failed: ${C.status}`)),d(L.slice(0,120)),process.exit(1)}let P=await C.json();z.stop(P.status==="auto_approved"?`${j.default.green("✓")} Edit auto-approved and live`:`${j.default.yellow("·")} Edit queued for admin review`),C0("cli_edit_invoked",{cli_version:u0}),w0(`Gallery: ${j.default.underline(`${q0}/pets/${q}`)}`)}async function kF(Q,$){if(!$){if(!Q.endsWith(".zip"))throw Error(`Expected a .zip file or a folder, got: ${Q}`);let V=await yF(Q);return V?[V]:[]}if(await s2(Z0.join(Q,"pet.json"))){let V=await v3(Q);return V?[V]:[]}let J=await OF(Q,{withFileTypes:!0}),Y=[];for(let V of J){if(!V.isDirectory())continue;let X=Z0.join(Q,V.name),K=await v3(X);if(K)Y.push(K)}return Y}async function v3(Q){let $=Z0.join(Q,"pet.json");if(!await s2($))return null;let q=Z0.join(Q,"spritesheet.webp"),J="webp";if(!await s2(q)){let U=Z0.join(Q,"spritesheet.png");if(!await s2(U))return null;q=U,J="png"}let Y=await sQ($,"utf8"),V={};try{V=JSON.parse(Y)}catch{throw Error(`pet.json in ${Q} is not valid JSON`)}let X=await sQ(q),K=new tQ.default;K.file("pet.json",Y),K.file(`spritesheet.${J}`,X);let W=Buffer.from(await K.generateAsync({type:"uint8array",compression:"DEFLATE"})),G=Z0.basename(Q);return{label:G,source:"folder",petJson:Y,petJsonObj:V,zipBuffer:W,zipFileName:`${G}.zip`,spritesheetBuffer:X,spritesheetExt:J,petIdHint:typeof V.id==="string"?V.id:G}}async function yF(Q){let $=await sQ(Q),q=await tQ.default.loadAsync($),J=q.file("pet.json"),Y=q.file("spritesheet.webp"),V=q.file("spritesheet.png"),X=Y??V,K=Y?"webp":"png";if(!J||!X)throw Error(`Zip is missing pet.json or spritesheet.{webp,png}: ${Q}`);let W=await J.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=Z0.basename(Q,".zip");return{label:z,source:"zip",petJson:W,petJsonObj:G,zipBuffer:$,zipFileName:Z0.basename(Q),spritesheetBuffer:U,spritesheetExt:K,petIdHint:typeof G.id==="string"?G.id:z}}async function gF(Q,$){let{width:q,height:J}=b3(Q.spritesheetBuffer);if(q===0||J===0)throw Error("spritesheet dimensions could not be parsed");let Y=await fetch(`${q0}/api/cli/submit`,{method:"POST",headers:{Authorization:`Bearer ${$}`,"Content-Type":"application/json"},body:JSON.stringify({slugHint:v8(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([v6(K.uploadUrl,Q.zipBuffer,"application/zip"),v6(W.uploadUrl,Q.spritesheetBuffer,U),v6(G.uploadUrl,Buffer.from(Q.petJson,"utf8"),"application/json")]);let z=await fetch(`${q0}/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:S3(Q.petJsonObj.displayName,"Untitled pet"),description:S3(Q.petJsonObj.description,"A Codex-compatible digital pet."),spritesheetWidth:q,spritesheetHeight:J})});if(!z.ok){let H=await z.text().catch(()=>"");throw Error(`register ${z.status} ${H.slice(0,100)}`)}return await z.json()}function _F(Q){let $=j.default.dim(Q.slug),q=bF(Q.review);if(Q.review.decision==="approved")return`${$} ${j.default.green("approved")}`;if(Q.review.decision==="rejected")return`${$} ${j.default.red("rejected")}${q?j.default.dim(`: ${q}`):""}`;return`${$} ${j.default.yellow("held for review")}${q?j.default.dim(`: ${q}`):""}`}function bF(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 v6(Q,$,q){let J=await fetch(Q,{method:"PUT",headers:{"Content-Type":q},body:$});if(!J.ok)throw Error(`R2 PUT ${J.status}`)}async function hF(Q,$){let q=new Map;if(Q.length===0)return q;try{let J=await fetch(`${q0}/api/cli/submit/check`,{method:"POST",headers:{Authorization:`Bearer ${$}`,"Content-Type":"application/json"},body:JSON.stringify({candidates:Q.map((V)=>({petId:V.petIdHint,slugHint:v8(V.petIdHint)}))}),signal:AbortSignal.timeout(8000)});if(!J.ok)return q;let Y=await J.json();for(let V of Y.existing??[])if(V&&typeof V.slug==="string")q.set(V.slug,V)}catch{}return q}function fF(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(`
434
+ ${Z.default.dim("Install with")} ${Z.default.cyan("petdex install <slug>")}
435
+ ${Z.default.dim("Browse:")} ${Z.default.underline($0)}`)}async function mF(Q){N0(Z.default.bgMagenta(Z.default.white(" petdex select ")));let $=await mY();if($.length===0)d(`No usable pets installed. Run ${Z.default.cyan("petdex install <slug>")} first.`),process.exit(1);let q=Q[0];if(!q){let V=await P5({message:"Which pet should the desktop mascot show?",options:$.map((K)=>({value:K,label:K}))});if(V1(V))d("Cancelled."),process.exit(0);q=V}else if(!$.includes(q))d(`${Z.default.cyan(q)} is not installed. Run ${Z.default.cyan(`petdex install ${q}`)} first.`),process.exit(1);await cY(q);let J=j0();J.start("Reloading desktop…");let Y=await uY();if(Y.status==="reloaded")J.stop(`${Z.default.green("✓")} Active pet set to ${Z.default.cyan(q)}`);else J.stop(`${Z.default.green("✓")} Active pet set to ${Z.default.cyan(q)}. ${Z.default.yellow("Restart the desktop to see the change.")} ${Z.default.dim(Y.reason)}`)}async function cF(Q){let q=Q.filter((L)=>!L.startsWith("--"))[0];if(!q)d(`Usage: ${Z.default.cyan("petdex submit <path> [--force]")}`),process.exit(1);let J=await S8(),Y;try{let L=await J.getAccessToken();if(!L)d(`Not signed in. Run ${Z.default.cyan("petdex login")}.`),process.exit(1);Y=L}catch{d(`Not signed in. Run ${Z.default.cyan("petdex login")}.`),process.exit(1)}let V=$0;try{V=sF(await J.whoami())}catch{}let K=U0.resolve(q),X=await c3(K).catch(()=>null);if(!X)d(`No such file or directory: ${q}`),process.exit(1);N0(Z.default.bgMagenta(Z.default.white(" petdex submit ")));let W=j0();W.start(`Scanning ${K}`);let G=await pF(K,X.isDirectory());if(W.stop(G.length>0?`${G.length} pet${G.length===1?"":"s"} found`:Z.default.red("no pets found")),G.length===0)d("A pet folder must contain pet.json and spritesheet.{webp,png}."),process.exit(1);let H=Q.includes("--force")?new Map:await nF(G,Y),U=G,z=0;if(H.size>0){let L=G.filter((O)=>H.has(v8(O.petIdHint))),A=G.filter((O)=>!H.has(v8(O.petIdHint)));b0(L.map((O)=>{let T=H.get(v8(O.petIdHint))?.status??"unknown";return`${Z.default.yellow("•")} ${Z.default.bold(O.label)} ${Z.default.dim(`(${T})`)}`}).join(`
436
+ `),`${L.length} already submitted by you`);let B=await P5({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(V1(B)||B==="cancel")d("Aborted."),process.exit(1);if(B==="skip"){if(U=A,z=L.length,U.length===0){D0(`Nothing new to submit. Track approval at ${Z.default.underline(V)}.`);return}}}if(U.length>1){let L=await m8({message:`Submit ${Z.default.bold(String(U.length))} pet${U.length===1?"":"s"}?`});if(V1(L)||!L)d("Aborted."),process.exit(1)}let F=0,N=0,C=[];for(let L of U){let A=j0();A.start(`Submitting ${Z.default.cyan(L.label)}`);try{let B=await J.getAccessToken();if(!B)throw Error("session expired");Y=B;let O=await lF(L,Y);V=aF(O.profileUrl)??V,A.stop(`${Z.default.green("✓")} ${Z.default.cyan(L.label)} → ${oF(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))}`),C.push({label:L.label,error:O}),N++}}if(C.length>0)b0(C.map((L)=>`${Z.default.red("•")} ${Z.default.bold(L.label)}: ${L.error}`).join(`
437
+ `),"Failures");let P=z>0?`, ${Z.default.yellow(String(z))} 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(`
438
+ `)),N>0)process.exit(1)}async function uF(Q){let q=Q.filter((L)=>!L.startsWith("--"))[0];if(!q)d(`Usage: ${Z.default.cyan('petdex edit <slug> [--desc "..."] [--displayName "..."] [--sprite ./new.webp] [--meta ./pet.json] [--zip ./pet.zip]')}`),process.exit(1);let J=await S8(),Y;try{let L=await J.getAccessToken();if(!L)d(`Not signed in. Run ${Z.default.cyan("petdex login")}.`),process.exit(1);Y=L}catch{d(`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 K=V("--desc"),X=V("--displayName"),W=V("--sprite"),G=V("--meta"),j=V("--zip");if(!K&&!X&&!W&&!G&&!j)d("Nothing to edit. Provide at least one flag."),process.exit(1);N0(Z.default.bgMagenta(Z.default.white(" petdex edit ")));let H=j0();H.start(`Resolving ${q}`);let U=await fetch(`${$0}/api/pets/${q}`,{headers:{Authorization:`Bearer ${Y}`}});if(!U.ok)H.stop(Z.default.red("not found")),d(`Pet "${q}" not found or you don't own it.`),process.exit(1);let F=(await U.json()).id;if(!F)H.stop(Z.default.red("could not resolve pet id")),process.exit(1);H.stop(`Found ${Z.default.cyan(q)}`);let N={};if(K)N.description=K;if(X)N.displayName=X;if(W||G||j){H.start("Uploading assets");let L=await fetch(`${$0}/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(j)})});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((w)=>w.readFile(W)),M=W.endsWith(".png")?"image/png":"image/webp",T=B("sprite");if(T){await v6(T.uploadUrl,O,M);let{width:w,height:x}=o3(O);if(N.spritesheetUrl=T.publicUrl,w)N.spritesheetWidth=w;if(x)N.spritesheetHeight=x}}if(G){let O=await import("node:fs/promises").then((T)=>T.readFile(G)),M=B("petjson");if(M)await v6(M.uploadUrl,O,"application/json"),N.petJsonUrl=M.publicUrl}if(j){let O=await import("node:fs/promises").then((T)=>T.readFile(j)),M=B("zip");if(M)await v6(M.uploadUrl,O,"application/zip"),N.zipUrl=M.publicUrl}H.stop("Assets uploaded")}else H.stop(Z.default.yellow("presign endpoint unavailable, skipping asset upload"))}H.start("Submitting edit");let C=await fetch(`${$0}/api/my-pets/${F}/edit`,{method:"PATCH",headers:{Authorization:`Bearer ${Y}`,"Content-Type":"application/json",Origin:$0},body:JSON.stringify(N)});if(!C.ok){let L=await C.text().catch(()=>"");H.stop(Z.default.red(`edit failed: ${C.status}`)),d(L.slice(0,120)),process.exit(1)}let P=await C.json();H.stop(P.status==="auto_approved"?`${Z.default.green("✓")} Edit auto-approved and live`:`${Z.default.yellow("·")} Edit queued for admin review`),C0("cli_edit_invoked",{cli_version:u0}),D0(`Gallery: ${Z.default.underline(`${$0}/pets/${q}`)}`)}async function pF(Q,$){if(!$){if(!Q.endsWith(".zip"))throw Error(`Expected a .zip file or a folder, got: ${Q}`);let V=await dF(Q);return V?[V]:[]}if(await s2(U0.join(Q,"pet.json"))){let V=await b3(Q);return V?[V]:[]}let J=await DF(Q,{withFileTypes:!0}),Y=[];for(let V of J){if(!V.isDirectory())continue;let K=U0.join(Q,V.name),X=await b3(K);if(X)Y.push(X)}return Y}async function b3(Q){let $=U0.join(Q,"pet.json");if(!await s2($))return null;let q=U0.join(Q,"spritesheet.webp"),J="webp";if(!await s2(q)){let j=U0.join(Q,"spritesheet.png");if(!await s2(j))return null;q=j,J="png"}let Y=await sQ($,"utf8"),V={};try{V=JSON.parse(Y)}catch{throw Error(`pet.json in ${Q} is not valid JSON`)}let K=await sQ(q),X=new tQ.default;X.file("pet.json",Y),X.file(`spritesheet.${J}`,K);let W=Buffer.from(await X.generateAsync({type:"uint8array",compression:"DEFLATE"})),G=U0.basename(Q);return{label:G,source:"folder",petJson:Y,petJsonObj:V,zipBuffer:W,zipFileName:`${G}.zip`,spritesheetBuffer:K,spritesheetExt:J,petIdHint:typeof V.id==="string"?V.id:G}}async function dF(Q){let $=await sQ(Q),q=await tQ.default.loadAsync($),J=q.file("pet.json"),Y=q.file("spritesheet.webp"),V=q.file("spritesheet.png"),K=Y??V,X=Y?"webp":"png";if(!J||!K)throw Error(`Zip is missing pet.json or spritesheet.{webp,png}: ${Q}`);let W=await J.async("string"),G={};try{G=JSON.parse(W)}catch{throw Error("pet.json in zip is not valid JSON")}let j=Buffer.from(await K.async("uint8array")),H=U0.basename(Q,".zip");return{label:H,source:"zip",petJson:W,petJsonObj:G,zipBuffer:$,zipFileName:U0.basename(Q),spritesheetBuffer:j,spritesheetExt:X,petIdHint:typeof G.id==="string"?G.id:H}}async function lF(Q,$){let{width:q,height:J}=o3(Q.spritesheetBuffer);if(q===0||J===0)throw Error("spritesheet dimensions could not be parsed");let Y=await fetch(`${$0}/api/cli/submit`,{method:"POST",headers:{Authorization:`Bearer ${$}`,"Content-Type":"application/json"},body:JSON.stringify({slugHint:v8(Q.petIdHint),petId:Q.petIdHint,spritesheetExt:Q.spritesheetExt})});if(!Y.ok){let z=await Y.text().catch(()=>"");throw Error(`presign ${Y.status} ${z.slice(0,100)}`)}let V=await Y.json(),K=(z)=>{let F=V.files.find((N)=>N.role===z);if(!F)throw Error(`presign response missing ${z}`);return F},X=K("zip"),W=K("sprite"),G=K("petjson"),j=Q.spritesheetExt==="png"?"image/png":"image/webp";await Promise.all([v6(X.uploadUrl,Q.zipBuffer,"application/zip"),v6(W.uploadUrl,Q.spritesheetBuffer,j),v6(G.uploadUrl,Buffer.from(Q.petJson,"utf8"),"application/json")]);let H=await fetch(`${$0}/api/cli/submit/register`,{method:"POST",headers:{Authorization:`Bearer ${$}`,"Content-Type":"application/json"},body:JSON.stringify({zipUrl:X.publicUrl,spritesheetUrl:W.publicUrl,petJsonUrl:G.publicUrl,petId:Q.petIdHint,displayName:h3(Q.petJsonObj.displayName,"Untitled pet"),description:h3(Q.petJsonObj.description,"A Codex-compatible digital pet."),spritesheetWidth:q,spritesheetHeight:J})});if(!H.ok){let z=await H.text().catch(()=>"");throw Error(`register ${H.status} ${z.slice(0,100)}`)}return await H.json()}function oF(Q){let $=Z.default.dim(Q.slug),q=iF(Q.review);if(Q.review.decision==="approved")return`${$} ${Z.default.green("approved")}`;if(Q.review.decision==="rejected")return`${$} ${Z.default.red("rejected")}${q?Z.default.dim(`: ${q}`):""}`;return`${$} ${Z.default.yellow("held for review")}${q?Z.default.dim(`: ${q}`):""}`}function iF(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 v6(Q,$,q){let J=await fetch(Q,{method:"PUT",headers:{"Content-Type":q},body:$});if(!J.ok)throw Error(`R2 PUT ${J.status}`)}async function nF(Q,$){let q=new Map;if(Q.length===0)return q;try{let J=await fetch(`${$0}/api/cli/submit/check`,{method:"POST",headers:{Authorization:`Bearer ${$}`,"Content-Type":"application/json"},body:JSON.stringify({candidates:Q.map((V)=>({petId:V.petIdHint,slugHint:v8(V.petIdHint)}))}),signal:AbortSignal.timeout(8000)});if(!J.ok)return q;let Y=await J.json();for(let V of Y.existing??[])if(V&&typeof V.slug==="string")q.set(V.slug,V)}catch{}return q}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(`
439
439
  `);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(`
440
440
  `);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(`
441
- `);return Q}async function s2(Q){try{return await y3(Q),!0}catch{return!1}}function S3(Q,$){if(typeof Q==="string"&&Q.trim())return Q.trim();return $}function t2(Q){return typeof Q==="string"&&Q.trim()?Q.trim():null}function g3(...Q){for(let $ of Q){let q=t2($);if(q)return q}return null}function _3(Q){let $=q0.replace(/\/+$/,""),q=Q.startsWith("/")?Q:`/${Q}`;return`${$}${q}`}function mF(Q){if(!Q)return null;if(Q.startsWith("http://")||Q.startsWith("https://"))return Q;return _3(Q)}function cF(Q){let $=g3(Q?.preferred_username,Q?.username)??(typeof Q?.sub==="string"?Q.sub.slice(-8).toLowerCase():null);return $?_3(`/u/${encodeURIComponent($.toLowerCase())}`):q0}function v8(Q){return Q.toLowerCase().trim().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,40)}function b3(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 q=Q[22],J=Q[23],Y=Q[24];return{width:((Q[21]|(q&63)<<8)>>>0)+1,height:((q>>6|J<<2|(Y&15)<<10)>>>0)+1}}if($==="VP8 "){for(let q=23;q<Math.min(60,Q.length-7);q++)if(Q[q]===157&&Q[q+1]===1&&Q[q+2]===42)return{width:(Q[q+3]|Q[q+4]<<8)&16383,height:(Q[q+5]|Q[q+6]<<8)&16383}}}return{width:0,height:0}}async function uF(Q){let $=Q[0];if(!$||$==="--help"||$==="-h"||$==="help"){E3();return}switch($){case"install":{let{installedAgents:q}=await gQ();if(q.length>0)C0("cli_hooks_install_success",{cli_version:u0,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":{pF($);break}case"uninstall":{let q=Q.includes("--remove-token");await G3({removeToken:q});break}case"refresh":{let{runRefresh:q}=await Promise.resolve().then(() => (fQ(),hQ)),J=await q();if(J.binaryPersisted)console.log(`${j.default.green("✓")} Snapshotted petdex binary at ${j.default.dim("~/.petdex/bin/petdex.js")}`);else if(J.binaryReason)console.log(`${j.default.yellow("!")} Binary snapshot skipped: ${J.binaryReason}`);for(let V of J.refreshed)console.log(`${j.default.green("✓")} Refreshed ${V}`);for(let{id:V,reason:X}of J.skipped){if(X==="not installed")continue;console.log(`${j.default.yellow("!")} Skipped ${V}: ${X}`)}let Y=J.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: ${$}`)),E3(),process.exit(1)}}function pF(Q){let $;if(Q==="toggle")$=HY();else if(Q==="on")$=A6("on");else if(Q==="off")$=A6("off");else $=T6();if($==="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 dF(){C0("cli_init_started",{cli_version:u0,os:process.platform,arch:process.arch});let Q=E0(),$=D3(Q),q=$,J=null;if(!$){console.log(j.default.dim(`${j.default.yellow("!")} No desktop app found. Installing Petdex Desktop...`)),console.log("");try{await TQ(),q=D3(E0())}catch(K){J=K.message,console.error(`${j.default.red("✗")} Could not install desktop: ${J}`),console.error(j.default.dim(" Continuing with hooks-only setup."))}}else{let K=Q.includes("/Petdex.app/Contents/MacOS/");console.log(`${j.default.green("●")} Desktop already installed at ${j.default.cyan(lF(Q))}${K?j.default.dim(" (DMG)"):j.default.dim(" (bare)")}`)}let Y=await CQ(),{installedAgents:V}=await gQ(),X=!1;if(q){let K=Q1();if(K.state==="running")X=!0,console.log(`${j.default.green("●")} Desktop already running (pid ${K.pid})`);else{let W=await k1();if(W.ok){if(X=!0,!W.alreadyRunning)C0("cli_desktop_start_success",{cli_version:u0});console.log(W.alreadyRunning?`${j.default.dim("•")} Desktop already running (pid ${W.pid})`:`${j.default.green("✓")} Desktop started (pid ${W.pid})`)}else console.log(`${j.default.yellow("!")} Could not start desktop: ${W.reason}`),console.log(j.default.dim(` Open ${j.default.cyan("/Applications/Petdex.app")} once manually, then re-run ${j.default.cyan("petdex up")}.`))}}if(console.log(""),console.log(j.default.bold("Setup summary")),console.log(q?`${j.default.green("✓")} Desktop installed${X?" and running":""}`:`${j.default.yellow("!")} Desktop not installed`),console.log(Y.status==="installed"?`${j.default.green("✓")} Starter pet installed: ${Y.slug}`:Y.status==="present"?`${j.default.green("✓")} Pet library ready`:`${j.default.yellow("!")} No starter pet installed`),console.log(V.length>0?`${j.default.green("✓")} Hooks installed for ${V.join(", ")}`:`${j.default.yellow("!")} No agent hooks installed`),J)console.log(j.default.dim(` Desktop install issue: ${J}`));if(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.`),console.log(j.default.dim(` Or from a shell: ${j.default.cyan("petdex up")} (force-wake) · ${j.default.cyan("petdex toggle")} (smart wake/sleep)`));else console.log(""),console.log(`${j.default.yellow("!")} Hooks-only setup finished. Desktop still needs a supported build for this platform.`),console.log(j.default.dim(` Try again later with ${j.default.cyan("petdex update")}.`))}function lF(Q){let $=process.env.HOME;if($&&Q.startsWith($))return`~${Q.slice($.length)}`;return Q}async function h3(){C0("cli_up_invoked",{cli_version:u0}),A6("on"),console.log(`${j.default.green("●")} Hooks ${j.default.bold("ENABLED")}`);let Q=Q1();if(Q.state==="running"){console.log(`${j.default.green("●")} Desktop already running (pid ${Q.pid})`);return}let $=await k1();if($.ok){if(!$.alreadyRunning)C0("cli_desktop_start_success",{cli_version:u0});console.log($.alreadyRunning?`${j.default.dim("•")} Desktop already running (pid ${$.pid})`:`${j.default.green("✓")} Desktop started (pid ${$.pid})`)}else console.log(`${j.default.yellow("!")} ${$.reason}`),console.log(j.default.dim(` Install the binary first: ${j.default.cyan("petdex install desktop")}`))}async function oF(){let Q=T6()==="on",$=Q1().state==="running";if(Q&&$)await f3();else await h3()}async function f3(){if(A6("off"),console.log(`${j.default.yellow("○")} Hooks ${j.default.bold("DISABLED")}`),Q1().state==="stopped"){console.log(`${j.default.dim("•")} Desktop wasn't running`);return}let $=await a1();if($.ok)console.log(`${j.default.green("✓")} Desktop stopped (pid ${$.pid})`);else console.log(`${j.default.dim("•")} ${$.reason}`)}function E3(){let Q=j.default.cyan,$=j.default.dim;console.log(["",` ${j.default.bold(j.default.magenta("petdex hooks"))}`,"",` ${Q("Usage")}`," petdex hooks <command>","",` ${Q("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`,"",` ${Q("Examples")}`,` ${$("$")} petdex hooks install`,` ${$("$")} petdex hooks toggle`,` ${$("$")} petdex hooks status`,""].join(`
442
- `))}async function iF(Q){let $=Q[0];if(!$||$==="--help"||$==="-h"||$==="help"){k3();return}switch($){case"start":await kY(),C0("cli_desktop_start_success",{cli_version:u0});break;case"stop":await yY();break;case"status":gY();break;default:console.error(j.default.red(`Unknown desktop command: ${$}`)),k3(),process.exit(1)}}function k3(){let Q=j.default.cyan,$=j.default.dim;console.log(["",` ${j.default.bold(j.default.magenta("petdex desktop"))}`,"",` ${Q("Usage")}`," petdex desktop <command>","",` ${Q("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`,"",` ${Q("Examples")}`,` ${$("$")} petdex desktop start`,` ${$("$")} petdex desktop status`,` ${$("$")} petdex desktop stop`,""].join(`
443
- `))}function nF(Q){let $=Q[0];if($==="on"||$==="off"){let q=$==="on";if(pY(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 ${$}\` again.`)),process.exit(1)}else if($==="status"||!$){let q=dY();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: ${$}`)),console.error("Use: petdex telemetry [on|off|status]"),process.exit(1)}
441
+ `);return Q}async function s2(Q){try{return await c3(Q),!0}catch{return!1}}function h3(Q,$){if(typeof Q==="string"&&Q.trim())return Q.trim();return $}function t2(Q){return typeof Q==="string"&&Q.trim()?Q.trim():null}function d3(...Q){for(let $ of Q){let q=t2($);if(q)return q}return null}function l3(Q){let $=$0.replace(/\/+$/,""),q=Q.startsWith("/")?Q:`/${Q}`;return`${$}${q}`}function aF(Q){if(!Q)return null;if(Q.startsWith("http://")||Q.startsWith("https://"))return Q;return l3(Q)}function sF(Q){let $=d3(Q?.preferred_username,Q?.username)??(typeof Q?.sub==="string"?Q.sub.slice(-8).toLowerCase():null);return $?l3(`/u/${encodeURIComponent($.toLowerCase())}`):$0}function v8(Q){return Q.toLowerCase().trim().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,40)}function o3(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 q=Q[22],J=Q[23],Y=Q[24];return{width:((Q[21]|(q&63)<<8)>>>0)+1,height:((q>>6|J<<2|(Y&15)<<10)>>>0)+1}}if($==="VP8 "){for(let q=23;q<Math.min(60,Q.length-7);q++)if(Q[q]===157&&Q[q+1]===1&&Q[q+2]===42)return{width:(Q[q+3]|Q[q+4]<<8)&16383,height:(Q[q+5]|Q[q+6]<<8)&16383}}}return{width:0,height:0}}async function tF(Q){let $=Q[0];if(!$||$==="--help"||$==="-h"||$==="help"){f3();return}switch($){case"install":{let{installedAgents:q}=await gQ();if(q.length>0)C0("cli_hooks_install_success",{cli_version:u0,agents:q}),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":{eF($);break}case"uninstall":{let q=Q.includes("--remove-token");await U3({removeToken:q});break}case"refresh":{let{runRefresh:q}=await Promise.resolve().then(() => (fQ(),hQ)),J=await q();if(J.binaryPersisted)console.log(`${Z.default.green("✓")} Snapshotted petdex binary at ${Z.default.dim("~/.petdex/bin/petdex.js")}`);else if(J.binaryReason)console.log(`${Z.default.yellow("!")} Binary snapshot skipped: ${J.binaryReason}`);for(let V of J.refreshed)console.log(`${Z.default.green("✓")} Refreshed ${V}`);for(let{id:V,reason:K}of J.skipped){if(K==="not installed")continue;console.log(`${Z.default.yellow("!")} Skipped ${V}: ${K}`)}let Y=J.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: ${$}`)),f3(),process.exit(1)}}function eF(Q){let $;if(Q==="toggle")$=zY();else if(Q==="on")$=A6("on");else if(Q==="off")$=A6("off");else $=T6();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 QL(){C0("cli_init_started",{cli_version:u0,os:process.platform,arch:process.arch});let Q=E0(),$=v3(Q),q=$,J=null;if(!$){console.log(Z.default.dim(`${Z.default.yellow("!")} No desktop app found. Installing Petdex Desktop...`)),console.log("");try{await TQ(),q=v3(E0())}catch(X){J=X.message,console.error(`${Z.default.red("✗")} Could not install desktop: ${J}`),console.error(Z.default.dim(" Continuing with hooks-only setup."))}}else{let X=Q.includes("/Petdex.app/Contents/MacOS/");console.log(`${Z.default.green("●")} Desktop already installed at ${Z.default.cyan($L(Q))}${X?Z.default.dim(" (DMG)"):Z.default.dim(" (bare)")}`)}let Y=await CQ(),{installedAgents:V}=await gQ(),K=!1;if(q){let X=Q1();if(X.state==="running")K=!0,console.log(`${Z.default.green("●")} Desktop already running (pid ${X.pid})`);else{let W=await k1();if(W.ok){if(K=!0,!W.alreadyRunning)C0("cli_desktop_start_success",{cli_version:u0});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(q?`${Z.default.green("✓")} Desktop installed${K?" 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`),J)console.log(Z.default.dim(` Desktop install issue: ${J}`));if(q)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 $L(Q){let $=process.env.HOME;if($&&Q.startsWith($))return`~${Q.slice($.length)}`;return Q}async function i3(){C0("cli_up_invoked",{cli_version:u0}),A6("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 k1();if($.ok){if(!$.alreadyRunning)C0("cli_desktop_start_success",{cli_version:u0});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 qL(){let Q=T6()==="on",$=Q1().state==="running";if(Q&&$)await n3();else await i3()}async function n3(){if(A6("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 a1();if($.ok)console.log(`${Z.default.green("✓")} Desktop stopped (pid ${$.pid})`);else console.log(`${Z.default.dim("•")} ${$.reason}`)}function f3(){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(`
442
+ `))}async function JL(Q){let $=Q[0];if(!$||$==="--help"||$==="-h"||$==="help"){m3();return}switch($){case"start":await bY(),C0("cli_desktop_start_success",{cli_version:u0});break;case"stop":await hY();break;case"status":fY();break;default:console.error(Z.default.red(`Unknown desktop command: ${$}`)),m3(),process.exit(1)}}function m3(){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(`
443
+ `))}function YL(Q){let $=Q[0];if($==="on"||$==="off"){let q=$==="on";if(iY(q))console.log(q?"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 q=nY();if(console.log(`Status: ${q.enabled?"enabled":"disabled"}`),q.install_id)console.log(`Install ID: ${q.install_id}`)}else console.error(Z.default.red(`Unknown telemetry subcommand: ${$}`)),console.error("Use: petdex telemetry [on|off|status]"),process.exit(1)}