@innovatorved/code-lab 0.7.1 → 0.7.2

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 (71) hide show
  1. package/ARCHITECTURE.md +2 -2
  2. package/CHANGELOG.md +10 -0
  3. package/README.md +5 -5
  4. package/dist/code-lab-sql.esm.js +2 -2
  5. package/dist/code-lab-sql.umd.js +3 -3
  6. package/dist/code-lab.css +1 -1
  7. package/dist/code-lab.d.ts +47 -38
  8. package/dist/code-lab.esm.js +918 -884
  9. package/dist/code-lab.js +917 -881
  10. package/dist/extensions/cpp.esm.js +33 -33
  11. package/dist/extensions/cpp.js +33 -33
  12. package/dist/extensions/python.esm.js +79 -49
  13. package/dist/extensions/python.js +79 -49
  14. package/dist/index.d.ts +1 -1
  15. package/dist/logger.d.ts +4 -20
  16. package/dist/modular-kernel.d.ts +0 -1
  17. package/dist/packages/core/src/errors.d.ts +5 -1
  18. package/dist/packages/fs/src/backends.d.ts +0 -27
  19. package/dist/packages/fs/src/index.d.ts +1 -1
  20. package/dist/packages/ui/src/html.d.ts +1 -0
  21. package/dist/packages/ui/src/index.d.ts +1 -0
  22. package/dist/{apps/web/src/index.d.ts → packages/ui/src/kernel.d.ts} +3 -2
  23. package/dist/packages/ui/src/observability.d.ts +1 -1
  24. package/dist/packages/ui/src/settings-dialog.d.ts +0 -1
  25. package/dist/preview-sw.js +1 -1
  26. package/dist/runtime.d.ts +3 -0
  27. package/dist/runtime.esm.js +2 -2
  28. package/dist/runtime.js +2 -2
  29. package/dist/schemas.d.ts +1 -1
  30. package/dist/shell.esm.js +277 -285
  31. package/dist/shell.js +277 -285
  32. package/dist/terminal.esm.js +2 -2
  33. package/dist/terminal.js +2 -2
  34. package/dist/workbench/editor.d.ts +0 -4
  35. package/dist/workbench/index.d.ts +0 -2
  36. package/dist/workbench/intellisense.d.ts +0 -1
  37. package/dist/workbench/xterm-adapter.d.ts +0 -1
  38. package/package.json +2 -4
  39. package/src/code-lab.css +0 -8086
  40. package/src/csp.ts +0 -590
  41. package/src/diagnostics.ts +0 -287
  42. package/src/extensions/cpp.ts +0 -2371
  43. package/src/extensions/guided-lab.ts +0 -68
  44. package/src/extensions/javascript.ts +0 -54
  45. package/src/extensions/python.ts +0 -1743
  46. package/src/extensions/typescript.ts +0 -85
  47. package/src/extensions/umbrella.ts +0 -5
  48. package/src/html.ts +0 -88
  49. package/src/index.ts +0 -129
  50. package/src/logger.ts +0 -139
  51. package/src/modular-kernel.ts +0 -7
  52. package/src/preview-sw.js +0 -296
  53. package/src/runtime/test-harness.ts +0 -57
  54. package/src/runtime.ts +0 -10565
  55. package/src/sample.html +0 -304
  56. package/src/schemas.ts +0 -366
  57. package/src/scm.ts +0 -2453
  58. package/src/search.ts +0 -433
  59. package/src/shell.ts +0 -10990
  60. package/src/storage.ts +0 -773
  61. package/src/terminal.ts +0 -1402
  62. package/src/workbench/command-palette.ts +0 -101
  63. package/src/workbench/diff-editor.ts +0 -472
  64. package/src/workbench/editor.ts +0 -49
  65. package/src/workbench/icons.ts +0 -255
  66. package/src/workbench/index.ts +0 -29
  67. package/src/workbench/intellisense.ts +0 -1884
  68. package/src/workbench/share.ts +0 -128
  69. package/src/workbench/xterm-adapter.ts +0 -1571
  70. package/src/workbench.ts +0 -21825
  71. package/src/zip.ts +0 -348
package/dist/shell.esm.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * ============================================================
3
- * @innovatorved/code-lab v0.7.1 — Standalone Browser Code IDE & Virtual Runtime
3
+ * @innovatorved/code-lab v0.7.2 — Standalone Browser Code IDE & Virtual Runtime
4
4
  * ============================================================
5
5
  * Features:
6
6
  * - Sandboxed Web Worker Execution Engine with Multi-Instance Isolation & Watchdog Timer
@@ -15,14 +15,14 @@
15
15
  * ============================================================
16
16
  */
17
17
  const _root = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : {};
18
- var CodeLabLogger=(()=>{var s=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var x=Object.prototype.hasOwnProperty;var y=(o,n)=>{for(var a in n)s(o,a,{get:n[a],enumerable:!0})},v=(o,n,a,t)=>{if(n&&typeof n=="object"||typeof n=="function")for(let e of C(n))!x.call(o,e)&&e!==a&&s(o,e,{get:()=>n[e],enumerable:!(t=p(n,e))||t.enumerable});return o};var O=o=>v(s({},"__esModule",{value:!0}),o);var h={};y(h,{CodeLabError:()=>d,DEFAULT_LOGGER:()=>w,LOG_PREFIX:()=>c,createLogger:()=>g,default:()=>_,isCodeLabError:()=>f});var c="[code-lab]",d=class extends Error{code;options;cause;recoverable;details;context;constructor(n,a,t={}){super(a),this.name="CodeLabError",this.code=n,this.options=t,this.cause=t.cause,this.recoverable=t.recoverable!==!1;let e=t.details??t.context;e!==void 0&&(this.details=e,this.context=e),Object.setPrototypeOf(this,new.target.prototype)}};function f(o){return!!(o&&typeof o=="object"&&(o instanceof d||o.name==="CodeLabError"&&typeof o.code=="string"))}function g(o={}){let n=o.logger??null,a=o.debug===!0,t=o.prefix||c,e=(r,b)=>{if(r==="debug"&&!a)return;if(n&&typeof n[r]=="function"){let L=null;try{n[r](...b);return}catch(k){L=k}}let i=typeof console<"u"?console:null,l=i?i[r]:null;typeof l=="function"&&l.call(i,t,...b)};return{debug:(...r)=>e("debug",r),info:(...r)=>e("info",r),warn:(...r)=>e("warn",r),error:(...r)=>e("error",r)}}var w=g(),E={LOG_PREFIX:c,CodeLabError:d,isCodeLabError:f,createLogger:g,DEFAULT_LOGGER:w},u=typeof globalThis<"u"?globalThis:null;u&&!u.CodeLabLogger&&(u.CodeLabLogger=E);var _=E;return O(h);})();
18
+ var CodeLabLogger=(()=>{var d=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var w=Object.prototype.hasOwnProperty;var k=(e,n)=>{for(var i in n)d(e,i,{get:n[i],enumerable:!0})},m=(e,n,i,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of R(n))!w.call(e,o)&&o!==i&&d(e,o,{get:()=>n[o],enumerable:!(r=y(n,o))||r.enumerable});return e};var _=e=>m(d({},"__esModule",{value:!0}),e);var h={};k(h,{CodeLabError:()=>s,DEFAULT_LOGGER:()=>f,LOG_PREFIX:()=>a,createLogger:()=>c,default:()=>C,isCodeLabError:()=>g});var s=class extends Error{code;options;cause;context;details;recoverable;constructor(n,i,r={}){super(i,r.cause!==void 0?{cause:r.cause}:void 0),this.name="CodeLabError",this.code=n,this.options=r,this.cause=r.cause,this.recoverable=r.recoverable!==!1;let o=r.details??r.context;this.context=Object.freeze({...o??{}}),o!==void 0&&(this.details=this.context),Object.setPrototypeOf(this,new.target.prototype)}};function g(e){return e instanceof s||typeof e=="object"&&e!==null&&e.name==="CodeLabError"&&typeof e.code=="string"}var a="[code-lab]";function c(e={}){let n=e.logger??null,i=e.debug===!0,r=e.prefix||a,o=(t,L)=>{if(t==="debug"&&!i)return;if(n&&typeof n[t]=="function"){let b=null;try{n[t](...L);return}catch(v){b=v}}let l=typeof console<"u"?console:null,E=l?l[t]:null;typeof E=="function"&&E.call(l,r,...L)};return{debug:(...t)=>o("debug",t),info:(...t)=>o("info",t),warn:(...t)=>o("warn",t),error:(...t)=>o("error",t)}}var f=c(),p={LOG_PREFIX:a,CodeLabError:s,isCodeLabError:g,createLogger:c,DEFAULT_LOGGER:f},u=typeof globalThis<"u"?globalThis:null;u&&!u.CodeLabLogger&&(u.CodeLabLogger=p);var C=p;return _(h);})();
19
19
 
20
- var CodeLabScm=(()=>{var nd=Object.create;var Or=Object.defineProperty;var id=Object.getOwnPropertyDescriptor;var ad=Object.getOwnPropertyNames;var od=Object.getPrototypeOf,sd=Object.prototype.hasOwnProperty;var O=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(r){throw e=0,r}},cd=(t,e)=>{for(var r in e)Or(t,r,{get:e[r],enumerable:!0})},ao=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of ad(e))!sd.call(t,i)&&i!==r&&Or(t,i,{get:()=>e[i],enumerable:!(n=id(e,i))||n.enumerable});return t};var At=(t,e,r)=>(r=t!=null?nd(od(t)):{},ao(e||!t||!t.__esModule?Or(r,"default",{value:t,enumerable:!0}):r,t)),fd=t=>ao(Or({},"__esModule",{value:!0}),t);var co=O(Br=>{"use strict";Br.byteLength=ud;Br.toByteArray=hd;Br.fromByteArray=md;var wt=[],nt=[],ld=typeof Uint8Array<"u"?Uint8Array:Array,Bn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(Xt=0,oo=Bn.length;Xt<oo;++Xt)wt[Xt]=Bn[Xt],nt[Bn.charCodeAt(Xt)]=Xt;var Xt,oo;nt[45]=62;nt[95]=63;function so(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");r===-1&&(r=e);var n=r===e?0:4-r%4;return[r,n]}function ud(t){var e=so(t),r=e[0],n=e[1];return(r+n)*3/4-n}function dd(t,e,r){return(e+r)*3/4-r}function hd(t){var e,r=so(t),n=r[0],i=r[1],a=new ld(dd(t,n,i)),o=0,s=i>0?n-4:n,c;for(c=0;c<s;c+=4)e=nt[t.charCodeAt(c)]<<18|nt[t.charCodeAt(c+1)]<<12|nt[t.charCodeAt(c+2)]<<6|nt[t.charCodeAt(c+3)],a[o++]=e>>16&255,a[o++]=e>>8&255,a[o++]=e&255;return i===2&&(e=nt[t.charCodeAt(c)]<<2|nt[t.charCodeAt(c+1)]>>4,a[o++]=e&255),i===1&&(e=nt[t.charCodeAt(c)]<<10|nt[t.charCodeAt(c+1)]<<4|nt[t.charCodeAt(c+2)]>>2,a[o++]=e>>8&255,a[o++]=e&255),a}function pd(t){return wt[t>>18&63]+wt[t>>12&63]+wt[t>>6&63]+wt[t&63]}function wd(t,e,r){for(var n,i=[],a=e;a<r;a+=3)n=(t[a]<<16&16711680)+(t[a+1]<<8&65280)+(t[a+2]&255),i.push(pd(n));return i.join("")}function md(t){for(var e,r=t.length,n=r%3,i=[],a=16383,o=0,s=r-n;o<s;o+=a)i.push(wd(t,o,o+a>s?s:o+a));return n===1?(e=t[r-1],i.push(wt[e>>2]+wt[e<<4&63]+"==")):n===2&&(e=(t[r-2]<<8)+t[r-1],i.push(wt[e>>10]+wt[e>>4&63]+wt[e<<2&63]+"=")),i.join("")}});var fo=O(In=>{In.read=function(t,e,r,n,i){var a,o,s=i*8-n-1,c=(1<<s)-1,f=c>>1,l=-7,u=r?i-1:0,d=r?-1:1,h=t[e+u];for(u+=d,a=h&(1<<-l)-1,h>>=-l,l+=s;l>0;a=a*256+t[e+u],u+=d,l-=8);for(o=a&(1<<-l)-1,a>>=-l,l+=n;l>0;o=o*256+t[e+u],u+=d,l-=8);if(a===0)a=1-f;else{if(a===c)return o?NaN:(h?-1:1)*(1/0);o=o+Math.pow(2,n),a=a-f}return(h?-1:1)*o*Math.pow(2,a-n)};In.write=function(t,e,r,n,i,a){var o,s,c,f=a*8-i-1,l=(1<<f)-1,u=l>>1,d=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,h=n?0:a-1,p=n?1:-1,w=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,o=l):(o=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-o))<1&&(o--,c*=2),o+u>=1?e+=d/c:e+=d*Math.pow(2,1-u),e*c>=2&&(o++,c/=2),o+u>=l?(s=0,o=l):o+u>=1?(s=(e*c-1)*Math.pow(2,i),o=o+u):(s=e*Math.pow(2,u-1)*Math.pow(2,i),o=0));i>=8;t[r+h]=s&255,h+=p,s/=256,i-=8);for(o=o<<i|s,f+=i;f>0;t[r+h]=o&255,h+=p,o/=256,f-=8);t[r+h-p]|=w*128}});var Mn=O(de=>{"use strict";var Tn=co(),le=fo(),lo=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;de.Buffer=v;de.SlowBuffer=xd;de.INSPECT_MAX_BYTES=50;var Ir=2147483647;de.kMaxLength=Ir;v.TYPED_ARRAY_SUPPORT=gd();!v.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function gd(){try{let t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),t.foo()===42}catch{return!1}}Object.defineProperty(v.prototype,"parent",{enumerable:!0,get:function(){if(v.isBuffer(this))return this.buffer}});Object.defineProperty(v.prototype,"offset",{enumerable:!0,get:function(){if(v.isBuffer(this))return this.byteOffset}});function $t(t){if(t>Ir)throw new RangeError('The value "'+t+'" is invalid for option "size"');let e=new Uint8Array(t);return Object.setPrototypeOf(e,v.prototype),e}function v(t,e,r){if(typeof t=="number"){if(typeof e=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return Dn(t)}return wo(t,e,r)}v.poolSize=8192;function wo(t,e,r){if(typeof t=="string")return bd(t,e);if(ArrayBuffer.isView(t))return _d(t);if(t==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(mt(t,ArrayBuffer)||t&&mt(t.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(mt(t,SharedArrayBuffer)||t&&mt(t.buffer,SharedArrayBuffer)))return Fn(t,e,r);if(typeof t=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let n=t.valueOf&&t.valueOf();if(n!=null&&n!==t)return v.from(n,e,r);let i=vd(t);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof t[Symbol.toPrimitive]=="function")return v.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}v.from=function(t,e,r){return wo(t,e,r)};Object.setPrototypeOf(v.prototype,Uint8Array.prototype);Object.setPrototypeOf(v,Uint8Array);function mo(t){if(typeof t!="number")throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function yd(t,e,r){return mo(t),t<=0?$t(t):e!==void 0?typeof r=="string"?$t(t).fill(e,r):$t(t).fill(e):$t(t)}v.alloc=function(t,e,r){return yd(t,e,r)};function Dn(t){return mo(t),$t(t<0?0:Nn(t)|0)}v.allocUnsafe=function(t){return Dn(t)};v.allocUnsafeSlow=function(t){return Dn(t)};function bd(t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!v.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let r=go(t,e)|0,n=$t(r),i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}function Cn(t){let e=t.length<0?0:Nn(t.length)|0,r=$t(e);for(let n=0;n<e;n+=1)r[n]=t[n]&255;return r}function _d(t){if(mt(t,Uint8Array)){let e=new Uint8Array(t);return Fn(e.buffer,e.byteOffset,e.byteLength)}return Cn(t)}function Fn(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return e===void 0&&r===void 0?n=new Uint8Array(t):r===void 0?n=new Uint8Array(t,e):n=new Uint8Array(t,e,r),Object.setPrototypeOf(n,v.prototype),n}function vd(t){if(v.isBuffer(t)){let e=Nn(t.length)|0,r=$t(e);return r.length===0||t.copy(r,0,0,e),r}if(t.length!==void 0)return typeof t.length!="number"||jn(t.length)?$t(0):Cn(t);if(t.type==="Buffer"&&Array.isArray(t.data))return Cn(t.data)}function Nn(t){if(t>=Ir)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Ir.toString(16)+" bytes");return t|0}function xd(t){return+t!=t&&(t=0),v.alloc(+t)}v.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==v.prototype};v.compare=function(e,r){if(mt(e,Uint8Array)&&(e=v.from(e,e.offset,e.byteLength)),mt(r,Uint8Array)&&(r=v.from(r,r.offset,r.byteLength)),!v.isBuffer(e)||!v.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===r)return 0;let n=e.length,i=r.length;for(let a=0,o=Math.min(n,i);a<o;++a)if(e[a]!==r[a]){n=e[a],i=r[a];break}return n<i?-1:i<n?1:0};v.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};v.concat=function(e,r){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return v.alloc(0);let n;if(r===void 0)for(r=0,n=0;n<e.length;++n)r+=e[n].length;let i=v.allocUnsafe(r),a=0;for(n=0;n<e.length;++n){let o=e[n];if(mt(o,Uint8Array))a+o.length>i.length?(v.isBuffer(o)||(o=v.from(o)),o.copy(i,a)):Uint8Array.prototype.set.call(i,o,a);else if(v.isBuffer(o))o.copy(i,a);else throw new TypeError('"list" argument must be an Array of Buffers');a+=o.length}return i};function go(t,e){if(v.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||mt(t,ArrayBuffer))return t.byteLength;if(typeof t!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);let r=t.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&r===0)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return Pn(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return Ao(t).length;default:if(i)return n?-1:Pn(t).length;e=(""+e).toLowerCase(),i=!0}}v.byteLength=go;function Ed(t,e,r){let n=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((r===void 0||r>this.length)&&(r=this.length),r<=0)||(r>>>=0,e>>>=0,r<=e))return"";for(t||(t="utf8");;)switch(t){case"hex":return Cd(this,e,r);case"utf8":case"utf-8":return bo(this,e,r);case"ascii":return Id(this,e,r);case"latin1":case"binary":return Td(this,e,r);case"base64":return Od(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Fd(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}v.prototype._isBuffer=!0;function Yt(t,e,r){let n=t[e];t[e]=t[r],t[r]=n}v.prototype.swap16=function(){let e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let r=0;r<e;r+=2)Yt(this,r,r+1);return this};v.prototype.swap32=function(){let e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let r=0;r<e;r+=4)Yt(this,r,r+3),Yt(this,r+1,r+2);return this};v.prototype.swap64=function(){let e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let r=0;r<e;r+=8)Yt(this,r,r+7),Yt(this,r+1,r+6),Yt(this,r+2,r+5),Yt(this,r+3,r+4);return this};v.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?bo(this,0,e):Ed.apply(this,arguments)};v.prototype.toLocaleString=v.prototype.toString;v.prototype.equals=function(e){if(!v.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:v.compare(this,e)===0};v.prototype.inspect=function(){let e="",r=de.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"};lo&&(v.prototype[lo]=v.prototype.inspect);v.prototype.compare=function(e,r,n,i,a){if(mt(e,Uint8Array)&&(e=v.from(e,e.offset,e.byteLength)),!v.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(r===void 0&&(r=0),n===void 0&&(n=e?e.length:0),i===void 0&&(i=0),a===void 0&&(a=this.length),r<0||n>e.length||i<0||a>this.length)throw new RangeError("out of range index");if(i>=a&&r>=n)return 0;if(i>=a)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,i>>>=0,a>>>=0,this===e)return 0;let o=a-i,s=n-r,c=Math.min(o,s),f=this.slice(i,a),l=e.slice(r,n);for(let u=0;u<c;++u)if(f[u]!==l[u]){o=f[u],s=l[u];break}return o<s?-1:s<o?1:0};function yo(t,e,r,n,i){if(t.length===0)return-1;if(typeof r=="string"?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,jn(r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0)if(i)r=0;else return-1;if(typeof e=="string"&&(e=v.from(e,n)),v.isBuffer(e))return e.length===0?-1:uo(t,e,r,n,i);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):uo(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function uo(t,e,r,n,i){let a=1,o=t.length,s=e.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(t.length<2||e.length<2)return-1;a=2,o/=2,s/=2,r/=2}function c(l,u){return a===1?l[u]:l.readUInt16BE(u*a)}let f;if(i){let l=-1;for(f=r;f<o;f++)if(c(t,f)===c(e,l===-1?0:f-l)){if(l===-1&&(l=f),f-l+1===s)return l*a}else l!==-1&&(f-=f-l),l=-1}else for(r+s>o&&(r=o-s),f=r;f>=0;f--){let l=!0;for(let u=0;u<s;u++)if(c(t,f+u)!==c(e,u)){l=!1;break}if(l)return f}return-1}v.prototype.includes=function(e,r,n){return this.indexOf(e,r,n)!==-1};v.prototype.indexOf=function(e,r,n){return yo(this,e,r,n,!0)};v.prototype.lastIndexOf=function(e,r,n){return yo(this,e,r,n,!1)};function kd(t,e,r,n){r=Number(r)||0;let i=t.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;let a=e.length;n>a/2&&(n=a/2);let o;for(o=0;o<n;++o){let s=parseInt(e.substr(o*2,2),16);if(jn(s))return o;t[r+o]=s}return o}function Sd(t,e,r,n){return Tr(Pn(e,t.length-r),t,r,n)}function Ad(t,e,r,n){return Tr(Ud(e),t,r,n)}function $d(t,e,r,n){return Tr(Ao(e),t,r,n)}function Rd(t,e,r,n){return Tr(jd(e,t.length-r),t,r,n)}v.prototype.write=function(e,r,n,i){if(r===void 0)i="utf8",n=this.length,r=0;else if(n===void 0&&typeof r=="string")i=r,n=this.length,r=0;else if(isFinite(r))r=r>>>0,isFinite(n)?(n=n>>>0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let a=this.length-r;if((n===void 0||n>a)&&(n=a),e.length>0&&(n<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let o=!1;for(;;)switch(i){case"hex":return kd(this,e,r,n);case"utf8":case"utf-8":return Sd(this,e,r,n);case"ascii":case"latin1":case"binary":return Ad(this,e,r,n);case"base64":return $d(this,e,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Rd(this,e,r,n);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}};v.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Od(t,e,r){return e===0&&r===t.length?Tn.fromByteArray(t):Tn.fromByteArray(t.slice(e,r))}function bo(t,e,r){r=Math.min(t.length,r);let n=[],i=e;for(;i<r;){let a=t[i],o=null,s=a>239?4:a>223?3:a>191?2:1;if(i+s<=r){let c,f,l,u;switch(s){case 1:a<128&&(o=a);break;case 2:c=t[i+1],(c&192)===128&&(u=(a&31)<<6|c&63,u>127&&(o=u));break;case 3:c=t[i+1],f=t[i+2],(c&192)===128&&(f&192)===128&&(u=(a&15)<<12|(c&63)<<6|f&63,u>2047&&(u<55296||u>57343)&&(o=u));break;case 4:c=t[i+1],f=t[i+2],l=t[i+3],(c&192)===128&&(f&192)===128&&(l&192)===128&&(u=(a&15)<<18|(c&63)<<12|(f&63)<<6|l&63,u>65535&&u<1114112&&(o=u))}}o===null?(o=65533,s=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|o&1023),n.push(o),i+=s}return Bd(n)}var ho=4096;function Bd(t){let e=t.length;if(e<=ho)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=ho));return r}function Id(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]&127);return n}function Td(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function Cd(t,e,r){let n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);let i="";for(let a=e;a<r;++a)i+=Md[t[a]];return i}function Fd(t,e,r){let n=t.slice(e,r),i="";for(let a=0;a<n.length-1;a+=2)i+=String.fromCharCode(n[a]+n[a+1]*256);return i}v.prototype.slice=function(e,r){let n=this.length;e=~~e,r=r===void 0?n:~~r,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),r<e&&(r=e);let i=this.subarray(e,r);return Object.setPrototypeOf(i,v.prototype),i};function H(t,e,r){if(t%1!==0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}v.prototype.readUintLE=v.prototype.readUIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||H(e,r,this.length);let i=this[e],a=1,o=0;for(;++o<r&&(a*=256);)i+=this[e+o]*a;return i};v.prototype.readUintBE=v.prototype.readUIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||H(e,r,this.length);let i=this[e+--r],a=1;for(;r>0&&(a*=256);)i+=this[e+--r]*a;return i};v.prototype.readUint8=v.prototype.readUInt8=function(e,r){return e=e>>>0,r||H(e,1,this.length),this[e]};v.prototype.readUint16LE=v.prototype.readUInt16LE=function(e,r){return e=e>>>0,r||H(e,2,this.length),this[e]|this[e+1]<<8};v.prototype.readUint16BE=v.prototype.readUInt16BE=function(e,r){return e=e>>>0,r||H(e,2,this.length),this[e]<<8|this[e+1]};v.prototype.readUint32LE=v.prototype.readUInt32LE=function(e,r){return e=e>>>0,r||H(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};v.prototype.readUint32BE=v.prototype.readUInt32BE=function(e,r){return e=e>>>0,r||H(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};v.prototype.readBigUInt64LE=Ut(function(e){e=e>>>0,ue(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Le(e,this.length-8);let i=r+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,a=this[++e]+this[++e]*2**8+this[++e]*2**16+n*2**24;return BigInt(i)+(BigInt(a)<<BigInt(32))});v.prototype.readBigUInt64BE=Ut(function(e){e=e>>>0,ue(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Le(e,this.length-8);let i=r*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],a=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n;return(BigInt(i)<<BigInt(32))+BigInt(a)});v.prototype.readIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||H(e,r,this.length);let i=this[e],a=1,o=0;for(;++o<r&&(a*=256);)i+=this[e+o]*a;return a*=128,i>=a&&(i-=Math.pow(2,8*r)),i};v.prototype.readIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||H(e,r,this.length);let i=r,a=1,o=this[e+--i];for(;i>0&&(a*=256);)o+=this[e+--i]*a;return a*=128,o>=a&&(o-=Math.pow(2,8*r)),o};v.prototype.readInt8=function(e,r){return e=e>>>0,r||H(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};v.prototype.readInt16LE=function(e,r){e=e>>>0,r||H(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n};v.prototype.readInt16BE=function(e,r){e=e>>>0,r||H(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n};v.prototype.readInt32LE=function(e,r){return e=e>>>0,r||H(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};v.prototype.readInt32BE=function(e,r){return e=e>>>0,r||H(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};v.prototype.readBigInt64LE=Ut(function(e){e=e>>>0,ue(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Le(e,this.length-8);let i=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(n<<24);return(BigInt(i)<<BigInt(32))+BigInt(r+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)});v.prototype.readBigInt64BE=Ut(function(e){e=e>>>0,ue(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Le(e,this.length-8);let i=(r<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(i)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n)});v.prototype.readFloatLE=function(e,r){return e=e>>>0,r||H(e,4,this.length),le.read(this,e,!0,23,4)};v.prototype.readFloatBE=function(e,r){return e=e>>>0,r||H(e,4,this.length),le.read(this,e,!1,23,4)};v.prototype.readDoubleLE=function(e,r){return e=e>>>0,r||H(e,8,this.length),le.read(this,e,!0,52,8)};v.prototype.readDoubleBE=function(e,r){return e=e>>>0,r||H(e,8,this.length),le.read(this,e,!1,52,8)};function J(t,e,r,n,i,a){if(!v.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<a)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}v.prototype.writeUintLE=v.prototype.writeUIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,n=n>>>0,!i){let s=Math.pow(2,8*n)-1;J(this,e,r,n,s,0)}let a=1,o=0;for(this[r]=e&255;++o<n&&(a*=256);)this[r+o]=e/a&255;return r+n};v.prototype.writeUintBE=v.prototype.writeUIntBE=function(e,r,n,i){if(e=+e,r=r>>>0,n=n>>>0,!i){let s=Math.pow(2,8*n)-1;J(this,e,r,n,s,0)}let a=n-1,o=1;for(this[r+a]=e&255;--a>=0&&(o*=256);)this[r+a]=e/o&255;return r+n};v.prototype.writeUint8=v.prototype.writeUInt8=function(e,r,n){return e=+e,r=r>>>0,n||J(this,e,r,1,255,0),this[r]=e&255,r+1};v.prototype.writeUint16LE=v.prototype.writeUInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||J(this,e,r,2,65535,0),this[r]=e&255,this[r+1]=e>>>8,r+2};v.prototype.writeUint16BE=v.prototype.writeUInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||J(this,e,r,2,65535,0),this[r]=e>>>8,this[r+1]=e&255,r+2};v.prototype.writeUint32LE=v.prototype.writeUInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||J(this,e,r,4,4294967295,0),this[r+3]=e>>>24,this[r+2]=e>>>16,this[r+1]=e>>>8,this[r]=e&255,r+4};v.prototype.writeUint32BE=v.prototype.writeUInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||J(this,e,r,4,4294967295,0),this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e&255,r+4};function _o(t,e,r,n,i){So(e,n,i,t,r,7);let a=Number(e&BigInt(4294967295));t[r++]=a,a=a>>8,t[r++]=a,a=a>>8,t[r++]=a,a=a>>8,t[r++]=a;let o=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=o,o=o>>8,t[r++]=o,o=o>>8,t[r++]=o,o=o>>8,t[r++]=o,r}function vo(t,e,r,n,i){So(e,n,i,t,r,7);let a=Number(e&BigInt(4294967295));t[r+7]=a,a=a>>8,t[r+6]=a,a=a>>8,t[r+5]=a,a=a>>8,t[r+4]=a;let o=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=o,o=o>>8,t[r+2]=o,o=o>>8,t[r+1]=o,o=o>>8,t[r]=o,r+8}v.prototype.writeBigUInt64LE=Ut(function(e,r=0){return _o(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});v.prototype.writeBigUInt64BE=Ut(function(e,r=0){return vo(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});v.prototype.writeIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){let c=Math.pow(2,8*n-1);J(this,e,r,n,c-1,-c)}let a=0,o=1,s=0;for(this[r]=e&255;++a<n&&(o*=256);)e<0&&s===0&&this[r+a-1]!==0&&(s=1),this[r+a]=(e/o>>0)-s&255;return r+n};v.prototype.writeIntBE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){let c=Math.pow(2,8*n-1);J(this,e,r,n,c-1,-c)}let a=n-1,o=1,s=0;for(this[r+a]=e&255;--a>=0&&(o*=256);)e<0&&s===0&&this[r+a+1]!==0&&(s=1),this[r+a]=(e/o>>0)-s&255;return r+n};v.prototype.writeInt8=function(e,r,n){return e=+e,r=r>>>0,n||J(this,e,r,1,127,-128),e<0&&(e=255+e+1),this[r]=e&255,r+1};v.prototype.writeInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||J(this,e,r,2,32767,-32768),this[r]=e&255,this[r+1]=e>>>8,r+2};v.prototype.writeInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||J(this,e,r,2,32767,-32768),this[r]=e>>>8,this[r+1]=e&255,r+2};v.prototype.writeInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||J(this,e,r,4,2147483647,-2147483648),this[r]=e&255,this[r+1]=e>>>8,this[r+2]=e>>>16,this[r+3]=e>>>24,r+4};v.prototype.writeInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||J(this,e,r,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e&255,r+4};v.prototype.writeBigInt64LE=Ut(function(e,r=0){return _o(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});v.prototype.writeBigInt64BE=Ut(function(e,r=0){return vo(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function xo(t,e,r,n,i,a){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function Eo(t,e,r,n,i){return e=+e,r=r>>>0,i||xo(t,e,r,4,34028234663852886e22,-34028234663852886e22),le.write(t,e,r,n,23,4),r+4}v.prototype.writeFloatLE=function(e,r,n){return Eo(this,e,r,!0,n)};v.prototype.writeFloatBE=function(e,r,n){return Eo(this,e,r,!1,n)};function ko(t,e,r,n,i){return e=+e,r=r>>>0,i||xo(t,e,r,8,17976931348623157e292,-17976931348623157e292),le.write(t,e,r,n,52,8),r+8}v.prototype.writeDoubleLE=function(e,r,n){return ko(this,e,r,!0,n)};v.prototype.writeDoubleBE=function(e,r,n){return ko(this,e,r,!1,n)};v.prototype.copy=function(e,r,n,i){if(!v.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),!i&&i!==0&&(i=this.length),r>=e.length&&(r=e.length),r||(r=0),i>0&&i<n&&(i=n),i===n||e.length===0||this.length===0)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-r<i-n&&(i=e.length-r+n);let a=i-n;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(r,n,i):Uint8Array.prototype.set.call(e,this.subarray(n,i),r),a};v.prototype.fill=function(e,r,n,i){if(typeof e=="string"){if(typeof r=="string"?(i=r,r=0,n=this.length):typeof n=="string"&&(i=n,n=this.length),i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!v.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(e.length===1){let o=e.charCodeAt(0);(i==="utf8"&&o<128||i==="latin1")&&(e=o)}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(r<0||this.length<r||this.length<n)throw new RangeError("Out of range index");if(n<=r)return this;r=r>>>0,n=n===void 0?this.length:n>>>0,e||(e=0);let a;if(typeof e=="number")for(a=r;a<n;++a)this[a]=e;else{let o=v.isBuffer(e)?e:v.from(e,i),s=o.length;if(s===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(a=0;a<n-r;++a)this[a+r]=o[a%s]}return this};var fe={};function Un(t,e,r){fe[t]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,this.stack,delete this.name}get code(){return t}set code(i){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:i,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}Un("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);Un("ERR_INVALID_ARG_TYPE",function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError);Un("ERR_OUT_OF_RANGE",function(t,e,r){let n=`The value of "${t}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=po(String(r)):typeof r=="bigint"&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=po(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n},RangeError);function po(t){let e="",r=t.length,n=t[0]==="-"?1:0;for(;r>=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function Pd(t,e,r){ue(e,"offset"),(t[e]===void 0||t[e+r]===void 0)&&Le(e,t.length-(r+1))}function So(t,e,r,n,i,a){if(t>r||t<e){let o=typeof e=="bigint"?"n":"",s;throw a>3?e===0||e===BigInt(0)?s=`>= 0${o} and < 2${o} ** ${(a+1)*8}${o}`:s=`>= -(2${o} ** ${(a+1)*8-1}${o}) and < 2 ** ${(a+1)*8-1}${o}`:s=`>= ${e}${o} and <= ${r}${o}`,new fe.ERR_OUT_OF_RANGE("value",s,t)}Pd(n,i,a)}function ue(t,e){if(typeof t!="number")throw new fe.ERR_INVALID_ARG_TYPE(e,"number",t)}function Le(t,e,r){throw Math.floor(t)!==t?(ue(t,r),new fe.ERR_OUT_OF_RANGE(r||"offset","an integer",t)):e<0?new fe.ERR_BUFFER_OUT_OF_BOUNDS:new fe.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}var Dd=/[^+/0-9A-Za-z-_]/g;function Nd(t){if(t=t.split("=")[0],t=t.trim().replace(Dd,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function Pn(t,e){e=e||1/0;let r,n=t.length,i=null,a=[];for(let o=0;o<n;++o){if(r=t.charCodeAt(o),r>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&a.push(239,191,189);continue}else if(o+1===n){(e-=3)>-1&&a.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&a.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(e-=3)>-1&&a.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;a.push(r)}else if(r<2048){if((e-=2)<0)break;a.push(r>>6|192,r&63|128)}else if(r<65536){if((e-=3)<0)break;a.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((e-=4)<0)break;a.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return a}function Ud(t){let e=[];for(let r=0;r<t.length;++r)e.push(t.charCodeAt(r)&255);return e}function jd(t,e){let r,n,i,a=[];for(let o=0;o<t.length&&!((e-=2)<0);++o)r=t.charCodeAt(o),n=r>>8,i=r%256,a.push(i),a.push(n);return a}function Ao(t){return Tn.toByteArray(Nd(t))}function Tr(t,e,r,n){let i;for(i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function mt(t,e){return t instanceof e||t!=null&&t.constructor!=null&&t.constructor.name!=null&&t.constructor.name===e.name}function jn(t){return t!==t}var Md=(function(){let t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){let n=r*16;for(let i=0;i<16;++i)e[n+i]=t[r]+t[i]}return e})();function Ut(t){return typeof BigInt>"u"?Ld:t}function Ld(){throw new Error("BigInt not supported")}});var $o=O((Cg,Ln)=>{typeof Object.create=="function"?Ln.exports=function(e,r){r&&(e.super_=r,e.prototype=Object.create(r.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:Ln.exports=function(e,r){if(r){e.super_=r;var n=function(){};n.prototype=r.prototype,e.prototype=new n,e.prototype.constructor=e}}});var Fr=O((Gn,Oo)=>{var Cr=Mn(),gt=Cr.Buffer;function Ro(t,e){for(var r in t)e[r]=t[r]}gt.from&&gt.alloc&&gt.allocUnsafe&&gt.allocUnsafeSlow?Oo.exports=Cr:(Ro(Cr,Gn),Gn.Buffer=Kt);function Kt(t,e,r){return gt(t,e,r)}Kt.prototype=Object.create(gt.prototype);Ro(gt,Kt);Kt.from=function(t,e,r){if(typeof t=="number")throw new TypeError("Argument must not be a number");return gt(t,e,r)};Kt.alloc=function(t,e,r){if(typeof t!="number")throw new TypeError("Argument must be a number");var n=gt(t);return e!==void 0?typeof r=="string"?n.fill(e,r):n.fill(e):n.fill(0),n};Kt.allocUnsafe=function(t){if(typeof t!="number")throw new TypeError("Argument must be a number");return gt(t)};Kt.allocUnsafeSlow=function(t){if(typeof t!="number")throw new TypeError("Argument must be a number");return Cr.SlowBuffer(t)}});var Io=O((Fg,Bo)=>{var Gd={}.toString;Bo.exports=Array.isArray||function(t){return Gd.call(t)=="[object Array]"}});var he=O((Pg,To)=>{"use strict";To.exports=TypeError});var zn=O((Dg,Co)=>{"use strict";Co.exports=Object});var Po=O((Ng,Fo)=>{"use strict";Fo.exports=Error});var No=O((Ug,Do)=>{"use strict";Do.exports=EvalError});var jo=O((jg,Uo)=>{"use strict";Uo.exports=RangeError});var Lo=O((Mg,Mo)=>{"use strict";Mo.exports=ReferenceError});var Hn=O((Lg,Go)=>{"use strict";Go.exports=SyntaxError});var Ho=O((Gg,zo)=>{"use strict";zo.exports=URIError});var Wo=O((zg,qo)=>{"use strict";qo.exports=Math.abs});var Vo=O((Hg,Zo)=>{"use strict";Zo.exports=Math.floor});var Yo=O((qg,Xo)=>{"use strict";Xo.exports=Math.max});var Jo=O((Wg,Ko)=>{"use strict";Ko.exports=Math.min});var ts=O((Zg,Qo)=>{"use strict";Qo.exports=Math.pow});var rs=O((Vg,es)=>{"use strict";es.exports=Math.round});var is=O((Xg,ns)=>{"use strict";ns.exports=Number.isNaN||function(e){return e!==e}});var os=O((Yg,as)=>{"use strict";var zd=is();as.exports=function(e){return zd(e)||e===0?e:e<0?-1:1}});var cs=O((Kg,ss)=>{"use strict";ss.exports=Object.getOwnPropertyDescriptor});var pe=O((Jg,fs)=>{"use strict";var Pr=cs();if(Pr)try{Pr([],"length")}catch{Pr=null}fs.exports=Pr});var Ge=O((Qg,ls)=>{"use strict";var Dr=Object.defineProperty||!1;if(Dr)try{Dr({},"a",{value:1})}catch{Dr=!1}ls.exports=Dr});var qn=O((ty,us)=>{"use strict";us.exports=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var e={},r=Symbol("test"),n=Object(r);if(typeof r=="string"||Object.prototype.toString.call(r)!=="[object Symbol]"||Object.prototype.toString.call(n)!=="[object Symbol]")return!1;var i=42;e[r]=i;for(var a in e)return!1;if(typeof Object.keys=="function"&&Object.keys(e).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(e).length!==0)return!1;var o=Object.getOwnPropertySymbols(e);if(o.length!==1||o[0]!==r||!Object.prototype.propertyIsEnumerable.call(e,r))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var s=Object.getOwnPropertyDescriptor(e,r);if(s.value!==i||s.enumerable!==!0)return!1}return!0}});var ps=O((ey,hs)=>{"use strict";var ds=typeof Symbol<"u"&&Symbol,Hd=qn();hs.exports=function(){return typeof ds!="function"||typeof Symbol!="function"||typeof ds("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:Hd()}});var Wn=O((ry,ws)=>{"use strict";ws.exports=typeof Reflect<"u"&&Reflect.getPrototypeOf||null});var Zn=O((ny,ms)=>{"use strict";var qd=zn();ms.exports=qd.getPrototypeOf||null});var bs=O((iy,ys)=>{"use strict";var Wd="Function.prototype.bind called on incompatible ",Zd=Object.prototype.toString,Vd=Math.max,Xd="[object Function]",gs=function(e,r){for(var n=[],i=0;i<e.length;i+=1)n[i]=e[i];for(var a=0;a<r.length;a+=1)n[a+e.length]=r[a];return n},Yd=function(e,r){for(var n=[],i=r||0,a=0;i<e.length;i+=1,a+=1)n[a]=e[i];return n},Kd=function(t,e){for(var r="",n=0;n<t.length;n+=1)r+=t[n],n+1<t.length&&(r+=e);return r};ys.exports=function(e){var r=this;if(typeof r!="function"||Zd.apply(r)!==Xd)throw new TypeError(Wd+r);for(var n=Yd(arguments,1),i,a=function(){if(this instanceof i){var l=r.apply(this,gs(n,arguments));return Object(l)===l?l:this}return r.apply(e,gs(n,arguments))},o=Vd(0,r.length-n.length),s=[],c=0;c<o;c++)s[c]="$"+c;if(i=Function("binder","return function ("+Kd(s,",")+"){ return binder.apply(this,arguments); }")(a),r.prototype){var f=function(){};f.prototype=r.prototype,i.prototype=new f,f.prototype=null}return i}});var we=O((ay,_s)=>{"use strict";var Jd=bs();_s.exports=Function.prototype.bind||Jd});var Nr=O((oy,vs)=>{"use strict";vs.exports=Function.prototype.call});var Ur=O((sy,xs)=>{"use strict";xs.exports=Function.prototype.apply});var ks=O((cy,Es)=>{"use strict";Es.exports=typeof Reflect<"u"&&Reflect&&Reflect.apply});var Vn=O((fy,Ss)=>{"use strict";var Qd=we(),th=Ur(),eh=Nr(),rh=ks();Ss.exports=rh||Qd.call(eh,th)});var jr=O((ly,As)=>{"use strict";var nh=we(),ih=he(),ah=Nr(),oh=Vn();As.exports=function(e){if(e.length<1||typeof e[0]!="function")throw new ih("a function is required");return oh(nh,ah,e)}});var Ts=O((uy,Is)=>{"use strict";var sh=jr(),$s=pe(),Os;try{Os=[].__proto__===Array.prototype}catch(t){if(!t||typeof t!="object"||!("code"in t)||t.code!=="ERR_PROTO_ACCESS")throw t}var Xn=!!Os&&$s&&$s(Object.prototype,"__proto__"),Bs=Object,Rs=Bs.getPrototypeOf;Is.exports=Xn&&typeof Xn.get=="function"?sh([Xn.get]):typeof Rs=="function"?function(e){return Rs(e==null?e:Bs(e))}:!1});var Yn=O((dy,Ds)=>{"use strict";var Cs=Wn(),Fs=Zn(),Ps=Ts();Ds.exports=Cs?function(e){return Cs(e)}:Fs?function(e){if(!e||typeof e!="object"&&typeof e!="function")throw new TypeError("getProto: not an object");return Fs(e)}:Ps?function(e){return Ps(e)}:null});var Us=O((hy,Ns)=>{"use strict";var ch=Function.prototype.call,fh=Object.prototype.hasOwnProperty,lh=we();Ns.exports=lh.call(ch,fh)});var Qn=O((py,Hs)=>{"use strict";var C,uh=zn(),dh=Po(),hh=No(),ph=jo(),wh=Lo(),be=Hn(),ye=he(),mh=Ho(),gh=Wo(),yh=Vo(),bh=Yo(),_h=Jo(),vh=ts(),xh=rs(),Eh=os(),Gs=Function,Kn=function(t){try{return Gs('"use strict"; return ('+t+").constructor;")()}catch{}},ze=pe(),kh=Ge(),Jn=function(){throw new ye},Sh=ze?(function(){try{return arguments.callee,Jn}catch{try{return ze(arguments,"callee").get}catch{return Jn}}})():Jn,me=ps()(),q=Yn(),Ah=Zn(),$h=Wn(),zs=Ur(),He=Nr(),ge={},Rh=typeof Uint8Array>"u"||!q?C:q(Uint8Array),Jt={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?C:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?C:ArrayBuffer,"%ArrayIteratorPrototype%":me&&q?q([][Symbol.iterator]()):C,"%AsyncFromSyncIteratorPrototype%":C,"%AsyncFunction%":ge,"%AsyncGenerator%":ge,"%AsyncGeneratorFunction%":ge,"%AsyncIteratorPrototype%":ge,"%Atomics%":typeof Atomics>"u"?C:Atomics,"%BigInt%":typeof BigInt>"u"?C:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?C:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?C:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?C:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":dh,"%eval%":eval,"%EvalError%":hh,"%Float16Array%":typeof Float16Array>"u"?C:Float16Array,"%Float32Array%":typeof Float32Array>"u"?C:Float32Array,"%Float64Array%":typeof Float64Array>"u"?C:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?C:FinalizationRegistry,"%Function%":Gs,"%GeneratorFunction%":ge,"%Int8Array%":typeof Int8Array>"u"?C:Int8Array,"%Int16Array%":typeof Int16Array>"u"?C:Int16Array,"%Int32Array%":typeof Int32Array>"u"?C:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":me&&q?q(q([][Symbol.iterator]())):C,"%JSON%":typeof JSON=="object"?JSON:C,"%Map%":typeof Map>"u"?C:Map,"%MapIteratorPrototype%":typeof Map>"u"||!me||!q?C:q(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":uh,"%Object.getOwnPropertyDescriptor%":ze,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?C:Promise,"%Proxy%":typeof Proxy>"u"?C:Proxy,"%RangeError%":ph,"%ReferenceError%":wh,"%Reflect%":typeof Reflect>"u"?C:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?C:Set,"%SetIteratorPrototype%":typeof Set>"u"||!me||!q?C:q(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?C:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":me&&q?q(""[Symbol.iterator]()):C,"%Symbol%":me?Symbol:C,"%SyntaxError%":be,"%ThrowTypeError%":Sh,"%TypedArray%":Rh,"%TypeError%":ye,"%Uint8Array%":typeof Uint8Array>"u"?C:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?C:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?C:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?C:Uint32Array,"%URIError%":mh,"%WeakMap%":typeof WeakMap>"u"?C:WeakMap,"%WeakRef%":typeof WeakRef>"u"?C:WeakRef,"%WeakSet%":typeof WeakSet>"u"?C:WeakSet,"%Function.prototype.call%":He,"%Function.prototype.apply%":zs,"%Object.defineProperty%":kh,"%Object.getPrototypeOf%":Ah,"%Math.abs%":gh,"%Math.floor%":yh,"%Math.max%":bh,"%Math.min%":_h,"%Math.pow%":vh,"%Math.round%":xh,"%Math.sign%":Eh,"%Reflect.getPrototypeOf%":$h};if(q)try{null.error}catch(t){js=q(q(t)),Jt["%Error.prototype%"]=js}var js,Oh=function t(e){var r;if(e==="%AsyncFunction%")r=Kn("async function () {}");else if(e==="%GeneratorFunction%")r=Kn("function* () {}");else if(e==="%AsyncGeneratorFunction%")r=Kn("async function* () {}");else if(e==="%AsyncGenerator%"){var n=t("%AsyncGeneratorFunction%");n&&(r=n.prototype)}else if(e==="%AsyncIteratorPrototype%"){var i=t("%AsyncGenerator%");i&&q&&(r=q(i.prototype))}return Jt[e]=r,r},Ms={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},qe=we(),Mr=Us(),Bh=qe.call(He,Array.prototype.concat),Ih=qe.call(zs,Array.prototype.splice),Ls=qe.call(He,String.prototype.replace),Lr=qe.call(He,String.prototype.slice),Th=qe.call(He,RegExp.prototype.exec),Ch=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,Fh=/\\(\\)?/g,Ph=function(e){var r=Lr(e,0,1),n=Lr(e,-1);if(r==="%"&&n!=="%")throw new be("invalid intrinsic syntax, expected closing `%`");if(n==="%"&&r!=="%")throw new be("invalid intrinsic syntax, expected opening `%`");var i=[];return Ls(e,Ch,function(a,o,s,c){i[i.length]=s?Ls(c,Fh,"$1"):o||a}),i},Dh=function(e,r){var n=e,i;if(Mr(Ms,n)&&(i=Ms[n],n="%"+i[0]+"%"),Mr(Jt,n)){var a=Jt[n];if(a===ge&&(a=Oh(n)),typeof a>"u"&&!r)throw new ye("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:i,name:n,value:a}}throw new be("intrinsic "+e+" does not exist!")};Hs.exports=function(e,r){if(typeof e!="string"||e.length===0)throw new ye("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof r!="boolean")throw new ye('"allowMissing" argument must be a boolean');if(Th(/^%?[^%]*%?$/,e)===null)throw new be("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var n=Ph(e),i=n.length>0?n[0]:"",a=Dh("%"+i+"%",r),o=a.name,s=a.value,c=!1,f=a.alias;f&&(i=f[0],Ih(n,Bh([0,1],f)));for(var l=1,u=!0;l<n.length;l+=1){var d=n[l],h=Lr(d,0,1),p=Lr(d,-1);if((h==='"'||h==="'"||h==="`"||p==='"'||p==="'"||p==="`")&&h!==p)throw new be("property names with quotes must have matching quotes");if((d==="constructor"||!u)&&(c=!0),i+="."+d,o="%"+i+"%",Mr(Jt,o))s=Jt[o];else if(s!=null){if(!(d in s)){if(!r)throw new ye("base intrinsic for "+e+" exists, but the property is not available.");return}if(ze&&l+1>=n.length){var w=ze(s,d);u=!!w,u&&"get"in w&&!("originalValue"in w.get)?s=w.get:s=s[d]}else u=Mr(s,d),s=s[d];u&&!c&&(Jt[o]=s)}}return s}});var ti=O((wy,Zs)=>{"use strict";var qs=Qn(),Ws=jr(),Nh=Ws([qs("%String.prototype.indexOf%")]);Zs.exports=function(e,r){var n=qs(e,!!r);return typeof n=="function"&&Nh(e,".prototype.")>-1?Ws([n]):n}});var Ks=O((my,Ys)=>{"use strict";var Xs=Function.prototype.toString,_e=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,ri,Gr;if(typeof _e=="function"&&typeof Object.defineProperty=="function")try{ri=Object.defineProperty({},"length",{get:function(){throw Gr}}),Gr={},_e(function(){throw 42},null,ri)}catch(t){t!==Gr&&(_e=null)}else _e=null;var Uh=/^\s*class\b/,ni=function(e){try{var r=Xs.call(e);return Uh.test(r)}catch{return!1}},ei=function(e){try{return ni(e)?!1:(Xs.call(e),!0)}catch{return!1}},zr=Object.prototype.toString,jh="[object Object]",Mh="[object Function]",Lh="[object GeneratorFunction]",Gh="[object HTMLAllCollection]",zh="[object HTML document.all class]",Hh="[object HTMLCollection]",qh=typeof Symbol=="function"&&!!Symbol.toStringTag,Wh=!(0 in[,]),ii=function(){return!1};typeof document=="object"&&(Vs=document.all,zr.call(Vs)===zr.call(document.all)&&(ii=function(e){if((Wh||!e)&&(typeof e>"u"||typeof e=="object"))try{var r=zr.call(e);return(r===Gh||r===zh||r===Hh||r===jh)&&e("")==null}catch{}return!1}));var Vs;Ys.exports=_e?function(e){if(ii(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;try{_e(e,null,ri)}catch(r){if(r!==Gr)return!1}return!ni(e)&&ei(e)}:function(e){if(ii(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;if(qh)return ei(e);if(ni(e))return!1;var r=zr.call(e);return r!==Mh&&r!==Lh&&!/^\[object HTML/.test(r)?!1:ei(e)}});var tc=O((gy,Qs)=>{"use strict";var Zh=Ks(),Vh=Object.prototype.toString,Js=Object.prototype.hasOwnProperty,Xh=function(e,r,n){for(var i=0,a=e.length;i<a;i++)Js.call(e,i)&&(n==null?r(e[i],i,e):r.call(n,e[i],i,e))},Yh=function(e,r,n){for(var i=0,a=e.length;i<a;i++)n==null?r(e.charAt(i),i,e):r.call(n,e.charAt(i),i,e)},Kh=function(e,r,n){for(var i in e)Js.call(e,i)&&(n==null?r(e[i],i,e):r.call(n,e[i],i,e))};function Jh(t){return Vh.call(t)==="[object Array]"}Qs.exports=function(e,r,n){if(!Zh(r))throw new TypeError("iterator must be a function");var i;arguments.length>=3&&(i=n),Jh(e)?Xh(e,r,i):typeof e=="string"?Yh(e,r,i):Kh(e,r,i)}});var rc=O((yy,ec)=>{"use strict";ec.exports=["Float16Array","Float32Array","Float64Array","Int8Array","Int16Array","Int32Array","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array"]});var ic=O((by,nc)=>{"use strict";var ai=rc(),Qh=typeof globalThis>"u"?global:globalThis;nc.exports=function(){for(var e=[],r=0;r<ai.length;r++)typeof Qh[ai[r]]=="function"&&(e[e.length]=ai[r]);return e}});var cc=O((_y,sc)=>{"use strict";var ac=Ge(),tp=Hn(),ve=he(),oc=pe();sc.exports=function(e,r,n){if(!e||typeof e!="object"&&typeof e!="function")throw new ve("`obj` must be an object or a function`");if(typeof r!="string"&&typeof r!="symbol")throw new ve("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new ve("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new ve("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new ve("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new ve("`loose`, if provided, must be a boolean");var i=arguments.length>3?arguments[3]:null,a=arguments.length>4?arguments[4]:null,o=arguments.length>5?arguments[5]:null,s=arguments.length>6?arguments[6]:!1,c=!!oc&&oc(e,r);if(ac)ac(e,r,{configurable:o===null&&c?c.configurable:!o,enumerable:i===null&&c?c.enumerable:!i,value:n,writable:a===null&&c?c.writable:!a});else if(s||!i&&!a&&!o)e[r]=n;else throw new tp("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")}});var uc=O((vy,lc)=>{"use strict";var oi=Ge(),fc=function(){return!!oi};fc.hasArrayLengthDefineBug=function(){if(!oi)return null;try{return oi([],"length",{value:1}).length!==1}catch{return!0}};lc.exports=fc});var mc=O((xy,wc)=>{"use strict";var ep=Qn(),dc=cc(),rp=uc()(),hc=pe(),pc=he(),np=ep("%Math.floor%");wc.exports=function(e,r){if(typeof e!="function")throw new pc("`fn` is not a function");if(typeof r!="number"||r<0||r>4294967295||np(r)!==r)throw new pc("`length` must be a positive 32-bit integer");var n=arguments.length>2&&!!arguments[2],i=!0,a=!0;if("length"in e&&hc){var o=hc(e,"length");o&&!o.configurable&&(i=!1),o&&!o.writable&&(a=!1)}return(i||a||!n)&&(rp?dc(e,"length",r,!0,!0):dc(e,"length",r)),e}});var yc=O((Ey,gc)=>{"use strict";var ip=we(),ap=Ur(),op=Vn();gc.exports=function(){return op(ip,ap,arguments)}});var vc=O((ky,Hr)=>{"use strict";var sp=mc(),bc=Ge(),cp=jr(),_c=yc();Hr.exports=function(e){var r=cp(arguments),n=1+e.length-(arguments.length-1);return sp(r,n>0?n:0,!0)};bc?bc(Hr.exports,"apply",{value:_c}):Hr.exports.apply=_c});var Ec=O((Sy,xc)=>{"use strict";var fp=qn();xc.exports=function(){return fp()&&!!Symbol.toStringTag}});var Rc=O((Ay,$c)=>{"use strict";var Zr=tc(),lp=ic(),kc=vc(),ci=ti(),Wr=pe(),qr=Yn(),up=ci("Object.prototype.toString"),Ac=Ec()(),Sc=typeof globalThis>"u"?global:globalThis,si=lp(),fi=ci("String.prototype.slice"),dp=ci("Array.prototype.indexOf",!0)||function(e,r){for(var n=0;n<e.length;n+=1)if(e[n]===r)return n;return-1},Vr={__proto__:null};Ac&&Wr&&qr?Zr(si,function(t){var e=new Sc[t];if(Symbol.toStringTag in e&&qr){var r=qr(e),n=Wr(r,Symbol.toStringTag);if(!n&&r){var i=qr(r);n=Wr(i,Symbol.toStringTag)}if(n&&n.get){var a=kc(n.get);Vr["$"+t]=a}}}):Zr(si,function(t){var e=new Sc[t],r=e.slice||e.set;if(r){var n=kc(r);Vr["$"+t]=n}});function hp(t){var e=!1;return Zr(Vr,function(r,n){if(!e)try{"$"+r(t)===n&&(e=fi(n,1))}catch{}}),e}function pp(t){var e=!1;return Zr(Vr,function(r,n){if(!e)try{r(t),e=fi(n,1)}catch{}}),e}function wp(t){return dp(si,t)>-1}function mp(t){if(!t||typeof t!="object")return!1;if(!Ac){var e=fi(up(t),8,-1);return wp(e)?e:e!=="Object"?!1:pp(t)}return Wr?hp(t):null}$c.exports=mp});var Bc=O(($y,Oc)=>{"use strict";var gp=Rc();Oc.exports=function(e){return!!gp(e)}});var Tc=O((Ry,Ic)=>{"use strict";var yp=he(),bp=ti(),_p=bp("TypedArray.prototype.buffer",!0),vp=Bc();Ic.exports=_p||function(e){if(!vp(e))throw new yp("Not a Typed Array");return e.buffer}});var Pc=O((Oy,Fc)=>{"use strict";var ut=Fr().Buffer,xp=Io(),Ep=Tc(),kp=ArrayBuffer.isView||function(e){try{return Ep(e),!0}catch{return!1}},Sp=typeof Uint8Array<"u",Cc=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",Ap=Cc&&(ut.prototype instanceof Uint8Array||ut.TYPED_ARRAY_SUPPORT);Fc.exports=function(e,r){if(ut.isBuffer(e))return e.constructor&&!("isBuffer"in e)?ut.from(e):e;if(typeof e=="string")return ut.from(e,r);if(Cc&&kp(e)){if(e.byteLength===0)return ut.alloc(0);if(Ap){var n=ut.from(e.buffer,e.byteOffset,e.byteLength);if(n.byteLength===e.byteLength)return n}var i=e instanceof Uint8Array?e:new Uint8Array(e.buffer,e.byteOffset,e.byteLength),a=ut.from(i);if(a.length===e.byteLength)return a}if(Sp&&e instanceof Uint8Array)return ut.from(e);var o=xp(e);if(o)for(var s=0;s<e.length;s+=1){var c=e[s];if(typeof c!="number"||c<0||c>255||~~c!==c)throw new RangeError("Array items must be numbers in the range 0-255.")}if(o||ut.isBuffer(e)&&e.constructor&&typeof e.constructor.isBuffer=="function"&&e.constructor.isBuffer(e))return ut.from(e);throw new TypeError('The "data" argument must be a string, an Array, a Buffer, a Uint8Array, or a DataView.')}});var Nc=O((By,Dc)=>{"use strict";var $p=Fr().Buffer,Rp=Pc();function Xr(t,e){this._block=$p.alloc(t),this._finalSize=e,this._blockSize=t,this._len=0}Xr.prototype.update=function(t,e){t=Rp(t,e||"utf8");for(var r=this._block,n=this._blockSize,i=t.length,a=this._len,o=0;o<i;){for(var s=a%n,c=Math.min(i-o,n-s),f=0;f<c;f++)r[s+f]=t[o+f];a+=c,o+=c,a%n===0&&this._update(r)}return this._len+=i,this};Xr.prototype.digest=function(t){var e=this._len%this._blockSize;this._block[e]=128,this._block.fill(0,e+1),e>=this._finalSize&&(this._update(this._block),this._block.fill(0));var r=this._len*8;if(r<=4294967295)this._block.writeUInt32BE(r,this._blockSize-4);else{var n=(r&4294967295)>>>0,i=(r-n)/4294967296;this._block.writeUInt32BE(i,this._blockSize-8),this._block.writeUInt32BE(n,this._blockSize-4)}this._update(this._block);var a=this._hash();return t?a.toString(t):a};Xr.prototype._update=function(){throw new Error("_update must be implemented by subclass")};Dc.exports=Xr});var Mc=O((Iy,jc)=>{"use strict";var Op=$o(),Uc=Nc(),Bp=Fr().Buffer,Ip=[1518500249,1859775393,-1894007588,-899497514],Tp=new Array(80);function We(){this.init(),this._w=Tp,Uc.call(this,64,56)}Op(We,Uc);We.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function Cp(t){return t<<1|t>>>31}function Fp(t){return t<<5|t>>>27}function Pp(t){return t<<30|t>>>2}function Dp(t,e,r,n){return t===0?e&r|~e&n:t===2?e&r|e&n|r&n:e^r^n}We.prototype._update=function(t){for(var e=this._w,r=this._a|0,n=this._b|0,i=this._c|0,a=this._d|0,o=this._e|0,s=0;s<16;++s)e[s]=t.readInt32BE(s*4);for(;s<80;++s)e[s]=Cp(e[s-3]^e[s-8]^e[s-14]^e[s-16]);for(var c=0;c<80;++c){var f=~~(c/20),l=Fp(r)+Dp(f,n,i,a)+o+e[c]+Ip[f]|0;o=a,a=i,i=Pp(n),n=r,r=l}this._a=r+this._a|0,this._b=n+this._b|0,this._c=i+this._c|0,this._d=a+this._d|0,this._e=o+this._e|0};We.prototype._hash=function(){var t=Bp.allocUnsafe(20);return t.writeInt32BE(this._a|0,0),t.writeInt32BE(this._b|0,4),t.writeInt32BE(this._c|0,8),t.writeInt32BE(this._d|0,12),t.writeInt32BE(this._e|0,16),t};jc.exports=We});var Gc=O((Ty,Lc)=>{"use strict";var tt=function(t){if(t=t||{},this.Promise=t.Promise||Promise,this.queues=Object.create(null),this.domainReentrant=t.domainReentrant||!1,this.domainReentrant){if(typeof process>"u"||typeof process.domain>"u")throw new Error("Domain-reentrant locks require `process.domain` to exist. Please flip `opts.domainReentrant = false`, use a NodeJS version that still implements Domain, or install a browser polyfill.");this.domains=Object.create(null)}this.timeout=t.timeout||tt.DEFAULT_TIMEOUT,this.maxOccupationTime=t.maxOccupationTime||tt.DEFAULT_MAX_OCCUPATION_TIME,this.maxExecutionTime=t.maxExecutionTime||tt.DEFAULT_MAX_EXECUTION_TIME,t.maxPending===1/0||Number.isInteger(t.maxPending)&&t.maxPending>=0?this.maxPending=t.maxPending:this.maxPending=tt.DEFAULT_MAX_PENDING};tt.DEFAULT_TIMEOUT=0;tt.DEFAULT_MAX_OCCUPATION_TIME=0;tt.DEFAULT_MAX_EXECUTION_TIME=0;tt.DEFAULT_MAX_PENDING=1e3;tt.prototype.acquire=function(t,e,r,n){if(Array.isArray(t))return this._acquireBatch(t,e,r,n);if(typeof e!="function")throw new Error("You must pass a function to execute");var i=null,a=null,o=null;typeof r!="function"&&(n=r,r=null,o=new this.Promise(function(E,S){i=E,a=S})),n=n||{};var s=!1,c=null,f=null,l=null,u=this,d=function(E,S,A){f&&(clearTimeout(f),f=null),l&&(clearTimeout(l),l=null),E&&(u.queues[t]&&u.queues[t].length===0&&delete u.queues[t],u.domainReentrant&&delete u.domains[t]),s||(o?S?a(S):i(A):typeof r=="function"&&r(S,A),s=!0),E&&u.queues[t]&&u.queues[t].length>0&&u.queues[t].shift()()},h=function(E){if(s)return d(E);c&&(clearTimeout(c),c=null),u.domainReentrant&&E&&(u.domains[t]=process.domain);var S=n.maxExecutionTime||u.maxExecutionTime;if(S&&(l=setTimeout(function(){u.queues[t]&&d(E,new Error("Maximum execution time is exceeded "+t))},S)),e.length===1){var A=!1;try{e(function(m,$){A||(A=!0,d(E,m,$))})}catch(m){A||(A=!0,d(E,m))}}else u._promiseTry(function(){return e()}).then(function(m){d(E,void 0,m)},function(m){d(E,m)})};u.domainReentrant&&process.domain&&(h=process.domain.bind(h));var p=n.maxPending||u.maxPending;if(!u.queues[t])u.queues[t]=[],h(!0);else if(u.domainReentrant&&process.domain&&process.domain===u.domains[t])h(!1);else if(u.queues[t].length>=p)d(!1,new Error("Too many pending tasks in queue "+t));else{var w=function(){h(!0)};n.skipQueue?u.queues[t].unshift(w):u.queues[t].push(w);var y=n.timeout||u.timeout;y&&(c=setTimeout(function(){c=null,d(!1,new Error("async-lock timed out in queue "+t))},y))}var b=n.maxOccupationTime||u.maxOccupationTime;if(b&&(f=setTimeout(function(){u.queues[t]&&d(!1,new Error("Maximum occupation time is exceeded in queue "+t))},b)),o)return o};tt.prototype._acquireBatch=function(t,e,r,n){var i=Object.create(null);t=t.filter(function(c){return i[c]?!1:(i[c]=!0,!0)}),typeof r!="function"&&(n=r,r=null);var a=this,o=function(c,f){return function(l){a.acquire(c,f,l,n)}},s=t.reduceRight(function(c,f){return o(f,c)},e);if(typeof r=="function")s(r);else return new this.Promise(function(c,f){s.length===1?s(function(l,u){l?f(l):c(u)}):c(s())})};tt.prototype.isBusy=function(t){return t?!!this.queues[t]:Object.keys(this.queues).length>0};tt.prototype._promiseTry=function(t){try{return this.Promise.resolve(t())}catch(e){return this.Promise.reject(e)}};Lc.exports=tt});var Hc=O((Cy,zc)=>{"use strict";zc.exports=Gc()});var Wc=O((Fy,qc)=>{"use strict";function Np(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function yt(t,e,r){return e=e instanceof RegExp?e:new RegExp(Np(e),"g"),t.replace(e,r)}var Up={clean:function(e){if(typeof e!="string")throw new Error("Expected a string, received: "+e);return e=yt(e,"./","/"),e=yt(e,"..","."),e=yt(e," ","-"),e=yt(e,/^[~^:?*\\\-]/g,""),e=yt(e,/[~^:?*\\]/g,"-"),e=yt(e,/[~^:?*\\\-]$/g,""),e=yt(e,"@{","-"),e=yt(e,/\.$/g,""),e=yt(e,/\/$/g,""),e=yt(e,/\.lock$/g,""),e}};qc.exports=Up});var Vc=O(li=>{var Zc;(function(t){typeof DO_NOT_EXPORT_CRC>"u"?typeof li=="object"?t(li):typeof define=="function"&&define.amd?define(function(){var e={};return t(e),e}):t(Zc={}):t(Zc={})})(function(t){t.version="1.2.2";function e(){for(var g=0,x=new Array(256),_=0;_!=256;++_)g=_,g=g&1?-306674912^g>>>1:g>>>1,g=g&1?-306674912^g>>>1:g>>>1,g=g&1?-306674912^g>>>1:g>>>1,g=g&1?-306674912^g>>>1:g>>>1,g=g&1?-306674912^g>>>1:g>>>1,g=g&1?-306674912^g>>>1:g>>>1,g=g&1?-306674912^g>>>1:g>>>1,g=g&1?-306674912^g>>>1:g>>>1,x[_]=g;return typeof Int32Array<"u"?new Int32Array(x):x}var r=e();function n(g){var x=0,_=0,R=0,k=typeof Int32Array<"u"?new Int32Array(4096):new Array(4096);for(R=0;R!=256;++R)k[R]=g[R];for(R=0;R!=256;++R)for(_=g[R],x=256+R;x<4096;x+=256)_=k[x]=_>>>8^g[_&255];var B=[];for(R=1;R!=16;++R)B[R-1]=typeof Int32Array<"u"?k.subarray(R*256,R*256+256):k.slice(R*256,R*256+256);return B}var i=n(r),a=i[0],o=i[1],s=i[2],c=i[3],f=i[4],l=i[5],u=i[6],d=i[7],h=i[8],p=i[9],w=i[10],y=i[11],b=i[12],E=i[13],S=i[14];function A(g,x){for(var _=x^-1,R=0,k=g.length;R<k;)_=_>>>8^r[(_^g.charCodeAt(R++))&255];return~_}function m(g,x){for(var _=x^-1,R=g.length-15,k=0;k<R;)_=S[g[k++]^_&255]^E[g[k++]^_>>8&255]^b[g[k++]^_>>16&255]^y[g[k++]^_>>>24]^w[g[k++]]^p[g[k++]]^h[g[k++]]^d[g[k++]]^u[g[k++]]^l[g[k++]]^f[g[k++]]^c[g[k++]]^s[g[k++]]^o[g[k++]]^a[g[k++]]^r[g[k++]];for(R+=15;k<R;)_=_>>>8^r[(_^g[k++])&255];return~_}function $(g,x){for(var _=x^-1,R=0,k=g.length,B=0,N=0;R<k;)B=g.charCodeAt(R++),B<128?_=_>>>8^r[(_^B)&255]:B<2048?(_=_>>>8^r[(_^(192|B>>6&31))&255],_=_>>>8^r[(_^(128|B&63))&255]):B>=55296&&B<57344?(B=(B&1023)+64,N=g.charCodeAt(R++)&1023,_=_>>>8^r[(_^(240|B>>8&7))&255],_=_>>>8^r[(_^(128|B>>2&63))&255],_=_>>>8^r[(_^(128|N>>6&15|(B&3)<<4))&255],_=_>>>8^r[(_^(128|N&63))&255]):(_=_>>>8^r[(_^(224|B>>12&15))&255],_=_>>>8^r[(_^(128|B>>6&63))&255],_=_>>>8^r[(_^(128|B&63))&255]);return~_}t.table=r,t.bstr=A,t.buf=m,t.str=$})});var Rt=O(Y=>{"use strict";var jp=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";function Mp(t,e){return Object.prototype.hasOwnProperty.call(t,e)}Y.assign=function(t){for(var e=Array.prototype.slice.call(arguments,1);e.length;){var r=e.shift();if(r){if(typeof r!="object")throw new TypeError(r+"must be non-object");for(var n in r)Mp(r,n)&&(t[n]=r[n])}}return t};Y.shrinkBuf=function(t,e){return t.length===e?t:t.subarray?t.subarray(0,e):(t.length=e,t)};var Lp={arraySet:function(t,e,r,n,i){if(e.subarray&&t.subarray){t.set(e.subarray(r,r+n),i);return}for(var a=0;a<n;a++)t[i+a]=e[r+a]},flattenChunks:function(t){var e,r,n,i,a,o;for(n=0,e=0,r=t.length;e<r;e++)n+=t[e].length;for(o=new Uint8Array(n),i=0,e=0,r=t.length;e<r;e++)a=t[e],o.set(a,i),i+=a.length;return o}},Gp={arraySet:function(t,e,r,n,i){for(var a=0;a<n;a++)t[i+a]=e[r+a]},flattenChunks:function(t){return[].concat.apply([],t)}};Y.setTyped=function(t){t?(Y.Buf8=Uint8Array,Y.Buf16=Uint16Array,Y.Buf32=Int32Array,Y.assign(Y,Lp)):(Y.Buf8=Array,Y.Buf16=Array,Y.Buf32=Array,Y.assign(Y,Gp))};Y.setTyped(jp)});var yf=O(ke=>{"use strict";var zp=Rt(),Hp=4,Xc=0,Yc=1,qp=2;function Ee(t){for(var e=t.length;--e>=0;)t[e]=0}var Wp=0,rf=1,Zp=2,Vp=3,Xp=258,gi=29,Je=256,Ve=Je+1+gi,xe=30,yi=19,nf=2*Ve+1,Qt=15,ui=16,Yp=7,bi=256,af=16,of=17,sf=18,wi=[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],Yr=[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],Kp=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],cf=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],Jp=512,Ot=new Array((Ve+2)*2);Ee(Ot);var Ze=new Array(xe*2);Ee(Ze);var Xe=new Array(Jp);Ee(Xe);var Ye=new Array(Xp-Vp+1);Ee(Ye);var _i=new Array(gi);Ee(_i);var Kr=new Array(xe);Ee(Kr);function di(t,e,r,n,i){this.static_tree=t,this.extra_bits=e,this.extra_base=r,this.elems=n,this.max_length=i,this.has_stree=t&&t.length}var ff,lf,uf;function hi(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}function df(t){return t<256?Xe[t]:Xe[256+(t>>>7)]}function Ke(t,e){t.pending_buf[t.pending++]=e&255,t.pending_buf[t.pending++]=e>>>8&255}function Q(t,e,r){t.bi_valid>ui-r?(t.bi_buf|=e<<t.bi_valid&65535,Ke(t,t.bi_buf),t.bi_buf=e>>ui-t.bi_valid,t.bi_valid+=r-ui):(t.bi_buf|=e<<t.bi_valid&65535,t.bi_valid+=r)}function bt(t,e,r){Q(t,r[e*2],r[e*2+1])}function hf(t,e){var r=0;do r|=t&1,t>>>=1,r<<=1;while(--e>0);return r>>>1}function Qp(t){t.bi_valid===16?(Ke(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=t.bi_buf&255,t.bi_buf>>=8,t.bi_valid-=8)}function t0(t,e){var r=e.dyn_tree,n=e.max_code,i=e.stat_desc.static_tree,a=e.stat_desc.has_stree,o=e.stat_desc.extra_bits,s=e.stat_desc.extra_base,c=e.stat_desc.max_length,f,l,u,d,h,p,w=0;for(d=0;d<=Qt;d++)t.bl_count[d]=0;for(r[t.heap[t.heap_max]*2+1]=0,f=t.heap_max+1;f<nf;f++)l=t.heap[f],d=r[r[l*2+1]*2+1]+1,d>c&&(d=c,w++),r[l*2+1]=d,!(l>n)&&(t.bl_count[d]++,h=0,l>=s&&(h=o[l-s]),p=r[l*2],t.opt_len+=p*(d+h),a&&(t.static_len+=p*(i[l*2+1]+h)));if(w!==0){do{for(d=c-1;t.bl_count[d]===0;)d--;t.bl_count[d]--,t.bl_count[d+1]+=2,t.bl_count[c]--,w-=2}while(w>0);for(d=c;d!==0;d--)for(l=t.bl_count[d];l!==0;)u=t.heap[--f],!(u>n)&&(r[u*2+1]!==d&&(t.opt_len+=(d-r[u*2+1])*r[u*2],r[u*2+1]=d),l--)}}function pf(t,e,r){var n=new Array(Qt+1),i=0,a,o;for(a=1;a<=Qt;a++)n[a]=i=i+r[a-1]<<1;for(o=0;o<=e;o++){var s=t[o*2+1];s!==0&&(t[o*2]=hf(n[s]++,s))}}function e0(){var t,e,r,n,i,a=new Array(Qt+1);for(r=0,n=0;n<gi-1;n++)for(_i[n]=r,t=0;t<1<<wi[n];t++)Ye[r++]=n;for(Ye[r-1]=n,i=0,n=0;n<16;n++)for(Kr[n]=i,t=0;t<1<<Yr[n];t++)Xe[i++]=n;for(i>>=7;n<xe;n++)for(Kr[n]=i<<7,t=0;t<1<<Yr[n]-7;t++)Xe[256+i++]=n;for(e=0;e<=Qt;e++)a[e]=0;for(t=0;t<=143;)Ot[t*2+1]=8,t++,a[8]++;for(;t<=255;)Ot[t*2+1]=9,t++,a[9]++;for(;t<=279;)Ot[t*2+1]=7,t++,a[7]++;for(;t<=287;)Ot[t*2+1]=8,t++,a[8]++;for(pf(Ot,Ve+1,a),t=0;t<xe;t++)Ze[t*2+1]=5,Ze[t*2]=hf(t,5);ff=new di(Ot,wi,Je+1,Ve,Qt),lf=new di(Ze,Yr,0,xe,Qt),uf=new di(new Array(0),Kp,0,yi,Yp)}function wf(t){var e;for(e=0;e<Ve;e++)t.dyn_ltree[e*2]=0;for(e=0;e<xe;e++)t.dyn_dtree[e*2]=0;for(e=0;e<yi;e++)t.bl_tree[e*2]=0;t.dyn_ltree[bi*2]=1,t.opt_len=t.static_len=0,t.last_lit=t.matches=0}function mf(t){t.bi_valid>8?Ke(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0}function r0(t,e,r,n){mf(t),n&&(Ke(t,r),Ke(t,~r)),zp.arraySet(t.pending_buf,t.window,e,r,t.pending),t.pending+=r}function Kc(t,e,r,n){var i=e*2,a=r*2;return t[i]<t[a]||t[i]===t[a]&&n[e]<=n[r]}function pi(t,e,r){for(var n=t.heap[r],i=r<<1;i<=t.heap_len&&(i<t.heap_len&&Kc(e,t.heap[i+1],t.heap[i],t.depth)&&i++,!Kc(e,n,t.heap[i],t.depth));)t.heap[r]=t.heap[i],r=i,i<<=1;t.heap[r]=n}function Jc(t,e,r){var n,i,a=0,o,s;if(t.last_lit!==0)do n=t.pending_buf[t.d_buf+a*2]<<8|t.pending_buf[t.d_buf+a*2+1],i=t.pending_buf[t.l_buf+a],a++,n===0?bt(t,i,e):(o=Ye[i],bt(t,o+Je+1,e),s=wi[o],s!==0&&(i-=_i[o],Q(t,i,s)),n--,o=df(n),bt(t,o,r),s=Yr[o],s!==0&&(n-=Kr[o],Q(t,n,s)));while(a<t.last_lit);bt(t,bi,e)}function mi(t,e){var r=e.dyn_tree,n=e.stat_desc.static_tree,i=e.stat_desc.has_stree,a=e.stat_desc.elems,o,s,c=-1,f;for(t.heap_len=0,t.heap_max=nf,o=0;o<a;o++)r[o*2]!==0?(t.heap[++t.heap_len]=c=o,t.depth[o]=0):r[o*2+1]=0;for(;t.heap_len<2;)f=t.heap[++t.heap_len]=c<2?++c:0,r[f*2]=1,t.depth[f]=0,t.opt_len--,i&&(t.static_len-=n[f*2+1]);for(e.max_code=c,o=t.heap_len>>1;o>=1;o--)pi(t,r,o);f=a;do o=t.heap[1],t.heap[1]=t.heap[t.heap_len--],pi(t,r,1),s=t.heap[1],t.heap[--t.heap_max]=o,t.heap[--t.heap_max]=s,r[f*2]=r[o*2]+r[s*2],t.depth[f]=(t.depth[o]>=t.depth[s]?t.depth[o]:t.depth[s])+1,r[o*2+1]=r[s*2+1]=f,t.heap[1]=f++,pi(t,r,1);while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],t0(t,e),pf(r,c,t.bl_count)}function Qc(t,e,r){var n,i=-1,a,o=e[1],s=0,c=7,f=4;for(o===0&&(c=138,f=3),e[(r+1)*2+1]=65535,n=0;n<=r;n++)a=o,o=e[(n+1)*2+1],!(++s<c&&a===o)&&(s<f?t.bl_tree[a*2]+=s:a!==0?(a!==i&&t.bl_tree[a*2]++,t.bl_tree[af*2]++):s<=10?t.bl_tree[of*2]++:t.bl_tree[sf*2]++,s=0,i=a,o===0?(c=138,f=3):a===o?(c=6,f=3):(c=7,f=4))}function tf(t,e,r){var n,i=-1,a,o=e[1],s=0,c=7,f=4;for(o===0&&(c=138,f=3),n=0;n<=r;n++)if(a=o,o=e[(n+1)*2+1],!(++s<c&&a===o)){if(s<f)do bt(t,a,t.bl_tree);while(--s!==0);else a!==0?(a!==i&&(bt(t,a,t.bl_tree),s--),bt(t,af,t.bl_tree),Q(t,s-3,2)):s<=10?(bt(t,of,t.bl_tree),Q(t,s-3,3)):(bt(t,sf,t.bl_tree),Q(t,s-11,7));s=0,i=a,o===0?(c=138,f=3):a===o?(c=6,f=3):(c=7,f=4)}}function n0(t){var e;for(Qc(t,t.dyn_ltree,t.l_desc.max_code),Qc(t,t.dyn_dtree,t.d_desc.max_code),mi(t,t.bl_desc),e=yi-1;e>=3&&t.bl_tree[cf[e]*2+1]===0;e--);return t.opt_len+=3*(e+1)+5+5+4,e}function i0(t,e,r,n){var i;for(Q(t,e-257,5),Q(t,r-1,5),Q(t,n-4,4),i=0;i<n;i++)Q(t,t.bl_tree[cf[i]*2+1],3);tf(t,t.dyn_ltree,e-1),tf(t,t.dyn_dtree,r-1)}function a0(t){var e=4093624447,r;for(r=0;r<=31;r++,e>>>=1)if(e&1&&t.dyn_ltree[r*2]!==0)return Xc;if(t.dyn_ltree[18]!==0||t.dyn_ltree[20]!==0||t.dyn_ltree[26]!==0)return Yc;for(r=32;r<Je;r++)if(t.dyn_ltree[r*2]!==0)return Yc;return Xc}var ef=!1;function o0(t){ef||(e0(),ef=!0),t.l_desc=new hi(t.dyn_ltree,ff),t.d_desc=new hi(t.dyn_dtree,lf),t.bl_desc=new hi(t.bl_tree,uf),t.bi_buf=0,t.bi_valid=0,wf(t)}function gf(t,e,r,n){Q(t,(Wp<<1)+(n?1:0),3),r0(t,e,r,!0)}function s0(t){Q(t,rf<<1,3),bt(t,bi,Ot),Qp(t)}function c0(t,e,r,n){var i,a,o=0;t.level>0?(t.strm.data_type===qp&&(t.strm.data_type=a0(t)),mi(t,t.l_desc),mi(t,t.d_desc),o=n0(t),i=t.opt_len+3+7>>>3,a=t.static_len+3+7>>>3,a<=i&&(i=a)):i=a=r+5,r+4<=i&&e!==-1?gf(t,e,r,n):t.strategy===Hp||a===i?(Q(t,(rf<<1)+(n?1:0),3),Jc(t,Ot,Ze)):(Q(t,(Zp<<1)+(n?1:0),3),i0(t,t.l_desc.max_code+1,t.d_desc.max_code+1,o+1),Jc(t,t.dyn_ltree,t.dyn_dtree)),wf(t),n&&mf(t)}function f0(t,e,r){return t.pending_buf[t.d_buf+t.last_lit*2]=e>>>8&255,t.pending_buf[t.d_buf+t.last_lit*2+1]=e&255,t.pending_buf[t.l_buf+t.last_lit]=r&255,t.last_lit++,e===0?t.dyn_ltree[r*2]++:(t.matches++,e--,t.dyn_ltree[(Ye[r]+Je+1)*2]++,t.dyn_dtree[df(e)*2]++),t.last_lit===t.lit_bufsize-1}ke._tr_init=o0;ke._tr_stored_block=gf;ke._tr_flush_block=c0;ke._tr_tally=f0;ke._tr_align=s0});var vi=O((Uy,bf)=>{"use strict";function l0(t,e,r,n){for(var i=t&65535|0,a=t>>>16&65535|0,o=0;r!==0;){o=r>2e3?2e3:r,r-=o;do i=i+e[n++]|0,a=a+i|0;while(--o);i%=65521,a%=65521}return i|a<<16|0}bf.exports=l0});var xi=O((jy,_f)=>{"use strict";function u0(){for(var t,e=[],r=0;r<256;r++){t=r;for(var n=0;n<8;n++)t=t&1?3988292384^t>>>1:t>>>1;e[r]=t}return e}var d0=u0();function h0(t,e,r,n){var i=d0,a=n+r;t^=-1;for(var o=n;o<a;o++)t=t>>>8^i[(t^e[o])&255];return t^-1}_f.exports=h0});var Jr=O((My,vf)=>{"use strict";vf.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 Bf=O(xt=>{"use strict";var K=Rt(),it=yf(),Sf=vi(),jt=xi(),p0=Jr(),ne=0,w0=1,m0=3,Ht=4,xf=5,vt=0,Ef=1,at=-2,g0=-3,Ei=-5,y0=-1,b0=1,Qr=2,_0=3,v0=4,x0=0,E0=2,nn=8,k0=9,S0=15,A0=8,$0=29,R0=256,Si=R0+1+$0,O0=30,B0=19,I0=2*Si+1,T0=15,F=3,Gt=258,dt=Gt+F+1,C0=32,an=42,Ai=69,tn=73,en=91,rn=103,te=113,tr=666,G=1,er=2,ee=3,$e=4,F0=3;function zt(t,e){return t.msg=p0[e],e}function kf(t){return(t<<1)-(t>4?9:0)}function Lt(t){for(var e=t.length;--e>=0;)t[e]=0}function Mt(t){var e=t.state,r=e.pending;r>t.avail_out&&(r=t.avail_out),r!==0&&(K.arraySet(t.output,e.pending_buf,e.pending_out,r,t.next_out),t.next_out+=r,e.pending_out+=r,t.total_out+=r,t.avail_out-=r,e.pending-=r,e.pending===0&&(e.pending_out=0))}function W(t,e){it._tr_flush_block(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,Mt(t.strm)}function P(t,e){t.pending_buf[t.pending++]=e}function Qe(t,e){t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=e&255}function P0(t,e,r,n){var i=t.avail_in;return i>n&&(i=n),i===0?0:(t.avail_in-=i,K.arraySet(e,t.input,t.next_in,i,r),t.state.wrap===1?t.adler=Sf(t.adler,e,i,r):t.state.wrap===2&&(t.adler=jt(t.adler,e,i,r)),t.next_in+=i,t.total_in+=i,i)}function Af(t,e){var r=t.max_chain_length,n=t.strstart,i,a,o=t.prev_length,s=t.nice_match,c=t.strstart>t.w_size-dt?t.strstart-(t.w_size-dt):0,f=t.window,l=t.w_mask,u=t.prev,d=t.strstart+Gt,h=f[n+o-1],p=f[n+o];t.prev_length>=t.good_match&&(r>>=2),s>t.lookahead&&(s=t.lookahead);do if(i=e,!(f[i+o]!==p||f[i+o-1]!==h||f[i]!==f[n]||f[++i]!==f[n+1])){n+=2,i++;do;while(f[++n]===f[++i]&&f[++n]===f[++i]&&f[++n]===f[++i]&&f[++n]===f[++i]&&f[++n]===f[++i]&&f[++n]===f[++i]&&f[++n]===f[++i]&&f[++n]===f[++i]&&n<d);if(a=Gt-(d-n),n=d-Gt,a>o){if(t.match_start=e,o=a,a>=s)break;h=f[n+o-1],p=f[n+o]}}while((e=u[e&l])>c&&--r!==0);return o<=t.lookahead?o:t.lookahead}function re(t){var e=t.w_size,r,n,i,a,o;do{if(a=t.window_size-t.lookahead-t.strstart,t.strstart>=e+(e-dt)){K.arraySet(t.window,t.window,e,e,0),t.match_start-=e,t.strstart-=e,t.block_start-=e,n=t.hash_size,r=n;do i=t.head[--r],t.head[r]=i>=e?i-e:0;while(--n);n=e,r=n;do i=t.prev[--r],t.prev[r]=i>=e?i-e:0;while(--n);a+=e}if(t.strm.avail_in===0)break;if(n=P0(t.strm,t.window,t.strstart+t.lookahead,a),t.lookahead+=n,t.lookahead+t.insert>=F)for(o=t.strstart-t.insert,t.ins_h=t.window[o],t.ins_h=(t.ins_h<<t.hash_shift^t.window[o+1])&t.hash_mask;t.insert&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[o+F-1])&t.hash_mask,t.prev[o&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=o,o++,t.insert--,!(t.lookahead+t.insert<F)););}while(t.lookahead<dt&&t.strm.avail_in!==0)}function D0(t,e){var r=65535;for(r>t.pending_buf_size-5&&(r=t.pending_buf_size-5);;){if(t.lookahead<=1){if(re(t),t.lookahead===0&&e===ne)return G;if(t.lookahead===0)break}t.strstart+=t.lookahead,t.lookahead=0;var n=t.block_start+r;if((t.strstart===0||t.strstart>=n)&&(t.lookahead=t.strstart-n,t.strstart=n,W(t,!1),t.strm.avail_out===0)||t.strstart-t.block_start>=t.w_size-dt&&(W(t,!1),t.strm.avail_out===0))return G}return t.insert=0,e===Ht?(W(t,!0),t.strm.avail_out===0?ee:$e):(t.strstart>t.block_start&&(W(t,!1),t.strm.avail_out===0),G)}function ki(t,e){for(var r,n;;){if(t.lookahead<dt){if(re(t),t.lookahead<dt&&e===ne)return G;if(t.lookahead===0)break}if(r=0,t.lookahead>=F&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+F-1])&t.hash_mask,r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),r!==0&&t.strstart-r<=t.w_size-dt&&(t.match_length=Af(t,r)),t.match_length>=F)if(n=it._tr_tally(t,t.strstart-t.match_start,t.match_length-F),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=F){t.match_length--;do t.strstart++,t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+F-1])&t.hash_mask,r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart;while(--t.match_length!==0);t.strstart++}else t.strstart+=t.match_length,t.match_length=0,t.ins_h=t.window[t.strstart],t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+1])&t.hash_mask;else n=it._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(n&&(W(t,!1),t.strm.avail_out===0))return G}return t.insert=t.strstart<F-1?t.strstart:F-1,e===Ht?(W(t,!0),t.strm.avail_out===0?ee:$e):t.last_lit&&(W(t,!1),t.strm.avail_out===0)?G:er}function Se(t,e){for(var r,n,i;;){if(t.lookahead<dt){if(re(t),t.lookahead<dt&&e===ne)return G;if(t.lookahead===0)break}if(r=0,t.lookahead>=F&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+F-1])&t.hash_mask,r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=F-1,r!==0&&t.prev_length<t.max_lazy_match&&t.strstart-r<=t.w_size-dt&&(t.match_length=Af(t,r),t.match_length<=5&&(t.strategy===b0||t.match_length===F&&t.strstart-t.match_start>4096)&&(t.match_length=F-1)),t.prev_length>=F&&t.match_length<=t.prev_length){i=t.strstart+t.lookahead-F,n=it._tr_tally(t,t.strstart-1-t.prev_match,t.prev_length-F),t.lookahead-=t.prev_length-1,t.prev_length-=2;do++t.strstart<=i&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+F-1])&t.hash_mask,r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart);while(--t.prev_length!==0);if(t.match_available=0,t.match_length=F-1,t.strstart++,n&&(W(t,!1),t.strm.avail_out===0))return G}else if(t.match_available){if(n=it._tr_tally(t,0,t.window[t.strstart-1]),n&&W(t,!1),t.strstart++,t.lookahead--,t.strm.avail_out===0)return G}else t.match_available=1,t.strstart++,t.lookahead--}return t.match_available&&(n=it._tr_tally(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<F-1?t.strstart:F-1,e===Ht?(W(t,!0),t.strm.avail_out===0?ee:$e):t.last_lit&&(W(t,!1),t.strm.avail_out===0)?G:er}function N0(t,e){for(var r,n,i,a,o=t.window;;){if(t.lookahead<=Gt){if(re(t),t.lookahead<=Gt&&e===ne)return G;if(t.lookahead===0)break}if(t.match_length=0,t.lookahead>=F&&t.strstart>0&&(i=t.strstart-1,n=o[i],n===o[++i]&&n===o[++i]&&n===o[++i])){a=t.strstart+Gt;do;while(n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&i<a);t.match_length=Gt-(a-i),t.match_length>t.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=F?(r=it._tr_tally(t,1,t.match_length-F),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(r=it._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),r&&(W(t,!1),t.strm.avail_out===0))return G}return t.insert=0,e===Ht?(W(t,!0),t.strm.avail_out===0?ee:$e):t.last_lit&&(W(t,!1),t.strm.avail_out===0)?G:er}function U0(t,e){for(var r;;){if(t.lookahead===0&&(re(t),t.lookahead===0)){if(e===ne)return G;break}if(t.match_length=0,r=it._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,r&&(W(t,!1),t.strm.avail_out===0))return G}return t.insert=0,e===Ht?(W(t,!0),t.strm.avail_out===0?ee:$e):t.last_lit&&(W(t,!1),t.strm.avail_out===0)?G:er}function _t(t,e,r,n,i){this.good_length=t,this.max_lazy=e,this.nice_length=r,this.max_chain=n,this.func=i}var Ae;Ae=[new _t(0,0,0,0,D0),new _t(4,4,8,4,ki),new _t(4,5,16,8,ki),new _t(4,6,32,32,ki),new _t(4,4,16,16,Se),new _t(8,16,32,32,Se),new _t(8,16,128,128,Se),new _t(8,32,128,256,Se),new _t(32,128,258,1024,Se),new _t(32,258,258,4096,Se)];function j0(t){t.window_size=2*t.w_size,Lt(t.head),t.max_lazy_match=Ae[t.level].max_lazy,t.good_match=Ae[t.level].good_length,t.nice_match=Ae[t.level].nice_length,t.max_chain_length=Ae[t.level].max_chain,t.strstart=0,t.block_start=0,t.lookahead=0,t.insert=0,t.match_length=t.prev_length=F-1,t.match_available=0,t.ins_h=0}function M0(){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=nn,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 K.Buf16(I0*2),this.dyn_dtree=new K.Buf16((2*O0+1)*2),this.bl_tree=new K.Buf16((2*B0+1)*2),Lt(this.dyn_ltree),Lt(this.dyn_dtree),Lt(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new K.Buf16(T0+1),this.heap=new K.Buf16(2*Si+1),Lt(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new K.Buf16(2*Si+1),Lt(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 $f(t){var e;return!t||!t.state?zt(t,at):(t.total_in=t.total_out=0,t.data_type=E0,e=t.state,e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=e.wrap?an:te,t.adler=e.wrap===2?0:1,e.last_flush=ne,it._tr_init(e),vt)}function Rf(t){var e=$f(t);return e===vt&&j0(t.state),e}function L0(t,e){return!t||!t.state||t.state.wrap!==2?at:(t.state.gzhead=e,vt)}function Of(t,e,r,n,i,a){if(!t)return at;var o=1;if(e===y0&&(e=6),n<0?(o=0,n=-n):n>15&&(o=2,n-=16),i<1||i>k0||r!==nn||n<8||n>15||e<0||e>9||a<0||a>v0)return zt(t,at);n===8&&(n=9);var s=new M0;return t.state=s,s.strm=t,s.wrap=o,s.gzhead=null,s.w_bits=n,s.w_size=1<<s.w_bits,s.w_mask=s.w_size-1,s.hash_bits=i+7,s.hash_size=1<<s.hash_bits,s.hash_mask=s.hash_size-1,s.hash_shift=~~((s.hash_bits+F-1)/F),s.window=new K.Buf8(s.w_size*2),s.head=new K.Buf16(s.hash_size),s.prev=new K.Buf16(s.w_size),s.lit_bufsize=1<<i+6,s.pending_buf_size=s.lit_bufsize*4,s.pending_buf=new K.Buf8(s.pending_buf_size),s.d_buf=1*s.lit_bufsize,s.l_buf=3*s.lit_bufsize,s.level=e,s.strategy=a,s.method=r,Rf(t)}function G0(t,e){return Of(t,e,nn,S0,A0,x0)}function z0(t,e){var r,n,i,a;if(!t||!t.state||e>xf||e<0)return t?zt(t,at):at;if(n=t.state,!t.output||!t.input&&t.avail_in!==0||n.status===tr&&e!==Ht)return zt(t,t.avail_out===0?Ei:at);if(n.strm=t,r=n.last_flush,n.last_flush=e,n.status===an)if(n.wrap===2)t.adler=0,P(n,31),P(n,139),P(n,8),n.gzhead?(P(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),P(n,n.gzhead.time&255),P(n,n.gzhead.time>>8&255),P(n,n.gzhead.time>>16&255),P(n,n.gzhead.time>>24&255),P(n,n.level===9?2:n.strategy>=Qr||n.level<2?4:0),P(n,n.gzhead.os&255),n.gzhead.extra&&n.gzhead.extra.length&&(P(n,n.gzhead.extra.length&255),P(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(t.adler=jt(t.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=Ai):(P(n,0),P(n,0),P(n,0),P(n,0),P(n,0),P(n,n.level===9?2:n.strategy>=Qr||n.level<2?4:0),P(n,F0),n.status=te);else{var o=nn+(n.w_bits-8<<4)<<8,s=-1;n.strategy>=Qr||n.level<2?s=0:n.level<6?s=1:n.level===6?s=2:s=3,o|=s<<6,n.strstart!==0&&(o|=C0),o+=31-o%31,n.status=te,Qe(n,o),n.strstart!==0&&(Qe(n,t.adler>>>16),Qe(n,t.adler&65535)),t.adler=1}if(n.status===Ai)if(n.gzhead.extra){for(i=n.pending;n.gzindex<(n.gzhead.extra.length&65535)&&!(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>i&&(t.adler=jt(t.adler,n.pending_buf,n.pending-i,i)),Mt(t),i=n.pending,n.pending===n.pending_buf_size));)P(n,n.gzhead.extra[n.gzindex]&255),n.gzindex++;n.gzhead.hcrc&&n.pending>i&&(t.adler=jt(t.adler,n.pending_buf,n.pending-i,i)),n.gzindex===n.gzhead.extra.length&&(n.gzindex=0,n.status=tn)}else n.status=tn;if(n.status===tn)if(n.gzhead.name){i=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>i&&(t.adler=jt(t.adler,n.pending_buf,n.pending-i,i)),Mt(t),i=n.pending,n.pending===n.pending_buf_size)){a=1;break}n.gzindex<n.gzhead.name.length?a=n.gzhead.name.charCodeAt(n.gzindex++)&255:a=0,P(n,a)}while(a!==0);n.gzhead.hcrc&&n.pending>i&&(t.adler=jt(t.adler,n.pending_buf,n.pending-i,i)),a===0&&(n.gzindex=0,n.status=en)}else n.status=en;if(n.status===en)if(n.gzhead.comment){i=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>i&&(t.adler=jt(t.adler,n.pending_buf,n.pending-i,i)),Mt(t),i=n.pending,n.pending===n.pending_buf_size)){a=1;break}n.gzindex<n.gzhead.comment.length?a=n.gzhead.comment.charCodeAt(n.gzindex++)&255:a=0,P(n,a)}while(a!==0);n.gzhead.hcrc&&n.pending>i&&(t.adler=jt(t.adler,n.pending_buf,n.pending-i,i)),a===0&&(n.status=rn)}else n.status=rn;if(n.status===rn&&(n.gzhead.hcrc?(n.pending+2>n.pending_buf_size&&Mt(t),n.pending+2<=n.pending_buf_size&&(P(n,t.adler&255),P(n,t.adler>>8&255),t.adler=0,n.status=te)):n.status=te),n.pending!==0){if(Mt(t),t.avail_out===0)return n.last_flush=-1,vt}else if(t.avail_in===0&&kf(e)<=kf(r)&&e!==Ht)return zt(t,Ei);if(n.status===tr&&t.avail_in!==0)return zt(t,Ei);if(t.avail_in!==0||n.lookahead!==0||e!==ne&&n.status!==tr){var c=n.strategy===Qr?U0(n,e):n.strategy===_0?N0(n,e):Ae[n.level].func(n,e);if((c===ee||c===$e)&&(n.status=tr),c===G||c===ee)return t.avail_out===0&&(n.last_flush=-1),vt;if(c===er&&(e===w0?it._tr_align(n):e!==xf&&(it._tr_stored_block(n,0,0,!1),e===m0&&(Lt(n.head),n.lookahead===0&&(n.strstart=0,n.block_start=0,n.insert=0))),Mt(t),t.avail_out===0))return n.last_flush=-1,vt}return e!==Ht?vt:n.wrap<=0?Ef:(n.wrap===2?(P(n,t.adler&255),P(n,t.adler>>8&255),P(n,t.adler>>16&255),P(n,t.adler>>24&255),P(n,t.total_in&255),P(n,t.total_in>>8&255),P(n,t.total_in>>16&255),P(n,t.total_in>>24&255)):(Qe(n,t.adler>>>16),Qe(n,t.adler&65535)),Mt(t),n.wrap>0&&(n.wrap=-n.wrap),n.pending!==0?vt:Ef)}function H0(t){var e;return!t||!t.state?at:(e=t.state.status,e!==an&&e!==Ai&&e!==tn&&e!==en&&e!==rn&&e!==te&&e!==tr?zt(t,at):(t.state=null,e===te?zt(t,g0):vt))}function q0(t,e){var r=e.length,n,i,a,o,s,c,f,l;if(!t||!t.state||(n=t.state,o=n.wrap,o===2||o===1&&n.status!==an||n.lookahead))return at;for(o===1&&(t.adler=Sf(t.adler,e,r,0)),n.wrap=0,r>=n.w_size&&(o===0&&(Lt(n.head),n.strstart=0,n.block_start=0,n.insert=0),l=new K.Buf8(n.w_size),K.arraySet(l,e,r-n.w_size,n.w_size,0),e=l,r=n.w_size),s=t.avail_in,c=t.next_in,f=t.input,t.avail_in=r,t.next_in=0,t.input=e,re(n);n.lookahead>=F;){i=n.strstart,a=n.lookahead-(F-1);do n.ins_h=(n.ins_h<<n.hash_shift^n.window[i+F-1])&n.hash_mask,n.prev[i&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=i,i++;while(--a);n.strstart=i,n.lookahead=F-1,re(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=F-1,n.match_available=0,t.next_in=c,t.input=f,t.avail_in=s,n.wrap=o,vt}xt.deflateInit=G0;xt.deflateInit2=Of;xt.deflateReset=Rf;xt.deflateResetKeep=$f;xt.deflateSetHeader=L0;xt.deflate=z0;xt.deflateEnd=H0;xt.deflateSetDictionary=q0;xt.deflateInfo="pako deflate (from Nodeca project)"});var $i=O(Re=>{"use strict";var on=Rt(),If=!0,Tf=!0;try{String.fromCharCode.apply(null,[0])}catch{If=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{Tf=!1}var rr=new on.Buf8(256);for(Bt=0;Bt<256;Bt++)rr[Bt]=Bt>=252?6:Bt>=248?5:Bt>=240?4:Bt>=224?3:Bt>=192?2:1;var Bt;rr[254]=rr[254]=1;Re.string2buf=function(t){var e,r,n,i,a,o=t.length,s=0;for(i=0;i<o;i++)r=t.charCodeAt(i),(r&64512)===55296&&i+1<o&&(n=t.charCodeAt(i+1),(n&64512)===56320&&(r=65536+(r-55296<<10)+(n-56320),i++)),s+=r<128?1:r<2048?2:r<65536?3:4;for(e=new on.Buf8(s),a=0,i=0;a<s;i++)r=t.charCodeAt(i),(r&64512)===55296&&i+1<o&&(n=t.charCodeAt(i+1),(n&64512)===56320&&(r=65536+(r-55296<<10)+(n-56320),i++)),r<128?e[a++]=r:r<2048?(e[a++]=192|r>>>6,e[a++]=128|r&63):r<65536?(e[a++]=224|r>>>12,e[a++]=128|r>>>6&63,e[a++]=128|r&63):(e[a++]=240|r>>>18,e[a++]=128|r>>>12&63,e[a++]=128|r>>>6&63,e[a++]=128|r&63);return e};function Cf(t,e){if(e<65534&&(t.subarray&&Tf||!t.subarray&&If))return String.fromCharCode.apply(null,on.shrinkBuf(t,e));for(var r="",n=0;n<e;n++)r+=String.fromCharCode(t[n]);return r}Re.buf2binstring=function(t){return Cf(t,t.length)};Re.binstring2buf=function(t){for(var e=new on.Buf8(t.length),r=0,n=e.length;r<n;r++)e[r]=t.charCodeAt(r);return e};Re.buf2string=function(t,e){var r,n,i,a,o=e||t.length,s=new Array(o*2);for(n=0,r=0;r<o;){if(i=t[r++],i<128){s[n++]=i;continue}if(a=rr[i],a>4){s[n++]=65533,r+=a-1;continue}for(i&=a===2?31:a===3?15:7;a>1&&r<o;)i=i<<6|t[r++]&63,a--;if(a>1){s[n++]=65533;continue}i<65536?s[n++]=i:(i-=65536,s[n++]=55296|i>>10&1023,s[n++]=56320|i&1023)}return Cf(s,n)};Re.utf8border=function(t,e){var r;for(e=e||t.length,e>t.length&&(e=t.length),r=e-1;r>=0&&(t[r]&192)===128;)r--;return r<0||r===0?e:r+rr[t[r]]>e?r:e}});var Ri=O((zy,Ff)=>{"use strict";function W0(){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}Ff.exports=W0});var Uf=O(ar=>{"use strict";var nr=Bf(),ir=Rt(),Bi=$i(),Ii=Jr(),Z0=Ri(),Nf=Object.prototype.toString,V0=0,Oi=4,Oe=0,Pf=1,Df=2,X0=-1,Y0=0,K0=8;function ie(t){if(!(this instanceof ie))return new ie(t);this.options=ir.assign({level:X0,method:K0,chunkSize:16384,windowBits:15,memLevel:8,strategy:Y0,to:""},t||{});var e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Z0,this.strm.avail_out=0;var r=nr.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(r!==Oe)throw new Error(Ii[r]);if(e.header&&nr.deflateSetHeader(this.strm,e.header),e.dictionary){var n;if(typeof e.dictionary=="string"?n=Bi.string2buf(e.dictionary):Nf.call(e.dictionary)==="[object ArrayBuffer]"?n=new Uint8Array(e.dictionary):n=e.dictionary,r=nr.deflateSetDictionary(this.strm,n),r!==Oe)throw new Error(Ii[r]);this._dict_set=!0}}ie.prototype.push=function(t,e){var r=this.strm,n=this.options.chunkSize,i,a;if(this.ended)return!1;a=e===~~e?e:e===!0?Oi:V0,typeof t=="string"?r.input=Bi.string2buf(t):Nf.call(t)==="[object ArrayBuffer]"?r.input=new Uint8Array(t):r.input=t,r.next_in=0,r.avail_in=r.input.length;do{if(r.avail_out===0&&(r.output=new ir.Buf8(n),r.next_out=0,r.avail_out=n),i=nr.deflate(r,a),i!==Pf&&i!==Oe)return this.onEnd(i),this.ended=!0,!1;(r.avail_out===0||r.avail_in===0&&(a===Oi||a===Df))&&(this.options.to==="string"?this.onData(Bi.buf2binstring(ir.shrinkBuf(r.output,r.next_out))):this.onData(ir.shrinkBuf(r.output,r.next_out)))}while((r.avail_in>0||r.avail_out===0)&&i!==Pf);return a===Oi?(i=nr.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===Oe):(a===Df&&(this.onEnd(Oe),r.avail_out=0),!0)};ie.prototype.onData=function(t){this.chunks.push(t)};ie.prototype.onEnd=function(t){t===Oe&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=ir.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};function Ti(t,e){var r=new ie(e);if(r.push(t,!0),r.err)throw r.msg||Ii[r.err];return r.result}function J0(t,e){return e=e||{},e.raw=!0,Ti(t,e)}function Q0(t,e){return e=e||{},e.gzip=!0,Ti(t,e)}ar.Deflate=ie;ar.deflate=Ti;ar.deflateRaw=J0;ar.gzip=Q0});var Mf=O((qy,jf)=>{"use strict";var sn=30,tw=12;jf.exports=function(e,r){var n,i,a,o,s,c,f,l,u,d,h,p,w,y,b,E,S,A,m,$,g,x,_,R,k;n=e.state,i=e.next_in,R=e.input,a=i+(e.avail_in-5),o=e.next_out,k=e.output,s=o-(r-e.avail_out),c=o+(e.avail_out-257),f=n.dmax,l=n.wsize,u=n.whave,d=n.wnext,h=n.window,p=n.hold,w=n.bits,y=n.lencode,b=n.distcode,E=(1<<n.lenbits)-1,S=(1<<n.distbits)-1;t:do{w<15&&(p+=R[i++]<<w,w+=8,p+=R[i++]<<w,w+=8),A=y[p&E];e:for(;;){if(m=A>>>24,p>>>=m,w-=m,m=A>>>16&255,m===0)k[o++]=A&65535;else if(m&16){$=A&65535,m&=15,m&&(w<m&&(p+=R[i++]<<w,w+=8),$+=p&(1<<m)-1,p>>>=m,w-=m),w<15&&(p+=R[i++]<<w,w+=8,p+=R[i++]<<w,w+=8),A=b[p&S];r:for(;;){if(m=A>>>24,p>>>=m,w-=m,m=A>>>16&255,m&16){if(g=A&65535,m&=15,w<m&&(p+=R[i++]<<w,w+=8,w<m&&(p+=R[i++]<<w,w+=8)),g+=p&(1<<m)-1,g>f){e.msg="invalid distance too far back",n.mode=sn;break t}if(p>>>=m,w-=m,m=o-s,g>m){if(m=g-m,m>u&&n.sane){e.msg="invalid distance too far back",n.mode=sn;break t}if(x=0,_=h,d===0){if(x+=l-m,m<$){$-=m;do k[o++]=h[x++];while(--m);x=o-g,_=k}}else if(d<m){if(x+=l+d-m,m-=d,m<$){$-=m;do k[o++]=h[x++];while(--m);if(x=0,d<$){m=d,$-=m;do k[o++]=h[x++];while(--m);x=o-g,_=k}}}else if(x+=d-m,m<$){$-=m;do k[o++]=h[x++];while(--m);x=o-g,_=k}for(;$>2;)k[o++]=_[x++],k[o++]=_[x++],k[o++]=_[x++],$-=3;$&&(k[o++]=_[x++],$>1&&(k[o++]=_[x++]))}else{x=o-g;do k[o++]=k[x++],k[o++]=k[x++],k[o++]=k[x++],$-=3;while($>2);$&&(k[o++]=k[x++],$>1&&(k[o++]=k[x++]))}}else if((m&64)===0){A=b[(A&65535)+(p&(1<<m)-1)];continue r}else{e.msg="invalid distance code",n.mode=sn;break t}break}}else if((m&64)===0){A=y[(A&65535)+(p&(1<<m)-1)];continue e}else if(m&32){n.mode=tw;break t}else{e.msg="invalid literal/length code",n.mode=sn;break t}break}}while(i<a&&o<c);$=w>>3,i-=$,w-=$<<3,p&=(1<<w)-1,e.next_in=i,e.next_out=o,e.avail_in=i<a?5+(a-i):5-(i-a),e.avail_out=o<c?257+(c-o):257-(o-c),n.hold=p,n.bits=w}});var Zf=O((Wy,Wf)=>{"use strict";var Lf=Rt(),Be=15,Gf=852,zf=592,Hf=0,Ci=1,qf=2,ew=[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],rw=[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],nw=[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],iw=[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];Wf.exports=function(e,r,n,i,a,o,s,c){var f=c.bits,l=0,u=0,d=0,h=0,p=0,w=0,y=0,b=0,E=0,S=0,A,m,$,g,x,_=null,R=0,k,B=new Lf.Buf16(Be+1),N=new Lf.Buf16(Be+1),M=null,no=0,io,$r,Rr;for(l=0;l<=Be;l++)B[l]=0;for(u=0;u<i;u++)B[r[n+u]]++;for(p=f,h=Be;h>=1&&B[h]===0;h--);if(p>h&&(p=h),h===0)return a[o++]=1<<24|64<<16|0,a[o++]=1<<24|64<<16|0,c.bits=1,0;for(d=1;d<h&&B[d]===0;d++);for(p<d&&(p=d),b=1,l=1;l<=Be;l++)if(b<<=1,b-=B[l],b<0)return-1;if(b>0&&(e===Hf||h!==1))return-1;for(N[1]=0,l=1;l<Be;l++)N[l+1]=N[l]+B[l];for(u=0;u<i;u++)r[n+u]!==0&&(s[N[r[n+u]]++]=u);if(e===Hf?(_=M=s,k=19):e===Ci?(_=ew,R-=257,M=rw,no-=257,k=256):(_=nw,M=iw,k=-1),S=0,u=0,l=d,x=o,w=p,y=0,$=-1,E=1<<p,g=E-1,e===Ci&&E>Gf||e===qf&&E>zf)return 1;for(;;){io=l-y,s[u]<k?($r=0,Rr=s[u]):s[u]>k?($r=M[no+s[u]],Rr=_[R+s[u]]):($r=96,Rr=0),A=1<<l-y,m=1<<w,d=m;do m-=A,a[x+(S>>y)+m]=io<<24|$r<<16|Rr|0;while(m!==0);for(A=1<<l-1;S&A;)A>>=1;if(A!==0?(S&=A-1,S+=A):S=0,u++,--B[l]===0){if(l===h)break;l=r[n+s[u]]}if(l>p&&(S&g)!==$){for(y===0&&(y=p),x+=d,w=l-y,b=1<<w;w+y<h&&(b-=B[w+y],!(b<=0));)w++,b<<=1;if(E+=1<<w,e===Ci&&E>Gf||e===qf&&E>zf)return 1;$=S&g,a[$]=p<<24|w<<16|x-o|0}}return S!==0&&(a[x+S]=l-y<<24|64<<16|0),c.bits=p,0}});var Rl=O(ht=>{"use strict";var et=Rt(),ji=vi(),Et=xi(),aw=Mf(),or=Zf(),ow=0,bl=1,_l=2,Vf=4,sw=5,cn=6,ae=0,cw=1,fw=2,ot=-2,vl=-3,Mi=-4,lw=-5,Xf=8,xl=1,Yf=2,Kf=3,Jf=4,Qf=5,tl=6,el=7,rl=8,nl=9,il=10,un=11,It=12,Fi=13,al=14,Pi=15,ol=16,sl=17,cl=18,fl=19,fn=20,ln=21,ll=22,ul=23,dl=24,hl=25,pl=26,Di=27,wl=28,ml=29,j=30,Li=31,uw=32,dw=852,hw=592,pw=15,ww=pw;function gl(t){return(t>>>24&255)+(t>>>8&65280)+((t&65280)<<8)+((t&255)<<24)}function mw(){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 et.Buf16(320),this.work=new et.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function El(t){var e;return!t||!t.state?ot:(e=t.state,t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=e.wrap&1),e.mode=xl,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new et.Buf32(dw),e.distcode=e.distdyn=new et.Buf32(hw),e.sane=1,e.back=-1,ae)}function kl(t){var e;return!t||!t.state?ot:(e=t.state,e.wsize=0,e.whave=0,e.wnext=0,El(t))}function Sl(t,e){var r,n;return!t||!t.state||(n=t.state,e<0?(r=0,e=-e):(r=(e>>4)+1,e<48&&(e&=15)),e&&(e<8||e>15))?ot:(n.window!==null&&n.wbits!==e&&(n.window=null),n.wrap=r,n.wbits=e,kl(t))}function Al(t,e){var r,n;return t?(n=new mw,t.state=n,n.window=null,r=Sl(t,e),r!==ae&&(t.state=null),r):ot}function gw(t){return Al(t,ww)}var yl=!0,Ni,Ui;function yw(t){if(yl){var e;for(Ni=new et.Buf32(512),Ui=new et.Buf32(32),e=0;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(or(bl,t.lens,0,288,Ni,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;or(_l,t.lens,0,32,Ui,0,t.work,{bits:5}),yl=!1}t.lencode=Ni,t.lenbits=9,t.distcode=Ui,t.distbits=5}function $l(t,e,r,n){var i,a=t.state;return a.window===null&&(a.wsize=1<<a.wbits,a.wnext=0,a.whave=0,a.window=new et.Buf8(a.wsize)),n>=a.wsize?(et.arraySet(a.window,e,r-a.wsize,a.wsize,0),a.wnext=0,a.whave=a.wsize):(i=a.wsize-a.wnext,i>n&&(i=n),et.arraySet(a.window,e,r-n,i,a.wnext),n-=i,n?(et.arraySet(a.window,e,r-n,n,0),a.wnext=n,a.whave=a.wsize):(a.wnext+=i,a.wnext===a.wsize&&(a.wnext=0),a.whave<a.wsize&&(a.whave+=i))),0}function bw(t,e){var r,n,i,a,o,s,c,f,l,u,d,h,p,w,y=0,b,E,S,A,m,$,g,x,_=new et.Buf8(4),R,k,B=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!t||!t.state||!t.output||!t.input&&t.avail_in!==0)return ot;r=t.state,r.mode===It&&(r.mode=Fi),o=t.next_out,i=t.output,c=t.avail_out,a=t.next_in,n=t.input,s=t.avail_in,f=r.hold,l=r.bits,u=s,d=c,x=ae;t:for(;;)switch(r.mode){case xl:if(r.wrap===0){r.mode=Fi;break}for(;l<16;){if(s===0)break t;s--,f+=n[a++]<<l,l+=8}if(r.wrap&2&&f===35615){r.check=0,_[0]=f&255,_[1]=f>>>8&255,r.check=Et(r.check,_,2,0),f=0,l=0,r.mode=Yf;break}if(r.flags=0,r.head&&(r.head.done=!1),!(r.wrap&1)||(((f&255)<<8)+(f>>8))%31){t.msg="incorrect header check",r.mode=j;break}if((f&15)!==Xf){t.msg="unknown compression method",r.mode=j;break}if(f>>>=4,l-=4,g=(f&15)+8,r.wbits===0)r.wbits=g;else if(g>r.wbits){t.msg="invalid window size",r.mode=j;break}r.dmax=1<<g,t.adler=r.check=1,r.mode=f&512?il:It,f=0,l=0;break;case Yf:for(;l<16;){if(s===0)break t;s--,f+=n[a++]<<l,l+=8}if(r.flags=f,(r.flags&255)!==Xf){t.msg="unknown compression method",r.mode=j;break}if(r.flags&57344){t.msg="unknown header flags set",r.mode=j;break}r.head&&(r.head.text=f>>8&1),r.flags&512&&(_[0]=f&255,_[1]=f>>>8&255,r.check=Et(r.check,_,2,0)),f=0,l=0,r.mode=Kf;case Kf:for(;l<32;){if(s===0)break t;s--,f+=n[a++]<<l,l+=8}r.head&&(r.head.time=f),r.flags&512&&(_[0]=f&255,_[1]=f>>>8&255,_[2]=f>>>16&255,_[3]=f>>>24&255,r.check=Et(r.check,_,4,0)),f=0,l=0,r.mode=Jf;case Jf:for(;l<16;){if(s===0)break t;s--,f+=n[a++]<<l,l+=8}r.head&&(r.head.xflags=f&255,r.head.os=f>>8),r.flags&512&&(_[0]=f&255,_[1]=f>>>8&255,r.check=Et(r.check,_,2,0)),f=0,l=0,r.mode=Qf;case Qf:if(r.flags&1024){for(;l<16;){if(s===0)break t;s--,f+=n[a++]<<l,l+=8}r.length=f,r.head&&(r.head.extra_len=f),r.flags&512&&(_[0]=f&255,_[1]=f>>>8&255,r.check=Et(r.check,_,2,0)),f=0,l=0}else r.head&&(r.head.extra=null);r.mode=tl;case tl:if(r.flags&1024&&(h=r.length,h>s&&(h=s),h&&(r.head&&(g=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Array(r.head.extra_len)),et.arraySet(r.head.extra,n,a,h,g)),r.flags&512&&(r.check=Et(r.check,n,h,a)),s-=h,a+=h,r.length-=h),r.length))break t;r.length=0,r.mode=el;case el:if(r.flags&2048){if(s===0)break t;h=0;do g=n[a+h++],r.head&&g&&r.length<65536&&(r.head.name+=String.fromCharCode(g));while(g&&h<s);if(r.flags&512&&(r.check=Et(r.check,n,h,a)),s-=h,a+=h,g)break t}else r.head&&(r.head.name=null);r.length=0,r.mode=rl;case rl:if(r.flags&4096){if(s===0)break t;h=0;do g=n[a+h++],r.head&&g&&r.length<65536&&(r.head.comment+=String.fromCharCode(g));while(g&&h<s);if(r.flags&512&&(r.check=Et(r.check,n,h,a)),s-=h,a+=h,g)break t}else r.head&&(r.head.comment=null);r.mode=nl;case nl:if(r.flags&512){for(;l<16;){if(s===0)break t;s--,f+=n[a++]<<l,l+=8}if(f!==(r.check&65535)){t.msg="header crc mismatch",r.mode=j;break}f=0,l=0}r.head&&(r.head.hcrc=r.flags>>9&1,r.head.done=!0),t.adler=r.check=0,r.mode=It;break;case il:for(;l<32;){if(s===0)break t;s--,f+=n[a++]<<l,l+=8}t.adler=r.check=gl(f),f=0,l=0,r.mode=un;case un:if(r.havedict===0)return t.next_out=o,t.avail_out=c,t.next_in=a,t.avail_in=s,r.hold=f,r.bits=l,fw;t.adler=r.check=1,r.mode=It;case It:if(e===sw||e===cn)break t;case Fi:if(r.last){f>>>=l&7,l-=l&7,r.mode=Di;break}for(;l<3;){if(s===0)break t;s--,f+=n[a++]<<l,l+=8}switch(r.last=f&1,f>>>=1,l-=1,f&3){case 0:r.mode=al;break;case 1:if(yw(r),r.mode=fn,e===cn){f>>>=2,l-=2;break t}break;case 2:r.mode=sl;break;case 3:t.msg="invalid block type",r.mode=j}f>>>=2,l-=2;break;case al:for(f>>>=l&7,l-=l&7;l<32;){if(s===0)break t;s--,f+=n[a++]<<l,l+=8}if((f&65535)!==(f>>>16^65535)){t.msg="invalid stored block lengths",r.mode=j;break}if(r.length=f&65535,f=0,l=0,r.mode=Pi,e===cn)break t;case Pi:r.mode=ol;case ol:if(h=r.length,h){if(h>s&&(h=s),h>c&&(h=c),h===0)break t;et.arraySet(i,n,a,h,o),s-=h,a+=h,c-=h,o+=h,r.length-=h;break}r.mode=It;break;case sl:for(;l<14;){if(s===0)break t;s--,f+=n[a++]<<l,l+=8}if(r.nlen=(f&31)+257,f>>>=5,l-=5,r.ndist=(f&31)+1,f>>>=5,l-=5,r.ncode=(f&15)+4,f>>>=4,l-=4,r.nlen>286||r.ndist>30){t.msg="too many length or distance symbols",r.mode=j;break}r.have=0,r.mode=cl;case cl:for(;r.have<r.ncode;){for(;l<3;){if(s===0)break t;s--,f+=n[a++]<<l,l+=8}r.lens[B[r.have++]]=f&7,f>>>=3,l-=3}for(;r.have<19;)r.lens[B[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,R={bits:r.lenbits},x=or(ow,r.lens,0,19,r.lencode,0,r.work,R),r.lenbits=R.bits,x){t.msg="invalid code lengths set",r.mode=j;break}r.have=0,r.mode=fl;case fl:for(;r.have<r.nlen+r.ndist;){for(;y=r.lencode[f&(1<<r.lenbits)-1],b=y>>>24,E=y>>>16&255,S=y&65535,!(b<=l);){if(s===0)break t;s--,f+=n[a++]<<l,l+=8}if(S<16)f>>>=b,l-=b,r.lens[r.have++]=S;else{if(S===16){for(k=b+2;l<k;){if(s===0)break t;s--,f+=n[a++]<<l,l+=8}if(f>>>=b,l-=b,r.have===0){t.msg="invalid bit length repeat",r.mode=j;break}g=r.lens[r.have-1],h=3+(f&3),f>>>=2,l-=2}else if(S===17){for(k=b+3;l<k;){if(s===0)break t;s--,f+=n[a++]<<l,l+=8}f>>>=b,l-=b,g=0,h=3+(f&7),f>>>=3,l-=3}else{for(k=b+7;l<k;){if(s===0)break t;s--,f+=n[a++]<<l,l+=8}f>>>=b,l-=b,g=0,h=11+(f&127),f>>>=7,l-=7}if(r.have+h>r.nlen+r.ndist){t.msg="invalid bit length repeat",r.mode=j;break}for(;h--;)r.lens[r.have++]=g}}if(r.mode===j)break;if(r.lens[256]===0){t.msg="invalid code -- missing end-of-block",r.mode=j;break}if(r.lenbits=9,R={bits:r.lenbits},x=or(bl,r.lens,0,r.nlen,r.lencode,0,r.work,R),r.lenbits=R.bits,x){t.msg="invalid literal/lengths set",r.mode=j;break}if(r.distbits=6,r.distcode=r.distdyn,R={bits:r.distbits},x=or(_l,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,R),r.distbits=R.bits,x){t.msg="invalid distances set",r.mode=j;break}if(r.mode=fn,e===cn)break t;case fn:r.mode=ln;case ln:if(s>=6&&c>=258){t.next_out=o,t.avail_out=c,t.next_in=a,t.avail_in=s,r.hold=f,r.bits=l,aw(t,d),o=t.next_out,i=t.output,c=t.avail_out,a=t.next_in,n=t.input,s=t.avail_in,f=r.hold,l=r.bits,r.mode===It&&(r.back=-1);break}for(r.back=0;y=r.lencode[f&(1<<r.lenbits)-1],b=y>>>24,E=y>>>16&255,S=y&65535,!(b<=l);){if(s===0)break t;s--,f+=n[a++]<<l,l+=8}if(E&&(E&240)===0){for(A=b,m=E,$=S;y=r.lencode[$+((f&(1<<A+m)-1)>>A)],b=y>>>24,E=y>>>16&255,S=y&65535,!(A+b<=l);){if(s===0)break t;s--,f+=n[a++]<<l,l+=8}f>>>=A,l-=A,r.back+=A}if(f>>>=b,l-=b,r.back+=b,r.length=S,E===0){r.mode=pl;break}if(E&32){r.back=-1,r.mode=It;break}if(E&64){t.msg="invalid literal/length code",r.mode=j;break}r.extra=E&15,r.mode=ll;case ll:if(r.extra){for(k=r.extra;l<k;){if(s===0)break t;s--,f+=n[a++]<<l,l+=8}r.length+=f&(1<<r.extra)-1,f>>>=r.extra,l-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=ul;case ul:for(;y=r.distcode[f&(1<<r.distbits)-1],b=y>>>24,E=y>>>16&255,S=y&65535,!(b<=l);){if(s===0)break t;s--,f+=n[a++]<<l,l+=8}if((E&240)===0){for(A=b,m=E,$=S;y=r.distcode[$+((f&(1<<A+m)-1)>>A)],b=y>>>24,E=y>>>16&255,S=y&65535,!(A+b<=l);){if(s===0)break t;s--,f+=n[a++]<<l,l+=8}f>>>=A,l-=A,r.back+=A}if(f>>>=b,l-=b,r.back+=b,E&64){t.msg="invalid distance code",r.mode=j;break}r.offset=S,r.extra=E&15,r.mode=dl;case dl:if(r.extra){for(k=r.extra;l<k;){if(s===0)break t;s--,f+=n[a++]<<l,l+=8}r.offset+=f&(1<<r.extra)-1,f>>>=r.extra,l-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){t.msg="invalid distance too far back",r.mode=j;break}r.mode=hl;case hl:if(c===0)break t;if(h=d-c,r.offset>h){if(h=r.offset-h,h>r.whave&&r.sane){t.msg="invalid distance too far back",r.mode=j;break}h>r.wnext?(h-=r.wnext,p=r.wsize-h):p=r.wnext-h,h>r.length&&(h=r.length),w=r.window}else w=i,p=o-r.offset,h=r.length;h>c&&(h=c),c-=h,r.length-=h;do i[o++]=w[p++];while(--h);r.length===0&&(r.mode=ln);break;case pl:if(c===0)break t;i[o++]=r.length,c--,r.mode=ln;break;case Di:if(r.wrap){for(;l<32;){if(s===0)break t;s--,f|=n[a++]<<l,l+=8}if(d-=c,t.total_out+=d,r.total+=d,d&&(t.adler=r.check=r.flags?Et(r.check,i,d,o-d):ji(r.check,i,d,o-d)),d=c,(r.flags?f:gl(f))!==r.check){t.msg="incorrect data check",r.mode=j;break}f=0,l=0}r.mode=wl;case wl:if(r.wrap&&r.flags){for(;l<32;){if(s===0)break t;s--,f+=n[a++]<<l,l+=8}if(f!==(r.total&4294967295)){t.msg="incorrect length check",r.mode=j;break}f=0,l=0}r.mode=ml;case ml:x=cw;break t;case j:x=vl;break t;case Li:return Mi;case uw:default:return ot}return t.next_out=o,t.avail_out=c,t.next_in=a,t.avail_in=s,r.hold=f,r.bits=l,(r.wsize||d!==t.avail_out&&r.mode<j&&(r.mode<Di||e!==Vf))&&$l(t,t.output,t.next_out,d-t.avail_out)?(r.mode=Li,Mi):(u-=t.avail_in,d-=t.avail_out,t.total_in+=u,t.total_out+=d,r.total+=d,r.wrap&&d&&(t.adler=r.check=r.flags?Et(r.check,i,d,t.next_out-d):ji(r.check,i,d,t.next_out-d)),t.data_type=r.bits+(r.last?64:0)+(r.mode===It?128:0)+(r.mode===fn||r.mode===Pi?256:0),(u===0&&d===0||e===Vf)&&x===ae&&(x=lw),x)}function _w(t){if(!t||!t.state)return ot;var e=t.state;return e.window&&(e.window=null),t.state=null,ae}function vw(t,e){var r;return!t||!t.state||(r=t.state,(r.wrap&2)===0)?ot:(r.head=e,e.done=!1,ae)}function xw(t,e){var r=e.length,n,i,a;return!t||!t.state||(n=t.state,n.wrap!==0&&n.mode!==un)?ot:n.mode===un&&(i=1,i=ji(i,e,r,0),i!==n.check)?vl:(a=$l(t,e,r,r),a?(n.mode=Li,Mi):(n.havedict=1,ae))}ht.inflateReset=kl;ht.inflateReset2=Sl;ht.inflateResetKeep=El;ht.inflateInit=gw;ht.inflateInit2=Al;ht.inflate=bw;ht.inflateEnd=_w;ht.inflateGetHeader=vw;ht.inflateSetDictionary=xw;ht.inflateInfo="pako inflate (from Nodeca project)"});var Gi=O((Vy,Ol)=>{"use strict";Ol.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 Il=O((Xy,Bl)=>{"use strict";function Ew(){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}Bl.exports=Ew});var Cl=O(cr=>{"use strict";var Ie=Rl(),sr=Rt(),dn=$i(),L=Gi(),zi=Jr(),kw=Ri(),Sw=Il(),Tl=Object.prototype.toString;function oe(t){if(!(this instanceof oe))return new oe(t);this.options=sr.assign({chunkSize:16384,windowBits:0,to:""},t||{});var e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,e.windowBits===0&&(e.windowBits=-15)),e.windowBits>=0&&e.windowBits<16&&!(t&&t.windowBits)&&(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&(e.windowBits&15)===0&&(e.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new kw,this.strm.avail_out=0;var r=Ie.inflateInit2(this.strm,e.windowBits);if(r!==L.Z_OK)throw new Error(zi[r]);if(this.header=new Sw,Ie.inflateGetHeader(this.strm,this.header),e.dictionary&&(typeof e.dictionary=="string"?e.dictionary=dn.string2buf(e.dictionary):Tl.call(e.dictionary)==="[object ArrayBuffer]"&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(r=Ie.inflateSetDictionary(this.strm,e.dictionary),r!==L.Z_OK)))throw new Error(zi[r])}oe.prototype.push=function(t,e){var r=this.strm,n=this.options.chunkSize,i=this.options.dictionary,a,o,s,c,f,l=!1;if(this.ended)return!1;o=e===~~e?e:e===!0?L.Z_FINISH:L.Z_NO_FLUSH,typeof t=="string"?r.input=dn.binstring2buf(t):Tl.call(t)==="[object ArrayBuffer]"?r.input=new Uint8Array(t):r.input=t,r.next_in=0,r.avail_in=r.input.length;do{if(r.avail_out===0&&(r.output=new sr.Buf8(n),r.next_out=0,r.avail_out=n),a=Ie.inflate(r,L.Z_NO_FLUSH),a===L.Z_NEED_DICT&&i&&(a=Ie.inflateSetDictionary(this.strm,i)),a===L.Z_BUF_ERROR&&l===!0&&(a=L.Z_OK,l=!1),a!==L.Z_STREAM_END&&a!==L.Z_OK)return this.onEnd(a),this.ended=!0,!1;r.next_out&&(r.avail_out===0||a===L.Z_STREAM_END||r.avail_in===0&&(o===L.Z_FINISH||o===L.Z_SYNC_FLUSH))&&(this.options.to==="string"?(s=dn.utf8border(r.output,r.next_out),c=r.next_out-s,f=dn.buf2string(r.output,s),r.next_out=c,r.avail_out=n-c,c&&sr.arraySet(r.output,r.output,s,c,0),this.onData(f)):this.onData(sr.shrinkBuf(r.output,r.next_out))),r.avail_in===0&&r.avail_out===0&&(l=!0)}while((r.avail_in>0||r.avail_out===0)&&a!==L.Z_STREAM_END);return a===L.Z_STREAM_END&&(o=L.Z_FINISH),o===L.Z_FINISH?(a=Ie.inflateEnd(this.strm),this.onEnd(a),this.ended=!0,a===L.Z_OK):(o===L.Z_SYNC_FLUSH&&(this.onEnd(L.Z_OK),r.avail_out=0),!0)};oe.prototype.onData=function(t){this.chunks.push(t)};oe.prototype.onEnd=function(t){t===L.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=sr.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};function Hi(t,e){var r=new oe(e);if(r.push(t,!0),r.err)throw r.msg||zi[r.err];return r.result}function Aw(t,e){return e=e||{},e.raw=!0,Hi(t,e)}cr.Inflate=oe;cr.inflate=Hi;cr.inflateRaw=Aw;cr.ungzip=Hi});var Dl=O((Ky,Pl)=>{"use strict";var $w=Rt().assign,Rw=Uf(),Ow=Cl(),Bw=Gi(),Fl={};$w(Fl,Rw,Ow,Bw);Pl.exports=Fl});var jl=O((Jy,Ul)=>{"use strict";var Nl=(t,e)=>function(...r){let n=e.promiseModule;return new n((i,a)=>{e.multiArgs?r.push((...o)=>{e.errorFirst?o[0]?a(o):(o.shift(),i(o)):i(o)}):e.errorFirst?r.push((o,s)=>{o?a(o):i(s)}):r.push(i),t.apply(this,r)})};Ul.exports=(t,e)=>{e=Object.assign({exclude:[/.+(Sync|Stream)$/],errorFirst:!0,promiseModule:Promise},e);let r=typeof t;if(!(t!==null&&(r==="object"||r==="function")))throw new TypeError(`Expected \`input\` to be a \`Function\` or \`Object\`, got \`${t===null?"null":r}\``);let n=a=>{let o=s=>typeof s=="string"?a===s:s.test(a);return e.include?e.include.some(o):!e.exclude.some(o)},i;r==="function"?i=function(...a){return e.excludeMain?t(...a):Nl(t,e).apply(this,a)}:i=Object.create(Object.getPrototypeOf(t));for(let a in t){let o=t[a];i[a]=typeof o=="function"&&n(a)?Nl(o,e):o}return i}});var Vl=O((Qy,Zl)=>{function Ml(t){return Array.isArray(t)?t:[t]}var Zi="",Ll=" ",qi="\\",Iw=/^\s+$/,Tw=/(?:[^\\]|^)\\$/,Cw=/^\\!/,Fw=/^\\#/,Pw=/\r?\n/g,Dw=/^\.*\/|^\.+$/,Wi="/",Hl="node-ignore";typeof Symbol<"u"&&(Hl=Symbol.for("node-ignore"));var Gl=Hl,Nw=(t,e,r)=>Object.defineProperty(t,e,{value:r}),Uw=/([0-z])-([0-z])/g,ql=()=>!1,jw=t=>t.replace(Uw,(e,r,n)=>r.charCodeAt(0)<=n.charCodeAt(0)?e:Zi),Mw=t=>{let{length:e}=t;return t.slice(0,e-e%2)},Lw=[[/^\uFEFF/,()=>Zi],[/((?:\\\\)*?)(\\?\s+)$/,(t,e,r)=>e+(r.indexOf("\\")===0?Ll:Zi)],[/(\\+?)\s/g,(t,e)=>{let{length:r}=e;return e.slice(0,r-r%2)+Ll}],[/[\\$.|*+(){^]/g,t=>`\\${t}`],[/(?!\\)\?/g,()=>"[^/]"],[/^\//,()=>"^"],[/\//g,()=>"\\/"],[/^\^*\\\*\\\*\\\//,()=>"^(?:.*\\/)?"],[/^(?=[^^])/,function(){return/\/(?!$)/.test(this)?"^":"(?:^|\\/)"}],[/\\\/\\\*\\\*(?=\\\/|$)/g,(t,e,r)=>e+6<r.length?"(?:\\/[^\\/]+)*":"\\/.+"],[/(^|[^\\]+)(\\\*)+(?=.+)/g,(t,e,r)=>{let n=r.replace(/\\\*/g,"[^\\/]*");return e+n}],[/\\\\\\(?=[$.|*+(){^])/g,()=>qi],[/\\\\/g,()=>qi],[/(\\)?\[([^\]/]*?)(\\*)($|\])/g,(t,e,r,n,i)=>e===qi?`\\[${r}${Mw(n)}${i}`:i==="]"&&n.length%2===0?`[${jw(r)}${n}]`:"[]"],[/(?:[^*])$/,t=>/\/$/.test(t)?`${t}$`:`${t}(?=$|\\/$)`],[/(\^|\\\/)?\\\*$/,(t,e)=>`${e?`${e}[^/]+`:"[^/]*"}(?=$|\\/$)`]],zl=Object.create(null),Gw=(t,e)=>{let r=zl[t];return r||(r=Lw.reduce((n,[i,a])=>n.replace(i,a.bind(t)),t),zl[t]=r),e?new RegExp(r,"i"):new RegExp(r)},Yi=t=>typeof t=="string",zw=t=>t&&Yi(t)&&!Iw.test(t)&&!Tw.test(t)&&t.indexOf("#")!==0,Hw=t=>t.split(Pw),Vi=class{constructor(e,r,n,i){this.origin=e,this.pattern=r,this.negative=n,this.regex=i}},qw=(t,e)=>{let r=t,n=!1;t.indexOf("!")===0&&(n=!0,t=t.substr(1)),t=t.replace(Cw,"!").replace(Fw,"#");let i=Gw(t,e);return new Vi(r,t,n,i)},Ww=(t,e)=>{throw new e(t)},Tt=(t,e,r)=>Yi(t)?t?Tt.isNotRelative(t)?r(`path should be a \`path.relative()\`d string, but got "${e}"`,RangeError):!0:r("path must not be empty",TypeError):r(`path must be a string, but got \`${e}\``,TypeError),Wl=t=>Dw.test(t);Tt.isNotRelative=Wl;Tt.convert=t=>t;var Xi=class{constructor({ignorecase:e=!0,ignoreCase:r=e,allowRelativePaths:n=!1}={}){Nw(this,Gl,!0),this._rules=[],this._ignoreCase=r,this._allowRelativePaths=n,this._initCache()}_initCache(){this._ignoreCache=Object.create(null),this._testCache=Object.create(null)}_addPattern(e){if(e&&e[Gl]){this._rules=this._rules.concat(e._rules),this._added=!0;return}if(zw(e)){let r=qw(e,this._ignoreCase);this._added=!0,this._rules.push(r)}}add(e){return this._added=!1,Ml(Yi(e)?Hw(e):e).forEach(this._addPattern,this),this._added&&this._initCache(),this}addPattern(e){return this.add(e)}_testOne(e,r){let n=!1,i=!1;return this._rules.forEach(a=>{let{negative:o}=a;if(i===o&&n!==i||o&&!n&&!i&&!r)return;a.regex.test(e)&&(n=!o,i=o)}),{ignored:n,unignored:i}}_test(e,r,n,i){let a=e&&Tt.convert(e);return Tt(a,e,this._allowRelativePaths?ql:Ww),this._t(a,r,n,i)}_t(e,r,n,i){if(e in r)return r[e];if(i||(i=e.split(Wi)),i.pop(),!i.length)return r[e]=this._testOne(e,n);let a=this._t(i.join(Wi)+Wi,r,n,i);return r[e]=a.ignored?a:this._testOne(e,n)}ignores(e){return this._test(e,this._ignoreCache,!1).ignored}createFilter(){return e=>!this.ignores(e)}filter(e){return Ml(e).filter(this.createFilter())}test(e){return this._test(e,this._testCache,!0)}},hn=t=>new Xi(t),Zw=t=>Tt(t&&Tt.convert(t),t,ql);hn.isPathValid=Zw;hn.default=hn;Zl.exports=hn;if(typeof process<"u"&&(process.env&&process.env.IGNORE_TEST_WIN32||process.platform==="win32")){let t=r=>/^\\\\\?\\/.test(r)||/["<>|\u0000-\u001F]+/u.test(r)?r:r.replace(/\\/g,"/");Tt.convert=t;let e=/^[a-z]:\//i;Tt.isNotRelative=r=>e.test(r)||Wl(r)}});var Yl=O((tb,Xl)=>{Xl.exports=function(t,e){var r=t,n=e,i=r.length,a=n.length,o=!1,s=null,c=i+1,f=[],l=[],u=[],d="",h=-1,p=0,w=1,y,b,E=function(){i>=a&&(y=r,b=i,r=n,n=y,i=a,a=b,o=!0,c=i+1)},S=function(g,x,_){return{x:g,y:x,k:_}},A=function(g,x){return{elem:g,t:x}},m=function(g,x,_){var R,k,B;for(x>_?R=f[g-1+c]:R=f[g+1+c],B=Math.max(x,_),k=B-g;k<i&&B<a&&r[k]===n[B];)++k,++B;return f[g+c]=l.length,l[l.length]=new S(k,B,R),B},$=function(g){var x,_,R,k,B;for(x=_=1,R=k=0,B=g.length-1;B>=0;--B)for(;R<g[B].x||k<g[B].y;)g[B].y-g[B].x>k-R?(o?u[u.length]=new A(n[k],h):u[u.length]=new A(n[k],w),++_,++k):g[B].y-g[B].x<k-R?(o?u[u.length]=new A(r[R],w):u[u.length]=new A(r[R],h),++x,++R):(u[u.length]=new A(r[R],p),d+=r[R],++x,++_,++R,++k)};return E(),{SES_DELETE:-1,SES_COMMON:0,SES_ADD:1,editdistance:function(){return s},getlcs:function(){return d},getses:function(){return u},compose:function(){var g,x,_,R,k,B,N,M;for(g=a-i,x=i+a+3,_={},N=0;N<x;++N)_[N]=-1,f[N]=-1;R=-1;do{for(++R,M=-R;M<=g-1;++M)_[M+c]=m(M,_[M-1+c]+1,_[M+1+c]);for(M=g+R;M>=g+1;--M)_[M+c]=m(M,_[M-1+c]+1,_[M+1+c]);_[g+c]=m(g,_[g-1+c]+1,_[g+1+c])}while(_[g+c]!==a);for(s=g+2*R,k=f[g+c],B=[];k!==-1;)B[B.length]=new S(l[k].x,l[k].y,null),k=l[k].k;$(B)}}}});var Ql=O((eb,Jl)=>{var Vw=Yl();function Xw(t,e){var r=new Vw(t,e);r.compose();for(var n=r.getses(),i,a,o=t.length-1,s=e.length-1,c=n.length-1;c>=0;--c)n[c].t===r.SES_COMMON?(a?(a.chain={file1index:o,file2index:s,chain:null},a=a.chain):(i={file1index:o,file2index:s,chain:null},a=i),o--,s--):n[c].t===r.SES_DELETE?o--:n[c].t===r.SES_ADD&&s--;var f={file1index:-1,file2index:-1,chain:null};return a?(a.chain=f,i):f}function Kl(t,e){for(var r=[],n=t.length,i=e.length,a=Xw(t,e);a!==null;a=a.chain){var o=n-a.file1index-1,s=i-a.file2index-1;n=a.file1index,i=a.file2index,(o||s)&&r.push({file1:[n+1,o],file2:[i+1,s]})}return r.reverse(),r}function Yw(t,e,r){var n,i=Kl(e,t),a=Kl(e,r),o=[];function s(N,M){o.push([N.file1[0],M,N.file1[1],N.file2[0],N.file2[1]])}for(n=0;n<i.length;n++)s(i[n],0);for(n=0;n<a.length;n++)s(a[n],2);o.sort(function(N,M){return N[0]-M[0]});var c=[],f=0;function l(N){N>f&&(c.push([1,f,N-f]),f=N)}for(var u=0;u<o.length;u++){for(var d=u,h=o[u],p=h[0],w=p+h[2];u<o.length-1;){var y=o[u+1],b=y[0];if(b>w)break;w=Math.max(w,b+y[2]),u++}if(l(p),d==u)h[4]>0&&c.push([h[1],h[3],h[4]]);else{var E={0:[t.length,-1,e.length,-1],2:[r.length,-1,e.length,-1]};for(n=d;n<=u;n++){h=o[n];var S=h[1],A=E[S],m=h[0],$=m+h[2],g=h[3],x=g+h[4];A[0]=Math.min(g,A[0]),A[1]=Math.max(x,A[1]),A[2]=Math.min(m,A[2]),A[3]=Math.max($,A[3])}var _=E[0][0]+(p-E[0][2]),R=E[0][1]+(w-E[0][3]),k=E[2][0]+(p-E[2][2]),B=E[2][1]+(w-E[2][3]);c.push([-1,_,R-_,p,w-p,k,B-k])}f=w}return l(e.length),c}function Kw(t,e,r){var n=[],i=[t,e,r],a=Yw(t,e,r),o=[];function s(){o.length&&n.push({ok:o}),o=[]}function c(h){for(var p=0;p<h.length;p++)o.push(h[p])}function f(h){if(h[2]!=h[6])return!0;for(var p=h[1],w=h[5],y=0;y<h[2];y++)if(t[y+p]!=r[y+w])return!0;return!1}for(var l=0;l<a.length;l++){var u=a[l],d=u[0];d==-1?f(u)?(s(),n.push({conflict:{a:t.slice(u[1],u[1]+u[2]),aIndex:u[1],o:e.slice(u[3],u[3]+u[4]),oIndex:u[3],b:r.slice(u[5],u[5]+u[6]),bIndex:u[5]}})):c(i[0].slice(u[1],u[1]+u[2])):c(i[d].slice(u[1],u[1]+u[2]))}return s(),n}Jl.exports=Kw});var $g={};cd($g,{blameFile:()=>td,checkoutBranch:()=>Vu,commitChanges:()=>qu,computeGitGutterChanges:()=>Zu,computeGitStatus:()=>eo,computeMyersDiffOps:()=>Me,computeShortCommitHash:()=>Sr,computeUnifiedHunkDiff:()=>ro,createGitState:()=>Ar,createIsoGitFsAdapter:()=>On,default:()=>Ag,discardChanges:()=>Wu,hydrateFromIsoGitRepo:()=>ed,initRepository:()=>Lu,isEffectiveStagedChange:()=>je,isIgnoredByRules:()=>to,isIgnoredScmPath:()=>V,isUnbornGitHead:()=>$n,isoGit:()=>rd,mergeBranch:()=>Ju,normalizeScmRelPath:()=>X,parseGitignoreRules:()=>Qa,readVfsTree:()=>ce,resetToRef:()=>Xu,resolveCommitRef:()=>Rn,saveBranchTip:()=>rt,showCommit:()=>Qu,stageAll:()=>zu,stageFile:()=>Gu,stashApply:()=>Ku,stashPush:()=>Yu,syncGitHead:()=>lt,syncToIsoGitRepo:()=>Nt,unstageAll:()=>Hu,unstageFile:()=>An});var ju=At(Mn());var bu=At(Mc(),1),_u=At(Hc(),1),vu=At(Wc(),1),xu=At(Vc(),1),Sn=At(Dl(),1),dr=At(jl(),1),Eu=At(Vl(),1),Jw=At(Ql(),1),T=class t extends Error{constructor(e){super(e),this.caller=""}toJSON(){let e=this;return{code:e.code,data:e.data,caller:this.caller,message:this.message,stack:this.stack}}fromJSON(e){let r=new t(e.message),n=r;return n.code=e.code,n.data=e.data,r.caller=e.caller,r.stack=e.stack,r}get isIsomorphicGitError(){return!0}},pn=class t extends T{constructor(e){super(`Modifying the index is not possible because you have unmerged files: ${e.toString}. Fix them up in the work tree, and then use 'git add/rm as appropriate to mark resolution and make a commit.`),this.code=this.name=t.code,this.data={filepaths:e}}};pn.code="UnmergedPathsError";var I=class t extends T{constructor(e){super(`An internal error caused this command to fail.
20
+ var CodeLabScm=(()=>{var nd=Object.create;var Or=Object.defineProperty;var id=Object.getOwnPropertyDescriptor;var ad=Object.getOwnPropertyNames;var od=Object.getPrototypeOf,sd=Object.prototype.hasOwnProperty;var O=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(r){throw e=0,r}},cd=(t,e)=>{for(var r in e)Or(t,r,{get:e[r],enumerable:!0})},ao=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of ad(e))!sd.call(t,i)&&i!==r&&Or(t,i,{get:()=>e[i],enumerable:!(n=id(e,i))||n.enumerable});return t};var At=(t,e,r)=>(r=t!=null?nd(od(t)):{},ao(e||!t||!t.__esModule?Or(r,"default",{value:t,enumerable:!0}):r,t)),fd=t=>ao(Or({},"__esModule",{value:!0}),t);var co=O(Br=>{"use strict";Br.byteLength=ud;Br.toByteArray=hd;Br.fromByteArray=md;var wt=[],nt=[],ld=typeof Uint8Array<"u"?Uint8Array:Array,Bn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(Xt=0,oo=Bn.length;Xt<oo;++Xt)wt[Xt]=Bn[Xt],nt[Bn.charCodeAt(Xt)]=Xt;var Xt,oo;nt[45]=62;nt[95]=63;function so(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");r===-1&&(r=e);var n=r===e?0:4-r%4;return[r,n]}function ud(t){var e=so(t),r=e[0],n=e[1];return(r+n)*3/4-n}function dd(t,e,r){return(e+r)*3/4-r}function hd(t){var e,r=so(t),n=r[0],i=r[1],a=new ld(dd(t,n,i)),o=0,s=i>0?n-4:n,c;for(c=0;c<s;c+=4)e=nt[t.charCodeAt(c)]<<18|nt[t.charCodeAt(c+1)]<<12|nt[t.charCodeAt(c+2)]<<6|nt[t.charCodeAt(c+3)],a[o++]=e>>16&255,a[o++]=e>>8&255,a[o++]=e&255;return i===2&&(e=nt[t.charCodeAt(c)]<<2|nt[t.charCodeAt(c+1)]>>4,a[o++]=e&255),i===1&&(e=nt[t.charCodeAt(c)]<<10|nt[t.charCodeAt(c+1)]<<4|nt[t.charCodeAt(c+2)]>>2,a[o++]=e>>8&255,a[o++]=e&255),a}function pd(t){return wt[t>>18&63]+wt[t>>12&63]+wt[t>>6&63]+wt[t&63]}function wd(t,e,r){for(var n,i=[],a=e;a<r;a+=3)n=(t[a]<<16&16711680)+(t[a+1]<<8&65280)+(t[a+2]&255),i.push(pd(n));return i.join("")}function md(t){for(var e,r=t.length,n=r%3,i=[],a=16383,o=0,s=r-n;o<s;o+=a)i.push(wd(t,o,o+a>s?s:o+a));return n===1?(e=t[r-1],i.push(wt[e>>2]+wt[e<<4&63]+"==")):n===2&&(e=(t[r-2]<<8)+t[r-1],i.push(wt[e>>10]+wt[e>>4&63]+wt[e<<2&63]+"=")),i.join("")}});var fo=O(In=>{In.read=function(t,e,r,n,i){var a,o,s=i*8-n-1,c=(1<<s)-1,f=c>>1,l=-7,u=r?i-1:0,d=r?-1:1,h=t[e+u];for(u+=d,a=h&(1<<-l)-1,h>>=-l,l+=s;l>0;a=a*256+t[e+u],u+=d,l-=8);for(o=a&(1<<-l)-1,a>>=-l,l+=n;l>0;o=o*256+t[e+u],u+=d,l-=8);if(a===0)a=1-f;else{if(a===c)return o?NaN:(h?-1:1)*(1/0);o=o+Math.pow(2,n),a=a-f}return(h?-1:1)*o*Math.pow(2,a-n)};In.write=function(t,e,r,n,i,a){var o,s,c,f=a*8-i-1,l=(1<<f)-1,u=l>>1,d=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,h=n?0:a-1,p=n?1:-1,w=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,o=l):(o=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-o))<1&&(o--,c*=2),o+u>=1?e+=d/c:e+=d*Math.pow(2,1-u),e*c>=2&&(o++,c/=2),o+u>=l?(s=0,o=l):o+u>=1?(s=(e*c-1)*Math.pow(2,i),o=o+u):(s=e*Math.pow(2,u-1)*Math.pow(2,i),o=0));i>=8;t[r+h]=s&255,h+=p,s/=256,i-=8);for(o=o<<i|s,f+=i;f>0;t[r+h]=o&255,h+=p,o/=256,f-=8);t[r+h-p]|=w*128}});var Mn=O(de=>{"use strict";var Tn=co(),le=fo(),lo=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;de.Buffer=v;de.SlowBuffer=xd;de.INSPECT_MAX_BYTES=50;var Ir=2147483647;de.kMaxLength=Ir;v.TYPED_ARRAY_SUPPORT=gd();!v.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function gd(){try{let t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),t.foo()===42}catch{return!1}}Object.defineProperty(v.prototype,"parent",{enumerable:!0,get:function(){if(v.isBuffer(this))return this.buffer}});Object.defineProperty(v.prototype,"offset",{enumerable:!0,get:function(){if(v.isBuffer(this))return this.byteOffset}});function Rt(t){if(t>Ir)throw new RangeError('The value "'+t+'" is invalid for option "size"');let e=new Uint8Array(t);return Object.setPrototypeOf(e,v.prototype),e}function v(t,e,r){if(typeof t=="number"){if(typeof e=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return Dn(t)}return wo(t,e,r)}v.poolSize=8192;function wo(t,e,r){if(typeof t=="string")return bd(t,e);if(ArrayBuffer.isView(t))return _d(t);if(t==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(mt(t,ArrayBuffer)||t&&mt(t.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(mt(t,SharedArrayBuffer)||t&&mt(t.buffer,SharedArrayBuffer)))return Fn(t,e,r);if(typeof t=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let n=t.valueOf&&t.valueOf();if(n!=null&&n!==t)return v.from(n,e,r);let i=vd(t);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof t[Symbol.toPrimitive]=="function")return v.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}v.from=function(t,e,r){return wo(t,e,r)};Object.setPrototypeOf(v.prototype,Uint8Array.prototype);Object.setPrototypeOf(v,Uint8Array);function mo(t){if(typeof t!="number")throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function yd(t,e,r){return mo(t),t<=0?Rt(t):e!==void 0?typeof r=="string"?Rt(t).fill(e,r):Rt(t).fill(e):Rt(t)}v.alloc=function(t,e,r){return yd(t,e,r)};function Dn(t){return mo(t),Rt(t<0?0:Nn(t)|0)}v.allocUnsafe=function(t){return Dn(t)};v.allocUnsafeSlow=function(t){return Dn(t)};function bd(t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!v.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let r=go(t,e)|0,n=Rt(r),i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}function Cn(t){let e=t.length<0?0:Nn(t.length)|0,r=Rt(e);for(let n=0;n<e;n+=1)r[n]=t[n]&255;return r}function _d(t){if(mt(t,Uint8Array)){let e=new Uint8Array(t);return Fn(e.buffer,e.byteOffset,e.byteLength)}return Cn(t)}function Fn(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return e===void 0&&r===void 0?n=new Uint8Array(t):r===void 0?n=new Uint8Array(t,e):n=new Uint8Array(t,e,r),Object.setPrototypeOf(n,v.prototype),n}function vd(t){if(v.isBuffer(t)){let e=Nn(t.length)|0,r=Rt(e);return r.length===0||t.copy(r,0,0,e),r}if(t.length!==void 0)return typeof t.length!="number"||jn(t.length)?Rt(0):Cn(t);if(t.type==="Buffer"&&Array.isArray(t.data))return Cn(t.data)}function Nn(t){if(t>=Ir)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Ir.toString(16)+" bytes");return t|0}function xd(t){return+t!=t&&(t=0),v.alloc(+t)}v.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==v.prototype};v.compare=function(e,r){if(mt(e,Uint8Array)&&(e=v.from(e,e.offset,e.byteLength)),mt(r,Uint8Array)&&(r=v.from(r,r.offset,r.byteLength)),!v.isBuffer(e)||!v.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===r)return 0;let n=e.length,i=r.length;for(let a=0,o=Math.min(n,i);a<o;++a)if(e[a]!==r[a]){n=e[a],i=r[a];break}return n<i?-1:i<n?1:0};v.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};v.concat=function(e,r){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return v.alloc(0);let n;if(r===void 0)for(r=0,n=0;n<e.length;++n)r+=e[n].length;let i=v.allocUnsafe(r),a=0;for(n=0;n<e.length;++n){let o=e[n];if(mt(o,Uint8Array))a+o.length>i.length?(v.isBuffer(o)||(o=v.from(o)),o.copy(i,a)):Uint8Array.prototype.set.call(i,o,a);else if(v.isBuffer(o))o.copy(i,a);else throw new TypeError('"list" argument must be an Array of Buffers');a+=o.length}return i};function go(t,e){if(v.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||mt(t,ArrayBuffer))return t.byteLength;if(typeof t!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);let r=t.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&r===0)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return Pn(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return Ao(t).length;default:if(i)return n?-1:Pn(t).length;e=(""+e).toLowerCase(),i=!0}}v.byteLength=go;function Ed(t,e,r){let n=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((r===void 0||r>this.length)&&(r=this.length),r<=0)||(r>>>=0,e>>>=0,r<=e))return"";for(t||(t="utf8");;)switch(t){case"hex":return Cd(this,e,r);case"utf8":case"utf-8":return bo(this,e,r);case"ascii":return Id(this,e,r);case"latin1":case"binary":return Td(this,e,r);case"base64":return Od(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Fd(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}v.prototype._isBuffer=!0;function Yt(t,e,r){let n=t[e];t[e]=t[r],t[r]=n}v.prototype.swap16=function(){let e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let r=0;r<e;r+=2)Yt(this,r,r+1);return this};v.prototype.swap32=function(){let e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let r=0;r<e;r+=4)Yt(this,r,r+3),Yt(this,r+1,r+2);return this};v.prototype.swap64=function(){let e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let r=0;r<e;r+=8)Yt(this,r,r+7),Yt(this,r+1,r+6),Yt(this,r+2,r+5),Yt(this,r+3,r+4);return this};v.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?bo(this,0,e):Ed.apply(this,arguments)};v.prototype.toLocaleString=v.prototype.toString;v.prototype.equals=function(e){if(!v.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:v.compare(this,e)===0};v.prototype.inspect=function(){let e="",r=de.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"};lo&&(v.prototype[lo]=v.prototype.inspect);v.prototype.compare=function(e,r,n,i,a){if(mt(e,Uint8Array)&&(e=v.from(e,e.offset,e.byteLength)),!v.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(r===void 0&&(r=0),n===void 0&&(n=e?e.length:0),i===void 0&&(i=0),a===void 0&&(a=this.length),r<0||n>e.length||i<0||a>this.length)throw new RangeError("out of range index");if(i>=a&&r>=n)return 0;if(i>=a)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,i>>>=0,a>>>=0,this===e)return 0;let o=a-i,s=n-r,c=Math.min(o,s),f=this.slice(i,a),l=e.slice(r,n);for(let u=0;u<c;++u)if(f[u]!==l[u]){o=f[u],s=l[u];break}return o<s?-1:s<o?1:0};function yo(t,e,r,n,i){if(t.length===0)return-1;if(typeof r=="string"?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,jn(r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0)if(i)r=0;else return-1;if(typeof e=="string"&&(e=v.from(e,n)),v.isBuffer(e))return e.length===0?-1:uo(t,e,r,n,i);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):uo(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function uo(t,e,r,n,i){let a=1,o=t.length,s=e.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(t.length<2||e.length<2)return-1;a=2,o/=2,s/=2,r/=2}function c(l,u){return a===1?l[u]:l.readUInt16BE(u*a)}let f;if(i){let l=-1;for(f=r;f<o;f++)if(c(t,f)===c(e,l===-1?0:f-l)){if(l===-1&&(l=f),f-l+1===s)return l*a}else l!==-1&&(f-=f-l),l=-1}else for(r+s>o&&(r=o-s),f=r;f>=0;f--){let l=!0;for(let u=0;u<s;u++)if(c(t,f+u)!==c(e,u)){l=!1;break}if(l)return f}return-1}v.prototype.includes=function(e,r,n){return this.indexOf(e,r,n)!==-1};v.prototype.indexOf=function(e,r,n){return yo(this,e,r,n,!0)};v.prototype.lastIndexOf=function(e,r,n){return yo(this,e,r,n,!1)};function kd(t,e,r,n){r=Number(r)||0;let i=t.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;let a=e.length;n>a/2&&(n=a/2);let o;for(o=0;o<n;++o){let s=parseInt(e.substr(o*2,2),16);if(jn(s))return o;t[r+o]=s}return o}function Sd(t,e,r,n){return Tr(Pn(e,t.length-r),t,r,n)}function Ad(t,e,r,n){return Tr(Ud(e),t,r,n)}function Rd(t,e,r,n){return Tr(Ao(e),t,r,n)}function $d(t,e,r,n){return Tr(jd(e,t.length-r),t,r,n)}v.prototype.write=function(e,r,n,i){if(r===void 0)i="utf8",n=this.length,r=0;else if(n===void 0&&typeof r=="string")i=r,n=this.length,r=0;else if(isFinite(r))r=r>>>0,isFinite(n)?(n=n>>>0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let a=this.length-r;if((n===void 0||n>a)&&(n=a),e.length>0&&(n<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let o=!1;for(;;)switch(i){case"hex":return kd(this,e,r,n);case"utf8":case"utf-8":return Sd(this,e,r,n);case"ascii":case"latin1":case"binary":return Ad(this,e,r,n);case"base64":return Rd(this,e,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return $d(this,e,r,n);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}};v.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Od(t,e,r){return e===0&&r===t.length?Tn.fromByteArray(t):Tn.fromByteArray(t.slice(e,r))}function bo(t,e,r){r=Math.min(t.length,r);let n=[],i=e;for(;i<r;){let a=t[i],o=null,s=a>239?4:a>223?3:a>191?2:1;if(i+s<=r){let c,f,l,u;switch(s){case 1:a<128&&(o=a);break;case 2:c=t[i+1],(c&192)===128&&(u=(a&31)<<6|c&63,u>127&&(o=u));break;case 3:c=t[i+1],f=t[i+2],(c&192)===128&&(f&192)===128&&(u=(a&15)<<12|(c&63)<<6|f&63,u>2047&&(u<55296||u>57343)&&(o=u));break;case 4:c=t[i+1],f=t[i+2],l=t[i+3],(c&192)===128&&(f&192)===128&&(l&192)===128&&(u=(a&15)<<18|(c&63)<<12|(f&63)<<6|l&63,u>65535&&u<1114112&&(o=u))}}o===null?(o=65533,s=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|o&1023),n.push(o),i+=s}return Bd(n)}var ho=4096;function Bd(t){let e=t.length;if(e<=ho)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=ho));return r}function Id(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]&127);return n}function Td(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function Cd(t,e,r){let n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);let i="";for(let a=e;a<r;++a)i+=Md[t[a]];return i}function Fd(t,e,r){let n=t.slice(e,r),i="";for(let a=0;a<n.length-1;a+=2)i+=String.fromCharCode(n[a]+n[a+1]*256);return i}v.prototype.slice=function(e,r){let n=this.length;e=~~e,r=r===void 0?n:~~r,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),r<e&&(r=e);let i=this.subarray(e,r);return Object.setPrototypeOf(i,v.prototype),i};function H(t,e,r){if(t%1!==0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}v.prototype.readUintLE=v.prototype.readUIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||H(e,r,this.length);let i=this[e],a=1,o=0;for(;++o<r&&(a*=256);)i+=this[e+o]*a;return i};v.prototype.readUintBE=v.prototype.readUIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||H(e,r,this.length);let i=this[e+--r],a=1;for(;r>0&&(a*=256);)i+=this[e+--r]*a;return i};v.prototype.readUint8=v.prototype.readUInt8=function(e,r){return e=e>>>0,r||H(e,1,this.length),this[e]};v.prototype.readUint16LE=v.prototype.readUInt16LE=function(e,r){return e=e>>>0,r||H(e,2,this.length),this[e]|this[e+1]<<8};v.prototype.readUint16BE=v.prototype.readUInt16BE=function(e,r){return e=e>>>0,r||H(e,2,this.length),this[e]<<8|this[e+1]};v.prototype.readUint32LE=v.prototype.readUInt32LE=function(e,r){return e=e>>>0,r||H(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};v.prototype.readUint32BE=v.prototype.readUInt32BE=function(e,r){return e=e>>>0,r||H(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};v.prototype.readBigUInt64LE=Ut(function(e){e=e>>>0,ue(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Le(e,this.length-8);let i=r+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,a=this[++e]+this[++e]*2**8+this[++e]*2**16+n*2**24;return BigInt(i)+(BigInt(a)<<BigInt(32))});v.prototype.readBigUInt64BE=Ut(function(e){e=e>>>0,ue(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Le(e,this.length-8);let i=r*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],a=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n;return(BigInt(i)<<BigInt(32))+BigInt(a)});v.prototype.readIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||H(e,r,this.length);let i=this[e],a=1,o=0;for(;++o<r&&(a*=256);)i+=this[e+o]*a;return a*=128,i>=a&&(i-=Math.pow(2,8*r)),i};v.prototype.readIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||H(e,r,this.length);let i=r,a=1,o=this[e+--i];for(;i>0&&(a*=256);)o+=this[e+--i]*a;return a*=128,o>=a&&(o-=Math.pow(2,8*r)),o};v.prototype.readInt8=function(e,r){return e=e>>>0,r||H(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};v.prototype.readInt16LE=function(e,r){e=e>>>0,r||H(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n};v.prototype.readInt16BE=function(e,r){e=e>>>0,r||H(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n};v.prototype.readInt32LE=function(e,r){return e=e>>>0,r||H(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};v.prototype.readInt32BE=function(e,r){return e=e>>>0,r||H(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};v.prototype.readBigInt64LE=Ut(function(e){e=e>>>0,ue(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Le(e,this.length-8);let i=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(n<<24);return(BigInt(i)<<BigInt(32))+BigInt(r+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)});v.prototype.readBigInt64BE=Ut(function(e){e=e>>>0,ue(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Le(e,this.length-8);let i=(r<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(i)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n)});v.prototype.readFloatLE=function(e,r){return e=e>>>0,r||H(e,4,this.length),le.read(this,e,!0,23,4)};v.prototype.readFloatBE=function(e,r){return e=e>>>0,r||H(e,4,this.length),le.read(this,e,!1,23,4)};v.prototype.readDoubleLE=function(e,r){return e=e>>>0,r||H(e,8,this.length),le.read(this,e,!0,52,8)};v.prototype.readDoubleBE=function(e,r){return e=e>>>0,r||H(e,8,this.length),le.read(this,e,!1,52,8)};function J(t,e,r,n,i,a){if(!v.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<a)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}v.prototype.writeUintLE=v.prototype.writeUIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,n=n>>>0,!i){let s=Math.pow(2,8*n)-1;J(this,e,r,n,s,0)}let a=1,o=0;for(this[r]=e&255;++o<n&&(a*=256);)this[r+o]=e/a&255;return r+n};v.prototype.writeUintBE=v.prototype.writeUIntBE=function(e,r,n,i){if(e=+e,r=r>>>0,n=n>>>0,!i){let s=Math.pow(2,8*n)-1;J(this,e,r,n,s,0)}let a=n-1,o=1;for(this[r+a]=e&255;--a>=0&&(o*=256);)this[r+a]=e/o&255;return r+n};v.prototype.writeUint8=v.prototype.writeUInt8=function(e,r,n){return e=+e,r=r>>>0,n||J(this,e,r,1,255,0),this[r]=e&255,r+1};v.prototype.writeUint16LE=v.prototype.writeUInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||J(this,e,r,2,65535,0),this[r]=e&255,this[r+1]=e>>>8,r+2};v.prototype.writeUint16BE=v.prototype.writeUInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||J(this,e,r,2,65535,0),this[r]=e>>>8,this[r+1]=e&255,r+2};v.prototype.writeUint32LE=v.prototype.writeUInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||J(this,e,r,4,4294967295,0),this[r+3]=e>>>24,this[r+2]=e>>>16,this[r+1]=e>>>8,this[r]=e&255,r+4};v.prototype.writeUint32BE=v.prototype.writeUInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||J(this,e,r,4,4294967295,0),this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e&255,r+4};function _o(t,e,r,n,i){So(e,n,i,t,r,7);let a=Number(e&BigInt(4294967295));t[r++]=a,a=a>>8,t[r++]=a,a=a>>8,t[r++]=a,a=a>>8,t[r++]=a;let o=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=o,o=o>>8,t[r++]=o,o=o>>8,t[r++]=o,o=o>>8,t[r++]=o,r}function vo(t,e,r,n,i){So(e,n,i,t,r,7);let a=Number(e&BigInt(4294967295));t[r+7]=a,a=a>>8,t[r+6]=a,a=a>>8,t[r+5]=a,a=a>>8,t[r+4]=a;let o=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=o,o=o>>8,t[r+2]=o,o=o>>8,t[r+1]=o,o=o>>8,t[r]=o,r+8}v.prototype.writeBigUInt64LE=Ut(function(e,r=0){return _o(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});v.prototype.writeBigUInt64BE=Ut(function(e,r=0){return vo(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});v.prototype.writeIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){let c=Math.pow(2,8*n-1);J(this,e,r,n,c-1,-c)}let a=0,o=1,s=0;for(this[r]=e&255;++a<n&&(o*=256);)e<0&&s===0&&this[r+a-1]!==0&&(s=1),this[r+a]=(e/o>>0)-s&255;return r+n};v.prototype.writeIntBE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){let c=Math.pow(2,8*n-1);J(this,e,r,n,c-1,-c)}let a=n-1,o=1,s=0;for(this[r+a]=e&255;--a>=0&&(o*=256);)e<0&&s===0&&this[r+a+1]!==0&&(s=1),this[r+a]=(e/o>>0)-s&255;return r+n};v.prototype.writeInt8=function(e,r,n){return e=+e,r=r>>>0,n||J(this,e,r,1,127,-128),e<0&&(e=255+e+1),this[r]=e&255,r+1};v.prototype.writeInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||J(this,e,r,2,32767,-32768),this[r]=e&255,this[r+1]=e>>>8,r+2};v.prototype.writeInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||J(this,e,r,2,32767,-32768),this[r]=e>>>8,this[r+1]=e&255,r+2};v.prototype.writeInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||J(this,e,r,4,2147483647,-2147483648),this[r]=e&255,this[r+1]=e>>>8,this[r+2]=e>>>16,this[r+3]=e>>>24,r+4};v.prototype.writeInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||J(this,e,r,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e&255,r+4};v.prototype.writeBigInt64LE=Ut(function(e,r=0){return _o(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});v.prototype.writeBigInt64BE=Ut(function(e,r=0){return vo(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function xo(t,e,r,n,i,a){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function Eo(t,e,r,n,i){return e=+e,r=r>>>0,i||xo(t,e,r,4,34028234663852886e22,-34028234663852886e22),le.write(t,e,r,n,23,4),r+4}v.prototype.writeFloatLE=function(e,r,n){return Eo(this,e,r,!0,n)};v.prototype.writeFloatBE=function(e,r,n){return Eo(this,e,r,!1,n)};function ko(t,e,r,n,i){return e=+e,r=r>>>0,i||xo(t,e,r,8,17976931348623157e292,-17976931348623157e292),le.write(t,e,r,n,52,8),r+8}v.prototype.writeDoubleLE=function(e,r,n){return ko(this,e,r,!0,n)};v.prototype.writeDoubleBE=function(e,r,n){return ko(this,e,r,!1,n)};v.prototype.copy=function(e,r,n,i){if(!v.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),!i&&i!==0&&(i=this.length),r>=e.length&&(r=e.length),r||(r=0),i>0&&i<n&&(i=n),i===n||e.length===0||this.length===0)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-r<i-n&&(i=e.length-r+n);let a=i-n;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(r,n,i):Uint8Array.prototype.set.call(e,this.subarray(n,i),r),a};v.prototype.fill=function(e,r,n,i){if(typeof e=="string"){if(typeof r=="string"?(i=r,r=0,n=this.length):typeof n=="string"&&(i=n,n=this.length),i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!v.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(e.length===1){let o=e.charCodeAt(0);(i==="utf8"&&o<128||i==="latin1")&&(e=o)}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(r<0||this.length<r||this.length<n)throw new RangeError("Out of range index");if(n<=r)return this;r=r>>>0,n=n===void 0?this.length:n>>>0,e||(e=0);let a;if(typeof e=="number")for(a=r;a<n;++a)this[a]=e;else{let o=v.isBuffer(e)?e:v.from(e,i),s=o.length;if(s===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(a=0;a<n-r;++a)this[a+r]=o[a%s]}return this};var fe={};function Un(t,e,r){fe[t]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,this.stack,delete this.name}get code(){return t}set code(i){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:i,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}Un("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);Un("ERR_INVALID_ARG_TYPE",function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError);Un("ERR_OUT_OF_RANGE",function(t,e,r){let n=`The value of "${t}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=po(String(r)):typeof r=="bigint"&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=po(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n},RangeError);function po(t){let e="",r=t.length,n=t[0]==="-"?1:0;for(;r>=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function Pd(t,e,r){ue(e,"offset"),(t[e]===void 0||t[e+r]===void 0)&&Le(e,t.length-(r+1))}function So(t,e,r,n,i,a){if(t>r||t<e){let o=typeof e=="bigint"?"n":"",s;throw a>3?e===0||e===BigInt(0)?s=`>= 0${o} and < 2${o} ** ${(a+1)*8}${o}`:s=`>= -(2${o} ** ${(a+1)*8-1}${o}) and < 2 ** ${(a+1)*8-1}${o}`:s=`>= ${e}${o} and <= ${r}${o}`,new fe.ERR_OUT_OF_RANGE("value",s,t)}Pd(n,i,a)}function ue(t,e){if(typeof t!="number")throw new fe.ERR_INVALID_ARG_TYPE(e,"number",t)}function Le(t,e,r){throw Math.floor(t)!==t?(ue(t,r),new fe.ERR_OUT_OF_RANGE(r||"offset","an integer",t)):e<0?new fe.ERR_BUFFER_OUT_OF_BOUNDS:new fe.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}var Dd=/[^+/0-9A-Za-z-_]/g;function Nd(t){if(t=t.split("=")[0],t=t.trim().replace(Dd,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function Pn(t,e){e=e||1/0;let r,n=t.length,i=null,a=[];for(let o=0;o<n;++o){if(r=t.charCodeAt(o),r>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&a.push(239,191,189);continue}else if(o+1===n){(e-=3)>-1&&a.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&a.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(e-=3)>-1&&a.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;a.push(r)}else if(r<2048){if((e-=2)<0)break;a.push(r>>6|192,r&63|128)}else if(r<65536){if((e-=3)<0)break;a.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((e-=4)<0)break;a.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return a}function Ud(t){let e=[];for(let r=0;r<t.length;++r)e.push(t.charCodeAt(r)&255);return e}function jd(t,e){let r,n,i,a=[];for(let o=0;o<t.length&&!((e-=2)<0);++o)r=t.charCodeAt(o),n=r>>8,i=r%256,a.push(i),a.push(n);return a}function Ao(t){return Tn.toByteArray(Nd(t))}function Tr(t,e,r,n){let i;for(i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function mt(t,e){return t instanceof e||t!=null&&t.constructor!=null&&t.constructor.name!=null&&t.constructor.name===e.name}function jn(t){return t!==t}var Md=(function(){let t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){let n=r*16;for(let i=0;i<16;++i)e[n+i]=t[r]+t[i]}return e})();function Ut(t){return typeof BigInt>"u"?Ld:t}function Ld(){throw new Error("BigInt not supported")}});var Ro=O((Cg,Ln)=>{typeof Object.create=="function"?Ln.exports=function(e,r){r&&(e.super_=r,e.prototype=Object.create(r.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:Ln.exports=function(e,r){if(r){e.super_=r;var n=function(){};n.prototype=r.prototype,e.prototype=new n,e.prototype.constructor=e}}});var Fr=O((Gn,Oo)=>{var Cr=Mn(),gt=Cr.Buffer;function $o(t,e){for(var r in t)e[r]=t[r]}gt.from&&gt.alloc&&gt.allocUnsafe&&gt.allocUnsafeSlow?Oo.exports=Cr:($o(Cr,Gn),Gn.Buffer=Kt);function Kt(t,e,r){return gt(t,e,r)}Kt.prototype=Object.create(gt.prototype);$o(gt,Kt);Kt.from=function(t,e,r){if(typeof t=="number")throw new TypeError("Argument must not be a number");return gt(t,e,r)};Kt.alloc=function(t,e,r){if(typeof t!="number")throw new TypeError("Argument must be a number");var n=gt(t);return e!==void 0?typeof r=="string"?n.fill(e,r):n.fill(e):n.fill(0),n};Kt.allocUnsafe=function(t){if(typeof t!="number")throw new TypeError("Argument must be a number");return gt(t)};Kt.allocUnsafeSlow=function(t){if(typeof t!="number")throw new TypeError("Argument must be a number");return Cr.SlowBuffer(t)}});var Io=O((Fg,Bo)=>{var Gd={}.toString;Bo.exports=Array.isArray||function(t){return Gd.call(t)=="[object Array]"}});var he=O((Pg,To)=>{"use strict";To.exports=TypeError});var zn=O((Dg,Co)=>{"use strict";Co.exports=Object});var Po=O((Ng,Fo)=>{"use strict";Fo.exports=Error});var No=O((Ug,Do)=>{"use strict";Do.exports=EvalError});var jo=O((jg,Uo)=>{"use strict";Uo.exports=RangeError});var Lo=O((Mg,Mo)=>{"use strict";Mo.exports=ReferenceError});var Hn=O((Lg,Go)=>{"use strict";Go.exports=SyntaxError});var Ho=O((Gg,zo)=>{"use strict";zo.exports=URIError});var Wo=O((zg,qo)=>{"use strict";qo.exports=Math.abs});var Vo=O((Hg,Zo)=>{"use strict";Zo.exports=Math.floor});var Yo=O((qg,Xo)=>{"use strict";Xo.exports=Math.max});var Jo=O((Wg,Ko)=>{"use strict";Ko.exports=Math.min});var ts=O((Zg,Qo)=>{"use strict";Qo.exports=Math.pow});var rs=O((Vg,es)=>{"use strict";es.exports=Math.round});var is=O((Xg,ns)=>{"use strict";ns.exports=Number.isNaN||function(e){return e!==e}});var os=O((Yg,as)=>{"use strict";var zd=is();as.exports=function(e){return zd(e)||e===0?e:e<0?-1:1}});var cs=O((Kg,ss)=>{"use strict";ss.exports=Object.getOwnPropertyDescriptor});var pe=O((Jg,fs)=>{"use strict";var Pr=cs();if(Pr)try{Pr([],"length")}catch{Pr=null}fs.exports=Pr});var Ge=O((Qg,ls)=>{"use strict";var Dr=Object.defineProperty||!1;if(Dr)try{Dr({},"a",{value:1})}catch{Dr=!1}ls.exports=Dr});var qn=O((ty,us)=>{"use strict";us.exports=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var e={},r=Symbol("test"),n=Object(r);if(typeof r=="string"||Object.prototype.toString.call(r)!=="[object Symbol]"||Object.prototype.toString.call(n)!=="[object Symbol]")return!1;var i=42;e[r]=i;for(var a in e)return!1;if(typeof Object.keys=="function"&&Object.keys(e).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(e).length!==0)return!1;var o=Object.getOwnPropertySymbols(e);if(o.length!==1||o[0]!==r||!Object.prototype.propertyIsEnumerable.call(e,r))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var s=Object.getOwnPropertyDescriptor(e,r);if(s.value!==i||s.enumerable!==!0)return!1}return!0}});var ps=O((ey,hs)=>{"use strict";var ds=typeof Symbol<"u"&&Symbol,Hd=qn();hs.exports=function(){return typeof ds!="function"||typeof Symbol!="function"||typeof ds("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:Hd()}});var Wn=O((ry,ws)=>{"use strict";ws.exports=typeof Reflect<"u"&&Reflect.getPrototypeOf||null});var Zn=O((ny,ms)=>{"use strict";var qd=zn();ms.exports=qd.getPrototypeOf||null});var bs=O((iy,ys)=>{"use strict";var Wd="Function.prototype.bind called on incompatible ",Zd=Object.prototype.toString,Vd=Math.max,Xd="[object Function]",gs=function(e,r){for(var n=[],i=0;i<e.length;i+=1)n[i]=e[i];for(var a=0;a<r.length;a+=1)n[a+e.length]=r[a];return n},Yd=function(e,r){for(var n=[],i=r||0,a=0;i<e.length;i+=1,a+=1)n[a]=e[i];return n},Kd=function(t,e){for(var r="",n=0;n<t.length;n+=1)r+=t[n],n+1<t.length&&(r+=e);return r};ys.exports=function(e){var r=this;if(typeof r!="function"||Zd.apply(r)!==Xd)throw new TypeError(Wd+r);for(var n=Yd(arguments,1),i,a=function(){if(this instanceof i){var l=r.apply(this,gs(n,arguments));return Object(l)===l?l:this}return r.apply(e,gs(n,arguments))},o=Vd(0,r.length-n.length),s=[],c=0;c<o;c++)s[c]="$"+c;if(i=Function("binder","return function ("+Kd(s,",")+"){ return binder.apply(this,arguments); }")(a),r.prototype){var f=function(){};f.prototype=r.prototype,i.prototype=new f,f.prototype=null}return i}});var we=O((ay,_s)=>{"use strict";var Jd=bs();_s.exports=Function.prototype.bind||Jd});var Nr=O((oy,vs)=>{"use strict";vs.exports=Function.prototype.call});var Ur=O((sy,xs)=>{"use strict";xs.exports=Function.prototype.apply});var ks=O((cy,Es)=>{"use strict";Es.exports=typeof Reflect<"u"&&Reflect&&Reflect.apply});var Vn=O((fy,Ss)=>{"use strict";var Qd=we(),th=Ur(),eh=Nr(),rh=ks();Ss.exports=rh||Qd.call(eh,th)});var jr=O((ly,As)=>{"use strict";var nh=we(),ih=he(),ah=Nr(),oh=Vn();As.exports=function(e){if(e.length<1||typeof e[0]!="function")throw new ih("a function is required");return oh(nh,ah,e)}});var Ts=O((uy,Is)=>{"use strict";var sh=jr(),Rs=pe(),Os;try{Os=[].__proto__===Array.prototype}catch(t){if(!t||typeof t!="object"||!("code"in t)||t.code!=="ERR_PROTO_ACCESS")throw t}var Xn=!!Os&&Rs&&Rs(Object.prototype,"__proto__"),Bs=Object,$s=Bs.getPrototypeOf;Is.exports=Xn&&typeof Xn.get=="function"?sh([Xn.get]):typeof $s=="function"?function(e){return $s(e==null?e:Bs(e))}:!1});var Yn=O((dy,Ds)=>{"use strict";var Cs=Wn(),Fs=Zn(),Ps=Ts();Ds.exports=Cs?function(e){return Cs(e)}:Fs?function(e){if(!e||typeof e!="object"&&typeof e!="function")throw new TypeError("getProto: not an object");return Fs(e)}:Ps?function(e){return Ps(e)}:null});var Us=O((hy,Ns)=>{"use strict";var ch=Function.prototype.call,fh=Object.prototype.hasOwnProperty,lh=we();Ns.exports=lh.call(ch,fh)});var Qn=O((py,Hs)=>{"use strict";var C,uh=zn(),dh=Po(),hh=No(),ph=jo(),wh=Lo(),be=Hn(),ye=he(),mh=Ho(),gh=Wo(),yh=Vo(),bh=Yo(),_h=Jo(),vh=ts(),xh=rs(),Eh=os(),Gs=Function,Kn=function(t){try{return Gs('"use strict"; return ('+t+").constructor;")()}catch{}},ze=pe(),kh=Ge(),Jn=function(){throw new ye},Sh=ze?(function(){try{return arguments.callee,Jn}catch{try{return ze(arguments,"callee").get}catch{return Jn}}})():Jn,me=ps()(),q=Yn(),Ah=Zn(),Rh=Wn(),zs=Ur(),He=Nr(),ge={},$h=typeof Uint8Array>"u"||!q?C:q(Uint8Array),Jt={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?C:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?C:ArrayBuffer,"%ArrayIteratorPrototype%":me&&q?q([][Symbol.iterator]()):C,"%AsyncFromSyncIteratorPrototype%":C,"%AsyncFunction%":ge,"%AsyncGenerator%":ge,"%AsyncGeneratorFunction%":ge,"%AsyncIteratorPrototype%":ge,"%Atomics%":typeof Atomics>"u"?C:Atomics,"%BigInt%":typeof BigInt>"u"?C:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?C:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?C:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?C:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":dh,"%eval%":eval,"%EvalError%":hh,"%Float16Array%":typeof Float16Array>"u"?C:Float16Array,"%Float32Array%":typeof Float32Array>"u"?C:Float32Array,"%Float64Array%":typeof Float64Array>"u"?C:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?C:FinalizationRegistry,"%Function%":Gs,"%GeneratorFunction%":ge,"%Int8Array%":typeof Int8Array>"u"?C:Int8Array,"%Int16Array%":typeof Int16Array>"u"?C:Int16Array,"%Int32Array%":typeof Int32Array>"u"?C:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":me&&q?q(q([][Symbol.iterator]())):C,"%JSON%":typeof JSON=="object"?JSON:C,"%Map%":typeof Map>"u"?C:Map,"%MapIteratorPrototype%":typeof Map>"u"||!me||!q?C:q(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":uh,"%Object.getOwnPropertyDescriptor%":ze,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?C:Promise,"%Proxy%":typeof Proxy>"u"?C:Proxy,"%RangeError%":ph,"%ReferenceError%":wh,"%Reflect%":typeof Reflect>"u"?C:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?C:Set,"%SetIteratorPrototype%":typeof Set>"u"||!me||!q?C:q(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?C:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":me&&q?q(""[Symbol.iterator]()):C,"%Symbol%":me?Symbol:C,"%SyntaxError%":be,"%ThrowTypeError%":Sh,"%TypedArray%":$h,"%TypeError%":ye,"%Uint8Array%":typeof Uint8Array>"u"?C:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?C:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?C:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?C:Uint32Array,"%URIError%":mh,"%WeakMap%":typeof WeakMap>"u"?C:WeakMap,"%WeakRef%":typeof WeakRef>"u"?C:WeakRef,"%WeakSet%":typeof WeakSet>"u"?C:WeakSet,"%Function.prototype.call%":He,"%Function.prototype.apply%":zs,"%Object.defineProperty%":kh,"%Object.getPrototypeOf%":Ah,"%Math.abs%":gh,"%Math.floor%":yh,"%Math.max%":bh,"%Math.min%":_h,"%Math.pow%":vh,"%Math.round%":xh,"%Math.sign%":Eh,"%Reflect.getPrototypeOf%":Rh};if(q)try{null.error}catch(t){js=q(q(t)),Jt["%Error.prototype%"]=js}var js,Oh=function t(e){var r;if(e==="%AsyncFunction%")r=Kn("async function () {}");else if(e==="%GeneratorFunction%")r=Kn("function* () {}");else if(e==="%AsyncGeneratorFunction%")r=Kn("async function* () {}");else if(e==="%AsyncGenerator%"){var n=t("%AsyncGeneratorFunction%");n&&(r=n.prototype)}else if(e==="%AsyncIteratorPrototype%"){var i=t("%AsyncGenerator%");i&&q&&(r=q(i.prototype))}return Jt[e]=r,r},Ms={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},qe=we(),Mr=Us(),Bh=qe.call(He,Array.prototype.concat),Ih=qe.call(zs,Array.prototype.splice),Ls=qe.call(He,String.prototype.replace),Lr=qe.call(He,String.prototype.slice),Th=qe.call(He,RegExp.prototype.exec),Ch=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,Fh=/\\(\\)?/g,Ph=function(e){var r=Lr(e,0,1),n=Lr(e,-1);if(r==="%"&&n!=="%")throw new be("invalid intrinsic syntax, expected closing `%`");if(n==="%"&&r!=="%")throw new be("invalid intrinsic syntax, expected opening `%`");var i=[];return Ls(e,Ch,function(a,o,s,c){i[i.length]=s?Ls(c,Fh,"$1"):o||a}),i},Dh=function(e,r){var n=e,i;if(Mr(Ms,n)&&(i=Ms[n],n="%"+i[0]+"%"),Mr(Jt,n)){var a=Jt[n];if(a===ge&&(a=Oh(n)),typeof a>"u"&&!r)throw new ye("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:i,name:n,value:a}}throw new be("intrinsic "+e+" does not exist!")};Hs.exports=function(e,r){if(typeof e!="string"||e.length===0)throw new ye("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof r!="boolean")throw new ye('"allowMissing" argument must be a boolean');if(Th(/^%?[^%]*%?$/,e)===null)throw new be("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var n=Ph(e),i=n.length>0?n[0]:"",a=Dh("%"+i+"%",r),o=a.name,s=a.value,c=!1,f=a.alias;f&&(i=f[0],Ih(n,Bh([0,1],f)));for(var l=1,u=!0;l<n.length;l+=1){var d=n[l],h=Lr(d,0,1),p=Lr(d,-1);if((h==='"'||h==="'"||h==="`"||p==='"'||p==="'"||p==="`")&&h!==p)throw new be("property names with quotes must have matching quotes");if((d==="constructor"||!u)&&(c=!0),i+="."+d,o="%"+i+"%",Mr(Jt,o))s=Jt[o];else if(s!=null){if(!(d in s)){if(!r)throw new ye("base intrinsic for "+e+" exists, but the property is not available.");return}if(ze&&l+1>=n.length){var w=ze(s,d);u=!!w,u&&"get"in w&&!("originalValue"in w.get)?s=w.get:s=s[d]}else u=Mr(s,d),s=s[d];u&&!c&&(Jt[o]=s)}}return s}});var ti=O((wy,Zs)=>{"use strict";var qs=Qn(),Ws=jr(),Nh=Ws([qs("%String.prototype.indexOf%")]);Zs.exports=function(e,r){var n=qs(e,!!r);return typeof n=="function"&&Nh(e,".prototype.")>-1?Ws([n]):n}});var Ks=O((my,Ys)=>{"use strict";var Xs=Function.prototype.toString,_e=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,ri,Gr;if(typeof _e=="function"&&typeof Object.defineProperty=="function")try{ri=Object.defineProperty({},"length",{get:function(){throw Gr}}),Gr={},_e(function(){throw 42},null,ri)}catch(t){t!==Gr&&(_e=null)}else _e=null;var Uh=/^\s*class\b/,ni=function(e){try{var r=Xs.call(e);return Uh.test(r)}catch{return!1}},ei=function(e){try{return ni(e)?!1:(Xs.call(e),!0)}catch{return!1}},zr=Object.prototype.toString,jh="[object Object]",Mh="[object Function]",Lh="[object GeneratorFunction]",Gh="[object HTMLAllCollection]",zh="[object HTML document.all class]",Hh="[object HTMLCollection]",qh=typeof Symbol=="function"&&!!Symbol.toStringTag,Wh=!(0 in[,]),ii=function(){return!1};typeof document=="object"&&(Vs=document.all,zr.call(Vs)===zr.call(document.all)&&(ii=function(e){if((Wh||!e)&&(typeof e>"u"||typeof e=="object"))try{var r=zr.call(e);return(r===Gh||r===zh||r===Hh||r===jh)&&e("")==null}catch{}return!1}));var Vs;Ys.exports=_e?function(e){if(ii(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;try{_e(e,null,ri)}catch(r){if(r!==Gr)return!1}return!ni(e)&&ei(e)}:function(e){if(ii(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;if(qh)return ei(e);if(ni(e))return!1;var r=zr.call(e);return r!==Mh&&r!==Lh&&!/^\[object HTML/.test(r)?!1:ei(e)}});var tc=O((gy,Qs)=>{"use strict";var Zh=Ks(),Vh=Object.prototype.toString,Js=Object.prototype.hasOwnProperty,Xh=function(e,r,n){for(var i=0,a=e.length;i<a;i++)Js.call(e,i)&&(n==null?r(e[i],i,e):r.call(n,e[i],i,e))},Yh=function(e,r,n){for(var i=0,a=e.length;i<a;i++)n==null?r(e.charAt(i),i,e):r.call(n,e.charAt(i),i,e)},Kh=function(e,r,n){for(var i in e)Js.call(e,i)&&(n==null?r(e[i],i,e):r.call(n,e[i],i,e))};function Jh(t){return Vh.call(t)==="[object Array]"}Qs.exports=function(e,r,n){if(!Zh(r))throw new TypeError("iterator must be a function");var i;arguments.length>=3&&(i=n),Jh(e)?Xh(e,r,i):typeof e=="string"?Yh(e,r,i):Kh(e,r,i)}});var rc=O((yy,ec)=>{"use strict";ec.exports=["Float16Array","Float32Array","Float64Array","Int8Array","Int16Array","Int32Array","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array"]});var ic=O((by,nc)=>{"use strict";var ai=rc(),Qh=typeof globalThis>"u"?global:globalThis;nc.exports=function(){for(var e=[],r=0;r<ai.length;r++)typeof Qh[ai[r]]=="function"&&(e[e.length]=ai[r]);return e}});var cc=O((_y,sc)=>{"use strict";var ac=Ge(),tp=Hn(),ve=he(),oc=pe();sc.exports=function(e,r,n){if(!e||typeof e!="object"&&typeof e!="function")throw new ve("`obj` must be an object or a function`");if(typeof r!="string"&&typeof r!="symbol")throw new ve("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new ve("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new ve("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new ve("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new ve("`loose`, if provided, must be a boolean");var i=arguments.length>3?arguments[3]:null,a=arguments.length>4?arguments[4]:null,o=arguments.length>5?arguments[5]:null,s=arguments.length>6?arguments[6]:!1,c=!!oc&&oc(e,r);if(ac)ac(e,r,{configurable:o===null&&c?c.configurable:!o,enumerable:i===null&&c?c.enumerable:!i,value:n,writable:a===null&&c?c.writable:!a});else if(s||!i&&!a&&!o)e[r]=n;else throw new tp("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")}});var uc=O((vy,lc)=>{"use strict";var oi=Ge(),fc=function(){return!!oi};fc.hasArrayLengthDefineBug=function(){if(!oi)return null;try{return oi([],"length",{value:1}).length!==1}catch{return!0}};lc.exports=fc});var mc=O((xy,wc)=>{"use strict";var ep=Qn(),dc=cc(),rp=uc()(),hc=pe(),pc=he(),np=ep("%Math.floor%");wc.exports=function(e,r){if(typeof e!="function")throw new pc("`fn` is not a function");if(typeof r!="number"||r<0||r>4294967295||np(r)!==r)throw new pc("`length` must be a positive 32-bit integer");var n=arguments.length>2&&!!arguments[2],i=!0,a=!0;if("length"in e&&hc){var o=hc(e,"length");o&&!o.configurable&&(i=!1),o&&!o.writable&&(a=!1)}return(i||a||!n)&&(rp?dc(e,"length",r,!0,!0):dc(e,"length",r)),e}});var yc=O((Ey,gc)=>{"use strict";var ip=we(),ap=Ur(),op=Vn();gc.exports=function(){return op(ip,ap,arguments)}});var vc=O((ky,Hr)=>{"use strict";var sp=mc(),bc=Ge(),cp=jr(),_c=yc();Hr.exports=function(e){var r=cp(arguments),n=1+e.length-(arguments.length-1);return sp(r,n>0?n:0,!0)};bc?bc(Hr.exports,"apply",{value:_c}):Hr.exports.apply=_c});var Ec=O((Sy,xc)=>{"use strict";var fp=qn();xc.exports=function(){return fp()&&!!Symbol.toStringTag}});var $c=O((Ay,Rc)=>{"use strict";var Zr=tc(),lp=ic(),kc=vc(),ci=ti(),Wr=pe(),qr=Yn(),up=ci("Object.prototype.toString"),Ac=Ec()(),Sc=typeof globalThis>"u"?global:globalThis,si=lp(),fi=ci("String.prototype.slice"),dp=ci("Array.prototype.indexOf",!0)||function(e,r){for(var n=0;n<e.length;n+=1)if(e[n]===r)return n;return-1},Vr={__proto__:null};Ac&&Wr&&qr?Zr(si,function(t){var e=new Sc[t];if(Symbol.toStringTag in e&&qr){var r=qr(e),n=Wr(r,Symbol.toStringTag);if(!n&&r){var i=qr(r);n=Wr(i,Symbol.toStringTag)}if(n&&n.get){var a=kc(n.get);Vr["$"+t]=a}}}):Zr(si,function(t){var e=new Sc[t],r=e.slice||e.set;if(r){var n=kc(r);Vr["$"+t]=n}});function hp(t){var e=!1;return Zr(Vr,function(r,n){if(!e)try{"$"+r(t)===n&&(e=fi(n,1))}catch{}}),e}function pp(t){var e=!1;return Zr(Vr,function(r,n){if(!e)try{r(t),e=fi(n,1)}catch{}}),e}function wp(t){return dp(si,t)>-1}function mp(t){if(!t||typeof t!="object")return!1;if(!Ac){var e=fi(up(t),8,-1);return wp(e)?e:e!=="Object"?!1:pp(t)}return Wr?hp(t):null}Rc.exports=mp});var Bc=O((Ry,Oc)=>{"use strict";var gp=$c();Oc.exports=function(e){return!!gp(e)}});var Tc=O(($y,Ic)=>{"use strict";var yp=he(),bp=ti(),_p=bp("TypedArray.prototype.buffer",!0),vp=Bc();Ic.exports=_p||function(e){if(!vp(e))throw new yp("Not a Typed Array");return e.buffer}});var Pc=O((Oy,Fc)=>{"use strict";var ut=Fr().Buffer,xp=Io(),Ep=Tc(),kp=ArrayBuffer.isView||function(e){try{return Ep(e),!0}catch{return!1}},Sp=typeof Uint8Array<"u",Cc=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",Ap=Cc&&(ut.prototype instanceof Uint8Array||ut.TYPED_ARRAY_SUPPORT);Fc.exports=function(e,r){if(ut.isBuffer(e))return e.constructor&&!("isBuffer"in e)?ut.from(e):e;if(typeof e=="string")return ut.from(e,r);if(Cc&&kp(e)){if(e.byteLength===0)return ut.alloc(0);if(Ap){var n=ut.from(e.buffer,e.byteOffset,e.byteLength);if(n.byteLength===e.byteLength)return n}var i=e instanceof Uint8Array?e:new Uint8Array(e.buffer,e.byteOffset,e.byteLength),a=ut.from(i);if(a.length===e.byteLength)return a}if(Sp&&e instanceof Uint8Array)return ut.from(e);var o=xp(e);if(o)for(var s=0;s<e.length;s+=1){var c=e[s];if(typeof c!="number"||c<0||c>255||~~c!==c)throw new RangeError("Array items must be numbers in the range 0-255.")}if(o||ut.isBuffer(e)&&e.constructor&&typeof e.constructor.isBuffer=="function"&&e.constructor.isBuffer(e))return ut.from(e);throw new TypeError('The "data" argument must be a string, an Array, a Buffer, a Uint8Array, or a DataView.')}});var Nc=O((By,Dc)=>{"use strict";var Rp=Fr().Buffer,$p=Pc();function Xr(t,e){this._block=Rp.alloc(t),this._finalSize=e,this._blockSize=t,this._len=0}Xr.prototype.update=function(t,e){t=$p(t,e||"utf8");for(var r=this._block,n=this._blockSize,i=t.length,a=this._len,o=0;o<i;){for(var s=a%n,c=Math.min(i-o,n-s),f=0;f<c;f++)r[s+f]=t[o+f];a+=c,o+=c,a%n===0&&this._update(r)}return this._len+=i,this};Xr.prototype.digest=function(t){var e=this._len%this._blockSize;this._block[e]=128,this._block.fill(0,e+1),e>=this._finalSize&&(this._update(this._block),this._block.fill(0));var r=this._len*8;if(r<=4294967295)this._block.writeUInt32BE(r,this._blockSize-4);else{var n=(r&4294967295)>>>0,i=(r-n)/4294967296;this._block.writeUInt32BE(i,this._blockSize-8),this._block.writeUInt32BE(n,this._blockSize-4)}this._update(this._block);var a=this._hash();return t?a.toString(t):a};Xr.prototype._update=function(){throw new Error("_update must be implemented by subclass")};Dc.exports=Xr});var Mc=O((Iy,jc)=>{"use strict";var Op=Ro(),Uc=Nc(),Bp=Fr().Buffer,Ip=[1518500249,1859775393,-1894007588,-899497514],Tp=new Array(80);function We(){this.init(),this._w=Tp,Uc.call(this,64,56)}Op(We,Uc);We.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function Cp(t){return t<<1|t>>>31}function Fp(t){return t<<5|t>>>27}function Pp(t){return t<<30|t>>>2}function Dp(t,e,r,n){return t===0?e&r|~e&n:t===2?e&r|e&n|r&n:e^r^n}We.prototype._update=function(t){for(var e=this._w,r=this._a|0,n=this._b|0,i=this._c|0,a=this._d|0,o=this._e|0,s=0;s<16;++s)e[s]=t.readInt32BE(s*4);for(;s<80;++s)e[s]=Cp(e[s-3]^e[s-8]^e[s-14]^e[s-16]);for(var c=0;c<80;++c){var f=~~(c/20),l=Fp(r)+Dp(f,n,i,a)+o+e[c]+Ip[f]|0;o=a,a=i,i=Pp(n),n=r,r=l}this._a=r+this._a|0,this._b=n+this._b|0,this._c=i+this._c|0,this._d=a+this._d|0,this._e=o+this._e|0};We.prototype._hash=function(){var t=Bp.allocUnsafe(20);return t.writeInt32BE(this._a|0,0),t.writeInt32BE(this._b|0,4),t.writeInt32BE(this._c|0,8),t.writeInt32BE(this._d|0,12),t.writeInt32BE(this._e|0,16),t};jc.exports=We});var Gc=O((Ty,Lc)=>{"use strict";var tt=function(t){if(t=t||{},this.Promise=t.Promise||Promise,this.queues=Object.create(null),this.domainReentrant=t.domainReentrant||!1,this.domainReentrant){if(typeof process>"u"||typeof process.domain>"u")throw new Error("Domain-reentrant locks require `process.domain` to exist. Please flip `opts.domainReentrant = false`, use a NodeJS version that still implements Domain, or install a browser polyfill.");this.domains=Object.create(null)}this.timeout=t.timeout||tt.DEFAULT_TIMEOUT,this.maxOccupationTime=t.maxOccupationTime||tt.DEFAULT_MAX_OCCUPATION_TIME,this.maxExecutionTime=t.maxExecutionTime||tt.DEFAULT_MAX_EXECUTION_TIME,t.maxPending===1/0||Number.isInteger(t.maxPending)&&t.maxPending>=0?this.maxPending=t.maxPending:this.maxPending=tt.DEFAULT_MAX_PENDING};tt.DEFAULT_TIMEOUT=0;tt.DEFAULT_MAX_OCCUPATION_TIME=0;tt.DEFAULT_MAX_EXECUTION_TIME=0;tt.DEFAULT_MAX_PENDING=1e3;tt.prototype.acquire=function(t,e,r,n){if(Array.isArray(t))return this._acquireBatch(t,e,r,n);if(typeof e!="function")throw new Error("You must pass a function to execute");var i=null,a=null,o=null;typeof r!="function"&&(n=r,r=null,o=new this.Promise(function(E,S){i=E,a=S})),n=n||{};var s=!1,c=null,f=null,l=null,u=this,d=function(E,S,A){f&&(clearTimeout(f),f=null),l&&(clearTimeout(l),l=null),E&&(u.queues[t]&&u.queues[t].length===0&&delete u.queues[t],u.domainReentrant&&delete u.domains[t]),s||(o?S?a(S):i(A):typeof r=="function"&&r(S,A),s=!0),E&&u.queues[t]&&u.queues[t].length>0&&u.queues[t].shift()()},h=function(E){if(s)return d(E);c&&(clearTimeout(c),c=null),u.domainReentrant&&E&&(u.domains[t]=process.domain);var S=n.maxExecutionTime||u.maxExecutionTime;if(S&&(l=setTimeout(function(){u.queues[t]&&d(E,new Error("Maximum execution time is exceeded "+t))},S)),e.length===1){var A=!1;try{e(function(m,$){A||(A=!0,d(E,m,$))})}catch(m){A||(A=!0,d(E,m))}}else u._promiseTry(function(){return e()}).then(function(m){d(E,void 0,m)},function(m){d(E,m)})};u.domainReentrant&&process.domain&&(h=process.domain.bind(h));var p=n.maxPending||u.maxPending;if(!u.queues[t])u.queues[t]=[],h(!0);else if(u.domainReentrant&&process.domain&&process.domain===u.domains[t])h(!1);else if(u.queues[t].length>=p)d(!1,new Error("Too many pending tasks in queue "+t));else{var w=function(){h(!0)};n.skipQueue?u.queues[t].unshift(w):u.queues[t].push(w);var y=n.timeout||u.timeout;y&&(c=setTimeout(function(){c=null,d(!1,new Error("async-lock timed out in queue "+t))},y))}var b=n.maxOccupationTime||u.maxOccupationTime;if(b&&(f=setTimeout(function(){u.queues[t]&&d(!1,new Error("Maximum occupation time is exceeded in queue "+t))},b)),o)return o};tt.prototype._acquireBatch=function(t,e,r,n){var i=Object.create(null);t=t.filter(function(c){return i[c]?!1:(i[c]=!0,!0)}),typeof r!="function"&&(n=r,r=null);var a=this,o=function(c,f){return function(l){a.acquire(c,f,l,n)}},s=t.reduceRight(function(c,f){return o(f,c)},e);if(typeof r=="function")s(r);else return new this.Promise(function(c,f){s.length===1?s(function(l,u){l?f(l):c(u)}):c(s())})};tt.prototype.isBusy=function(t){return t?!!this.queues[t]:Object.keys(this.queues).length>0};tt.prototype._promiseTry=function(t){try{return this.Promise.resolve(t())}catch(e){return this.Promise.reject(e)}};Lc.exports=tt});var Hc=O((Cy,zc)=>{"use strict";zc.exports=Gc()});var Wc=O((Fy,qc)=>{"use strict";function Np(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function yt(t,e,r){return e=e instanceof RegExp?e:new RegExp(Np(e),"g"),t.replace(e,r)}var Up={clean:function(e){if(typeof e!="string")throw new Error("Expected a string, received: "+e);return e=yt(e,"./","/"),e=yt(e,"..","."),e=yt(e," ","-"),e=yt(e,/^[~^:?*\\\-]/g,""),e=yt(e,/[~^:?*\\]/g,"-"),e=yt(e,/[~^:?*\\\-]$/g,""),e=yt(e,"@{","-"),e=yt(e,/\.$/g,""),e=yt(e,/\/$/g,""),e=yt(e,/\.lock$/g,""),e}};qc.exports=Up});var Vc=O(li=>{var Zc;(function(t){typeof DO_NOT_EXPORT_CRC>"u"?typeof li=="object"?t(li):typeof define=="function"&&define.amd?define(function(){var e={};return t(e),e}):t(Zc={}):t(Zc={})})(function(t){t.version="1.2.2";function e(){for(var g=0,x=new Array(256),_=0;_!=256;++_)g=_,g=g&1?-306674912^g>>>1:g>>>1,g=g&1?-306674912^g>>>1:g>>>1,g=g&1?-306674912^g>>>1:g>>>1,g=g&1?-306674912^g>>>1:g>>>1,g=g&1?-306674912^g>>>1:g>>>1,g=g&1?-306674912^g>>>1:g>>>1,g=g&1?-306674912^g>>>1:g>>>1,g=g&1?-306674912^g>>>1:g>>>1,x[_]=g;return typeof Int32Array<"u"?new Int32Array(x):x}var r=e();function n(g){var x=0,_=0,R=0,k=typeof Int32Array<"u"?new Int32Array(4096):new Array(4096);for(R=0;R!=256;++R)k[R]=g[R];for(R=0;R!=256;++R)for(_=g[R],x=256+R;x<4096;x+=256)_=k[x]=_>>>8^g[_&255];var B=[];for(R=1;R!=16;++R)B[R-1]=typeof Int32Array<"u"?k.subarray(R*256,R*256+256):k.slice(R*256,R*256+256);return B}var i=n(r),a=i[0],o=i[1],s=i[2],c=i[3],f=i[4],l=i[5],u=i[6],d=i[7],h=i[8],p=i[9],w=i[10],y=i[11],b=i[12],E=i[13],S=i[14];function A(g,x){for(var _=x^-1,R=0,k=g.length;R<k;)_=_>>>8^r[(_^g.charCodeAt(R++))&255];return~_}function m(g,x){for(var _=x^-1,R=g.length-15,k=0;k<R;)_=S[g[k++]^_&255]^E[g[k++]^_>>8&255]^b[g[k++]^_>>16&255]^y[g[k++]^_>>>24]^w[g[k++]]^p[g[k++]]^h[g[k++]]^d[g[k++]]^u[g[k++]]^l[g[k++]]^f[g[k++]]^c[g[k++]]^s[g[k++]]^o[g[k++]]^a[g[k++]]^r[g[k++]];for(R+=15;k<R;)_=_>>>8^r[(_^g[k++])&255];return~_}function $(g,x){for(var _=x^-1,R=0,k=g.length,B=0,N=0;R<k;)B=g.charCodeAt(R++),B<128?_=_>>>8^r[(_^B)&255]:B<2048?(_=_>>>8^r[(_^(192|B>>6&31))&255],_=_>>>8^r[(_^(128|B&63))&255]):B>=55296&&B<57344?(B=(B&1023)+64,N=g.charCodeAt(R++)&1023,_=_>>>8^r[(_^(240|B>>8&7))&255],_=_>>>8^r[(_^(128|B>>2&63))&255],_=_>>>8^r[(_^(128|N>>6&15|(B&3)<<4))&255],_=_>>>8^r[(_^(128|N&63))&255]):(_=_>>>8^r[(_^(224|B>>12&15))&255],_=_>>>8^r[(_^(128|B>>6&63))&255],_=_>>>8^r[(_^(128|B&63))&255]);return~_}t.table=r,t.bstr=A,t.buf=m,t.str=$})});var $t=O(Y=>{"use strict";var jp=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";function Mp(t,e){return Object.prototype.hasOwnProperty.call(t,e)}Y.assign=function(t){for(var e=Array.prototype.slice.call(arguments,1);e.length;){var r=e.shift();if(r){if(typeof r!="object")throw new TypeError(r+"must be non-object");for(var n in r)Mp(r,n)&&(t[n]=r[n])}}return t};Y.shrinkBuf=function(t,e){return t.length===e?t:t.subarray?t.subarray(0,e):(t.length=e,t)};var Lp={arraySet:function(t,e,r,n,i){if(e.subarray&&t.subarray){t.set(e.subarray(r,r+n),i);return}for(var a=0;a<n;a++)t[i+a]=e[r+a]},flattenChunks:function(t){var e,r,n,i,a,o;for(n=0,e=0,r=t.length;e<r;e++)n+=t[e].length;for(o=new Uint8Array(n),i=0,e=0,r=t.length;e<r;e++)a=t[e],o.set(a,i),i+=a.length;return o}},Gp={arraySet:function(t,e,r,n,i){for(var a=0;a<n;a++)t[i+a]=e[r+a]},flattenChunks:function(t){return[].concat.apply([],t)}};Y.setTyped=function(t){t?(Y.Buf8=Uint8Array,Y.Buf16=Uint16Array,Y.Buf32=Int32Array,Y.assign(Y,Lp)):(Y.Buf8=Array,Y.Buf16=Array,Y.Buf32=Array,Y.assign(Y,Gp))};Y.setTyped(jp)});var yf=O(ke=>{"use strict";var zp=$t(),Hp=4,Xc=0,Yc=1,qp=2;function Ee(t){for(var e=t.length;--e>=0;)t[e]=0}var Wp=0,rf=1,Zp=2,Vp=3,Xp=258,gi=29,Je=256,Ve=Je+1+gi,xe=30,yi=19,nf=2*Ve+1,Qt=15,ui=16,Yp=7,bi=256,af=16,of=17,sf=18,wi=[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],Yr=[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],Kp=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],cf=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],Jp=512,Ot=new Array((Ve+2)*2);Ee(Ot);var Ze=new Array(xe*2);Ee(Ze);var Xe=new Array(Jp);Ee(Xe);var Ye=new Array(Xp-Vp+1);Ee(Ye);var _i=new Array(gi);Ee(_i);var Kr=new Array(xe);Ee(Kr);function di(t,e,r,n,i){this.static_tree=t,this.extra_bits=e,this.extra_base=r,this.elems=n,this.max_length=i,this.has_stree=t&&t.length}var ff,lf,uf;function hi(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}function df(t){return t<256?Xe[t]:Xe[256+(t>>>7)]}function Ke(t,e){t.pending_buf[t.pending++]=e&255,t.pending_buf[t.pending++]=e>>>8&255}function Q(t,e,r){t.bi_valid>ui-r?(t.bi_buf|=e<<t.bi_valid&65535,Ke(t,t.bi_buf),t.bi_buf=e>>ui-t.bi_valid,t.bi_valid+=r-ui):(t.bi_buf|=e<<t.bi_valid&65535,t.bi_valid+=r)}function bt(t,e,r){Q(t,r[e*2],r[e*2+1])}function hf(t,e){var r=0;do r|=t&1,t>>>=1,r<<=1;while(--e>0);return r>>>1}function Qp(t){t.bi_valid===16?(Ke(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=t.bi_buf&255,t.bi_buf>>=8,t.bi_valid-=8)}function t0(t,e){var r=e.dyn_tree,n=e.max_code,i=e.stat_desc.static_tree,a=e.stat_desc.has_stree,o=e.stat_desc.extra_bits,s=e.stat_desc.extra_base,c=e.stat_desc.max_length,f,l,u,d,h,p,w=0;for(d=0;d<=Qt;d++)t.bl_count[d]=0;for(r[t.heap[t.heap_max]*2+1]=0,f=t.heap_max+1;f<nf;f++)l=t.heap[f],d=r[r[l*2+1]*2+1]+1,d>c&&(d=c,w++),r[l*2+1]=d,!(l>n)&&(t.bl_count[d]++,h=0,l>=s&&(h=o[l-s]),p=r[l*2],t.opt_len+=p*(d+h),a&&(t.static_len+=p*(i[l*2+1]+h)));if(w!==0){do{for(d=c-1;t.bl_count[d]===0;)d--;t.bl_count[d]--,t.bl_count[d+1]+=2,t.bl_count[c]--,w-=2}while(w>0);for(d=c;d!==0;d--)for(l=t.bl_count[d];l!==0;)u=t.heap[--f],!(u>n)&&(r[u*2+1]!==d&&(t.opt_len+=(d-r[u*2+1])*r[u*2],r[u*2+1]=d),l--)}}function pf(t,e,r){var n=new Array(Qt+1),i=0,a,o;for(a=1;a<=Qt;a++)n[a]=i=i+r[a-1]<<1;for(o=0;o<=e;o++){var s=t[o*2+1];s!==0&&(t[o*2]=hf(n[s]++,s))}}function e0(){var t,e,r,n,i,a=new Array(Qt+1);for(r=0,n=0;n<gi-1;n++)for(_i[n]=r,t=0;t<1<<wi[n];t++)Ye[r++]=n;for(Ye[r-1]=n,i=0,n=0;n<16;n++)for(Kr[n]=i,t=0;t<1<<Yr[n];t++)Xe[i++]=n;for(i>>=7;n<xe;n++)for(Kr[n]=i<<7,t=0;t<1<<Yr[n]-7;t++)Xe[256+i++]=n;for(e=0;e<=Qt;e++)a[e]=0;for(t=0;t<=143;)Ot[t*2+1]=8,t++,a[8]++;for(;t<=255;)Ot[t*2+1]=9,t++,a[9]++;for(;t<=279;)Ot[t*2+1]=7,t++,a[7]++;for(;t<=287;)Ot[t*2+1]=8,t++,a[8]++;for(pf(Ot,Ve+1,a),t=0;t<xe;t++)Ze[t*2+1]=5,Ze[t*2]=hf(t,5);ff=new di(Ot,wi,Je+1,Ve,Qt),lf=new di(Ze,Yr,0,xe,Qt),uf=new di(new Array(0),Kp,0,yi,Yp)}function wf(t){var e;for(e=0;e<Ve;e++)t.dyn_ltree[e*2]=0;for(e=0;e<xe;e++)t.dyn_dtree[e*2]=0;for(e=0;e<yi;e++)t.bl_tree[e*2]=0;t.dyn_ltree[bi*2]=1,t.opt_len=t.static_len=0,t.last_lit=t.matches=0}function mf(t){t.bi_valid>8?Ke(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0}function r0(t,e,r,n){mf(t),n&&(Ke(t,r),Ke(t,~r)),zp.arraySet(t.pending_buf,t.window,e,r,t.pending),t.pending+=r}function Kc(t,e,r,n){var i=e*2,a=r*2;return t[i]<t[a]||t[i]===t[a]&&n[e]<=n[r]}function pi(t,e,r){for(var n=t.heap[r],i=r<<1;i<=t.heap_len&&(i<t.heap_len&&Kc(e,t.heap[i+1],t.heap[i],t.depth)&&i++,!Kc(e,n,t.heap[i],t.depth));)t.heap[r]=t.heap[i],r=i,i<<=1;t.heap[r]=n}function Jc(t,e,r){var n,i,a=0,o,s;if(t.last_lit!==0)do n=t.pending_buf[t.d_buf+a*2]<<8|t.pending_buf[t.d_buf+a*2+1],i=t.pending_buf[t.l_buf+a],a++,n===0?bt(t,i,e):(o=Ye[i],bt(t,o+Je+1,e),s=wi[o],s!==0&&(i-=_i[o],Q(t,i,s)),n--,o=df(n),bt(t,o,r),s=Yr[o],s!==0&&(n-=Kr[o],Q(t,n,s)));while(a<t.last_lit);bt(t,bi,e)}function mi(t,e){var r=e.dyn_tree,n=e.stat_desc.static_tree,i=e.stat_desc.has_stree,a=e.stat_desc.elems,o,s,c=-1,f;for(t.heap_len=0,t.heap_max=nf,o=0;o<a;o++)r[o*2]!==0?(t.heap[++t.heap_len]=c=o,t.depth[o]=0):r[o*2+1]=0;for(;t.heap_len<2;)f=t.heap[++t.heap_len]=c<2?++c:0,r[f*2]=1,t.depth[f]=0,t.opt_len--,i&&(t.static_len-=n[f*2+1]);for(e.max_code=c,o=t.heap_len>>1;o>=1;o--)pi(t,r,o);f=a;do o=t.heap[1],t.heap[1]=t.heap[t.heap_len--],pi(t,r,1),s=t.heap[1],t.heap[--t.heap_max]=o,t.heap[--t.heap_max]=s,r[f*2]=r[o*2]+r[s*2],t.depth[f]=(t.depth[o]>=t.depth[s]?t.depth[o]:t.depth[s])+1,r[o*2+1]=r[s*2+1]=f,t.heap[1]=f++,pi(t,r,1);while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],t0(t,e),pf(r,c,t.bl_count)}function Qc(t,e,r){var n,i=-1,a,o=e[1],s=0,c=7,f=4;for(o===0&&(c=138,f=3),e[(r+1)*2+1]=65535,n=0;n<=r;n++)a=o,o=e[(n+1)*2+1],!(++s<c&&a===o)&&(s<f?t.bl_tree[a*2]+=s:a!==0?(a!==i&&t.bl_tree[a*2]++,t.bl_tree[af*2]++):s<=10?t.bl_tree[of*2]++:t.bl_tree[sf*2]++,s=0,i=a,o===0?(c=138,f=3):a===o?(c=6,f=3):(c=7,f=4))}function tf(t,e,r){var n,i=-1,a,o=e[1],s=0,c=7,f=4;for(o===0&&(c=138,f=3),n=0;n<=r;n++)if(a=o,o=e[(n+1)*2+1],!(++s<c&&a===o)){if(s<f)do bt(t,a,t.bl_tree);while(--s!==0);else a!==0?(a!==i&&(bt(t,a,t.bl_tree),s--),bt(t,af,t.bl_tree),Q(t,s-3,2)):s<=10?(bt(t,of,t.bl_tree),Q(t,s-3,3)):(bt(t,sf,t.bl_tree),Q(t,s-11,7));s=0,i=a,o===0?(c=138,f=3):a===o?(c=6,f=3):(c=7,f=4)}}function n0(t){var e;for(Qc(t,t.dyn_ltree,t.l_desc.max_code),Qc(t,t.dyn_dtree,t.d_desc.max_code),mi(t,t.bl_desc),e=yi-1;e>=3&&t.bl_tree[cf[e]*2+1]===0;e--);return t.opt_len+=3*(e+1)+5+5+4,e}function i0(t,e,r,n){var i;for(Q(t,e-257,5),Q(t,r-1,5),Q(t,n-4,4),i=0;i<n;i++)Q(t,t.bl_tree[cf[i]*2+1],3);tf(t,t.dyn_ltree,e-1),tf(t,t.dyn_dtree,r-1)}function a0(t){var e=4093624447,r;for(r=0;r<=31;r++,e>>>=1)if(e&1&&t.dyn_ltree[r*2]!==0)return Xc;if(t.dyn_ltree[18]!==0||t.dyn_ltree[20]!==0||t.dyn_ltree[26]!==0)return Yc;for(r=32;r<Je;r++)if(t.dyn_ltree[r*2]!==0)return Yc;return Xc}var ef=!1;function o0(t){ef||(e0(),ef=!0),t.l_desc=new hi(t.dyn_ltree,ff),t.d_desc=new hi(t.dyn_dtree,lf),t.bl_desc=new hi(t.bl_tree,uf),t.bi_buf=0,t.bi_valid=0,wf(t)}function gf(t,e,r,n){Q(t,(Wp<<1)+(n?1:0),3),r0(t,e,r,!0)}function s0(t){Q(t,rf<<1,3),bt(t,bi,Ot),Qp(t)}function c0(t,e,r,n){var i,a,o=0;t.level>0?(t.strm.data_type===qp&&(t.strm.data_type=a0(t)),mi(t,t.l_desc),mi(t,t.d_desc),o=n0(t),i=t.opt_len+3+7>>>3,a=t.static_len+3+7>>>3,a<=i&&(i=a)):i=a=r+5,r+4<=i&&e!==-1?gf(t,e,r,n):t.strategy===Hp||a===i?(Q(t,(rf<<1)+(n?1:0),3),Jc(t,Ot,Ze)):(Q(t,(Zp<<1)+(n?1:0),3),i0(t,t.l_desc.max_code+1,t.d_desc.max_code+1,o+1),Jc(t,t.dyn_ltree,t.dyn_dtree)),wf(t),n&&mf(t)}function f0(t,e,r){return t.pending_buf[t.d_buf+t.last_lit*2]=e>>>8&255,t.pending_buf[t.d_buf+t.last_lit*2+1]=e&255,t.pending_buf[t.l_buf+t.last_lit]=r&255,t.last_lit++,e===0?t.dyn_ltree[r*2]++:(t.matches++,e--,t.dyn_ltree[(Ye[r]+Je+1)*2]++,t.dyn_dtree[df(e)*2]++),t.last_lit===t.lit_bufsize-1}ke._tr_init=o0;ke._tr_stored_block=gf;ke._tr_flush_block=c0;ke._tr_tally=f0;ke._tr_align=s0});var vi=O((Uy,bf)=>{"use strict";function l0(t,e,r,n){for(var i=t&65535|0,a=t>>>16&65535|0,o=0;r!==0;){o=r>2e3?2e3:r,r-=o;do i=i+e[n++]|0,a=a+i|0;while(--o);i%=65521,a%=65521}return i|a<<16|0}bf.exports=l0});var xi=O((jy,_f)=>{"use strict";function u0(){for(var t,e=[],r=0;r<256;r++){t=r;for(var n=0;n<8;n++)t=t&1?3988292384^t>>>1:t>>>1;e[r]=t}return e}var d0=u0();function h0(t,e,r,n){var i=d0,a=n+r;t^=-1;for(var o=n;o<a;o++)t=t>>>8^i[(t^e[o])&255];return t^-1}_f.exports=h0});var Jr=O((My,vf)=>{"use strict";vf.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 Bf=O(xt=>{"use strict";var K=$t(),it=yf(),Sf=vi(),jt=xi(),p0=Jr(),ne=0,w0=1,m0=3,Ht=4,xf=5,vt=0,Ef=1,at=-2,g0=-3,Ei=-5,y0=-1,b0=1,Qr=2,_0=3,v0=4,x0=0,E0=2,nn=8,k0=9,S0=15,A0=8,R0=29,$0=256,Si=$0+1+R0,O0=30,B0=19,I0=2*Si+1,T0=15,F=3,Gt=258,dt=Gt+F+1,C0=32,an=42,Ai=69,tn=73,en=91,rn=103,te=113,tr=666,G=1,er=2,ee=3,Re=4,F0=3;function zt(t,e){return t.msg=p0[e],e}function kf(t){return(t<<1)-(t>4?9:0)}function Lt(t){for(var e=t.length;--e>=0;)t[e]=0}function Mt(t){var e=t.state,r=e.pending;r>t.avail_out&&(r=t.avail_out),r!==0&&(K.arraySet(t.output,e.pending_buf,e.pending_out,r,t.next_out),t.next_out+=r,e.pending_out+=r,t.total_out+=r,t.avail_out-=r,e.pending-=r,e.pending===0&&(e.pending_out=0))}function W(t,e){it._tr_flush_block(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,Mt(t.strm)}function P(t,e){t.pending_buf[t.pending++]=e}function Qe(t,e){t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=e&255}function P0(t,e,r,n){var i=t.avail_in;return i>n&&(i=n),i===0?0:(t.avail_in-=i,K.arraySet(e,t.input,t.next_in,i,r),t.state.wrap===1?t.adler=Sf(t.adler,e,i,r):t.state.wrap===2&&(t.adler=jt(t.adler,e,i,r)),t.next_in+=i,t.total_in+=i,i)}function Af(t,e){var r=t.max_chain_length,n=t.strstart,i,a,o=t.prev_length,s=t.nice_match,c=t.strstart>t.w_size-dt?t.strstart-(t.w_size-dt):0,f=t.window,l=t.w_mask,u=t.prev,d=t.strstart+Gt,h=f[n+o-1],p=f[n+o];t.prev_length>=t.good_match&&(r>>=2),s>t.lookahead&&(s=t.lookahead);do if(i=e,!(f[i+o]!==p||f[i+o-1]!==h||f[i]!==f[n]||f[++i]!==f[n+1])){n+=2,i++;do;while(f[++n]===f[++i]&&f[++n]===f[++i]&&f[++n]===f[++i]&&f[++n]===f[++i]&&f[++n]===f[++i]&&f[++n]===f[++i]&&f[++n]===f[++i]&&f[++n]===f[++i]&&n<d);if(a=Gt-(d-n),n=d-Gt,a>o){if(t.match_start=e,o=a,a>=s)break;h=f[n+o-1],p=f[n+o]}}while((e=u[e&l])>c&&--r!==0);return o<=t.lookahead?o:t.lookahead}function re(t){var e=t.w_size,r,n,i,a,o;do{if(a=t.window_size-t.lookahead-t.strstart,t.strstart>=e+(e-dt)){K.arraySet(t.window,t.window,e,e,0),t.match_start-=e,t.strstart-=e,t.block_start-=e,n=t.hash_size,r=n;do i=t.head[--r],t.head[r]=i>=e?i-e:0;while(--n);n=e,r=n;do i=t.prev[--r],t.prev[r]=i>=e?i-e:0;while(--n);a+=e}if(t.strm.avail_in===0)break;if(n=P0(t.strm,t.window,t.strstart+t.lookahead,a),t.lookahead+=n,t.lookahead+t.insert>=F)for(o=t.strstart-t.insert,t.ins_h=t.window[o],t.ins_h=(t.ins_h<<t.hash_shift^t.window[o+1])&t.hash_mask;t.insert&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[o+F-1])&t.hash_mask,t.prev[o&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=o,o++,t.insert--,!(t.lookahead+t.insert<F)););}while(t.lookahead<dt&&t.strm.avail_in!==0)}function D0(t,e){var r=65535;for(r>t.pending_buf_size-5&&(r=t.pending_buf_size-5);;){if(t.lookahead<=1){if(re(t),t.lookahead===0&&e===ne)return G;if(t.lookahead===0)break}t.strstart+=t.lookahead,t.lookahead=0;var n=t.block_start+r;if((t.strstart===0||t.strstart>=n)&&(t.lookahead=t.strstart-n,t.strstart=n,W(t,!1),t.strm.avail_out===0)||t.strstart-t.block_start>=t.w_size-dt&&(W(t,!1),t.strm.avail_out===0))return G}return t.insert=0,e===Ht?(W(t,!0),t.strm.avail_out===0?ee:Re):(t.strstart>t.block_start&&(W(t,!1),t.strm.avail_out===0),G)}function ki(t,e){for(var r,n;;){if(t.lookahead<dt){if(re(t),t.lookahead<dt&&e===ne)return G;if(t.lookahead===0)break}if(r=0,t.lookahead>=F&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+F-1])&t.hash_mask,r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),r!==0&&t.strstart-r<=t.w_size-dt&&(t.match_length=Af(t,r)),t.match_length>=F)if(n=it._tr_tally(t,t.strstart-t.match_start,t.match_length-F),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=F){t.match_length--;do t.strstart++,t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+F-1])&t.hash_mask,r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart;while(--t.match_length!==0);t.strstart++}else t.strstart+=t.match_length,t.match_length=0,t.ins_h=t.window[t.strstart],t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+1])&t.hash_mask;else n=it._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(n&&(W(t,!1),t.strm.avail_out===0))return G}return t.insert=t.strstart<F-1?t.strstart:F-1,e===Ht?(W(t,!0),t.strm.avail_out===0?ee:Re):t.last_lit&&(W(t,!1),t.strm.avail_out===0)?G:er}function Se(t,e){for(var r,n,i;;){if(t.lookahead<dt){if(re(t),t.lookahead<dt&&e===ne)return G;if(t.lookahead===0)break}if(r=0,t.lookahead>=F&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+F-1])&t.hash_mask,r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=F-1,r!==0&&t.prev_length<t.max_lazy_match&&t.strstart-r<=t.w_size-dt&&(t.match_length=Af(t,r),t.match_length<=5&&(t.strategy===b0||t.match_length===F&&t.strstart-t.match_start>4096)&&(t.match_length=F-1)),t.prev_length>=F&&t.match_length<=t.prev_length){i=t.strstart+t.lookahead-F,n=it._tr_tally(t,t.strstart-1-t.prev_match,t.prev_length-F),t.lookahead-=t.prev_length-1,t.prev_length-=2;do++t.strstart<=i&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+F-1])&t.hash_mask,r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart);while(--t.prev_length!==0);if(t.match_available=0,t.match_length=F-1,t.strstart++,n&&(W(t,!1),t.strm.avail_out===0))return G}else if(t.match_available){if(n=it._tr_tally(t,0,t.window[t.strstart-1]),n&&W(t,!1),t.strstart++,t.lookahead--,t.strm.avail_out===0)return G}else t.match_available=1,t.strstart++,t.lookahead--}return t.match_available&&(n=it._tr_tally(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<F-1?t.strstart:F-1,e===Ht?(W(t,!0),t.strm.avail_out===0?ee:Re):t.last_lit&&(W(t,!1),t.strm.avail_out===0)?G:er}function N0(t,e){for(var r,n,i,a,o=t.window;;){if(t.lookahead<=Gt){if(re(t),t.lookahead<=Gt&&e===ne)return G;if(t.lookahead===0)break}if(t.match_length=0,t.lookahead>=F&&t.strstart>0&&(i=t.strstart-1,n=o[i],n===o[++i]&&n===o[++i]&&n===o[++i])){a=t.strstart+Gt;do;while(n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&i<a);t.match_length=Gt-(a-i),t.match_length>t.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=F?(r=it._tr_tally(t,1,t.match_length-F),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(r=it._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),r&&(W(t,!1),t.strm.avail_out===0))return G}return t.insert=0,e===Ht?(W(t,!0),t.strm.avail_out===0?ee:Re):t.last_lit&&(W(t,!1),t.strm.avail_out===0)?G:er}function U0(t,e){for(var r;;){if(t.lookahead===0&&(re(t),t.lookahead===0)){if(e===ne)return G;break}if(t.match_length=0,r=it._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,r&&(W(t,!1),t.strm.avail_out===0))return G}return t.insert=0,e===Ht?(W(t,!0),t.strm.avail_out===0?ee:Re):t.last_lit&&(W(t,!1),t.strm.avail_out===0)?G:er}function _t(t,e,r,n,i){this.good_length=t,this.max_lazy=e,this.nice_length=r,this.max_chain=n,this.func=i}var Ae;Ae=[new _t(0,0,0,0,D0),new _t(4,4,8,4,ki),new _t(4,5,16,8,ki),new _t(4,6,32,32,ki),new _t(4,4,16,16,Se),new _t(8,16,32,32,Se),new _t(8,16,128,128,Se),new _t(8,32,128,256,Se),new _t(32,128,258,1024,Se),new _t(32,258,258,4096,Se)];function j0(t){t.window_size=2*t.w_size,Lt(t.head),t.max_lazy_match=Ae[t.level].max_lazy,t.good_match=Ae[t.level].good_length,t.nice_match=Ae[t.level].nice_length,t.max_chain_length=Ae[t.level].max_chain,t.strstart=0,t.block_start=0,t.lookahead=0,t.insert=0,t.match_length=t.prev_length=F-1,t.match_available=0,t.ins_h=0}function M0(){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=nn,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 K.Buf16(I0*2),this.dyn_dtree=new K.Buf16((2*O0+1)*2),this.bl_tree=new K.Buf16((2*B0+1)*2),Lt(this.dyn_ltree),Lt(this.dyn_dtree),Lt(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new K.Buf16(T0+1),this.heap=new K.Buf16(2*Si+1),Lt(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new K.Buf16(2*Si+1),Lt(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 Rf(t){var e;return!t||!t.state?zt(t,at):(t.total_in=t.total_out=0,t.data_type=E0,e=t.state,e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=e.wrap?an:te,t.adler=e.wrap===2?0:1,e.last_flush=ne,it._tr_init(e),vt)}function $f(t){var e=Rf(t);return e===vt&&j0(t.state),e}function L0(t,e){return!t||!t.state||t.state.wrap!==2?at:(t.state.gzhead=e,vt)}function Of(t,e,r,n,i,a){if(!t)return at;var o=1;if(e===y0&&(e=6),n<0?(o=0,n=-n):n>15&&(o=2,n-=16),i<1||i>k0||r!==nn||n<8||n>15||e<0||e>9||a<0||a>v0)return zt(t,at);n===8&&(n=9);var s=new M0;return t.state=s,s.strm=t,s.wrap=o,s.gzhead=null,s.w_bits=n,s.w_size=1<<s.w_bits,s.w_mask=s.w_size-1,s.hash_bits=i+7,s.hash_size=1<<s.hash_bits,s.hash_mask=s.hash_size-1,s.hash_shift=~~((s.hash_bits+F-1)/F),s.window=new K.Buf8(s.w_size*2),s.head=new K.Buf16(s.hash_size),s.prev=new K.Buf16(s.w_size),s.lit_bufsize=1<<i+6,s.pending_buf_size=s.lit_bufsize*4,s.pending_buf=new K.Buf8(s.pending_buf_size),s.d_buf=1*s.lit_bufsize,s.l_buf=3*s.lit_bufsize,s.level=e,s.strategy=a,s.method=r,$f(t)}function G0(t,e){return Of(t,e,nn,S0,A0,x0)}function z0(t,e){var r,n,i,a;if(!t||!t.state||e>xf||e<0)return t?zt(t,at):at;if(n=t.state,!t.output||!t.input&&t.avail_in!==0||n.status===tr&&e!==Ht)return zt(t,t.avail_out===0?Ei:at);if(n.strm=t,r=n.last_flush,n.last_flush=e,n.status===an)if(n.wrap===2)t.adler=0,P(n,31),P(n,139),P(n,8),n.gzhead?(P(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),P(n,n.gzhead.time&255),P(n,n.gzhead.time>>8&255),P(n,n.gzhead.time>>16&255),P(n,n.gzhead.time>>24&255),P(n,n.level===9?2:n.strategy>=Qr||n.level<2?4:0),P(n,n.gzhead.os&255),n.gzhead.extra&&n.gzhead.extra.length&&(P(n,n.gzhead.extra.length&255),P(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(t.adler=jt(t.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=Ai):(P(n,0),P(n,0),P(n,0),P(n,0),P(n,0),P(n,n.level===9?2:n.strategy>=Qr||n.level<2?4:0),P(n,F0),n.status=te);else{var o=nn+(n.w_bits-8<<4)<<8,s=-1;n.strategy>=Qr||n.level<2?s=0:n.level<6?s=1:n.level===6?s=2:s=3,o|=s<<6,n.strstart!==0&&(o|=C0),o+=31-o%31,n.status=te,Qe(n,o),n.strstart!==0&&(Qe(n,t.adler>>>16),Qe(n,t.adler&65535)),t.adler=1}if(n.status===Ai)if(n.gzhead.extra){for(i=n.pending;n.gzindex<(n.gzhead.extra.length&65535)&&!(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>i&&(t.adler=jt(t.adler,n.pending_buf,n.pending-i,i)),Mt(t),i=n.pending,n.pending===n.pending_buf_size));)P(n,n.gzhead.extra[n.gzindex]&255),n.gzindex++;n.gzhead.hcrc&&n.pending>i&&(t.adler=jt(t.adler,n.pending_buf,n.pending-i,i)),n.gzindex===n.gzhead.extra.length&&(n.gzindex=0,n.status=tn)}else n.status=tn;if(n.status===tn)if(n.gzhead.name){i=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>i&&(t.adler=jt(t.adler,n.pending_buf,n.pending-i,i)),Mt(t),i=n.pending,n.pending===n.pending_buf_size)){a=1;break}n.gzindex<n.gzhead.name.length?a=n.gzhead.name.charCodeAt(n.gzindex++)&255:a=0,P(n,a)}while(a!==0);n.gzhead.hcrc&&n.pending>i&&(t.adler=jt(t.adler,n.pending_buf,n.pending-i,i)),a===0&&(n.gzindex=0,n.status=en)}else n.status=en;if(n.status===en)if(n.gzhead.comment){i=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>i&&(t.adler=jt(t.adler,n.pending_buf,n.pending-i,i)),Mt(t),i=n.pending,n.pending===n.pending_buf_size)){a=1;break}n.gzindex<n.gzhead.comment.length?a=n.gzhead.comment.charCodeAt(n.gzindex++)&255:a=0,P(n,a)}while(a!==0);n.gzhead.hcrc&&n.pending>i&&(t.adler=jt(t.adler,n.pending_buf,n.pending-i,i)),a===0&&(n.status=rn)}else n.status=rn;if(n.status===rn&&(n.gzhead.hcrc?(n.pending+2>n.pending_buf_size&&Mt(t),n.pending+2<=n.pending_buf_size&&(P(n,t.adler&255),P(n,t.adler>>8&255),t.adler=0,n.status=te)):n.status=te),n.pending!==0){if(Mt(t),t.avail_out===0)return n.last_flush=-1,vt}else if(t.avail_in===0&&kf(e)<=kf(r)&&e!==Ht)return zt(t,Ei);if(n.status===tr&&t.avail_in!==0)return zt(t,Ei);if(t.avail_in!==0||n.lookahead!==0||e!==ne&&n.status!==tr){var c=n.strategy===Qr?U0(n,e):n.strategy===_0?N0(n,e):Ae[n.level].func(n,e);if((c===ee||c===Re)&&(n.status=tr),c===G||c===ee)return t.avail_out===0&&(n.last_flush=-1),vt;if(c===er&&(e===w0?it._tr_align(n):e!==xf&&(it._tr_stored_block(n,0,0,!1),e===m0&&(Lt(n.head),n.lookahead===0&&(n.strstart=0,n.block_start=0,n.insert=0))),Mt(t),t.avail_out===0))return n.last_flush=-1,vt}return e!==Ht?vt:n.wrap<=0?Ef:(n.wrap===2?(P(n,t.adler&255),P(n,t.adler>>8&255),P(n,t.adler>>16&255),P(n,t.adler>>24&255),P(n,t.total_in&255),P(n,t.total_in>>8&255),P(n,t.total_in>>16&255),P(n,t.total_in>>24&255)):(Qe(n,t.adler>>>16),Qe(n,t.adler&65535)),Mt(t),n.wrap>0&&(n.wrap=-n.wrap),n.pending!==0?vt:Ef)}function H0(t){var e;return!t||!t.state?at:(e=t.state.status,e!==an&&e!==Ai&&e!==tn&&e!==en&&e!==rn&&e!==te&&e!==tr?zt(t,at):(t.state=null,e===te?zt(t,g0):vt))}function q0(t,e){var r=e.length,n,i,a,o,s,c,f,l;if(!t||!t.state||(n=t.state,o=n.wrap,o===2||o===1&&n.status!==an||n.lookahead))return at;for(o===1&&(t.adler=Sf(t.adler,e,r,0)),n.wrap=0,r>=n.w_size&&(o===0&&(Lt(n.head),n.strstart=0,n.block_start=0,n.insert=0),l=new K.Buf8(n.w_size),K.arraySet(l,e,r-n.w_size,n.w_size,0),e=l,r=n.w_size),s=t.avail_in,c=t.next_in,f=t.input,t.avail_in=r,t.next_in=0,t.input=e,re(n);n.lookahead>=F;){i=n.strstart,a=n.lookahead-(F-1);do n.ins_h=(n.ins_h<<n.hash_shift^n.window[i+F-1])&n.hash_mask,n.prev[i&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=i,i++;while(--a);n.strstart=i,n.lookahead=F-1,re(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=F-1,n.match_available=0,t.next_in=c,t.input=f,t.avail_in=s,n.wrap=o,vt}xt.deflateInit=G0;xt.deflateInit2=Of;xt.deflateReset=$f;xt.deflateResetKeep=Rf;xt.deflateSetHeader=L0;xt.deflate=z0;xt.deflateEnd=H0;xt.deflateSetDictionary=q0;xt.deflateInfo="pako deflate (from Nodeca project)"});var Ri=O($e=>{"use strict";var on=$t(),If=!0,Tf=!0;try{String.fromCharCode.apply(null,[0])}catch{If=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{Tf=!1}var rr=new on.Buf8(256);for(Bt=0;Bt<256;Bt++)rr[Bt]=Bt>=252?6:Bt>=248?5:Bt>=240?4:Bt>=224?3:Bt>=192?2:1;var Bt;rr[254]=rr[254]=1;$e.string2buf=function(t){var e,r,n,i,a,o=t.length,s=0;for(i=0;i<o;i++)r=t.charCodeAt(i),(r&64512)===55296&&i+1<o&&(n=t.charCodeAt(i+1),(n&64512)===56320&&(r=65536+(r-55296<<10)+(n-56320),i++)),s+=r<128?1:r<2048?2:r<65536?3:4;for(e=new on.Buf8(s),a=0,i=0;a<s;i++)r=t.charCodeAt(i),(r&64512)===55296&&i+1<o&&(n=t.charCodeAt(i+1),(n&64512)===56320&&(r=65536+(r-55296<<10)+(n-56320),i++)),r<128?e[a++]=r:r<2048?(e[a++]=192|r>>>6,e[a++]=128|r&63):r<65536?(e[a++]=224|r>>>12,e[a++]=128|r>>>6&63,e[a++]=128|r&63):(e[a++]=240|r>>>18,e[a++]=128|r>>>12&63,e[a++]=128|r>>>6&63,e[a++]=128|r&63);return e};function Cf(t,e){if(e<65534&&(t.subarray&&Tf||!t.subarray&&If))return String.fromCharCode.apply(null,on.shrinkBuf(t,e));for(var r="",n=0;n<e;n++)r+=String.fromCharCode(t[n]);return r}$e.buf2binstring=function(t){return Cf(t,t.length)};$e.binstring2buf=function(t){for(var e=new on.Buf8(t.length),r=0,n=e.length;r<n;r++)e[r]=t.charCodeAt(r);return e};$e.buf2string=function(t,e){var r,n,i,a,o=e||t.length,s=new Array(o*2);for(n=0,r=0;r<o;){if(i=t[r++],i<128){s[n++]=i;continue}if(a=rr[i],a>4){s[n++]=65533,r+=a-1;continue}for(i&=a===2?31:a===3?15:7;a>1&&r<o;)i=i<<6|t[r++]&63,a--;if(a>1){s[n++]=65533;continue}i<65536?s[n++]=i:(i-=65536,s[n++]=55296|i>>10&1023,s[n++]=56320|i&1023)}return Cf(s,n)};$e.utf8border=function(t,e){var r;for(e=e||t.length,e>t.length&&(e=t.length),r=e-1;r>=0&&(t[r]&192)===128;)r--;return r<0||r===0?e:r+rr[t[r]]>e?r:e}});var $i=O((zy,Ff)=>{"use strict";function W0(){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}Ff.exports=W0});var Uf=O(ar=>{"use strict";var nr=Bf(),ir=$t(),Bi=Ri(),Ii=Jr(),Z0=$i(),Nf=Object.prototype.toString,V0=0,Oi=4,Oe=0,Pf=1,Df=2,X0=-1,Y0=0,K0=8;function ie(t){if(!(this instanceof ie))return new ie(t);this.options=ir.assign({level:X0,method:K0,chunkSize:16384,windowBits:15,memLevel:8,strategy:Y0,to:""},t||{});var e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Z0,this.strm.avail_out=0;var r=nr.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(r!==Oe)throw new Error(Ii[r]);if(e.header&&nr.deflateSetHeader(this.strm,e.header),e.dictionary){var n;if(typeof e.dictionary=="string"?n=Bi.string2buf(e.dictionary):Nf.call(e.dictionary)==="[object ArrayBuffer]"?n=new Uint8Array(e.dictionary):n=e.dictionary,r=nr.deflateSetDictionary(this.strm,n),r!==Oe)throw new Error(Ii[r]);this._dict_set=!0}}ie.prototype.push=function(t,e){var r=this.strm,n=this.options.chunkSize,i,a;if(this.ended)return!1;a=e===~~e?e:e===!0?Oi:V0,typeof t=="string"?r.input=Bi.string2buf(t):Nf.call(t)==="[object ArrayBuffer]"?r.input=new Uint8Array(t):r.input=t,r.next_in=0,r.avail_in=r.input.length;do{if(r.avail_out===0&&(r.output=new ir.Buf8(n),r.next_out=0,r.avail_out=n),i=nr.deflate(r,a),i!==Pf&&i!==Oe)return this.onEnd(i),this.ended=!0,!1;(r.avail_out===0||r.avail_in===0&&(a===Oi||a===Df))&&(this.options.to==="string"?this.onData(Bi.buf2binstring(ir.shrinkBuf(r.output,r.next_out))):this.onData(ir.shrinkBuf(r.output,r.next_out)))}while((r.avail_in>0||r.avail_out===0)&&i!==Pf);return a===Oi?(i=nr.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===Oe):(a===Df&&(this.onEnd(Oe),r.avail_out=0),!0)};ie.prototype.onData=function(t){this.chunks.push(t)};ie.prototype.onEnd=function(t){t===Oe&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=ir.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};function Ti(t,e){var r=new ie(e);if(r.push(t,!0),r.err)throw r.msg||Ii[r.err];return r.result}function J0(t,e){return e=e||{},e.raw=!0,Ti(t,e)}function Q0(t,e){return e=e||{},e.gzip=!0,Ti(t,e)}ar.Deflate=ie;ar.deflate=Ti;ar.deflateRaw=J0;ar.gzip=Q0});var Mf=O((qy,jf)=>{"use strict";var sn=30,tw=12;jf.exports=function(e,r){var n,i,a,o,s,c,f,l,u,d,h,p,w,y,b,E,S,A,m,$,g,x,_,R,k;n=e.state,i=e.next_in,R=e.input,a=i+(e.avail_in-5),o=e.next_out,k=e.output,s=o-(r-e.avail_out),c=o+(e.avail_out-257),f=n.dmax,l=n.wsize,u=n.whave,d=n.wnext,h=n.window,p=n.hold,w=n.bits,y=n.lencode,b=n.distcode,E=(1<<n.lenbits)-1,S=(1<<n.distbits)-1;t:do{w<15&&(p+=R[i++]<<w,w+=8,p+=R[i++]<<w,w+=8),A=y[p&E];e:for(;;){if(m=A>>>24,p>>>=m,w-=m,m=A>>>16&255,m===0)k[o++]=A&65535;else if(m&16){$=A&65535,m&=15,m&&(w<m&&(p+=R[i++]<<w,w+=8),$+=p&(1<<m)-1,p>>>=m,w-=m),w<15&&(p+=R[i++]<<w,w+=8,p+=R[i++]<<w,w+=8),A=b[p&S];r:for(;;){if(m=A>>>24,p>>>=m,w-=m,m=A>>>16&255,m&16){if(g=A&65535,m&=15,w<m&&(p+=R[i++]<<w,w+=8,w<m&&(p+=R[i++]<<w,w+=8)),g+=p&(1<<m)-1,g>f){e.msg="invalid distance too far back",n.mode=sn;break t}if(p>>>=m,w-=m,m=o-s,g>m){if(m=g-m,m>u&&n.sane){e.msg="invalid distance too far back",n.mode=sn;break t}if(x=0,_=h,d===0){if(x+=l-m,m<$){$-=m;do k[o++]=h[x++];while(--m);x=o-g,_=k}}else if(d<m){if(x+=l+d-m,m-=d,m<$){$-=m;do k[o++]=h[x++];while(--m);if(x=0,d<$){m=d,$-=m;do k[o++]=h[x++];while(--m);x=o-g,_=k}}}else if(x+=d-m,m<$){$-=m;do k[o++]=h[x++];while(--m);x=o-g,_=k}for(;$>2;)k[o++]=_[x++],k[o++]=_[x++],k[o++]=_[x++],$-=3;$&&(k[o++]=_[x++],$>1&&(k[o++]=_[x++]))}else{x=o-g;do k[o++]=k[x++],k[o++]=k[x++],k[o++]=k[x++],$-=3;while($>2);$&&(k[o++]=k[x++],$>1&&(k[o++]=k[x++]))}}else if((m&64)===0){A=b[(A&65535)+(p&(1<<m)-1)];continue r}else{e.msg="invalid distance code",n.mode=sn;break t}break}}else if((m&64)===0){A=y[(A&65535)+(p&(1<<m)-1)];continue e}else if(m&32){n.mode=tw;break t}else{e.msg="invalid literal/length code",n.mode=sn;break t}break}}while(i<a&&o<c);$=w>>3,i-=$,w-=$<<3,p&=(1<<w)-1,e.next_in=i,e.next_out=o,e.avail_in=i<a?5+(a-i):5-(i-a),e.avail_out=o<c?257+(c-o):257-(o-c),n.hold=p,n.bits=w}});var Zf=O((Wy,Wf)=>{"use strict";var Lf=$t(),Be=15,Gf=852,zf=592,Hf=0,Ci=1,qf=2,ew=[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],rw=[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],nw=[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],iw=[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];Wf.exports=function(e,r,n,i,a,o,s,c){var f=c.bits,l=0,u=0,d=0,h=0,p=0,w=0,y=0,b=0,E=0,S=0,A,m,$,g,x,_=null,R=0,k,B=new Lf.Buf16(Be+1),N=new Lf.Buf16(Be+1),M=null,no=0,io,Rr,$r;for(l=0;l<=Be;l++)B[l]=0;for(u=0;u<i;u++)B[r[n+u]]++;for(p=f,h=Be;h>=1&&B[h]===0;h--);if(p>h&&(p=h),h===0)return a[o++]=1<<24|64<<16|0,a[o++]=1<<24|64<<16|0,c.bits=1,0;for(d=1;d<h&&B[d]===0;d++);for(p<d&&(p=d),b=1,l=1;l<=Be;l++)if(b<<=1,b-=B[l],b<0)return-1;if(b>0&&(e===Hf||h!==1))return-1;for(N[1]=0,l=1;l<Be;l++)N[l+1]=N[l]+B[l];for(u=0;u<i;u++)r[n+u]!==0&&(s[N[r[n+u]]++]=u);if(e===Hf?(_=M=s,k=19):e===Ci?(_=ew,R-=257,M=rw,no-=257,k=256):(_=nw,M=iw,k=-1),S=0,u=0,l=d,x=o,w=p,y=0,$=-1,E=1<<p,g=E-1,e===Ci&&E>Gf||e===qf&&E>zf)return 1;for(;;){io=l-y,s[u]<k?(Rr=0,$r=s[u]):s[u]>k?(Rr=M[no+s[u]],$r=_[R+s[u]]):(Rr=96,$r=0),A=1<<l-y,m=1<<w,d=m;do m-=A,a[x+(S>>y)+m]=io<<24|Rr<<16|$r|0;while(m!==0);for(A=1<<l-1;S&A;)A>>=1;if(A!==0?(S&=A-1,S+=A):S=0,u++,--B[l]===0){if(l===h)break;l=r[n+s[u]]}if(l>p&&(S&g)!==$){for(y===0&&(y=p),x+=d,w=l-y,b=1<<w;w+y<h&&(b-=B[w+y],!(b<=0));)w++,b<<=1;if(E+=1<<w,e===Ci&&E>Gf||e===qf&&E>zf)return 1;$=S&g,a[$]=p<<24|w<<16|x-o|0}}return S!==0&&(a[x+S]=l-y<<24|64<<16|0),c.bits=p,0}});var $l=O(ht=>{"use strict";var et=$t(),ji=vi(),Et=xi(),aw=Mf(),or=Zf(),ow=0,bl=1,_l=2,Vf=4,sw=5,cn=6,ae=0,cw=1,fw=2,ot=-2,vl=-3,Mi=-4,lw=-5,Xf=8,xl=1,Yf=2,Kf=3,Jf=4,Qf=5,tl=6,el=7,rl=8,nl=9,il=10,un=11,It=12,Fi=13,al=14,Pi=15,ol=16,sl=17,cl=18,fl=19,fn=20,ln=21,ll=22,ul=23,dl=24,hl=25,pl=26,Di=27,wl=28,ml=29,j=30,Li=31,uw=32,dw=852,hw=592,pw=15,ww=pw;function gl(t){return(t>>>24&255)+(t>>>8&65280)+((t&65280)<<8)+((t&255)<<24)}function mw(){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 et.Buf16(320),this.work=new et.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function El(t){var e;return!t||!t.state?ot:(e=t.state,t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=e.wrap&1),e.mode=xl,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new et.Buf32(dw),e.distcode=e.distdyn=new et.Buf32(hw),e.sane=1,e.back=-1,ae)}function kl(t){var e;return!t||!t.state?ot:(e=t.state,e.wsize=0,e.whave=0,e.wnext=0,El(t))}function Sl(t,e){var r,n;return!t||!t.state||(n=t.state,e<0?(r=0,e=-e):(r=(e>>4)+1,e<48&&(e&=15)),e&&(e<8||e>15))?ot:(n.window!==null&&n.wbits!==e&&(n.window=null),n.wrap=r,n.wbits=e,kl(t))}function Al(t,e){var r,n;return t?(n=new mw,t.state=n,n.window=null,r=Sl(t,e),r!==ae&&(t.state=null),r):ot}function gw(t){return Al(t,ww)}var yl=!0,Ni,Ui;function yw(t){if(yl){var e;for(Ni=new et.Buf32(512),Ui=new et.Buf32(32),e=0;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(or(bl,t.lens,0,288,Ni,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;or(_l,t.lens,0,32,Ui,0,t.work,{bits:5}),yl=!1}t.lencode=Ni,t.lenbits=9,t.distcode=Ui,t.distbits=5}function Rl(t,e,r,n){var i,a=t.state;return a.window===null&&(a.wsize=1<<a.wbits,a.wnext=0,a.whave=0,a.window=new et.Buf8(a.wsize)),n>=a.wsize?(et.arraySet(a.window,e,r-a.wsize,a.wsize,0),a.wnext=0,a.whave=a.wsize):(i=a.wsize-a.wnext,i>n&&(i=n),et.arraySet(a.window,e,r-n,i,a.wnext),n-=i,n?(et.arraySet(a.window,e,r-n,n,0),a.wnext=n,a.whave=a.wsize):(a.wnext+=i,a.wnext===a.wsize&&(a.wnext=0),a.whave<a.wsize&&(a.whave+=i))),0}function bw(t,e){var r,n,i,a,o,s,c,f,l,u,d,h,p,w,y=0,b,E,S,A,m,$,g,x,_=new et.Buf8(4),R,k,B=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!t||!t.state||!t.output||!t.input&&t.avail_in!==0)return ot;r=t.state,r.mode===It&&(r.mode=Fi),o=t.next_out,i=t.output,c=t.avail_out,a=t.next_in,n=t.input,s=t.avail_in,f=r.hold,l=r.bits,u=s,d=c,x=ae;t:for(;;)switch(r.mode){case xl:if(r.wrap===0){r.mode=Fi;break}for(;l<16;){if(s===0)break t;s--,f+=n[a++]<<l,l+=8}if(r.wrap&2&&f===35615){r.check=0,_[0]=f&255,_[1]=f>>>8&255,r.check=Et(r.check,_,2,0),f=0,l=0,r.mode=Yf;break}if(r.flags=0,r.head&&(r.head.done=!1),!(r.wrap&1)||(((f&255)<<8)+(f>>8))%31){t.msg="incorrect header check",r.mode=j;break}if((f&15)!==Xf){t.msg="unknown compression method",r.mode=j;break}if(f>>>=4,l-=4,g=(f&15)+8,r.wbits===0)r.wbits=g;else if(g>r.wbits){t.msg="invalid window size",r.mode=j;break}r.dmax=1<<g,t.adler=r.check=1,r.mode=f&512?il:It,f=0,l=0;break;case Yf:for(;l<16;){if(s===0)break t;s--,f+=n[a++]<<l,l+=8}if(r.flags=f,(r.flags&255)!==Xf){t.msg="unknown compression method",r.mode=j;break}if(r.flags&57344){t.msg="unknown header flags set",r.mode=j;break}r.head&&(r.head.text=f>>8&1),r.flags&512&&(_[0]=f&255,_[1]=f>>>8&255,r.check=Et(r.check,_,2,0)),f=0,l=0,r.mode=Kf;case Kf:for(;l<32;){if(s===0)break t;s--,f+=n[a++]<<l,l+=8}r.head&&(r.head.time=f),r.flags&512&&(_[0]=f&255,_[1]=f>>>8&255,_[2]=f>>>16&255,_[3]=f>>>24&255,r.check=Et(r.check,_,4,0)),f=0,l=0,r.mode=Jf;case Jf:for(;l<16;){if(s===0)break t;s--,f+=n[a++]<<l,l+=8}r.head&&(r.head.xflags=f&255,r.head.os=f>>8),r.flags&512&&(_[0]=f&255,_[1]=f>>>8&255,r.check=Et(r.check,_,2,0)),f=0,l=0,r.mode=Qf;case Qf:if(r.flags&1024){for(;l<16;){if(s===0)break t;s--,f+=n[a++]<<l,l+=8}r.length=f,r.head&&(r.head.extra_len=f),r.flags&512&&(_[0]=f&255,_[1]=f>>>8&255,r.check=Et(r.check,_,2,0)),f=0,l=0}else r.head&&(r.head.extra=null);r.mode=tl;case tl:if(r.flags&1024&&(h=r.length,h>s&&(h=s),h&&(r.head&&(g=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Array(r.head.extra_len)),et.arraySet(r.head.extra,n,a,h,g)),r.flags&512&&(r.check=Et(r.check,n,h,a)),s-=h,a+=h,r.length-=h),r.length))break t;r.length=0,r.mode=el;case el:if(r.flags&2048){if(s===0)break t;h=0;do g=n[a+h++],r.head&&g&&r.length<65536&&(r.head.name+=String.fromCharCode(g));while(g&&h<s);if(r.flags&512&&(r.check=Et(r.check,n,h,a)),s-=h,a+=h,g)break t}else r.head&&(r.head.name=null);r.length=0,r.mode=rl;case rl:if(r.flags&4096){if(s===0)break t;h=0;do g=n[a+h++],r.head&&g&&r.length<65536&&(r.head.comment+=String.fromCharCode(g));while(g&&h<s);if(r.flags&512&&(r.check=Et(r.check,n,h,a)),s-=h,a+=h,g)break t}else r.head&&(r.head.comment=null);r.mode=nl;case nl:if(r.flags&512){for(;l<16;){if(s===0)break t;s--,f+=n[a++]<<l,l+=8}if(f!==(r.check&65535)){t.msg="header crc mismatch",r.mode=j;break}f=0,l=0}r.head&&(r.head.hcrc=r.flags>>9&1,r.head.done=!0),t.adler=r.check=0,r.mode=It;break;case il:for(;l<32;){if(s===0)break t;s--,f+=n[a++]<<l,l+=8}t.adler=r.check=gl(f),f=0,l=0,r.mode=un;case un:if(r.havedict===0)return t.next_out=o,t.avail_out=c,t.next_in=a,t.avail_in=s,r.hold=f,r.bits=l,fw;t.adler=r.check=1,r.mode=It;case It:if(e===sw||e===cn)break t;case Fi:if(r.last){f>>>=l&7,l-=l&7,r.mode=Di;break}for(;l<3;){if(s===0)break t;s--,f+=n[a++]<<l,l+=8}switch(r.last=f&1,f>>>=1,l-=1,f&3){case 0:r.mode=al;break;case 1:if(yw(r),r.mode=fn,e===cn){f>>>=2,l-=2;break t}break;case 2:r.mode=sl;break;case 3:t.msg="invalid block type",r.mode=j}f>>>=2,l-=2;break;case al:for(f>>>=l&7,l-=l&7;l<32;){if(s===0)break t;s--,f+=n[a++]<<l,l+=8}if((f&65535)!==(f>>>16^65535)){t.msg="invalid stored block lengths",r.mode=j;break}if(r.length=f&65535,f=0,l=0,r.mode=Pi,e===cn)break t;case Pi:r.mode=ol;case ol:if(h=r.length,h){if(h>s&&(h=s),h>c&&(h=c),h===0)break t;et.arraySet(i,n,a,h,o),s-=h,a+=h,c-=h,o+=h,r.length-=h;break}r.mode=It;break;case sl:for(;l<14;){if(s===0)break t;s--,f+=n[a++]<<l,l+=8}if(r.nlen=(f&31)+257,f>>>=5,l-=5,r.ndist=(f&31)+1,f>>>=5,l-=5,r.ncode=(f&15)+4,f>>>=4,l-=4,r.nlen>286||r.ndist>30){t.msg="too many length or distance symbols",r.mode=j;break}r.have=0,r.mode=cl;case cl:for(;r.have<r.ncode;){for(;l<3;){if(s===0)break t;s--,f+=n[a++]<<l,l+=8}r.lens[B[r.have++]]=f&7,f>>>=3,l-=3}for(;r.have<19;)r.lens[B[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,R={bits:r.lenbits},x=or(ow,r.lens,0,19,r.lencode,0,r.work,R),r.lenbits=R.bits,x){t.msg="invalid code lengths set",r.mode=j;break}r.have=0,r.mode=fl;case fl:for(;r.have<r.nlen+r.ndist;){for(;y=r.lencode[f&(1<<r.lenbits)-1],b=y>>>24,E=y>>>16&255,S=y&65535,!(b<=l);){if(s===0)break t;s--,f+=n[a++]<<l,l+=8}if(S<16)f>>>=b,l-=b,r.lens[r.have++]=S;else{if(S===16){for(k=b+2;l<k;){if(s===0)break t;s--,f+=n[a++]<<l,l+=8}if(f>>>=b,l-=b,r.have===0){t.msg="invalid bit length repeat",r.mode=j;break}g=r.lens[r.have-1],h=3+(f&3),f>>>=2,l-=2}else if(S===17){for(k=b+3;l<k;){if(s===0)break t;s--,f+=n[a++]<<l,l+=8}f>>>=b,l-=b,g=0,h=3+(f&7),f>>>=3,l-=3}else{for(k=b+7;l<k;){if(s===0)break t;s--,f+=n[a++]<<l,l+=8}f>>>=b,l-=b,g=0,h=11+(f&127),f>>>=7,l-=7}if(r.have+h>r.nlen+r.ndist){t.msg="invalid bit length repeat",r.mode=j;break}for(;h--;)r.lens[r.have++]=g}}if(r.mode===j)break;if(r.lens[256]===0){t.msg="invalid code -- missing end-of-block",r.mode=j;break}if(r.lenbits=9,R={bits:r.lenbits},x=or(bl,r.lens,0,r.nlen,r.lencode,0,r.work,R),r.lenbits=R.bits,x){t.msg="invalid literal/lengths set",r.mode=j;break}if(r.distbits=6,r.distcode=r.distdyn,R={bits:r.distbits},x=or(_l,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,R),r.distbits=R.bits,x){t.msg="invalid distances set",r.mode=j;break}if(r.mode=fn,e===cn)break t;case fn:r.mode=ln;case ln:if(s>=6&&c>=258){t.next_out=o,t.avail_out=c,t.next_in=a,t.avail_in=s,r.hold=f,r.bits=l,aw(t,d),o=t.next_out,i=t.output,c=t.avail_out,a=t.next_in,n=t.input,s=t.avail_in,f=r.hold,l=r.bits,r.mode===It&&(r.back=-1);break}for(r.back=0;y=r.lencode[f&(1<<r.lenbits)-1],b=y>>>24,E=y>>>16&255,S=y&65535,!(b<=l);){if(s===0)break t;s--,f+=n[a++]<<l,l+=8}if(E&&(E&240)===0){for(A=b,m=E,$=S;y=r.lencode[$+((f&(1<<A+m)-1)>>A)],b=y>>>24,E=y>>>16&255,S=y&65535,!(A+b<=l);){if(s===0)break t;s--,f+=n[a++]<<l,l+=8}f>>>=A,l-=A,r.back+=A}if(f>>>=b,l-=b,r.back+=b,r.length=S,E===0){r.mode=pl;break}if(E&32){r.back=-1,r.mode=It;break}if(E&64){t.msg="invalid literal/length code",r.mode=j;break}r.extra=E&15,r.mode=ll;case ll:if(r.extra){for(k=r.extra;l<k;){if(s===0)break t;s--,f+=n[a++]<<l,l+=8}r.length+=f&(1<<r.extra)-1,f>>>=r.extra,l-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=ul;case ul:for(;y=r.distcode[f&(1<<r.distbits)-1],b=y>>>24,E=y>>>16&255,S=y&65535,!(b<=l);){if(s===0)break t;s--,f+=n[a++]<<l,l+=8}if((E&240)===0){for(A=b,m=E,$=S;y=r.distcode[$+((f&(1<<A+m)-1)>>A)],b=y>>>24,E=y>>>16&255,S=y&65535,!(A+b<=l);){if(s===0)break t;s--,f+=n[a++]<<l,l+=8}f>>>=A,l-=A,r.back+=A}if(f>>>=b,l-=b,r.back+=b,E&64){t.msg="invalid distance code",r.mode=j;break}r.offset=S,r.extra=E&15,r.mode=dl;case dl:if(r.extra){for(k=r.extra;l<k;){if(s===0)break t;s--,f+=n[a++]<<l,l+=8}r.offset+=f&(1<<r.extra)-1,f>>>=r.extra,l-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){t.msg="invalid distance too far back",r.mode=j;break}r.mode=hl;case hl:if(c===0)break t;if(h=d-c,r.offset>h){if(h=r.offset-h,h>r.whave&&r.sane){t.msg="invalid distance too far back",r.mode=j;break}h>r.wnext?(h-=r.wnext,p=r.wsize-h):p=r.wnext-h,h>r.length&&(h=r.length),w=r.window}else w=i,p=o-r.offset,h=r.length;h>c&&(h=c),c-=h,r.length-=h;do i[o++]=w[p++];while(--h);r.length===0&&(r.mode=ln);break;case pl:if(c===0)break t;i[o++]=r.length,c--,r.mode=ln;break;case Di:if(r.wrap){for(;l<32;){if(s===0)break t;s--,f|=n[a++]<<l,l+=8}if(d-=c,t.total_out+=d,r.total+=d,d&&(t.adler=r.check=r.flags?Et(r.check,i,d,o-d):ji(r.check,i,d,o-d)),d=c,(r.flags?f:gl(f))!==r.check){t.msg="incorrect data check",r.mode=j;break}f=0,l=0}r.mode=wl;case wl:if(r.wrap&&r.flags){for(;l<32;){if(s===0)break t;s--,f+=n[a++]<<l,l+=8}if(f!==(r.total&4294967295)){t.msg="incorrect length check",r.mode=j;break}f=0,l=0}r.mode=ml;case ml:x=cw;break t;case j:x=vl;break t;case Li:return Mi;case uw:default:return ot}return t.next_out=o,t.avail_out=c,t.next_in=a,t.avail_in=s,r.hold=f,r.bits=l,(r.wsize||d!==t.avail_out&&r.mode<j&&(r.mode<Di||e!==Vf))&&Rl(t,t.output,t.next_out,d-t.avail_out)?(r.mode=Li,Mi):(u-=t.avail_in,d-=t.avail_out,t.total_in+=u,t.total_out+=d,r.total+=d,r.wrap&&d&&(t.adler=r.check=r.flags?Et(r.check,i,d,t.next_out-d):ji(r.check,i,d,t.next_out-d)),t.data_type=r.bits+(r.last?64:0)+(r.mode===It?128:0)+(r.mode===fn||r.mode===Pi?256:0),(u===0&&d===0||e===Vf)&&x===ae&&(x=lw),x)}function _w(t){if(!t||!t.state)return ot;var e=t.state;return e.window&&(e.window=null),t.state=null,ae}function vw(t,e){var r;return!t||!t.state||(r=t.state,(r.wrap&2)===0)?ot:(r.head=e,e.done=!1,ae)}function xw(t,e){var r=e.length,n,i,a;return!t||!t.state||(n=t.state,n.wrap!==0&&n.mode!==un)?ot:n.mode===un&&(i=1,i=ji(i,e,r,0),i!==n.check)?vl:(a=Rl(t,e,r,r),a?(n.mode=Li,Mi):(n.havedict=1,ae))}ht.inflateReset=kl;ht.inflateReset2=Sl;ht.inflateResetKeep=El;ht.inflateInit=gw;ht.inflateInit2=Al;ht.inflate=bw;ht.inflateEnd=_w;ht.inflateGetHeader=vw;ht.inflateSetDictionary=xw;ht.inflateInfo="pako inflate (from Nodeca project)"});var Gi=O((Vy,Ol)=>{"use strict";Ol.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 Il=O((Xy,Bl)=>{"use strict";function Ew(){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}Bl.exports=Ew});var Cl=O(cr=>{"use strict";var Ie=$l(),sr=$t(),dn=Ri(),L=Gi(),zi=Jr(),kw=$i(),Sw=Il(),Tl=Object.prototype.toString;function oe(t){if(!(this instanceof oe))return new oe(t);this.options=sr.assign({chunkSize:16384,windowBits:0,to:""},t||{});var e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,e.windowBits===0&&(e.windowBits=-15)),e.windowBits>=0&&e.windowBits<16&&!(t&&t.windowBits)&&(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&(e.windowBits&15)===0&&(e.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new kw,this.strm.avail_out=0;var r=Ie.inflateInit2(this.strm,e.windowBits);if(r!==L.Z_OK)throw new Error(zi[r]);if(this.header=new Sw,Ie.inflateGetHeader(this.strm,this.header),e.dictionary&&(typeof e.dictionary=="string"?e.dictionary=dn.string2buf(e.dictionary):Tl.call(e.dictionary)==="[object ArrayBuffer]"&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(r=Ie.inflateSetDictionary(this.strm,e.dictionary),r!==L.Z_OK)))throw new Error(zi[r])}oe.prototype.push=function(t,e){var r=this.strm,n=this.options.chunkSize,i=this.options.dictionary,a,o,s,c,f,l=!1;if(this.ended)return!1;o=e===~~e?e:e===!0?L.Z_FINISH:L.Z_NO_FLUSH,typeof t=="string"?r.input=dn.binstring2buf(t):Tl.call(t)==="[object ArrayBuffer]"?r.input=new Uint8Array(t):r.input=t,r.next_in=0,r.avail_in=r.input.length;do{if(r.avail_out===0&&(r.output=new sr.Buf8(n),r.next_out=0,r.avail_out=n),a=Ie.inflate(r,L.Z_NO_FLUSH),a===L.Z_NEED_DICT&&i&&(a=Ie.inflateSetDictionary(this.strm,i)),a===L.Z_BUF_ERROR&&l===!0&&(a=L.Z_OK,l=!1),a!==L.Z_STREAM_END&&a!==L.Z_OK)return this.onEnd(a),this.ended=!0,!1;r.next_out&&(r.avail_out===0||a===L.Z_STREAM_END||r.avail_in===0&&(o===L.Z_FINISH||o===L.Z_SYNC_FLUSH))&&(this.options.to==="string"?(s=dn.utf8border(r.output,r.next_out),c=r.next_out-s,f=dn.buf2string(r.output,s),r.next_out=c,r.avail_out=n-c,c&&sr.arraySet(r.output,r.output,s,c,0),this.onData(f)):this.onData(sr.shrinkBuf(r.output,r.next_out))),r.avail_in===0&&r.avail_out===0&&(l=!0)}while((r.avail_in>0||r.avail_out===0)&&a!==L.Z_STREAM_END);return a===L.Z_STREAM_END&&(o=L.Z_FINISH),o===L.Z_FINISH?(a=Ie.inflateEnd(this.strm),this.onEnd(a),this.ended=!0,a===L.Z_OK):(o===L.Z_SYNC_FLUSH&&(this.onEnd(L.Z_OK),r.avail_out=0),!0)};oe.prototype.onData=function(t){this.chunks.push(t)};oe.prototype.onEnd=function(t){t===L.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=sr.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};function Hi(t,e){var r=new oe(e);if(r.push(t,!0),r.err)throw r.msg||zi[r.err];return r.result}function Aw(t,e){return e=e||{},e.raw=!0,Hi(t,e)}cr.Inflate=oe;cr.inflate=Hi;cr.inflateRaw=Aw;cr.ungzip=Hi});var Dl=O((Ky,Pl)=>{"use strict";var Rw=$t().assign,$w=Uf(),Ow=Cl(),Bw=Gi(),Fl={};Rw(Fl,$w,Ow,Bw);Pl.exports=Fl});var jl=O((Jy,Ul)=>{"use strict";var Nl=(t,e)=>function(...r){let n=e.promiseModule;return new n((i,a)=>{e.multiArgs?r.push((...o)=>{e.errorFirst?o[0]?a(o):(o.shift(),i(o)):i(o)}):e.errorFirst?r.push((o,s)=>{o?a(o):i(s)}):r.push(i),t.apply(this,r)})};Ul.exports=(t,e)=>{e=Object.assign({exclude:[/.+(Sync|Stream)$/],errorFirst:!0,promiseModule:Promise},e);let r=typeof t;if(!(t!==null&&(r==="object"||r==="function")))throw new TypeError(`Expected \`input\` to be a \`Function\` or \`Object\`, got \`${t===null?"null":r}\``);let n=a=>{let o=s=>typeof s=="string"?a===s:s.test(a);return e.include?e.include.some(o):!e.exclude.some(o)},i;r==="function"?i=function(...a){return e.excludeMain?t(...a):Nl(t,e).apply(this,a)}:i=Object.create(Object.getPrototypeOf(t));for(let a in t){let o=t[a];i[a]=typeof o=="function"&&n(a)?Nl(o,e):o}return i}});var Vl=O((Qy,Zl)=>{function Ml(t){return Array.isArray(t)?t:[t]}var Zi="",Ll=" ",qi="\\",Iw=/^\s+$/,Tw=/(?:[^\\]|^)\\$/,Cw=/^\\!/,Fw=/^\\#/,Pw=/\r?\n/g,Dw=/^\.*\/|^\.+$/,Wi="/",Hl="node-ignore";typeof Symbol<"u"&&(Hl=Symbol.for("node-ignore"));var Gl=Hl,Nw=(t,e,r)=>Object.defineProperty(t,e,{value:r}),Uw=/([0-z])-([0-z])/g,ql=()=>!1,jw=t=>t.replace(Uw,(e,r,n)=>r.charCodeAt(0)<=n.charCodeAt(0)?e:Zi),Mw=t=>{let{length:e}=t;return t.slice(0,e-e%2)},Lw=[[/^\uFEFF/,()=>Zi],[/((?:\\\\)*?)(\\?\s+)$/,(t,e,r)=>e+(r.indexOf("\\")===0?Ll:Zi)],[/(\\+?)\s/g,(t,e)=>{let{length:r}=e;return e.slice(0,r-r%2)+Ll}],[/[\\$.|*+(){^]/g,t=>`\\${t}`],[/(?!\\)\?/g,()=>"[^/]"],[/^\//,()=>"^"],[/\//g,()=>"\\/"],[/^\^*\\\*\\\*\\\//,()=>"^(?:.*\\/)?"],[/^(?=[^^])/,function(){return/\/(?!$)/.test(this)?"^":"(?:^|\\/)"}],[/\\\/\\\*\\\*(?=\\\/|$)/g,(t,e,r)=>e+6<r.length?"(?:\\/[^\\/]+)*":"\\/.+"],[/(^|[^\\]+)(\\\*)+(?=.+)/g,(t,e,r)=>{let n=r.replace(/\\\*/g,"[^\\/]*");return e+n}],[/\\\\\\(?=[$.|*+(){^])/g,()=>qi],[/\\\\/g,()=>qi],[/(\\)?\[([^\]/]*?)(\\*)($|\])/g,(t,e,r,n,i)=>e===qi?`\\[${r}${Mw(n)}${i}`:i==="]"&&n.length%2===0?`[${jw(r)}${n}]`:"[]"],[/(?:[^*])$/,t=>/\/$/.test(t)?`${t}$`:`${t}(?=$|\\/$)`],[/(\^|\\\/)?\\\*$/,(t,e)=>`${e?`${e}[^/]+`:"[^/]*"}(?=$|\\/$)`]],zl=Object.create(null),Gw=(t,e)=>{let r=zl[t];return r||(r=Lw.reduce((n,[i,a])=>n.replace(i,a.bind(t)),t),zl[t]=r),e?new RegExp(r,"i"):new RegExp(r)},Yi=t=>typeof t=="string",zw=t=>t&&Yi(t)&&!Iw.test(t)&&!Tw.test(t)&&t.indexOf("#")!==0,Hw=t=>t.split(Pw),Vi=class{constructor(e,r,n,i){this.origin=e,this.pattern=r,this.negative=n,this.regex=i}},qw=(t,e)=>{let r=t,n=!1;t.indexOf("!")===0&&(n=!0,t=t.substr(1)),t=t.replace(Cw,"!").replace(Fw,"#");let i=Gw(t,e);return new Vi(r,t,n,i)},Ww=(t,e)=>{throw new e(t)},Tt=(t,e,r)=>Yi(t)?t?Tt.isNotRelative(t)?r(`path should be a \`path.relative()\`d string, but got "${e}"`,RangeError):!0:r("path must not be empty",TypeError):r(`path must be a string, but got \`${e}\``,TypeError),Wl=t=>Dw.test(t);Tt.isNotRelative=Wl;Tt.convert=t=>t;var Xi=class{constructor({ignorecase:e=!0,ignoreCase:r=e,allowRelativePaths:n=!1}={}){Nw(this,Gl,!0),this._rules=[],this._ignoreCase=r,this._allowRelativePaths=n,this._initCache()}_initCache(){this._ignoreCache=Object.create(null),this._testCache=Object.create(null)}_addPattern(e){if(e&&e[Gl]){this._rules=this._rules.concat(e._rules),this._added=!0;return}if(zw(e)){let r=qw(e,this._ignoreCase);this._added=!0,this._rules.push(r)}}add(e){return this._added=!1,Ml(Yi(e)?Hw(e):e).forEach(this._addPattern,this),this._added&&this._initCache(),this}addPattern(e){return this.add(e)}_testOne(e,r){let n=!1,i=!1;return this._rules.forEach(a=>{let{negative:o}=a;if(i===o&&n!==i||o&&!n&&!i&&!r)return;a.regex.test(e)&&(n=!o,i=o)}),{ignored:n,unignored:i}}_test(e,r,n,i){let a=e&&Tt.convert(e);return Tt(a,e,this._allowRelativePaths?ql:Ww),this._t(a,r,n,i)}_t(e,r,n,i){if(e in r)return r[e];if(i||(i=e.split(Wi)),i.pop(),!i.length)return r[e]=this._testOne(e,n);let a=this._t(i.join(Wi)+Wi,r,n,i);return r[e]=a.ignored?a:this._testOne(e,n)}ignores(e){return this._test(e,this._ignoreCache,!1).ignored}createFilter(){return e=>!this.ignores(e)}filter(e){return Ml(e).filter(this.createFilter())}test(e){return this._test(e,this._testCache,!0)}},hn=t=>new Xi(t),Zw=t=>Tt(t&&Tt.convert(t),t,ql);hn.isPathValid=Zw;hn.default=hn;Zl.exports=hn;if(typeof process<"u"&&(process.env&&process.env.IGNORE_TEST_WIN32||process.platform==="win32")){let t=r=>/^\\\\\?\\/.test(r)||/["<>|\u0000-\u001F]+/u.test(r)?r:r.replace(/\\/g,"/");Tt.convert=t;let e=/^[a-z]:\//i;Tt.isNotRelative=r=>e.test(r)||Wl(r)}});var Yl=O((tb,Xl)=>{Xl.exports=function(t,e){var r=t,n=e,i=r.length,a=n.length,o=!1,s=null,c=i+1,f=[],l=[],u=[],d="",h=-1,p=0,w=1,y,b,E=function(){i>=a&&(y=r,b=i,r=n,n=y,i=a,a=b,o=!0,c=i+1)},S=function(g,x,_){return{x:g,y:x,k:_}},A=function(g,x){return{elem:g,t:x}},m=function(g,x,_){var R,k,B;for(x>_?R=f[g-1+c]:R=f[g+1+c],B=Math.max(x,_),k=B-g;k<i&&B<a&&r[k]===n[B];)++k,++B;return f[g+c]=l.length,l[l.length]=new S(k,B,R),B},$=function(g){var x,_,R,k,B;for(x=_=1,R=k=0,B=g.length-1;B>=0;--B)for(;R<g[B].x||k<g[B].y;)g[B].y-g[B].x>k-R?(o?u[u.length]=new A(n[k],h):u[u.length]=new A(n[k],w),++_,++k):g[B].y-g[B].x<k-R?(o?u[u.length]=new A(r[R],w):u[u.length]=new A(r[R],h),++x,++R):(u[u.length]=new A(r[R],p),d+=r[R],++x,++_,++R,++k)};return E(),{SES_DELETE:-1,SES_COMMON:0,SES_ADD:1,editdistance:function(){return s},getlcs:function(){return d},getses:function(){return u},compose:function(){var g,x,_,R,k,B,N,M;for(g=a-i,x=i+a+3,_={},N=0;N<x;++N)_[N]=-1,f[N]=-1;R=-1;do{for(++R,M=-R;M<=g-1;++M)_[M+c]=m(M,_[M-1+c]+1,_[M+1+c]);for(M=g+R;M>=g+1;--M)_[M+c]=m(M,_[M-1+c]+1,_[M+1+c]);_[g+c]=m(g,_[g-1+c]+1,_[g+1+c])}while(_[g+c]!==a);for(s=g+2*R,k=f[g+c],B=[];k!==-1;)B[B.length]=new S(l[k].x,l[k].y,null),k=l[k].k;$(B)}}}});var Ql=O((eb,Jl)=>{var Vw=Yl();function Xw(t,e){var r=new Vw(t,e);r.compose();for(var n=r.getses(),i,a,o=t.length-1,s=e.length-1,c=n.length-1;c>=0;--c)n[c].t===r.SES_COMMON?(a?(a.chain={file1index:o,file2index:s,chain:null},a=a.chain):(i={file1index:o,file2index:s,chain:null},a=i),o--,s--):n[c].t===r.SES_DELETE?o--:n[c].t===r.SES_ADD&&s--;var f={file1index:-1,file2index:-1,chain:null};return a?(a.chain=f,i):f}function Kl(t,e){for(var r=[],n=t.length,i=e.length,a=Xw(t,e);a!==null;a=a.chain){var o=n-a.file1index-1,s=i-a.file2index-1;n=a.file1index,i=a.file2index,(o||s)&&r.push({file1:[n+1,o],file2:[i+1,s]})}return r.reverse(),r}function Yw(t,e,r){var n,i=Kl(e,t),a=Kl(e,r),o=[];function s(N,M){o.push([N.file1[0],M,N.file1[1],N.file2[0],N.file2[1]])}for(n=0;n<i.length;n++)s(i[n],0);for(n=0;n<a.length;n++)s(a[n],2);o.sort(function(N,M){return N[0]-M[0]});var c=[],f=0;function l(N){N>f&&(c.push([1,f,N-f]),f=N)}for(var u=0;u<o.length;u++){for(var d=u,h=o[u],p=h[0],w=p+h[2];u<o.length-1;){var y=o[u+1],b=y[0];if(b>w)break;w=Math.max(w,b+y[2]),u++}if(l(p),d==u)h[4]>0&&c.push([h[1],h[3],h[4]]);else{var E={0:[t.length,-1,e.length,-1],2:[r.length,-1,e.length,-1]};for(n=d;n<=u;n++){h=o[n];var S=h[1],A=E[S],m=h[0],$=m+h[2],g=h[3],x=g+h[4];A[0]=Math.min(g,A[0]),A[1]=Math.max(x,A[1]),A[2]=Math.min(m,A[2]),A[3]=Math.max($,A[3])}var _=E[0][0]+(p-E[0][2]),R=E[0][1]+(w-E[0][3]),k=E[2][0]+(p-E[2][2]),B=E[2][1]+(w-E[2][3]);c.push([-1,_,R-_,p,w-p,k,B-k])}f=w}return l(e.length),c}function Kw(t,e,r){var n=[],i=[t,e,r],a=Yw(t,e,r),o=[];function s(){o.length&&n.push({ok:o}),o=[]}function c(h){for(var p=0;p<h.length;p++)o.push(h[p])}function f(h){if(h[2]!=h[6])return!0;for(var p=h[1],w=h[5],y=0;y<h[2];y++)if(t[y+p]!=r[y+w])return!0;return!1}for(var l=0;l<a.length;l++){var u=a[l],d=u[0];d==-1?f(u)?(s(),n.push({conflict:{a:t.slice(u[1],u[1]+u[2]),aIndex:u[1],o:e.slice(u[3],u[3]+u[4]),oIndex:u[3],b:r.slice(u[5],u[5]+u[6]),bIndex:u[5]}})):c(i[0].slice(u[1],u[1]+u[2])):c(i[d].slice(u[1],u[1]+u[2]))}return s(),n}Jl.exports=Kw});var Rg={};cd(Rg,{blameFile:()=>td,checkoutBranch:()=>Vu,commitChanges:()=>qu,computeGitGutterChanges:()=>Zu,computeGitStatus:()=>eo,computeMyersDiffOps:()=>Me,computeShortCommitHash:()=>Sr,computeUnifiedHunkDiff:()=>ro,createGitState:()=>Ar,createIsoGitFsAdapter:()=>On,default:()=>Ag,discardChanges:()=>Wu,hydrateFromIsoGitRepo:()=>ed,initRepository:()=>Lu,isEffectiveStagedChange:()=>je,isIgnoredByRules:()=>to,isIgnoredScmPath:()=>V,isUnbornGitHead:()=>Rn,isoGit:()=>rd,mergeBranch:()=>Ju,normalizeScmRelPath:()=>X,parseGitignoreRules:()=>Qa,readVfsTree:()=>ce,resetToRef:()=>Xu,resolveCommitRef:()=>$n,saveBranchTip:()=>rt,showCommit:()=>Qu,stageAll:()=>zu,stageFile:()=>Gu,stashApply:()=>Ku,stashPush:()=>Yu,syncGitHead:()=>lt,syncToIsoGitRepo:()=>Nt,unstageAll:()=>Hu,unstageFile:()=>An});var ju=At(Mn());var bu=At(Mc(),1),_u=At(Hc(),1),vu=At(Wc(),1),xu=At(Vc(),1),Sn=At(Dl(),1),dr=At(jl(),1),Eu=At(Vl(),1),Jw=At(Ql(),1),T=class t extends Error{constructor(e){super(e),this.caller=""}toJSON(){let e=this;return{code:e.code,data:e.data,caller:this.caller,message:this.message,stack:this.stack}}fromJSON(e){let r=new t(e.message),n=r;return n.code=e.code,n.data=e.data,r.caller=e.caller,r.stack=e.stack,r}get isIsomorphicGitError(){return!0}},pn=class t extends T{constructor(e){super(`Modifying the index is not possible because you have unmerged files: ${e.toString}. Fix them up in the work tree, and then use 'git add/rm as appropriate to mark resolution and make a commit.`),this.code=this.name=t.code,this.data={filepaths:e}}};pn.code="UnmergedPathsError";var I=class t extends T{constructor(e){super(`An internal error caused this command to fail.
21
21
 
22
22
  If you're using an application that depends on isomorphic-git, please report this error to that application's developers.
23
23
 
24
24
  If you're a developer and you believe this is a bug in isomorphic-git, please file an issue at https://github.com/isomorphic-git/isomorphic-git/issues with a minimal reproduction, version and environment details, and this error message: ${e}`),this.code=this.name=t.code,this.data={message:e}}};I.code="InternalError";var hr=class t extends T{constructor(e){super(`The filepath "${e}" contains unsafe character sequences`),this.code=this.name=t.code,this.data={filepath:e}}};hr.code="UnsafeFilepathError";var ct=class{constructor(e){this.buffer=e,this._start=0}eof(){return this._start>=this.buffer.length}tell(){return this._start}seek(e){this._start=e}slice(e){let r=this.buffer.slice(this._start,this._start+e);return this._start+=e,r}toString(e,r){let n=this.buffer.toString(e,this._start,this._start+r);return this._start+=r,n}write(e,r,n){let i=this.buffer.write(e,this._start,r,n);return this._start+=r,i}copy(e,r,n){let i=e.copy(this.buffer,this._start,r,n);return this._start+=i,i}readUInt8(){let e=this.buffer.readUInt8(this._start);return this._start+=1,e}writeUInt8(e){let r=this.buffer.writeUInt8(e,this._start);return this._start+=1,r}readUInt16BE(){let e=this.buffer.readUInt16BE(this._start);return this._start+=2,e}writeUInt16BE(e){let r=this.buffer.writeUInt16BE(e,this._start);return this._start+=2,r}readUInt32BE(){let e=this.buffer.readUInt32BE(this._start);return this._start+=4,e}writeUInt32BE(e){let r=this.buffer.writeUInt32BE(e,this._start);return this._start+=4,r}},tu=/[\ud800-￿]/;function eu(t,e,r){if(r<55296||r>57343)return!1;if(r<56320){let i=e+1<t.length?t.charCodeAt(e+1):0;return i<56320||i>57343}let n=e>0?t.charCodeAt(e-1):0;return n<55296||n>56319}function Ha(t,e){if(!tu.test(t)&&!tu.test(e))return-(t<e)||+(t>e);let r=Math.min(t.length,e.length);for(let n=0;n<r;n++){let i=t.charCodeAt(n),a=e.charCodeAt(n);if(i!==a){if(eu(t,n,i)&&(i=65533),eu(e,n,a)&&(a=65533),i===a)continue;return i>=55296&&a>=55296&&(i+=i>=57344?-2048:8192,a+=a>=57344?-2048:8192),i<a?-1:1}}return t.length<e.length?-1:t.length>e.length?1:0}function ku(t,e){return Ha(t.path,e.path)}function Su(t){let e=t>0?t>>12:0;e!==4&&e!==8&&e!==10&&e!==14&&(e=8);let r=t&511;return r&73?r=493:r=420,e!==8&&(r=0),(e<<12)+r}var kt=2**32;function ru(t,e,r,n){if(t!==void 0&&e!==void 0)return[t,e];r===void 0&&(r=n.valueOf());let i=Math.floor(r/1e3),a=Math.floor((r-i*1e3)*1e6);return[i,a]}function Ce(t){let[e,r]=ru(t.ctimeSeconds,t.ctimeNanoseconds,t.ctimeMs,t.ctime),[n,i]=ru(t.mtimeSeconds,t.mtimeNanoseconds,t.mtimeMs,t.mtime);return{ctimeSeconds:e%kt,ctimeNanoseconds:r%kt,mtimeSeconds:n%kt,mtimeNanoseconds:i%kt,dev:t.dev%kt,ino:t.ino%kt,mode:Su(t.mode%kt),uid:t.uid%kt,gid:t.gid%kt,size:t.size>-1?t.size%kt:0}}function Qw(){return new bu.default}function tm(t){let e="";for(let r of new Uint8Array(t))r<16&&(e+="0"),e+=r.toString(16);return e}var Ki=null;async function qt(t){return Ki===null&&(Ki=await rm()),Ki?Au(t):em(t)}function em(t){return Qw().update(t).digest("hex")}async function Au(t){let e=await crypto.subtle.digest("SHA-1",t);return tm(e)}async function rm(){try{return await Au(new Uint8Array([]))==="da39a3ee5e6b4b0d3255bfef95601890afd80709"}catch{}return!1}function nm(t){return{assumeValid:!!(t&32768),extended:!!(t&16384),stage:(t&12288)>>12,nameLength:t&4095,skipWorktree:!1,intentToAdd:!1}}var na=16384,ia=8192;function aa(t){return!!(t.flags.skipWorktree||t.flags.intentToAdd)}function im(t){let e=t.flags;return e.extended=aa(t),e.nameLength=Math.min(Buffer.from(t.path).length,4095),(e.assumeValid?32768:0)+(e.extended?16384:0)+((e.stage&3)<<12)+(e.nameLength&4095)}function am(t){return(t.flags.skipWorktree?na:0)+(t.flags.intentToAdd?ia:0)}var oa=class t{constructor(e,r){this._dirty=!1,this._unmergedPaths=r||new Set,this._entries=e||new Map}_addEntry(e){if(e.flags.stage===0)e.stages=[e],this._entries.set(e.path,e),this._unmergedPaths.delete(e.path);else{let r=this._entries.get(e.path);r||(this._entries.set(e.path,e),r=e),r.stages[e.flags.stage]=e,this._unmergedPaths.add(e.path)}}static async from(e){if(Buffer.isBuffer(e))return t.fromBuffer(e);if(e===null)return new t(null);throw new I("invalid type passed to GitIndex.from")}static async fromBuffer(e){if(e.length===0)throw new I("Index file is empty (.git/index)");let r=new t,n=new ct(e),i=n.toString("utf8",4);if(i!=="DIRC")throw new I(`Invalid dircache magic file number: ${i}`);let a=await qt(e.slice(0,-20)),o=e.slice(-20).toString("hex");if(o!==a)throw new I(`Invalid checksum in GitIndex buffer: expected ${o} but saw ${a}`);let s=n.readUInt32BE();if(s!==2&&s!==3)throw new I(`Unsupported dircache version: ${s}`);let c=n.readUInt32BE(),f=0;for(;!n.eof()&&f<c;){let l={};l.ctimeSeconds=n.readUInt32BE(),l.ctimeNanoseconds=n.readUInt32BE(),l.mtimeSeconds=n.readUInt32BE(),l.mtimeNanoseconds=n.readUInt32BE(),l.dev=n.readUInt32BE(),l.ino=n.readUInt32BE(),l.mode=n.readUInt32BE(),l.uid=n.readUInt32BE(),l.gid=n.readUInt32BE(),l.size=n.readUInt32BE(),l.oid=n.slice(20).toString("hex");let u=n.readUInt16BE();if(l.flags=nm(u),l.flags.extended){let p=n.readUInt16BE();if(p&~(na|ia))throw new I(`Unknown index entry format: 0x${p.toString(16)}`);l.flags.skipWorktree=!!(p&na),l.flags.intentToAdd=!!(p&ia)}let d=e.indexOf(0,n.tell()+1)-n.tell();if(d<1)throw new I(`Got a path length of: ${d}`);if(l.path=n.toString("utf8",d),l.path.includes("..\\")||l.path.includes("../"))throw new hr(l.path);let h=8-(n.tell()-12)%8;for(h===0&&(h=8);h--;){let p=n.readUInt8();if(p!==0)throw new I(`Expected 1-8 null characters but got '${p}' after ${l.path}`);if(n.eof())throw new I("Unexpected end of file")}l.stages=[],r._addEntry(l),f++}return r}get unmergedPaths(){return[...this._unmergedPaths]}get entries(){return[...this._entries.values()].sort(ku)}get entriesMap(){return this._entries}get entriesFlat(){return[...this.entries].flatMap(e=>e.stages.length>1?e.stages.filter(r=>r):e)}*[Symbol.iterator](){for(let e of this.entries)yield e}insert({filepath:e,stats:r,oid:n,stage:i=0}){r||(r={ctimeSeconds:0,ctimeNanoseconds:0,mtimeSeconds:0,mtimeNanoseconds:0,dev:0,ino:0,mode:0,uid:0,gid:0,size:0}),r=Ce(r);let a=Buffer.from(e),o=i===0?this._entries.get(e):void 0,s={ctimeSeconds:r.ctimeSeconds,ctimeNanoseconds:r.ctimeNanoseconds,mtimeSeconds:r.mtimeSeconds,mtimeNanoseconds:r.mtimeNanoseconds,dev:r.dev,ino:r.ino,mode:r.mode||33188,uid:r.uid,gid:r.gid,size:r.size,path:e,oid:n,flags:{assumeValid:!1,extended:!1,stage:i,nameLength:a.length<4095?a.length:4095,skipWorktree:!!o?.flags.skipWorktree,intentToAdd:!1},stages:[]};this._addEntry(s),this._dirty=!0}delete({filepath:e}){if(this._entries.has(e))this._entries.delete(e);else for(let r of this._entries.keys())r.startsWith(e+"/")&&this._entries.delete(r);this._unmergedPaths.has(e)&&this._unmergedPaths.delete(e),this._dirty=!0}clear(){this._entries.clear(),this._dirty=!0}has({filepath:e}){return this._entries.has(e)}render(){return this.entries.map(e=>`${e.mode.toString(8)} ${e.oid} ${e.path}`).join(`
25
- `)}static async _entryToBuffer(e){let r=Buffer.from(e.path),n=aa(e),i=Math.ceil((62+(n?2:0)+r.length+1)/8)*8,a=Buffer.alloc(i),o=new ct(a),s=Ce(e);return o.writeUInt32BE(s.ctimeSeconds),o.writeUInt32BE(s.ctimeNanoseconds),o.writeUInt32BE(s.mtimeSeconds),o.writeUInt32BE(s.mtimeNanoseconds),o.writeUInt32BE(s.dev),o.writeUInt32BE(s.ino),o.writeUInt32BE(s.mode),o.writeUInt32BE(s.uid),o.writeUInt32BE(s.gid),o.writeUInt32BE(s.size),o.write(e.oid,20,"hex"),o.writeUInt16BE(im(e)),n&&o.writeUInt16BE(am(e)),o.write(e.path,r.length,"utf8"),a}async toObject(){let e=Buffer.alloc(12),r=new ct(e);r.write("DIRC",4,"utf8"),r.writeUInt32BE(this.entriesFlat.some(aa)?3:2),r.writeUInt32BE(this.entriesFlat.length);let n=[];for(let s of this.entries)if(n.push(t._entryToBuffer(s)),s.stages.length>1)for(let c of s.stages)c&&c!==s&&n.push(t._entryToBuffer(c));n=await Promise.all(n);let i=Buffer.concat(n),a=Buffer.concat([e,i]),o=await qt(a);return Buffer.concat([a,Buffer.from(o,"hex")])}};function om(t,e,r=!0,n=!0){let i=Ce(t),a=Ce(e);return r&&i.mode!==a.mode||i.mtimeSeconds!==a.mtimeSeconds||i.mtimeNanoseconds!==a.mtimeNanoseconds||i.ctimeSeconds!==a.ctimeSeconds||i.ctimeNanoseconds!==a.ctimeNanoseconds||i.uid!==a.uid||i.gid!==a.gid||n&&i.ino!==a.ino||i.size!==a.size}var Ji;function sm(){return Ji===void 0&&(Ji=new _u.default({maxPending:1/0})),Ji}function st(t,e){return sm().acquire(t,e)}var Qi=Symbol("IndexCache");function cm(){return{map:new Map,stats:new Map}}async function fm(t,e,r){let[n,i]=await Promise.all([t.lstat(e),t.read(e)]),a=await oa.from(i);r.map.set(e,a),r.stats.set(e,n)}async function lm(t,e,r){let n=r.stats.get(e);if(n===void 0)return!0;if(n===null)return!1;let i=await t.lstat(e);if(i===null)return!1;if(om(n,i))return!0;let a=Ce(n),o=Ce(i);return a.mtimeNanoseconds!==o.mtimeNanoseconds||a.ctimeNanoseconds!==o.ctimeNanoseconds}var wn=class{static async acquire({fs:e,gitdir:r,cache:n,allowUnmerged:i=!0},a){n[Qi]||(n[Qi]=cm());let o=`${r}/index`,s,c=[];return await st(o,async()=>{let f=n[Qi];await lm(e,o,f)&&await fm(e,o,f);let l=f.map.get(o);if(c=l.unmergedPaths,c.length&&!i)throw new pn(c);try{s=await a(l)}catch(u){throw f.map.delete(o),f.stats.delete(o),u}if(l._dirty){let u=await l.toObject();await e.write(o,u),f.stats.set(o,await e.lstat(o)),l._dirty=!1}}),s}};function sa(t){let e=Math.max(t.lastIndexOf("/"),t.lastIndexOf("\\"));return e>-1&&(t=t.slice(e+1)),t}function Fe(t){let e=Math.max(t.lastIndexOf("/"),t.lastIndexOf("\\"));return e===-1?".":e===0?"/":t.slice(0,e)}function um(t){let e=new Map,r=function(i){if(!e.has(i)){let a={type:"tree",fullpath:i,basename:sa(i),metadata:{},children:[]};e.set(i,a),a.parent=r(Fe(i)),a.parent&&a.parent!==a&&a.parent.children.push(a)}return e.get(i)},n=function(i,a){if(!e.has(i)){let o={type:"blob",fullpath:i,basename:sa(i),metadata:a,parent:r(Fe(i)),children:[]};o.parent&&o.parent.children.push(o),e.set(i,o)}return e.get(i)};r(".");for(let i of t)n(i.path,i);return e}var $u=Symbol("GitWalkSymbol");var Z=class t extends T{constructor(e){super(`Could not find ${e}.`),this.code=this.name=t.code,this.data={what:e}}};Z.code="NotFoundError";var Wt=class t extends T{constructor(e,r,n,i){super(`Object ${e} ${i?`at ${i}`:""}was anticipated to be a ${n} but it is a ${r}.`),this.code=this.name=t.code,this.data={oid:e,actual:r,expected:n,filepath:i}}};Wt.code="ObjectTypeError";var pr=class t extends T{constructor(e){super(`Expected a 40-char hex object id but saw "${e}".`),this.code=this.name=t.code,this.data={value:e}}};pr.code="InvalidOidError";var wr=class t extends T{constructor(e,r){super(`"${e}" would be an invalid git reference. (Hint: a valid alternative would be "${r}".)`),this.code=this.name=t.code,this.data={ref:e,suggestion:r}}};wr.code="InvalidRefNameError";var mn=class t extends T{constructor(e){super(`Could not find a fetch refspec for remote "${e}". Make sure the config file has an entry like the following:
25
+ `)}static async _entryToBuffer(e){let r=Buffer.from(e.path),n=aa(e),i=Math.ceil((62+(n?2:0)+r.length+1)/8)*8,a=Buffer.alloc(i),o=new ct(a),s=Ce(e);return o.writeUInt32BE(s.ctimeSeconds),o.writeUInt32BE(s.ctimeNanoseconds),o.writeUInt32BE(s.mtimeSeconds),o.writeUInt32BE(s.mtimeNanoseconds),o.writeUInt32BE(s.dev),o.writeUInt32BE(s.ino),o.writeUInt32BE(s.mode),o.writeUInt32BE(s.uid),o.writeUInt32BE(s.gid),o.writeUInt32BE(s.size),o.write(e.oid,20,"hex"),o.writeUInt16BE(im(e)),n&&o.writeUInt16BE(am(e)),o.write(e.path,r.length,"utf8"),a}async toObject(){let e=Buffer.alloc(12),r=new ct(e);r.write("DIRC",4,"utf8"),r.writeUInt32BE(this.entriesFlat.some(aa)?3:2),r.writeUInt32BE(this.entriesFlat.length);let n=[];for(let s of this.entries)if(n.push(t._entryToBuffer(s)),s.stages.length>1)for(let c of s.stages)c&&c!==s&&n.push(t._entryToBuffer(c));n=await Promise.all(n);let i=Buffer.concat(n),a=Buffer.concat([e,i]),o=await qt(a);return Buffer.concat([a,Buffer.from(o,"hex")])}};function om(t,e,r=!0,n=!0){let i=Ce(t),a=Ce(e);return r&&i.mode!==a.mode||i.mtimeSeconds!==a.mtimeSeconds||i.mtimeNanoseconds!==a.mtimeNanoseconds||i.ctimeSeconds!==a.ctimeSeconds||i.ctimeNanoseconds!==a.ctimeNanoseconds||i.uid!==a.uid||i.gid!==a.gid||n&&i.ino!==a.ino||i.size!==a.size}var Ji;function sm(){return Ji===void 0&&(Ji=new _u.default({maxPending:1/0})),Ji}function st(t,e){return sm().acquire(t,e)}var Qi=Symbol("IndexCache");function cm(){return{map:new Map,stats:new Map}}async function fm(t,e,r){let[n,i]=await Promise.all([t.lstat(e),t.read(e)]),a=await oa.from(i);r.map.set(e,a),r.stats.set(e,n)}async function lm(t,e,r){let n=r.stats.get(e);if(n===void 0)return!0;if(n===null)return!1;let i=await t.lstat(e);if(i===null)return!1;if(om(n,i))return!0;let a=Ce(n),o=Ce(i);return a.mtimeNanoseconds!==o.mtimeNanoseconds||a.ctimeNanoseconds!==o.ctimeNanoseconds}var wn=class{static async acquire({fs:e,gitdir:r,cache:n,allowUnmerged:i=!0},a){n[Qi]||(n[Qi]=cm());let o=`${r}/index`,s,c=[];return await st(o,async()=>{let f=n[Qi];await lm(e,o,f)&&await fm(e,o,f);let l=f.map.get(o);if(c=l.unmergedPaths,c.length&&!i)throw new pn(c);try{s=await a(l)}catch(u){throw f.map.delete(o),f.stats.delete(o),u}if(l._dirty){let u=await l.toObject();await e.write(o,u),f.stats.set(o,await e.lstat(o)),l._dirty=!1}}),s}};function sa(t){let e=Math.max(t.lastIndexOf("/"),t.lastIndexOf("\\"));return e>-1&&(t=t.slice(e+1)),t}function Fe(t){let e=Math.max(t.lastIndexOf("/"),t.lastIndexOf("\\"));return e===-1?".":e===0?"/":t.slice(0,e)}function um(t){let e=new Map,r=function(i){if(!e.has(i)){let a={type:"tree",fullpath:i,basename:sa(i),metadata:{},children:[]};e.set(i,a),a.parent=r(Fe(i)),a.parent&&a.parent!==a&&a.parent.children.push(a)}return e.get(i)},n=function(i,a){if(!e.has(i)){let o={type:"blob",fullpath:i,basename:sa(i),metadata:a,parent:r(Fe(i)),children:[]};o.parent&&o.parent.children.push(o),e.set(i,o)}return e.get(i)};r(".");for(let i of t)n(i.path,i);return e}var Ru=Symbol("GitWalkSymbol");var Z=class t extends T{constructor(e){super(`Could not find ${e}.`),this.code=this.name=t.code,this.data={what:e}}};Z.code="NotFoundError";var Wt=class t extends T{constructor(e,r,n,i){super(`Object ${e} ${i?`at ${i}`:""}was anticipated to be a ${n} but it is a ${r}.`),this.code=this.name=t.code,this.data={oid:e,actual:r,expected:n,filepath:i}}};Wt.code="ObjectTypeError";var pr=class t extends T{constructor(e){super(`Expected a 40-char hex object id but saw "${e}".`),this.code=this.name=t.code,this.data={value:e}}};pr.code="InvalidOidError";var wr=class t extends T{constructor(e,r){super(`"${e}" would be an invalid git reference. (Hint: a valid alternative would be "${r}".)`),this.code=this.name=t.code,this.data={ref:e,suggestion:r}}};wr.code="InvalidRefNameError";var mn=class t extends T{constructor(e){super(`Could not find a fetch refspec for remote "${e}". Make sure the config file has an entry like the following:
26
26
  [remote "${e}"]
27
27
  fetch = +refs/heads/*:refs/remotes/origin/*
28
28
  `),this.code=this.name=t.code,this.data={remote:e}}};mn.code="NoRefspecError";var gn=class t{constructor(e){if(this.refs=new Map,this.parsedConfig=[],e){let r=null;this.parsedConfig=e.trim().split(`
@@ -30,13 +30,13 @@ If you're a developer and you believe this is a bug in isomorphic-git, please fi
30
30
  `)+`
31
31
  `}},yn=class t{constructor({remotePath:e,localPath:r,force:n,matchPrefix:i}){Object.assign(this,{remotePath:e,localPath:r,force:n,matchPrefix:i})}static from(e){let[r,n,i,a,o]=e.match(/^(\+?)(.*?)(\*?):(.*?)(\*?)$/).slice(1),s=r==="+",c=i==="*";if(c!==(o==="*"))throw new I("Invalid refspec");return new t({remotePath:n,localPath:a,force:s,matchPrefix:c})}translate(e){if(this.matchPrefix){if(e.startsWith(this.remotePath))return this.localPath+e.replace(this.remotePath,"")}else if(e===this.remotePath)return this.localPath;return null}reverseTranslate(e){if(this.matchPrefix){if(e.startsWith(this.localPath))return this.remotePath+e.replace(this.localPath,"")}else if(e===this.localPath)return this.remotePath;return null}},ca=class t{constructor(e=[]){this.rules=e}static from(e){let r=[];for(let n of e)r.push(yn.from(n));return new t(r)}add(e){let r=yn.from(e);this.rules.push(r)}translate(e){let r=[];for(let n of this.rules)for(let i of e){let a=n.translate(i);a&&r.push([i,a])}return r}translateOne(e){let r=null;for(let n of this.rules){let i=n.translate(e);i&&(r=i)}return r}localNamespaces(){return this.rules.filter(e=>e.matchPrefix).map(e=>e.localPath.replace(/\/$/,""))}};function dm(t,e){let r=t.replace(/\^\{\}$/,""),n=e.replace(/\^\{\}$/,""),i=-(r<n)||+(r>n);return i===0?t.endsWith("^{}")?1:-1:i}var hm=/(^|[/.])([/.]|$)|^@$|@{|[\x00-\x20\x7f~^:?*[\\]|\.lock(\/|$)/;function pm(t,e){if(typeof t!="string")throw new TypeError("Reference name must be a string");return!hm.test(t)&&(!!e||t.includes("/"))}function wm(t,e){let r="",n=0,i=-1,a=0,o="\0";for(let s=0;s<=t.length;++s){if(s<t.length)o=t[s];else{if(o==="/")break;o="/"}if(o==="/"){if(!(i===s-1||a===1))if(a===2){if(r.length<2||n!==2||r.at(-1)!=="."||r.at(-2)!=="."){if(r.length>2){let c=r.lastIndexOf("/");c===-1?(r="",n=0):(r=r.slice(0,c),n=r.length-1-r.lastIndexOf("/")),i=s,a=0;continue}else if(r.length!==0){r="",n=0,i=s,a=0;continue}}e&&(r+=r.length>0?"/..":"..",n=2)}else r.length>0?r+="/"+t.slice(i+1,s):r=t.slice(i+1,s),n=s-i-1;i=s,a=0}else o==="."&&a!==-1?++a:a=-1}return r}function mm(t){return t.length>=2&&/^[a-zA-Z]:/.test(t)?t.slice(0,2):null}function gm(t){if(!t.length)return".";t=t.replace(/\\/g,"/");let e=mm(t),r=t[0]==="/"||e!==null&&t[2]==="/",n=t.at(-1)==="/",i=e?t.slice(2):t,a=wm(i,!r);if(!a.length){let o=e?r?e+"/":e:r?"/":".";return n&&!r?o+"/":o}return n&&(a+="/"),e?r?`${e}/${a}`:`${e}${a}`:r?`/${a}`:a}function D(...t){if(t.length===0)return".";let e;for(let r=0;r<t.length;++r){let n=t[r].replace(/\\/g,"/");n.length!==0&&(/^[a-zA-Z]:\//.test(n)||e===void 0?e=n:e+="/"+n)}return e===void 0?".":gm(e)}var ym=t=>{if(typeof t=="number")return t;t=t.toLowerCase();let e=parseInt(t);return t.endsWith("k")&&(e*=1024),t.endsWith("m")&&(e*=1024*1024),t.endsWith("g")&&(e*=1024*1024*1024),e},fr=t=>{if(typeof t=="boolean")return t;if(t=t.trim().toLowerCase(),t==="true"||t==="yes"||t==="on")return!0;if(t==="false"||t==="no"||t==="off")return!1;throw Error(`Expected 'true', 'false', 'yes', 'no', 'on', or 'off', but got ${t}`)},nu={core:{filemode:fr,bare:fr,logallrefupdates:fr,symlinks:fr,ignorecase:fr,bigFileThreshold:ym}},bm=/^\[([A-Za-z0-9-.]+)(?:[ \t]+"((?:[^"\\]|\\.)*)")?\][ \t]*(?:[#;].*)?$/,_m=/^[A-Za-z0-9-.]+$/,vm=/^([A-Za-z][A-Za-z0-9-]*)(?:\s*=\s*(.*))?$/,xm=/^[A-Za-z][A-Za-z0-9-]*$/,Em=t=>{let e=bm.exec(t);if(e!=null){let[r,n]=e.slice(1);return[r,n&&n.replace(/\\(.)/g,"$1")]}return null},km=t=>{let e=vm.exec(t);if(e!=null){let[r,n="true"]=e.slice(1);return[r,Sm(n)]}return null},iu=new Map([["t"," "],["b","\b"],["n",`
32
32
  `],["\\","\\"],['"','"']]),Sm=t=>{let e="",r="",n=!1;for(let i=0;i<t.length;i++){let a=t[i];if(!n&&/[ \t\r\v\f]/.test(a)){e!==""&&(r+=a);continue}if(!n&&(a==="#"||a===";"))break;e+=r,r="",a==="\\"&&iu.has(t[i+1])?e+=iu.get(t[++i]):a==='"'?n=!n:e+=a}return e},Am=t=>{if(typeof t!="string")return t;let e=t.startsWith(" ")||t.endsWith(" ")||/[#;]/.test(t)?'"':"",r=t.replace(/[\\"\n\t]/g,n=>n===`
33
- `?"\\n":n===" "?"\\t":`\\${n}`);return`${e}${r}${e}`},au=t=>t!=null?t.toLowerCase():null,fa=(t,e,r)=>[au(t),e,au(r)].filter(n=>n!=null).join("."),ou=t=>{let e=t.split("."),r=e.shift(),n=e.pop(),i=e.length?e.join("."):void 0;return{section:r,subsection:i,name:n,path:fa(r,i,n),sectionPath:fa(r,i,null),isSection:!!r}},$m=(t,e)=>t.reduce((r,n,i)=>e(n)?i:r,-1),la=class t{constructor(e){let r=null,n=null;this.parsedConfig=e?e.split(`
34
- `).map(i=>{let a=null,o=null,s=i.trim(),c=Em(s),f=c!=null;if(f)[r,n]=c;else{let u=km(s);u!=null&&([a,o]=u)}let l=fa(r,n,a);return{line:i,isSection:f,section:r,subsection:n,name:a,value:o,path:l}}):[]}static from(e){return new t(e)}async get(e,r=!1){let n=ou(e).path,i=this.parsedConfig.filter(a=>a.path===n).map(({section:a,name:o,value:s})=>{let c=nu[a]&&nu[a][o];return c?c(s):s});return r?i:i.pop()}async getall(e){return this.get(e,!0)}async getSubsections(e){return this.parsedConfig.filter(r=>r.isSection&&r.section===e).map(r=>r.subsection)}async deleteSection(e,r){this.parsedConfig=this.parsedConfig.filter(n=>!(n.section===e&&n.subsection===r))}async append(e,r){return this.set(e,r,!0)}async set(e,r,n=!1){let{section:i,subsection:a,name:o,path:s,sectionPath:c,isSection:f}=ou(e),l=$m(this.parsedConfig,u=>u.path===s);if(r==null)l!==-1&&this.parsedConfig.splice(l,1);else if(l!==-1){let u=this.parsedConfig[l],d=Object.assign({},u,{name:o,value:r,modified:!0});n?this.parsedConfig.splice(l+1,0,d):this.parsedConfig[l]=d}else{let u=this.parsedConfig.findIndex(h=>h.path===c),d={section:i,subsection:a,name:o,value:r,modified:!0,path:s};if(_m.test(i)&&xm.test(o))if(u>=0)this.parsedConfig.splice(u+1,0,d);else{let h={isSection:f,section:i,subsection:a,modified:!0,path:c};this.parsedConfig.push(h,d)}}}toString(){return this.parsedConfig.map(({line:e,section:r,subsection:n,name:i,value:a,modified:o=!1})=>o?i!=null&&a!=null?` ${i} = ${Am(a)}`:n!=null?`[${r} "${n}"]`:`[${r}]`:e).join(`
33
+ `?"\\n":n===" "?"\\t":`\\${n}`);return`${e}${r}${e}`},au=t=>t!=null?t.toLowerCase():null,fa=(t,e,r)=>[au(t),e,au(r)].filter(n=>n!=null).join("."),ou=t=>{let e=t.split("."),r=e.shift(),n=e.pop(),i=e.length?e.join("."):void 0;return{section:r,subsection:i,name:n,path:fa(r,i,n),sectionPath:fa(r,i,null),isSection:!!r}},Rm=(t,e)=>t.reduce((r,n,i)=>e(n)?i:r,-1),la=class t{constructor(e){let r=null,n=null;this.parsedConfig=e?e.split(`
34
+ `).map(i=>{let a=null,o=null,s=i.trim(),c=Em(s),f=c!=null;if(f)[r,n]=c;else{let u=km(s);u!=null&&([a,o]=u)}let l=fa(r,n,a);return{line:i,isSection:f,section:r,subsection:n,name:a,value:o,path:l}}):[]}static from(e){return new t(e)}async get(e,r=!1){let n=ou(e).path,i=this.parsedConfig.filter(a=>a.path===n).map(({section:a,name:o,value:s})=>{let c=nu[a]&&nu[a][o];return c?c(s):s});return r?i:i.pop()}async getall(e){return this.get(e,!0)}async getSubsections(e){return this.parsedConfig.filter(r=>r.isSection&&r.section===e).map(r=>r.subsection)}async deleteSection(e,r){this.parsedConfig=this.parsedConfig.filter(n=>!(n.section===e&&n.subsection===r))}async append(e,r){return this.set(e,r,!0)}async set(e,r,n=!1){let{section:i,subsection:a,name:o,path:s,sectionPath:c,isSection:f}=ou(e),l=Rm(this.parsedConfig,u=>u.path===s);if(r==null)l!==-1&&this.parsedConfig.splice(l,1);else if(l!==-1){let u=this.parsedConfig[l],d=Object.assign({},u,{name:o,value:r,modified:!0});n?this.parsedConfig.splice(l+1,0,d):this.parsedConfig[l]=d}else{let u=this.parsedConfig.findIndex(h=>h.path===c),d={section:i,subsection:a,name:o,value:r,modified:!0,path:s};if(_m.test(i)&&xm.test(o))if(u>=0)this.parsedConfig.splice(u+1,0,d);else{let h={isSection:f,section:i,subsection:a,modified:!0,path:c};this.parsedConfig.push(h,d)}}}toString(){return this.parsedConfig.map(({line:e,section:r,subsection:n,name:i,value:a,modified:o=!1})=>o?i!=null&&a!=null?` ${i} = ${Am(a)}`:n!=null?`[${r} "${n}"]`:`[${r}]`:e).join(`
35
35
  `)}},mr=class{static async get({fs:e,gitdir:r}){let n=await e.read(`${r}/config`,{encoding:"utf8"});return la.from(n)}static async save({fs:e,gitdir:r,config:n}){await e.write(`${r}/config`,n.toString(),{encoding:"utf8"})}},lr=t=>[`${t}`,`refs/${t}`,`refs/tags/${t}`,`refs/heads/${t}`,`refs/remotes/${t}`,`refs/remotes/${t}/HEAD`],ua=["config","description","index","shallow","commondir"];function se(t){if(ua.includes(t))throw new wr(t,`refs/heads/${t}`);if(!pm(t,!0))throw new wr(t,vu.default.clean(t))}var ft=class t{static async updateRemoteRefs({fs:e,gitdir:r,remote:n,refs:i,symrefs:a,tags:o,refspecs:s=void 0,prune:c=!1,pruneTags:f=!1}){for(let b of i.values())if(!b.match(/[0-9a-f]{40}/))throw new pr(b);let l=await mr.get({fs:e,gitdir:r});if(!s){if(s=await l.getall(`remote.${n}.fetch`),s.length===0)throw new mn(n);s.unshift(`+HEAD:refs/remotes/${n}/HEAD`)}let u=ca.from(s),d=new Map,h=u.translate([...i.keys()]),p=[];for(let[b,E]of u.translate([...a.keys()])){let S=u.translateOne(a.get(b));S&&(se(S),p.push([E,`ref: ${S}`]))}let w=o?[...i.keys()].filter(b=>b.startsWith("refs/tags")&&!b.endsWith("^{}")):[];for(let[,b]of h)se(b);for(let[b]of p)se(b);if(w.forEach(se),f){let b=await t.listRefs({fs:e,gitdir:r,filepath:"refs/tags"});await t.deleteRefs({fs:e,gitdir:r,refs:b.map(E=>`refs/tags/${E}`)})}for(let b of w)if(!await t.exists({fs:e,gitdir:r,ref:b})){let E=i.get(b);d.set(b,E)}for(let[b,E]of h){let S=i.get(b);d.set(E,S)}for(let[b,E]of p)d.set(b,E);let y=[];if(c){for(let b of u.localNamespaces()){let E=(await t.listRefs({fs:e,gitdir:r,filepath:b})).map(S=>`${b}/${S}`);for(let S of E)d.has(S)||y.push(S)}y.length>0&&await t.deleteRefs({fs:e,gitdir:r,refs:y})}for(let[b,E]of d)await st(b,async()=>e.write(D(r,b),`${E.trim()}
36
36
  `,"utf8"));return{pruned:y}}static async writeRef({fs:e,gitdir:r,ref:n,value:i}){if(se(n),!i.match(/[0-9a-f]{40}/))throw new pr(i);await st(n,async()=>e.write(D(r,n),`${i.trim()}
37
37
  `,"utf8"))}static async writeSymbolicRef({fs:e,gitdir:r,ref:n,value:i}){se(n),await st(n,async()=>e.write(D(r,n),`ref: ${i.trim()}
38
- `,"utf8"))}static async deleteRef({fs:e,gitdir:r,ref:n}){return t.deleteRefs({fs:e,gitdir:r,refs:[n]})}static async deleteRefs({fs:e,gitdir:r,refs:n}){n.forEach(se),await Promise.all(n.map(s=>e.rm(D(r,s))));let i=await st("packed-refs",async()=>e.read(`${r}/packed-refs`,{encoding:"utf8"})),a=gn.from(i),o=a.refs.size;for(let s of n)a.refs.has(s)&&a.delete(s);a.refs.size<o&&(i=a.toString(),await st("packed-refs",async()=>e.write(`${r}/packed-refs`,i,{encoding:"utf8"})))}static async resolve({fs:e,gitdir:r,ref:n,depth:i=void 0,visited:a=new Set}){if(i!==void 0&&(i--,i===-1))return n;if(n.startsWith("ref: "))return n=n.slice(5),t.resolve({fs:e,gitdir:r,ref:n,depth:i,visited:a});if(n.length===40&&/[0-9a-f]{40}/.test(n))return n;let o=await t.packedRefs({fs:e,gitdir:r}),s=lr(n).filter(c=>!ua.includes(c));for(let c of s){let f=await st(c,async()=>await e.read(`${r}/${c}`,{encoding:"utf8"})||o.get(c));if(f){if(a.has(c))throw new I(`Circular reference detected while resolving ref "${c}"`);return a.add(c),t.resolve({fs:e,gitdir:r,ref:f.trim(),depth:i,visited:a})}}throw new Z(n)}static async isUnbornBranch({fs:e,gitdir:r,ref:n}){let i;try{i=await t.resolve({fs:e,gitdir:r,ref:"HEAD",depth:2})}catch(a){if(a instanceof Z)return!1;throw a}return i.startsWith("refs/heads/")?n==="HEAD"||lr(n).includes(i):!1}static async exists({fs:e,gitdir:r,ref:n}){try{return await t.expand({fs:e,gitdir:r,ref:n}),!0}catch(i){if(i instanceof Z)return!1;throw i}}static async expand({fs:e,gitdir:r,ref:n}){if(n.length===40&&/[0-9a-f]{40}/.test(n))return n;let i=await t.packedRefs({fs:e,gitdir:r}),a=lr(n).filter(o=>!ua.includes(o));for(let o of a)if(await st(o,async()=>e.exists(`${r}/${o}`))||i.has(o))return o;throw new Z(n)}static async expandAgainstMap({ref:e,map:r}){let n=lr(e);for(let i of n)if(await r.has(i))return i;throw new Z(e)}static resolveAgainstMap({ref:e,fullref:r=e,depth:n=void 0,map:i}){if(n!==void 0&&(n--,n===-1))return{fullref:r,oid:e};if(e.startsWith("ref: "))return e=e.slice(5),t.resolveAgainstMap({ref:e,fullref:r,depth:n,map:i});if(e.length===40&&/[0-9a-f]{40}/.test(e))return{fullref:r,oid:e};let a=lr(e);for(let o of a){let s=i.get(o);if(s)return t.resolveAgainstMap({ref:s.trim(),fullref:o,depth:n,map:i})}throw new Z(e)}static async packedRefs({fs:e,gitdir:r}){let n=await st("packed-refs",async()=>e.read(`${r}/packed-refs`,{encoding:"utf8"}));return gn.from(n).refs}static async listRefs({fs:e,gitdir:r,filepath:n}){let i=await t.packedRefs({fs:e,gitdir:r}),a=null;try{a=await e.readdirDeep(`${r}/${n}`),a=a.map(o=>o.replace(`${r}/${n}/`,""))}catch{a=[]}for(let o of i.keys())o.startsWith(n)&&(o=o.replace(n+"/",""),a.includes(o)||a.push(o));return a.sort(dm),a}static async listBranches({fs:e,gitdir:r,remote:n}){return n?t.listRefs({fs:e,gitdir:r,filepath:`refs/remotes/${n}`}):t.listRefs({fs:e,gitdir:r,filepath:"refs/heads"})}static async listTags({fs:e,gitdir:r}){return(await t.listRefs({fs:e,gitdir:r,filepath:"refs/tags"})).filter(i=>!i.endsWith("^{}"))}};function Rm(t,e){return Ha(su(t),su(e))}function su(t){return t.mode==="040000"?t.path+"/":t.path}function Ru(t){switch(t){case"040000":return"tree";case"100644":return"blob";case"100755":return"blob";case"120000":return"blob";case"160000":return"commit"}throw new I(`Unexpected GitTree entry mode: ${t}`)}function Om(t){let e=[],r=0;for(;r<t.length;){let n=t.indexOf(32,r);if(n===-1)throw new I(`GitTree: Error parsing buffer at byte location ${r}: Could not find the next space character.`);let i=t.indexOf(0,r);if(i===-1)throw new I(`GitTree: Error parsing buffer at byte location ${r}: Could not find the next null character.`);let a=t.slice(r,n).toString("utf8");a==="40000"&&(a="040000");let o=Ru(a),s=t.slice(n+1,i).toString("utf8"),c=s.replace(/[\u200C-\u200F\u202A-\u202E\u206A-\u206F\uFEFF]/g,""),l=c.split(":")[0].toLowerCase().replace(/[. ]+$/,"");if(s.includes("\\")||s.includes("/")||c==="."||c===".."||l===".git"||/^\.?git~[1-9]$/.test(l))throw new hr(s);let u=t.slice(i+1,i+21).toString("hex");r=i+21,e.push({mode:a,path:s,oid:u,type:o})}return e}function Bm(t){if(typeof t=="number"&&(t=t.toString(8)),t.match(/^0?4.*/))return"040000";if(t.match(/^1006.*/))return"100644";if(t.match(/^1007.*/))return"100755";if(t.match(/^120.*/))return"120000";if(t.match(/^160.*/))return"160000";throw new I(`Could not understand file mode: ${t}`)}function Im(t){return!t.oid&&t.sha&&(t.oid=t.sha),t.mode=Bm(t.mode),t.type||(t.type=Ru(t.mode)),t}var Zt=class t{constructor(e){if(Buffer.isBuffer(e))this._entries=Om(e);else if(Array.isArray(e))this._entries=e.map(Im);else throw new I("invalid type passed to GitTree constructor");this._entries.sort(ku)}static from(e){return new t(e)}render(){return this._entries.map(e=>`${e.mode} ${e.type} ${e.oid} ${e.path}`).join(`
39
- `)}toObject(){let e=[...this._entries];return e.sort(Rm),Buffer.concat(e.map(r=>{let n=Buffer.from(r.mode.replace(/^0/,"")),i=Buffer.from(" "),a=Buffer.from(r.path,"utf8"),o=Buffer.from([0]),s=Buffer.from(r.oid,"hex");return Buffer.concat([n,i,a,o,s])}))}entries(){return this._entries}*[Symbol.iterator](){for(let e of this._entries)yield e}},Pe=class{static wrap({type:e,object:r}){let n=`${e} ${r.length}\0`,i=n.length,a=i+r.length,o=new Uint8Array(a);for(let s=0;s<i;s++)o[s]=n.charCodeAt(s);return o.set(r,i),o}static unwrap(e){let r=e.indexOf(32),n=e.indexOf(0),i=e.slice(0,r).toString("utf8"),a=e.slice(r+1,n).toString("utf8"),o=e.length-(n+1);if(parseInt(a)!==o)throw new I(`Length mismatch: expected ${a} bytes but got ${o} instead.`);return{type:i,object:Buffer.from(e.slice(n+1))}}};async function Tm({fs:t,gitdir:e,oid:r}){let n=`objects/${r.slice(0,2)}/${r.slice(2)}`,i=await t.read(`${e}/${n}`);return i?{object:i,format:"deflated",source:n}:null}function Ou(t,e){let r=new ct(t),n=cu(r);if(n!==e.byteLength)throw new I(`applyDelta expected source buffer to be ${n} bytes but the provided buffer was ${e.length} bytes`);let i=cu(r),a,o=lu(r,e);if(o.byteLength===i)a=o;else{let s=[o],c=o.byteLength;for(;!r.eof();){let f=lu(r,e);s.push(f),c+=f.byteLength}if(i!==c)throw new I(`applyDelta expected target buffer to be ${i} bytes but the resulting buffer was ${c} bytes`);a=Buffer.concat(s,i)}return a}function cu(t){let e=0,r=0,n=null;do n=t.readUInt8(),e|=(n&127)<<r,r+=7;while(n&128);return e}function fu(t,e,r){let n=0,i=0;for(;r--;)e&1&&(n|=t.readUInt8()<<i),e>>=1,i+=8;return n}function lu(t,e){let r=t.readUInt8(),n=128,i=15,a=112;if(r&n){let o=fu(t,r&i,4),s=fu(t,(r&a)>>4,3);return s===0&&(s=65536),e.slice(o,o+s)}else return t.slice(r)}function Cm(t){let e=[t];return{next(){return Promise.resolve({done:e.length===0,value:e.pop()})},return(){return e=[],{}},[Symbol.asyncIterator](){return this}}}function Fm(t){return t[Symbol.asyncIterator]?t[Symbol.asyncIterator]():t[Symbol.iterator]?t[Symbol.iterator]():t.next?t:Cm(t)}var da=class{constructor(e){if(typeof Buffer>"u")throw new Error("Missing Buffer dependency");this.stream=Fm(e),this.buffer=null,this.cursor=0,this.undoCursor=0,this.started=!1,this._ended=!1,this._discardedBytes=0}eof(){return this._ended&&this.cursor===this.buffer.length}tell(){return this._discardedBytes+this.cursor}async byte(){if(!this.eof()&&(this.started||await this._init(),!(this.cursor===this.buffer.length&&(await this._loadnext(),this._ended))))return this._moveCursor(1),this.buffer[this.undoCursor]}async chunk(){if(!this.eof()&&(this.started||await this._init(),!(this.cursor===this.buffer.length&&(await this._loadnext(),this._ended))))return this._moveCursor(this.buffer.length),this.buffer.slice(this.undoCursor,this.cursor)}async read(e){if(!this.eof())return this.started||await this._init(),this.cursor+e>this.buffer.length&&(this._trim(),await this._accumulate(e)),this._moveCursor(e),this.buffer.slice(this.undoCursor,this.cursor)}async skip(e){this.eof()||(this.started||await this._init(),this.cursor+e>this.buffer.length&&(this._trim(),await this._accumulate(e)),this._moveCursor(e))}async undo(){this.cursor=this.undoCursor}async _next(){this.started=!0;let{done:e,value:r}=await this.stream.next();return e&&(this._ended=!0,!r)?Buffer.alloc(0):(r&&(r=Buffer.from(r)),r)}_trim(){this.buffer=this.buffer.slice(this.undoCursor),this.cursor-=this.undoCursor,this._discardedBytes+=this.undoCursor,this.undoCursor=0}_moveCursor(e){this.undoCursor=this.cursor,this.cursor+=e,this.cursor>this.buffer.length&&(this.cursor=this.buffer.length)}async _accumulate(e){if(this._ended)return;let r=[this.buffer];for(;this.cursor+e>Pm(r);){let n=await this._next();if(this._ended)break;r.push(n)}this.buffer=Buffer.concat(r)}async _loadnext(){this._discardedBytes+=this.buffer.length,this.undoCursor=0,this.cursor=0,this.buffer=await this._next()}async _init(){this.buffer=await this._next()}};function Pm(t){return t.reduce((e,r)=>e+r.length,0)}async function Dm(t,e){let r=new da(t),n=await r.read(4);if(n=n.toString("utf8"),n!=="PACK")throw new I(`Invalid PACK header '${n}'`);let i=await r.read(4);if(i=i.readUInt32BE(0),i!==2)throw new I(`Invalid packfile version: ${i}`);let a=await r.read(4);if(a=a.readUInt32BE(0),!(a<1))for(;!r.eof()&&a--;){let o=r.tell(),{type:s,length:c,ofs:f,reference:l}=await Nm(r),u=new Sn.default.Inflate;for(;!u.result;){let d=await r.chunk();if(!d)break;if(u.push(d,!1),u.err)throw new I(`Pako error: ${u.msg}`);if(u.result){if(u.result.length!==c)throw new I("Inflated object size is different from that stated in packfile.");await r.undo(),await r.read(d.length-u.strm.avail_in);let h=r.tell();await e({data:u.result,type:s,num:a,offset:o,end:h,reference:l,ofs:f})}}}}async function Nm(t){let e=await t.byte(),r=e>>4&7,n=e&15;if(e&128){let o=4;do e=await t.byte(),n|=(e&127)<<o,o+=7;while(e&128)}let i,a;if(r===6){let o=0;i=0;let s=[];do e=await t.byte(),i|=(e&127)<<o,o+=7,s.push(e);while(e&128);a=Buffer.from(s)}return r===7&&(a=await t.read(20)),{type:r,length:n,ofs:i,reference:a}}var gr=class t extends T{constructor(e){super(`Invalid compressed buffer: ${e}`),this.code=this.name=t.code,this.data={message:e}}};gr.code="DecompressionError";async function Um(t){let e=new DecompressionStream("deflate"),r=new Blob([t]).stream().pipeThrough(e);try{return new Uint8Array(await new Response(r).arrayBuffer())}catch(n){throw n&&n.name==="TypeError"&&n.message===""?new gr("decompression failed"):n}}var ta=!1;async function Bu(t){ta===null&&(ta=jm());try{return ta?await Um(t):Sn.default.inflate(t)}catch(e){throw typeof e=="string"?new gr(e):e}}function jm(){try{if(new DecompressionStream("deflate"))return!0}catch{}return!1}function Iu(t){let e=[],r=0,n=0;do{r=t.readUInt8();let i=r&127;e.push(i),n=r&128}while(n);return e.reduce((i,a)=>i+1<<7|a,-1)}function Mm(t,e){let r=e,n=4,i=null;do i=t.readUInt8(),r|=(i&127)<<n,n+=7;while(i&128);return r}var Lm=32*1024*1024,ha=class{constructor(e){this.maxBytes=e,this.bytes=0,this.map=new Map}get(e){let r=this.map.get(e);return r!==void 0&&(this.map.delete(e),this.map.set(e,r)),r}set(e,r){let n=r.object.byteLength;if(!(n>this.maxBytes/4)){this.map.set(e,r),this.bytes+=n;for(let[i,a]of this.map){if(this.bytes<=this.maxBytes)break;this.map.delete(i),this.bytes-=a.object.byteLength}}}};function Gm({type:t,data:e,reference:r,offset:n},i,a){let o=Buffer.from(e.buffer,e.byteOffset,e.byteLength);if(t!=="ofs-delta"&&t!=="ref-delta")return{type:t,object:o};let s=t==="ofs-delta"?n-Iu(new ct(r)):a.get(r.toString("hex")),c=i.get(s);if(!c)return null;try{return{type:c.type,object:Buffer.from(Ou(o,c.object))}}catch(f){if(f instanceof I||f instanceof RangeError)return null;throw f}}var pa=class t{constructor(e){Object.assign(this,e),this.offsetCache={}}static async fromIdx({idx:e,getExternalRefDelta:r}){let n=new ct(e);if(n.slice(4).toString("hex")!=="ff744f63")return;let a=n.readUInt32BE();if(a!==2)throw new I(`Unable to read version ${a} packfile IDX. (Only version 2 supported)`);if(e.byteLength>2048*1024*1024)throw new I("To keep implementation simple, I haven't implemented the layer 5 feature needed to support packfiles > 2GB in size.");n.seek(n.tell()+1020);let o=n.readUInt32BE(),s=[];for(let l=0;l<o;l++){let u=n.slice(20).toString("hex");s[l]=u}n.seek(n.tell()+4*o);let c=new Map;for(let l=0;l<o;l++)c.set(s[l],n.readUInt32BE());let f=n.slice(20).toString("hex");return new t({hashes:s,crcs:{},offsets:c,packfileSha:f,getExternalRefDelta:r})}static async fromPack({pack:e,getExternalRefDelta:r,onProgress:n}){let i={1:"commit",2:"tree",3:"blob",4:"tag",6:"ofs-delta",7:"ref-delta"},a={},o=e.slice(-20).toString("hex"),s=[],c={},f=new Map,l=null,u=null,d=new ha(Lm),h=new Map;await Dm([e],async({data:E,type:S,reference:A,offset:m,num:$})=>{l===null&&(l=$);let g=Math.floor((l-$)*100/l);g!==u&&n&&await n({phase:"Receiving objects",loaded:l-$,total:l}),u=g,S=i[S],["commit","tree","blob","tag"].includes(S)?a[m]={type:S,offset:m}:S==="ofs-delta"?a[m]={type:S,offset:m}:S==="ref-delta"&&(a[m]={type:S,offset:m});let x=a[m];if(!x)return;let _=Gm({type:S,data:E,reference:A,offset:m},d,h);_&&(x.oid=await qt(Pe.wrap(_)),h.set(x.oid,m),d.set(m,_))});let p=Object.keys(a).map(Number);for(let[E,S]of p.entries()){let A=E+1===p.length?e.byteLength-20:p[E+1],m=a[S],$=xu.default.buf(e.slice(S,A))>>>0;m.end=A,m.crc=$}let w=new t({pack:Promise.resolve(e),packfileSha:o,crcs:c,hashes:s,offsets:f,getExternalRefDelta:r});u=null;let y=0,b=[0,0,0,0,0,0,0,0,0,0,0,0];for(let E in a){E=Number(E);let S=Math.floor(y*100/l);S!==u&&n&&await n({phase:"Resolving deltas",loaded:y,total:l}),y++,u=S;let A=a[E];if(!A.oid)try{w.readDepth=0,w.externalReadDepth=0;let{type:m,object:$}=await w.readSlice({start:E});b[w.readDepth]+=1,A.oid=await qt(Pe.wrap({type:m,object:$}))}catch{continue}s.push(A.oid),f.set(A.oid,E),c[A.oid]=A.crc}return s.sort(),w}async toBuffer(){let e=[],r=(f,l)=>{e.push(Buffer.from(f,l))};r("ff744f63","hex"),r("00000002","hex");let n=new ct(Buffer.alloc(256*4));for(let f=0;f<256;f++){let l=0;for(let u of this.hashes)parseInt(u.slice(0,2),16)<=f&&l++;n.writeUInt32BE(l)}e.push(n.buffer);for(let f of this.hashes)r(f,"hex");let i=new ct(Buffer.alloc(this.hashes.length*4));for(let f of this.hashes)i.writeUInt32BE(this.crcs[f]);e.push(i.buffer);let a=new ct(Buffer.alloc(this.hashes.length*4));for(let f of this.hashes)a.writeUInt32BE(this.offsets.get(f));e.push(a.buffer),r(this.packfileSha,"hex");let o=Buffer.concat(e),s=await qt(o),c=Buffer.alloc(20);return c.write(s,"hex"),Buffer.concat([o,c])}async load({pack:e}){this.pack=e}async unload(){this.pack=null}async read({oid:e}){if(!this.offsets.get(e)){if(this.getExternalRefDelta)return this.externalReadDepth++,this.getExternalRefDelta(e);throw new I(`Could not read object ${e} from packfile`)}let r=this.offsets.get(e);return this.readSlice({start:r})}async readSlice({start:e}){if(this.offsetCache[e])return Object.assign({},this.offsetCache[e]);this.readDepth++;let r={16:"commit",32:"tree",48:"blob",64:"tag",96:"ofs_delta",112:"ref_delta"},n=await this.pack;if(!n)throw new I("Could not read packfile data. The packfile may be missing, corrupted, or too large to read into memory.");let i=n.slice(e),a=new ct(i),o=a.readUInt8(),s=o&112,c=r[s];if(c===void 0)throw new I("Unrecognized type: 0b"+s.toString(2));let f=o&15,l=f;o&128&&(l=Mm(a,f));let d=null,h=null;if(c==="ofs_delta"){let w=Iu(a),y=e-w;({object:d,type:c}=await this.readSlice({start:y}))}if(c==="ref_delta"){let w=a.slice(20).toString("hex");({object:d,type:c}=await this.read({oid:w}))}let p=i.slice(a.tell());if(h=Buffer.from(await Bu(p)),h.byteLength!==l)throw new I(`Packfile told us object would have length ${l} but it had length ${h.byteLength}`);return d&&(h=Buffer.from(Ou(h,d))),this.readDepth>3&&(this.offsetCache[e]={type:c,object:h}),{type:c,format:"content",object:h}}},Te=Symbol("PackfileCache");async function zm({fs:t,filename:e,getExternalRefDelta:r,emitter:n,emitterPrefix:i}){let a=await t.read(e);return pa.fromIdx({idx:a,getExternalRefDelta:r})}function Tu({fs:t,cache:e,filename:r,getExternalRefDelta:n,emitter:i,emitterPrefix:a}){e[Te]||(e[Te]=new Map);let o=e[Te].get(r);return o||(o=zm({fs:t,filename:r,getExternalRefDelta:n,emitter:i,emitterPrefix:a}),e[Te].set(r,o),o.catch(()=>{e[Te].get(r)===o&&e[Te].delete(r)})),o}async function Hm(t,{start:e=0,end:r=t.length}={}){return qt(t.subarray(e,r))}async function qm({fs:t,cache:e,gitdir:r,oid:n,format:i="content",getExternalRefDelta:a}){let o=await t.readdir(D(r,"objects/pack"));o=o.filter(s=>s.endsWith(".idx"));for(let s of o){let c=`${r}/objects/pack/${s}`,f=await Tu({fs:t,cache:e,filename:c,getExternalRefDelta:a});if(f.error)throw new I(f.error);if(f.offsets.has(n)){let l=c.replace(/idx$/,"pack");if(!f.pack){let h=t.read(l);f.pack=h,h.catch(()=>{f.pack===h&&(f.pack=null)})}let u=await f.pack;if(!u)throw f.pack=null,new I(`Could not read packfile at ${l}. The file may be missing, corrupted, or too large to read into memory.`);f._checksumVerification||(f._checksumVerification=Wm(u,f.packfileSha)),await f._checksumVerification;let d=await f.read({oid:n,getExternalRefDelta:a});return d.format="content",d.source=`objects/pack/${s.replace(/idx$/,"pack")}`,d}}return null}async function Wm(t,e){let r=t.subarray(-20),n=Array.from(r).map(a=>a.toString(16).padStart(2,"0")).join("");if(n!==e)throw new I(`Packfile trailer mismatch: expected ${e}, got ${n}. The packfile may be corrupted.`);let i=await Hm(t,{start:0,end:t.length-20});if(i!==e)throw new I(`Packfile payload corrupted: calculated ${i} but expected ${e}. The packfile may have been tampered with.`)}async function Ft({fs:t,cache:e,gitdir:r,oid:n,format:i="content"}){if(!["deflated","wrapped","content"].includes(i))throw new I(`invalid requested format "${i}"`);let a=l=>Ft({fs:t,cache:e,gitdir:r,oid:l}),o;if(n==="4b825dc642cb6eb9a060e54bf8d69288fbee4904"&&(o={format:"wrapped",object:Buffer.from("tree 0\0")}),o||(o=await Tm({fs:t,gitdir:r,oid:n})),!o){if(o=await qm({fs:t,cache:e,gitdir:r,oid:n,getExternalRefDelta:a}),!o)throw new Z(n);return o}if(i==="deflated"||(o.format==="deflated"&&(o.object=Buffer.from(await Bu(o.object)),o.format="wrapped"),i==="wrapped"))return o;let s=await qt(o.object);if(s!==n)throw new I(`SHA check failed! Expected ${n}, computed ${s}`);let{object:c,type:f}=Pe.unwrap(o.object);return o.type=f,o.object=c,o.format="content",o}var wa=class t extends T{constructor(e,r,n=!0){super(`Failed to create ${e} at ${r} because it already exists.${n?` (Hint: use 'force: true' parameter to overwrite existing ${e}.)`:""}`),this.code=this.name=t.code,this.data={noun:e,where:r,canForce:n}}};wa.code="AlreadyExistsError";var ma=class t extends T{constructor(e,r,n){super(`Found multiple ${e} matching "${r}" (${n.join(", ")}). Use a longer abbreviation length to disambiguate them.`),this.code=this.name=t.code,this.data={nouns:e,short:r,matches:n}}};ma.code="AmbiguousError";var ga=class t extends T{constructor(e){super(`Your local changes to the following files would be overwritten by checkout: ${e.join(", ")}`),this.code=this.name=t.code,this.data={filepaths:e}}};ga.code="CheckoutConflictError";var ya=class t extends T{constructor(e){super(`Your local changes to the following files would be overwritten by cherry-pick: ${e.join(", ")}`),this.code=this.name=t.code,this.data={filepaths:e}}};ya.code="CherryPickLocalChangesError";var ba=class t extends T{constructor(e,r){super(`Cannot cherry-pick merge commit ${e}. Merge commits have ${r} parents and require specifying which parent to use as the base.`),this.code=this.name=t.code,this.data={oid:e,parentCount:r}}};ba.code="CherryPickMergeCommitError";var _a=class t extends T{constructor(e){super(`Cannot cherry-pick root commit ${e}. Root commits have no parents.`),this.code=this.name=t.code,this.data={oid:e}}};_a.code="CherryPickRootCommitError";var va=class t extends T{constructor(e,r){super(`Failed to checkout "${e}" because commit ${r} is not available locally. Do a git fetch to make the branch available locally.`),this.code=this.name=t.code,this.data={ref:e,oid:r}}};va.code="CommitNotFetchedError";var bn=class t extends T{constructor(){super("Cannot create an empty commit when disallowEmpty is true."),this.code=this.name=t.code,this.data={}}};bn.code="EmptyCommitError";var xa=class t extends T{constructor(){super("Empty response from git server."),this.code=this.name=t.code,this.data={}}};xa.code="EmptyServerResponseError";var Ea=class t extends T{constructor(){super("A simple fast-forward merge was not possible."),this.code=this.name=t.code,this.data={}}};Ea.code="FastForwardError";var ka=class t extends T{constructor(e,r){super(`One or more branches were not updated: ${e}`),this.code=this.name=t.code,this.data={prettyDetails:e,result:r}}};ka.code="GitPushError";var Sa=class t extends T{constructor(e,r,n){super(`HTTP Error: ${e} ${r}`),this.code=this.name=t.code,this.data={statusCode:e,statusMessage:r,response:n}}};Sa.code="HttpError";var yr=class t extends T{constructor(e){let r="invalid filepath";e==="leading-slash"||e==="trailing-slash"?r='"filepath" parameter should not include leading or trailing directory separators because these can cause problems on some platforms.':e==="directory"&&(r='"filepath" should not be a directory.'),super(r),this.code=this.name=t.code,this.data={reason:e}}};yr.code="InvalidFilepathError";var Aa=class t extends T{constructor(e){super(`Maximum search depth of ${e} exceeded.`),this.code=this.name=t.code,this.data={depth:e}}};Aa.code="MaxDepthError";var $a=class t extends T{constructor(){super("Merges with conflicts are not supported yet."),this.code=this.name=t.code,this.data={}}};$a.code="MergeNotSupportedError";var Ra=class t extends T{constructor(e,r,n,i){super(`Automatic merge failed with one or more merge conflicts in the following files: ${e.toString()}. Fix conflicts then commit the result.`),this.code=this.name=t.code,this.data={filepaths:e,bothModified:r,deleteByUs:n,deleteByTheirs:i}}};Ra.code="MergeConflictError";var br=class t extends T{constructor(e){super(`No name was provided for ${e} in the argument or in the .git/config file.`),this.code=this.name=t.code,this.data={role:e}}};br.code="MissingNameError";var _r=class t extends T{constructor(e){super(`The function requires a "${e}" parameter but none was provided.`),this.code=this.name=t.code,this.data={parameter:e}}};_r.code="MissingParameterError";var _n=class t extends T{constructor(e){super('There are multiple errors that were thrown by the method. Please refer to the "errors" property to see more'),this.code=this.name=t.code,this.data={errors:e},this.errors=e}};_n.code="MultipleGitError";var vn=class t extends T{constructor(e,r){super(`Expected "${e}" but received "${r}".`),this.code=this.name=t.code,this.data={expected:e,actual:r}}};vn.code="ParseError";var Oa=class t extends T{constructor(e){let r="";e==="not-fast-forward"?r=" because it was not a simple fast-forward":e==="tag-exists"&&(r=" because tag already exists"),super(`Push rejected${r}. Use "force: true" to override.`),this.code=this.name=t.code,this.data={reason:e}}};Oa.code="PushRejectedError";var Ba=class t extends T{constructor(e,r){super(`Remote does not support the "${e}" so the "${r}" parameter cannot be used.`),this.code=this.name=t.code,this.data={capability:e,parameter:r}}};Ba.code="RemoteCapabilityError";var Ia=class t extends T{constructor(e,r){super(`Remote did not reply using the "smart" HTTP protocol. Expected "001e# service=git-upload-pack" but received: ${e}`),this.code=this.name=t.code,this.data={preview:e,response:r}}};Ia.code="SmartHttpError";var Ta=class t extends T{constructor(e,r,n){super(`Git remote "${e}" uses an unrecognized transport protocol: "${r}"`),this.code=this.name=t.code,this.data={url:e,transport:r,suggestion:n}}};Ta.code="UnknownTransportError";var Ca=class t extends T{constructor(e){super(`Cannot parse remote URL: "${e}"`),this.code=this.name=t.code,this.data={url:e}}};Ca.code="UrlParseError";var Fa=class t extends T{constructor(){super("The operation was canceled."),this.code=this.name=t.code,this.data={}}};Fa.code="UserCanceledError";var Pa=class t extends T{constructor(e){super(`Could not merge index: Entry for '${e}' is not up to date. Either reset the index entry to HEAD, or stage your unstaged changes.`),this.code=this.name=t.code,this.data={filepath:e}}};Pa.code="IndexResetError";var xn=class t extends T{constructor(e){super(`"${e}" does not point to any commit. You're maybe working on a repository with no commits yet. `),this.code=this.name=t.code,this.data={ref:e}}};xn.code="NoCommitError";function Da({name:t,email:e,timestamp:r,timezoneOffset:n}){return n=Zm(n),`${t} <${e}> ${r} ${n}`}function Zm(t){let e=Vm(Xm(t));t=Math.abs(t);let r=Math.floor(t/60);t-=r*60;let n=String(r),i=String(t);return n.length<2&&(n="0"+n),i.length<2&&(i="0"+i),(e===-1?"-":"+")+n+i}function Vm(t){return Math.sign(t)||(Object.is(t,-0)?-1:1)}function Xm(t){return t===0?t:-t}function Ct(t){return t=t.replace(/\r/g,""),t=t.replace(/^\n+/,""),t=t.replace(/\n+$/,"")+`
38
+ `,"utf8"))}static async deleteRef({fs:e,gitdir:r,ref:n}){return t.deleteRefs({fs:e,gitdir:r,refs:[n]})}static async deleteRefs({fs:e,gitdir:r,refs:n}){n.forEach(se),await Promise.all(n.map(s=>e.rm(D(r,s))));let i=await st("packed-refs",async()=>e.read(`${r}/packed-refs`,{encoding:"utf8"})),a=gn.from(i),o=a.refs.size;for(let s of n)a.refs.has(s)&&a.delete(s);a.refs.size<o&&(i=a.toString(),await st("packed-refs",async()=>e.write(`${r}/packed-refs`,i,{encoding:"utf8"})))}static async resolve({fs:e,gitdir:r,ref:n,depth:i=void 0,visited:a=new Set}){if(i!==void 0&&(i--,i===-1))return n;if(n.startsWith("ref: "))return n=n.slice(5),t.resolve({fs:e,gitdir:r,ref:n,depth:i,visited:a});if(n.length===40&&/[0-9a-f]{40}/.test(n))return n;let o=await t.packedRefs({fs:e,gitdir:r}),s=lr(n).filter(c=>!ua.includes(c));for(let c of s){let f=await st(c,async()=>await e.read(`${r}/${c}`,{encoding:"utf8"})||o.get(c));if(f){if(a.has(c))throw new I(`Circular reference detected while resolving ref "${c}"`);return a.add(c),t.resolve({fs:e,gitdir:r,ref:f.trim(),depth:i,visited:a})}}throw new Z(n)}static async isUnbornBranch({fs:e,gitdir:r,ref:n}){let i;try{i=await t.resolve({fs:e,gitdir:r,ref:"HEAD",depth:2})}catch(a){if(a instanceof Z)return!1;throw a}return i.startsWith("refs/heads/")?n==="HEAD"||lr(n).includes(i):!1}static async exists({fs:e,gitdir:r,ref:n}){try{return await t.expand({fs:e,gitdir:r,ref:n}),!0}catch(i){if(i instanceof Z)return!1;throw i}}static async expand({fs:e,gitdir:r,ref:n}){if(n.length===40&&/[0-9a-f]{40}/.test(n))return n;let i=await t.packedRefs({fs:e,gitdir:r}),a=lr(n).filter(o=>!ua.includes(o));for(let o of a)if(await st(o,async()=>e.exists(`${r}/${o}`))||i.has(o))return o;throw new Z(n)}static async expandAgainstMap({ref:e,map:r}){let n=lr(e);for(let i of n)if(await r.has(i))return i;throw new Z(e)}static resolveAgainstMap({ref:e,fullref:r=e,depth:n=void 0,map:i}){if(n!==void 0&&(n--,n===-1))return{fullref:r,oid:e};if(e.startsWith("ref: "))return e=e.slice(5),t.resolveAgainstMap({ref:e,fullref:r,depth:n,map:i});if(e.length===40&&/[0-9a-f]{40}/.test(e))return{fullref:r,oid:e};let a=lr(e);for(let o of a){let s=i.get(o);if(s)return t.resolveAgainstMap({ref:s.trim(),fullref:o,depth:n,map:i})}throw new Z(e)}static async packedRefs({fs:e,gitdir:r}){let n=await st("packed-refs",async()=>e.read(`${r}/packed-refs`,{encoding:"utf8"}));return gn.from(n).refs}static async listRefs({fs:e,gitdir:r,filepath:n}){let i=await t.packedRefs({fs:e,gitdir:r}),a=null;try{a=await e.readdirDeep(`${r}/${n}`),a=a.map(o=>o.replace(`${r}/${n}/`,""))}catch{a=[]}for(let o of i.keys())o.startsWith(n)&&(o=o.replace(n+"/",""),a.includes(o)||a.push(o));return a.sort(dm),a}static async listBranches({fs:e,gitdir:r,remote:n}){return n?t.listRefs({fs:e,gitdir:r,filepath:`refs/remotes/${n}`}):t.listRefs({fs:e,gitdir:r,filepath:"refs/heads"})}static async listTags({fs:e,gitdir:r}){return(await t.listRefs({fs:e,gitdir:r,filepath:"refs/tags"})).filter(i=>!i.endsWith("^{}"))}};function $m(t,e){return Ha(su(t),su(e))}function su(t){return t.mode==="040000"?t.path+"/":t.path}function $u(t){switch(t){case"040000":return"tree";case"100644":return"blob";case"100755":return"blob";case"120000":return"blob";case"160000":return"commit"}throw new I(`Unexpected GitTree entry mode: ${t}`)}function Om(t){let e=[],r=0;for(;r<t.length;){let n=t.indexOf(32,r);if(n===-1)throw new I(`GitTree: Error parsing buffer at byte location ${r}: Could not find the next space character.`);let i=t.indexOf(0,r);if(i===-1)throw new I(`GitTree: Error parsing buffer at byte location ${r}: Could not find the next null character.`);let a=t.slice(r,n).toString("utf8");a==="40000"&&(a="040000");let o=$u(a),s=t.slice(n+1,i).toString("utf8"),c=s.replace(/[\u200C-\u200F\u202A-\u202E\u206A-\u206F\uFEFF]/g,""),l=c.split(":")[0].toLowerCase().replace(/[. ]+$/,"");if(s.includes("\\")||s.includes("/")||c==="."||c===".."||l===".git"||/^\.?git~[1-9]$/.test(l))throw new hr(s);let u=t.slice(i+1,i+21).toString("hex");r=i+21,e.push({mode:a,path:s,oid:u,type:o})}return e}function Bm(t){if(typeof t=="number"&&(t=t.toString(8)),t.match(/^0?4.*/))return"040000";if(t.match(/^1006.*/))return"100644";if(t.match(/^1007.*/))return"100755";if(t.match(/^120.*/))return"120000";if(t.match(/^160.*/))return"160000";throw new I(`Could not understand file mode: ${t}`)}function Im(t){return!t.oid&&t.sha&&(t.oid=t.sha),t.mode=Bm(t.mode),t.type||(t.type=$u(t.mode)),t}var Zt=class t{constructor(e){if(Buffer.isBuffer(e))this._entries=Om(e);else if(Array.isArray(e))this._entries=e.map(Im);else throw new I("invalid type passed to GitTree constructor");this._entries.sort(ku)}static from(e){return new t(e)}render(){return this._entries.map(e=>`${e.mode} ${e.type} ${e.oid} ${e.path}`).join(`
39
+ `)}toObject(){let e=[...this._entries];return e.sort($m),Buffer.concat(e.map(r=>{let n=Buffer.from(r.mode.replace(/^0/,"")),i=Buffer.from(" "),a=Buffer.from(r.path,"utf8"),o=Buffer.from([0]),s=Buffer.from(r.oid,"hex");return Buffer.concat([n,i,a,o,s])}))}entries(){return this._entries}*[Symbol.iterator](){for(let e of this._entries)yield e}},Pe=class{static wrap({type:e,object:r}){let n=`${e} ${r.length}\0`,i=n.length,a=i+r.length,o=new Uint8Array(a);for(let s=0;s<i;s++)o[s]=n.charCodeAt(s);return o.set(r,i),o}static unwrap(e){let r=e.indexOf(32),n=e.indexOf(0),i=e.slice(0,r).toString("utf8"),a=e.slice(r+1,n).toString("utf8"),o=e.length-(n+1);if(parseInt(a)!==o)throw new I(`Length mismatch: expected ${a} bytes but got ${o} instead.`);return{type:i,object:Buffer.from(e.slice(n+1))}}};async function Tm({fs:t,gitdir:e,oid:r}){let n=`objects/${r.slice(0,2)}/${r.slice(2)}`,i=await t.read(`${e}/${n}`);return i?{object:i,format:"deflated",source:n}:null}function Ou(t,e){let r=new ct(t),n=cu(r);if(n!==e.byteLength)throw new I(`applyDelta expected source buffer to be ${n} bytes but the provided buffer was ${e.length} bytes`);let i=cu(r),a,o=lu(r,e);if(o.byteLength===i)a=o;else{let s=[o],c=o.byteLength;for(;!r.eof();){let f=lu(r,e);s.push(f),c+=f.byteLength}if(i!==c)throw new I(`applyDelta expected target buffer to be ${i} bytes but the resulting buffer was ${c} bytes`);a=Buffer.concat(s,i)}return a}function cu(t){let e=0,r=0,n=null;do n=t.readUInt8(),e|=(n&127)<<r,r+=7;while(n&128);return e}function fu(t,e,r){let n=0,i=0;for(;r--;)e&1&&(n|=t.readUInt8()<<i),e>>=1,i+=8;return n}function lu(t,e){let r=t.readUInt8(),n=128,i=15,a=112;if(r&n){let o=fu(t,r&i,4),s=fu(t,(r&a)>>4,3);return s===0&&(s=65536),e.slice(o,o+s)}else return t.slice(r)}function Cm(t){let e=[t];return{next(){return Promise.resolve({done:e.length===0,value:e.pop()})},return(){return e=[],{}},[Symbol.asyncIterator](){return this}}}function Fm(t){return t[Symbol.asyncIterator]?t[Symbol.asyncIterator]():t[Symbol.iterator]?t[Symbol.iterator]():t.next?t:Cm(t)}var da=class{constructor(e){if(typeof Buffer>"u")throw new Error("Missing Buffer dependency");this.stream=Fm(e),this.buffer=null,this.cursor=0,this.undoCursor=0,this.started=!1,this._ended=!1,this._discardedBytes=0}eof(){return this._ended&&this.cursor===this.buffer.length}tell(){return this._discardedBytes+this.cursor}async byte(){if(!this.eof()&&(this.started||await this._init(),!(this.cursor===this.buffer.length&&(await this._loadnext(),this._ended))))return this._moveCursor(1),this.buffer[this.undoCursor]}async chunk(){if(!this.eof()&&(this.started||await this._init(),!(this.cursor===this.buffer.length&&(await this._loadnext(),this._ended))))return this._moveCursor(this.buffer.length),this.buffer.slice(this.undoCursor,this.cursor)}async read(e){if(!this.eof())return this.started||await this._init(),this.cursor+e>this.buffer.length&&(this._trim(),await this._accumulate(e)),this._moveCursor(e),this.buffer.slice(this.undoCursor,this.cursor)}async skip(e){this.eof()||(this.started||await this._init(),this.cursor+e>this.buffer.length&&(this._trim(),await this._accumulate(e)),this._moveCursor(e))}async undo(){this.cursor=this.undoCursor}async _next(){this.started=!0;let{done:e,value:r}=await this.stream.next();return e&&(this._ended=!0,!r)?Buffer.alloc(0):(r&&(r=Buffer.from(r)),r)}_trim(){this.buffer=this.buffer.slice(this.undoCursor),this.cursor-=this.undoCursor,this._discardedBytes+=this.undoCursor,this.undoCursor=0}_moveCursor(e){this.undoCursor=this.cursor,this.cursor+=e,this.cursor>this.buffer.length&&(this.cursor=this.buffer.length)}async _accumulate(e){if(this._ended)return;let r=[this.buffer];for(;this.cursor+e>Pm(r);){let n=await this._next();if(this._ended)break;r.push(n)}this.buffer=Buffer.concat(r)}async _loadnext(){this._discardedBytes+=this.buffer.length,this.undoCursor=0,this.cursor=0,this.buffer=await this._next()}async _init(){this.buffer=await this._next()}};function Pm(t){return t.reduce((e,r)=>e+r.length,0)}async function Dm(t,e){let r=new da(t),n=await r.read(4);if(n=n.toString("utf8"),n!=="PACK")throw new I(`Invalid PACK header '${n}'`);let i=await r.read(4);if(i=i.readUInt32BE(0),i!==2)throw new I(`Invalid packfile version: ${i}`);let a=await r.read(4);if(a=a.readUInt32BE(0),!(a<1))for(;!r.eof()&&a--;){let o=r.tell(),{type:s,length:c,ofs:f,reference:l}=await Nm(r),u=new Sn.default.Inflate;for(;!u.result;){let d=await r.chunk();if(!d)break;if(u.push(d,!1),u.err)throw new I(`Pako error: ${u.msg}`);if(u.result){if(u.result.length!==c)throw new I("Inflated object size is different from that stated in packfile.");await r.undo(),await r.read(d.length-u.strm.avail_in);let h=r.tell();await e({data:u.result,type:s,num:a,offset:o,end:h,reference:l,ofs:f})}}}}async function Nm(t){let e=await t.byte(),r=e>>4&7,n=e&15;if(e&128){let o=4;do e=await t.byte(),n|=(e&127)<<o,o+=7;while(e&128)}let i,a;if(r===6){let o=0;i=0;let s=[];do e=await t.byte(),i|=(e&127)<<o,o+=7,s.push(e);while(e&128);a=Buffer.from(s)}return r===7&&(a=await t.read(20)),{type:r,length:n,ofs:i,reference:a}}var gr=class t extends T{constructor(e){super(`Invalid compressed buffer: ${e}`),this.code=this.name=t.code,this.data={message:e}}};gr.code="DecompressionError";async function Um(t){let e=new DecompressionStream("deflate"),r=new Blob([t]).stream().pipeThrough(e);try{return new Uint8Array(await new Response(r).arrayBuffer())}catch(n){throw n&&n.name==="TypeError"&&n.message===""?new gr("decompression failed"):n}}var ta=!1;async function Bu(t){ta===null&&(ta=jm());try{return ta?await Um(t):Sn.default.inflate(t)}catch(e){throw typeof e=="string"?new gr(e):e}}function jm(){try{if(new DecompressionStream("deflate"))return!0}catch{}return!1}function Iu(t){let e=[],r=0,n=0;do{r=t.readUInt8();let i=r&127;e.push(i),n=r&128}while(n);return e.reduce((i,a)=>i+1<<7|a,-1)}function Mm(t,e){let r=e,n=4,i=null;do i=t.readUInt8(),r|=(i&127)<<n,n+=7;while(i&128);return r}var Lm=32*1024*1024,ha=class{constructor(e){this.maxBytes=e,this.bytes=0,this.map=new Map}get(e){let r=this.map.get(e);return r!==void 0&&(this.map.delete(e),this.map.set(e,r)),r}set(e,r){let n=r.object.byteLength;if(!(n>this.maxBytes/4)){this.map.set(e,r),this.bytes+=n;for(let[i,a]of this.map){if(this.bytes<=this.maxBytes)break;this.map.delete(i),this.bytes-=a.object.byteLength}}}};function Gm({type:t,data:e,reference:r,offset:n},i,a){let o=Buffer.from(e.buffer,e.byteOffset,e.byteLength);if(t!=="ofs-delta"&&t!=="ref-delta")return{type:t,object:o};let s=t==="ofs-delta"?n-Iu(new ct(r)):a.get(r.toString("hex")),c=i.get(s);if(!c)return null;try{return{type:c.type,object:Buffer.from(Ou(o,c.object))}}catch(f){if(f instanceof I||f instanceof RangeError)return null;throw f}}var pa=class t{constructor(e){Object.assign(this,e),this.offsetCache={}}static async fromIdx({idx:e,getExternalRefDelta:r}){let n=new ct(e);if(n.slice(4).toString("hex")!=="ff744f63")return;let a=n.readUInt32BE();if(a!==2)throw new I(`Unable to read version ${a} packfile IDX. (Only version 2 supported)`);if(e.byteLength>2048*1024*1024)throw new I("To keep implementation simple, I haven't implemented the layer 5 feature needed to support packfiles > 2GB in size.");n.seek(n.tell()+1020);let o=n.readUInt32BE(),s=[];for(let l=0;l<o;l++){let u=n.slice(20).toString("hex");s[l]=u}n.seek(n.tell()+4*o);let c=new Map;for(let l=0;l<o;l++)c.set(s[l],n.readUInt32BE());let f=n.slice(20).toString("hex");return new t({hashes:s,crcs:{},offsets:c,packfileSha:f,getExternalRefDelta:r})}static async fromPack({pack:e,getExternalRefDelta:r,onProgress:n}){let i={1:"commit",2:"tree",3:"blob",4:"tag",6:"ofs-delta",7:"ref-delta"},a={},o=e.slice(-20).toString("hex"),s=[],c={},f=new Map,l=null,u=null,d=new ha(Lm),h=new Map;await Dm([e],async({data:E,type:S,reference:A,offset:m,num:$})=>{l===null&&(l=$);let g=Math.floor((l-$)*100/l);g!==u&&n&&await n({phase:"Receiving objects",loaded:l-$,total:l}),u=g,S=i[S],["commit","tree","blob","tag"].includes(S)?a[m]={type:S,offset:m}:S==="ofs-delta"?a[m]={type:S,offset:m}:S==="ref-delta"&&(a[m]={type:S,offset:m});let x=a[m];if(!x)return;let _=Gm({type:S,data:E,reference:A,offset:m},d,h);_&&(x.oid=await qt(Pe.wrap(_)),h.set(x.oid,m),d.set(m,_))});let p=Object.keys(a).map(Number);for(let[E,S]of p.entries()){let A=E+1===p.length?e.byteLength-20:p[E+1],m=a[S],$=xu.default.buf(e.slice(S,A))>>>0;m.end=A,m.crc=$}let w=new t({pack:Promise.resolve(e),packfileSha:o,crcs:c,hashes:s,offsets:f,getExternalRefDelta:r});u=null;let y=0,b=[0,0,0,0,0,0,0,0,0,0,0,0];for(let E in a){E=Number(E);let S=Math.floor(y*100/l);S!==u&&n&&await n({phase:"Resolving deltas",loaded:y,total:l}),y++,u=S;let A=a[E];if(!A.oid)try{w.readDepth=0,w.externalReadDepth=0;let{type:m,object:$}=await w.readSlice({start:E});b[w.readDepth]+=1,A.oid=await qt(Pe.wrap({type:m,object:$}))}catch{continue}s.push(A.oid),f.set(A.oid,E),c[A.oid]=A.crc}return s.sort(),w}async toBuffer(){let e=[],r=(f,l)=>{e.push(Buffer.from(f,l))};r("ff744f63","hex"),r("00000002","hex");let n=new ct(Buffer.alloc(256*4));for(let f=0;f<256;f++){let l=0;for(let u of this.hashes)parseInt(u.slice(0,2),16)<=f&&l++;n.writeUInt32BE(l)}e.push(n.buffer);for(let f of this.hashes)r(f,"hex");let i=new ct(Buffer.alloc(this.hashes.length*4));for(let f of this.hashes)i.writeUInt32BE(this.crcs[f]);e.push(i.buffer);let a=new ct(Buffer.alloc(this.hashes.length*4));for(let f of this.hashes)a.writeUInt32BE(this.offsets.get(f));e.push(a.buffer),r(this.packfileSha,"hex");let o=Buffer.concat(e),s=await qt(o),c=Buffer.alloc(20);return c.write(s,"hex"),Buffer.concat([o,c])}async load({pack:e}){this.pack=e}async unload(){this.pack=null}async read({oid:e}){if(!this.offsets.get(e)){if(this.getExternalRefDelta)return this.externalReadDepth++,this.getExternalRefDelta(e);throw new I(`Could not read object ${e} from packfile`)}let r=this.offsets.get(e);return this.readSlice({start:r})}async readSlice({start:e}){if(this.offsetCache[e])return Object.assign({},this.offsetCache[e]);this.readDepth++;let r={16:"commit",32:"tree",48:"blob",64:"tag",96:"ofs_delta",112:"ref_delta"},n=await this.pack;if(!n)throw new I("Could not read packfile data. The packfile may be missing, corrupted, or too large to read into memory.");let i=n.slice(e),a=new ct(i),o=a.readUInt8(),s=o&112,c=r[s];if(c===void 0)throw new I("Unrecognized type: 0b"+s.toString(2));let f=o&15,l=f;o&128&&(l=Mm(a,f));let d=null,h=null;if(c==="ofs_delta"){let w=Iu(a),y=e-w;({object:d,type:c}=await this.readSlice({start:y}))}if(c==="ref_delta"){let w=a.slice(20).toString("hex");({object:d,type:c}=await this.read({oid:w}))}let p=i.slice(a.tell());if(h=Buffer.from(await Bu(p)),h.byteLength!==l)throw new I(`Packfile told us object would have length ${l} but it had length ${h.byteLength}`);return d&&(h=Buffer.from(Ou(h,d))),this.readDepth>3&&(this.offsetCache[e]={type:c,object:h}),{type:c,format:"content",object:h}}},Te=Symbol("PackfileCache");async function zm({fs:t,filename:e,getExternalRefDelta:r,emitter:n,emitterPrefix:i}){let a=await t.read(e);return pa.fromIdx({idx:a,getExternalRefDelta:r})}function Tu({fs:t,cache:e,filename:r,getExternalRefDelta:n,emitter:i,emitterPrefix:a}){e[Te]||(e[Te]=new Map);let o=e[Te].get(r);return o||(o=zm({fs:t,filename:r,getExternalRefDelta:n,emitter:i,emitterPrefix:a}),e[Te].set(r,o),o.catch(()=>{e[Te].get(r)===o&&e[Te].delete(r)})),o}async function Hm(t,{start:e=0,end:r=t.length}={}){return qt(t.subarray(e,r))}async function qm({fs:t,cache:e,gitdir:r,oid:n,format:i="content",getExternalRefDelta:a}){let o=await t.readdir(D(r,"objects/pack"));o=o.filter(s=>s.endsWith(".idx"));for(let s of o){let c=`${r}/objects/pack/${s}`,f=await Tu({fs:t,cache:e,filename:c,getExternalRefDelta:a});if(f.error)throw new I(f.error);if(f.offsets.has(n)){let l=c.replace(/idx$/,"pack");if(!f.pack){let h=t.read(l);f.pack=h,h.catch(()=>{f.pack===h&&(f.pack=null)})}let u=await f.pack;if(!u)throw f.pack=null,new I(`Could not read packfile at ${l}. The file may be missing, corrupted, or too large to read into memory.`);f._checksumVerification||(f._checksumVerification=Wm(u,f.packfileSha)),await f._checksumVerification;let d=await f.read({oid:n,getExternalRefDelta:a});return d.format="content",d.source=`objects/pack/${s.replace(/idx$/,"pack")}`,d}}return null}async function Wm(t,e){let r=t.subarray(-20),n=Array.from(r).map(a=>a.toString(16).padStart(2,"0")).join("");if(n!==e)throw new I(`Packfile trailer mismatch: expected ${e}, got ${n}. The packfile may be corrupted.`);let i=await Hm(t,{start:0,end:t.length-20});if(i!==e)throw new I(`Packfile payload corrupted: calculated ${i} but expected ${e}. The packfile may have been tampered with.`)}async function Ft({fs:t,cache:e,gitdir:r,oid:n,format:i="content"}){if(!["deflated","wrapped","content"].includes(i))throw new I(`invalid requested format "${i}"`);let a=l=>Ft({fs:t,cache:e,gitdir:r,oid:l}),o;if(n==="4b825dc642cb6eb9a060e54bf8d69288fbee4904"&&(o={format:"wrapped",object:Buffer.from("tree 0\0")}),o||(o=await Tm({fs:t,gitdir:r,oid:n})),!o){if(o=await qm({fs:t,cache:e,gitdir:r,oid:n,getExternalRefDelta:a}),!o)throw new Z(n);return o}if(i==="deflated"||(o.format==="deflated"&&(o.object=Buffer.from(await Bu(o.object)),o.format="wrapped"),i==="wrapped"))return o;let s=await qt(o.object);if(s!==n)throw new I(`SHA check failed! Expected ${n}, computed ${s}`);let{object:c,type:f}=Pe.unwrap(o.object);return o.type=f,o.object=c,o.format="content",o}var wa=class t extends T{constructor(e,r,n=!0){super(`Failed to create ${e} at ${r} because it already exists.${n?` (Hint: use 'force: true' parameter to overwrite existing ${e}.)`:""}`),this.code=this.name=t.code,this.data={noun:e,where:r,canForce:n}}};wa.code="AlreadyExistsError";var ma=class t extends T{constructor(e,r,n){super(`Found multiple ${e} matching "${r}" (${n.join(", ")}). Use a longer abbreviation length to disambiguate them.`),this.code=this.name=t.code,this.data={nouns:e,short:r,matches:n}}};ma.code="AmbiguousError";var ga=class t extends T{constructor(e){super(`Your local changes to the following files would be overwritten by checkout: ${e.join(", ")}`),this.code=this.name=t.code,this.data={filepaths:e}}};ga.code="CheckoutConflictError";var ya=class t extends T{constructor(e){super(`Your local changes to the following files would be overwritten by cherry-pick: ${e.join(", ")}`),this.code=this.name=t.code,this.data={filepaths:e}}};ya.code="CherryPickLocalChangesError";var ba=class t extends T{constructor(e,r){super(`Cannot cherry-pick merge commit ${e}. Merge commits have ${r} parents and require specifying which parent to use as the base.`),this.code=this.name=t.code,this.data={oid:e,parentCount:r}}};ba.code="CherryPickMergeCommitError";var _a=class t extends T{constructor(e){super(`Cannot cherry-pick root commit ${e}. Root commits have no parents.`),this.code=this.name=t.code,this.data={oid:e}}};_a.code="CherryPickRootCommitError";var va=class t extends T{constructor(e,r){super(`Failed to checkout "${e}" because commit ${r} is not available locally. Do a git fetch to make the branch available locally.`),this.code=this.name=t.code,this.data={ref:e,oid:r}}};va.code="CommitNotFetchedError";var bn=class t extends T{constructor(){super("Cannot create an empty commit when disallowEmpty is true."),this.code=this.name=t.code,this.data={}}};bn.code="EmptyCommitError";var xa=class t extends T{constructor(){super("Empty response from git server."),this.code=this.name=t.code,this.data={}}};xa.code="EmptyServerResponseError";var Ea=class t extends T{constructor(){super("A simple fast-forward merge was not possible."),this.code=this.name=t.code,this.data={}}};Ea.code="FastForwardError";var ka=class t extends T{constructor(e,r){super(`One or more branches were not updated: ${e}`),this.code=this.name=t.code,this.data={prettyDetails:e,result:r}}};ka.code="GitPushError";var Sa=class t extends T{constructor(e,r,n){super(`HTTP Error: ${e} ${r}`),this.code=this.name=t.code,this.data={statusCode:e,statusMessage:r,response:n}}};Sa.code="HttpError";var yr=class t extends T{constructor(e){let r="invalid filepath";e==="leading-slash"||e==="trailing-slash"?r='"filepath" parameter should not include leading or trailing directory separators because these can cause problems on some platforms.':e==="directory"&&(r='"filepath" should not be a directory.'),super(r),this.code=this.name=t.code,this.data={reason:e}}};yr.code="InvalidFilepathError";var Aa=class t extends T{constructor(e){super(`Maximum search depth of ${e} exceeded.`),this.code=this.name=t.code,this.data={depth:e}}};Aa.code="MaxDepthError";var Ra=class t extends T{constructor(){super("Merges with conflicts are not supported yet."),this.code=this.name=t.code,this.data={}}};Ra.code="MergeNotSupportedError";var $a=class t extends T{constructor(e,r,n,i){super(`Automatic merge failed with one or more merge conflicts in the following files: ${e.toString()}. Fix conflicts then commit the result.`),this.code=this.name=t.code,this.data={filepaths:e,bothModified:r,deleteByUs:n,deleteByTheirs:i}}};$a.code="MergeConflictError";var br=class t extends T{constructor(e){super(`No name was provided for ${e} in the argument or in the .git/config file.`),this.code=this.name=t.code,this.data={role:e}}};br.code="MissingNameError";var _r=class t extends T{constructor(e){super(`The function requires a "${e}" parameter but none was provided.`),this.code=this.name=t.code,this.data={parameter:e}}};_r.code="MissingParameterError";var _n=class t extends T{constructor(e){super('There are multiple errors that were thrown by the method. Please refer to the "errors" property to see more'),this.code=this.name=t.code,this.data={errors:e},this.errors=e}};_n.code="MultipleGitError";var vn=class t extends T{constructor(e,r){super(`Expected "${e}" but received "${r}".`),this.code=this.name=t.code,this.data={expected:e,actual:r}}};vn.code="ParseError";var Oa=class t extends T{constructor(e){let r="";e==="not-fast-forward"?r=" because it was not a simple fast-forward":e==="tag-exists"&&(r=" because tag already exists"),super(`Push rejected${r}. Use "force: true" to override.`),this.code=this.name=t.code,this.data={reason:e}}};Oa.code="PushRejectedError";var Ba=class t extends T{constructor(e,r){super(`Remote does not support the "${e}" so the "${r}" parameter cannot be used.`),this.code=this.name=t.code,this.data={capability:e,parameter:r}}};Ba.code="RemoteCapabilityError";var Ia=class t extends T{constructor(e,r){super(`Remote did not reply using the "smart" HTTP protocol. Expected "001e# service=git-upload-pack" but received: ${e}`),this.code=this.name=t.code,this.data={preview:e,response:r}}};Ia.code="SmartHttpError";var Ta=class t extends T{constructor(e,r,n){super(`Git remote "${e}" uses an unrecognized transport protocol: "${r}"`),this.code=this.name=t.code,this.data={url:e,transport:r,suggestion:n}}};Ta.code="UnknownTransportError";var Ca=class t extends T{constructor(e){super(`Cannot parse remote URL: "${e}"`),this.code=this.name=t.code,this.data={url:e}}};Ca.code="UrlParseError";var Fa=class t extends T{constructor(){super("The operation was canceled."),this.code=this.name=t.code,this.data={}}};Fa.code="UserCanceledError";var Pa=class t extends T{constructor(e){super(`Could not merge index: Entry for '${e}' is not up to date. Either reset the index entry to HEAD, or stage your unstaged changes.`),this.code=this.name=t.code,this.data={filepath:e}}};Pa.code="IndexResetError";var xn=class t extends T{constructor(e){super(`"${e}" does not point to any commit. You're maybe working on a repository with no commits yet. `),this.code=this.name=t.code,this.data={ref:e}}};xn.code="NoCommitError";function Da({name:t,email:e,timestamp:r,timezoneOffset:n}){return n=Zm(n),`${t} <${e}> ${r} ${n}`}function Zm(t){let e=Vm(Xm(t));t=Math.abs(t);let r=Math.floor(t/60);t-=r*60;let n=String(r),i=String(t);return n.length<2&&(n="0"+n),i.length<2&&(i="0"+i),(e===-1?"-":"+")+n+i}function Vm(t){return Math.sign(t)||(Object.is(t,-0)?-1:1)}function Xm(t){return t===0?t:-t}function Ct(t){return t=t.replace(/\r/g,""),t=t.replace(/^\n+/,""),t=t.replace(/\n+$/,"")+`
40
40
  `,t}function En(t){let[,e,r,n,i]=t.match(/^(.*) <(.*)> (.*) (.*)$/);return{name:e,email:r,timestamp:Number(n),timezoneOffset:Ym(i)}}function Ym(t){let[,e,r,n]=t.match(/(\+|-)(\d\d)(\d\d)/);return n=(e==="+"?1:-1)*(Number(r)*60+Number(n)),Km(n)}function Km(t){return t===0?t:-t}var vr=class t{constructor(e){if(typeof e=="string")this._tag=e;else if(Buffer.isBuffer(e))this._tag=e.toString("utf8");else if(typeof e=="object")this._tag=t.render(e);else throw new I("invalid type passed to GitAnnotatedTag constructor")}static from(e){return new t(e)}static render(e){return`object ${e.object}
41
41
  type ${e.type}
42
42
  tag ${e.tag}
@@ -78,7 +78,7 @@ gpgsig`)),n=e.slice(e.indexOf(`-----END PGP SIGNATURE-----
78
78
  `)+28);return Ct(r+`
79
79
  `+n)}isolateSignature(){let e=this._commit.slice(this._commit.indexOf("-----BEGIN PGP SIGNATURE-----"),this._commit.indexOf("-----END PGP SIGNATURE-----")+27);return Jm(e)}static async sign(e,r,n){let i=e.withoutSignature(),a=t.justMessage(e._commit),{signature:o}=await r({payload:i,secretKey:n});o=Ct(o);let c=t.justHeaders(e._commit)+`
80
80
  gpgsig`+ea(o)+`
81
- `+a;return t.from(c)}};async function xr({fs:t,cache:e,gitdir:r,oid:n}){if(n==="4b825dc642cb6eb9a060e54bf8d69288fbee4904")return{tree:Zt.from([]),oid:n};let{type:i,object:a}=await Ft({fs:t,cache:e,gitdir:r,oid:n});if(i==="tag")return n=vr.from(a).parse().object,xr({fs:t,cache:e,gitdir:r,oid:n});if(i==="commit")return n=De.from(a).parse().tree,xr({fs:t,cache:e,gitdir:r,oid:n});if(i!=="tree")throw new Wt(n,i,"tree");return{tree:Zt.from(a),oid:n}}var Na=class{constructor({fs:e,gitdir:r,ref:n,cache:i}){this.fs=e,this.cache=i,this.gitdir=r,this.mapPromise=(async()=>{let o=new Map,s;try{s=await ft.resolve({fs:e,gitdir:r,ref:n})}catch(f){if(f instanceof Z&&await ft.isUnbornBranch({fs:e,gitdir:r,ref:n}))s="4b825dc642cb6eb9a060e54bf8d69288fbee4904";else throw f}let c=await xr({fs:e,cache:this.cache,gitdir:r,oid:s});return c.type="tree",c.mode="40000",o.set(".",c),o})();let a=this;this.ConstructEntry=class{constructor(s){this._fullpath=s,this._type=!1,this._mode=!1,this._stat=!1,this._content=!1,this._oid=!1}async type(){return a.type(this)}async mode(){return a.mode(this)}async stat(){return a.stat(this)}async content(){return a.content(this)}async oid(){return a.oid(this)}}}async readdir(e){let r=e._fullpath,{fs:n,cache:i,gitdir:a}=this,o=await this.mapPromise,s=o.get(r);if(!s)throw new Error(`No obj for ${r}`);let c=s.oid;if(!c)throw new Error(`No oid for obj ${JSON.stringify(s)}`);if(s.type!=="tree")return null;let{type:f,object:l}=await Ft({fs:n,cache:i,gitdir:a,oid:c});if(f!==s.type)throw new Wt(c,f,s.type);let u=Zt.from(l);for(let d of u)o.set(D(r,d.path),d);return u.entries().map(d=>D(r,d.path))}async type(e){if(e._type===!1){let r=await this.mapPromise,{type:n}=r.get(e._fullpath);e._type=n}return e._type}async mode(e){if(e._mode===!1){let r=await this.mapPromise,{mode:n}=r.get(e._fullpath);e._mode=Su(parseInt(n,8))}return e._mode}async stat(e){}async content(e){if(e._content===!1){let r=await this.mapPromise,{fs:n,cache:i,gitdir:a}=this,s=r.get(e._fullpath).oid,{type:c,object:f}=await Ft({fs:n,cache:i,gitdir:a,oid:s});c!=="blob"?e._content=void 0:e._content=new Uint8Array(f)}return e._content}async oid(e){if(e._oid===!1){let n=(await this.mapPromise).get(e._fullpath);e._oid=n.oid}return e._oid}};function uu({ref:t="HEAD"}={}){let e=Object.create(null);return Object.defineProperty(e,$u,{value:function({fs:r,gitdir:n,cache:i}){return new Na({fs:r,gitdir:n,ref:t,cache:i})}}),Object.freeze(e),e}function Qm(t,e){let r=e-t;return Array.from({length:r},(n,i)=>t+i)}var tg=typeof Array.prototype.flat>"u"?t=>t.reduce((e,r)=>e.concat(r),[]):t=>t.flat(),Ua=class{constructor(){this.value=null}consider(e){e!=null&&(this.value===null?this.value=e:e<this.value&&(this.value=e))}reset(){this.value=null}};function*eg(t){let e=new Ua,r,n=[],i=t.length;for(let a=0;a<i;a++)n[a]=t[a].next().value,n[a]!==void 0&&e.consider(n[a]);if(e.value!==null)for(;;){let a=[];r=e.value,e.reset();for(let o=0;o<i;o++)n[o]!==void 0&&n[o]===r?(a[o]=n[o],n[o]=t[o].next().value):a[o]=null,n[o]!==void 0&&e.consider(n[o]);if(yield a,e.value===null)return}}async function rg({fs:t,cache:e,dir:r,gitdir:n,trees:i,map:a=async(c,f)=>f,reduce:o=async(c,f)=>{let l=tg(f);return c!==void 0&&l.unshift(c),l},iterate:s=(c,f)=>Promise.all([...f].map(c))}){let c=i.map(p=>p[$u]({fs:t,dir:r,gitdir:n,cache:e})),f=new Array(c.length).fill("."),l=Qm(0,c.length),u=async p=>{l.forEach(b=>{let E=p[b];p[b]=E&&new c[b].ConstructEntry(E)});let y=(await Promise.all(l.map(b=>{let E=p[b];return E?c[b].readdir(E):[]}))).map(b=>(b===null?[]:b)[Symbol.iterator]());return{entries:p,children:eg(y)}},d=async p=>{let{entries:w,children:y}=await u(p),b=w.find(S=>S&&S._fullpath)._fullpath,E=await a(b,w);if(E!==null){let S=await s(d,y);return S=S.filter(A=>A!==void 0),o(E,S)}},h=await d(f);for(let p of c)p.flush&&await p.flush();return h}async function Cu(t,e,r=10){try{await t(e)}catch(n){if(n===null||n.code==="EEXIST")return;if(n.code!=="ENOENT")throw n;let i=Fe(e);if(i==="."||i==="/"||i===e)throw n;await Cu(t,i,r);for(let a=0;;a++)try{await t(e);return}catch(o){if(o===null||o.code==="EEXIST")return;if(o.code==="ENOENT"&&a<r){await new Promise(s=>setTimeout(s,0));continue}throw o}}}async function ja(t,e){let r=await t.readdir(e);r==null?await t.rm(e):r.length?await Promise.all(r.map(n=>{let i=D(e,n);return t.lstat(i).then(a=>{if(a)return a.isDirectory()?ja(t,i):t.rm(i)})})).then(()=>t.rmdir(e)):await t.rmdir(e)}function ng(t){return ig(t)&&du(t.then)&&du(t.catch)}function ig(t){return t&&typeof t=="object"}function du(t){return typeof t=="function"}function ur(t){let e=t.code;return typeof e!="string"?!1:e==="ENOENT"||e==="ENOTDIR"||e.includes("ENS")}function hu(t){return ng((r=>{try{return r.readFile().catch(n=>n)}catch(n){return n}})(t))}var pu=["readFile","writeFile","mkdir","rmdir","unlink","stat","lstat","readdir","readlink","symlink"];function wu(t,e){if(hu(e))for(let r of pu)t[`_${r}`]=e[r].bind(e);else for(let r of pu)t[`_${r}`]=(0,dr.default)(e[r].bind(e));hu(e)?(e.cp&&(t._cp=e.cp.bind(e)),e.rm?t._rm=e.rm.bind(e):e.rmdir.length>1?t._rm=e.rmdir.bind(e):t._rm=ja.bind(null,t)):(e.cp&&(t._cp=(0,dr.default)(e.cp.bind(e))),e.rm?t._rm=(0,dr.default)(e.rm.bind(e)):e.rmdir.length>2?t._rm=(0,dr.default)(e.rmdir.bind(e)):t._rm=ja.bind(null,t))}var Vt=class{constructor(e){if(typeof e._original_unwrapped_fs<"u")return e;let r=Object.getOwnPropertyDescriptor(e,"promises");r&&r.enumerable?wu(this,e.promises):wu(this,e),this._original_unwrapped_fs=e}async exists(e,r={}){try{return await this._stat(e),!0}catch(n){if(ur(n))return!1;throw console.log('Unhandled error in "FileSystem.exists()" function',n),n}}async read(e,r={}){let n;try{n=await this._readFile(e,r)}catch(i){if(ur(i)||i.code==="EISDIR")return null;throw i}if(n==null)return null;if(r.autocrlf==="true")try{n=new TextDecoder("utf8",{fatal:!0}).decode(n),n=n.replace(/\r\n/g,`
81
+ `+a;return t.from(c)}};async function xr({fs:t,cache:e,gitdir:r,oid:n}){if(n==="4b825dc642cb6eb9a060e54bf8d69288fbee4904")return{tree:Zt.from([]),oid:n};let{type:i,object:a}=await Ft({fs:t,cache:e,gitdir:r,oid:n});if(i==="tag")return n=vr.from(a).parse().object,xr({fs:t,cache:e,gitdir:r,oid:n});if(i==="commit")return n=De.from(a).parse().tree,xr({fs:t,cache:e,gitdir:r,oid:n});if(i!=="tree")throw new Wt(n,i,"tree");return{tree:Zt.from(a),oid:n}}var Na=class{constructor({fs:e,gitdir:r,ref:n,cache:i}){this.fs=e,this.cache=i,this.gitdir=r,this.mapPromise=(async()=>{let o=new Map,s;try{s=await ft.resolve({fs:e,gitdir:r,ref:n})}catch(f){if(f instanceof Z&&await ft.isUnbornBranch({fs:e,gitdir:r,ref:n}))s="4b825dc642cb6eb9a060e54bf8d69288fbee4904";else throw f}let c=await xr({fs:e,cache:this.cache,gitdir:r,oid:s});return c.type="tree",c.mode="40000",o.set(".",c),o})();let a=this;this.ConstructEntry=class{constructor(s){this._fullpath=s,this._type=!1,this._mode=!1,this._stat=!1,this._content=!1,this._oid=!1}async type(){return a.type(this)}async mode(){return a.mode(this)}async stat(){return a.stat(this)}async content(){return a.content(this)}async oid(){return a.oid(this)}}}async readdir(e){let r=e._fullpath,{fs:n,cache:i,gitdir:a}=this,o=await this.mapPromise,s=o.get(r);if(!s)throw new Error(`No obj for ${r}`);let c=s.oid;if(!c)throw new Error(`No oid for obj ${JSON.stringify(s)}`);if(s.type!=="tree")return null;let{type:f,object:l}=await Ft({fs:n,cache:i,gitdir:a,oid:c});if(f!==s.type)throw new Wt(c,f,s.type);let u=Zt.from(l);for(let d of u)o.set(D(r,d.path),d);return u.entries().map(d=>D(r,d.path))}async type(e){if(e._type===!1){let r=await this.mapPromise,{type:n}=r.get(e._fullpath);e._type=n}return e._type}async mode(e){if(e._mode===!1){let r=await this.mapPromise,{mode:n}=r.get(e._fullpath);e._mode=Su(parseInt(n,8))}return e._mode}async stat(e){}async content(e){if(e._content===!1){let r=await this.mapPromise,{fs:n,cache:i,gitdir:a}=this,s=r.get(e._fullpath).oid,{type:c,object:f}=await Ft({fs:n,cache:i,gitdir:a,oid:s});c!=="blob"?e._content=void 0:e._content=new Uint8Array(f)}return e._content}async oid(e){if(e._oid===!1){let n=(await this.mapPromise).get(e._fullpath);e._oid=n.oid}return e._oid}};function uu({ref:t="HEAD"}={}){let e=Object.create(null);return Object.defineProperty(e,Ru,{value:function({fs:r,gitdir:n,cache:i}){return new Na({fs:r,gitdir:n,ref:t,cache:i})}}),Object.freeze(e),e}function Qm(t,e){let r=e-t;return Array.from({length:r},(n,i)=>t+i)}var tg=typeof Array.prototype.flat>"u"?t=>t.reduce((e,r)=>e.concat(r),[]):t=>t.flat(),Ua=class{constructor(){this.value=null}consider(e){e!=null&&(this.value===null?this.value=e:e<this.value&&(this.value=e))}reset(){this.value=null}};function*eg(t){let e=new Ua,r,n=[],i=t.length;for(let a=0;a<i;a++)n[a]=t[a].next().value,n[a]!==void 0&&e.consider(n[a]);if(e.value!==null)for(;;){let a=[];r=e.value,e.reset();for(let o=0;o<i;o++)n[o]!==void 0&&n[o]===r?(a[o]=n[o],n[o]=t[o].next().value):a[o]=null,n[o]!==void 0&&e.consider(n[o]);if(yield a,e.value===null)return}}async function rg({fs:t,cache:e,dir:r,gitdir:n,trees:i,map:a=async(c,f)=>f,reduce:o=async(c,f)=>{let l=tg(f);return c!==void 0&&l.unshift(c),l},iterate:s=(c,f)=>Promise.all([...f].map(c))}){let c=i.map(p=>p[Ru]({fs:t,dir:r,gitdir:n,cache:e})),f=new Array(c.length).fill("."),l=Qm(0,c.length),u=async p=>{l.forEach(b=>{let E=p[b];p[b]=E&&new c[b].ConstructEntry(E)});let y=(await Promise.all(l.map(b=>{let E=p[b];return E?c[b].readdir(E):[]}))).map(b=>(b===null?[]:b)[Symbol.iterator]());return{entries:p,children:eg(y)}},d=async p=>{let{entries:w,children:y}=await u(p),b=w.find(S=>S&&S._fullpath)._fullpath,E=await a(b,w);if(E!==null){let S=await s(d,y);return S=S.filter(A=>A!==void 0),o(E,S)}},h=await d(f);for(let p of c)p.flush&&await p.flush();return h}async function Cu(t,e,r=10){try{await t(e)}catch(n){if(n===null||n.code==="EEXIST")return;if(n.code!=="ENOENT")throw n;let i=Fe(e);if(i==="."||i==="/"||i===e)throw n;await Cu(t,i,r);for(let a=0;;a++)try{await t(e);return}catch(o){if(o===null||o.code==="EEXIST")return;if(o.code==="ENOENT"&&a<r){await new Promise(s=>setTimeout(s,0));continue}throw o}}}async function ja(t,e){let r=await t.readdir(e);r==null?await t.rm(e):r.length?await Promise.all(r.map(n=>{let i=D(e,n);return t.lstat(i).then(a=>{if(a)return a.isDirectory()?ja(t,i):t.rm(i)})})).then(()=>t.rmdir(e)):await t.rmdir(e)}function ng(t){return ig(t)&&du(t.then)&&du(t.catch)}function ig(t){return t&&typeof t=="object"}function du(t){return typeof t=="function"}function ur(t){let e=t.code;return typeof e!="string"?!1:e==="ENOENT"||e==="ENOTDIR"||e.includes("ENS")}function hu(t){return ng((r=>{try{return r.readFile().catch(n=>n)}catch(n){return n}})(t))}var pu=["readFile","writeFile","mkdir","rmdir","unlink","stat","lstat","readdir","readlink","symlink"];function wu(t,e){if(hu(e))for(let r of pu)t[`_${r}`]=e[r].bind(e);else for(let r of pu)t[`_${r}`]=(0,dr.default)(e[r].bind(e));hu(e)?(e.cp&&(t._cp=e.cp.bind(e)),e.rm?t._rm=e.rm.bind(e):e.rmdir.length>1?t._rm=e.rmdir.bind(e):t._rm=ja.bind(null,t)):(e.cp&&(t._cp=(0,dr.default)(e.cp.bind(e))),e.rm?t._rm=(0,dr.default)(e.rm.bind(e)):e.rmdir.length>2?t._rm=(0,dr.default)(e.rmdir.bind(e)):t._rm=ja.bind(null,t))}var Vt=class{constructor(e){if(typeof e._original_unwrapped_fs<"u")return e;let r=Object.getOwnPropertyDescriptor(e,"promises");r&&r.enumerable?wu(this,e.promises):wu(this,e),this._original_unwrapped_fs=e}async exists(e,r={}){try{return await this._stat(e),!0}catch(n){if(ur(n))return!1;throw console.log('Unhandled error in "FileSystem.exists()" function',n),n}}async read(e,r={}){let n;try{n=await this._readFile(e,r)}catch(i){if(ur(i)||i.code==="EISDIR")return null;throw i}if(n==null)return null;if(r.autocrlf==="true")try{n=new TextDecoder("utf8",{fatal:!0}).decode(n),n=n.replace(/\r\n/g,`
82
82
  `),n=new TextEncoder().encode(n)}catch{}return typeof n!="string"&&(n=Buffer.from(n)),n}async write(e,r,n={}){try{await this._writeFile(e,r,n)}catch{await this.mkdir(Fe(e)),await this._writeFile(e,r,n)}}async mkdir(e){await Cu(this._mkdir,e)}async rm(e){try{await this._unlink(e)}catch(r){if(r.code!=="ENOENT")throw r}}async rmdir(e,r){try{r&&r.recursive?await this._rm(e,r):await this._rmdir(e)}catch(n){if(n.code!=="ENOENT")throw n}}async readdir(e){let r;try{r=await this._readdir(e)}catch(n){if(n.code==="ENOTDIR")return null;if(ur(n))return[];throw n}return r.sort(Ha),r}async readdirDeep(e){let r=await this._readdir(e);return(await Promise.all(r.map(async i=>{let a=e+"/"+i;return(await this._stat(a)).isDirectory()?this.readdirDeep(a):a}))).reduce((i,a)=>i.concat(a),[])}async lstat(e){try{return await this._lstat(e)}catch(r){if(ur(r))return null;throw r}}async readlink(e,r={encoding:"buffer"}){try{let n=await this._readlink(e,r);return Buffer.isBuffer(n)?n:Buffer.from(n)}catch(n){if(ur(n))return null;throw n}}async writelink(e,r){return this._symlink(r.toString("utf8"),e)}};function z(t,e){if(e===void 0)throw new _r(t)}function ag(t){return t.startsWith("/")||/^[a-zA-Z]:[\\/]/.test(t)}async function Ne({fsp:t,dotgit:e}){z("fsp",t),z("dotgit",e);let r=await t._stat(e).catch(()=>({isFile:()=>!1,isDirectory:()=>!1}));return r.isDirectory()?e:r.isFile()?t._readFile(e,"utf8").then(n=>n.trimRight().substr(8)).then(n=>ag(n)?n:D(Fe(e),n)):e}var Ma=class{static async isIgnored({fs:e,dir:r,gitdir:n=D(r,".git"),filepath:i}){if(sa(i)===".git")return!0;if(i===".")return!1;let a="",o=D(n,"info","exclude");await e.exists(o)&&(a=await e.read(o,"utf8"));let s=[{gitignore:D(r,".gitignore"),filepath:i}],c=i.split("/").filter(Boolean);for(let l=1;l<c.length;l++){let u=c.slice(0,l).join("/"),d=c.slice(l).join("/");s.push({gitignore:D(r,u,".gitignore"),filepath:d})}let f=!1;for(let[l,u]of s.entries()){let d=await e.read(u.gitignore,"utf8"),h=(0,Eu.default)();l===0&&h.add(a),h.add(d);let p=Fe(u.filepath);if(p!=="."&&h.ignores(p))return!0;f?f=!h.test(u.filepath).unignored:f=h.test(u.filepath).ignored}return f}};async function og({fs:t,gitdir:e,object:r,format:n,oid:i}){if(n!=="deflated")throw new I("GitObjectStoreLoose expects objects to write to be in deflated format");let a=`objects/${i.slice(0,2)}/${i.slice(2)}`,o=`${e}/${a}`;await t.exists(o)||await t.write(o,r)}var ra=null;async function sg(t){return ra===null&&(ra=fg()),ra?cg(t):Sn.default.deflate(t)}async function cg(t){let e=new CompressionStream("deflate"),r=new Blob([t]).stream().pipeThrough(e);return new Uint8Array(await new Response(r).arrayBuffer())}function fg(){try{return new CompressionStream("deflate").writable.close(),new Blob([]).stream().cancel(),!0}catch{return!1}}async function qa({fs:t,gitdir:e,type:r,object:n,format:i="content",oid:a=void 0,dryRun:o=!1}){return i!=="deflated"&&(i!=="wrapped"&&(n=Pe.wrap({type:r,object:n})),a=await qt(n),n=Buffer.from(await sg(n))),o||await og({fs:t,gitdir:e,object:n,format:"deflated",oid:a}),a}function lg(t){let e;for(;~(e=t.indexOf(92));)t[e]=47;return t}async function Wa({fs:t,dir:e,gitdir:r=D(e,".git"),filepath:n,cache:i={},force:a=!1,parallel:o=!0}){try{z("fs",t),z("dir",e),z("gitdir",r),z("filepath",n);let s=new Vt(t),c=await Ne({fsp:s,dotgit:r});await wn.acquire({fs:s,gitdir:c,cache:i},async f=>{let u=await(await mr.get({fs:s,gitdir:c})).get("core.autocrlf");return La({dir:e,gitdir:c,fs:s,filepath:n,index:f,force:a,parallel:o,autocrlf:u})})}catch(s){throw s.caller="git.add",s}}function ug(t,e){if(t.has({filepath:e}))return!0;let r=`${e}/`;for(let n of t.entriesMap.keys())if(n.startsWith(r))return!0;return!1}async function La({dir:t,gitdir:e,fs:r,filepath:n,index:i,force:a,parallel:o,autocrlf:s}){n=Array.isArray(n)?n:[n];let c=n.map(async d=>{if(!a&&!ug(i,d)&&await Ma.isIgnored({fs:r,dir:t,gitdir:e,filepath:d}))return;let h=await r.lstat(D(t,d));if(!h)throw new Z(d);if(h.isDirectory()){let p=await r.readdir(D(t,d));if(o){let w=p.map(y=>La({dir:t,gitdir:e,fs:r,filepath:[D(d,y)],index:i,force:a,parallel:o,autocrlf:s}));await Promise.all(w)}else for(let w of p)await La({dir:t,gitdir:e,fs:r,filepath:[D(d,w)],index:i,force:a,parallel:o,autocrlf:s})}else{let p=h.isSymbolicLink()?await r.readlink(D(t,d)).then(lg):await r.read(D(t,d),{autocrlf:s});if(p===null)throw new Z(d);let w=await qa({fs:r,gitdir:e,type:"blob",object:p});i.insert({filepath:d,stats:h,oid:w})}}),f=await Promise.allSettled(c),l=f.filter(d=>d.status==="rejected").map(d=>d.reason);if(l.length>1)throw new _n(l);if(l.length===1)throw l[0];return f.filter(d=>d.status==="fulfilled"&&d.value).map(d=>d.value)}async function dg({fs:t,gitdir:e,oid:r}){let n=`objects/${r.slice(0,2)}/${r.slice(2)}`;return t.exists(`${e}/${n}`)}async function hg({fs:t,cache:e,gitdir:r,oid:n,getExternalRefDelta:i}){let a=await t.readdir(D(r,"objects/pack"));a=a.filter(o=>o.endsWith(".idx"));for(let o of a){let s=`${r}/objects/pack/${o}`,c=await Tu({fs:t,cache:e,filename:s,getExternalRefDelta:i});if(c.error)throw new I(c.error);if(c.offsets.has(n))return!0}return!1}async function pg({fs:t,cache:e,gitdir:r,oid:n,format:i="content"}){let a=s=>Ft({fs:t,cache:e,gitdir:r,oid:s}),o=await dg({fs:t,gitdir:r,oid:n});return o||(o=await hg({fs:t,cache:e,gitdir:r,oid:n,getExternalRefDelta:a})),o}async function kn({fs:t,gitdir:e,path:r}){return(await mr.get({fs:t,gitdir:e})).get(r)}function Fu(t,...e){for(let r of e)if(r)for(let n of Object.keys(r)){let i=r[n];i!==void 0&&(t[n]=i)}return t}async function mu({fs:t,gitdir:e,author:r,commit:n}){let i=Math.floor(Date.now()/1e3),a={name:await kn({fs:t,gitdir:e,path:"user.name"}),email:await kn({fs:t,gitdir:e,path:"user.email"})||"",timestamp:i,timezoneOffset:new Date(i*1e3).getTimezoneOffset()},o=Fu({},a,n?n.author:void 0,r);if(o.name!==void 0)return o}async function gu({fs:t,gitdir:e,author:r,committer:n,commit:i}){let a=Math.floor(Date.now()/1e3),o={name:await kn({fs:t,gitdir:e,path:"user.name"}),email:await kn({fs:t,gitdir:e,path:"user.email"})||"",timestamp:a,timezoneOffset:new Date(a*1e3).getTimezoneOffset()},s=Fu({},o,i?i.committer:void 0,r,n);if(s.name!==void 0)return s}async function Pu({fs:t,cache:e,gitdir:r,oid:n}){let{type:i,object:a}=await Ft({fs:t,cache:e,gitdir:r,oid:n});if(i==="tag")return n=vr.from(a).parse().object,Pu({fs:t,cache:e,gitdir:r,oid:n});if(i!=="commit")throw new Wt(n,i,"commit");return{commit:De.from(a),oid:n}}async function Ga({fs:t,cache:e,gitdir:r,oid:n}){let{commit:i,oid:a}=await Pu({fs:t,cache:e,gitdir:r,oid:n});return{oid:a,commit:i.parse(),payload:i.withoutSignature()}}var wg="4b825dc642cb6eb9a060e54bf8d69288fbee4904";async function mg({fs:t,cache:e,onSign:r,gitdir:n,message:i,author:a,committer:o,signingKey:s,amend:c=!1,dryRun:f=!1,noUpdateBranch:l=!1,disallowEmpty:u=!1,ref:d,parent:h,tree:p}){let w=!1,y=!1;d||(y=!(await t.read(`${n}/HEAD`,{encoding:"utf8"})).startsWith("ref:"),d=await ft.resolve({fs:t,gitdir:n,ref:"HEAD",depth:2}));let b,E;try{b=await ft.resolve({fs:t,gitdir:n,ref:d})}catch(m){if(!(m instanceof Z))throw m;w=!0}if(!w&&(c||u)&&(E=await Ga({fs:t,gitdir:n,oid:b,cache:e})),c&&w)throw new xn(d);let S=c?await mu({fs:t,gitdir:n,author:a,commit:E.commit}):await mu({fs:t,gitdir:n,author:a});if(!S)throw new br("author");let A=c?await gu({fs:t,gitdir:n,author:S,committer:o,commit:E.commit}):await gu({fs:t,gitdir:n,author:S,committer:o});if(!A)throw new br("committer");return wn.acquire({fs:t,gitdir:n,cache:e,allowUnmerged:!1},async function(m){let g=um(m.entries.filter(R=>!R.flags.intentToAdd)).get(".");if(p||(p=await Du({fs:t,gitdir:n,inode:g,dryRun:f})),h?h=await Promise.all(h.map(async R=>{let k=await ft.resolve({fs:t,gitdir:n,ref:R});for(;await pg({fs:t,cache:e,gitdir:n,oid:k});){let{type:B,object:N}=await Ft({fs:t,cache:e,gitdir:n,oid:k});if(B==="commit")break;if(B!=="tag")throw new Wt(k,B,"commit");k=vr.from(N).parse().object}return k})):c?h=E.commit.parent:h=b?[b]:[],u&&!c&&(w&&p===wg||!w&&p===E.commit.tree))throw new bn;if(!i)if(c)i=E.commit.message;else throw new _r("message");let x=De.from({tree:p,parent:h,author:S,committer:A,message:i});s&&(x=await De.sign(x,r,s));let _=await qa({fs:t,gitdir:n,type:"commit",object:x.toObject(),dryRun:f});return!l&&!f&&await ft.writeRef({fs:t,gitdir:n,ref:y?"HEAD":d,value:_}),_})}async function Du({fs:t,gitdir:e,inode:r,dryRun:n}){let i=r.children;for(let c of i)c.type==="tree"&&(c.metadata.mode="040000",c.metadata.oid=await Du({fs:t,gitdir:e,inode:c,dryRun:n}));let a=i.map(c=>({mode:c.metadata.mode,path:c.basename,oid:c.metadata.oid,type:c.type})),o=Zt.from(a);return await qa({fs:t,gitdir:e,type:"tree",object:o.toObject(),dryRun:n})}async function gg({fs:t,cache:e,gitdir:r,oid:n,filepath:i}){if(i.startsWith("/"))throw new yr("leading-slash");if(i.endsWith("/"))throw new yr("trailing-slash");let a=n,o=await xr({fs:t,cache:e,gitdir:r,oid:n}),s=o.tree;if(i==="")return{mode:"040000",oid:o.oid,path:"",type:"tree"};{let c=i.split("/");return Nu({fs:t,cache:e,gitdir:r,tree:s,pathArray:c,oid:a,filepath:i})}}async function Nu({fs:t,cache:e,gitdir:r,tree:n,pathArray:i,oid:a,filepath:o}){let s=i.shift();for(let c of n)if(c.path===s){if(i.length===0)return c;{let{type:f,object:l}=await Ft({fs:t,cache:e,gitdir:r,oid:c.oid});if(f!=="tree")throw new Wt(a,f,"tree",o);return n=Zt.from(l),Nu({fs:t,cache:e,gitdir:r,tree:n,pathArray:i,oid:a,filepath:o})}}throw new Z(`file or directory found at "${a}:${o}"`)}var yg=/^refs\/(heads\/|tags\/|remotes\/)?(.*)/;function bg(t){let e=yg.exec(t);return e?e[1]==="remotes/"&&t.endsWith("/HEAD")?e[2].slice(0,-5):e[2]:t}async function _g({fs:t,gitdir:e,fullname:r=!1,test:n=!1}){let i=await ft.resolve({fs:t,gitdir:e,ref:"HEAD",depth:2});if(n)try{await ft.resolve({fs:t,gitdir:e,ref:i})}catch(a){if(a instanceof Z)return;throw a}if(i.startsWith("refs/"))return r?i:bg(i)}var za=class{static async read({fs:e,gitdir:r}){let n=D(r,"shallow"),i=new Set;return await st(n,async function(){let a=await e.read(n,{encoding:"utf8"});if(a===null||a.trim()==="")return i;a.trim().split(`
83
83
  `).map(o=>i.add(o))}),i}static async write({fs:e,gitdir:r,oids:n}){let i=D(r,"shallow");if(n.size>0){let a=[...n].join(`
84
84
  `)+`
@@ -90,12 +90,12 @@ gpgsig`+ea(o)+`
90
90
  `)+` symlinks = false
91
91
  ignorecase = true
92
92
  `),await t.write(n+"/HEAD",`ref: refs/heads/${i}
93
- `)}async function Za({fs:t,onSign:e,dir:r,gitdir:n=D(r,".git"),message:i,author:a,committer:o,signingKey:s,amend:c=!1,dryRun:f=!1,noUpdateBranch:l=!1,disallowEmpty:u=!1,ref:d,parent:h,tree:p,cache:w={}}){try{z("fs",t),c||z("message",i),s&&z("onSign",e);let y=new Vt(t),b=await Ne({fsp:y,dotgit:n});return await mg({fs:y,cache:w,onSign:e,gitdir:b,message:i,author:a,committer:o,signingKey:s,amend:c,dryRun:f,noUpdateBranch:l,disallowEmpty:u,ref:d,parent:h,tree:p})}catch(y){throw y.caller="git.commit",y}}async function Va({fs:t,dir:e,gitdir:r=D(e,".git"),fullname:n=!1,test:i=!1}){try{z("fs",t),z("gitdir",r);let a=new Vt(t),o=await Ne({fsp:a,dotgit:r});return await _g({fs:a,gitdir:o,fullname:n,test:i})}catch(a){throw a.caller="git.currentBranch",a}}async function Xa({fs:t,bare:e=!1,dir:r,gitdir:n=e?r:D(r,".git"),defaultBranch:i="master"}){try{z("fs",t),z("gitdir",n),e||z("dir",r);let a=new Vt(t),o=await Ne({fsp:a,dotgit:n});return await vg({fs:a,bare:e,dir:r,gitdir:o,defaultBranch:i})}catch(a){throw a.caller="git.init",a}}async function Ya({fs:t,dir:e,gitdir:r=D(e,".git"),remote:n}){try{z("fs",t),z("gitdir",r);let i=new Vt(t),a=await Ne({fsp:i,dotgit:r});return ft.listBranches({fs:i,gitdir:a,remote:n})}catch(i){throw i.caller="git.listBranches",i}}function xg(t,e){return t.committer.timestamp-e.committer.timestamp}var Eg="e69de29bb2d1d6434b8b29ae775ad8c2e48c5391";async function yu({fs:t,cache:e,gitdir:r,oid:n,fileId:i}){if(i===Eg)return;let a=n,o,s=await xr({fs:t,cache:e,gitdir:r,oid:n}),c=s.tree;return i===s.oid?o=s.path:(o=await Uu({fs:t,cache:e,gitdir:r,tree:c,fileId:i,oid:a}),Array.isArray(o)&&(o.length===0?o=void 0:o.length===1&&(o=o[0]))),o}async function Uu({fs:t,cache:e,gitdir:r,tree:n,fileId:i,oid:a,filepaths:o=[],parentPath:s=""}){let c=n.entries().map(function(f){let l;return f.oid===i?(l=D(s,f.path),o.push(l)):f.type==="tree"&&(l=Ft({fs:t,cache:e,gitdir:r,oid:f.oid}).then(function({object:u}){return Uu({fs:t,cache:e,gitdir:r,tree:Zt.from(u),fileId:i,oid:a,filepaths:o,parentPath:D(s,f.path)})})),l});return await Promise.all(c),o}async function kg({fs:t,cache:e,gitdir:r,filepath:n,ref:i,depth:a,since:o,author:s,force:c,follow:f,includeChanges:l}){let u=typeof o>"u"?void 0:Math.floor(o.valueOf()/1e3),d=s==null?void 0:new RegExp(s,"i"),h=({commit:x})=>d===void 0?!0:x.author?d.test(`${x.author.name} <${x.author.email}>`):!1,p=[],w=x=>{h(x)&&p.push(x)},y=await za.read({fs:t,gitdir:r}),b=await ft.resolve({fs:t,gitdir:r,ref:i}),E=[await Ga({fs:t,cache:e,gitdir:r,oid:b})],S,A,m,$;function g(x){$&&n&&w(x)}for(;E.length>0;){let x=E.pop();if(u!==void 0&&x.commit.committer.timestamp<=u)break;if(n){let _;try{_=await gg({fs:t,cache:e,gitdir:r,oid:x.commit.tree,filepath:n}),m&&(S!==_.oid||A!==_.mode)&&w(m),S=_.oid,A=_.mode,m=x,$=!0}catch(R){if(R instanceof Z){let k=f&&S;if(k&&(k=await yu({fs:t,cache:e,gitdir:r,oid:x.commit.tree,fileId:S}),k))if(Array.isArray(k)){if(m){let B=await yu({fs:t,cache:e,gitdir:r,oid:m.commit.tree,fileId:S});if(Array.isArray(B))if(k=k.filter(N=>B.indexOf(N)===-1),k.length===1)k=k[0],n=k,m&&w(m);else{k=!1,m&&w(m);break}}}else n=k,m&&w(m);if(!k){if($&&S&&(w(m),!c))break;if(!c&&!f)throw R}m=x,$=!1}else throw R}}else w(x);if(a!==void 0&&p.length===a){g(x);break}if(!y.has(x.oid))for(let _ of x.commit.parent){let R=await Ga({fs:t,cache:e,gitdir:r,oid:_});E.map(k=>k.oid).includes(R.oid)||E.push(R)}E.length===0&&g(x),E.sort((_,R)=>xg(_.commit,R.commit))}if(l)for(let x of p)x.commit.changes=await Sg({fs:t,cache:e,gitdir:r,commit:x,shallow:y.has(x.oid)});return p}async function Sg({fs:t,cache:e,gitdir:r,commit:n,shallow:i}){let a=i||!n.commit.parent[0]?"4b825dc642cb6eb9a060e54bf8d69288fbee4904":n.commit.parent[0];return rg({fs:t,cache:e,gitdir:r,trees:[uu({ref:n.oid}),uu({ref:a})],map:async(o,[s,c])=>{let[f,l]=await Promise.all([s&&s.type(),c&&c.type()]);if(f==="tree")return l&&l!=="tree"?[null,await c.oid(),o]:void 0;if(l==="tree")return f?[await s.oid(),null,o]:void 0;let[u,d]=await Promise.all([s?s.oid():null,c?c.oid():null]);if(u!==d)return[u,d,o]}})}async function Ka({fs:t,dir:e,gitdir:r=D(e,".git"),filepath:n,ref:i="HEAD",depth:a,since:o,author:s,force:c,follow:f,includeChanges:l=!1,cache:u={}}){try{z("fs",t),z("gitdir",r),z("ref",i);let d=new Vt(t),h=await Ne({fsp:d,dotgit:r});return await kg({fs:d,cache:u,gitdir:h,filepath:n,ref:i,depth:a,since:o,author:s,force:c,follow:f,includeChanges:l})}catch(d){throw d.caller="git.log",d}}if(typeof globalThis<"u"){let t=globalThis;typeof t.Buffer>"u"&&(t.Buffer=ju.Buffer)}function Sr(t){let e=3735928559^t.length,r=1103547991^t.length;for(let i=0;i<t.length;i++){let a=t.charCodeAt(i);e=Math.imul(e^a,2654435761),r=Math.imul(r^a,1597334677)}return e=Math.imul(e^e>>>16,2246822507)^Math.imul(r^r>>>13,3266489909),r=Math.imul(r^r>>>16,2246822507)^Math.imul(e^e>>>13,3266489909),(4294967296*(2097151&r)+(e>>>0)).toString(16).padStart(7,"0").slice(0,7)}function Qa(t){if(!t||typeof t!="string")return[];let e=[];for(let r of t.split(/\r?\n/)){let n=r.trim();if(!n||n.startsWith("#"))continue;let i=!1;if(n.startsWith("!")&&(i=!0,n=n.slice(1).trim(),!n))continue;let a=n.endsWith("/");a&&(n=n.replace(/\/+$/,""));let o=n.startsWith("/");if(o&&(n=n.replace(/^\/+/,"")),!n)continue;let s=n.includes("/"),c="";for(let u=0;u<n.length;u++){let d=n[u];d==="*"?n[u+1]==="*"?n[u+2]==="/"?(c+="(?:.+/)?",u+=2):(c+=".*",u+=1):c+="[^/]*":d==="?"?c+="[^/]":"\\^$.|+()[]{}".includes(d)?c+=`\\${d}`:c+=d}let f=o||s?"^":"(?:^|/)",l=a?"(?:/|$)":"(?:$|/)";try{e.push({negated:i,dirOnly:a,regex:new RegExp(`${f}${c}${l}`)})}catch(u){let d=u}}return e}function to(t,e){if(!e.length)return!1;let r=!1;for(let n of e)n.regex.test(t)&&(r=!n.negated);return r}function V(t,e){return!t||t===".git"||t.startsWith(".git/")||t.includes("/.git/")||t.endsWith("/.git")||t==="node_modules"||t.startsWith("node_modules/")||t.includes("/node_modules/")||t.endsWith("/node_modules")?!0:e&&e.length>0&&t!==".gitignore"?to(t,e):!1}function X(t,e="/workspace"){if(typeof t!="string")return"";let r=t.trim().replace(/\\/g,"/");if(!r)return"";let n=(e||"/workspace").replace(/\\/g,"/").replace(/\/+$/,"")||"/";if(r===n)return"";for(n!=="/"&&r.startsWith(`${n}/`)?r=r.slice(n.length+1):r.startsWith("/workspace/")&&n==="/workspace"?r=r.slice(11):r.startsWith("/")&&n!=="/"&&(r.startsWith(`${n}/`)||(r=r.replace(/^\/+/,"")));r.startsWith("./");)r=r.slice(2);r.startsWith("/")&&(r=r.replace(/^\/+/,""));let i=[];for(let a of r.split("/"))if(!(!a||a===".")){if(a===".."){if(i.length===0)return"";i.pop();continue}i.push(a)}return i.join("/")}function Mu(t,e,r="/workspace"){let n;if(t&&typeof t=="object")if(typeof t[".gitignore"]=="string")n=t[".gitignore"];else{let i=`${r.replace(/\/+$/,"")}/.gitignore`;typeof t[i]=="string"&&(n=t[i])}return n===void 0&&e&&typeof e[".gitignore"]=="string"&&(n=e[".gitignore"]),Qa(n)}function U(t,e="/workspace",r,n){let i={};if(!t||typeof t!="object")return i;for(let[a,o]of Object.entries(t)){let s=X(a,e);!s||V(s)||!(n&&Object.prototype.hasOwnProperty.call(n,s))&&r&&V(s,r)||(i[s]=String(o??""))}return i}function $n(t){return(!Array.isArray(t?.commits)||t.commits.length===0)&&!t?.headCommit}function je(t,e,r,n){if(!e||V(e))return!1;let i=t?.repoRoot||"/workspace",a=n??U(t?.headFiles||t?.headSnapshot||{},i),o=Object.prototype.hasOwnProperty.call(a,e),s=r==null?null:String(r);return s===null?o:!o||$n(t)?!0:s!==a[e]}function Pt(t,e,r,n,i){let a=t?.repoRoot||"/workspace",o=X(r,a);if(!o||V(o))return;let s=n==null?null:String(n);je(t,o,s,i)?e.set(o,s):e.delete(o)}function Er(t,e,r){let n=t?.repoRoot||"/workspace",i=r??U(t?.headFiles||t?.headSnapshot||{},n);for(let[a,o]of Array.from(e.entries())){let s=X(a,n);if(s!==a&&e.delete(a),!s||V(s)){e.delete(a);continue}let c=o==null?null:String(o);je(t,s,c,i)?e.set(s,c):e.delete(s)}}function Ue(t,e,r){return typeof t.add!="function"&&Object.defineProperty(t,"add",{value:i=>{let a=e?.repoRoot||"/workspace",o=X(i,a);if(o&&!V(o)){let s=r?r(o):null;Pt(e,t,o,s)}return t},enumerable:!1,configurable:!0,writable:!0}),t}function lt(t,e){let r=t.repoRoot||"/workspace",n=e!==void 0?e:t.headFiles||t.headSnapshot||{},i=U(n,r);return t.headFiles=i,t.headSnapshot=i,i}function kr(t,e){if(t.branches instanceof Set){e&&t.branches.add(e);return}if(Array.isArray(t.branches)){e&&!t.branches.includes(e)&&t.branches.push(e);return}t.branches=e?[e]:[t.branch||"main"]}function rt(t,e=t.branch){if(!t||!e)return;(!t.branchHeads||typeof t.branchHeads!="object")&&(t.branchHeads={});let r=t.repoRoot||"/workspace",n=U(t.headFiles||t.headSnapshot||{},r),i=Array.isArray(t.commits)?t.commits.map(a=>({...a,...a.files?{files:{...a.files}}:{}})):[];t.branchHeads[e]={headCommit:t.headCommit||"",headFiles:n,commits:i}}function pt(t,e){let r=t.repoRoot||"/workspace",n=U(t.headFiles||t.headSnapshot||{},r),i=o=>e?Object.prototype.hasOwnProperty.call(e,o)?e[o]:null:Object.prototype.hasOwnProperty.call(n,o)?n[o]:null;if(t.staged instanceof Map){let o=Ue(t.staged,t,i);return Er(t,o,n),t.stagedFiles=o,o}let a=Ue(new Map,t,i);if(t.staged instanceof Set)for(let o of t.staged.values()){let s=X(o,r);!s||V(s)||Pt(t,a,s,i(s),n)}return t.staged=a,t.stagedFiles=a,a}function Ar(t={},e="main",r){let n=r?.repoRoot||"/workspace",i=r?.initialized!==!1,a=i,o=n,s=i?U(t,n):{},c=i?Sr(JSON.stringify(s)+":init"):"",f=Date.now(),l=i?[{hash:c,message:"Initial commit",timestamp:f,author:"CodeLab Developer <dev@codelab.internal>",date:new Date(f).toUTCString(),files:{...s}}]:[],u={branch:e,branches:[e],branchHeads:i?{[e]:{headCommit:c,headFiles:{...s},commits:l.map(p=>({...p,files:{...s}}))}}:{},tags:{},stashes:[],remoteUrl:null,remotes:{}},d=p=>Object.prototype.hasOwnProperty.call(s,p)?s[p]:null,h=Ue(new Map,u,d);return Object.defineProperties(u,{initialized:{enumerable:!0,configurable:!0,get(){return a},set(p){a=!!p}},repoRoot:{enumerable:!0,configurable:!0,get(){return o},set(p){o=String(p||"/workspace")}},headCommit:{enumerable:!0,configurable:!0,get(){return c},set(p){c=String(p||"")}},headFiles:{enumerable:!0,configurable:!0,get(){return s},set(p){s=p&&typeof p=="object"?p:{}}},headSnapshot:{enumerable:!0,configurable:!0,get(){return s},set(p){s=p&&typeof p=="object"?p:{}}},staged:{enumerable:!0,configurable:!0,get(){return h},set(p){if(p instanceof Map)h=Ue(p,u,d),Er(u,h);else{let w=Ue(new Map,u,d);if(p instanceof Set)for(let y of p.values()){let b=X(y,o);!b||V(b)||Pt(u,w,b,d(b))}h=w}}},stagedFiles:{enumerable:!0,configurable:!0,get(){return h},set(p){p instanceof Map&&(h=Ue(p,u,d),Er(u,h))}},commits:{enumerable:!0,configurable:!0,get(){return l},set(p){l=Array.isArray(p)?p:[],l.length>0&&l[0]?.hash?c=l[0].hash:l.length===0&&(c="")}}}),u}function ce(t,e){let r={};if(!t||typeof t.existsSync!="function"||typeof t.readdirSync!="function"||typeof t.statSync!="function"||typeof t.readFileSync!="function")return r;let n=e.replace(/\/+$/,"")||"/";if(!t.existsSync(n))return r;let i=a=>{let o=[];try{o=t.readdirSync?t.readdirSync(a):[]}catch(s){let c=s;return}for(let s of o){if(s===".git"||s==="node_modules")continue;let c=a==="/"?`/${s}`:`${a}/${s}`;try{let f=t.statSync?t.statSync(c):null;if(f&&f.isDirectory())i(c);else{let l=X(c,n);if(!l||V(l))continue;let u=t.readFileSync?t.readFileSync(c,"utf8"):"";r[l]=typeof u=="string"?u:new TextDecoder().decode(u)}}catch(f){let l=f}}};return i(n),r}function Ja(t){return!!(t&&typeof t=="object")&&("vfs"in t||"gitState"in t||"cwd"in t&&!("headFiles"in t))}function Lu(t,e){if(Ja(t)){let a=(e?.repoRoot||t.gitState?.repoRoot||t.cwd||"/workspace").replace(/\/+$/,"")||"/",o=e?.branch||t.gitState?.branch||"main",s=t.vfs??null;if(s){let l=a==="/"?"/.git":`${a}/.git`,u=`${l}/HEAD`,d=`${l}/config`;typeof s.mkdirSync=="function"&&(!s.existsSync||!s.existsSync(l))&&s.mkdirSync(l,{recursive:!0}),s.writeFileSync?.(u,`ref: refs/heads/${o}
93
+ `)}async function Za({fs:t,onSign:e,dir:r,gitdir:n=D(r,".git"),message:i,author:a,committer:o,signingKey:s,amend:c=!1,dryRun:f=!1,noUpdateBranch:l=!1,disallowEmpty:u=!1,ref:d,parent:h,tree:p,cache:w={}}){try{z("fs",t),c||z("message",i),s&&z("onSign",e);let y=new Vt(t),b=await Ne({fsp:y,dotgit:n});return await mg({fs:y,cache:w,onSign:e,gitdir:b,message:i,author:a,committer:o,signingKey:s,amend:c,dryRun:f,noUpdateBranch:l,disallowEmpty:u,ref:d,parent:h,tree:p})}catch(y){throw y.caller="git.commit",y}}async function Va({fs:t,dir:e,gitdir:r=D(e,".git"),fullname:n=!1,test:i=!1}){try{z("fs",t),z("gitdir",r);let a=new Vt(t),o=await Ne({fsp:a,dotgit:r});return await _g({fs:a,gitdir:o,fullname:n,test:i})}catch(a){throw a.caller="git.currentBranch",a}}async function Xa({fs:t,bare:e=!1,dir:r,gitdir:n=e?r:D(r,".git"),defaultBranch:i="master"}){try{z("fs",t),z("gitdir",n),e||z("dir",r);let a=new Vt(t),o=await Ne({fsp:a,dotgit:n});return await vg({fs:a,bare:e,dir:r,gitdir:o,defaultBranch:i})}catch(a){throw a.caller="git.init",a}}async function Ya({fs:t,dir:e,gitdir:r=D(e,".git"),remote:n}){try{z("fs",t),z("gitdir",r);let i=new Vt(t),a=await Ne({fsp:i,dotgit:r});return ft.listBranches({fs:i,gitdir:a,remote:n})}catch(i){throw i.caller="git.listBranches",i}}function xg(t,e){return t.committer.timestamp-e.committer.timestamp}var Eg="e69de29bb2d1d6434b8b29ae775ad8c2e48c5391";async function yu({fs:t,cache:e,gitdir:r,oid:n,fileId:i}){if(i===Eg)return;let a=n,o,s=await xr({fs:t,cache:e,gitdir:r,oid:n}),c=s.tree;return i===s.oid?o=s.path:(o=await Uu({fs:t,cache:e,gitdir:r,tree:c,fileId:i,oid:a}),Array.isArray(o)&&(o.length===0?o=void 0:o.length===1&&(o=o[0]))),o}async function Uu({fs:t,cache:e,gitdir:r,tree:n,fileId:i,oid:a,filepaths:o=[],parentPath:s=""}){let c=n.entries().map(function(f){let l;return f.oid===i?(l=D(s,f.path),o.push(l)):f.type==="tree"&&(l=Ft({fs:t,cache:e,gitdir:r,oid:f.oid}).then(function({object:u}){return Uu({fs:t,cache:e,gitdir:r,tree:Zt.from(u),fileId:i,oid:a,filepaths:o,parentPath:D(s,f.path)})})),l});return await Promise.all(c),o}async function kg({fs:t,cache:e,gitdir:r,filepath:n,ref:i,depth:a,since:o,author:s,force:c,follow:f,includeChanges:l}){let u=typeof o>"u"?void 0:Math.floor(o.valueOf()/1e3),d=s==null?void 0:new RegExp(s,"i"),h=({commit:x})=>d===void 0?!0:x.author?d.test(`${x.author.name} <${x.author.email}>`):!1,p=[],w=x=>{h(x)&&p.push(x)},y=await za.read({fs:t,gitdir:r}),b=await ft.resolve({fs:t,gitdir:r,ref:i}),E=[await Ga({fs:t,cache:e,gitdir:r,oid:b})],S,A,m,$;function g(x){$&&n&&w(x)}for(;E.length>0;){let x=E.pop();if(u!==void 0&&x.commit.committer.timestamp<=u)break;if(n){let _;try{_=await gg({fs:t,cache:e,gitdir:r,oid:x.commit.tree,filepath:n}),m&&(S!==_.oid||A!==_.mode)&&w(m),S=_.oid,A=_.mode,m=x,$=!0}catch(R){if(R instanceof Z){let k=f&&S;if(k&&(k=await yu({fs:t,cache:e,gitdir:r,oid:x.commit.tree,fileId:S}),k))if(Array.isArray(k)){if(m){let B=await yu({fs:t,cache:e,gitdir:r,oid:m.commit.tree,fileId:S});if(Array.isArray(B))if(k=k.filter(N=>B.indexOf(N)===-1),k.length===1)k=k[0],n=k,m&&w(m);else{k=!1,m&&w(m);break}}}else n=k,m&&w(m);if(!k){if($&&S&&(w(m),!c))break;if(!c&&!f)throw R}m=x,$=!1}else throw R}}else w(x);if(a!==void 0&&p.length===a){g(x);break}if(!y.has(x.oid))for(let _ of x.commit.parent){let R=await Ga({fs:t,cache:e,gitdir:r,oid:_});E.map(k=>k.oid).includes(R.oid)||E.push(R)}E.length===0&&g(x),E.sort((_,R)=>xg(_.commit,R.commit))}if(l)for(let x of p)x.commit.changes=await Sg({fs:t,cache:e,gitdir:r,commit:x,shallow:y.has(x.oid)});return p}async function Sg({fs:t,cache:e,gitdir:r,commit:n,shallow:i}){let a=i||!n.commit.parent[0]?"4b825dc642cb6eb9a060e54bf8d69288fbee4904":n.commit.parent[0];return rg({fs:t,cache:e,gitdir:r,trees:[uu({ref:n.oid}),uu({ref:a})],map:async(o,[s,c])=>{let[f,l]=await Promise.all([s&&s.type(),c&&c.type()]);if(f==="tree")return l&&l!=="tree"?[null,await c.oid(),o]:void 0;if(l==="tree")return f?[await s.oid(),null,o]:void 0;let[u,d]=await Promise.all([s?s.oid():null,c?c.oid():null]);if(u!==d)return[u,d,o]}})}async function Ka({fs:t,dir:e,gitdir:r=D(e,".git"),filepath:n,ref:i="HEAD",depth:a,since:o,author:s,force:c,follow:f,includeChanges:l=!1,cache:u={}}){try{z("fs",t),z("gitdir",r),z("ref",i);let d=new Vt(t),h=await Ne({fsp:d,dotgit:r});return await kg({fs:d,cache:u,gitdir:h,filepath:n,ref:i,depth:a,since:o,author:s,force:c,follow:f,includeChanges:l})}catch(d){throw d.caller="git.log",d}}if(typeof globalThis<"u"){let t=globalThis;typeof t.Buffer>"u"&&(t.Buffer=ju.Buffer)}function Sr(t){let e=3735928559^t.length,r=1103547991^t.length;for(let i=0;i<t.length;i++){let a=t.charCodeAt(i);e=Math.imul(e^a,2654435761),r=Math.imul(r^a,1597334677)}return e=Math.imul(e^e>>>16,2246822507)^Math.imul(r^r>>>13,3266489909),r=Math.imul(r^r>>>16,2246822507)^Math.imul(e^e>>>13,3266489909),(4294967296*(2097151&r)+(e>>>0)).toString(16).padStart(7,"0").slice(0,7)}function Qa(t){if(!t||typeof t!="string")return[];let e=[];for(let r of t.split(/\r?\n/)){let n=r.trim();if(!n||n.startsWith("#"))continue;let i=!1;if(n.startsWith("!")&&(i=!0,n=n.slice(1).trim(),!n))continue;let a=n.endsWith("/");a&&(n=n.replace(/\/+$/,""));let o=n.startsWith("/");if(o&&(n=n.replace(/^\/+/,"")),!n)continue;let s=n.includes("/"),c="";for(let u=0;u<n.length;u++){let d=n[u];d==="*"?n[u+1]==="*"?n[u+2]==="/"?(c+="(?:.+/)?",u+=2):(c+=".*",u+=1):c+="[^/]*":d==="?"?c+="[^/]":"\\^$.|+()[]{}".includes(d)?c+=`\\${d}`:c+=d}let f=o||s?"^":"(?:^|/)",l=a?"(?:/|$)":"(?:$|/)";try{e.push({negated:i,dirOnly:a,regex:new RegExp(`${f}${c}${l}`)})}catch(u){let d=u}}return e}function to(t,e){if(!e.length)return!1;let r=!1;for(let n of e)n.regex.test(t)&&(r=!n.negated);return r}function V(t,e){return!t||t===".git"||t.startsWith(".git/")||t.includes("/.git/")||t.endsWith("/.git")||t==="node_modules"||t.startsWith("node_modules/")||t.includes("/node_modules/")||t.endsWith("/node_modules")?!0:e&&e.length>0&&t!==".gitignore"?to(t,e):!1}function X(t,e="/workspace"){if(typeof t!="string")return"";let r=t.trim().replace(/\\/g,"/");if(!r)return"";let n=(e||"/workspace").replace(/\\/g,"/").replace(/\/+$/,"")||"/";if(r===n)return"";for(n!=="/"&&r.startsWith(`${n}/`)?r=r.slice(n.length+1):r.startsWith("/workspace/")&&n==="/workspace"?r=r.slice(11):r.startsWith("/")&&n!=="/"&&(r.startsWith(`${n}/`)||(r=r.replace(/^\/+/,"")));r.startsWith("./");)r=r.slice(2);r.startsWith("/")&&(r=r.replace(/^\/+/,""));let i=[];for(let a of r.split("/"))if(!(!a||a===".")){if(a===".."){if(i.length===0)return"";i.pop();continue}i.push(a)}return i.join("/")}function Mu(t,e,r="/workspace"){let n;if(t&&typeof t=="object")if(typeof t[".gitignore"]=="string")n=t[".gitignore"];else{let i=`${r.replace(/\/+$/,"")}/.gitignore`;typeof t[i]=="string"&&(n=t[i])}return n===void 0&&e&&typeof e[".gitignore"]=="string"&&(n=e[".gitignore"]),Qa(n)}function U(t,e="/workspace",r,n){let i={};if(!t||typeof t!="object")return i;for(let[a,o]of Object.entries(t)){let s=X(a,e);!s||V(s)||!(n&&Object.prototype.hasOwnProperty.call(n,s))&&r&&V(s,r)||(i[s]=String(o??""))}return i}function Rn(t){return(!Array.isArray(t?.commits)||t.commits.length===0)&&!t?.headCommit}function je(t,e,r,n){if(!e||V(e))return!1;let i=t?.repoRoot||"/workspace",a=n??U(t?.headFiles||t?.headSnapshot||{},i),o=Object.prototype.hasOwnProperty.call(a,e),s=r==null?null:String(r);return s===null?o:!o||Rn(t)?!0:s!==a[e]}function Pt(t,e,r,n,i){let a=t?.repoRoot||"/workspace",o=X(r,a);if(!o||V(o))return;let s=n==null?null:String(n);je(t,o,s,i)?e.set(o,s):e.delete(o)}function Er(t,e,r){let n=t?.repoRoot||"/workspace",i=r??U(t?.headFiles||t?.headSnapshot||{},n);for(let[a,o]of Array.from(e.entries())){let s=X(a,n);if(s!==a&&e.delete(a),!s||V(s)){e.delete(a);continue}let c=o==null?null:String(o);je(t,s,c,i)?e.set(s,c):e.delete(s)}}function Ue(t,e,r){return typeof t.add!="function"&&Object.defineProperty(t,"add",{value:i=>{let a=e?.repoRoot||"/workspace",o=X(i,a);if(o&&!V(o)){let s=r?r(o):null;Pt(e,t,o,s)}return t},enumerable:!1,configurable:!0,writable:!0}),t}function lt(t,e){let r=t.repoRoot||"/workspace",n=e!==void 0?e:t.headFiles||t.headSnapshot||{},i=U(n,r);return t.headFiles=i,t.headSnapshot=i,i}function kr(t,e){if(t.branches instanceof Set){e&&t.branches.add(e);return}if(Array.isArray(t.branches)){e&&!t.branches.includes(e)&&t.branches.push(e);return}t.branches=e?[e]:[t.branch||"main"]}function rt(t,e=t.branch){if(!t||!e)return;(!t.branchHeads||typeof t.branchHeads!="object")&&(t.branchHeads={});let r=t.repoRoot||"/workspace",n=U(t.headFiles||t.headSnapshot||{},r),i=Array.isArray(t.commits)?t.commits.map(a=>({...a,...a.files?{files:{...a.files}}:{}})):[];t.branchHeads[e]={headCommit:t.headCommit||"",headFiles:n,commits:i}}function pt(t,e){let r=t.repoRoot||"/workspace",n=U(t.headFiles||t.headSnapshot||{},r),i=o=>e?Object.prototype.hasOwnProperty.call(e,o)?e[o]:null:Object.prototype.hasOwnProperty.call(n,o)?n[o]:null;if(t.staged instanceof Map){let o=Ue(t.staged,t,i);return Er(t,o,n),t.stagedFiles=o,o}let a=Ue(new Map,t,i);if(t.staged instanceof Set)for(let o of t.staged.values()){let s=X(o,r);!s||V(s)||Pt(t,a,s,i(s),n)}return t.staged=a,t.stagedFiles=a,a}function Ar(t={},e="main",r){let n=r?.repoRoot||"/workspace",i=r?.initialized!==!1,a=i,o=n,s=i?U(t,n):{},c=i?Sr(JSON.stringify(s)+":init"):"",f=Date.now(),l=i?[{hash:c,message:"Initial commit",timestamp:f,author:"CodeLab Developer <dev@codelab.internal>",date:new Date(f).toUTCString(),files:{...s}}]:[],u={branch:e,branches:[e],branchHeads:i?{[e]:{headCommit:c,headFiles:{...s},commits:l.map(p=>({...p,files:{...s}}))}}:{},tags:{},stashes:[],remoteUrl:null,remotes:{}},d=p=>Object.prototype.hasOwnProperty.call(s,p)?s[p]:null,h=Ue(new Map,u,d);return Object.defineProperties(u,{initialized:{enumerable:!0,configurable:!0,get(){return a},set(p){a=!!p}},repoRoot:{enumerable:!0,configurable:!0,get(){return o},set(p){o=String(p||"/workspace")}},headCommit:{enumerable:!0,configurable:!0,get(){return c},set(p){c=String(p||"")}},headFiles:{enumerable:!0,configurable:!0,get(){return s},set(p){s=p&&typeof p=="object"?p:{}}},headSnapshot:{enumerable:!0,configurable:!0,get(){return s},set(p){s=p&&typeof p=="object"?p:{}}},staged:{enumerable:!0,configurable:!0,get(){return h},set(p){if(p instanceof Map)h=Ue(p,u,d),Er(u,h);else{let w=Ue(new Map,u,d);if(p instanceof Set)for(let y of p.values()){let b=X(y,o);!b||V(b)||Pt(u,w,b,d(b))}h=w}}},stagedFiles:{enumerable:!0,configurable:!0,get(){return h},set(p){p instanceof Map&&(h=Ue(p,u,d),Er(u,h))}},commits:{enumerable:!0,configurable:!0,get(){return l},set(p){l=Array.isArray(p)?p:[],l.length>0&&l[0]?.hash?c=l[0].hash:l.length===0&&(c="")}}}),u}function ce(t,e){let r={};if(!t||typeof t.existsSync!="function"||typeof t.readdirSync!="function"||typeof t.statSync!="function"||typeof t.readFileSync!="function")return r;let n=e.replace(/\/+$/,"")||"/";if(!t.existsSync(n))return r;let i=a=>{let o=[];try{o=t.readdirSync?t.readdirSync(a):[]}catch(s){let c=s;return}for(let s of o){if(s===".git"||s==="node_modules")continue;let c=a==="/"?`/${s}`:`${a}/${s}`;try{let f=t.statSync?t.statSync(c):null;if(f&&f.isDirectory())i(c);else{let l=X(c,n);if(!l||V(l))continue;let u=t.readFileSync?t.readFileSync(c,"utf8"):"";r[l]=typeof u=="string"?u:new TextDecoder().decode(u)}}catch(f){let l=f}}};return i(n),r}function Ja(t){return!!(t&&typeof t=="object")&&("vfs"in t||"gitState"in t||"cwd"in t&&!("headFiles"in t))}function Lu(t,e){if(Ja(t)){let a=(e?.repoRoot||t.gitState?.repoRoot||t.cwd||"/workspace").replace(/\/+$/,"")||"/",o=e?.branch||t.gitState?.branch||"main",s=t.vfs??null;if(s){let l=a==="/"?"/.git":`${a}/.git`,u=`${l}/HEAD`,d=`${l}/config`;typeof s.mkdirSync=="function"&&(!s.existsSync||!s.existsSync(l))&&s.mkdirSync(l,{recursive:!0}),s.writeFileSync?.(u,`ref: refs/heads/${o}
94
94
  `),s.writeFileSync?.(d,`[core]
95
95
  repositoryformatversion = 0
96
96
  filemode = true
97
97
  bare = false
98
- `),t._emitVfsMutation?.("create",u)}let c=e?.snapshotExisting?e.initialFiles?U(e.initialFiles,a):s?ce(s,a):{}:{},f=t.gitState;return f?(f.initialized=!0,f.repoRoot=a,f.branch=o,kr(f,o),pt(f).clear(),lt(f,c),!e?.snapshotExisting&&f.commits.length===0&&(f.headCommit=""),rt(f,o),s&&Nt(s,f),f):(f=Ar(c,o,{initialized:!0,repoRoot:a}),e?.snapshotExisting||(f.commits=[],f.headCommit=""),rt(f,o),t.gitState=f,s&&Nt(s,f),f)}let r=t,n=e?.repoRoot||r.repoRoot||"/workspace",i=e?.branch||r.branch||"main";return r.initialized=!0,r.repoRoot=n,r.branch=i,kr(r,i),pt(r).clear(),lt(r,e?.snapshotExisting?e.initialFiles||{}:{}),rt(r,i),r}function eo(t,e="/workspace",r){let n,i="/workspace",a;t&&typeof t=="object"&&("headFiles"in t||"headSnapshot"in t||"staged"in t||"commits"in t)?(a=t,n=e&&typeof e=="object"?e:{},i=a.repoRoot||"/workspace"):(n=t&&typeof t=="object"?t:{},i=typeof e=="string"&&e?e:r?.repoRoot||"/workspace",a=r||Ar({}));let o=U(a.headFiles||a.headSnapshot||{},i),s=Mu(n,o,i),c=U(n,i,s,o),f=$n(a),l=new Map;if(a.staged instanceof Map)for(let[m,$]of a.staged.entries()){let g=X(m,i);if(!g||V(g))continue;let x=$==null?null:String($);je(a,g,x,o)&&l.set(g,x)}else if(a.staged instanceof Set)for(let m of a.staged.values()){let $=X(m,i);if(!$||V($))continue;let x=Object.prototype.hasOwnProperty.call(c,$)?c[$]:null;je(a,$,x,o)&&l.set($,x)}for(let m of l.keys())if(!Object.prototype.hasOwnProperty.call(c,m)){let $=`${i.replace(/\/+$/,"")}/${m}`;Object.prototype.hasOwnProperty.call(n,m)?c[m]=String(n[m]??""):Object.prototype.hasOwnProperty.call(n,$)&&(c[m]=String(n[$]??""))}let u=[],d=[],h=[],p=[];for(let[m,$]of l.entries()){let g=Object.prototype.hasOwnProperty.call(o,m),x=g&&!f;$===null?g&&p.push({path:m,status:"deleted",staged:!0,oldContent:o[m]}):(p.push({path:m,status:x?"modified":"added",staged:!0,oldContent:x?o[m]:void 0,newContent:$}),Object.prototype.hasOwnProperty.call(c,m)||h.push({path:m,status:"deleted",staged:!1,oldContent:$}))}for(let[m,$]of Object.entries(c))if(l.has(m)){let g=l.get(m);g===null?u.push({path:m,status:"untracked",staged:!1,newContent:$}):g!==$&&d.push({path:m,status:"modified",staged:!1,oldContent:g??void 0,newContent:$})}else Object.prototype.hasOwnProperty.call(o,m)?o[m]!==$&&d.push({path:m,status:"modified",staged:!1,oldContent:o[m],newContent:$}):u.push({path:m,status:"untracked",staged:!1,newContent:$});for(let m of Object.keys(o))!Object.prototype.hasOwnProperty.call(c,m)&&!l.has(m)&&h.push({path:m,status:"deleted",staged:!1,oldContent:o[m]});let w=new Set(d.map(m=>m.path)),y=new Set(h.map(m=>m.path)),b=new Map;for(let m of p)b.set(m.path,m.status==="added"?"A":m.status==="deleted"?"D":"M");let E=[...d,...h],S=[...p.map(m=>({path:m.path,status:m.status,staged:!0,index:b.get(m.path)||"M",worktree:w.has(m.path)?"M":y.has(m.path)?"D":" "})),...d.filter(m=>!b.has(m.path)).map(m=>({path:m.path,status:m.status,staged:!1,index:" ",worktree:"M"})),...h.filter(m=>!b.has(m.path)).map(m=>({path:m.path,status:m.status,staged:!1,index:" ",worktree:"D"})),...u.map(m=>({path:m.path,status:m.status,staged:!1,index:"?",worktree:"?"}))],A=u.length===0&&d.length===0&&h.length===0&&p.length===0;return{branch:a.branch||"main",headCommit:a.headCommit||"",untracked:u,modified:d,deleted:h,staged:p,unstaged:E,entries:S,hasChanges:!A,isClean:A}}function Gu(t,e,r){if(!t)return;let n=t.repoRoot||"/workspace",i=X(e,n);if(!i||V(i))return;let a=U(t.headFiles||t.headSnapshot||{},n),o=pt(t),s=r==null?null:String(r);Pt(t,o,i,s,a)}function zu(t,e,r="/workspace"){if(!t)return;let n=t.repoRoot||r||"/workspace",i=U(t.headFiles||t.headSnapshot||{},n),a=Mu(e,i,n),o=U(e,n,a,i),s=pt(t,o);for(let[c,f]of Object.entries(o))Pt(t,s,c,f,i);for(let c of Object.keys(i))Object.prototype.hasOwnProperty.call(o,c)||Pt(t,s,c,null,i);for(let c of Array.from(s.keys())){let f=X(c,n);(!f||V(f)||!Object.prototype.hasOwnProperty.call(o,f)&&!Object.prototype.hasOwnProperty.call(i,f))&&s.delete(c)}}function An(t,e){if(!t)return;let r=t.repoRoot||"/workspace",n=X(e,r);(t.staged instanceof Map||t.staged instanceof Set)&&(t.staged.delete(n),t.staged.delete(e))}function Hu(t){!t||!t.staged||t.staged.clear()}function qu(t,e,r="CodeLab Developer <dev@codelab.internal>"){let n=typeof e=="string"?e.trim():"";if(!n)throw new Error("Commit message cannot be empty");if(!t)throw new Error("Nothing to commit (staging area is empty)");let i=t.repoRoot||"/workspace",a=U(t.headFiles||t.headSnapshot||{},i),o=pt(t);if(Er(t,o,a),o.size===0)throw new Error("Nothing to commit (staging area is empty)");let s=[];for(let[p,w]of o.entries()){let y=X(p,i);!y||V(y)||(s.push(`${y}:${w===null?"<DEL>":w}`),w===null?delete a[y]:a[y]=w)}let c=Date.now(),f=Array.isArray(t.commits)?t.commits.length:0,l=t.headCommit?[t.headCommit]:[],u=Sr(`${t.headCommit}:${n}:${c}:${f}:${s.join("|")}`),d=lt(t,a),h={hash:u,message:n,timestamp:c,author:r,date:new Date(c).toUTCString(),files:{...d},parents:l};return Array.isArray(t.commits)||(t.commits=[]),t.commits.unshift(h),t.initialized=!0,t.headCommit=u,o.clear(),kr(t,t.branch||"main"),rt(t,t.branch||"main"),u}function St(t,e,r,n){if(!t)return;let i=e.lastIndexOf("/"),a=i>0?e.slice(0,i):"/";a&&typeof t.mkdirSync=="function"&&(typeof t.existsSync!="function"||!t.existsSync(a))&&t.mkdirSync(a,{recursive:!0}),t.writeFileSync?.(e,r),n?._emitVfsMutation?.("change",e)}function Dt(t,e,r){t&&(typeof t.rmSync=="function"?t.rmSync(e,{force:!0}):typeof t.unlinkSync=="function"?(typeof t.existsSync!="function"||t.existsSync(e))&&t.unlinkSync(e):t.files instanceof Map&&t.files.delete(e),r?._emitVfsMutation?.("delete",e))}function Wu(t,e,r,n){if(!t||typeof e!="string"||!e.trim())return!1;let i=t.gitState??null,a=(i&&i.repoRoot||t.cwd||"/workspace").replace(/\/+$/,"")||"/",o=X(e,a);if(!o||V(o))return!1;let s=a==="/"?`/${o}`:`${a}/${o}`,c=i?U(i.headFiles||i.headSnapshot||{},a):{},f=Object.prototype.hasOwnProperty.call(c,o),l=t.vfs??null,u=i?pt(i):null;if(n?.keepStaged&&u&&u.has(o)){let y=u.get(o);return y!=null?(St(l,s,y,t),r&&typeof r=="object"&&(r[o]=y),!0):(Dt(l,s,t),r&&typeof r=="object"&&delete r[o],!0)}if(f){let y=c[o];return St(l,s,y,t),r&&typeof r=="object"&&(r[o]=y),i&&An(i,o),!0}let d=!!(l&&typeof l.existsSync=="function"&&l.existsSync(s)),h=!!(l&&l.files instanceof Map&&l.files.has(s)),p=!!(r&&Object.prototype.hasOwnProperty.call(r,o)),w=!!(u&&u.has(o));return!d&&!h&&!p&&!w?!1:(Dt(l,s,t),r&&typeof r=="object"&&delete r[o],i&&An(i,o),!0)}function Me(t,e){let r=w=>{if(!w)return[];let y=w.replace(/\r\n/g,`
98
+ `),t._emitVfsMutation?.("create",u)}let c=e?.snapshotExisting?e.initialFiles?U(e.initialFiles,a):s?ce(s,a):{}:{},f=t.gitState;return f?(f.initialized=!0,f.repoRoot=a,f.branch=o,kr(f,o),pt(f).clear(),lt(f,c),!e?.snapshotExisting&&f.commits.length===0&&(f.headCommit=""),rt(f,o),s&&Nt(s,f),f):(f=Ar(c,o,{initialized:!0,repoRoot:a}),e?.snapshotExisting||(f.commits=[],f.headCommit=""),rt(f,o),t.gitState=f,s&&Nt(s,f),f)}let r=t,n=e?.repoRoot||r.repoRoot||"/workspace",i=e?.branch||r.branch||"main";return r.initialized=!0,r.repoRoot=n,r.branch=i,kr(r,i),pt(r).clear(),lt(r,e?.snapshotExisting?e.initialFiles||{}:{}),rt(r,i),r}function eo(t,e="/workspace",r){let n,i="/workspace",a;t&&typeof t=="object"&&("headFiles"in t||"headSnapshot"in t||"staged"in t||"commits"in t)?(a=t,n=e&&typeof e=="object"?e:{},i=a.repoRoot||"/workspace"):(n=t&&typeof t=="object"?t:{},i=typeof e=="string"&&e?e:r?.repoRoot||"/workspace",a=r||Ar({}));let o=U(a.headFiles||a.headSnapshot||{},i),s=Mu(n,o,i),c=U(n,i,s,o),f=Rn(a),l=new Map;if(a.staged instanceof Map)for(let[m,$]of a.staged.entries()){let g=X(m,i);if(!g||V(g))continue;let x=$==null?null:String($);je(a,g,x,o)&&l.set(g,x)}else if(a.staged instanceof Set)for(let m of a.staged.values()){let $=X(m,i);if(!$||V($))continue;let x=Object.prototype.hasOwnProperty.call(c,$)?c[$]:null;je(a,$,x,o)&&l.set($,x)}for(let m of l.keys())if(!Object.prototype.hasOwnProperty.call(c,m)){let $=`${i.replace(/\/+$/,"")}/${m}`;Object.prototype.hasOwnProperty.call(n,m)?c[m]=String(n[m]??""):Object.prototype.hasOwnProperty.call(n,$)&&(c[m]=String(n[$]??""))}let u=[],d=[],h=[],p=[];for(let[m,$]of l.entries()){let g=Object.prototype.hasOwnProperty.call(o,m),x=g&&!f;$===null?g&&p.push({path:m,status:"deleted",staged:!0,oldContent:o[m]}):(p.push({path:m,status:x?"modified":"added",staged:!0,oldContent:x?o[m]:void 0,newContent:$}),Object.prototype.hasOwnProperty.call(c,m)||h.push({path:m,status:"deleted",staged:!1,oldContent:$}))}for(let[m,$]of Object.entries(c))if(l.has(m)){let g=l.get(m);g===null?u.push({path:m,status:"untracked",staged:!1,newContent:$}):g!==$&&d.push({path:m,status:"modified",staged:!1,oldContent:g??void 0,newContent:$})}else Object.prototype.hasOwnProperty.call(o,m)?o[m]!==$&&d.push({path:m,status:"modified",staged:!1,oldContent:o[m],newContent:$}):u.push({path:m,status:"untracked",staged:!1,newContent:$});for(let m of Object.keys(o))!Object.prototype.hasOwnProperty.call(c,m)&&!l.has(m)&&h.push({path:m,status:"deleted",staged:!1,oldContent:o[m]});let w=new Set(d.map(m=>m.path)),y=new Set(h.map(m=>m.path)),b=new Map;for(let m of p)b.set(m.path,m.status==="added"?"A":m.status==="deleted"?"D":"M");let E=[...d,...h],S=[...p.map(m=>({path:m.path,status:m.status,staged:!0,index:b.get(m.path)||"M",worktree:w.has(m.path)?"M":y.has(m.path)?"D":" "})),...d.filter(m=>!b.has(m.path)).map(m=>({path:m.path,status:m.status,staged:!1,index:" ",worktree:"M"})),...h.filter(m=>!b.has(m.path)).map(m=>({path:m.path,status:m.status,staged:!1,index:" ",worktree:"D"})),...u.map(m=>({path:m.path,status:m.status,staged:!1,index:"?",worktree:"?"}))],A=u.length===0&&d.length===0&&h.length===0&&p.length===0;return{branch:a.branch||"main",headCommit:a.headCommit||"",untracked:u,modified:d,deleted:h,staged:p,unstaged:E,entries:S,hasChanges:!A,isClean:A}}function Gu(t,e,r){if(!t)return;let n=t.repoRoot||"/workspace",i=X(e,n);if(!i||V(i))return;let a=U(t.headFiles||t.headSnapshot||{},n),o=pt(t),s=r==null?null:String(r);Pt(t,o,i,s,a)}function zu(t,e,r="/workspace"){if(!t)return;let n=t.repoRoot||r||"/workspace",i=U(t.headFiles||t.headSnapshot||{},n),a=Mu(e,i,n),o=U(e,n,a,i),s=pt(t,o);for(let[c,f]of Object.entries(o))Pt(t,s,c,f,i);for(let c of Object.keys(i))Object.prototype.hasOwnProperty.call(o,c)||Pt(t,s,c,null,i);for(let c of Array.from(s.keys())){let f=X(c,n);(!f||V(f)||!Object.prototype.hasOwnProperty.call(o,f)&&!Object.prototype.hasOwnProperty.call(i,f))&&s.delete(c)}}function An(t,e){if(!t)return;let r=t.repoRoot||"/workspace",n=X(e,r);(t.staged instanceof Map||t.staged instanceof Set)&&(t.staged.delete(n),t.staged.delete(e))}function Hu(t){!t||!t.staged||t.staged.clear()}function qu(t,e,r="CodeLab Developer <dev@codelab.internal>"){let n=typeof e=="string"?e.trim():"";if(!n)throw new Error("Commit message cannot be empty");if(!t)throw new Error("Nothing to commit (staging area is empty)");let i=t.repoRoot||"/workspace",a=U(t.headFiles||t.headSnapshot||{},i),o=pt(t);if(Er(t,o,a),o.size===0)throw new Error("Nothing to commit (staging area is empty)");let s=[];for(let[p,w]of o.entries()){let y=X(p,i);!y||V(y)||(s.push(`${y}:${w===null?"<DEL>":w}`),w===null?delete a[y]:a[y]=w)}let c=Date.now(),f=Array.isArray(t.commits)?t.commits.length:0,l=t.headCommit?[t.headCommit]:[],u=Sr(`${t.headCommit}:${n}:${c}:${f}:${s.join("|")}`),d=lt(t,a),h={hash:u,message:n,timestamp:c,author:r,date:new Date(c).toUTCString(),files:{...d},parents:l};return Array.isArray(t.commits)||(t.commits=[]),t.commits.unshift(h),t.initialized=!0,t.headCommit=u,o.clear(),kr(t,t.branch||"main"),rt(t,t.branch||"main"),u}function St(t,e,r,n){if(!t)return;let i=e.lastIndexOf("/"),a=i>0?e.slice(0,i):"/";a&&typeof t.mkdirSync=="function"&&(typeof t.existsSync!="function"||!t.existsSync(a))&&t.mkdirSync(a,{recursive:!0}),t.writeFileSync?.(e,r),n?._emitVfsMutation?.("change",e)}function Dt(t,e,r){t&&(typeof t.rmSync=="function"?t.rmSync(e,{force:!0}):typeof t.unlinkSync=="function"?(typeof t.existsSync!="function"||t.existsSync(e))&&t.unlinkSync(e):t.files instanceof Map&&t.files.delete(e),r?._emitVfsMutation?.("delete",e))}function Wu(t,e,r,n){if(!t||typeof e!="string"||!e.trim())return!1;let i=t.gitState??null,a=(i&&i.repoRoot||t.cwd||"/workspace").replace(/\/+$/,"")||"/",o=X(e,a);if(!o||V(o))return!1;let s=a==="/"?`/${o}`:`${a}/${o}`,c=i?U(i.headFiles||i.headSnapshot||{},a):{},f=Object.prototype.hasOwnProperty.call(c,o),l=t.vfs??null,u=i?pt(i):null;if(n?.keepStaged&&u&&u.has(o)){let y=u.get(o);return y!=null?(St(l,s,y,t),r&&typeof r=="object"&&(r[o]=y),!0):(Dt(l,s,t),r&&typeof r=="object"&&delete r[o],!0)}if(f){let y=c[o];return St(l,s,y,t),r&&typeof r=="object"&&(r[o]=y),i&&An(i,o),!0}let d=!!(l&&typeof l.existsSync=="function"&&l.existsSync(s)),h=!!(l&&l.files instanceof Map&&l.files.has(s)),p=!!(r&&Object.prototype.hasOwnProperty.call(r,o)),w=!!(u&&u.has(o));return!d&&!h&&!p&&!w?!1:(Dt(l,s,t),r&&typeof r=="object"&&delete r[o],i&&An(i,o),!0)}function Me(t,e){let r=w=>{if(!w)return[];let y=w.replace(/\r\n/g,`
99
99
  `).split(`
100
100
  `);return y.length>0&&y[y.length-1]===""&&w.endsWith(`
101
101
  `)&&y.pop(),y},n=r(t),i=r(e),a=n.length,o=i.length;if(a===0&&o===0)return[];let s=a+o,c=s,f=new Int32Array(2*s+2);f.fill(-1),f[c+1]=0;let l=[],u=s;for(let w=0;w<=s;w++){l.push(new Int32Array(f));for(let y=-w;y<=w;y+=2){let b;y===-w||y!==w&&f[c+y-1]<f[c+y+1]?b=f[c+y+1]:b=f[c+y-1]+1;let E=b-y;for(;b<a&&E<o&&n[b]===i[E];)b++,E++;if(f[c+y]=b,b>=a&&E>=o){u=w,w=s+1;break}}}let d=[],h=a,p=o;for(let w=u;w>0;w--){let y=l[w],b=h-p,E;b===-w||b!==w&&y[c+b-1]<y[c+b+1]?E=b+1:E=b-1;let S=y[c+E],A=S-E;for(;h>S&&p>A;)h--,p--,d.push({type:"common",line:n[h],oldLineNumber:h+1,newLineNumber:p+1});h===S?(p--,d.push({type:"added",line:i[p],newLineNumber:p+1})):(h--,d.push({type:"removed",line:n[h],oldLineNumber:h+1}))}for(;h>0&&p>0;)h--,p--,d.push({type:"common",line:n[h],oldLineNumber:h+1,newLineNumber:p+1});return d.reverse(),d}function ro(t,e,r,n,i=3){let a=Me(r,n);if(!a.some(f=>f.type!=="common"))return"";let o=[];for(let f=0;f<a.length;f++)a[f].type!=="common"&&o.push(f);let s=[];for(let f of o){let l=Math.max(0,f-i),u=Math.min(a.length-1,f+i),d=s[s.length-1];d&&l<=d.end+1?d.end=Math.max(d.end,u):s.push({start:l,end:u})}let c=`--- ${t}
@@ -106,7 +106,7 @@ gpgsig`+ea(o)+`
106
106
  `:c+=`-${w.line}
107
107
  `}return c}function Zu(t,e){if(t===void 0){let o=e?e.split(/\r?\n/).length:1;return[{line:1,endLine:Math.max(1,o),kind:"added"}]}if(t===e)return[];let r=Me(t,e),n=[],i=0,a=1;for(;i<r.length;){let o=r[i];if(o.type==="common"){o.newLineNumber&&(a=o.newLineNumber),i++;continue}let s=0,c=[];for(;i<r.length&&r[i].type!=="common";)r[i].type==="removed"?s++:r[i].type==="added"&&r[i].newLineNumber&&c.push(r[i].newLineNumber),i++;if(c.length>0&&s>0)n.push({line:c[0],endLine:c[c.length-1],kind:"modified"}),a=c[c.length-1];else if(c.length>0)n.push({line:c[0],endLine:c[c.length-1],kind:"added"}),a=c[c.length-1];else if(s>0){let f=Math.max(1,a);n.push({line:f,endLine:f,kind:"deleted"})}}return n}function Vu(t,e,r){let n=typeof e=="string"?e.trim():"";if(!n)return{ok:!1,created:!1,error:"branch name required"};let i=Ja(t)?t:null,a=Ja(t)?t.gitState??null:t;if(!a)return{ok:!1,created:!1,error:"not a git repository"};let o=(a.repoRoot||i?.cwd||"/workspace").replace(/\/+$/,"")||"/",s=i?.vfs??null,c=a.branch||"main";rt(a,c);let f=a.branches instanceof Set?a.branches.has(n):Array.isArray(a.branches)?a.branches.includes(n):c===n;if(r?.create){if(kr(a,n),a.branch=n,rt(a,n),s){let p=`${o==="/"?"":o}/.git/HEAD`;St(s,p,`ref: refs/heads/${n}
108
108
  `,i??void 0),Nt(s,a)}return{ok:!0,created:!0}}if(!f&&!(a.branchHeads&&a.branchHeads[n]))return{ok:!1,created:!1,error:`pathspec '${n}' did not match any file(s) known to git`};let l=U(a.headFiles||a.headSnapshot||{},o),u=a.branchHeads?.[n],d=u?U(u.headFiles,o):{...l},h=pt(a);if(s||r?.workspaceFiles){let p=s?ce(s,o):{...r?.workspaceFiles||{}},w=new Set([...Object.keys(l),...Object.keys(d)]);for(let y of w){let b=Object.prototype.hasOwnProperty.call(l,y),E=Object.prototype.hasOwnProperty.call(d,y),S=Object.prototype.hasOwnProperty.call(p,y);if((h.has(y)||b&&(!S||p[y]!==l[y])||!b&&S&&(!E||p[y]!==d[y]))&&!r?.force)continue;let m=o==="/"?`/${y}`:`${o}/${y}`;E?((!S||p[y]!==d[y])&&St(s,m,d[y],i??void 0),r?.workspaceFiles&&(r.workspaceFiles[y]=d[y])):b&&(Dt(s,m,i??void 0),r?.workspaceFiles&&delete r.workspaceFiles[y])}}if(a.branch=n,kr(a,n),u&&(a.commits=u.commits.map(p=>({...p,...p.files?{files:{...p.files}}:{}})),a.headCommit=u.headCommit,lt(a,d)),Er(a,h,d),s){let p=`${o==="/"?"":o}/.git/HEAD`;St(s,p,`ref: refs/heads/${n}
109
- `,i??void 0),Nt(s,a)}return{ok:!0,created:!1}}function Rn(t,e){let r=Array.isArray(t.commits)?t.commits:[];if(r.length===0)return{commit:null,index:-1};let n=(e||"HEAD").trim();if(!n||n==="HEAD")return{commit:r[0],index:0};let i=/^HEAD~(\d+)$/.exec(n);if(i){let c=Number.parseInt(i[1],10);return c>=0&&c<r.length?{commit:r[c],index:c}:{commit:null,index:-1}}let a=/^HEAD(\^+)$/.exec(n);if(a){let s=a[1].length;return s>=0&&s<r.length?{commit:r[s],index:s}:{commit:null,index:-1}}if(t.tags&&t.tags[n]){let s=t.tags[n],c=r.findIndex(f=>f.hash===s||f.hash.startsWith(s));if(c!==-1)return{commit:r[c],index:c}}if(t.branchHeads&&t.branchHeads[n]){let s=t.branchHeads[n];if(s.commits.length>0)return{commit:s.commits[0],index:0}}let o=r.findIndex(s=>s.hash===n||s.hash.startsWith(n));return o!==-1?{commit:r[o],index:o}:{commit:null,index:-1}}function Xu(t,e="HEAD",r="mixed",n){let i=t.gitState??null;if(!i)return{ok:!1,headCommit:"",error:"not a git repository"};let a=(i.repoRoot||t.cwd||"/workspace").replace(/\/+$/,"")||"/",o=t.vfs??null,{commit:s,index:c}=Rn(i,e);if(!s&&i.commits.length>0)return{ok:!1,headCommit:i.headCommit,error:`fatal: ambiguous argument '${e}': unknown revision or path not in the working tree.`};let f=U(i.headFiles||i.headSnapshot||{},a),l=s?.files?U(s.files,a):f,u=pt(i);if(s&&c>0?(i.commits=i.commits.slice(c),i.headCommit=s.hash,lt(i,l)):s&&(i.headCommit=s.hash,lt(i,l)),r==="soft"){let d={...f};for(let[h,p]of u.entries())p===null?delete d[h]:d[h]=p;u.clear();for(let[h,p]of Object.entries(d))Pt(i,u,h,p,l);for(let h of Object.keys(l))Object.prototype.hasOwnProperty.call(d,h)||Pt(i,u,h,null,l)}else if(r==="mixed")u.clear();else if(r==="hard"&&(u.clear(),o)){let d=ce(o,a);for(let h of Object.keys(d))Object.prototype.hasOwnProperty.call(l,h)||(Dt(o,a==="/"?`/${h}`:`${a}/${h}`,t),n&&delete n[h]);for(let[h,p]of Object.entries(l))St(o,a==="/"?`/${h}`:`${a}/${h}`,p,t),n&&(n[h]=p)}return rt(i,i.branch),o&&Nt(o,i),{ok:!0,headCommit:i.headCommit,message:s?`HEAD is now at ${s.hash} ${s.message}`:void 0}}function Yu(t,e,r=!1,n){let i=t.gitState??null;if(!i)return{ok:!1,created:!1,label:"not a git repository"};let a=(i.repoRoot||t.cwd||"/workspace").replace(/\/+$/,"")||"/",o=t.vfs??null,s=o?ce(o,a):{...n||{}},c=eo(s,a,i);if(!(c.staged.length>0||c.modified.length>0||c.deleted.length>0||r&&c.untracked.length>0))return{ok:!0,created:!1,label:"No local changes to save"};Array.isArray(i.stashes)||(i.stashes=[]);let l=U(i.headFiles||i.headSnapshot||{},a),u=pt(i),d={};if(r)for(let w of c.untracked)Object.prototype.hasOwnProperty.call(s,w.path)&&(d[w.path]=s[w.path]);let h={};for(let[w,y]of Object.entries(s))(Object.prototype.hasOwnProperty.call(l,w)||u.has(w))&&(h[w]=y);let p=e?.trim()||`WIP on ${i.branch||"main"}: ${i.headCommit||"unborn"} ${i.commits[0]?.message||"initial"}`;i.stashes.unshift({id:Date.now(),branch:i.branch||"main",headCommit:i.headCommit||"",message:p,timestamp:Date.now(),worktreeFiles:h,stagedEntries:Array.from(u.entries()),untrackedFiles:d}),u.clear();for(let w of Object.keys(d))Dt(o,a==="/"?`/${w}`:`${a}/${w}`,t),n&&delete n[w];for(let w of Object.keys(h))Object.prototype.hasOwnProperty.call(l,w)||(Dt(o,a==="/"?`/${w}`:`${a}/${w}`,t),n&&delete n[w]);for(let[w,y]of Object.entries(l))St(o,a==="/"?`/${w}`:`${a}/${w}`,y,t),n&&(n[w]=y);return{ok:!0,created:!0,label:`Saved working directory and index state ${p}`}}function Ku(t,e=0,r=!1,n){let i=t.gitState??null;if(!i||!Array.isArray(i.stashes)||i.stashes.length===0)return{ok:!1,error:"No stash entries found."};if(e<0||e>=i.stashes.length)return{ok:!1,error:`error: stash@{${e}} is not a valid reference`};let a=i.stashes[e],o=(i.repoRoot||t.cwd||"/workspace").replace(/\/+$/,"")||"/",s=t.vfs??null,c=U(i.headFiles||i.headSnapshot||{},o),f=pt(i);for(let l of Object.keys(c))Object.prototype.hasOwnProperty.call(a.worktreeFiles,l)||(Dt(s,o==="/"?`/${l}`:`${o}/${l}`,t),n&&delete n[l]);for(let[l,u]of Object.entries({...a.worktreeFiles,...a.untrackedFiles}))St(s,o==="/"?`/${l}`:`${o}/${l}`,u,t),n&&(n[l]=u);for(let[l,u]of a.stagedEntries)Pt(i,f,l,u,c);return r&&i.stashes.splice(e,1),{ok:!0,message:r?`Dropped refs/stash@{${e}} (${a.message})`:`Applied stash@{${e}}`}}function Ju(t,e,r){let n=t.gitState??null;if(!n)return{ok:!1,fastForward:!1,conflicts:[],message:"fatal: not a git repository"};let i=e.trim(),a=(n.repoRoot||t.cwd||"/workspace").replace(/\/+$/,"")||"/",o=t.vfs??null;rt(n,n.branch);let s=n.branchHeads?.[i];if(!s)return{ok:!1,fastForward:!1,conflicts:[],message:`merge: ${i} - not something we can merge`};if(s.headCommit===n.headCommit)return{ok:!0,fastForward:!0,conflicts:[],message:"Already up to date."};let c=new Set(n.commits.map(m=>m.hash));if(c.has(s.headCommit))return{ok:!0,fastForward:!0,conflicts:[],message:"Already up to date."};if(!n.headCommit||s.commits.some(m=>m.hash===n.headCommit)){let m=U(s.headFiles,a),$=U(n.headFiles||n.headSnapshot||{},a);for(let g of Object.keys($))Object.prototype.hasOwnProperty.call(m,g)||(Dt(o,a==="/"?`/${g}`:`${a}/${g}`,t),r&&delete r[g]);for(let[g,x]of Object.entries(m))St(o,a==="/"?`/${g}`:`${a}/${g}`,x,t),r&&(r[g]=x);return n.commits=s.commits.map(g=>({...g,...g.files?{files:{...g.files}}:{}})),n.headCommit=s.headCommit,lt(n,m),rt(n,n.branch),o&&Nt(o,n),{ok:!0,fastForward:!0,conflicts:[],commitHash:n.headCommit,message:`Updating ${s.headCommit}
109
+ `,i??void 0),Nt(s,a)}return{ok:!0,created:!1}}function $n(t,e){let r=Array.isArray(t.commits)?t.commits:[];if(r.length===0)return{commit:null,index:-1};let n=(e||"HEAD").trim();if(!n||n==="HEAD")return{commit:r[0],index:0};let i=/^HEAD~(\d+)$/.exec(n);if(i){let c=Number.parseInt(i[1],10);return c>=0&&c<r.length?{commit:r[c],index:c}:{commit:null,index:-1}}let a=/^HEAD(\^+)$/.exec(n);if(a){let s=a[1].length;return s>=0&&s<r.length?{commit:r[s],index:s}:{commit:null,index:-1}}if(t.tags&&t.tags[n]){let s=t.tags[n],c=r.findIndex(f=>f.hash===s||f.hash.startsWith(s));if(c!==-1)return{commit:r[c],index:c}}if(t.branchHeads&&t.branchHeads[n]){let s=t.branchHeads[n];if(s.commits.length>0)return{commit:s.commits[0],index:0}}let o=r.findIndex(s=>s.hash===n||s.hash.startsWith(n));return o!==-1?{commit:r[o],index:o}:{commit:null,index:-1}}function Xu(t,e="HEAD",r="mixed",n){let i=t.gitState??null;if(!i)return{ok:!1,headCommit:"",error:"not a git repository"};let a=(i.repoRoot||t.cwd||"/workspace").replace(/\/+$/,"")||"/",o=t.vfs??null,{commit:s,index:c}=$n(i,e);if(!s&&i.commits.length>0)return{ok:!1,headCommit:i.headCommit,error:`fatal: ambiguous argument '${e}': unknown revision or path not in the working tree.`};let f=U(i.headFiles||i.headSnapshot||{},a),l=s?.files?U(s.files,a):f,u=pt(i);if(s&&c>0?(i.commits=i.commits.slice(c),i.headCommit=s.hash,lt(i,l)):s&&(i.headCommit=s.hash,lt(i,l)),r==="soft"){let d={...f};for(let[h,p]of u.entries())p===null?delete d[h]:d[h]=p;u.clear();for(let[h,p]of Object.entries(d))Pt(i,u,h,p,l);for(let h of Object.keys(l))Object.prototype.hasOwnProperty.call(d,h)||Pt(i,u,h,null,l)}else if(r==="mixed")u.clear();else if(r==="hard"&&(u.clear(),o)){let d=ce(o,a);for(let h of Object.keys(d))Object.prototype.hasOwnProperty.call(l,h)||(Dt(o,a==="/"?`/${h}`:`${a}/${h}`,t),n&&delete n[h]);for(let[h,p]of Object.entries(l))St(o,a==="/"?`/${h}`:`${a}/${h}`,p,t),n&&(n[h]=p)}return rt(i,i.branch),o&&Nt(o,i),{ok:!0,headCommit:i.headCommit,message:s?`HEAD is now at ${s.hash} ${s.message}`:void 0}}function Yu(t,e,r=!1,n){let i=t.gitState??null;if(!i)return{ok:!1,created:!1,label:"not a git repository"};let a=(i.repoRoot||t.cwd||"/workspace").replace(/\/+$/,"")||"/",o=t.vfs??null,s=o?ce(o,a):{...n||{}},c=eo(s,a,i);if(!(c.staged.length>0||c.modified.length>0||c.deleted.length>0||r&&c.untracked.length>0))return{ok:!0,created:!1,label:"No local changes to save"};Array.isArray(i.stashes)||(i.stashes=[]);let l=U(i.headFiles||i.headSnapshot||{},a),u=pt(i),d={};if(r)for(let w of c.untracked)Object.prototype.hasOwnProperty.call(s,w.path)&&(d[w.path]=s[w.path]);let h={};for(let[w,y]of Object.entries(s))(Object.prototype.hasOwnProperty.call(l,w)||u.has(w))&&(h[w]=y);let p=e?.trim()||`WIP on ${i.branch||"main"}: ${i.headCommit||"unborn"} ${i.commits[0]?.message||"initial"}`;i.stashes.unshift({id:Date.now(),branch:i.branch||"main",headCommit:i.headCommit||"",message:p,timestamp:Date.now(),worktreeFiles:h,stagedEntries:Array.from(u.entries()),untrackedFiles:d}),u.clear();for(let w of Object.keys(d))Dt(o,a==="/"?`/${w}`:`${a}/${w}`,t),n&&delete n[w];for(let w of Object.keys(h))Object.prototype.hasOwnProperty.call(l,w)||(Dt(o,a==="/"?`/${w}`:`${a}/${w}`,t),n&&delete n[w]);for(let[w,y]of Object.entries(l))St(o,a==="/"?`/${w}`:`${a}/${w}`,y,t),n&&(n[w]=y);return{ok:!0,created:!0,label:`Saved working directory and index state ${p}`}}function Ku(t,e=0,r=!1,n){let i=t.gitState??null;if(!i||!Array.isArray(i.stashes)||i.stashes.length===0)return{ok:!1,error:"No stash entries found."};if(e<0||e>=i.stashes.length)return{ok:!1,error:`error: stash@{${e}} is not a valid reference`};let a=i.stashes[e],o=(i.repoRoot||t.cwd||"/workspace").replace(/\/+$/,"")||"/",s=t.vfs??null,c=U(i.headFiles||i.headSnapshot||{},o),f=pt(i);for(let l of Object.keys(c))Object.prototype.hasOwnProperty.call(a.worktreeFiles,l)||(Dt(s,o==="/"?`/${l}`:`${o}/${l}`,t),n&&delete n[l]);for(let[l,u]of Object.entries({...a.worktreeFiles,...a.untrackedFiles}))St(s,o==="/"?`/${l}`:`${o}/${l}`,u,t),n&&(n[l]=u);for(let[l,u]of a.stagedEntries)Pt(i,f,l,u,c);return r&&i.stashes.splice(e,1),{ok:!0,message:r?`Dropped refs/stash@{${e}} (${a.message})`:`Applied stash@{${e}}`}}function Ju(t,e,r){let n=t.gitState??null;if(!n)return{ok:!1,fastForward:!1,conflicts:[],message:"fatal: not a git repository"};let i=e.trim(),a=(n.repoRoot||t.cwd||"/workspace").replace(/\/+$/,"")||"/",o=t.vfs??null;rt(n,n.branch);let s=n.branchHeads?.[i];if(!s)return{ok:!1,fastForward:!1,conflicts:[],message:`merge: ${i} - not something we can merge`};if(s.headCommit===n.headCommit)return{ok:!0,fastForward:!0,conflicts:[],message:"Already up to date."};let c=new Set(n.commits.map(m=>m.hash));if(c.has(s.headCommit))return{ok:!0,fastForward:!0,conflicts:[],message:"Already up to date."};if(!n.headCommit||s.commits.some(m=>m.hash===n.headCommit)){let m=U(s.headFiles,a),$=U(n.headFiles||n.headSnapshot||{},a);for(let g of Object.keys($))Object.prototype.hasOwnProperty.call(m,g)||(Dt(o,a==="/"?`/${g}`:`${a}/${g}`,t),r&&delete r[g]);for(let[g,x]of Object.entries(m))St(o,a==="/"?`/${g}`:`${a}/${g}`,x,t),r&&(r[g]=x);return n.commits=s.commits.map(g=>({...g,...g.files?{files:{...g.files}}:{}})),n.headCommit=s.headCommit,lt(n,m),rt(n,n.branch),o&&Nt(o,n),{ok:!0,fastForward:!0,conflicts:[],commitHash:n.headCommit,message:`Updating ${s.headCommit}
110
110
  Fast-forward`}}let l=s.commits.find(m=>c.has(m.hash)),u=l?.files?U(l.files,a):{},d=U(n.headFiles||n.headSnapshot||{},a),h=U(s.headFiles,a),p=new Set([...Object.keys(u),...Object.keys(d),...Object.keys(h)]),w={},y=[];for(let m of p){let $=u[m],g=d[m],x=h[m];g===x?g!==void 0&&(w[m]=g):g===$?x!==void 0&&(w[m]=x):x===$?g!==void 0&&(w[m]=g):(y.push(m),w[m]=`<<<<<<< HEAD
111
111
  ${g??""}`+(g&&!g.endsWith(`
112
112
  `)?`
@@ -116,7 +116,7 @@ ${x??""}`+(x&&!x.endsWith(`
116
116
  `:"")+`>>>>>>> ${i}
117
117
  `)}for(let m of Object.keys(d))Object.prototype.hasOwnProperty.call(w,m)||(Dt(o,a==="/"?`/${m}`:`${a}/${m}`,t),r&&delete r[m]);for(let[m,$]of Object.entries(w))St(o,a==="/"?`/${m}`:`${a}/${m}`,$,t),r&&(r[m]=$);if(y.length>0)return{ok:!1,fastForward:!1,conflicts:y,message:y.map(m=>`CONFLICT (content): Merge conflict in ${m}`).join(`
118
118
  `)+`
119
- Automatic merge failed; fix conflicts and then commit the result.`};let b=Date.now(),E=`Merge branch '${i}' into ${n.branch}`,S=Sr(`${n.headCommit}:${s.headCommit}:${b}`),A=lt(n,w);return n.commits.unshift({hash:S,message:E,timestamp:b,author:"CodeLab Developer <dev@codelab.internal>",date:new Date(b).toUTCString(),files:{...A},parents:[n.headCommit,s.headCommit].filter(Boolean)}),n.headCommit=S,pt(n).clear(),rt(n,n.branch),o&&Nt(o,n),{ok:!0,fastForward:!1,conflicts:[],commitHash:S,message:"Merge made by the 'ort' strategy."}}function Qu(t,e="HEAD"){let{commit:r,index:n}=Rn(t,e);if(!r)return{ok:!1,output:`fatal: bad object ${e}
119
+ Automatic merge failed; fix conflicts and then commit the result.`};let b=Date.now(),E=`Merge branch '${i}' into ${n.branch}`,S=Sr(`${n.headCommit}:${s.headCommit}:${b}`),A=lt(n,w);return n.commits.unshift({hash:S,message:E,timestamp:b,author:"CodeLab Developer <dev@codelab.internal>",date:new Date(b).toUTCString(),files:{...A},parents:[n.headCommit,s.headCommit].filter(Boolean)}),n.headCommit=S,pt(n).clear(),rt(n,n.branch),o&&Nt(o,n),{ok:!0,fastForward:!1,conflicts:[],commitHash:S,message:"Merge made by the 'ort' strategy."}}function Qu(t,e="HEAD"){let{commit:r,index:n}=$n(t,e);if(!r)return{ok:!1,output:`fatal: bad object ${e}
120
120
  `};let a=t.commits[n+1]?.files||{},o=r.files||{},s=Array.from(new Set([...Object.keys(a),...Object.keys(o)])).sort(),c=r.author||"CodeLab Developer <dev@codelab.internal>",f=r.date||new Date(r.timestamp||0).toUTCString(),l=`commit ${r.hash}
121
121
  Author: ${c}
122
122
  Date: ${f}
@@ -137,7 +137,7 @@ ${p}`)}}return{ok:!0,output:l}}function td(t,e,r){let n=t.repoRoot||"/workspace"
137
137
  `),s.join(`
138
138
  `));for(let w of p)if(w.type==="common"&&w.oldLineNumber&&w.newLineNumber){let y=u[w.oldLineNumber-1];y&&(f[w.newLineNumber-1]=y)}}let d=s.map((p,w)=>({lineNumber:w+1,hash:f[w].hash,author:f[w].author,timestamp:f[w].timestamp,content:p})),h=d.map(p=>{let w=new Date(p.timestamp).toISOString().slice(0,10);return`${p.hash.slice(0,7)} (${p.author.padEnd(18).slice(0,18)} ${w} ${String(p.lineNumber).padStart(3)}) ${p.content}`}).join(`
139
139
  `)+(d.length>0?`
140
- `:"");return{ok:!0,entries:d,output:h}}function On(t){let e=(n,i)=>{let a=new Error(i);return a.code=n,a},r=async n=>{if(!t.statSync)throw e("ENOENT",`ENOENT: ${n}`);try{let i=t.statSync(n),a=i.isDirectory(),o=i.mtimeMs??Date.now();return{type:a?"dir":"file",mode:i.mode??(a?16877:33188),size:i.size??0,ino:1,mtimeMs:o,ctimeMs:o,uid:1e3,gid:1e3,dev:1,isFile:()=>!a,isDirectory:()=>a,isSymbolicLink:()=>!!i.isSymbolicLink?.()}}catch(i){let a=i instanceof Error?i.message:String(i);throw e("ENOENT",a)}};return{promises:{readFile:async(n,i)=>{if(!t.readFileSync)throw e("ENOENT",`ENOENT: ${n}`);let a=typeof i=="string"?i:i?.encoding;try{let o=t.readFileSync(n,a);return a==="utf8"||a==="utf-8"?typeof o=="string"?o:new TextDecoder().decode(o):o instanceof Uint8Array?o:new TextEncoder().encode(String(o))}catch(o){let s=o instanceof Error?o.message:String(o);throw e("ENOENT",s)}},writeFile:async(n,i)=>{let a=n.lastIndexOf("/"),o=a>0?n.slice(0,a):"/";o&&t.mkdirSync&&(!t.existsSync||!t.existsSync(o))&&t.mkdirSync(o,{recursive:!0}),t.writeFileSync?.(n,i)},unlink:async n=>{if(t.unlinkSync)try{t.unlinkSync(n)}catch(i){let a=i instanceof Error?i.message:String(i);throw e("ENOENT",a)}else t.rmSync&&t.rmSync(n,{force:!0})},readdir:async n=>{if(!t.readdirSync)throw e("ENOENT",`ENOENT: ${n}`);try{return t.readdirSync(n)}catch(i){let a=i instanceof Error?i.message:String(i);throw e("ENOENT",a)}},mkdir:async n=>{try{t.mkdirSync?.(n,{recursive:!0})}catch(i){let a=i}},rmdir:async n=>{try{t.rmdirSync?t.rmdirSync(n):t.rmSync?.(n,{recursive:!1,force:!0})}catch(i){let a=i instanceof Error?i.message:String(i);throw e("ENOENT",a)}},stat:r,lstat:r,readlink:async n=>{if(t.readlinkSync)return t.readlinkSync(n);throw e("ENOENT",`ENOENT: ${n}`)},symlink:async(n,i)=>{t.symlinkSync?.(n,i)}}}}async function Nt(t,e){if(!t||!e.initialized||typeof t.writeFileSync!="function")return;let r=(e.repoRoot||"/workspace").replace(/\/+$/,"")||"/workspace",n=On(t);try{if(await Xa({fs:n,dir:r,defaultBranch:e.branch||"main"}),e.commits.length>0){let i=e.commits[0],a=e.headFiles||e.headSnapshot||{};for(let o of Object.keys(a)){let s=`${r}/${o}`;t.existsSync?.(s)&&await Wa({fs:n,dir:r,filepath:o})}await Za({fs:n,dir:r,message:i.message||"commit",author:{name:"CodeLab Developer",email:"dev@codelab.internal",timestamp:Math.floor((i.timestamp||Date.now())/1e3)}})}}catch(i){let a=i}}async function ed(t,e="/workspace"){let r=(e||"/workspace").replace(/\/+$/,"")||"/workspace",n=`${r}/.git/HEAD`;if(!t||!t.existsSync?.(n))return null;let i=On(t);try{let a=await Va({fs:i,dir:r,fullname:!1})||"main",o=await Ya({fs:i,dir:r}),s=await Ka({fs:i,dir:r,depth:50}).catch(()=>[]),c=[];for(let u of s)c.push({hash:u.oid.slice(0,7),message:u.commit.message.trim(),timestamp:u.commit.author.timestamp*1e3,author:`${u.commit.author.name} <${u.commit.author.email}>`,date:new Date(u.commit.author.timestamp*1e3).toUTCString()});let f=ce(t,r),l=Ar(c.length>0?f:{},String(a),{initialized:!0,repoRoot:r});return l.branches=o.length>0?o:[String(a)],c.length>0?(c[0].files={...f},l.commits=c,l.headCommit=c[0].hash,lt(l,f)):(l.commits=[],l.headCommit="",lt(l,{})),rt(l,l.branch),l}catch(a){let o=a;return null}}var rd={init:Xa,add:Wa,commit:Za,currentBranch:Va,listBranches:Ya,log:Ka};var Ag={computeShortCommitHash:Sr,parseGitignoreRules:Qa,isIgnoredByRules:to,isIgnoredScmPath:V,normalizeScmRelPath:X,isUnbornGitHead:$n,isEffectiveStagedChange:je,syncGitHead:lt,saveBranchTip:rt,createGitState:Ar,readVfsTree:ce,initRepository:Lu,computeGitStatus:eo,stageFile:Gu,stageAll:zu,unstageFile:An,unstageAll:Hu,commitChanges:qu,discardChanges:Wu,computeMyersDiffOps:Me,computeUnifiedHunkDiff:ro,computeGitGutterChanges:Zu,checkoutBranch:Vu,resolveCommitRef:Rn,resetToRef:Xu,stashPush:Yu,stashApply:Ku,mergeBranch:Ju,showCommit:Qu,blameFile:td,createIsoGitFsAdapter:On,syncToIsoGitRepo:Nt,hydrateFromIsoGitRepo:ed,isoGit:rd};return fd($g);})();
140
+ `:"");return{ok:!0,entries:d,output:h}}function On(t){let e=(n,i)=>{let a=new Error(i);return a.code=n,a},r=async n=>{if(!t.statSync)throw e("ENOENT",`ENOENT: ${n}`);try{let i=t.statSync(n),a=i.isDirectory(),o=i.mtimeMs??Date.now();return{type:a?"dir":"file",mode:i.mode??(a?16877:33188),size:i.size??0,ino:1,mtimeMs:o,ctimeMs:o,uid:1e3,gid:1e3,dev:1,isFile:()=>!a,isDirectory:()=>a,isSymbolicLink:()=>!!i.isSymbolicLink?.()}}catch(i){let a=i instanceof Error?i.message:String(i);throw e("ENOENT",a)}};return{promises:{readFile:async(n,i)=>{if(!t.readFileSync)throw e("ENOENT",`ENOENT: ${n}`);let a=typeof i=="string"?i:i?.encoding;try{let o=t.readFileSync(n,a);return a==="utf8"||a==="utf-8"?typeof o=="string"?o:new TextDecoder().decode(o):o instanceof Uint8Array?o:new TextEncoder().encode(String(o))}catch(o){let s=o instanceof Error?o.message:String(o);throw e("ENOENT",s)}},writeFile:async(n,i)=>{let a=n.lastIndexOf("/"),o=a>0?n.slice(0,a):"/";o&&t.mkdirSync&&(!t.existsSync||!t.existsSync(o))&&t.mkdirSync(o,{recursive:!0}),t.writeFileSync?.(n,i)},unlink:async n=>{if(t.unlinkSync)try{t.unlinkSync(n)}catch(i){let a=i instanceof Error?i.message:String(i);throw e("ENOENT",a)}else t.rmSync&&t.rmSync(n,{force:!0})},readdir:async n=>{if(!t.readdirSync)throw e("ENOENT",`ENOENT: ${n}`);try{return t.readdirSync(n)}catch(i){let a=i instanceof Error?i.message:String(i);throw e("ENOENT",a)}},mkdir:async n=>{try{t.mkdirSync?.(n,{recursive:!0})}catch(i){let a=i}},rmdir:async n=>{try{t.rmdirSync?t.rmdirSync(n):t.rmSync?.(n,{recursive:!1,force:!0})}catch(i){let a=i instanceof Error?i.message:String(i);throw e("ENOENT",a)}},stat:r,lstat:r,readlink:async n=>{if(t.readlinkSync)return t.readlinkSync(n);throw e("ENOENT",`ENOENT: ${n}`)},symlink:async(n,i)=>{t.symlinkSync?.(n,i)}}}}async function Nt(t,e){if(!t||!e.initialized||typeof t.writeFileSync!="function")return;let r=(e.repoRoot||"/workspace").replace(/\/+$/,"")||"/workspace",n=On(t);try{if(await Xa({fs:n,dir:r,defaultBranch:e.branch||"main"}),e.commits.length>0){let i=e.commits[0],a=e.headFiles||e.headSnapshot||{};for(let o of Object.keys(a)){let s=`${r}/${o}`;t.existsSync?.(s)&&await Wa({fs:n,dir:r,filepath:o})}await Za({fs:n,dir:r,message:i.message||"commit",author:{name:"CodeLab Developer",email:"dev@codelab.internal",timestamp:Math.floor((i.timestamp||Date.now())/1e3)}})}}catch(i){let a=i}}async function ed(t,e="/workspace"){let r=(e||"/workspace").replace(/\/+$/,"")||"/workspace",n=`${r}/.git/HEAD`;if(!t||!t.existsSync?.(n))return null;let i=On(t);try{let a=await Va({fs:i,dir:r,fullname:!1})||"main",o=await Ya({fs:i,dir:r}),s=await Ka({fs:i,dir:r,depth:50}).catch(()=>[]),c=[];for(let u of s)c.push({hash:u.oid.slice(0,7),message:u.commit.message.trim(),timestamp:u.commit.author.timestamp*1e3,author:`${u.commit.author.name} <${u.commit.author.email}>`,date:new Date(u.commit.author.timestamp*1e3).toUTCString()});let f=ce(t,r),l=Ar(c.length>0?f:{},String(a),{initialized:!0,repoRoot:r});return l.branches=o.length>0?o:[String(a)],c.length>0?(c[0].files={...f},l.commits=c,l.headCommit=c[0].hash,lt(l,f)):(l.commits=[],l.headCommit="",lt(l,{})),rt(l,l.branch),l}catch(a){let o=a;return null}}var rd={init:Xa,add:Wa,commit:Za,currentBranch:Va,listBranches:Ya,log:Ka};var Ag={computeShortCommitHash:Sr,parseGitignoreRules:Qa,isIgnoredByRules:to,isIgnoredScmPath:V,normalizeScmRelPath:X,isUnbornGitHead:Rn,isEffectiveStagedChange:je,syncGitHead:lt,saveBranchTip:rt,createGitState:Ar,readVfsTree:ce,initRepository:Lu,computeGitStatus:eo,stageFile:Gu,stageAll:zu,unstageFile:An,unstageAll:Hu,commitChanges:qu,discardChanges:Wu,computeMyersDiffOps:Me,computeUnifiedHunkDiff:ro,computeGitGutterChanges:Zu,checkoutBranch:Vu,resolveCommitRef:$n,resetToRef:Xu,stashPush:Yu,stashApply:Ku,mergeBranch:Ju,showCommit:Qu,blameFile:td,createIsoGitFsAdapter:On,syncToIsoGitRepo:Nt,hydrateFromIsoGitRepo:ed,isoGit:rd};return fd(Rg);})();
141
141
  /*! Bundled license information:
142
142
 
143
143
  ieee754/index.js:
@@ -179,23 +179,15 @@ isomorphic-git/index.js:
179
179
 
180
180
  if (typeof CodeLabScm !== 'undefined') _root.CodeLabScm = CodeLabScm;
181
181
  (function () {
182
- (function(W,N){const U=N(W);W&&(W.CodeLabShell=U,W.createPosixShell=U.createPosixShell,W.PosixShell=U.PosixShell,W.parseShellCommand=U.parseShellCommand,W.tokenizeShell=U.tokenizeShell,W.COREUTILS=U.COREUTILS,W.createVirtualPortTable=U.createVirtualPortTable,W.parseGitHubRepoUrl=U.parseGitHubRepoUrl,W.cloneGitHubRepository=U.cloneGitHubRepository),typeof module<"u"&&module.exports?module.exports=U:typeof define=="function"&&define.amd&&define([],function(){return U})})(typeof globalThis<"u"?globalThis:this,function(W){"use strict";const N=W&&W.CodeLabLogger&&typeof W.CodeLabLogger.createLogger=="function"?W.CodeLabLogger.createLogger():{debug(){},info(...n){typeof console<"u"&&console.info&&console.info("[code-lab]",...n)},warn(...n){typeof console<"u"&&console.warn&&console.warn("[code-lab]",...n)},error(...n){typeof console<"u"&&console.error&&console.error("[code-lab]",...n)}};function U(){if(typeof W<"u"&&W&&W.CodeLabRuntime)return W.CodeLabRuntime;if(typeof globalThis<"u"&&globalThis.CodeLabRuntime)return globalThis.CodeLabRuntime;try{if(typeof require<"u")return require("./runtime.js")}catch(n){N.debug("Optional ./runtime.js require skipped in shell.",n)}return null}function je(){if(typeof W<"u"&&W&&W.CodeLabScm)return W.CodeLabScm;if(typeof globalThis<"u"&&globalThis.CodeLabScm)return globalThis.CodeLabScm;try{if(typeof require<"u")return require("./scm.js")}catch(n){N.debug("Optional ./scm.js require skipped in shell.",n)}return null}function Re(){const n=U();return!!(n&&typeof n.executeInVirtualRuntime=="function")}function Oe(...n){const e=U();if(e&&typeof e.executeInVirtualRuntime=="function")return e.executeInVirtualRuntime(...n);throw new Error("Virtual runtime engine is not available")}async function q(n,e){const s=U();if(!s||typeof s.executeInVirtualRuntime!="function")throw new Error("Virtual runtime engine is not available");let t=typeof n.replCode=="string"?n.replCode:"";if(!t&&typeof n.entry=="string"&&e&&e.vfs&&typeof e.vfs.existsSync=="function")try{const h=typeof e.resolvePath=="function"?e.resolvePath(n.entry):n.entry,u=e.vfs.existsSync(h)?h:e.vfs.existsSync(n.entry)?n.entry:"";u&&(t=String(e.vfs.readFileSync(u,"utf8")||""))}catch(h){}let r=n.npmModules;const o=new Set(["assert","buffer","child_process","cluster","console","constants","crypto","dgram","diagnostics_channel","dns","domain","events","fs","http","http2","https","inspector","module","net","os","path","perf_hooks","process","punycode","querystring","readline","repl","sqlite","stream","string_decoder","sys","test","timers","tls","tty","url","util","v8","vm","wasi","worker_threads","zlib"]);let i=!1;if(t&&!(n.isBackground||e&&e.isBackground)){const h=/(?:from\s+|require\s*\(\s*)['"]([^./'"]+)['"]/g;let u;for(;(u=h.exec(t))!==null;){const p=u[1];if(p.startsWith("node:")||p.startsWith("bun:"))continue;const g=p.startsWith("@")?p.split("/").slice(0,2).join("/"):p.split("/")[0];if(!o.has(g)){i=!0;break}}}if(i&&typeof s.preloadNpmPackages=="function")try{const h=await s.preloadNpmPackages({[n.entry||"eval.js"]:t});h&&typeof h=="object"&&(r=Object.assign({},h,r||{}))}catch(h){N.debug("preloadNpmPackages skipped in shell:",h)}const f=(e&&typeof e.onRequestStdin=="function"?e.onRequestStdin:null)||(e&&e.shell&&e.shell.options&&typeof e.shell.options.onRequestStdin=="function"?e.shell.options.onRequestStdin:void 0),d=e&&e.shell?e.shell.portTable:null,y=!!(d&&typeof d.listServers=="function"&&d.listServers().length>0),l=!!(n.isBackground||e&&e.isBackground||y||/(?:\bcreateServer\b|\.listen\s*\(|\bBun\.serve\b|\blocalhost\b|127\.0\.0\.1)/.test(t)),a=n.instanceId||(e&&e.shell&&e.shell.options&&e.shell.options.instanceId?e.shell.options.instanceId:void 0),c={...n,...a?{instanceId:a}:{},concurrent:!0,npmModules:r,onRequestStdin:f};if(!l&&typeof Worker<"u"&&typeof s.executeInWorker=="function"){const h={...c};return delete h.activePortTable,delete h.portTable,s.executeInWorker(h)}return s.executeInVirtualRuntime({...c,activePortTable:d})}function le(...n){const e=U();return e&&typeof e.createVirtualPortTable=="function"?e.createVirtualPortTable(...n):null}function Je(n,e){const s=U();return s&&typeof s.transpileTS=="function"?s.transpileTS(n,e):String(n).replace(/^\s*import\s+type\s+[^\n;]+;?\s*$/gm,"").replace(/^\s*export\s+(?:interface|type)\s+[A-Za-z0-9_$]+[\s\S]*?(?:^\}|\n)/gm,"").replace(/^\s*(?:interface|type)\s+[A-Za-z0-9_$]+[^;{]*\{[^}]*\}/gm,"").replace(/:\s*[A-Za-z0-9_$<>\[\]|&\s]+(?=[,=)\n;{])/g,"")}const j={normalize(n){if(typeof n!="string"||!n)return"/";const e=n.startsWith("/"),s=n.split("/").filter(Boolean),t=[];for(const o of s)o!=="."&&(o===".."?t.length>0&&t.pop():t.push(o));return(e?"/":"")+t.join("/")||(e?"/":".")},resolve(n,...e){let s=n.startsWith("/")?n:"/"+n;const t=j._homeDir||"/home/codelab";for(const r of e)r&&(r.startsWith("/")?s=r:r==="~"||r.startsWith("~/")?s=t+r.slice(1):s=s.endsWith("/")?s+r:s+"/"+r);return j.normalize(s)},dirname(n){const e=j.normalize(n);if(e==="/"||e===".")return e;const s=e.lastIndexOf("/");return s===-1?".":s===0?"/":e.slice(0,s)},basename(n,e){const s=j.normalize(n);if(s==="/")return"/";const t=s.lastIndexOf("/");let r=t===-1?s:s.slice(t+1);return e&&r.endsWith(e)&&r!==e&&(r=r.slice(0,-e.length)),r},join(...n){return j.normalize(n.filter(Boolean).join("/"))}};function Pe(n,e=!0){let s="^",t=0;for(;t<n.length;){const r=n[t];if(r==="*"&&n[t+1]==="*"&&(n[t+2]==="/"||t+2===n.length))s+="(?:.+/)?",t+=n[t+2]==="/"?3:2;else if(r==="*"&&n[t+1]==="*")s+=".*",t+=2;else if(r==="*")s+=e?"[^/]*":".*",t++;else if(r==="?")s+=e?"[^/]":".",t++;else if(r==="["){const o=n.indexOf("]",t+1);if(o!==-1){let i=n.slice(t+1,o);i.startsWith("!")&&(i="^"+i.slice(1)),s+="["+i+"]",t=o+1}else s+="\\[",t++}else[".","$","^","+","(",")","{","}","|","\\"].includes(r)?(s+="\\"+r,t++):(s+=r,t++)}return s+="$",new RegExp(s)}function Ee(n){if(typeof n!="string"||!n.includes("{")||!n.includes("}"))return[n];let e=-1,s=-1,t=0;for(let a=0;a<n.length;a++){if(n[a]==="\\"){a++;continue}if(n[a]==="{")t===0&&(e=a),t++;else if(n[a]==="}"&&t>0&&(t--,t===0)){const c=n.slice(e+1,a);if(ae(c)||/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(c)||/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(c)){s=a;break}}}if(e===-1||s===-1)return[n];const r=n.slice(0,e),o=n.slice(e+1,s),i=n.slice(s+1);let f=[];const d=o.match(/^(-?\d+)\.\.(-?\d+)(?:\.\.(-?\d+))?$/),y=o.match(/^([a-zA-Z])\.\.([a-zA-Z])(?:\.\.(-?\d+))?$/);if(d&&!ae(o)){const a=d[1],c=d[2],h=parseInt(a,10),u=parseInt(c,10);let p=d[3]!==void 0?parseInt(d[3],10):h<=u?1:-1;p===0&&(p=1),(h<=u&&p<0||h>u&&p>0)&&(p=-p);const g=a.startsWith("0")&&a.length>1||c.startsWith("0")&&c.length>1?Math.max(a.length,c.length):0;for(let m=h;p>0?m<=u:m>=u;m+=p){let S=String(Math.abs(m));g>0&&(S=S.padStart(g-(m<0?1:0),"0")),f.push(m<0?"-"+S:S)}}else if(y&&!ae(o)){const a=y[1].charCodeAt(0),c=y[2].charCodeAt(0);let h=y[3]!==void 0&&Math.abs(parseInt(y[3],10))||1;a>c&&(h=-h);for(let u=a;h>0?u<=c:u>=c;u+=h)f.push(String.fromCharCode(u))}else f=Ge(o);const l=[];for(const a of f)for(const c of Ee(a))for(const h of Ee(i))l.push(r+c+h);return l}function ae(n){let e=0;for(let s=0;s<n.length;s++){if(n[s]==="\\"){s++;continue}if(n[s]==="{")e++;else if(n[s]==="}")e=Math.max(0,e-1);else if(n[s]===","&&e===0)return!0}return!1}function Ge(n){const e=[];let s="",t=0;for(let r=0;r<n.length;r++){if(n[r]==="\\"&&r+1<n.length){s+=n[r]+n[r+1],r++;continue}n[r]==="{"?(t++,s+=n[r]):n[r]==="}"?(t=Math.max(0,t-1),s+=n[r]):n[r]===","&&t===0?(e.push(s),s=""):s+=n[r]}return e.push(s),e}function ce(n,e={},s=null){const t=String(n||"").trim();if(!t)return 0;const r=[];let o=0;const i=t.length;for(;o<i;){const k=t[o];if(/\s/.test(k)){o++;continue}const O=t.slice(o,o+3);if(O==="<<="||O===">>="){r.push({type:"OP",value:O}),o+=3;continue}const F=t.slice(o,o+2);if(["**","++","--","<<",">>","<=",">=","==","!=","&&","||","+=","-=","*=","/=","%=","&=","^=","|="].includes(F)){r.push({type:"OP",value:F}),o+=2;continue}if("+-*/%<>&|^!~?:=,()".includes(k)){r.push({type:"OP",value:k}),o++;continue}if(k==="$"){o++;let P="";if(t[o]==="{"){for(o++;o<i&&t[o]!=="}";)P+=t[o++];t[o]==="}"&&o++}else for(;o<i&&/[a-zA-Z0-9_?#]/.test(t[o]);)P+=t[o++];const A=e[P]!==void 0?e[P]:s&&s[P]!==void 0?s[P]:"0",M=Number(A);r.push({type:"NUM",value:Number.isFinite(M)?Math.trunc(M):0,name:P});continue}if(/[0-9]/.test(k)){let P="";for(;o<i&&/[0-9a-fA-FxXbBoO_]/.test(t[o]);)t[o]!=="_"&&(P+=t[o]),o++;let A=0;/^0[xX]/.test(P)?A=parseInt(P.slice(2),16)||0:/^0[bB]/.test(P)?A=parseInt(P.slice(2),2)||0:/^0[oO]/.test(P)?A=parseInt(P.slice(2),8)||0:P.length>1&&P.startsWith("0")&&/^[0-7]+$/.test(P)?A=parseInt(P,8)||0:A=parseInt(P,10)||0,r.push({type:"NUM",value:A});continue}if(/[a-zA-Z_]/.test(k)){let P="";for(;o<i&&/[a-zA-Z0-9_]/.test(t[o]);)P+=t[o++];r.push({type:"IDENT",name:P});continue}o++}let f=0;const d=()=>r[f]||null,y=()=>r[f++]||null;function l(k){const O=e[k]!==void 0?e[k]:s&&s[k]!==void 0?s[k]:0,F=Number(O);return Number.isFinite(F)?Math.trunc(F):0}function a(k,O){const F=Math.trunc(Number(O)||0);return e[k]=String(F),s&&(s[k]=String(F)),F}function c(){let k=h();for(;d()&&d().type==="OP"&&d().value===",";)y(),k=h();return k}function h(){if(d()&&(d().type==="IDENT"||d().type==="NUM"&&d().name)){const k=r[f+1];if(k&&k.type==="OP"&&["=","+=","-=","*=","/=","%=","<<=",">>=","&=","^=","|="].includes(k.value)){const O=y().name,F=y().value,P=h(),A=l(O);if(F==="=")return a(O,P);if(F==="+=")return a(O,A+P);if(F==="-=")return a(O,A-P);if(F==="*=")return a(O,A*P);if(F==="/=")return a(O,P===0?0:Math.trunc(A/P));if(F==="%=")return a(O,P===0?0:A%P);if(F==="<<=")return a(O,A<<P);if(F===">>=")return a(O,A>>P);if(F==="&=")return a(O,A&P);if(F==="^=")return a(O,A^P);if(F==="|=")return a(O,A|P)}}return u()}function u(){const k=p();if(d()&&d().type==="OP"&&d().value==="?"){y();const O=h();d()&&d().type==="OP"&&d().value===":"&&y();const F=h();return k!==0?O:F}return k}function p(){let k=g();for(;d()&&d().type==="OP"&&d().value==="||";){y();const O=g();k=k!==0||O!==0?1:0}return k}function g(){let k=m();for(;d()&&d().type==="OP"&&d().value==="&&";){y();const O=m();k=k!==0&&O!==0?1:0}return k}function m(){let k=S();for(;d()&&d().type==="OP"&&d().value==="|";)y(),k=k|S();return k}function S(){let k=b();for(;d()&&d().type==="OP"&&d().value==="^";)y(),k=k^b();return k}function b(){let k=v();for(;d()&&d().type==="OP"&&d().value==="&";)y(),k=k&v();return k}function v(){let k=w();for(;d()&&d().type==="OP"&&(d().value==="=="||d().value==="!=");){const O=y().value,F=w();k=O==="=="?k===F?1:0:k!==F?1:0}return k}function w(){let k=$();for(;d()&&d().type==="OP"&&["<","<=",">",">="].includes(d().value);){const O=y().value,F=$();O==="<"?k=k<F?1:0:O==="<="?k=k<=F?1:0:O===">"?k=k>F?1:0:O===">="&&(k=k>=F?1:0)}return k}function $(){let k=R();for(;d()&&d().type==="OP"&&(d().value==="<<"||d().value===">>");){const O=y().value,F=R();k=O==="<<"?k<<F:k>>F}return k}function R(){let k=I();for(;d()&&d().type==="OP"&&(d().value==="+"||d().value==="-");){const O=y().value,F=I();k=O==="+"?k+F:k-F}return k}function I(){let k=C();for(;d()&&d().type==="OP"&&["*","/","%"].includes(d().value);){const O=y().value,F=C();O==="*"?k=k*F:O==="/"?k=F===0?0:Math.trunc(k/F):O==="%"&&(k=F===0?0:k%F)}return k}function C(){const k=E();if(d()&&d().type==="OP"&&d().value==="**"){y();const O=C();return Math.trunc(Math.pow(k,O))}return k}function E(){const k=d();if(k&&k.type==="OP"){if(k.value==="+")return y(),+E();if(k.value==="-")return y(),-E();if(k.value==="!")return y(),E()===0?1:0;if(k.value==="~")return y(),~E();if(k.value==="++"||k.value==="--"){const O=y().value,F=d();if(F&&(F.type==="IDENT"||F.name)){y();const P=l(F.name);return a(F.name,O==="++"?P+1:P-1)}return E()}}return T()}function T(){const k=d();if(!k)return 0;if(k.type==="OP"&&k.value==="("){y();const O=c();return d()&&d().type==="OP"&&d().value===")"&&y(),O}if(k.type==="IDENT"){y();const O=l(k.name);if(d()&&d().type==="OP"&&(d().value==="++"||d().value==="--")){const F=y().value;a(k.name,F==="++"?O+1:O-1)}return O}if(k.type==="NUM"){if(y(),k.name&&d()&&d().type==="OP"&&(d().value==="++"||d().value==="--")){const O=y().value;a(k.name,O==="++"?k.value+1:k.value-1)}return k.value}return y(),0}return Math.trunc(c()||0)}function Fe(n,e,s){if(!s)return[n];if(!/[*?\[]/.test(n))return[n];const t=n.startsWith("/"),r=t?"/":e,o=[];function i(l,a){let c=[];try{typeof s.readdirSync=="function"&&(c=s.readdirSync(l))}catch{return}for(const h of c){const u=l==="/"?"/"+h:l+"/"+h,p=a?a+"/"+h:h;o.push({full:u,rel:p});let g=!1;try{typeof s.statSync=="function"&&(g=s.statSync(u).isDirectory())}catch(m){N.debug("Glob statSync failed.",u,m)}g&&i(u,p)}}i(r,"");const f=t?n:n.startsWith("./")?n.slice(2):n,d=Pe(f,!0),y=[];for(const l of o){const a=t?l.full:l.rel;if(d.test(a)){const c=a.split("/").filter(Boolean),h=f.split("/").filter(Boolean);let u=!1;for(let p=0;p<c.length;p++){const g=c[p],m=h[p]!==void 0?h[p]:h[h.length-1];if(g&&g.startsWith(".")&&m&&!m.startsWith(".")){u=!0;break}}u||y.push(t?l.full:n.startsWith("./")?"./"+l.rel:l.rel)}}return y.sort(),y.length>0?y:[n]}function Te(n){if(typeof n!="string")return[];const e=[],s=n.length;let t=0,r=-1;for(;t<s;){const o=n[t];if(o===`
182
+ (function(W,_){const U=_(W);W&&(W.CodeLabShell=U,W.createPosixShell=U.createPosixShell,W.PosixShell=U.PosixShell,W.parseShellCommand=U.parseShellCommand,W.tokenizeShell=U.tokenizeShell,W.COREUTILS=U.COREUTILS,W.createVirtualPortTable=U.createVirtualPortTable,W.parseGitHubRepoUrl=U.parseGitHubRepoUrl,W.cloneGitHubRepository=U.cloneGitHubRepository),typeof module<"u"&&module.exports?module.exports=U:typeof define=="function"&&define.amd&&define([],function(){return U})})(typeof globalThis<"u"?globalThis:this,function(W){"use strict";const _=W&&W.CodeLabLogger&&typeof W.CodeLabLogger.createLogger=="function"?W.CodeLabLogger.createLogger():{debug(){},info(...n){typeof console<"u"&&console.info&&console.info("[code-lab]",...n)},warn(...n){typeof console<"u"&&console.warn&&console.warn("[code-lab]",...n)},error(...n){typeof console<"u"&&console.error&&console.error("[code-lab]",...n)}};function U(){if(typeof W<"u"&&W&&W.CodeLabRuntime)return W.CodeLabRuntime;if(typeof globalThis<"u"&&globalThis.CodeLabRuntime)return globalThis.CodeLabRuntime;try{if(typeof require<"u")return require("./runtime.js")}catch(n){_.debug("Optional ./runtime.js require skipped in shell.",n)}return null}function je(){if(typeof W<"u"&&W&&W.CodeLabScm)return W.CodeLabScm;if(typeof globalThis<"u"&&globalThis.CodeLabScm)return globalThis.CodeLabScm;try{if(typeof require<"u")return require("./scm.js")}catch(n){_.debug("Optional ./scm.js require skipped in shell.",n)}return null}function Re(){const n=U();return!!(n&&typeof n.executeInVirtualRuntime=="function")}function Oe(...n){const e=U();if(e&&typeof e.executeInVirtualRuntime=="function")return e.executeInVirtualRuntime(...n);throw new Error("Virtual runtime engine is not available")}async function q(n,e){const s=U();if(!s||typeof s.executeInVirtualRuntime!="function")throw new Error("Virtual runtime engine is not available");let t=typeof n.replCode=="string"?n.replCode:"";if(!t&&typeof n.entry=="string"&&e&&e.vfs&&typeof e.vfs.existsSync=="function")try{const u=typeof e.resolvePath=="function"?e.resolvePath(n.entry):n.entry,h=e.vfs.existsSync(u)?u:e.vfs.existsSync(n.entry)?n.entry:"";h&&(t=String(e.vfs.readFileSync(h,"utf8")||""))}catch(u){}let r=n.npmModules;const o=new Set(["assert","buffer","child_process","cluster","console","constants","crypto","dgram","diagnostics_channel","dns","domain","events","fs","http","http2","https","inspector","module","net","os","path","perf_hooks","process","punycode","querystring","readline","repl","sqlite","stream","string_decoder","sys","test","timers","tls","tty","url","util","v8","vm","wasi","worker_threads","zlib"]);let i=!1;if(t&&!(n.isBackground||e&&e.isBackground)){const u=/(?:from\s+|require\s*\(\s*)['"]([^./'"]+)['"]/g;let h;for(;(h=u.exec(t))!==null;){const p=h[1];if(p.startsWith("node:")||p.startsWith("bun:"))continue;const g=p.startsWith("@")?p.split("/").slice(0,2).join("/"):p.split("/")[0];if(!o.has(g)){i=!0;break}}}if(i&&typeof s.preloadNpmPackages=="function")try{const u=await s.preloadNpmPackages({[n.entry||"eval.js"]:t});u&&typeof u=="object"&&(r=Object.assign({},u,r||{}))}catch(u){_.debug("preloadNpmPackages skipped in shell:",u)}const f=(e&&typeof e.onRequestStdin=="function"?e.onRequestStdin:null)||(e&&e.shell&&e.shell.options&&typeof e.shell.options.onRequestStdin=="function"?e.shell.options.onRequestStdin:void 0),a=e&&e.shell?e.shell.portTable:null,y=!!(a&&typeof a.listServers=="function"&&a.listServers().length>0),l=!!(n.isBackground||e&&e.isBackground||y||/(?:\bcreateServer\b|\.listen\s*\(|\bBun\.serve\b|\blocalhost\b|127\.0\.0\.1)/.test(t)),c=n.instanceId||(e&&e.shell&&e.shell.options&&e.shell.options.instanceId?e.shell.options.instanceId:void 0),d={...n,...c?{instanceId:c}:{},concurrent:!0,npmModules:r,onRequestStdin:f};if(!l&&typeof Worker<"u"&&typeof s.executeInWorker=="function"){const u={...d};return delete u.activePortTable,delete u.portTable,s.executeInWorker(u)}return s.executeInVirtualRuntime({...d,activePortTable:a})}function le(...n){const e=U();return e&&typeof e.createVirtualPortTable=="function"?e.createVirtualPortTable(...n):null}function Ve(n,e){const s=U();return s&&typeof s.transpileTS=="function"?s.transpileTS(n,e):String(n).replace(/^\s*import\s+type\s+[^\n;]+;?\s*$/gm,"").replace(/^\s*export\s+(?:interface|type)\s+[A-Za-z0-9_$]+[\s\S]*?(?:^\}|\n)/gm,"").replace(/^\s*(?:interface|type)\s+[A-Za-z0-9_$]+[^;{]*\{[^}]*\}/gm,"").replace(/:\s*[A-Za-z0-9_$<>\[\]|&\s]+(?=[,=)\n;{])/g,"")}const j={normalize(n){if(typeof n!="string"||!n)return"/";const e=n.startsWith("/"),s=n.split("/").filter(Boolean),t=[];for(const o of s)o!=="."&&(o===".."?t.length>0&&t.pop():t.push(o));return(e?"/":"")+t.join("/")||(e?"/":".")},resolve(n,...e){let s=n.startsWith("/")?n:"/"+n;const t=j._homeDir||"/home/codelab";for(const r of e)r&&(r.startsWith("/")?s=r:r==="~"||r.startsWith("~/")?s=t+r.slice(1):s=s.endsWith("/")?s+r:s+"/"+r);return j.normalize(s)},dirname(n){const e=j.normalize(n);if(e==="/"||e===".")return e;const s=e.lastIndexOf("/");return s===-1?".":s===0?"/":e.slice(0,s)},basename(n,e){const s=j.normalize(n);if(s==="/")return"/";const t=s.lastIndexOf("/");let r=t===-1?s:s.slice(t+1);return e&&r.endsWith(e)&&r!==e&&(r=r.slice(0,-e.length)),r},join(...n){return j.normalize(n.filter(Boolean).join("/"))}};function Pe(n,e=!0){let s="^",t=0;for(;t<n.length;){const r=n[t];if(r==="*"&&n[t+1]==="*"&&(n[t+2]==="/"||t+2===n.length))s+="(?:.+/)?",t+=n[t+2]==="/"?3:2;else if(r==="*"&&n[t+1]==="*")s+=".*",t+=2;else if(r==="*")s+=e?"[^/]*":".*",t++;else if(r==="?")s+=e?"[^/]":".",t++;else if(r==="["){const o=n.indexOf("]",t+1);if(o!==-1){let i=n.slice(t+1,o);i.startsWith("!")&&(i="^"+i.slice(1)),s+="["+i+"]",t=o+1}else s+="\\[",t++}else[".","$","^","+","(",")","{","}","|","\\"].includes(r)?(s+="\\"+r,t++):(s+=r,t++)}return s+="$",new RegExp(s)}function Ee(n){if(typeof n!="string"||!n.includes("{")||!n.includes("}"))return[n];let e=-1,s=-1,t=0;for(let c=0;c<n.length;c++){if(n[c]==="\\"){c++;continue}if(n[c]==="{")t===0&&(e=c),t++;else if(n[c]==="}"&&t>0&&(t--,t===0)){const d=n.slice(e+1,c);if(ae(d)||/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(d)||/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(d)){s=c;break}}}if(e===-1||s===-1)return[n];const r=n.slice(0,e),o=n.slice(e+1,s),i=n.slice(s+1);let f=[];const a=o.match(/^(-?\d+)\.\.(-?\d+)(?:\.\.(-?\d+))?$/),y=o.match(/^([a-zA-Z])\.\.([a-zA-Z])(?:\.\.(-?\d+))?$/);if(a&&!ae(o)){const c=a[1],d=a[2],u=parseInt(c,10),h=parseInt(d,10);let p=a[3]!==void 0?parseInt(a[3],10):u<=h?1:-1;p===0&&(p=1),(u<=h&&p<0||u>h&&p>0)&&(p=-p);const g=c.startsWith("0")&&c.length>1||d.startsWith("0")&&d.length>1?Math.max(c.length,d.length):0;for(let m=u;p>0?m<=h:m>=h;m+=p){let S=String(Math.abs(m));g>0&&(S=S.padStart(g-(m<0?1:0),"0")),f.push(m<0?"-"+S:S)}}else if(y&&!ae(o)){const c=y[1].charCodeAt(0),d=y[2].charCodeAt(0);let u=y[3]!==void 0&&Math.abs(parseInt(y[3],10))||1;c>d&&(u=-u);for(let h=c;u>0?h<=d:h>=d;h+=u)f.push(String.fromCharCode(h))}else f=Je(o);const l=[];for(const c of f)for(const d of Ee(c))for(const u of Ee(i))l.push(r+d+u);return l}function ae(n){let e=0;for(let s=0;s<n.length;s++){if(n[s]==="\\"){s++;continue}if(n[s]==="{")e++;else if(n[s]==="}")e=Math.max(0,e-1);else if(n[s]===","&&e===0)return!0}return!1}function Je(n){const e=[];let s="",t=0;for(let r=0;r<n.length;r++){if(n[r]==="\\"&&r+1<n.length){s+=n[r]+n[r+1],r++;continue}n[r]==="{"?(t++,s+=n[r]):n[r]==="}"?(t=Math.max(0,t-1),s+=n[r]):n[r]===","&&t===0?(e.push(s),s=""):s+=n[r]}return e.push(s),e}function ce(n,e={},s=null){const t=String(n||"").trim();if(!t)return 0;const r=[];let o=0;const i=t.length;for(;o<i;){const k=t[o];if(/\s/.test(k)){o++;continue}const O=t.slice(o,o+3);if(O==="<<="||O===">>="){r.push({type:"OP",value:O}),o+=3;continue}const F=t.slice(o,o+2);if(["**","++","--","<<",">>","<=",">=","==","!=","&&","||","+=","-=","*=","/=","%=","&=","^=","|="].includes(F)){r.push({type:"OP",value:F}),o+=2;continue}if("+-*/%<>&|^!~?:=,()".includes(k)){r.push({type:"OP",value:k}),o++;continue}if(k==="$"){o++;let P="";if(t[o]==="{"){for(o++;o<i&&t[o]!=="}";)P+=t[o++];t[o]==="}"&&o++}else for(;o<i&&/[a-zA-Z0-9_?#]/.test(t[o]);)P+=t[o++];const A=e[P]!==void 0?e[P]:s&&s[P]!==void 0?s[P]:"0",M=Number(A);r.push({type:"NUM",value:Number.isFinite(M)?Math.trunc(M):0,name:P});continue}if(/[0-9]/.test(k)){let P="";for(;o<i&&/[0-9a-fA-FxXbBoO_]/.test(t[o]);)t[o]!=="_"&&(P+=t[o]),o++;let A=0;/^0[xX]/.test(P)?A=parseInt(P.slice(2),16)||0:/^0[bB]/.test(P)?A=parseInt(P.slice(2),2)||0:/^0[oO]/.test(P)?A=parseInt(P.slice(2),8)||0:P.length>1&&P.startsWith("0")&&/^[0-7]+$/.test(P)?A=parseInt(P,8)||0:A=parseInt(P,10)||0,r.push({type:"NUM",value:A});continue}if(/[a-zA-Z_]/.test(k)){let P="";for(;o<i&&/[a-zA-Z0-9_]/.test(t[o]);)P+=t[o++];r.push({type:"IDENT",name:P});continue}o++}let f=0;const a=()=>r[f]||null,y=()=>r[f++]||null;function l(k){const O=e[k]!==void 0?e[k]:s&&s[k]!==void 0?s[k]:0,F=Number(O);return Number.isFinite(F)?Math.trunc(F):0}function c(k,O){const F=Math.trunc(Number(O)||0);return e[k]=String(F),s&&(s[k]=String(F)),F}function d(){let k=u();for(;a()&&a().type==="OP"&&a().value===",";)y(),k=u();return k}function u(){if(a()&&(a().type==="IDENT"||a().type==="NUM"&&a().name)){const k=r[f+1];if(k&&k.type==="OP"&&["=","+=","-=","*=","/=","%=","<<=",">>=","&=","^=","|="].includes(k.value)){const O=y().name,F=y().value,P=u(),A=l(O);if(F==="=")return c(O,P);if(F==="+=")return c(O,A+P);if(F==="-=")return c(O,A-P);if(F==="*=")return c(O,A*P);if(F==="/=")return c(O,P===0?0:Math.trunc(A/P));if(F==="%=")return c(O,P===0?0:A%P);if(F==="<<=")return c(O,A<<P);if(F===">>=")return c(O,A>>P);if(F==="&=")return c(O,A&P);if(F==="^=")return c(O,A^P);if(F==="|=")return c(O,A|P)}}return h()}function h(){const k=p();if(a()&&a().type==="OP"&&a().value==="?"){y();const O=u();a()&&a().type==="OP"&&a().value===":"&&y();const F=u();return k!==0?O:F}return k}function p(){let k=g();for(;a()&&a().type==="OP"&&a().value==="||";){y();const O=g();k=k!==0||O!==0?1:0}return k}function g(){let k=m();for(;a()&&a().type==="OP"&&a().value==="&&";){y();const O=m();k=k!==0&&O!==0?1:0}return k}function m(){let k=S();for(;a()&&a().type==="OP"&&a().value==="|";)y(),k=k|S();return k}function S(){let k=b();for(;a()&&a().type==="OP"&&a().value==="^";)y(),k=k^b();return k}function b(){let k=v();for(;a()&&a().type==="OP"&&a().value==="&";)y(),k=k&v();return k}function v(){let k=w();for(;a()&&a().type==="OP"&&(a().value==="=="||a().value==="!=");){const O=y().value,F=w();k=O==="=="?k===F?1:0:k!==F?1:0}return k}function w(){let k=$();for(;a()&&a().type==="OP"&&["<","<=",">",">="].includes(a().value);){const O=y().value,F=$();O==="<"?k=k<F?1:0:O==="<="?k=k<=F?1:0:O===">"?k=k>F?1:0:O===">="&&(k=k>=F?1:0)}return k}function $(){let k=R();for(;a()&&a().type==="OP"&&(a().value==="<<"||a().value===">>");){const O=y().value,F=R();k=O==="<<"?k<<F:k>>F}return k}function R(){let k=I();for(;a()&&a().type==="OP"&&(a().value==="+"||a().value==="-");){const O=y().value,F=I();k=O==="+"?k+F:k-F}return k}function I(){let k=C();for(;a()&&a().type==="OP"&&["*","/","%"].includes(a().value);){const O=y().value,F=C();O==="*"?k=k*F:O==="/"?k=F===0?0:Math.trunc(k/F):O==="%"&&(k=F===0?0:k%F)}return k}function C(){const k=E();if(a()&&a().type==="OP"&&a().value==="**"){y();const O=C();return Math.trunc(Math.pow(k,O))}return k}function E(){const k=a();if(k&&k.type==="OP"){if(k.value==="+")return y(),+E();if(k.value==="-")return y(),-E();if(k.value==="!")return y(),E()===0?1:0;if(k.value==="~")return y(),~E();if(k.value==="++"||k.value==="--"){const O=y().value,F=a();if(F&&(F.type==="IDENT"||F.name)){y();const P=l(F.name);return c(F.name,O==="++"?P+1:P-1)}return E()}}return T()}function T(){const k=a();if(!k)return 0;if(k.type==="OP"&&k.value==="("){y();const O=d();return a()&&a().type==="OP"&&a().value===")"&&y(),O}if(k.type==="IDENT"){y();const O=l(k.name);if(a()&&a().type==="OP"&&(a().value==="++"||a().value==="--")){const F=y().value;c(k.name,F==="++"?O+1:O-1)}return O}if(k.type==="NUM"){if(y(),k.name&&a()&&a().type==="OP"&&(a().value==="++"||a().value==="--")){const O=y().value;c(k.name,O==="++"?k.value+1:k.value-1)}return k.value}return y(),0}return Math.trunc(d()||0)}function Fe(n,e,s){if(!s)return[n];if(!/[*?\[]/.test(n))return[n];const t=n.startsWith("/"),r=t?"/":e,o=[];function i(l,c){let d=[];try{typeof s.readdirSync=="function"&&(d=s.readdirSync(l))}catch{return}for(const u of d){const h=l==="/"?"/"+u:l+"/"+u,p=c?c+"/"+u:u;o.push({full:h,rel:p});let g=!1;try{typeof s.statSync=="function"&&(g=s.statSync(h).isDirectory())}catch(m){_.debug("Glob statSync failed.",h,m)}g&&i(h,p)}}i(r,"");const f=t?n:n.startsWith("./")?n.slice(2):n,a=Pe(f,!0),y=[];for(const l of o){const c=t?l.full:l.rel;if(a.test(c)){const d=c.split("/").filter(Boolean),u=f.split("/").filter(Boolean);let h=!1;for(let p=0;p<d.length;p++){const g=d[p],m=u[p]!==void 0?u[p]:u[u.length-1];if(g&&g.startsWith(".")&&m&&!m.startsWith(".")){h=!0;break}}h||y.push(t?l.full:n.startsWith("./")?"./"+l.rel:l.rel)}}return y.sort(),y.length>0?y:[n]}function Te(n){if(typeof n!="string")return[];const e=[],s=n.length;let t=0,r=-1;for(;t<s;){const o=n[t];if(o===`
183
183
  `){if(r>t?(t=r,r=-1):t++,e.length>0){const l=e[e.length-1].type;l!=="SEMICOLON"&&l!=="DSEMI"&&l!=="AND"&&l!=="OR"&&l!=="PIPE"&&l!=="LPAREN"&&e.push({type:"SEMICOLON",raw:";"})}continue}if(/[ \t\r\f\v]/.test(o)){t++;continue}if(o==="#"){for(;t<s&&n[t]!==`
184
- `;)t++;continue}if(o===";"&&n[t+1]===";"){e.push({type:"DSEMI",raw:";;"}),t+=2;continue}if(o===";"){e.push({type:"SEMICOLON",raw:";"}),t++;continue}if(o==="("){e.push({type:"LPAREN",raw:"("}),t++;continue}if(o===")"){e.push({type:"RPAREN",raw:")"}),t++;continue}if(o==="&"&&n[t+1]==="&"){e.push({type:"AND",raw:"&&"}),t+=2;continue}if(o==="|"&&n[t+1]==="|"){e.push({type:"OR",raw:"||"}),t+=2;continue}if(o==="|"){e.push({type:"PIPE",raw:"|"}),t++;continue}if(o==="&"&&n[t+1]===">"){e.push({type:"REDIRECT",op:"&>",sourceFd:"all",raw:"&>"}),t+=2;continue}if(o==="&"){e.push({type:"BACKGROUND",raw:"&"}),t++;continue}if((o==="1"||o==="2"||o==="0")&&(n[t+1]===">"||n[t+1]==="<")){const l=parseInt(o,10),a=n[t+1];if(a===">"&&n[t+2]==="&"&&(n[t+3]==="1"||n[t+3]==="2")){const c=parseInt(n[t+3],10);e.push({type:"REDIRECT_FD",sourceFd:l,targetFd:c,raw:`${l}>&${c}`}),t+=4;continue}if(a===">"&&n[t+2]===">"){e.push({type:"REDIRECT",op:">>",sourceFd:l,raw:`${l}>>`}),t+=3;continue}e.push({type:"REDIRECT",op:a,sourceFd:l,raw:`${l}${a}`}),t+=2;continue}if(o===">"){if(n[t+1]==="&"&&(n[t+2]==="1"||n[t+2]==="2")){const l=parseInt(n[t+2],10);e.push({type:"REDIRECT_FD",sourceFd:1,targetFd:l,raw:`>&${l}`}),t+=3;continue}if(n[t+1]===">"){e.push({type:"REDIRECT",op:">>",sourceFd:1,raw:">>"}),t+=2;continue}e.push({type:"REDIRECT",op:">",sourceFd:1,raw:">"}),t++;continue}if(o==="<"){if(n[t+1]==="<"&&n[t+2]==="<"){e.push({type:"REDIRECT",op:"<<<",sourceFd:0,raw:"<<<"}),t+=3;continue}if(n[t+1]==="<"){const l=n[t+2]==="-";for(t+=l?3:2;t<s&&(n[t]===" "||n[t]===" ");)t++;let a="",c=!1;for(;t<s&&!/[\s;|&<>()]/.test(n[t]);)if(n[t]==="'"||n[t]==='"'){const p=n[t++];for(c=!0;t<s&&n[t]!==p;)a+=n[t++];t<s&&n[t]===p&&t++}else n[t]==="\\"&&t+1<s&&(c=!0,t++),a+=n[t++];const h=r>t?r:n.indexOf(`
185
- `,t);let u="";if(h!==-1&&h<s){let p=h+1;for(;p<=s;){let g=n.indexOf(`
186
- `,p);g===-1&&(g=s);const m=n.slice(p,g).replace(/\r$/,"");if((l?m.replace(/^\t+/,""):m)===a){r=g<s?g+1:s;break}if(u+=(l?m.replace(/^\t+/,""):m)+`
187
- `,g===s){r=s;break}p=g+1}}e.push({type:"REDIRECT",op:"<<",sourceFd:0,stripTabs:l,quoted:c,body:u,delim:a,raw:l?"<<-":"<<"});continue}e.push({type:"REDIRECT",op:"<",sourceFd:0,raw:"<"}),t++;continue}const i=[];let f="",d=!1,y=!1;for(;t<s;){const l=n[t];if(/\s/.test(l)||l==="|"||l==="&"||l===";"||l==="<"||l===">"||l==="("||l===")")break;if(l==="'"){t++;let a="";for(;t<s&&n[t]!=="'";)a+=n[t],t++;t<s&&n[t]==="'"&&t++,i.push({type:"single_quoted",value:a}),f+=`'${a}'`;continue}if(l==='"'){const a=t;t++;const c=[];let h="";for(;t<s&&n[t]!=='"';){const u=n[t];if(u==="\\"&&t+1<s){const p=n[t+1];if(p==='"'||p==="\\"||p==="$"||p==="`"){h+=p,t+=2;continue}if(p==="n"){h+=`
188
- `,t+=2;continue}if(p==="t"){h+=" ",t+=2;continue}h+="\\"+p,t+=2;continue}if(u==="$"&&n[t+1]==="("&&n[t+2]==="("){h&&(c.push({type:"literal",value:h}),h=""),t+=3;let p=2,g="";for(;t<s&&p>0;)if(n[t]==="(")p++,g+="(",t++;else if(n[t]===")"){if(p===2&&n[t+1]===")"){p=0,t+=2;break}p--,p>0&&(g+=")"),t++}else g+=n[t++];c.push({type:"arith",expr:g});continue}if(u==="$"&&n[t+1]==="("){h&&(c.push({type:"literal",value:h}),h=""),t+=2;let p=1,g="";for(;t<s&&p>0;)n[t]==="("?p++:n[t]===")"&&p--,p>0&&(g+=n[t]),t++;c.push({type:"subshell",command:g});continue}if(u==="`"){h&&(c.push({type:"literal",value:h}),h=""),t++;let p="";for(;t<s&&n[t]!=="`";)p+=n[t++];t<s&&n[t]==="`"&&t++,c.push({type:"subshell",command:p});continue}if(u==="$"){if(h&&(c.push({type:"literal",value:h}),h=""),t++,n[t]==="{"){t++;let p="",g=1;for(;t<s&&g>0;)n[t]==="{"?g++:n[t]==="}"&&g--,g>0&&(p+=n[t]),t++;c.push({type:"variable",name:p})}else if(/[0-9?!$#@*]/.test(n[t])){const p=n[t++];c.push({type:"variable",name:p})}else if(/[a-zA-Z_]/.test(n[t])){let p="";for(;t<s&&/[a-zA-Z0-9_]/.test(n[t]);)p+=n[t++];c.push({type:"variable",name:p})}else h+="$";continue}h+=u,t++}t<s&&n[t]==='"'&&t++,h&&c.push({type:"literal",value:h}),i.push({type:"double_quoted",parts:c}),f+=n.slice(a,t);continue}if(l==="\\"&&t+1<s){i.push({type:"literal",value:n[t+1],escaped:!0}),f+="\\"+n[t+1],t+=2;continue}if(l==="$"&&n[t+1]==="("&&n[t+2]==="("){t+=3;let a=2,c="";for(;t<s&&a>0;)if(n[t]==="(")a++,c+="(",t++;else if(n[t]===")"){if(a===2&&n[t+1]===")"){a=0,t+=2;break}a--,a>0&&(c+=")"),t++}else c+=n[t++];i.push({type:"arith",expr:c}),f+=`$((${c}))`;continue}if(l==="$"&&n[t+1]==="("){t+=2;let a=1,c="";for(;t<s&&a>0;)n[t]==="("?a++:n[t]===")"&&a--,a>0&&(c+=n[t]),t++;i.push({type:"subshell",command:c}),f+=`$(${c})`;continue}if(l==="`"){t++;let a="";for(;t<s&&n[t]!=="`";)a+=n[t],t++;t<s&&n[t]==="`"&&t++,i.push({type:"subshell",command:a}),f+=`\`${a}\``;continue}if(l==="$"){if(t++,n[t]==="{"){t++;let a="",c=1;for(;t<s&&c>0;)n[t]==="{"?c++:n[t]==="}"&&c--,c>0&&(a+=n[t]),t++;i.push({type:"variable",name:a}),f+=`\${${a}}`}else if(/[0-9?!$#@*]/.test(n[t])){const a=n[t++];i.push({type:"variable",name:a}),f+=`$${a}`}else if(/[a-zA-Z_]/.test(n[t])){let a="";for(;t<s&&/[a-zA-Z0-9_]/.test(n[t]);)a+=n[t++];i.push({type:"variable",name:a}),f+=`$${a}`}else i.push({type:"literal",value:"$"}),f+="$";continue}(l==="*"||l==="?"||l==="[")&&(d=!0),(l==="{"||l==="}")&&(y=!0),i.push({type:"literal",value:l}),f+=l,t++}e.push({type:"WORD",segments:i,raw:f,hasWildcard:d,hasBraces:y})}return e}function Ce(n){const e=typeof n=="string"?Te(n):n;let s=0;function t(){return e[s]||null}function r(){return e[s++]||null}function o(c,...h){return!!(c&&c.type==="WORD"&&h.includes(c.raw))}function i(){for(;t()&&t().type==="SEMICOLON";)r()}function f(c=[]){const h=[];for(;s<e.length;){i();const u=t();if(!u||u.type==="RPAREN"||u.type==="DSEMI"||c.length>0&&o(u,...c))break;const p=d(c);if(!p)break;let g=!1;t()&&t().type==="BACKGROUND"?(r(),g=!0):t()&&t().type==="SEMICOLON"&&r(),h.push({node:p,background:g})}return{type:"Sequence",items:h}}function d(c=[]){let h=y(c);if(!h)return null;for(;t()&&(t().type==="AND"||t().type==="OR");){const u=r();i();const p=y(c);if(!p)break;h={type:"Logical",op:u.type==="AND"?"&&":"||",left:h,right:p}}return h}function y(c=[]){let h=!1;o(t(),"!")&&(r(),h=!0);const u=[],p=a(c);if(!p)return null;for(u.push(p);t()&&t().type==="PIPE";){r(),i();const g=a(c);g&&u.push(g)}return u.length===1&&!h?u[0]:{type:"Pipeline",negated:h,commands:u}}function l(){const c=[];for(;t()&&(t().type==="REDIRECT"||t().type==="REDIRECT_FD");){const h=r();if(h.type==="REDIRECT")if(h.op==="<<")c.push({type:"<<",sourceFd:h.sourceFd,body:h.body,quoted:h.quoted,stripTabs:h.stripTabs});else{let u=null;t()&&t().type==="WORD"&&(u=r()),c.push({type:h.op,sourceFd:h.sourceFd,target:u})}else c.push({type:">&",sourceFd:h.sourceFd,targetFd:h.targetFd})}return c}function a(c=[]){const h=t();if(!h||h.type==="RPAREN"||h.type==="DSEMI"||c.length>0&&o(h,...c))return null;if(h.type==="LPAREN"){r();const m=f([]);return t()&&t().type==="RPAREN"&&r(),{type:"Subshell",body:m,redirects:l()}}if(o(h,"{")){r();const m=f(["}"]);return o(t(),"}")&&r(),{type:"BraceGroup",body:m,redirects:l()}}if(o(h,"if")){r();const m=[],S=f(["then"]);o(t(),"then")&&r();const b=f(["elif","else","fi"]);for(m.push({cond:S,body:b});o(t(),"elif");){r();const w=f(["then"]);o(t(),"then")&&r();const $=f(["elif","else","fi"]);m.push({cond:w,body:$})}let v=null;return o(t(),"else")&&(r(),v=f(["fi"])),o(t(),"fi")&&r(),{type:"If",branches:m,elseBody:v,redirects:l()}}if(o(h,"for")){r();const m=r(),S=m?m.raw:"i";let b=null;if(o(t(),"in"))for(r(),b=[];t()&&t().type==="WORD"&&!o(t(),"do");)b.push(r());i(),o(t(),"do")&&r();const v=f(["done"]);return o(t(),"done")&&r(),{type:"For",varName:S,items:b,body:v,redirects:l()}}if(o(h,"while","until")){const m=r().raw,S=f(["do"]);o(t(),"do")&&r();const b=f(["done"]);return o(t(),"done")&&r(),{type:m==="while"?"While":"Until",cond:S,body:b,redirects:l()}}if(o(h,"case")){r();const m=r();i(),o(t(),"in")&&r(),i();const S=[];for(;s<e.length&&!o(t(),"esac")&&(i(),!o(t(),"esac"));){t()&&t().type==="LPAREN"&&r();const b=[];for(;s<e.length&&t().type!=="RPAREN"&&!o(t(),"esac");){if(t().type==="PIPE"){r();continue}b.push(r())}t()&&t().type==="RPAREN"&&r();const v=f(["esac"]);t()&&t().type==="DSEMI"&&r(),i(),S.push({patterns:b,body:v})}return o(t(),"esac")&&r(),{type:"Case",word:m,clauses:S,redirects:l()}}if(o(h,"function")){r();const m=r(),S=m?m.raw:"";t()&&t().type==="LPAREN"&&(r(),t()&&t().type==="RPAREN"&&r()),i();const b=a(c);return{type:"FunctionDef",name:S,body:b}}if(h.type==="WORD"&&e[s+1]&&e[s+1].type==="LPAREN"&&e[s+2]&&e[s+2].type==="RPAREN"){const m=r().raw;r(),r(),i();const S=a(c);return{type:"FunctionDef",name:m,body:S}}const u=[],p=[],g=[];for(;s<e.length;){const m=t();if(!m)break;if(p.length>=1&&p[0].raw==="[["){if(m.type==="WORD"&&m.raw==="]]"){p.push(r());break}if(m.type==="SEMICOLON")break;const S=r();if(S.type==="WORD")p.push(S);else{const b=S.raw||S.op||"";p.push({type:"WORD",segments:[{type:"literal",value:b}],raw:b,hasWildcard:!1})}continue}if(m.type==="PIPE"||m.type==="AND"||m.type==="OR"||m.type==="SEMICOLON"||m.type==="DSEMI"||m.type==="BACKGROUND"||m.type==="LPAREN"||m.type==="RPAREN")break;if(m.type==="REDIRECT"){if(r(),m.op==="<<"){g.push({type:"<<",sourceFd:m.sourceFd,body:m.body,quoted:m.quoted,stripTabs:m.stripTabs});continue}const S=t();let b=null;S&&S.type==="WORD"&&(b=r()),g.push({type:m.op,sourceFd:m.sourceFd,target:b});continue}if(m.type==="REDIRECT_FD"){r(),g.push({type:">&",sourceFd:m.sourceFd,targetFd:m.targetFd});continue}if(m.type==="WORD"){if(p.length===0&&m.raw.includes("=")){const S=m.raw.indexOf("="),b=m.raw.slice(0,S);if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(b)){u.push({key:b,rawVal:m.raw.slice(S+1),token:m}),r();continue}}p.push(r());continue}r()}return p.length===0&&u.length===0&&g.length===0?null:{type:"Command",name:p[0]||null,args:p.slice(1),envVars:u,redirects:g}}return f([])}function Ze(){const n=new Map,e=new Set(["/","/tmp","/workspace","/etc","/home","/home/user","/home/codelab"]);let s="",t="/workspace";function r(i){const f=String(i);if(f.startsWith("/"))return j.normalize(f);const d=t&&t.startsWith("/")?t:"/workspace";return j.normalize(d.endsWith("/")?d+f:d+"/"+f)}return{...{_listeners:new Map,on(i,f){this._listeners.has(i)||this._listeners.set(i,[]),this._listeners.get(i).push(f)},emit(i,...f){const d=this._listeners.get(i)||[];for(const y of d)y(...f)}},existsSync(i){const f=r(i);return e.has(f)||n.has(f)},statSync(i){const f=r(i);if(e.has(f))return{size:0,mtimeMs:Date.now(),isDirectory:()=>!0,isFile:()=>!1,isSymbolicLink:()=>!1,mode:16877};const d=n.get(f);if(d)return{size:d.data.length,mtimeMs:d.mtimeMs,isDirectory:()=>!1,isFile:()=>!0,isSymbolicLink:()=>!!d.symlinkTarget,symlinkTarget:d.symlinkTarget||null,mode:d.mode!==void 0?d.mode:33188};const y=new Error(`ENOENT: no such file or directory, stat '${i}'`);throw y.code="ENOENT",y},lstatSync(i){return this.statSync(i)},symlinkSync(i,f){const d=r(f),y=r(i),l=n.has(y)?n.get(y).data:"";n.set(d,{data:l,mtimeMs:Date.now(),mode:41471,symlinkTarget:i})},chmodSync(i,f){const d=r(i);if(e.has(d))return;const y=n.get(d);if(!y){const c=new Error(`ENOENT: no such file or directory, chmod '${i}'`);throw c.code="ENOENT",c}const l=typeof f=="string"?parseInt(f,8):Number(f),a=(y.mode!==void 0?y.mode:33188)&-512;y.mode=a|l&511},readdirSync(i){const f=r(i);if(!e.has(f)){const l=new Error(`ENOTDIR: not a directory, scandir '${i}'`);throw l.code="ENOTDIR",l}const d=f==="/"?"/":f+"/",y=new Set;for(const l of e)if(l!==f&&l.startsWith(d)){const a=l.slice(d.length).split("/")[0];a&&y.add(a)}for(const l of n.keys())if(l.startsWith(d)){const a=l.slice(d.length);a.includes("/")||y.add(a)}return Array.from(y).sort()},readFileSync(i,f){if(i===0||i==="/dev/stdin")return!f||f==="buffer"?new TextEncoder().encode(s):s;const d=r(i),y=n.get(d);if(!y){const l=new Error(`ENOENT: no such file or directory, open '${i}'`);throw l.code="ENOENT",l}return!f&&y.rawBytes instanceof Uint8Array?y.rawBytes:y.data},_setActiveStdin(i){s=i==null?"":String(i)},_setCwd(i){i&&typeof i=="string"&&(t=j.normalize(i))},_getRawFileBytes(i){const f=r(i),d=n.get(f);return d&&d.rawBytes instanceof Uint8Array?d.rawBytes:null},_getAllRawFiles(){const i={};for(const[f,d]of n.entries())d&&d.rawBytes instanceof Uint8Array&&(i[f]=d.rawBytes);return i},writeFileSync(i,f){const d=r(i),y=j.dirname(d);if(!e.has(y)){const u=y.split("/").filter(Boolean);let p="";for(const g of u)p+="/"+g,e.add(p)}const l=f instanceof Uint8Array,a=l?new Uint8Array(f.buffer,f.byteOffset,f.byteLength):null,c=l?new TextDecoder("utf-8").decode(a):typeof f=="string"?f:f&&f.toString?f.toString("utf8"):String(f),h=n.has(d)?n.get(d).mode:33188;n.set(d,{data:c,rawBytes:a,mtimeMs:Date.now(),mode:h})},appendFileSync(i,f){const d=r(i),y=n.has(d)?n.get(d).data:"",l=typeof f=="string"?f:f.toString?f.toString("utf8"):String(f);this.writeFileSync(d,y+l)},mkdirSync(i,f={}){const d=r(i),y=!!(f&&f.recursive);if(n.has(d))throw new Error(`EEXIST: file already exists, mkdir '${i}'`);if(e.has(d))return;const l=j.dirname(d);if(!e.has(l)){if(!y)throw new Error(`ENOENT: no such file or directory, mkdir '${i}'`);const a=d.split("/").filter(Boolean);let c="";for(const h of a)c+="/"+h,e.add(c);return}e.add(d)},rmdirSync(i,f={}){const d=r(i),y=!!(f&&f.recursive);if(!e.has(d)){const l=new Error(`ENOENT: no such file or directory, rmdir '${i}'`);throw l.code="ENOENT",l}if(!y){const l=d==="/"?"/":d+"/";for(const a of n.keys())if(a.startsWith(l)){const c=new Error(`ENOTEMPTY: directory not empty, rmdir '${i}'`);throw c.code="ENOTEMPTY",c}for(const a of e)if(a!==d&&a.startsWith(l)){const c=new Error(`ENOTEMPTY: directory not empty, rmdir '${i}'`);throw c.code="ENOTEMPTY",c}d!=="/"&&d!=="/workspace"&&d!=="/tmp"&&e.delete(d);return}this.rmSync(i,{...f,recursive:!0})},unlinkSync(i){const f=r(i);if(!n.has(f))throw new Error(`ENOENT: no such file or directory, unlink '${i}'`);n.delete(f)},rmSync(i,f={}){const d=r(i),y=!!(f&&f.recursive),l=!!(f&&f.force);if(n.has(d)){n.delete(d);return}if(e.has(d)){if(!y){const c=new Error(`EISDIR: illegal operation on a directory, rm '${i}'`);throw c.code="EISDIR",c}const a=d==="/"?"/":d+"/";for(const c of Array.from(n.keys()))c.startsWith(a)&&n.delete(c);for(const c of Array.from(e))c.startsWith(a)&&c!=="/"&&c!=="/workspace"&&c!=="/tmp"&&e.delete(c);d!=="/"&&d!=="/workspace"&&d!=="/tmp"&&e.delete(d);return}if(!l)throw new Error(`ENOENT: no such file or directory, rm '${i}'`)},renameSync(i,f){const d=r(i),y=r(f);if(n.has(d))n.set(y,n.get(d)),n.delete(d);else if(e.has(d)){const l=d==="/"?"/":d+"/";e.add(y),d!=="/"&&d!=="/workspace"&&d!=="/tmp"&&e.delete(d);for(const a of Array.from(e))a.startsWith(l)&&(e.add(y+"/"+a.slice(l.length)),e.delete(a));for(const[a,c]of Array.from(n.entries()))a.startsWith(l)&&(n.set(y+"/"+a.slice(l.length),c),n.delete(a))}else throw new Error(`ENOENT: no such file or directory, rename '${i}' -> '${f}'`)},copyFileSync(i,f){const d=r(i),y=r(f);if(!n.has(d))throw new Error(`ENOENT: no such file or directory, copy '${i}'`);const l=n.get(d),a=l.rawBytes instanceof Uint8Array?new Uint8Array(l.rawBytes):null;n.set(y,{data:l.data,rawBytes:a,mtimeMs:Date.now(),mode:l.mode!==void 0?l.mode:33188})}}}function de(n,e,s,t){const r=je();if(r&&typeof r.computeUnifiedHunkDiff=="function"){const u=r.computeUnifiedHunkDiff(n,e,s,t,3);return u?u.endsWith(`
189
- `)?u:u+`
190
- `:""}const o=s.length>0?s.split(`
191
- `):[],i=t.length>0?t.split(`
192
- `):[],f=o.length,d=i.length,y=Array.from({length:f+1},()=>new Int32Array(d+1));for(let u=1;u<=f;u++)for(let p=1;p<=d;p++)o[u-1]===i[p-1]?y[u][p]=y[u-1][p-1]+1:y[u][p]=Math.max(y[u-1][p],y[u][p-1]);const l=[];let a=f,c=d;for(;a>0||c>0;)a>0&&c>0&&o[a-1]===i[c-1]?(l.push({type:"common",line:o[a-1]}),a--,c--):c>0&&(a===0||y[a][c-1]>=y[a-1][c])?(l.push({type:"added",line:i[c-1]}),c--):a>0&&(c===0||y[a][c-1]<y[a-1][c])&&(l.push({type:"removed",line:o[a-1]}),a--);if(l.reverse(),!l.some(u=>u.type!=="common"))return"";let h=`--- ${n}
193
- +++ ${e}
194
- @@ -1,${f} +1,${d} @@
195
- `;for(const u of l)u.type==="common"?h+=` ${u.line}
196
- `:u.type==="added"?h+=`+${u.line}
197
- `:u.type==="removed"&&(h+=`-${u.line}
198
- `);return h}function fe(n){if(!n||typeof n!="string")return null;let e=n.trim();if(!e)return null;let s=null,t=null,r=null,o=null;const i=e.indexOf("#");if(i!==-1){const l=e.slice(i+1).trim();e=e.slice(0,i).trim(),l&&(r=l)}const f=e.match(/^git@github\.com:([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]+?)(?:\.git)?\/?$/);if(f)return s=f[1],t=f[2],{owner:s,repo:t,branch:r,subpath:null,fullName:`${s}/${t}`,httpsUrl:`https://github.com/${s}/${t}`,gitUrl:`https://github.com/${s}/${t}.git`,url:`https://github.com/${s}/${t}.git`};const d=e.match(/^(?:https?:\/\/)?(?:www\.)?github\.com\/([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]+?)(?:\.git)?(?:\/(tree|blob)\/([^/]+)(?:\/(.+?))?)?\/?$/);if(d){s=d[1],t=d[2];const l=d[4]?d[5]?`${d[4]}/${d[5].replace(/^\/+|\/+$/g,"")}`:d[4]:null;return l&&/^(?:feature|feat|fix|bugfix|hotfix|release|chore|refactor|docs|test|ci|depend|dependabot)\/[^/]+$/.test(l)&&!r?(r=l,o=null):(r=d[4]||r||null,o=d[5]?d[5].replace(/^\/+|\/+$/g,""):null),{owner:s,repo:t,branch:r,subpath:o,rawTreeTail:l,fullName:`${s}/${t}`,httpsUrl:`https://github.com/${s}/${t}`,gitUrl:`https://github.com/${s}/${t}.git`,url:`https://github.com/${s}/${t}.git`}}const y=e.match(/^([A-Za-z0-9_-]+)\/([A-Za-z0-9_.-]+?)(?:\.git)?(?:@([A-Za-z0-9_./-]+))?$/);return y&&!y[1].startsWith("-")?(s=y[1],t=y[2],r=y[3]||r||null,{owner:s,repo:t,branch:r,subpath:null,fullName:`${s}/${t}`,httpsUrl:`https://github.com/${s}/${t}`,gitUrl:`https://github.com/${s}/${t}.git`,url:`https://github.com/${s}/${t}.git`}):null}function L(n,e){const s={};if(!n||!e||!n.existsSync(e))return s;const t=j.normalize(e);function r(o){let i=[];try{i=n.readdirSync(o)}catch{return}for(const f of i){if(f===".git"||f==="node_modules")continue;const d=j.join(o,f);let y;try{y=n.statSync(d)}catch{continue}if(y.isDirectory())r(d);else{const l=d.startsWith(t==="/"?"/":t+"/")?d.slice(t==="/"?1:t.length+1):f;try{s[l]=String(n.readFileSync(d,"utf8"))}catch(a){N.debug("Skipped unreadable VFS file in snapshot.",d,a)}}}}return r(t),s}function re(n){const e=String(n||"");let s=3735928559^e.length,t=1103547991^e.length;for(let o=0;o<e.length;o++){const i=e.charCodeAt(o);s=Math.imul(s^i,2654435761),t=Math.imul(t^i,1597334677)}return s=Math.imul(s^s>>>16,2246822507)^Math.imul(t^t>>>13,3266489909),t=Math.imul(t^t>>>16,2246822507)^Math.imul(s^s>>>13,3266489909),(4294967296*(2097151&t)+(s>>>0)).toString(16).padStart(7,"0").slice(0,7)}function ee(n,e){if(!n||typeof n!="string")return"";let s=n.trim().replace(/\\/g,"/");if(!s)return"";const t=j.normalize(e||"/workspace"),r=t==="/"?"/":t+"/";if(s===t)return"";for(s.startsWith(r)?s=s.slice(r.length):s.startsWith("/workspace/")&&(s=s.slice(11));s.startsWith("./");)s=s.slice(2);s.startsWith("/")&&(s=s.replace(/^\/+/,""));const o=[];for(const f of s.split("/"))if(!(!f||f===".")){if(f===".."){if(o.length===0)return"";o.pop();continue}o.push(f)}const i=o.join("/");return!i||i===".git"||i.startsWith(".git/")||i.includes("/.git/")||i.endsWith("/.git")||i==="node_modules"||i.startsWith("node_modules/")||i.includes("/node_modules/")||i.endsWith("/node_modules")?"":i}function oe(n){return(!Array.isArray(n&&n.commits)||n.commits.length===0)&&!(n&&n.headCommit)}function ue(n,e,s,t){if(!e)return!1;const r=t||n&&(n.headSnapshot||n.headFiles)||{},o=Object.prototype.hasOwnProperty.call(r,e),i=s==null?null:String(s);return i===null?o:!o||oe(n)?!0:i!==r[e]}function K(n,e,s,t,r){const o=n&&n.repoRoot||"/workspace",i=ee(s,o);if(!i)return;const f=t==null?null:String(t);ue(n,i,f,r)?e.set(i,f):e.delete(i)}function Y(n,e,s){if(!(e instanceof Map))return;const t=n&&n.repoRoot||"/workspace",r=s||n&&(n.headSnapshot||n.headFiles)||{};for(const[o,i]of Array.from(e.entries())){const f=ee(o,t);if(f!==o&&e.delete(o),!f){e.delete(o);continue}const d=i==null?null:String(i);ue(n,f,d,r)?e.set(f,d):e.delete(f)}}function Ke(n,e){if(!n||!n._initialBootSnapshot||!n._initialBootRoot)return{};const s=j.normalize(e),t=n._initialBootRoot;if(s===t)return n._initialBootSnapshot;const r=t==="/"?"/":t+"/";if(s.startsWith(r)){const o=s.slice(r.length)+"/",i={};for(const[f,d]of Object.entries(n._initialBootSnapshot))f.startsWith(o)&&(i[f.slice(o.length)]=d);return i}return{}}function Q(n,e,s,t){return n instanceof Map&&(n._hasShellStagedShim||(Object.defineProperty(n,"_hasShellStagedShim",{value:!0,enumerable:!1,configurable:!0,writable:!0}),Object.defineProperty(n,"add",{value(r){const o=typeof t=="function"?t():null,i=typeof s=="function"?s():o&&o.repoRoot||"/workspace",f=ee(r,i);if(!f)return n;let d=null;if(e&&typeof e.existsSync=="function"){const y=j.join(i,f);if(e.existsSync(y)){if(typeof e.statSync=="function")try{if(e.statSync(y).isDirectory())return n}catch(l){N.debug("Failed statting staged path in VFS.",y,l)}if(typeof e.readFileSync=="function")try{d=String(e.readFileSync(y,"utf8"))}catch(l){return N.debug("Failed reading staged file from VFS.",y,l),n}}}return o?K(o,n,f,d):n.set(f,d),n},enumerable:!1,configurable:!0,writable:!0}))),n}function Xe(n,e,s){const t=()=>n&&n.repoRoot||s||"/workspace",r=()=>n;if(n.staged instanceof Map)return Q(n.staged,e,t,r),Y(n,n.staged),n.stagedFiles=n.staged,n.staged;const o=Q(new Map,e,t,r);if(n.staged&&typeof n.staged[Symbol.iterator]=="function")for(const i of n.staged)Array.isArray(i)&&i.length>=2?K(n,o,i[0],i[1]===null?null:String(i[1])):typeof i=="string"&&o.add(i);return n.staged=o,n.stagedFiles=o,o}function Ye(n,e){if(!n||typeof n.existsSync!="function"||typeof n.readFileSync!="function")return null;const s=[j.join(e,".git/HEAD"),"/workspace/.git/HEAD"];for(const t of s)if(n.existsSync(t))try{const r=String(n.readFileSync(t,"utf8")).trim(),o=/^ref:\s*refs\/heads\/([^\s]+)$/.exec(r);if(o&&o[1])return o[1]}catch(r){N.debug("Could not parse .git/HEAD branch.",t,r)}return null}function Qe(n,e,s={}){const t=j.normalize(e||"/workspace"),r=!!(n&&typeof n.existsSync=="function"&&(n.existsSync(j.join(t,".git"))||n.existsSync(j.join(t,".git/HEAD"))||n.existsSync("/workspace/.git")||n.existsSync("/workspace/.git/HEAD")));let o=!!(s.gitInitialized===!0||r),i=t;const d=(r?Ye(n,t):null)||"main";let y=o?L(n,t):{},l=o?re(JSON.stringify(y)+":init"):"";const a=Date.now();let c=o?[{hash:l,author:"CodeLab Developer <dev@codelab.internal>",date:new Date(a).toUTCString(),timestamp:a,message:"Initial commit",files:Object.assign({},y)}]:[];const h={branch:d,branches:new Set([d]),remoteUrl:null,remotes:{}};let u=Q(new Map,n,()=>i,()=>h);return Object.defineProperties(h,{initialized:{enumerable:!0,configurable:!0,get(){if(o)return!0;const p=i||t;return n&&typeof n.existsSync=="function"&&(n.existsSync(j.join(p,".git"))||n.existsSync(j.join(p,".git/HEAD")))?(o=!0,!0):!1},set(p){o=!!p}},repoRoot:{enumerable:!0,configurable:!0,get(){return i},set(p){i=j.normalize(String(p||t))}},headCommit:{enumerable:!0,configurable:!0,get(){return l},set(p){l=String(p||"")}},headSnapshot:{enumerable:!0,configurable:!0,get(){return y},set(p){y=p&&typeof p=="object"?p:{}}},headFiles:{enumerable:!0,configurable:!0,get(){return y},set(p){y=p&&typeof p=="object"?p:{}}},staged:{enumerable:!0,configurable:!0,get(){return u},set(p){if(p instanceof Map)u=Q(p,n,()=>i,()=>h),Y(h,u);else{const g=Q(new Map,n,()=>i,()=>h);if(p&&typeof p[Symbol.iterator]=="function")for(const m of p)typeof m=="string"?g.add(m):Array.isArray(m)&&m.length>=2&&K(h,g,m[0],m[1]===null?null:String(m[1]));u=g}}},stagedFiles:{enumerable:!0,configurable:!0,get(){return u},set(p){p instanceof Map&&(u=Q(p,n,()=>i,()=>h),Y(h,u))}},commits:{enumerable:!0,configurable:!0,get(){return c},set(p){c=Array.isArray(p)?p:[],c.length>0&&c[0]&&c[0].hash?l=String(c[0].hash):c.length===0&&(l="")}}}),h}const xe=/\.(png|jpg|jpeg|gif|webp|ico|bmp|tiff|woff|woff2|ttf|eot|otf|mp3|mp4|wav|ogg|webm|avi|mov|pdf|zip|tar|gz|tgz|bz2|7z|rar|exe|dll|so|dylib|wasm|pyc|pyo|class|jar|war|ear|bin|dat|iso|dmg|pkg|deb|rpm|o|a|lib|DS_Store)$/i;function et(n){const e=n.toLowerCase(),s=j.basename(e),t=n.split("/").length;return s==="readme.md"||s==="package.json"||s==="cargo.toml"||s==="go.mod"||s==="pyproject.toml"?0:t===1&&/\.(js|ts|jsx|tsx|mjs|cjs|py|go|rs|json|md|yml|yaml|toml|sh)$/.test(e)?1:e.startsWith("src/")||e.startsWith("lib/")||e.startsWith("app/")?2+t*.1:e.startsWith("test/")||e.startsWith("tests/")||e.startsWith("examples/")?5+t*.1:10+t*.1}async function tt(n,e,s={}){const t=typeof s.onProgress=="function"?s.onProgress:null;t&&t({phase:"connecting",message:`Connecting to repository '${n}'...`});const r=fe(n);if(!r)throw new Error(`fatal: repository '${n}' does not exist or is not a valid GitHub repository URL`);if(!e)throw new Error("fatal: virtual filesystem (vfs) is required to clone repository");const o=s.fetchImpl||(typeof fetch=="function"?fetch.bind(globalThis):null);if(!o)throw new Error("fatal: global fetch API is unavailable in this environment");const i=j.normalize(s.targetDir||"/workspace"),f=s.maxFiles||250,d=s.maxFileSize||512*1024,y=s.branch||r.branch||null,{owner:l,repo:a}=r,c=s.signal||null,h=()=>{if(c&&c.aborted){const T=new Error("fatal: clone cancelled (SIGINT)");throw T.name="AbortError",T}};h();let u=y,p=null,g=!1;t&&t({phase:"metadata",message:`Fetching repository metadata for ${l}/${a}...`});try{if(!u){const T=await o(`https://api.github.com/repos/${l}/${a}`,{headers:{Accept:"application/vnd.github.v3+json"},signal:c});if(T.status===404)g=!0;else if(T.ok){const k=await T.json();k&&k.default_branch&&(u=k.default_branch)}}if(!g){const T=Array.from(y?new Set([y,!s.branch&&r.rawTreeTail&&r.rawTreeTail!==y?r.rawTreeTail:null].filter(Boolean)):new Set([u,"main","master"].filter(Boolean)));for(const k of T){h();const O=await o(`https://api.github.com/repos/${l}/${a}/git/trees/${encodeURIComponent(k)}?recursive=1`,{headers:{Accept:"application/vnd.github.v3+json"},signal:c});if(O.ok){const F=await O.json();if(F&&Array.isArray(F.tree)){u=k,r.rawTreeTail&&k===r.rawTreeTail&&(r.subpath=null),p=F.tree.filter(P=>P&&P.type==="blob"&&P.path).map(P=>({path:P.path.replace(/^\/+/,""),size:P.size||0}));break}}}}}catch(T){N.debug("GitHub REST API tree fetch failed; falling back to jsDelivr.",T)}if(!p&&!g)try{const T=y?[y]:Array.from(new Set([u,"main","master"].filter(Boolean)));for(const k of T){h();const O=await o(`https://data.jsdelivr.com/v1/package/gh/${l}/${a}@${encodeURIComponent(k)}/flat`,{signal:c});if(O&&O.ok){const F=await O.json();if(F&&Array.isArray(F.files)&&F.files.length>0){u=k,p=F.files.filter(P=>P&&P.name).map(P=>({path:P.name.replace(/^\/+/,""),size:P.size||0}));break}}}}catch(T){N.debug("jsDelivr flat tree fetch failed.",T)}if(g||!p)throw new Error(`fatal: repository '${r.url}' not found or could not be fetched`);const m=r.subpath?r.subpath.replace(/^\/+|\/+$/g,"")+"/":null,S=[];for(const T of p){let k=T.path;if(m)if(T.path===r.subpath)k=j.basename(T.path);else if(T.path.startsWith(m))k=T.path.slice(m.length);else continue;!k||k.startsWith(".git/")||k.includes("/node_modules/")||k.startsWith("node_modules/")||xe.test(k)||T.size&&T.size>d||S.push({repoPath:T.path,destPath:k,size:T.size||0,priority:et(k)})}S.sort((T,k)=>T.priority-k.priority||T.destPath.localeCompare(k.destPath));const b=S.slice(0,f),v=b.length;t&&t({phase:"downloading",message:`Downloading files (0/${v})...`,loaded:0,total:v}),e.existsSync(i)||e.mkdirSync(i,{recursive:!0});const w={};let $=0,R=0;const I=12;for(let T=0;T<b.length;T+=I){h();const k=b.slice(T,T+I);await Promise.all(k.map(async O=>{h();const F=O.repoPath.split("/").map(encodeURIComponent).join("/"),P=`https://raw.githubusercontent.com/${l}/${a}/${encodeURIComponent(u)}/${F}`,A=`https://cdn.jsdelivr.net/gh/${l}/${a}@${encodeURIComponent(u)}/${F}`;let M=null;try{const D=await o(P,{signal:c});D&&D.ok&&(M=await D.text())}catch(D){if(c&&c.aborted)throw D}if(M===null)try{const D=await o(A,{signal:c});D&&D.ok&&(M=await D.text())}catch(D){if(c&&c.aborted)throw D}if(M!==null&&M.length<=d){const D=j.join(i,O.destPath),_=j.dirname(D);e.existsSync(_)||e.mkdirSync(_,{recursive:!0}),e.writeFileSync(D,M),w[O.destPath]=M,$++,R+=M.length,t&&t({phase:"downloading",message:`Downloading files (${$}/${v}): ${O.destPath}`,loaded:$,total:v}),typeof s.onFile=="function"&&s.onFile(D,M,O.destPath)}}))}h(),t&&t({phase:"mounting",message:`Mounting files and writing Git metadata into ${i}...`,loaded:$,total:v});const C=j.join(i,".git");e.existsSync(C)||e.mkdirSync(C,{recursive:!0}),e.writeFileSync(j.join(C,"HEAD"),`ref: refs/heads/${u}
184
+ `;)t++;continue}if(o===";"&&n[t+1]===";"){e.push({type:"DSEMI",raw:";;"}),t+=2;continue}if(o===";"){e.push({type:"SEMICOLON",raw:";"}),t++;continue}if(o==="("){e.push({type:"LPAREN",raw:"("}),t++;continue}if(o===")"){e.push({type:"RPAREN",raw:")"}),t++;continue}if(o==="&"&&n[t+1]==="&"){e.push({type:"AND",raw:"&&"}),t+=2;continue}if(o==="|"&&n[t+1]==="|"){e.push({type:"OR",raw:"||"}),t+=2;continue}if(o==="|"){e.push({type:"PIPE",raw:"|"}),t++;continue}if(o==="&"&&n[t+1]===">"){e.push({type:"REDIRECT",op:"&>",sourceFd:"all",raw:"&>"}),t+=2;continue}if(o==="&"){e.push({type:"BACKGROUND",raw:"&"}),t++;continue}if((o==="1"||o==="2"||o==="0")&&(n[t+1]===">"||n[t+1]==="<")){const l=parseInt(o,10),c=n[t+1];if(c===">"&&n[t+2]==="&"&&(n[t+3]==="1"||n[t+3]==="2")){const d=parseInt(n[t+3],10);e.push({type:"REDIRECT_FD",sourceFd:l,targetFd:d,raw:`${l}>&${d}`}),t+=4;continue}if(c===">"&&n[t+2]===">"){e.push({type:"REDIRECT",op:">>",sourceFd:l,raw:`${l}>>`}),t+=3;continue}e.push({type:"REDIRECT",op:c,sourceFd:l,raw:`${l}${c}`}),t+=2;continue}if(o===">"){if(n[t+1]==="&"&&(n[t+2]==="1"||n[t+2]==="2")){const l=parseInt(n[t+2],10);e.push({type:"REDIRECT_FD",sourceFd:1,targetFd:l,raw:`>&${l}`}),t+=3;continue}if(n[t+1]===">"){e.push({type:"REDIRECT",op:">>",sourceFd:1,raw:">>"}),t+=2;continue}e.push({type:"REDIRECT",op:">",sourceFd:1,raw:">"}),t++;continue}if(o==="<"){if(n[t+1]==="<"&&n[t+2]==="<"){e.push({type:"REDIRECT",op:"<<<",sourceFd:0,raw:"<<<"}),t+=3;continue}if(n[t+1]==="<"){const l=n[t+2]==="-";for(t+=l?3:2;t<s&&(n[t]===" "||n[t]===" ");)t++;let c="",d=!1;for(;t<s&&!/[\s;|&<>()]/.test(n[t]);)if(n[t]==="'"||n[t]==='"'){const p=n[t++];for(d=!0;t<s&&n[t]!==p;)c+=n[t++];t<s&&n[t]===p&&t++}else n[t]==="\\"&&t+1<s&&(d=!0,t++),c+=n[t++];const u=r>t?r:n.indexOf(`
185
+ `,t);let h="";if(u!==-1&&u<s){let p=u+1;for(;p<=s;){let g=n.indexOf(`
186
+ `,p);g===-1&&(g=s);const m=n.slice(p,g).replace(/\r$/,"");if((l?m.replace(/^\t+/,""):m)===c){r=g<s?g+1:s;break}if(h+=(l?m.replace(/^\t+/,""):m)+`
187
+ `,g===s){r=s;break}p=g+1}}e.push({type:"REDIRECT",op:"<<",sourceFd:0,stripTabs:l,quoted:d,body:h,delim:c,raw:l?"<<-":"<<"});continue}e.push({type:"REDIRECT",op:"<",sourceFd:0,raw:"<"}),t++;continue}const i=[];let f="",a=!1,y=!1;for(;t<s;){const l=n[t];if(/\s/.test(l)||l==="|"||l==="&"||l===";"||l==="<"||l===">"||l==="("||l===")")break;if(l==="'"){t++;let c="";for(;t<s&&n[t]!=="'";)c+=n[t],t++;t<s&&n[t]==="'"&&t++,i.push({type:"single_quoted",value:c}),f+=`'${c}'`;continue}if(l==='"'){const c=t;t++;const d=[];let u="";for(;t<s&&n[t]!=='"';){const h=n[t];if(h==="\\"&&t+1<s){const p=n[t+1];if(p==='"'||p==="\\"||p==="$"||p==="`"){u+=p,t+=2;continue}if(p==="n"){u+=`
188
+ `,t+=2;continue}if(p==="t"){u+=" ",t+=2;continue}u+="\\"+p,t+=2;continue}if(h==="$"&&n[t+1]==="("&&n[t+2]==="("){u&&(d.push({type:"literal",value:u}),u=""),t+=3;let p=2,g="";for(;t<s&&p>0;)if(n[t]==="(")p++,g+="(",t++;else if(n[t]===")"){if(p===2&&n[t+1]===")"){p=0,t+=2;break}p--,p>0&&(g+=")"),t++}else g+=n[t++];d.push({type:"arith",expr:g});continue}if(h==="$"&&n[t+1]==="("){u&&(d.push({type:"literal",value:u}),u=""),t+=2;let p=1,g="";for(;t<s&&p>0;)n[t]==="("?p++:n[t]===")"&&p--,p>0&&(g+=n[t]),t++;d.push({type:"subshell",command:g});continue}if(h==="`"){u&&(d.push({type:"literal",value:u}),u=""),t++;let p="";for(;t<s&&n[t]!=="`";)p+=n[t++];t<s&&n[t]==="`"&&t++,d.push({type:"subshell",command:p});continue}if(h==="$"){if(u&&(d.push({type:"literal",value:u}),u=""),t++,n[t]==="{"){t++;let p="",g=1;for(;t<s&&g>0;)n[t]==="{"?g++:n[t]==="}"&&g--,g>0&&(p+=n[t]),t++;d.push({type:"variable",name:p})}else if(/[0-9?!$#@*]/.test(n[t])){const p=n[t++];d.push({type:"variable",name:p})}else if(/[a-zA-Z_]/.test(n[t])){let p="";for(;t<s&&/[a-zA-Z0-9_]/.test(n[t]);)p+=n[t++];d.push({type:"variable",name:p})}else u+="$";continue}u+=h,t++}t<s&&n[t]==='"'&&t++,u&&d.push({type:"literal",value:u}),i.push({type:"double_quoted",parts:d}),f+=n.slice(c,t);continue}if(l==="\\"&&t+1<s){i.push({type:"literal",value:n[t+1],escaped:!0}),f+="\\"+n[t+1],t+=2;continue}if(l==="$"&&n[t+1]==="("&&n[t+2]==="("){t+=3;let c=2,d="";for(;t<s&&c>0;)if(n[t]==="(")c++,d+="(",t++;else if(n[t]===")"){if(c===2&&n[t+1]===")"){c=0,t+=2;break}c--,c>0&&(d+=")"),t++}else d+=n[t++];i.push({type:"arith",expr:d}),f+=`$((${d}))`;continue}if(l==="$"&&n[t+1]==="("){t+=2;let c=1,d="";for(;t<s&&c>0;)n[t]==="("?c++:n[t]===")"&&c--,c>0&&(d+=n[t]),t++;i.push({type:"subshell",command:d}),f+=`$(${d})`;continue}if(l==="`"){t++;let c="";for(;t<s&&n[t]!=="`";)c+=n[t],t++;t<s&&n[t]==="`"&&t++,i.push({type:"subshell",command:c}),f+=`\`${c}\``;continue}if(l==="$"){if(t++,n[t]==="{"){t++;let c="",d=1;for(;t<s&&d>0;)n[t]==="{"?d++:n[t]==="}"&&d--,d>0&&(c+=n[t]),t++;i.push({type:"variable",name:c}),f+=`\${${c}}`}else if(/[0-9?!$#@*]/.test(n[t])){const c=n[t++];i.push({type:"variable",name:c}),f+=`$${c}`}else if(/[a-zA-Z_]/.test(n[t])){let c="";for(;t<s&&/[a-zA-Z0-9_]/.test(n[t]);)c+=n[t++];i.push({type:"variable",name:c}),f+=`$${c}`}else i.push({type:"literal",value:"$"}),f+="$";continue}(l==="*"||l==="?"||l==="[")&&(a=!0),(l==="{"||l==="}")&&(y=!0),i.push({type:"literal",value:l}),f+=l,t++}e.push({type:"WORD",segments:i,raw:f,hasWildcard:a,hasBraces:y})}return e}function Ce(n){const e=typeof n=="string"?Te(n):n;let s=0;function t(){return e[s]||null}function r(){return e[s++]||null}function o(d,...u){return!!(d&&d.type==="WORD"&&u.includes(d.raw))}function i(){for(;t()&&t().type==="SEMICOLON";)r()}function f(d=[]){const u=[];for(;s<e.length;){i();const h=t();if(!h||h.type==="RPAREN"||h.type==="DSEMI"||d.length>0&&o(h,...d))break;const p=a(d);if(!p)break;let g=!1;t()&&t().type==="BACKGROUND"?(r(),g=!0):t()&&t().type==="SEMICOLON"&&r(),u.push({node:p,background:g})}return{type:"Sequence",items:u}}function a(d=[]){let u=y(d);if(!u)return null;for(;t()&&(t().type==="AND"||t().type==="OR");){const h=r();i();const p=y(d);if(!p)break;u={type:"Logical",op:h.type==="AND"?"&&":"||",left:u,right:p}}return u}function y(d=[]){let u=!1;o(t(),"!")&&(r(),u=!0);const h=[],p=c(d);if(!p)return null;for(h.push(p);t()&&t().type==="PIPE";){r(),i();const g=c(d);g&&h.push(g)}return h.length===1&&!u?h[0]:{type:"Pipeline",negated:u,commands:h}}function l(){const d=[];for(;t()&&(t().type==="REDIRECT"||t().type==="REDIRECT_FD");){const u=r();if(u.type==="REDIRECT")if(u.op==="<<")d.push({type:"<<",sourceFd:u.sourceFd,body:u.body,quoted:u.quoted,stripTabs:u.stripTabs});else{let h=null;t()&&t().type==="WORD"&&(h=r()),d.push({type:u.op,sourceFd:u.sourceFd,target:h})}else d.push({type:">&",sourceFd:u.sourceFd,targetFd:u.targetFd})}return d}function c(d=[]){const u=t();if(!u||u.type==="RPAREN"||u.type==="DSEMI"||d.length>0&&o(u,...d))return null;if(u.type==="LPAREN"){r();const m=f([]);return t()&&t().type==="RPAREN"&&r(),{type:"Subshell",body:m,redirects:l()}}if(o(u,"{")){r();const m=f(["}"]);return o(t(),"}")&&r(),{type:"BraceGroup",body:m,redirects:l()}}if(o(u,"if")){r();const m=[],S=f(["then"]);o(t(),"then")&&r();const b=f(["elif","else","fi"]);for(m.push({cond:S,body:b});o(t(),"elif");){r();const w=f(["then"]);o(t(),"then")&&r();const $=f(["elif","else","fi"]);m.push({cond:w,body:$})}let v=null;return o(t(),"else")&&(r(),v=f(["fi"])),o(t(),"fi")&&r(),{type:"If",branches:m,elseBody:v,redirects:l()}}if(o(u,"for")){r();const m=r(),S=m?m.raw:"i";let b=null;if(o(t(),"in"))for(r(),b=[];t()&&t().type==="WORD"&&!o(t(),"do");)b.push(r());i(),o(t(),"do")&&r();const v=f(["done"]);return o(t(),"done")&&r(),{type:"For",varName:S,items:b,body:v,redirects:l()}}if(o(u,"while","until")){const m=r().raw,S=f(["do"]);o(t(),"do")&&r();const b=f(["done"]);return o(t(),"done")&&r(),{type:m==="while"?"While":"Until",cond:S,body:b,redirects:l()}}if(o(u,"case")){r();const m=r();i(),o(t(),"in")&&r(),i();const S=[];for(;s<e.length&&!o(t(),"esac")&&(i(),!o(t(),"esac"));){t()&&t().type==="LPAREN"&&r();const b=[];for(;s<e.length&&t().type!=="RPAREN"&&!o(t(),"esac");){if(t().type==="PIPE"){r();continue}b.push(r())}t()&&t().type==="RPAREN"&&r();const v=f(["esac"]);t()&&t().type==="DSEMI"&&r(),i(),S.push({patterns:b,body:v})}return o(t(),"esac")&&r(),{type:"Case",word:m,clauses:S,redirects:l()}}if(o(u,"function")){r();const m=r(),S=m?m.raw:"";t()&&t().type==="LPAREN"&&(r(),t()&&t().type==="RPAREN"&&r()),i();const b=c(d);return{type:"FunctionDef",name:S,body:b}}if(u.type==="WORD"&&e[s+1]&&e[s+1].type==="LPAREN"&&e[s+2]&&e[s+2].type==="RPAREN"){const m=r().raw;r(),r(),i();const S=c(d);return{type:"FunctionDef",name:m,body:S}}const h=[],p=[],g=[];for(;s<e.length;){const m=t();if(!m)break;if(p.length>=1&&p[0].raw==="[["){if(m.type==="WORD"&&m.raw==="]]"){p.push(r());break}if(m.type==="SEMICOLON")break;const S=r();if(S.type==="WORD")p.push(S);else{const b=S.raw||S.op||"";p.push({type:"WORD",segments:[{type:"literal",value:b}],raw:b,hasWildcard:!1})}continue}if(m.type==="PIPE"||m.type==="AND"||m.type==="OR"||m.type==="SEMICOLON"||m.type==="DSEMI"||m.type==="BACKGROUND"||m.type==="LPAREN"||m.type==="RPAREN")break;if(m.type==="REDIRECT"){if(r(),m.op==="<<"){g.push({type:"<<",sourceFd:m.sourceFd,body:m.body,quoted:m.quoted,stripTabs:m.stripTabs});continue}const S=t();let b=null;S&&S.type==="WORD"&&(b=r()),g.push({type:m.op,sourceFd:m.sourceFd,target:b});continue}if(m.type==="REDIRECT_FD"){r(),g.push({type:">&",sourceFd:m.sourceFd,targetFd:m.targetFd});continue}if(m.type==="WORD"){if(p.length===0&&m.raw.includes("=")){const S=m.raw.indexOf("="),b=m.raw.slice(0,S);if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(b)){h.push({key:b,rawVal:m.raw.slice(S+1),token:m}),r();continue}}p.push(r());continue}r()}return p.length===0&&h.length===0&&g.length===0?null:{type:"Command",name:p[0]||null,args:p.slice(1),envVars:h,redirects:g}}return f([])}function Ge(){const n=new Map,e=new Set(["/","/tmp","/workspace","/etc","/home","/home/user","/home/codelab"]);let s="",t="/workspace";function r(i){const f=String(i);if(f.startsWith("/"))return j.normalize(f);const a=t&&t.startsWith("/")?t:"/workspace";return j.normalize(a.endsWith("/")?a+f:a+"/"+f)}return{...{_listeners:new Map,on(i,f){this._listeners.has(i)||this._listeners.set(i,[]),this._listeners.get(i).push(f)},emit(i,...f){const a=this._listeners.get(i)||[];for(const y of a)y(...f)}},existsSync(i){const f=r(i);return e.has(f)||n.has(f)},statSync(i){const f=r(i);if(e.has(f))return{size:0,mtimeMs:Date.now(),isDirectory:()=>!0,isFile:()=>!1,isSymbolicLink:()=>!1,mode:16877};const a=n.get(f);if(a)return{size:a.data.length,mtimeMs:a.mtimeMs,isDirectory:()=>!1,isFile:()=>!0,isSymbolicLink:()=>!!a.symlinkTarget,symlinkTarget:a.symlinkTarget||null,mode:a.mode!==void 0?a.mode:33188};const y=new Error(`ENOENT: no such file or directory, stat '${i}'`);throw y.code="ENOENT",y},lstatSync(i){return this.statSync(i)},symlinkSync(i,f){const a=r(f),y=r(i),l=n.has(y)?n.get(y).data:"";n.set(a,{data:l,mtimeMs:Date.now(),mode:41471,symlinkTarget:i})},chmodSync(i,f){const a=r(i);if(e.has(a))return;const y=n.get(a);if(!y){const d=new Error(`ENOENT: no such file or directory, chmod '${i}'`);throw d.code="ENOENT",d}const l=typeof f=="string"?parseInt(f,8):Number(f),c=(y.mode!==void 0?y.mode:33188)&-512;y.mode=c|l&511},readdirSync(i){const f=r(i);if(!e.has(f)){const l=new Error(`ENOTDIR: not a directory, scandir '${i}'`);throw l.code="ENOTDIR",l}const a=f==="/"?"/":f+"/",y=new Set;for(const l of e)if(l!==f&&l.startsWith(a)){const c=l.slice(a.length).split("/")[0];c&&y.add(c)}for(const l of n.keys())if(l.startsWith(a)){const c=l.slice(a.length);c.includes("/")||y.add(c)}return Array.from(y).sort()},readFileSync(i,f){if(i===0||i==="/dev/stdin")return!f||f==="buffer"?new TextEncoder().encode(s):s;const a=r(i),y=n.get(a);if(!y){const l=new Error(`ENOENT: no such file or directory, open '${i}'`);throw l.code="ENOENT",l}return!f&&y.rawBytes instanceof Uint8Array?y.rawBytes:y.data},_setActiveStdin(i){s=i==null?"":String(i)},_setCwd(i){i&&typeof i=="string"&&(t=j.normalize(i))},_getRawFileBytes(i){const f=r(i),a=n.get(f);return a&&a.rawBytes instanceof Uint8Array?a.rawBytes:null},_getAllRawFiles(){const i={};for(const[f,a]of n.entries())a&&a.rawBytes instanceof Uint8Array&&(i[f]=a.rawBytes);return i},writeFileSync(i,f){const a=r(i),y=j.dirname(a);if(!e.has(y)){const h=y.split("/").filter(Boolean);let p="";for(const g of h)p+="/"+g,e.add(p)}const l=f instanceof Uint8Array,c=l?new Uint8Array(f.buffer,f.byteOffset,f.byteLength):null,d=l?new TextDecoder("utf-8").decode(c):typeof f=="string"?f:f&&f.toString?f.toString("utf8"):String(f),u=n.has(a)?n.get(a).mode:33188;n.set(a,{data:d,rawBytes:c,mtimeMs:Date.now(),mode:u})},appendFileSync(i,f){const a=r(i),y=n.has(a)?n.get(a).data:"",l=typeof f=="string"?f:f.toString?f.toString("utf8"):String(f);this.writeFileSync(a,y+l)},mkdirSync(i,f={}){const a=r(i),y=!!(f&&f.recursive);if(n.has(a))throw new Error(`EEXIST: file already exists, mkdir '${i}'`);if(e.has(a))return;const l=j.dirname(a);if(!e.has(l)){if(!y)throw new Error(`ENOENT: no such file or directory, mkdir '${i}'`);const c=a.split("/").filter(Boolean);let d="";for(const u of c)d+="/"+u,e.add(d);return}e.add(a)},rmdirSync(i,f={}){const a=r(i),y=!!(f&&f.recursive);if(!e.has(a)){const l=new Error(`ENOENT: no such file or directory, rmdir '${i}'`);throw l.code="ENOENT",l}if(!y){const l=a==="/"?"/":a+"/";for(const c of n.keys())if(c.startsWith(l)){const d=new Error(`ENOTEMPTY: directory not empty, rmdir '${i}'`);throw d.code="ENOTEMPTY",d}for(const c of e)if(c!==a&&c.startsWith(l)){const d=new Error(`ENOTEMPTY: directory not empty, rmdir '${i}'`);throw d.code="ENOTEMPTY",d}a!=="/"&&a!=="/workspace"&&a!=="/tmp"&&e.delete(a);return}this.rmSync(i,{...f,recursive:!0})},unlinkSync(i){const f=r(i);if(!n.has(f))throw new Error(`ENOENT: no such file or directory, unlink '${i}'`);n.delete(f)},rmSync(i,f={}){const a=r(i),y=!!(f&&f.recursive),l=!!(f&&f.force);if(n.has(a)){n.delete(a);return}if(e.has(a)){if(!y){const d=new Error(`EISDIR: illegal operation on a directory, rm '${i}'`);throw d.code="EISDIR",d}const c=a==="/"?"/":a+"/";for(const d of Array.from(n.keys()))d.startsWith(c)&&n.delete(d);for(const d of Array.from(e))d.startsWith(c)&&d!=="/"&&d!=="/workspace"&&d!=="/tmp"&&e.delete(d);a!=="/"&&a!=="/workspace"&&a!=="/tmp"&&e.delete(a);return}if(!l)throw new Error(`ENOENT: no such file or directory, rm '${i}'`)},renameSync(i,f){const a=r(i),y=r(f);if(n.has(a))n.set(y,n.get(a)),n.delete(a);else if(e.has(a)){const l=a==="/"?"/":a+"/";e.add(y),a!=="/"&&a!=="/workspace"&&a!=="/tmp"&&e.delete(a);for(const c of Array.from(e))c.startsWith(l)&&(e.add(y+"/"+c.slice(l.length)),e.delete(c));for(const[c,d]of Array.from(n.entries()))c.startsWith(l)&&(n.set(y+"/"+c.slice(l.length),d),n.delete(c))}else throw new Error(`ENOENT: no such file or directory, rename '${i}' -> '${f}'`)},copyFileSync(i,f){const a=r(i),y=r(f);if(!n.has(a))throw new Error(`ENOENT: no such file or directory, copy '${i}'`);const l=n.get(a),c=l.rawBytes instanceof Uint8Array?new Uint8Array(l.rawBytes):null;n.set(y,{data:l.data,rawBytes:c,mtimeMs:Date.now(),mode:l.mode!==void 0?l.mode:33188})}}}function de(n,e,s,t){const r=je();if(r&&typeof r.computeUnifiedHunkDiff=="function"){const o=r.computeUnifiedHunkDiff(n,e,s,t,3);return o?o.endsWith(`
189
+ `)?o:o+`
190
+ `:""}return""}function fe(n){if(!n||typeof n!="string")return null;let e=n.trim();if(!e)return null;let s=null,t=null,r=null,o=null;const i=e.indexOf("#");if(i!==-1){const l=e.slice(i+1).trim();e=e.slice(0,i).trim(),l&&(r=l)}const f=e.match(/^git@github\.com:([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]+?)(?:\.git)?\/?$/);if(f)return s=f[1],t=f[2],{owner:s,repo:t,branch:r,subpath:null,fullName:`${s}/${t}`,httpsUrl:`https://github.com/${s}/${t}`,gitUrl:`https://github.com/${s}/${t}.git`,url:`https://github.com/${s}/${t}.git`};const a=e.match(/^(?:https?:\/\/)?(?:www\.)?github\.com\/([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]+?)(?:\.git)?(?:\/(tree|blob)\/([^/]+)(?:\/(.+?))?)?\/?$/);if(a){s=a[1],t=a[2];const l=a[4]?a[5]?`${a[4]}/${a[5].replace(/^\/+|\/+$/g,"")}`:a[4]:null;return l&&/^(?:feature|feat|fix|bugfix|hotfix|release|chore|refactor|docs|test|ci|depend|dependabot)\/[^/]+$/.test(l)&&!r?(r=l,o=null):(r=a[4]||r||null,o=a[5]?a[5].replace(/^\/+|\/+$/g,""):null),{owner:s,repo:t,branch:r,subpath:o,rawTreeTail:l,fullName:`${s}/${t}`,httpsUrl:`https://github.com/${s}/${t}`,gitUrl:`https://github.com/${s}/${t}.git`,url:`https://github.com/${s}/${t}.git`}}const y=e.match(/^([A-Za-z0-9_-]+)\/([A-Za-z0-9_.-]+?)(?:\.git)?(?:@([A-Za-z0-9_./-]+))?$/);return y&&!y[1].startsWith("-")?(s=y[1],t=y[2],r=y[3]||r||null,{owner:s,repo:t,branch:r,subpath:null,fullName:`${s}/${t}`,httpsUrl:`https://github.com/${s}/${t}`,gitUrl:`https://github.com/${s}/${t}.git`,url:`https://github.com/${s}/${t}.git`}):null}function L(n,e){const s={};if(!n||!e||!n.existsSync(e))return s;const t=j.normalize(e);function r(o){let i=[];try{i=n.readdirSync(o)}catch{return}for(const f of i){if(f===".git"||f==="node_modules")continue;const a=j.join(o,f);let y;try{y=n.statSync(a)}catch{continue}if(y.isDirectory())r(a);else{const l=a.startsWith(t==="/"?"/":t+"/")?a.slice(t==="/"?1:t.length+1):f;try{s[l]=String(n.readFileSync(a,"utf8"))}catch(c){_.debug("Skipped unreadable VFS file in snapshot.",a,c)}}}}return r(t),s}function re(n){const e=String(n||"");let s=3735928559^e.length,t=1103547991^e.length;for(let o=0;o<e.length;o++){const i=e.charCodeAt(o);s=Math.imul(s^i,2654435761),t=Math.imul(t^i,1597334677)}return s=Math.imul(s^s>>>16,2246822507)^Math.imul(t^t>>>13,3266489909),t=Math.imul(t^t>>>16,2246822507)^Math.imul(s^s>>>13,3266489909),(4294967296*(2097151&t)+(s>>>0)).toString(16).padStart(7,"0").slice(0,7)}function ee(n,e){if(!n||typeof n!="string")return"";let s=n.trim().replace(/\\/g,"/");if(!s)return"";const t=j.normalize(e||"/workspace"),r=t==="/"?"/":t+"/";if(s===t)return"";for(s.startsWith(r)?s=s.slice(r.length):s.startsWith("/workspace/")&&(s=s.slice(11));s.startsWith("./");)s=s.slice(2);s.startsWith("/")&&(s=s.replace(/^\/+/,""));const o=[];for(const f of s.split("/"))if(!(!f||f===".")){if(f===".."){if(o.length===0)return"";o.pop();continue}o.push(f)}const i=o.join("/");return!i||i===".git"||i.startsWith(".git/")||i.includes("/.git/")||i.endsWith("/.git")||i==="node_modules"||i.startsWith("node_modules/")||i.includes("/node_modules/")||i.endsWith("/node_modules")?"":i}function oe(n){return(!Array.isArray(n&&n.commits)||n.commits.length===0)&&!(n&&n.headCommit)}function ue(n,e,s,t){if(!e)return!1;const r=t||n&&(n.headSnapshot||n.headFiles)||{},o=Object.prototype.hasOwnProperty.call(r,e),i=s==null?null:String(s);return i===null?o:!o||oe(n)?!0:i!==r[e]}function K(n,e,s,t,r){const o=n&&n.repoRoot||"/workspace",i=ee(s,o);if(!i)return;const f=t==null?null:String(t);ue(n,i,f,r)?e.set(i,f):e.delete(i)}function Y(n,e,s){if(!(e instanceof Map))return;const t=n&&n.repoRoot||"/workspace",r=s||n&&(n.headSnapshot||n.headFiles)||{};for(const[o,i]of Array.from(e.entries())){const f=ee(o,t);if(f!==o&&e.delete(o),!f){e.delete(o);continue}const a=i==null?null:String(i);ue(n,f,a,r)?e.set(f,a):e.delete(f)}}function Ze(n,e){if(!n||!n._initialBootSnapshot||!n._initialBootRoot)return{};const s=j.normalize(e),t=n._initialBootRoot;if(s===t)return n._initialBootSnapshot;const r=t==="/"?"/":t+"/";if(s.startsWith(r)){const o=s.slice(r.length)+"/",i={};for(const[f,a]of Object.entries(n._initialBootSnapshot))f.startsWith(o)&&(i[f.slice(o.length)]=a);return i}return{}}function Q(n,e,s,t){return n instanceof Map&&(n._hasShellStagedShim||(Object.defineProperty(n,"_hasShellStagedShim",{value:!0,enumerable:!1,configurable:!0,writable:!0}),Object.defineProperty(n,"add",{value(r){const o=typeof t=="function"?t():null,i=typeof s=="function"?s():o&&o.repoRoot||"/workspace",f=ee(r,i);if(!f)return n;let a=null;if(e&&typeof e.existsSync=="function"){const y=j.join(i,f);if(e.existsSync(y)){if(typeof e.statSync=="function")try{if(e.statSync(y).isDirectory())return n}catch(l){_.debug("Failed statting staged path in VFS.",y,l)}if(typeof e.readFileSync=="function")try{a=String(e.readFileSync(y,"utf8"))}catch(l){return _.debug("Failed reading staged file from VFS.",y,l),n}}}return o?K(o,n,f,a):n.set(f,a),n},enumerable:!1,configurable:!0,writable:!0}))),n}function Ke(n,e,s){const t=()=>n&&n.repoRoot||s||"/workspace",r=()=>n;if(n.staged instanceof Map)return Q(n.staged,e,t,r),Y(n,n.staged),n.stagedFiles=n.staged,n.staged;const o=Q(new Map,e,t,r);if(n.staged&&typeof n.staged[Symbol.iterator]=="function")for(const i of n.staged)Array.isArray(i)&&i.length>=2?K(n,o,i[0],i[1]===null?null:String(i[1])):typeof i=="string"&&o.add(i);return n.staged=o,n.stagedFiles=o,o}function Xe(n,e){if(!n||typeof n.existsSync!="function"||typeof n.readFileSync!="function")return null;const s=[j.join(e,".git/HEAD"),"/workspace/.git/HEAD"];for(const t of s)if(n.existsSync(t))try{const r=String(n.readFileSync(t,"utf8")).trim(),o=/^ref:\s*refs\/heads\/([^\s]+)$/.exec(r);if(o&&o[1])return o[1]}catch(r){_.debug("Could not parse .git/HEAD branch.",t,r)}return null}function Ye(n,e,s={}){const t=j.normalize(e||"/workspace"),r=!!(n&&typeof n.existsSync=="function"&&(n.existsSync(j.join(t,".git"))||n.existsSync(j.join(t,".git/HEAD"))||n.existsSync("/workspace/.git")||n.existsSync("/workspace/.git/HEAD")));let o=!!(s.gitInitialized===!0||r),i=t;const a=(r?Xe(n,t):null)||"main";let y=o?L(n,t):{},l=o?re(JSON.stringify(y)+":init"):"";const c=Date.now();let d=o?[{hash:l,author:"CodeLab Developer <dev@codelab.internal>",date:new Date(c).toUTCString(),timestamp:c,message:"Initial commit",files:Object.assign({},y)}]:[];const u={branch:a,branches:new Set([a]),remoteUrl:null,remotes:{}};let h=Q(new Map,n,()=>i,()=>u);return Object.defineProperties(u,{initialized:{enumerable:!0,configurable:!0,get(){if(o)return!0;const p=i||t;return n&&typeof n.existsSync=="function"&&(n.existsSync(j.join(p,".git"))||n.existsSync(j.join(p,".git/HEAD")))?(o=!0,!0):!1},set(p){o=!!p}},repoRoot:{enumerable:!0,configurable:!0,get(){return i},set(p){i=j.normalize(String(p||t))}},headCommit:{enumerable:!0,configurable:!0,get(){return l},set(p){l=String(p||"")}},headSnapshot:{enumerable:!0,configurable:!0,get(){return y},set(p){y=p&&typeof p=="object"?p:{}}},headFiles:{enumerable:!0,configurable:!0,get(){return y},set(p){y=p&&typeof p=="object"?p:{}}},staged:{enumerable:!0,configurable:!0,get(){return h},set(p){if(p instanceof Map)h=Q(p,n,()=>i,()=>u),Y(u,h);else{const g=Q(new Map,n,()=>i,()=>u);if(p&&typeof p[Symbol.iterator]=="function")for(const m of p)typeof m=="string"?g.add(m):Array.isArray(m)&&m.length>=2&&K(u,g,m[0],m[1]===null?null:String(m[1]));h=g}}},stagedFiles:{enumerable:!0,configurable:!0,get(){return h},set(p){p instanceof Map&&(h=Q(p,n,()=>i,()=>u),Y(u,h))}},commits:{enumerable:!0,configurable:!0,get(){return d},set(p){d=Array.isArray(p)?p:[],d.length>0&&d[0]&&d[0].hash?l=String(d[0].hash):d.length===0&&(l="")}}}),u}const Qe=/\.(png|jpg|jpeg|gif|webp|ico|bmp|tiff|woff|woff2|ttf|eot|otf|mp3|mp4|wav|ogg|webm|avi|mov|pdf|zip|tar|gz|tgz|bz2|7z|rar|exe|dll|so|dylib|wasm|pyc|pyo|class|jar|war|ear|bin|dat|iso|dmg|pkg|deb|rpm|o|a|lib|DS_Store)$/i;function xe(n){const e=n.toLowerCase(),s=j.basename(e),t=n.split("/").length;return s==="readme.md"||s==="package.json"||s==="cargo.toml"||s==="go.mod"||s==="pyproject.toml"?0:t===1&&/\.(js|ts|jsx|tsx|mjs|cjs|py|go|rs|json|md|yml|yaml|toml|sh)$/.test(e)?1:e.startsWith("src/")||e.startsWith("lib/")||e.startsWith("app/")?2+t*.1:e.startsWith("test/")||e.startsWith("tests/")||e.startsWith("examples/")?5+t*.1:10+t*.1}async function et(n,e,s={}){const t=typeof s.onProgress=="function"?s.onProgress:null;t&&t({phase:"connecting",message:`Connecting to repository '${n}'...`});const r=fe(n);if(!r)throw new Error(`fatal: repository '${n}' does not exist or is not a valid GitHub repository URL`);if(!e)throw new Error("fatal: virtual filesystem (vfs) is required to clone repository");const o=s.fetchImpl||(typeof fetch=="function"?fetch.bind(globalThis):null);if(!o)throw new Error("fatal: global fetch API is unavailable in this environment");const i=j.normalize(s.targetDir||"/workspace"),f=s.maxFiles||250,a=s.maxFileSize||512*1024,y=s.branch||r.branch||null,{owner:l,repo:c}=r,d=s.signal||null,u=()=>{if(d&&d.aborted){const T=new Error("fatal: clone cancelled (SIGINT)");throw T.name="AbortError",T}};u();let h=y,p=null,g=!1;t&&t({phase:"metadata",message:`Fetching repository metadata for ${l}/${c}...`});try{if(!h){const T=await o(`https://api.github.com/repos/${l}/${c}`,{headers:{Accept:"application/vnd.github.v3+json"},signal:d});if(T.status===404)g=!0;else if(T.ok){const k=await T.json();k&&k.default_branch&&(h=k.default_branch)}}if(!g){const T=Array.from(y?new Set([y,!s.branch&&r.rawTreeTail&&r.rawTreeTail!==y?r.rawTreeTail:null].filter(Boolean)):new Set([h,"main","master"].filter(Boolean)));for(const k of T){u();const O=await o(`https://api.github.com/repos/${l}/${c}/git/trees/${encodeURIComponent(k)}?recursive=1`,{headers:{Accept:"application/vnd.github.v3+json"},signal:d});if(O.ok){const F=await O.json();if(F&&Array.isArray(F.tree)){h=k,r.rawTreeTail&&k===r.rawTreeTail&&(r.subpath=null),p=F.tree.filter(P=>P&&P.type==="blob"&&P.path).map(P=>({path:P.path.replace(/^\/+/,""),size:P.size||0}));break}}}}}catch(T){_.debug("GitHub REST API tree fetch failed; falling back to jsDelivr.",T)}if(!p&&!g)try{const T=y?[y]:Array.from(new Set([h,"main","master"].filter(Boolean)));for(const k of T){u();const O=await o(`https://data.jsdelivr.com/v1/package/gh/${l}/${c}@${encodeURIComponent(k)}/flat`,{signal:d});if(O&&O.ok){const F=await O.json();if(F&&Array.isArray(F.files)&&F.files.length>0){h=k,p=F.files.filter(P=>P&&P.name).map(P=>({path:P.name.replace(/^\/+/,""),size:P.size||0}));break}}}}catch(T){_.debug("jsDelivr flat tree fetch failed.",T)}if(g||!p)throw new Error(`fatal: repository '${r.url}' not found or could not be fetched`);const m=r.subpath?r.subpath.replace(/^\/+|\/+$/g,"")+"/":null,S=[];for(const T of p){let k=T.path;if(m)if(T.path===r.subpath)k=j.basename(T.path);else if(T.path.startsWith(m))k=T.path.slice(m.length);else continue;!k||k.startsWith(".git/")||k.includes("/node_modules/")||k.startsWith("node_modules/")||Qe.test(k)||T.size&&T.size>a||S.push({repoPath:T.path,destPath:k,size:T.size||0,priority:xe(k)})}S.sort((T,k)=>T.priority-k.priority||T.destPath.localeCompare(k.destPath));const b=S.slice(0,f),v=b.length;t&&t({phase:"downloading",message:`Downloading files (0/${v})...`,loaded:0,total:v}),e.existsSync(i)||e.mkdirSync(i,{recursive:!0});const w={};let $=0,R=0;const I=12;for(let T=0;T<b.length;T+=I){u();const k=b.slice(T,T+I);await Promise.all(k.map(async O=>{u();const F=O.repoPath.split("/").map(encodeURIComponent).join("/"),P=`https://raw.githubusercontent.com/${l}/${c}/${encodeURIComponent(h)}/${F}`,A=`https://cdn.jsdelivr.net/gh/${l}/${c}@${encodeURIComponent(h)}/${F}`;let M=null;try{const D=await o(P,{signal:d});D&&D.ok&&(M=await D.text())}catch(D){if(d&&d.aborted)throw D}if(M===null)try{const D=await o(A,{signal:d});D&&D.ok&&(M=await D.text())}catch(D){if(d&&d.aborted)throw D}if(M!==null&&M.length<=a){const D=j.join(i,O.destPath),N=j.dirname(D);e.existsSync(N)||e.mkdirSync(N,{recursive:!0}),e.writeFileSync(D,M),w[O.destPath]=M,$++,R+=M.length,t&&t({phase:"downloading",message:`Downloading files (${$}/${v}): ${O.destPath}`,loaded:$,total:v}),typeof s.onFile=="function"&&s.onFile(D,M,O.destPath)}}))}u(),t&&t({phase:"mounting",message:`Mounting files and writing Git metadata into ${i}...`,loaded:$,total:v});const C=j.join(i,".git");e.existsSync(C)||e.mkdirSync(C,{recursive:!0}),e.writeFileSync(j.join(C,"HEAD"),`ref: refs/heads/${h}
199
191
  `),e.writeFileSync(j.join(C,"config"),`[core]
200
192
  repositoryformatversion = 0
201
193
  filemode = true
@@ -203,191 +195,191 @@ if (typeof CodeLabScm !== 'undefined') _root.CodeLabScm = CodeLabScm;
203
195
  [remote "origin"]
204
196
  url = ${r.url}
205
197
  fetch = +refs/heads/*:refs/remotes/origin/*
206
- [branch "${u}"]
198
+ [branch "${h}"]
207
199
  remote = origin
208
- merge = refs/heads/${u}
209
- `);let E=[];try{const T=await o(`https://api.github.com/repos/${l}/${a}/commits?sha=${encodeURIComponent(u)}&per_page=10`,{headers:{Accept:"application/vnd.github.v3+json"},signal:c});if(T&&T.ok){const k=await T.json();Array.isArray(k)&&k.length>0&&(E=k.map((O,F)=>{const P=O.commit&&O.commit.message?String(O.commit.message).split(`
210
- `)[0]:"Commit",A=re(`${l}/${a}:${u}:${F}:${P}`),M=O.commit&&O.commit.author&&O.commit.author.date&&Date.parse(O.commit.author.date)||Date.now();return{hash:String(O.sha||A).slice(0,7),author:O.commit&&O.commit.author?`${O.commit.author.name||l} <${O.commit.author.email||`${l}@users.noreply.github.com`}>`:`${l} <${l}@users.noreply.github.com>`,date:new Date(M).toUTCString(),timestamp:M,message:P}}))}}catch(T){N.debug("Optional commit history fetch skipped.",T)}if(E.length===0){const T=Date.now();E=[{hash:re(`${l}/${a}:${u}:${$}`),author:`${l} <${l}@users.noreply.github.com>`,date:new Date(T).toUTCString(),timestamp:T,message:`Clone ${l}/${a} (${u})`}]}return t&&t({phase:"ready",message:`Repository cloned successfully (${$} files).`,loaded:$,total:v}),{owner:l,repo:a,branch:u,url:r.url,targetDir:i,count:$,fileCount:$,filesWritten:$,totalBytes:R,commits:E,headSnapshot:w}}async function he(n,e,s={}){const t=typeof s.onProgress=="function"?s.onProgress:null;try{return await tt(n,e,s)}catch(r){throw t&&t({phase:"error",message:r&&r.message?r.message:String(r)}),r}}function nt(n,e){const s=j.join(e||"/workspace","package.json");if(n.existsSync(s))return s;const t="/workspace/package.json";return n.existsSync(t)?t:s}function H(n,e){const s=nt(n,e);if(n.existsSync(s))try{const t=JSON.parse(n.readFileSync(s,"utf8"));return{path:s,data:t}}catch(t){N.warn(`Invalid JSON in ${s}; falling back to default package metadata.`,t)}return{path:s,data:{name:"app",dependencies:{},devDependencies:{},scripts:{}}}}function De(n,e,s,t){const r=j.dirname(e);n.existsSync(r)||n.mkdirSync(r,{recursive:!0});const o=JSON.stringify(s,null,2)+`
211
- `;n.writeFileSync(e,o),typeof t=="function"&&t("change",e)}function G(n,e,s){n.existsSync(e)||(n.mkdirSync(e,{recursive:!0}),typeof s=="function"&&s("create",e))}function pe(n,e,s){if(n.existsSync(e))try{if(typeof n.rmSync=="function")n.rmSync(e,{recursive:!0,force:!0});else{const t=n.readdirSync(e);for(const r of t){const o=j.join(e,r);n.statSync(o).isDirectory()?pe(n,o,s):n.unlinkSync(o)}n.rmdirSync(e)}typeof s=="function"&&s("delete",e)}catch(t){N.debug("removeDirRecursive failed.",e,t)}}const Ie="https://cdn.jsdelivr.net/npm",st=["https://cdn.jsdelivr.net/npm","https://unpkg.com","https://esm.sh"],rt={"is-even":`module.exports = function isEven(n) { return (Number(n) % 2) === 0; };
200
+ merge = refs/heads/${h}
201
+ `);let E=[];try{const T=await o(`https://api.github.com/repos/${l}/${c}/commits?sha=${encodeURIComponent(h)}&per_page=10`,{headers:{Accept:"application/vnd.github.v3+json"},signal:d});if(T&&T.ok){const k=await T.json();Array.isArray(k)&&k.length>0&&(E=k.map((O,F)=>{const P=O.commit&&O.commit.message?String(O.commit.message).split(`
202
+ `)[0]:"Commit",A=re(`${l}/${c}:${h}:${F}:${P}`),M=O.commit&&O.commit.author&&O.commit.author.date&&Date.parse(O.commit.author.date)||Date.now();return{hash:String(O.sha||A).slice(0,7),author:O.commit&&O.commit.author?`${O.commit.author.name||l} <${O.commit.author.email||`${l}@users.noreply.github.com`}>`:`${l} <${l}@users.noreply.github.com>`,date:new Date(M).toUTCString(),timestamp:M,message:P}}))}}catch(T){_.debug("Optional commit history fetch skipped.",T)}if(E.length===0){const T=Date.now();E=[{hash:re(`${l}/${c}:${h}:${$}`),author:`${l} <${l}@users.noreply.github.com>`,date:new Date(T).toUTCString(),timestamp:T,message:`Clone ${l}/${c} (${h})`}]}return t&&t({phase:"ready",message:`Repository cloned successfully (${$} files).`,loaded:$,total:v}),{owner:l,repo:c,branch:h,url:r.url,targetDir:i,count:$,fileCount:$,filesWritten:$,totalBytes:R,commits:E,headSnapshot:w}}async function he(n,e,s={}){const t=typeof s.onProgress=="function"?s.onProgress:null;try{return await et(n,e,s)}catch(r){throw t&&t({phase:"error",message:r&&r.message?r.message:String(r)}),r}}function tt(n,e){const s=j.join(e||"/workspace","package.json");if(n.existsSync(s))return s;const t="/workspace/package.json";return n.existsSync(t)?t:s}function H(n,e){const s=tt(n,e);if(n.existsSync(s))try{const t=JSON.parse(n.readFileSync(s,"utf8"));return{path:s,data:t}}catch(t){_.warn(`Invalid JSON in ${s}; falling back to default package metadata.`,t)}return{path:s,data:{name:"app",dependencies:{},devDependencies:{},scripts:{}}}}function De(n,e,s,t){const r=j.dirname(e);n.existsSync(r)||n.mkdirSync(r,{recursive:!0});const o=JSON.stringify(s,null,2)+`
203
+ `;n.writeFileSync(e,o),typeof t=="function"&&t("change",e)}function G(n,e,s){n.existsSync(e)||(n.mkdirSync(e,{recursive:!0}),typeof s=="function"&&s("create",e))}function pe(n,e,s){if(n.existsSync(e))try{if(typeof n.rmSync=="function")n.rmSync(e,{recursive:!0,force:!0});else{const t=n.readdirSync(e);for(const r of t){const o=j.join(e,r);n.statSync(o).isDirectory()?pe(n,o,s):n.unlinkSync(o)}n.rmdirSync(e)}typeof s=="function"&&s("delete",e)}catch(t){_.debug("removeDirRecursive failed.",e,t)}}const Ie="https://cdn.jsdelivr.net/npm",nt=["https://cdn.jsdelivr.net/npm","https://unpkg.com","https://esm.sh"],st={"is-even":`module.exports = function isEven(n) { return (Number(n) % 2) === 0; };
212
204
  `,"tiny-invariant":`module.exports = function invariant(condition, message) { if (!condition) throw new Error(message || "Invariant failed"); };
213
205
  `,lodash:`module.exports = { isArray: Array.isArray, isObject: function (v) { return v !== null && typeof v === "object"; } };
214
206
  `,"left-pad":`module.exports = function leftPad(str, len, ch) { str = String(str); ch = (ch === undefined ? " " : String(ch)); while (str.length < len) str = ch + str; return str.slice(-len); };
215
- `};function ot(n){return n&&n.shell&&n.shell.options&&typeof n.shell.options.fetchImpl=="function"?n.shell.options.fetchImpl:typeof fetch=="function"?fetch.bind(globalThis):null}function ye(n){const e=String(n||"").trim();if(!e)return{name:"",range:null};if(e.startsWith("@")){const t=e.indexOf("@",1);return t===-1?{name:e,range:null}:{name:e.slice(0,t),range:e.slice(t+1)||null}}const s=e.indexOf("@");return s<=0?{name:e,range:null}:{name:e.slice(0,s),range:e.slice(s+1)||null}}function te(n){if(typeof n=="string")return n;if(Array.isArray(n)){for(const e of n){const s=te(e);if(s)return s}return null}if(!n||typeof n!="object")return null;for(const e of["require","node","default","browser","import","module"])if(n[e]!==void 0){const s=te(n[e]);if(s)return s}return null}function Ae(n){let e=null;const s=n&&n.exports;return typeof s=="string"?e=s:s&&typeof s=="object"&&s["."]!==void 0&&(e=te(s["."])),e||(e=n.main||n.module||(typeof n.browser=="string"?n.browser:"")||"index.js"),e=String(e).replace(/^[./]+/,""),e||"index.js"}function _e(n){return String(n||"").replace(/^[./]+/,"")}function it(n){const e=new Set,s=[/\bfrom\s*['"](\.{1,2}\/[^'"]+)['"]/g,/\brequire\s*\(\s*['"](\.{1,2}\/[^'"]+)['"]/g,/\bimport\s*\(\s*['"](\.{1,2}\/[^'"]+)['"]/g,/\bimport\s*['"](\.{1,2}\/[^'"]+)['"]/g];for(const t of s){let r;for(;(r=t.exec(n))!==null;)e.add(r[1])}return Array.from(e)}function lt(n,e){const s=String(n||"").split("/").filter(Boolean);for(const t of String(e).split("/"))!t||t==="."||(t===".."?s.pop():s.push(t));return s.join("/")}function me(n){return new Promise(e=>{typeof setTimeout=="function"?setTimeout(e,n):e()})}async function ge(n,e){for(let t=1;t<=3;t++)try{const r=await n(e);if(!r){if(t<3){await me(t*150);continue}return null}if(!(r.ok===!0||r.status===200||r.status===void 0)){if((r.status>=500||r.status===429||r.status===408)&&t<3){await me(t*150);continue}return null}const i=r.headers&&typeof r.headers.get=="function"&&r.headers.get("content-type")||"",f=/\.html?(?:[?#]|$)/i.test(e);if(/text\/html/i.test(i)&&!f)return null;const d=typeof r.text=="function"?await r.text():String(r.body!=null?r.body:"");return!f&&/^\s*(?:<!doctype\s+html|<html[\s>]|<head[\s>])/i.test(d)?null:d}catch{if(t<3){await me(t*150);continue}return null}return null}async function at(n,e,s){for(const t of st){const r=s?[`${t}/${e}@${s}/package.json`,`${t}/${e}/package.json`]:[`${t}/${e}/package.json`];for(const o of r){const i=await ge(n,o);if(i)try{const f=JSON.parse(i);if(f&&f.version)return f._resolvedCdnBase=t,f}catch(f){N.debug("Invalid package.json metadata from CDN.",o,f)}}}return null}async function ct(n,e,s,t){const r=await at(n,e,s);if(!r){const b=rt[e];return b?{ok:!0,offline:!0,version:s&&s.replace(/^[\^~>=<\s]+/,"")||"1.0.0",entry:"index.js",files:[{rel:"index.js",content:b}],deps:[]}:{ok:!1,reason:`${e}: package metadata not found on the registry (offline?)`}}const o=r._resolvedCdnBase||Ie,i=r.version,f=`${e}@${i}`;if(t.has(f))return{ok:!0,deduped:!0,version:i,entry:Ae(r),files:[],deps:[]};t.add(f);const d=Ae(r),y=[],l=new Set,a=[d,`${d}.js`,`${d}.json`,`${d}.mjs`,`${d}.cjs`,`${d}/index.js`,`${d}/index.json`,`${d}/index.mjs`,`${d}/index.cjs`],c=r.exports;if(c&&typeof c=="object")for(const b of Object.keys(c)){if(b==="."||b.slice(0,2)!=="./"||b.includes("*"))continue;const v=te(c[b]);v&&a.push(v)}let h=a;for(;h.length>0;){const b=[];for(const w of h){const $=_e(w);!$||$.endsWith("/")||l.has($)||(l.add($),b.push($))}if(h=[],b.length===0)break;const v=await Promise.all(b.map(w=>ge(n,`${o}/${e}@${i}/${w}`)));for(let w=0;w<b.length;w++){const $=b[w],R=v[w];if(R===null)continue;y.push({rel:$,content:R});const I=$.includes("/")?$.slice(0,$.lastIndexOf("/")):"";for(const C of it(R)){const E=lt(I,C),T=/\.[a-z0-9]+$/i.test(E)?[E]:[E,`${E}.js`,`${E}.json`,`${E}.mjs`,`${E}.cjs`,`${E}/index.js`];for(const k of T){const O=_e(k);O&&!l.has(O)&&h.push(k)}}}}if(!y.some(b=>b.rel===d)){const b=await ge(n,`${o}/${e}@${i}/index.js`);b!==null&&y.push({rel:"index.js",content:b})}const u=[],p=new Set,g=r.dependencies||{};for(const b of Object.keys(g))p.has(b)||(p.add(b),u.push({name:b,range:g[b]||null}));const m=r.peerDependenciesMeta||{},S=r.peerDependencies||{};for(const b of Object.keys(S))m[b]&&m[b].optional||p.has(b)||(p.add(b),u.push({name:b,range:S[b]||null}));return{ok:!0,version:i,entry:d,files:y,deps:u,pkgBin:r.bin||null,pkgExports:r.exports&&typeof r.exports=="object"?r.exports:null}}function Ne(n,e){const s=["/workspace/node_modules/"+e],t=j.join(n.cwd||"/workspace","node_modules",e);return s.includes(t)||s.push(t),s}function Me(n,e,s,t){for(const r of e){G(n.vfs,r,n.emitMutation);for(const f of t.files){if(!f||!f.rel||f.rel.endsWith("/"))continue;const d=j.join(r,f.rel);try{if(n.vfs.existsSync(d)&&n.vfs.statSync(d).isDirectory())continue}catch(y){N.debug("Package install statSync check skipped.",d,y)}G(n.vfs,j.dirname(d),n.emitMutation),n.vfs.writeFileSync(d,f.content),typeof n.emitMutation=="function"&&n.emitMutation("create",d)}const o=j.join(r,"package.json"),i={name:s,version:t.version||"1.0.0",main:"./"+(t.entry||"index.js")};if(t.pkgBin&&(i.bin=t.pkgBin),t.pkgExports&&typeof t.pkgExports=="object"){const f={".":"./"+(t.entry||"index.js")};for(const d of Object.keys(t.pkgExports)){if(d==="."||d.indexOf("*")!==-1)continue;const y=te(t.pkgExports[d]);y&&(f[d]=y.charAt(0)==="."?y:"./"+y)}i.exports=f}if(n.vfs.writeFileSync(o,JSON.stringify(i,null,2)+`
216
- `),typeof n.emitMutation=="function"&&n.emitMutation("create",o),t.pkgBin){const f=r.slice(0,r.length-s.length-1),d=j.join(f,".bin");G(n.vfs,d,n.emitMutation);const y=typeof t.pkgBin=="string"?{[s.includes("/")?s.split("/").pop():s]:t.pkgBin}:typeof t.pkgBin=="object"?t.pkgBin:{};for(const[l,a]of Object.entries(y)){if(!l||!a)continue;const c=j.join(r,String(a).replace(/^\.\//,"")),h=j.join(d,l),u=`// Auto-generated bin shim for ${s}
217
- require(${JSON.stringify(c)});
218
- `;if(n.vfs.writeFileSync(h,u),typeof n.vfs.chmodSync=="function")try{n.vfs.chmodSync(h,493)}catch(p){}typeof n.emitMutation=="function"&&n.emitMutation("create",h)}}}}async function dt(n,e,s,t){const r=s&&typeof s=="object"?s:t||{},o=typeof s=="function"?s:typeof r.onLine=="function"?r.onLine:null,i=!!r.dev,{name:f,range:d}=ye(n);if(!f)return{name:null,ok:!1,installed:[],warning:null};const{path:y,data:l}=H(e.vfs,e.cwd),a=i?"devDependencies":"dependencies";l[a]||(l[a]={});const c=ot(e),h=e.shell&&e.shell._cdnSeen?e.shell._cdnSeen:e.shell?e.shell._cdnSeen=new Set:new Set,u=[{name:f,range:d,direct:!0}],p=new Set([f]),g=[];let m=null,S=null;for(;u.length>0;){const b=u.shift(),v=c?await ct(c,b.name,b.range,h):{ok:!1,reason:`${b.name}: no fetch implementation available`};if(!v.ok){Me(e,Ne(e,b.name),b.name,{version:"0.0.0",entry:"index.js",files:[{rel:"index.js",content:`module.exports = {};
219
- `}]}),m||(m=v.reason),g.push({name:b.name,version:"0.0.0"}),typeof o=="function"&&o({name:b.name,version:"0.0.0",offline:!0});continue}Me(e,Ne(e,b.name),b.name,v),g.push({name:b.name,version:v.version||"1.0.0"}),typeof o=="function"&&o({name:b.name,version:v.version||"1.0.0",deduped:!!v.deduped}),b.direct&&(S=v.version||null);for(const w of v.deps||[]){const $=w&&typeof w=="object"?w.name:ye(w).name,R=w&&typeof w=="object"?w.range:ye(w).range;$&&!p.has($)&&(p.add($),u.push({name:$,range:R||null,direct:!1}))}}l[a][f]=d||(S?`^${S}`:l[a][f]||"latest"),De(e.vfs,y,l,e.emitMutation);try{const b=j.join(j.dirname(y),"package-lock.json");let v={name:l.name||"workspace",version:l.version||"1.0.0",lockfileVersion:3,packages:{}};if(e.vfs.existsSync(b)){const w=String(e.vfs.readFileSync(b,"utf8")||""),$=JSON.parse(w);$&&typeof $=="object"&&(v=$,(!v.packages||typeof v.packages!="object")&&(v.packages={}))}for(const w of g)w&&w.name&&(v.packages[`node_modules/${w.name}`]={version:w.version||"1.0.0",resolved:`${Ie}/${w.name}@${w.version||"1.0.0"}`});e.vfs.writeFileSync(b,JSON.stringify(v,null,2)+`
220
- `),typeof e.emitMutation=="function"&&e.emitMutation("modify",b)}catch(b){N.debug("Could not write package-lock.json during installPackage.",b)}return{name:f,ok:!0,version:S,installed:g,warning:m}}function ft(n,e){const s=n&&typeof n.onStdout=="function"?n.onStdout:null;return function(r){r&&(e.push(r),s&&s(r))}}function ut(n){if(!n||!n.name)return"";const e=n.offline?" (offline fallback)":n.deduped?" (deduped)":"";return` + ${n.name}@${n.version||"1.0.0"}${e}
221
- `}function ht(n){const e=new Set;for(const s of n)if(s){s.name&&e.add(s.name);for(const t of s.installed||[])t&&t.name&&e.add(t.name)}return e.size}async function ne(n,e,s){const t=s||{},r=t.manager||"bun",o=t.header||(r==="npm"?"npm install v10.2.0":"bun add v1.1.20 (1.1.20)"),i=[],f=ft(e,i),d=Date.now();f(`${o}
207
+ `};function rt(n){return n&&n.shell&&n.shell.options&&typeof n.shell.options.fetchImpl=="function"?n.shell.options.fetchImpl:typeof fetch=="function"?fetch.bind(globalThis):null}function ye(n){const e=String(n||"").trim();if(!e)return{name:"",range:null};if(e.startsWith("@")){const t=e.indexOf("@",1);return t===-1?{name:e,range:null}:{name:e.slice(0,t),range:e.slice(t+1)||null}}const s=e.indexOf("@");return s<=0?{name:e,range:null}:{name:e.slice(0,s),range:e.slice(s+1)||null}}function te(n){if(typeof n=="string")return n;if(Array.isArray(n)){for(const e of n){const s=te(e);if(s)return s}return null}if(!n||typeof n!="object")return null;for(const e of["require","node","default","browser","import","module"])if(n[e]!==void 0){const s=te(n[e]);if(s)return s}return null}function Ae(n){let e=null;const s=n&&n.exports;return typeof s=="string"?e=s:s&&typeof s=="object"&&s["."]!==void 0&&(e=te(s["."])),e||(e=n.main||n.module||(typeof n.browser=="string"?n.browser:"")||"index.js"),e=String(e).replace(/^[./]+/,""),e||"index.js"}function Ne(n){return String(n||"").replace(/^[./]+/,"")}function ot(n){const e=new Set,s=[/\bfrom\s*['"](\.{1,2}\/[^'"]+)['"]/g,/\brequire\s*\(\s*['"](\.{1,2}\/[^'"]+)['"]/g,/\bimport\s*\(\s*['"](\.{1,2}\/[^'"]+)['"]/g,/\bimport\s*['"](\.{1,2}\/[^'"]+)['"]/g];for(const t of s){let r;for(;(r=t.exec(n))!==null;)e.add(r[1])}return Array.from(e)}function it(n,e){const s=String(n||"").split("/").filter(Boolean);for(const t of String(e).split("/"))!t||t==="."||(t===".."?s.pop():s.push(t));return s.join("/")}function me(n){return new Promise(e=>{typeof setTimeout=="function"?setTimeout(e,n):e()})}async function ge(n,e){for(let t=1;t<=3;t++)try{const r=await n(e);if(!r){if(t<3){await me(t*150);continue}return null}if(!(r.ok===!0||r.status===200||r.status===void 0)){if((r.status>=500||r.status===429||r.status===408)&&t<3){await me(t*150);continue}return null}const i=r.headers&&typeof r.headers.get=="function"&&r.headers.get("content-type")||"",f=/\.html?(?:[?#]|$)/i.test(e);if(/text\/html/i.test(i)&&!f)return null;const a=typeof r.text=="function"?await r.text():String(r.body!=null?r.body:"");return!f&&/^\s*(?:<!doctype\s+html|<html[\s>]|<head[\s>])/i.test(a)?null:a}catch{if(t<3){await me(t*150);continue}return null}return null}async function lt(n,e,s){for(const t of nt){const r=s?[`${t}/${e}@${s}/package.json`,`${t}/${e}/package.json`]:[`${t}/${e}/package.json`];for(const o of r){const i=await ge(n,o);if(i)try{const f=JSON.parse(i);if(f&&f.version)return f._resolvedCdnBase=t,f}catch(f){_.debug("Invalid package.json metadata from CDN.",o,f)}}}return null}async function at(n,e,s,t){const r=await lt(n,e,s);if(!r){const b=st[e];return b?{ok:!0,offline:!0,version:s&&s.replace(/^[\^~>=<\s]+/,"")||"1.0.0",entry:"index.js",files:[{rel:"index.js",content:b}],deps:[]}:{ok:!1,reason:`${e}: package metadata not found on the registry (offline?)`}}const o=r._resolvedCdnBase||Ie,i=r.version,f=`${e}@${i}`;if(t.has(f))return{ok:!0,deduped:!0,version:i,entry:Ae(r),files:[],deps:[]};t.add(f);const a=Ae(r),y=[],l=new Set,c=[a,`${a}.js`,`${a}.json`,`${a}.mjs`,`${a}.cjs`,`${a}/index.js`,`${a}/index.json`,`${a}/index.mjs`,`${a}/index.cjs`],d=r.exports;if(d&&typeof d=="object")for(const b of Object.keys(d)){if(b==="."||b.slice(0,2)!=="./"||b.includes("*"))continue;const v=te(d[b]);v&&c.push(v)}let u=c;for(;u.length>0;){const b=[];for(const w of u){const $=Ne(w);!$||$.endsWith("/")||l.has($)||(l.add($),b.push($))}if(u=[],b.length===0)break;const v=await Promise.all(b.map(w=>ge(n,`${o}/${e}@${i}/${w}`)));for(let w=0;w<b.length;w++){const $=b[w],R=v[w];if(R===null)continue;y.push({rel:$,content:R});const I=$.includes("/")?$.slice(0,$.lastIndexOf("/")):"";for(const C of ot(R)){const E=it(I,C),T=/\.[a-z0-9]+$/i.test(E)?[E]:[E,`${E}.js`,`${E}.json`,`${E}.mjs`,`${E}.cjs`,`${E}/index.js`];for(const k of T){const O=Ne(k);O&&!l.has(O)&&u.push(k)}}}}if(!y.some(b=>b.rel===a)){const b=await ge(n,`${o}/${e}@${i}/index.js`);b!==null&&y.push({rel:"index.js",content:b})}const h=[],p=new Set,g=r.dependencies||{};for(const b of Object.keys(g))p.has(b)||(p.add(b),h.push({name:b,range:g[b]||null}));const m=r.peerDependenciesMeta||{},S=r.peerDependencies||{};for(const b of Object.keys(S))m[b]&&m[b].optional||p.has(b)||(p.add(b),h.push({name:b,range:S[b]||null}));return{ok:!0,version:i,entry:a,files:y,deps:h,pkgBin:r.bin||null,pkgExports:r.exports&&typeof r.exports=="object"?r.exports:null}}function _e(n,e){const s=["/workspace/node_modules/"+e],t=j.join(n.cwd||"/workspace","node_modules",e);return s.includes(t)||s.push(t),s}function Me(n,e,s,t){for(const r of e){G(n.vfs,r,n.emitMutation);for(const f of t.files){if(!f||!f.rel||f.rel.endsWith("/"))continue;const a=j.join(r,f.rel);try{if(n.vfs.existsSync(a)&&n.vfs.statSync(a).isDirectory())continue}catch(y){_.debug("Package install statSync check skipped.",a,y)}G(n.vfs,j.dirname(a),n.emitMutation),n.vfs.writeFileSync(a,f.content),typeof n.emitMutation=="function"&&n.emitMutation("create",a)}const o=j.join(r,"package.json"),i={name:s,version:t.version||"1.0.0",main:"./"+(t.entry||"index.js")};if(t.pkgBin&&(i.bin=t.pkgBin),t.pkgExports&&typeof t.pkgExports=="object"){const f={".":"./"+(t.entry||"index.js")};for(const a of Object.keys(t.pkgExports)){if(a==="."||a.indexOf("*")!==-1)continue;const y=te(t.pkgExports[a]);y&&(f[a]=y.charAt(0)==="."?y:"./"+y)}i.exports=f}if(n.vfs.writeFileSync(o,JSON.stringify(i,null,2)+`
208
+ `),typeof n.emitMutation=="function"&&n.emitMutation("create",o),t.pkgBin){const f=r.slice(0,r.length-s.length-1),a=j.join(f,".bin");G(n.vfs,a,n.emitMutation);const y=typeof t.pkgBin=="string"?{[s.includes("/")?s.split("/").pop():s]:t.pkgBin}:typeof t.pkgBin=="object"?t.pkgBin:{};for(const[l,c]of Object.entries(y)){if(!l||!c)continue;const d=j.join(r,String(c).replace(/^\.\//,"")),u=j.join(a,l),h=`// Auto-generated bin shim for ${s}
209
+ require(${JSON.stringify(d)});
210
+ `;if(n.vfs.writeFileSync(u,h),typeof n.vfs.chmodSync=="function")try{n.vfs.chmodSync(u,493)}catch(p){}typeof n.emitMutation=="function"&&n.emitMutation("create",u)}}}}async function ct(n,e,s,t){const r=s&&typeof s=="object"?s:t||{},o=typeof s=="function"?s:typeof r.onLine=="function"?r.onLine:null,i=!!r.dev,{name:f,range:a}=ye(n);if(!f)return{name:null,ok:!1,installed:[],warning:null};const{path:y,data:l}=H(e.vfs,e.cwd),c=i?"devDependencies":"dependencies";l[c]||(l[c]={});const d=rt(e),u=e.shell&&e.shell._cdnSeen?e.shell._cdnSeen:e.shell?e.shell._cdnSeen=new Set:new Set,h=[{name:f,range:a,direct:!0}],p=new Set([f]),g=[];let m=null,S=null;for(;h.length>0;){const b=h.shift(),v=d?await at(d,b.name,b.range,u):{ok:!1,reason:`${b.name}: no fetch implementation available`};if(!v.ok){Me(e,_e(e,b.name),b.name,{version:"0.0.0",entry:"index.js",files:[{rel:"index.js",content:`module.exports = {};
211
+ `}]}),m||(m=v.reason),g.push({name:b.name,version:"0.0.0"}),typeof o=="function"&&o({name:b.name,version:"0.0.0",offline:!0});continue}Me(e,_e(e,b.name),b.name,v),g.push({name:b.name,version:v.version||"1.0.0"}),typeof o=="function"&&o({name:b.name,version:v.version||"1.0.0",deduped:!!v.deduped}),b.direct&&(S=v.version||null);for(const w of v.deps||[]){const $=w&&typeof w=="object"?w.name:ye(w).name,R=w&&typeof w=="object"?w.range:ye(w).range;$&&!p.has($)&&(p.add($),h.push({name:$,range:R||null,direct:!1}))}}l[c][f]=a||(S?`^${S}`:l[c][f]||"latest"),De(e.vfs,y,l,e.emitMutation);try{const b=j.join(j.dirname(y),"package-lock.json");let v={name:l.name||"workspace",version:l.version||"1.0.0",lockfileVersion:3,packages:{}};if(e.vfs.existsSync(b)){const w=String(e.vfs.readFileSync(b,"utf8")||""),$=JSON.parse(w);$&&typeof $=="object"&&(v=$,(!v.packages||typeof v.packages!="object")&&(v.packages={}))}for(const w of g)w&&w.name&&(v.packages[`node_modules/${w.name}`]={version:w.version||"1.0.0",resolved:`${Ie}/${w.name}@${w.version||"1.0.0"}`});e.vfs.writeFileSync(b,JSON.stringify(v,null,2)+`
212
+ `),typeof e.emitMutation=="function"&&e.emitMutation("modify",b)}catch(b){_.debug("Could not write package-lock.json during installPackage.",b)}return{name:f,ok:!0,version:S,installed:g,warning:m}}function dt(n,e){const s=n&&typeof n.onStdout=="function"?n.onStdout:null;return function(r){r&&(e.push(r),s&&s(r))}}function ft(n){if(!n||!n.name)return"";const e=n.offline?" (offline fallback)":n.deduped?" (deduped)":"";return` + ${n.name}@${n.version||"1.0.0"}${e}
213
+ `}function ut(n){const e=new Set;for(const s of n)if(s){s.name&&e.add(s.name);for(const t of s.installed||[])t&&t.name&&e.add(t.name)}return e.size}async function ne(n,e,s){const t=s||{},r=t.manager||"bun",o=t.header||(r==="npm"?"npm install v10.2.0":"bun add v1.1.20 (1.1.20)"),i=[],f=dt(e,i),a=Date.now();f(`${o}
222
214
 
223
215
  Resolving dependencies...
224
- `);const y=[];for(const h of n)y.push(await dt(h,e,{onLine:u=>f(ut(u)),dev:!!t.dev}));const l=y.map(h=>h&&h.warning).filter(Boolean)[0],a=ht(y),c=Date.now()-d;return f(r==="npm"?`
225
- added ${a} package(s) in ${c}ms
216
+ `);const y=[];for(const u of n)y.push(await ct(u,e,{onLine:h=>f(ft(h)),dev:!!t.dev}));const l=y.map(u=>u&&u.warning).filter(Boolean)[0],c=ut(y),d=Date.now()-a;return f(r==="npm"?`
217
+ added ${c} package(s) in ${d}ms
226
218
  `:r==="pnpm"?`
227
- Packages: +${a}
228
- ${"+".repeat(Math.min(a,40))}
229
- Done in ${c}ms using pnpm v9.0.0
219
+ Packages: +${c}
220
+ ${"+".repeat(Math.min(c,40))}
221
+ Done in ${d}ms using pnpm v9.0.0
230
222
  `:`Saved lockfile
231
223
 
232
- ${a} package(s) installed [${c}ms]
224
+ ${c} package(s) installed [${d}ms]
233
225
  `),{code:0,stdout:i.join(""),stderr:l?`${r==="npm"?"npm warn":r==="pnpm"?"pnpm warn":"bun warn"} ${l}
234
226
  `:""}}function be(n,e){const{path:s,data:t}=H(e.vfs,e.cwd);let r=!1;t.dependencies&&n in t.dependencies&&(delete t.dependencies[n],r=!0),t.devDependencies&&n in t.devDependencies&&(delete t.devDependencies[n],r=!0),r&&De(e.vfs,s,t,e.emitMutation);const o=["/workspace/node_modules/"+n],i=j.join(e.cwd||"/workspace","node_modules",n);o.includes(i)||o.push(i);for(const f of o)pe(e.vfs,f,e.emitMutation)}function ie(n){const{data:e}=H(n.vfs,n.cwd),s=Object.assign({},e.dependencies||{});let t=`${e.name||"project"}@${e.version||"1.0.0"} ${n.cwd||"/workspace"}
235
227
  `;const r=Object.keys(s);if(r.length===0)t+=`\u2514\u2500\u2500 (empty)
236
- `;else for(let o=0;o<r.length;o++){const i=r[o],f=String(s[i]).replace(/^[\^~]/,""),d=o===r.length-1?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 ";t+=`${d}${i}@${f}
228
+ `;else for(let o=0;o<r.length;o++){const i=r[o],f=String(s[i]).replace(/^[\^~]/,""),a=o===r.length-1?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 ";t+=`${a}${i}@${f}
237
229
  `}return t}function We(n){const e=String(n??"");return e.length===0?"''":/[\s"'\\$&|;<>()`!*?~#]/.test(e)?"'"+e.replace(/'/g,"'\\''")+"'":e}async function Z(n,e,s){const{data:t}=H(s.vfs,s.cwd);if(!t.scripts||!t.scripts[n])return{code:1,stdout:"",stderr:`npm ERR! Missing script: "${n}"
238
- `};let r=t.scripts[n];e&&e.length>0&&(r+=" "+e.map(We).join(" "));const o=await Ve(n,r,s);if(o)return o;const i=`${j.join(s.cwd||"/workspace","node_modules/.bin")}:/workspace/node_modules/.bin`,f={...s.env,PATH:s.env&&s.env.PATH?`${i}:${s.env.PATH}`:`${i}:/usr/local/bin:/usr/bin:/bin`},d=await s.shell.execute(r,{cwd:s.cwd,env:f,stdin:s.stdin,signal:s.signal,isBackground:s.isBackground,onStdout:s.onStdout,onStderr:s.onStderr,onRequestStdin:s.onRequestStdin||(s.shell&&s.shell.options?s.shell.options.onRequestStdin:void 0)});return{code:d.code!==void 0?d.code:0,stdout:d.stdout||"",stderr:d.stderr||"",alreadyStreamed:!!s.onStdout,aborted:d.aborted}}const Be="https://cdn.jsdelivr.net/npm",pt={".html":"text/html; charset=utf-8",".htm":"text/html; charset=utf-8",".js":"text/javascript; charset=utf-8",".mjs":"text/javascript; charset=utf-8",".cjs":"text/javascript; charset=utf-8",".jsx":"text/javascript; charset=utf-8",".ts":"text/javascript; charset=utf-8",".tsx":"text/javascript; charset=utf-8",".css":"text/css; charset=utf-8",".json":"application/json; charset=utf-8",".map":"application/json; charset=utf-8",".svg":"image/svg+xml",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".ico":"image/x-icon",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".wasm":"application/wasm",".pdf":"application/pdf",".mp3":"audio/mpeg",".mp4":"video/mp4",".webm":"video/webm",".txt":"text/plain; charset=utf-8"};function yt(n){const e=String(n||"").toLowerCase().split(";")[0].trim();return e?!(e.startsWith("text/")||e==="application/javascript"||e==="application/json"||e==="application/xml"||e==="application/xhtml+xml"||e==="image/svg+xml"):!1}function mt(n){const e=String(n).toLowerCase(),s=e.lastIndexOf(".");return s===-1?"application/octet-stream":pt[e.slice(s)]||"application/octet-stream"}function Se(n){return/\.(?:[cm]?jsx?|tsx?)$/i.test(n)&&!/\.d\.ts$/i.test(n)}function ve(n){const e=new Set,s=[/\bfrom\s*['"]((?:@[^'"/]+\/)?[^'"./][^'"]*)['"]/g,/\brequire\s*\(\s*['"]((?:@[^'"/]+\/)?[^'"./][^'"]*)['"]/g,/\bimport\s*\(\s*['"]((?:@[^'"/]+\/)?[^'"./][^'"]*)['"]/g,/\bimport\s*['"]((?:@[^'"/]+\/)?[^'"./][^'"]*)['"]/g];for(const t of s){let r;for(;(r=t.exec(n))!==null;){const o=r[1];!o||o.startsWith(".")||o.startsWith("/")||o.includes(":")||e.add(o)}}return Array.from(e)}function gt(n){if(!n||typeof n!="string")return"latest";const e=n.trim();return!e||e==="*"||/^(?:latest|next|beta|canary)$/.test(e)||/^(?:file|link|workspace|portal|git|https?):/.test(e)?"latest":e.replace(/\s+/g,"").replace(/^[v=\s]+/,"")||"latest"}function Ue(n,e,s){try{const t=j.join(e,"node_modules",s,"package.json");if(n.existsSync(t)){const r=JSON.parse(n.readFileSync(t,"utf8"));if(r&&r.version)return r.version}}catch(t){N.debug("Could not read installed module package.json.",s,t)}try{for(const t of[e,"/workspace"]){const r=j.join(t,"package.json");if(!n.existsSync(r))continue;const o=JSON.parse(n.readFileSync(r,"utf8")),i=Object.assign({},o.dependencies||{},o.devDependencies||{},o.peerDependencies||{});if(i[s])return gt(i[s])}}catch(t){N.debug("Could not read workspace package.json for version resolution.",s,t)}return"latest"}function ze(n,e,s){const t=`${Be}/${n}@${e}`,r=s?"/"+String(s).replace(/^\/+|\/+$/g,""):"";return`${t}${r}/+esm`}function bt(n,e,s){const t={};for(const r of s){const o=String(r).split("/"),i=r.startsWith("@")?o.slice(0,2).join("/"):o[0];if(!i)continue;const f=r.slice(i.length).replace(/^\/+/,""),d=Ue(n,e,i);if(f&&/\.css$/i.test(f)){const y=`${Be}/${i}@${d}/${f.replace(/^\/+/,"")}`,l=`if(typeof document!=='undefined'){const l=document.createElement('link');l.rel='stylesheet';l.href=${JSON.stringify(y)};document.head.appendChild(l);}export default ${JSON.stringify(y)};`;t[r]=`data:text/javascript;charset=utf-8,${encodeURIComponent(l)}`;continue}t[r]=ze(i,d,f||void 0)}return t}const St=/https?:\/\/(?:cdn\.jsdelivr\.net\/npm|esm\.sh)\/((?:@[^\/'"`@\s]+\/)?[^\/'"`@\s]+)@([^\s'"`),;]+)/g;function He(n,e,s,t){if(!s||typeof s!="string")return;const r=new RegExp(St.source,"g");let o;for(;(o=r.exec(s))!==null;){const i=o[0];if(i.includes("${"))continue;const f=decodeURIComponent(o[1]),d=o[2],y=d.split(/[\/?]/)[0],l=d.slice(y.length),c=(l.startsWith("/")&&l!=="/+esm"?l.slice(1).split(/[?#]/)[0]:"").replace(/^\/+|\/+$/g,""),h=c?`${f}/${c}`:f,u=Ue(n,e,f),p=u&&u!=="latest"?u:decodeURIComponent(y),g=t[h]||ze(f,p,c||void 0);g&&g!==i&&(t[i]=g)}}function qe(n,e,s=200){const t=[],r=(o,i)=>{if(i>8||t.length>=s)return;let f=[];try{f=n.readdirSync(o)}catch{return}for(const d of f){if(d==="node_modules"||d.startsWith("."))continue;const y=j.join(o,d);let l;try{l=n.statSync(y)}catch{continue}if(l&&(typeof l.isDirectory=="function"?l.isDirectory():l.isDirectory))r(y,i+1);else if(Se(d)&&t.length<s)try{const c=n.readFileSync(y,"utf8"),h=y.startsWith(e+"/")?y.slice(e.length+1):d;t.push({full:y,rel:h,content:c})}catch(c){N.debug("Preview script read skipped.",y,c)}}};return r(e,0),t}function vt(n,e,s=200){const t=[],r=(o,i)=>{if(i>8||t.length>=s)return;let f=[];try{f=n.readdirSync(o)}catch{return}for(const d of f){if(d==="node_modules"||d.startsWith("."))continue;const y=j.join(o,d);let l;try{l=n.statSync(y)}catch{continue}if(l&&(typeof l.isDirectory=="function"?l.isDirectory():l.isDirectory))r(y,i+1);else if(/\.(?:css|json|svg)$/i.test(d)&&t.length<s)try{const c=n.readFileSync(y,"utf8"),h=y.startsWith(e+"/")?y.slice(e.length+1):d;t.push({full:y,rel:h,content:c})}catch(c){N.debug("Preview asset read skipped.",y,c)}}};return r(e,0),t}function Pt(n,e,s=200){return qe(n,e,s).map(t=>t.content)}function wt(n,e){let s=n;const r=`<script type="importmap">
230
+ `};let r=t.scripts[n];e&&e.length>0&&(r+=" "+e.map(We).join(" "));const o=await Le(n,r,s);if(o)return o;const i=`${j.join(s.cwd||"/workspace","node_modules/.bin")}:/workspace/node_modules/.bin`,f={...s.env,PATH:s.env&&s.env.PATH?`${i}:${s.env.PATH}`:`${i}:/usr/local/bin:/usr/bin:/bin`},a=await s.shell.execute(r,{cwd:s.cwd,env:f,stdin:s.stdin,signal:s.signal,isBackground:s.isBackground,onStdout:s.onStdout,onStderr:s.onStderr,onRequestStdin:s.onRequestStdin||(s.shell&&s.shell.options?s.shell.options.onRequestStdin:void 0)});return{code:a.code!==void 0?a.code:0,stdout:a.stdout||"",stderr:a.stderr||"",alreadyStreamed:!!s.onStdout,aborted:a.aborted}}const Be="https://cdn.jsdelivr.net/npm",ht={".html":"text/html; charset=utf-8",".htm":"text/html; charset=utf-8",".js":"text/javascript; charset=utf-8",".mjs":"text/javascript; charset=utf-8",".cjs":"text/javascript; charset=utf-8",".jsx":"text/javascript; charset=utf-8",".ts":"text/javascript; charset=utf-8",".tsx":"text/javascript; charset=utf-8",".css":"text/css; charset=utf-8",".json":"application/json; charset=utf-8",".map":"application/json; charset=utf-8",".svg":"image/svg+xml",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".ico":"image/x-icon",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".wasm":"application/wasm",".pdf":"application/pdf",".mp3":"audio/mpeg",".mp4":"video/mp4",".webm":"video/webm",".txt":"text/plain; charset=utf-8"};function pt(n){const e=String(n||"").toLowerCase().split(";")[0].trim();return e?!(e.startsWith("text/")||e==="application/javascript"||e==="application/json"||e==="application/xml"||e==="application/xhtml+xml"||e==="image/svg+xml"):!1}function yt(n){const e=String(n).toLowerCase(),s=e.lastIndexOf(".");return s===-1?"application/octet-stream":ht[e.slice(s)]||"application/octet-stream"}function Se(n){return/\.(?:[cm]?jsx?|tsx?)$/i.test(n)&&!/\.d\.ts$/i.test(n)}function ve(n){const e=new Set,s=[/\bfrom\s*['"]((?:@[^'"/]+\/)?[^'"./][^'"]*)['"]/g,/\brequire\s*\(\s*['"]((?:@[^'"/]+\/)?[^'"./][^'"]*)['"]/g,/\bimport\s*\(\s*['"]((?:@[^'"/]+\/)?[^'"./][^'"]*)['"]/g,/\bimport\s*['"]((?:@[^'"/]+\/)?[^'"./][^'"]*)['"]/g];for(const t of s){let r;for(;(r=t.exec(n))!==null;){const o=r[1];!o||o.startsWith(".")||o.startsWith("/")||o.includes(":")||e.add(o)}}return Array.from(e)}function mt(n){if(!n||typeof n!="string")return"latest";const e=n.trim();return!e||e==="*"||/^(?:latest|next|beta|canary)$/.test(e)||/^(?:file|link|workspace|portal|git|https?):/.test(e)?"latest":e.replace(/\s+/g,"").replace(/^[v=\s]+/,"")||"latest"}function Ue(n,e,s){try{const t=j.join(e,"node_modules",s,"package.json");if(n.existsSync(t)){const r=JSON.parse(n.readFileSync(t,"utf8"));if(r&&r.version)return r.version}}catch(t){_.debug("Could not read installed module package.json.",s,t)}try{for(const t of[e,"/workspace"]){const r=j.join(t,"package.json");if(!n.existsSync(r))continue;const o=JSON.parse(n.readFileSync(r,"utf8")),i=Object.assign({},o.dependencies||{},o.devDependencies||{},o.peerDependencies||{});if(i[s])return mt(i[s])}}catch(t){_.debug("Could not read workspace package.json for version resolution.",s,t)}return"latest"}function ze(n,e,s){const t=`${Be}/${n}@${e}`,r=s?"/"+String(s).replace(/^\/+|\/+$/g,""):"";return`${t}${r}/+esm`}function gt(n,e,s){const t={};for(const r of s){const o=String(r).split("/"),i=r.startsWith("@")?o.slice(0,2).join("/"):o[0];if(!i)continue;const f=r.slice(i.length).replace(/^\/+/,""),a=Ue(n,e,i);if(f&&/\.css$/i.test(f)){const y=`${Be}/${i}@${a}/${f.replace(/^\/+/,"")}`,l=`if(typeof document!=='undefined'){const l=document.createElement('link');l.rel='stylesheet';l.href=${JSON.stringify(y)};document.head.appendChild(l);}export default ${JSON.stringify(y)};`;t[r]=`data:text/javascript;charset=utf-8,${encodeURIComponent(l)}`;continue}t[r]=ze(i,a,f||void 0)}return t}const bt=/https?:\/\/(?:cdn\.jsdelivr\.net\/npm|esm\.sh)\/((?:@[^\/'"`@\s]+\/)?[^\/'"`@\s]+)@([^\s'"`),;]+)/g;function He(n,e,s,t){if(!s||typeof s!="string")return;const r=new RegExp(bt.source,"g");let o;for(;(o=r.exec(s))!==null;){const i=o[0];if(i.includes("${"))continue;const f=decodeURIComponent(o[1]),a=o[2],y=a.split(/[\/?]/)[0],l=a.slice(y.length),d=(l.startsWith("/")&&l!=="/+esm"?l.slice(1).split(/[?#]/)[0]:"").replace(/^\/+|\/+$/g,""),u=d?`${f}/${d}`:f,h=Ue(n,e,f),p=h&&h!=="latest"?h:decodeURIComponent(y),g=t[u]||ze(f,p,d||void 0);g&&g!==i&&(t[i]=g)}}function St(n,e,s=200){const t=[],r=(o,i)=>{if(i>8||t.length>=s)return;let f=[];try{f=n.readdirSync(o)}catch{return}for(const a of f){if(a==="node_modules"||a.startsWith("."))continue;const y=j.join(o,a);let l;try{l=n.statSync(y)}catch{continue}if(l&&(typeof l.isDirectory=="function"?l.isDirectory():l.isDirectory))r(y,i+1);else if(Se(a)&&t.length<s)try{const d=n.readFileSync(y,"utf8"),u=y.startsWith(e+"/")?y.slice(e.length+1):a;t.push({full:y,rel:u,content:d})}catch(d){_.debug("Preview script read skipped.",y,d)}}};return r(e,0),t}function vt(n,e,s=200){const t=[],r=(o,i)=>{if(i>8||t.length>=s)return;let f=[];try{f=n.readdirSync(o)}catch{return}for(const a of f){if(a==="node_modules"||a.startsWith("."))continue;const y=j.join(o,a);let l;try{l=n.statSync(y)}catch{continue}if(l&&(typeof l.isDirectory=="function"?l.isDirectory():l.isDirectory))r(y,i+1);else if(/\.(?:css|json|svg)$/i.test(a)&&t.length<s)try{const d=n.readFileSync(y,"utf8"),u=y.startsWith(e+"/")?y.slice(e.length+1):a;t.push({full:y,rel:u,content:d})}catch(d){_.debug("Preview asset read skipped.",y,d)}}};return r(e,0),t}function wt(n,e){let s=n;const r=`<script type="importmap">
239
231
  ${JSON.stringify({imports:e},null,2).replace(/</g,"\\u003c")}
240
232
  <\/script>`;/<head[^>]*>/i.test(s)?s=s.replace(/<head[^>]*>/i,i=>`${i}
241
233
  ${r}`):s=r+`
242
234
  `+s;const o="<script>window.__CODELAB_PREVIEW__ = true;<\/script>";return/<\/body>/i.test(s)?s=s.replace(/<\/body>/i,`${o}
243
235
  </body>`):s=s+`
244
- `+o,s}function we(n,e,s){const t=n.shell&&n.shell.portTable;if(!t||typeof t.registerServer!="function")return null;let r=Number(s)||3e3;const o=new Set((typeof t.listServers=="function"?t.listServers():[]).map(S=>Number(S.port)));for(;o.has(r);)r++;const i=S=>{try{return n.vfs.existsSync(S)}catch{return!1}},f=S=>{try{const b=n.vfs.statSync(S);return!!(b&&(typeof b.isDirectory=="function"?b.isDirectory():b.isDirectory))}catch{return!1}},d=S=>i(S)&&!f(S),y=S=>{try{return n.vfs.readFileSync(S,"utf8")}catch{return null}},l=S=>{const b=e==="/"?"/":e+"/";return S===e||S.startsWith(b)},a=(S,b)=>{if(!b||typeof b!="string")return null;const v=b.split(/[?#]/)[0].trim();if(!v||/^(?:https?:|data:|blob:|\/\/)/i.test(v))return null;const w=v.startsWith("/")?j.join(e,v.replace(/^\/+/,"")):j.join(S,v);if(!l(w))return null;if(d(w))return w;const $=[w+".tsx",w+".ts",w+".jsx",w+".js",w+".mjs",w+".cjs",j.join(w,"index.tsx"),j.join(w,"index.ts"),j.join(w,"index.jsx"),j.join(w,"index.js")];for(const R of $)if(l(R)&&d(R))return R;return null},c=S=>`@codelab-local/${S.startsWith(e+"/")?S.slice(e.length+1):S.replace(/^\/+/,"")}`,h=(S,b)=>{let v=S;try{const R=U();R&&typeof R.transpileForBrowser=="function"&&(v=R.transpileForBrowser(v,b))}catch(R){N.warn(`Preview script transpilation failed for ${b}.`,R)}const w=j.dirname(b),$=R=>{if(!R||!R.startsWith(".")&&!R.startsWith("/"))return R;const I=a(w,R);return I?c(I):R};return v=v.replace(/(\b(?:from|import)\s*['"])(\.{1,2}\/[^'"]+|\/[^'"]+)(['"])/g,(R,I,C,E)=>`${I}${$(C)}${E}`),v=v.replace(/(\bimport\s*\(\s*['"])(\.{1,2}\/[^'"]+|\/[^'"]+)(['"]\s*\))/g,(R,I,C,E)=>`${I}${$(C)}${E}`),v},u=(S,b)=>S?S.replace(/@import\s+(?:url\(\s*['"]?([^'")]+)['"]?\s*\)|['"]([^'"]+)['"])\s*;?/gi,(v,w,$)=>{const R=(w||$||"").trim();if(!R||/^(?:https?:|data:|\/\/)/i.test(R))return v;if(R==="tailwindcss")return"";const I=a(b,R);if(I&&/\.css$/i.test(I)){const C=y(I);if(C!==null)return C}return""}):"",p=(S,b)=>{const v=qe(n.vfs,e),w=vt(n.vfs,e),$=new Set,R=[];for(const P of v){for(const M of ve(P.content))$.add(M);const A=h(P.content,P.full);for(const M of ve(A))$.add(M);R.push({file:P,compiled:A})}const I=/<script\b[^>]*>([\s\S]*?)<\/script>/gi;let C;for(;(C=I.exec(S))!==null;)if(C[1])for(const P of ve(C[1]))$.add(P);const E=bt(n.vfs,e,$);for(const P of v)He(n.vfs,e,P.content,E);He(n.vfs,e,S,E);for(const{file:P,compiled:A}of R){const M=c(P.full);E[M]=`data:text/javascript;charset=utf-8,${encodeURIComponent(A)}`}let T=!1;for(const P of w){const A=c(P.full);if(/\.css$/i.test(P.full)){/@import\s+['"]tailwindcss['"]/i.test(P.content)&&(T=!0);const M=u(P.content,j.dirname(P.full)),D=`const __css=${JSON.stringify(M)};if(typeof document!=='undefined'){const __s=document.createElement('style');__s.setAttribute('data-codelab-css',${JSON.stringify(P.rel)});__s.textContent=__css;document.head.appendChild(__s);}export default __css;`;E[A]=`data:text/javascript;charset=utf-8,${encodeURIComponent(D)}`}else if(/\.json$/i.test(P.full)){const M=`export default ${P.content.trim()||"null"};`;E[A]=`data:text/javascript;charset=utf-8,${encodeURIComponent(M)}`}else if(/\.svg$/i.test(P.full)){const M=`data:image/svg+xml;utf8,${encodeURIComponent(P.content)}`,D=`export default ${JSON.stringify(M)};`;E[A]=`data:text/javascript;charset=utf-8,${encodeURIComponent(D)}`}}const k=j.dirname(b);let O=S.replace(/%PUBLIC_URL%\//g,"/").replace(/%PUBLIC_URL%/g,"");if(!/<script\b[^>]*\bsrc\s*=\s*["']([^"']+)["'][^>]*>/i.test(O)){const P=["/src/main.tsx","/src/main.jsx","/src/main.ts","/src/main.js","/src/index.tsx","/src/index.jsx","/src/index.ts","/src/index.js"];for(const A of P)if(d(j.join(e,A.slice(1)))){const M=`<script type="module" src="${A}"><\/script>`;/<\/body>/i.test(O)?O=O.replace(/<\/body>/i,` ${M}
236
+ `+o,s}function we(n,e,s){const t=n.shell&&n.shell.portTable;if(!t||typeof t.registerServer!="function")return null;let r=Number(s)||3e3;const o=new Set((typeof t.listServers=="function"?t.listServers():[]).map(S=>Number(S.port)));for(;o.has(r);)r++;const i=S=>{try{return n.vfs.existsSync(S)}catch{return!1}},f=S=>{try{const b=n.vfs.statSync(S);return!!(b&&(typeof b.isDirectory=="function"?b.isDirectory():b.isDirectory))}catch{return!1}},a=S=>i(S)&&!f(S),y=S=>{try{return n.vfs.readFileSync(S,"utf8")}catch{return null}},l=S=>{const b=e==="/"?"/":e+"/";return S===e||S.startsWith(b)},c=(S,b)=>{if(!b||typeof b!="string")return null;const v=b.split(/[?#]/)[0].trim();if(!v||/^(?:https?:|data:|blob:|\/\/)/i.test(v))return null;const w=v.startsWith("/")?j.join(e,v.replace(/^\/+/,"")):j.join(S,v);if(!l(w))return null;if(a(w))return w;const $=[w+".tsx",w+".ts",w+".jsx",w+".js",w+".mjs",w+".cjs",j.join(w,"index.tsx"),j.join(w,"index.ts"),j.join(w,"index.jsx"),j.join(w,"index.js")];for(const R of $)if(l(R)&&a(R))return R;return null},d=S=>`@codelab-local/${S.startsWith(e+"/")?S.slice(e.length+1):S.replace(/^\/+/,"")}`,u=(S,b)=>{let v=S;try{const R=U();R&&typeof R.transpileForBrowser=="function"&&(v=R.transpileForBrowser(v,b))}catch(R){_.warn(`Preview script transpilation failed for ${b}.`,R)}const w=j.dirname(b),$=R=>{if(!R||!R.startsWith(".")&&!R.startsWith("/"))return R;const I=c(w,R);return I?d(I):R};return v=v.replace(/(\b(?:from|import)\s*['"])(\.{1,2}\/[^'"]+|\/[^'"]+)(['"])/g,(R,I,C,E)=>`${I}${$(C)}${E}`),v=v.replace(/(\bimport\s*\(\s*['"])(\.{1,2}\/[^'"]+|\/[^'"]+)(['"]\s*\))/g,(R,I,C,E)=>`${I}${$(C)}${E}`),v},h=(S,b)=>S?S.replace(/@import\s+(?:url\(\s*['"]?([^'")]+)['"]?\s*\)|['"]([^'"]+)['"])\s*;?/gi,(v,w,$)=>{const R=(w||$||"").trim();if(!R||/^(?:https?:|data:|\/\/)/i.test(R))return v;if(R==="tailwindcss")return"";const I=c(b,R);if(I&&/\.css$/i.test(I)){const C=y(I);if(C!==null)return C}return""}):"",p=(S,b)=>{const v=St(n.vfs,e),w=vt(n.vfs,e),$=new Set,R=[];for(const P of v){for(const M of ve(P.content))$.add(M);const A=u(P.content,P.full);for(const M of ve(A))$.add(M);R.push({file:P,compiled:A})}const I=/<script\b[^>]*>([\s\S]*?)<\/script>/gi;let C;for(;(C=I.exec(S))!==null;)if(C[1])for(const P of ve(C[1]))$.add(P);const E=gt(n.vfs,e,$);for(const P of v)He(n.vfs,e,P.content,E);He(n.vfs,e,S,E);for(const{file:P,compiled:A}of R){const M=d(P.full);E[M]=`data:text/javascript;charset=utf-8,${encodeURIComponent(A)}`}let T=!1;for(const P of w){const A=d(P.full);if(/\.css$/i.test(P.full)){/@import\s+['"]tailwindcss['"]/i.test(P.content)&&(T=!0);const M=h(P.content,j.dirname(P.full)),D=`const __css=${JSON.stringify(M)};if(typeof document!=='undefined'){const __s=document.createElement('style');__s.setAttribute('data-codelab-css',${JSON.stringify(P.rel)});__s.textContent=__css;document.head.appendChild(__s);}export default __css;`;E[A]=`data:text/javascript;charset=utf-8,${encodeURIComponent(D)}`}else if(/\.json$/i.test(P.full)){const M=`export default ${P.content.trim()||"null"};`;E[A]=`data:text/javascript;charset=utf-8,${encodeURIComponent(M)}`}else if(/\.svg$/i.test(P.full)){const M=`data:image/svg+xml;utf8,${encodeURIComponent(P.content)}`,D=`export default ${JSON.stringify(M)};`;E[A]=`data:text/javascript;charset=utf-8,${encodeURIComponent(D)}`}}const k=j.dirname(b);let O=S.replace(/%PUBLIC_URL%\//g,"/").replace(/%PUBLIC_URL%/g,"");if(!/<script\b[^>]*\bsrc\s*=\s*["']([^"']+)["'][^>]*>/i.test(O)){const P=["/src/main.tsx","/src/main.jsx","/src/main.ts","/src/main.js","/src/index.tsx","/src/index.jsx","/src/index.ts","/src/index.js"];for(const A of P)if(a(j.join(e,A.slice(1)))){const M=`<script type="module" src="${A}"><\/script>`;/<\/body>/i.test(O)?O=O.replace(/<\/body>/i,` ${M}
245
237
  </body>`):O+=`
246
- ${M}`;break}}if(O=O.replace(/<link\b([^>]*?)>/gi,(P,A)=>{if(!/\brel\s*=\s*["']stylesheet["']/i.test(A))return P;const M=/\bhref\s*=\s*["']([^"']+)["']/i.exec(A);if(!M)return P;const D=a(k,M[1]);if(!D||!/\.css$/i.test(D))return P;const _=y(D);if(_===null)return P;/@import\s+['"]tailwindcss['"]/i.test(_)&&(T=!0);const B=u(_,j.dirname(D)).replace(/<\/style/gi,"<\\/style");return`<style data-codelab-href="${M[1].replace(/"/g,"&quot;")}">
238
+ ${M}`;break}}if(O=O.replace(/<link\b([^>]*?)>/gi,(P,A)=>{if(!/\brel\s*=\s*["']stylesheet["']/i.test(A))return P;const M=/\bhref\s*=\s*["']([^"']+)["']/i.exec(A);if(!M)return P;const D=c(k,M[1]);if(!D||!/\.css$/i.test(D))return P;const N=y(D);if(N===null)return P;/@import\s+['"]tailwindcss['"]/i.test(N)&&(T=!0);const B=h(N,j.dirname(D)).replace(/<\/style/gi,"<\\/style");return`<style data-codelab-href="${M[1].replace(/"/g,"&quot;")}">
247
239
  ${B}
248
- </style>`}),O=O.replace(/<script\b([^>]*?)>\s*<\/script>/gi,(P,A)=>{const M=/\bsrc\s*=\s*["']([^"']+)["']/i.exec(A);if(!M)return P;const D=a(k,M[1]);if(!D||!Se(D))return P;const _=y(D);if(_===null)return P;const B=h(_,D).replace(/<\/script/gi,"<\\/script");return`<script${/\btype\s*=\s*["']module["']/i.test(A)||/\.(?:tsx|ts|jsx|mjs)$/i.test(D)||/^\s*(?:import|export)\b/m.test(_)?' type="module"':""} data-codelab-src="${M[1].replace(/"/g,"&quot;")}">
240
+ </style>`}),O=O.replace(/<script\b([^>]*?)>\s*<\/script>/gi,(P,A)=>{const M=/\bsrc\s*=\s*["']([^"']+)["']/i.exec(A);if(!M)return P;const D=c(k,M[1]);if(!D||!Se(D))return P;const N=y(D);if(N===null)return P;const B=u(N,D).replace(/<\/script/gi,"<\\/script");return`<script${/\btype\s*=\s*["']module["']/i.test(A)||/\.(?:tsx|ts|jsx|mjs)$/i.test(D)||/^\s*(?:import|export)\b/m.test(N)?' type="module"':""} data-codelab-src="${M[1].replace(/"/g,"&quot;")}">
249
241
  ${B}
250
242
  <\/script>`}),T&&!O.includes("@tailwindcss/browser")){const P='<script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"><\/script>';/<head[^>]*>/i.test(O)?O=O.replace(/<head[^>]*>/i,A=>`${A}
251
243
  ${P}`):O=P+`
252
- `+O}return wt(O,E)},g=async S=>{let b="/";try{b=decodeURIComponent(new URL(S.url).pathname)}catch(C){N.debug("Preview URL decode failed.",C)}const v=b.replace(/^\/+/,"");let w=j.join(e,v);if(!l(w))return new Response('<!doctype html><meta charset="utf-8"><title>403</title><h1>403 Forbidden</h1>',{status:403,headers:{"content-type":"text/html; charset=utf-8"}});const $=/\.[A-Za-z0-9]+$/.test(v);if(!v||b.endsWith("/")||f(w)){const C=j.join(w,"index.html"),E=j.join(w,"public","index.html");w=!i(C)&&i(E)?E:C}if(!i(w)&&!$){const C=[w+".tsx",w+".ts",w+".jsx",w+".js",w+".mjs",w+".cjs",j.join(w,"index.tsx"),j.join(w,"index.ts"),j.join(w,"index.jsx"),j.join(w,"index.js")];for(const E of C)if(i(E)){w=E;break}}if(!i(w)&&!$){const C=j.join(e,"index.html"),E=j.join(e,"public","index.html");w=!i(C)&&i(E)?E:C}if(!i(w)){const C=String(b).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;");return new Response(`<!doctype html><meta charset="utf-8"><title>404</title><h1>404 Not Found</h1><p>${C}</p>`,{status:404,headers:{"content-type":"text/html; charset=utf-8"}})}const R=mt(w);if(yt(R)){let C=null;try{C=n.vfs.readFileSync(w)}catch(T){N.debug("Binary preview asset read failed.",w,T)}const E=C instanceof Uint8Array?C:typeof C=="string"?new TextEncoder().encode(C):new Uint8Array(0);return new Response(E,{status:200,headers:{"content-type":R}})}let I=y(w);if(I===null&&(I=""),/\.html?$/i.test(w))I=p(I,w);else if(Se(w))try{const C=U();C&&typeof C.transpileForBrowser=="function"&&(I=C.transpileForBrowser(I,w))}catch(C){N.warn(`Preview script transpilation failed for ${w}.`,C)}return new Response(I,{status:200,headers:{"content-type":R}})},m=n.shell&&typeof n.shell.nextPid=="number"?n.shell.nextPid++:n.pid||1e3;return t.registerServer(r,{server:{close(){try{t.unregisterServer(r)}catch(S){N.debug("Preview server unregister failed.",r,S)}}},fetch:g,name:"code-lab-serve",pid:m,root:e})}const Le=/\b(vite|ng|astro|next|webpack|parcel|esbuild|snowpack|react-scripts|serve|http-server)\b/,$t=/^(vite|ng|astro|next|webpack|parcel|esbuild|snowpack|react-scripts)$/,kt=/^(vite|ng|astro|next|webpack|parcel|esbuild|snowpack|react-scripts|http-server)$/;async function $e(n,e,s){const t=e&&e.shell?e.shell.portTable:null;if(!!!(e&&!e.isBackground&&e.signal))return{code:0,stdout:s,stderr:""};const o=`${s.replace(/\n+$/,"")}
244
+ `+O}return wt(O,E)},g=async S=>{let b="/";try{b=decodeURIComponent(new URL(S.url).pathname)}catch(C){_.debug("Preview URL decode failed.",C)}const v=b.replace(/^\/+/,"");let w=j.join(e,v);if(!l(w))return new Response('<!doctype html><meta charset="utf-8"><title>403</title><h1>403 Forbidden</h1>',{status:403,headers:{"content-type":"text/html; charset=utf-8"}});const $=/\.[A-Za-z0-9]+$/.test(v);if(!v||b.endsWith("/")||f(w)){const C=j.join(w,"index.html"),E=j.join(w,"public","index.html");w=!i(C)&&i(E)?E:C}if(!i(w)&&!$){const C=[w+".tsx",w+".ts",w+".jsx",w+".js",w+".mjs",w+".cjs",j.join(w,"index.tsx"),j.join(w,"index.ts"),j.join(w,"index.jsx"),j.join(w,"index.js")];for(const E of C)if(i(E)){w=E;break}}if(!i(w)&&!$){const C=j.join(e,"index.html"),E=j.join(e,"public","index.html");w=!i(C)&&i(E)?E:C}if(!i(w)){const C=String(b).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;");return new Response(`<!doctype html><meta charset="utf-8"><title>404</title><h1>404 Not Found</h1><p>${C}</p>`,{status:404,headers:{"content-type":"text/html; charset=utf-8"}})}const R=yt(w);if(pt(R)){let C=null;try{C=n.vfs.readFileSync(w)}catch(T){_.debug("Binary preview asset read failed.",w,T)}const E=C instanceof Uint8Array?C:typeof C=="string"?new TextEncoder().encode(C):new Uint8Array(0);return new Response(E,{status:200,headers:{"content-type":R}})}let I=y(w);if(I===null&&(I=""),/\.html?$/i.test(w))I=p(I,w);else if(Se(w))try{const C=U();C&&typeof C.transpileForBrowser=="function"&&(I=C.transpileForBrowser(I,w))}catch(C){_.warn(`Preview script transpilation failed for ${w}.`,C)}return new Response(I,{status:200,headers:{"content-type":R}})},m=n.shell&&typeof n.shell.nextPid=="number"?n.shell.nextPid++:n.pid||1e3;return t.registerServer(r,{server:{close(){try{t.unregisterServer(r)}catch(S){_.debug("Preview server unregister failed.",r,S)}}},fetch:g,name:"code-lab-serve",pid:m,root:e})}const qe=/\b(vite|ng|astro|next|webpack|parcel|esbuild|snowpack|react-scripts|serve|http-server)\b/,$t=/^(vite|ng|astro|next|webpack|parcel|esbuild|snowpack|react-scripts)$/,kt=/^(vite|ng|astro|next|webpack|parcel|esbuild|snowpack|react-scripts|http-server)$/;async function $e(n,e,s){const t=e&&e.shell?e.shell.portTable:null;if(!!!(e&&!e.isBackground&&e.signal))return{code:0,stdout:s,stderr:""};const o=`${s.replace(/\n+$/,"")}
253
245
  \u279C Press Ctrl+C to stop
254
246
 
255
- `;typeof e.onStdout=="function"&&e.onStdout(o);const i=()=>{if(n&&n.server&&typeof n.server.close=="function")try{n.server.close()}catch(f){N.debug("Foreground server close failed.",f)}else if(t&&typeof t.unregisterServer=="function"&&n)try{t.unregisterServer(n.port)}catch(f){N.debug("Foreground server unregister failed.",f)}};return e.signal.aborted?(i(),{code:130,stdout:o,stderr:"",alreadyStreamed:typeof e.onStdout=="function",aborted:!0}):await new Promise(f=>{let d=!1;const y=()=>{if(e.signal&&typeof e.signal.removeEventListener=="function")try{e.signal.removeEventListener("abort",a)}catch(h){}if(t&&typeof t.off=="function")try{t.off("close",c)}catch(h){}},l=(h,u)=>{d||(d=!0,y(),f({code:h,stdout:o,stderr:"",alreadyStreamed:typeof e.onStdout=="function",aborted:u}))},a=()=>{i(),l(130,!0)},c=(h,u)=>{n&&Number(h)===Number(n.port)&&(!u||u===n)&&l(0,!1)};e.signal.addEventListener("abort",a,{once:!0}),t&&typeof t.on=="function"&&t.on("close",c)})}async function Ve(n,e,s,t){if(!Le.test(e))return null;const r=(e.match(Le)||[])[1],o=!!(t&&t.force),i=j.join("/workspace/node_modules/.bin",r),f=s.vfs.existsSync(i);if(!o&&!$t.test(r)&&f)return null;const d=e.match(/--port(?:=|\s+)(\d+)/),l=d?Number(d[1]):{ng:4200,vite:5173,astro:4321,next:3e3}[r]||3e3,a=typeof s.resolvePath=="function"?s.resolvePath("."):s.cwd||"/workspace",c=we(s,a,l);if(!c)return null;const h=o||f?`${r} is a native dev server and cannot execute inside this virtual runtime \u2014 using the CodeLab preview server instead.`:`${r} is not available in this virtual runtime \u2014 using the CodeLab preview server instead.`,u=`
247
+ `;typeof e.onStdout=="function"&&e.onStdout(o);const i=()=>{if(n&&n.server&&typeof n.server.close=="function")try{n.server.close()}catch(f){_.debug("Foreground server close failed.",f)}else if(t&&typeof t.unregisterServer=="function"&&n)try{t.unregisterServer(n.port)}catch(f){_.debug("Foreground server unregister failed.",f)}};return e.signal.aborted?(i(),{code:130,stdout:o,stderr:"",alreadyStreamed:typeof e.onStdout=="function",aborted:!0}):await new Promise(f=>{let a=!1;const y=()=>{if(e.signal&&typeof e.signal.removeEventListener=="function")try{e.signal.removeEventListener("abort",c)}catch(u){}if(t&&typeof t.off=="function")try{t.off("close",d)}catch(u){}},l=(u,h)=>{a||(a=!0,y(),f({code:u,stdout:o,stderr:"",alreadyStreamed:typeof e.onStdout=="function",aborted:h}))},c=()=>{i(),l(130,!0)},d=(u,h)=>{n&&Number(u)===Number(n.port)&&(!h||h===n)&&l(0,!1)};e.signal.addEventListener("abort",c,{once:!0}),t&&typeof t.on=="function"&&t.on("close",d)})}async function Le(n,e,s,t){if(!qe.test(e))return null;const r=(e.match(qe)||[])[1],o=!!(t&&t.force),i=j.join("/workspace/node_modules/.bin",r),f=s.vfs.existsSync(i);if(!o&&!$t.test(r)&&f)return null;const a=e.match(/--port(?:=|\s+)(\d+)/),l=a?Number(a[1]):{ng:4200,vite:5173,astro:4321,next:3e3}[r]||3e3,c=typeof s.resolvePath=="function"?s.resolvePath("."):s.cwd||"/workspace",d=we(s,c,l);if(!d)return null;const u=o||f?`${r} is a native dev server and cannot execute inside this virtual runtime \u2014 using the CodeLab preview server instead.`:`${r} is not available in this virtual runtime \u2014 using the CodeLab preview server instead.`,h=`
256
248
  > ${n}
257
249
  > ${e}
258
250
 
259
- ${h}
251
+ ${u}
260
252
 
261
- \u279C Local: http://127.0.0.1:${c.port}/
253
+ \u279C Local: http://127.0.0.1:${d.port}/
262
254
 
263
- `;return await $e(c,s,u)}function ke(n,e){const s=[...n];if(s.length>0&&s[s.length-1]==="]"&&s.pop(),s.length===0)return 1;if(s[0]==="!")return ke(s.slice(1),e)===0?1:0;if(s.length===1)return s[0]?0:1;if(s.length===2){const[t,r]=s;if(t==="-z")return r.length===0?0:1;if(t==="-n")return r.length>0?0:1;if(t==="-e"||t==="-f"||t==="-d"||t==="-s"){const o=e.resolvePath(r);if(!e.vfs.existsSync(o))return 1;if(t==="-e")return 0;const i=e.vfs.statSync(o);if(t==="-f")return typeof i.isFile=="function"?i.isFile()?0:1:i.isFile?0:1;if(t==="-d")return typeof i.isDirectory=="function"?i.isDirectory()?0:1:i.isDirectory?0:1;if(t==="-s")return i.size>0?0:1}}if(s.length===3){const[t,r,o]=s;if(r==="="||r==="==")return t===o?0:1;if(r==="!=")return t!==o?0:1;const i=parseInt(t,10),f=parseInt(o,10);if(r==="-eq")return i===f?0:1;if(r==="-ne")return i!==f?0:1;if(r==="-lt")return i<f?0:1;if(r==="-le")return i<=f?0:1;if(r==="-gt")return i>f?0:1;if(r==="-ge")return i>=f?0:1}return 1}const V={async pwd(n,e){return{code:0,stdout:(e.shell?e.shell.cwd:e.cwd)+`
255
+ `;return await $e(d,s,h)}function ke(n,e){const s=[...n];if(s.length>0&&s[s.length-1]==="]"&&s.pop(),s.length===0)return 1;if(s[0]==="!")return ke(s.slice(1),e)===0?1:0;if(s.length===1)return s[0]?0:1;if(s.length===2){const[t,r]=s;if(t==="-z")return r.length===0?0:1;if(t==="-n")return r.length>0?0:1;if(t==="-e"||t==="-f"||t==="-d"||t==="-s"){const o=e.resolvePath(r);if(!e.vfs.existsSync(o))return 1;if(t==="-e")return 0;const i=e.vfs.statSync(o);if(t==="-f")return typeof i.isFile=="function"?i.isFile()?0:1:i.isFile?0:1;if(t==="-d")return typeof i.isDirectory=="function"?i.isDirectory()?0:1:i.isDirectory?0:1;if(t==="-s")return i.size>0?0:1}}if(s.length===3){const[t,r,o]=s;if(r==="="||r==="==")return t===o?0:1;if(r==="!=")return t!==o?0:1;const i=parseInt(t,10),f=parseInt(o,10);if(r==="-eq")return i===f?0:1;if(r==="-ne")return i!==f?0:1;if(r==="-lt")return i<f?0:1;if(r==="-le")return i<=f?0:1;if(r==="-gt")return i>f?0:1;if(r==="-ge")return i>=f?0:1}return 1}const V={async pwd(n,e){return{code:0,stdout:(e.shell?e.shell.cwd:e.cwd)+`
264
256
  `,stderr:""}},async cd(n,e){const s=e.env&&e.env.HOME||"/home/codelab";j._homeDir=s;let t=n[0];!t||t==="~"?t=s:t==="-"&&(t=e.env.OLDPWD||e.cwd);const r=e.resolvePath(t);if(r===s&&!e.vfs.existsSync(r)&&typeof e.vfs.mkdirSync=="function")try{e.vfs.mkdirSync(r,{recursive:!0})}catch(f){}if(!e.vfs.existsSync(r))return{code:1,stdout:"",stderr:`cd: ${t}: No such file or directory
265
- `};let o=!1;try{o=e.vfs.statSync(r).isDirectory()}catch(f){N.debug("cd statSync failed.",r,f)}if(!o)return{code:1,stdout:"",stderr:`cd: ${t}: Not a directory
266
- `};const i=e.cwd;return e.cwd=r,e.env.OLDPWD=i,e.env.PWD=r,e.vfs&&typeof e.vfs._setCwd=="function"&&e.vfs._setCwd(r),e.shell&&(e.shell.cwd=r,e.shell.env.OLDPWD=i,e.shell.env.PWD=r),{code:0,stdout:"",stderr:""}},async ls(n,e){let s=!1,t=!1,r=!1,o=!1,i=!1,f=!1,d=!1,y=!1;const l=[];for(const m of n)if(m.startsWith("-")&&m.length>1)for(let S=1;S<m.length;S++){const b=m[S];b==="a"||b==="A"?s=!0:b==="l"?t=!0:b==="h"?r=!0:b==="r"?o=!0:b==="t"?i=!0:b==="1"?f=!0:b==="R"?d=!0:b==="d"&&(y=!0)}else l.push(m);l.length===0&&l.push(".");function a(m){return r?m<1024?`${m}B`.padStart(5," "):m<1024*1024?`${(m/1024).toFixed(1)}K`.padStart(5," "):`${(m/(1024*1024)).toFixed(1)}M`.padStart(5," "):String(m).padStart(6," ")}function c(m){const S=new Date(m||Date.now()),v=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][S.getMonth()],w=String(S.getDate()).padStart(2," "),$=String(S.getHours()).padStart(2,"0"),R=String(S.getMinutes()).padStart(2,"0");return`${v} ${w} ${$}:${R}`}let h="",u="",p=0;function g(m,S,b){b&&(h+=(h.length>0?`
257
+ `};let o=!1;try{o=e.vfs.statSync(r).isDirectory()}catch(f){_.debug("cd statSync failed.",r,f)}if(!o)return{code:1,stdout:"",stderr:`cd: ${t}: Not a directory
258
+ `};const i=e.cwd;return e.cwd=r,e.env.OLDPWD=i,e.env.PWD=r,e.vfs&&typeof e.vfs._setCwd=="function"&&e.vfs._setCwd(r),e.shell&&(e.shell.cwd=r,e.shell.env.OLDPWD=i,e.shell.env.PWD=r),{code:0,stdout:"",stderr:""}},async ls(n,e){let s=!1,t=!1,r=!1,o=!1,i=!1,f=!1,a=!1,y=!1;const l=[];for(const m of n)if(m.startsWith("-")&&m.length>1)for(let S=1;S<m.length;S++){const b=m[S];b==="a"||b==="A"?s=!0:b==="l"?t=!0:b==="h"?r=!0:b==="r"?o=!0:b==="t"?i=!0:b==="1"?f=!0:b==="R"?a=!0:b==="d"&&(y=!0)}else l.push(m);l.length===0&&l.push(".");function c(m){return r?m<1024?`${m}B`.padStart(5," "):m<1024*1024?`${(m/1024).toFixed(1)}K`.padStart(5," "):`${(m/(1024*1024)).toFixed(1)}M`.padStart(5," "):String(m).padStart(6," ")}function d(m){const S=new Date(m||Date.now()),v=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][S.getMonth()],w=String(S.getDate()).padStart(2," "),$=String(S.getHours()).padStart(2,"0"),R=String(S.getMinutes()).padStart(2,"0");return`${v} ${w} ${$}:${R}`}let u="",h="",p=0;function g(m,S,b){b&&(u+=(u.length>0?`
267
259
  `:"")+`${m}:
268
- `);let v=[];try{v=e.vfs.readdirSync(S)}catch($){u+=`ls: cannot open directory '${m}': ${$.message}
269
- `,p=2;return}s?v=[".","..",...v]:v=v.filter($=>!$.startsWith("."));const w=v.map($=>{const R=S==="/"?"/"+$:S+"/"+$;let I=!1,C=0,E=Date.now();try{const T=e.vfs.statSync(R);I=T.isDirectory(),C=T.size,E=T.mtimeMs||Date.now()}catch(T){N.debug("ls statSync skipped.",R,T)}return{name:$,isDirectory:I,size:C,mtimeMs:E,absPath:R}});if(i?w.sort(($,R)=>R.mtimeMs-$.mtimeMs):w.sort(($,R)=>$.name.localeCompare(R.name)),o&&w.reverse(),t){let $=0;for(const R of w)$+=Math.ceil(R.size/512);h+=`total ${$}
270
- `;for(const R of w){const I=R.isDirectory?"drwxr-xr-x":"-rw-r--r--";h+=`${I} 1 ${e.env.USER||"codelab"} ${e.env.USER||"codelab"} ${a(R.size)} ${c(R.mtimeMs)} ${R.name}
271
- `}}else if(f)for(const $ of w)h+=`${$.name}
272
- `;else h+=w.map($=>$.name).join(" ")+(w.length>0?`
273
- `:"");if(d){for(const $ of w)if($.isDirectory&&$.name!=="."&&$.name!==".."){const R=m==="/"?"/"+$.name:m.replace(/\/+$/,"")+"/"+$.name;g(R,$.absPath,!0)}}}for(let m=0;m<l.length;m++){const S=l[m],b=e.resolvePath(S);if(!e.vfs.existsSync(b)){u+=`ls: cannot access '${S}': No such file or directory
274
- `,p=2;continue}let v;try{v=e.vfs.statSync(b)}catch(w){u+=`ls: cannot access '${S}': ${w.message}
275
- `,p=2;continue}if(v.isFile()||y){t?h+=`-rw-r--r-- 1 ${e.env.USER||"codelab"} ${e.env.USER||"codelab"} ${a(v.size)} ${c(v.mtimeMs)} ${S}
276
- `:h+=`${S}
277
- `;continue}g(S,b,l.length>1||d)}return{code:p,stdout:h,stderr:u}},async stat(n,e){if(n.length===0)return{code:1,stdout:"",stderr:`stat: missing operand
260
+ `);let v=[];try{v=e.vfs.readdirSync(S)}catch($){h+=`ls: cannot open directory '${m}': ${$.message}
261
+ `,p=2;return}s?v=[".","..",...v]:v=v.filter($=>!$.startsWith("."));const w=v.map($=>{const R=S==="/"?"/"+$:S+"/"+$;let I=!1,C=0,E=Date.now();try{const T=e.vfs.statSync(R);I=T.isDirectory(),C=T.size,E=T.mtimeMs||Date.now()}catch(T){_.debug("ls statSync skipped.",R,T)}return{name:$,isDirectory:I,size:C,mtimeMs:E,absPath:R}});if(i?w.sort(($,R)=>R.mtimeMs-$.mtimeMs):w.sort(($,R)=>$.name.localeCompare(R.name)),o&&w.reverse(),t){let $=0;for(const R of w)$+=Math.ceil(R.size/512);u+=`total ${$}
262
+ `;for(const R of w){const I=R.isDirectory?"drwxr-xr-x":"-rw-r--r--";u+=`${I} 1 ${e.env.USER||"codelab"} ${e.env.USER||"codelab"} ${c(R.size)} ${d(R.mtimeMs)} ${R.name}
263
+ `}}else if(f)for(const $ of w)u+=`${$.name}
264
+ `;else u+=w.map($=>$.name).join(" ")+(w.length>0?`
265
+ `:"");if(a){for(const $ of w)if($.isDirectory&&$.name!=="."&&$.name!==".."){const R=m==="/"?"/"+$.name:m.replace(/\/+$/,"")+"/"+$.name;g(R,$.absPath,!0)}}}for(let m=0;m<l.length;m++){const S=l[m],b=e.resolvePath(S);if(!e.vfs.existsSync(b)){h+=`ls: cannot access '${S}': No such file or directory
266
+ `,p=2;continue}let v;try{v=e.vfs.statSync(b)}catch(w){h+=`ls: cannot access '${S}': ${w.message}
267
+ `,p=2;continue}if(v.isFile()||y){t?u+=`-rw-r--r-- 1 ${e.env.USER||"codelab"} ${e.env.USER||"codelab"} ${c(v.size)} ${d(v.mtimeMs)} ${S}
268
+ `:u+=`${S}
269
+ `;continue}g(S,b,l.length>1||a)}return{code:p,stdout:u,stderr:h}},async stat(n,e){if(n.length===0)return{code:1,stdout:"",stderr:`stat: missing operand
278
270
  `};let s="",t="",r=0;for(const o of n){const i=e.resolvePath(o);if(!e.vfs.existsSync(i)){t+=`stat: cannot stat '${o}': No such file or directory
279
- `,r=1;continue}const f=e.vfs.statSync(i),d=f.isDirectory(),y=new Date(f.mtimeMs||Date.now());s+=` File: ${o}
280
- `,s+=` Size: ${f.size} Blocks: ${Math.ceil(f.size/512)} IO Block: 4096 ${d?"directory":"regular file"}
271
+ `,r=1;continue}const f=e.vfs.statSync(i),a=f.isDirectory(),y=new Date(f.mtimeMs||Date.now());s+=` File: ${o}
272
+ `,s+=` Size: ${f.size} Blocks: ${Math.ceil(f.size/512)} IO Block: 4096 ${a?"directory":"regular file"}
281
273
  `,s+=`Device: 1h/1d Inode: 100 Links: 1
282
- `,s+=`Access: (${d?"0755/drwxr-xr-x":"0644/-rw-r--r--"}) Uid: (1000/${e.env.USER||"codelab"}) Gid: (1000/${e.env.USER||"codelab"})
274
+ `,s+=`Access: (${a?"0755/drwxr-xr-x":"0644/-rw-r--r--"}) Uid: (1000/${e.env.USER||"codelab"}) Gid: (1000/${e.env.USER||"codelab"})
283
275
  `,s+=`Access: ${y.toISOString()}
284
276
  `,s+=`Modify: ${y.toISOString()}
285
277
  `,s+=`Change: ${y.toISOString()}
286
278
  `,s+=` Birth: ${y.toISOString()}
287
- `}return{code:r,stdout:s,stderr:t}},async cat(n,e){let s=!1,t=!1,r=!1;const o=[];for(const h of n)h==="-n"?s=!0:h==="-b"?t=!0:h==="-s"?r=!0:o.push(h);let i="",f=0,d="";if(o.length===0||o.length===1&&o[0]==="-")i=e.stdin||"";else for(const h of o){if(h==="-"){i+=e.stdin||"";continue}const u=e.resolvePath(h);if(!e.vfs.existsSync(u)){d+=`cat: ${h}: No such file or directory
288
- `,f=1;continue}try{i+=e.vfs.readFileSync(u,"utf8")}catch(p){d+=`cat: ${h}: ${p.message}
289
- `,f=1}}if(!s&&!t&&!r)return{code:f,stdout:i,stderr:d};const y=i.split(`
290
- `);let l=[],a=1,c=!1;for(let h=0;h<y.length;h++){const u=y[h],p=u.trim()==="";r&&p&&c||(c=p,t?p?l.push(u):l.push(`${String(a++).padStart(6," ")} ${u}`):s?l.push(`${String(a++).padStart(6," ")} ${u}`):l.push(u))}return{code:f,stdout:l.join(`
291
- `),stderr:d}},async head(n,e){let s=10;const t=[];for(let d=0;d<n.length;d++){const y=n[d];if(y==="-n"&&d+1<n.length){const l=parseInt(n[++d],10);s=isNaN(l)?10:l}else if(/^-\d+$/.test(y)){const l=parseInt(y.slice(1),10);s=isNaN(l)?10:l}else t.push(y)}function r(d){if(s<=0)return"";const y=d.split(`
279
+ `}return{code:r,stdout:s,stderr:t}},async cat(n,e){let s=!1,t=!1,r=!1;const o=[];for(const u of n)u==="-n"?s=!0:u==="-b"?t=!0:u==="-s"?r=!0:o.push(u);let i="",f=0,a="";if(o.length===0||o.length===1&&o[0]==="-")i=e.stdin||"";else for(const u of o){if(u==="-"){i+=e.stdin||"";continue}const h=e.resolvePath(u);if(!e.vfs.existsSync(h)){a+=`cat: ${u}: No such file or directory
280
+ `,f=1;continue}try{i+=e.vfs.readFileSync(h,"utf8")}catch(p){a+=`cat: ${u}: ${p.message}
281
+ `,f=1}}if(!s&&!t&&!r)return{code:f,stdout:i,stderr:a};const y=i.split(`
282
+ `);let l=[],c=1,d=!1;for(let u=0;u<y.length;u++){const h=y[u],p=h.trim()==="";r&&p&&d||(d=p,t?p?l.push(h):l.push(`${String(c++).padStart(6," ")} ${h}`):s?l.push(`${String(c++).padStart(6," ")} ${h}`):l.push(h))}return{code:f,stdout:l.join(`
283
+ `),stderr:a}},async head(n,e){let s=10;const t=[];for(let a=0;a<n.length;a++){const y=n[a];if(y==="-n"&&a+1<n.length){const l=parseInt(n[++a],10);s=isNaN(l)?10:l}else if(/^-\d+$/.test(y)){const l=parseInt(y.slice(1),10);s=isNaN(l)?10:l}else t.push(y)}function r(a){if(s<=0)return"";const y=a.split(`
292
284
  `);return y.slice(0,s).join(`
293
285
  `)+(y.length>0?`
294
- `:"")}if(t.length===0)return{code:0,stdout:r(e.stdin||""),stderr:""};let o="",i="",f=0;for(const d of t){const y=e.resolvePath(d);if(!e.vfs.existsSync(y)){i+=`head: cannot open '${d}' for reading: No such file or directory
295
- `,f=1;continue}if(e.vfs.statSync&&e.vfs.statSync(y).isDirectory()){i+=`head: error reading '${d}': Is a directory
286
+ `:"")}if(t.length===0)return{code:0,stdout:r(e.stdin||""),stderr:""};let o="",i="",f=0;for(const a of t){const y=e.resolvePath(a);if(!e.vfs.existsSync(y)){i+=`head: cannot open '${a}' for reading: No such file or directory
287
+ `,f=1;continue}if(e.vfs.statSync&&e.vfs.statSync(y).isDirectory()){i+=`head: error reading '${a}': Is a directory
296
288
  `,f=1;continue}try{const l=e.vfs.readFileSync(y,"utf8");o+=r(l)}catch(l){i+=`head: ${l.message}
297
- `,f=1}}return{code:f,stdout:o,stderr:i}},async tail(n,e){let s=10;const t=[];for(let d=0;d<n.length;d++){const y=n[d];if(y==="-n"&&d+1<n.length){const l=parseInt(n[++d],10);s=isNaN(l)?10:l}else if(/^-\d+$/.test(y)){const l=parseInt(y.slice(1),10);s=isNaN(l)?10:l}else t.push(y)}function r(d){if(s<=0)return"";const y=d.endsWith(`
298
- `)?d.slice(0,-1).split(`
299
- `):d.split(`
289
+ `,f=1}}return{code:f,stdout:o,stderr:i}},async tail(n,e){let s=10;const t=[];for(let a=0;a<n.length;a++){const y=n[a];if(y==="-n"&&a+1<n.length){const l=parseInt(n[++a],10);s=isNaN(l)?10:l}else if(/^-\d+$/.test(y)){const l=parseInt(y.slice(1),10);s=isNaN(l)?10:l}else t.push(y)}function r(a){if(s<=0)return"";const y=a.endsWith(`
290
+ `)?a.slice(0,-1).split(`
291
+ `):a.split(`
300
292
  `);return y.slice(Math.max(0,y.length-s)).join(`
301
293
  `)+`
302
- `}if(t.length===0)return{code:0,stdout:r(e.stdin||""),stderr:""};let o="",i="",f=0;for(const d of t){const y=e.resolvePath(d);if(!e.vfs.existsSync(y)){i+=`tail: cannot open '${d}' for reading: No such file or directory
303
- `,f=1;continue}if(e.vfs.statSync&&e.vfs.statSync(y).isDirectory()){i+=`tail: error reading '${d}': Is a directory
294
+ `}if(t.length===0)return{code:0,stdout:r(e.stdin||""),stderr:""};let o="",i="",f=0;for(const a of t){const y=e.resolvePath(a);if(!e.vfs.existsSync(y)){i+=`tail: cannot open '${a}' for reading: No such file or directory
295
+ `,f=1;continue}if(e.vfs.statSync&&e.vfs.statSync(y).isDirectory()){i+=`tail: error reading '${a}': Is a directory
304
296
  `,f=1;continue}try{const l=e.vfs.readFileSync(y,"utf8");o+=r(l)}catch(l){i+=`tail: ${l.message}
305
297
  `,f=1}}return{code:f,stdout:o,stderr:i}},async echo(n,e){let s=!1,t=!1,r=0;for(;r<n.length&&n[r].startsWith("-");){const i=n[r];if(i==="-n")s=!0;else if(i==="-e")t=!0;else if(i==="-ne"||i==="-en")s=!0,t=!0;else break;r++}let o=n.slice(r).join(" ");return t&&(o=o.replace(/\\n/g,`
306
298
  `).replace(/\\t/g," ").replace(/\\r/g,"\r").replace(/\\b/g,"\b").replace(/\\f/g,"\f").replace(/\\\\/g,"\\")),{code:0,stdout:o+(s?"":`
307
299
  `),stderr:""}},async printf(n,e){if(n.length===0)return{code:0,stdout:"",stderr:""};let s=n[0].replace(/\\n/g,`
308
- `).replace(/\\t/g," ").replace(/\\r/g,"\r").replace(/\\\\/g,"\\"),t=1;return{code:0,stdout:s.replace(/%([-+0 #]*)(\d+)?(?:\.(\d+))?([sdifxX%])/g,(o,i,f,d,y)=>{if(y==="%")return"%";const l=n[t++];if(l===void 0)return"";let a="";if(y==="s")a=String(l),d!==void 0&&d!==""&&(a=a.slice(0,parseInt(d,10)));else if(y==="d"||y==="i")a=String(parseInt(l,10)||0);else if(y==="f"){const c=parseFloat(l)||0;a=d!==void 0&&d!==""?c.toFixed(parseInt(d,10)):String(c)}else if(y==="x")a=(Number(l)||0).toString(16);else if(y==="X")a=(Number(l)||0).toString(16).toUpperCase();else return o;if(f){const c=parseInt(f,10);if(i&&i.includes("0")&&(y==="d"||y==="i")){const h=a.startsWith("-");h&&(a=a.slice(1)),a=a.padStart(c-(h?1:0),"0"),h&&(a="-"+a)}else i&&i.includes("-")?a=a.padEnd(c," "):a=a.padStart(c," ")}return a}),stderr:""}},async grep(n,e){let s=!1,t=!1,r=!1,o=!1,i=!1,f=!1,d=!1,y=null;const l=[];for(let b=0;b<n.length;b++){const v=n[b];if(v.startsWith("-")&&v.length>1)for(let w=1;w<v.length;w++){const $=v[w];$==="i"?s=!0:$==="v"?t=!0:$==="n"?r=!0:$==="c"?o=!0:$==="l"?i=!0:$==="r"||$==="R"?f=!0:$==="E"&&(d=!0)}else y===null?y=v:l.push(v)}if(!y)return{code:2,stdout:"",stderr:`grep: missing pattern
309
- `};let a;try{a=new RegExp(y,s?"i":"")}catch(b){return{code:2,stdout:"",stderr:`grep: invalid pattern: ${b.message}
310
- `}}const c=[];if(f){const b=l.length>0?l:["."];for(const v of b){let $=function(R){try{const I=e.vfs.readdirSync(R);for(const C of I){const E=R==="/"?"/"+C:R+"/"+C;e.vfs.statSync(E).isDirectory()?$(E):c.push(E)}}catch(I){N.debug("grep directory walk skipped.",R,I)}};const w=e.resolvePath(v);e.vfs.existsSync(w)&&(e.vfs.statSync(w).isDirectory()?$(w):c.push(w))}}else for(const b of l)c.push(e.resolvePath(b));let h="",u="",p=0,g=!1;function m(b,v){const w=b.split(`
311
- `);w.length>0&&w[w.length-1]===""&&w.pop();let $=0,R="";for(let I=0;I<w.length;I++){const C=w[I],E=a.test(C);if(t?!E:E){if($++,p++,i){h+=`${v}
300
+ `).replace(/\\t/g," ").replace(/\\r/g,"\r").replace(/\\\\/g,"\\"),t=1;return{code:0,stdout:s.replace(/%([-+0 #]*)(\d+)?(?:\.(\d+))?([sdifxX%])/g,(o,i,f,a,y)=>{if(y==="%")return"%";const l=n[t++];if(l===void 0)return"";let c="";if(y==="s")c=String(l),a!==void 0&&a!==""&&(c=c.slice(0,parseInt(a,10)));else if(y==="d"||y==="i")c=String(parseInt(l,10)||0);else if(y==="f"){const d=parseFloat(l)||0;c=a!==void 0&&a!==""?d.toFixed(parseInt(a,10)):String(d)}else if(y==="x")c=(Number(l)||0).toString(16);else if(y==="X")c=(Number(l)||0).toString(16).toUpperCase();else return o;if(f){const d=parseInt(f,10);if(i&&i.includes("0")&&(y==="d"||y==="i")){const u=c.startsWith("-");u&&(c=c.slice(1)),c=c.padStart(d-(u?1:0),"0"),u&&(c="-"+c)}else i&&i.includes("-")?c=c.padEnd(d," "):c=c.padStart(d," ")}return c}),stderr:""}},async grep(n,e){let s=!1,t=!1,r=!1,o=!1,i=!1,f=!1,a=!1,y=null;const l=[];for(let b=0;b<n.length;b++){const v=n[b];if(v.startsWith("-")&&v.length>1)for(let w=1;w<v.length;w++){const $=v[w];$==="i"?s=!0:$==="v"?t=!0:$==="n"?r=!0:$==="c"?o=!0:$==="l"?i=!0:$==="r"||$==="R"?f=!0:$==="E"&&(a=!0)}else y===null?y=v:l.push(v)}if(!y)return{code:2,stdout:"",stderr:`grep: missing pattern
301
+ `};let c;try{c=new RegExp(y,s?"i":"")}catch(b){return{code:2,stdout:"",stderr:`grep: invalid pattern: ${b.message}
302
+ `}}const d=[];if(f){const b=l.length>0?l:["."];for(const v of b){let $=function(R){try{const I=e.vfs.readdirSync(R);for(const C of I){const E=R==="/"?"/"+C:R+"/"+C;e.vfs.statSync(E).isDirectory()?$(E):d.push(E)}}catch(I){_.debug("grep directory walk skipped.",R,I)}};const w=e.resolvePath(v);e.vfs.existsSync(w)&&(e.vfs.statSync(w).isDirectory()?$(w):d.push(w))}}else for(const b of l)d.push(e.resolvePath(b));let u="",h="",p=0,g=!1;function m(b,v){const w=b.split(`
303
+ `);w.length>0&&w[w.length-1]===""&&w.pop();let $=0,R="";for(let I=0;I<w.length;I++){const C=w[I],E=c.test(C);if(t?!E:E){if($++,p++,i){u+=`${v}
312
304
  `;return}if(!o){const k=v?`${v}:`:"",O=r?`${I+1}:`:"";R+=`${k}${O}${C}
313
- `}}}if(o){const I=v?`${v}:`:"";h+=`${I}${$}
314
- `}else h+=R}if(c.length===0)m(e.stdin||"","");else{const b=c.length>1;for(const v of c){if(!e.vfs.existsSync(v)){u+=`grep: ${v}: No such file or directory
315
- `,g=!0;continue}try{const w=e.vfs.readFileSync(v,"utf8"),$=b?j.normalize(v.replace("/workspace/","")):"";m(w,$)}catch(w){u+=`grep: ${v}: ${w.message}
316
- `,g=!0}}}let S=1;return p>0?S=0:g&&(S=2),{code:S,stdout:h,stderr:u}},async find(n,e){let s=".",t=null,r=null,o=1/0,i=0;for(n[0]&&!n[0].startsWith("-")&&(s=n[0],i=1);i<n.length;){const a=n[i];if(a==="-name"&&i+1<n.length)t=n[++i];else if(a==="-type"&&i+1<n.length)r=n[++i];else if(a==="-maxdepth"&&i+1<n.length){const c=parseInt(n[++i],10);o=isNaN(c)?1/0:c}i++}const f=t?Pe(t,!1):null,d=e.resolvePath(s),y=[];function l(a,c){if(c>o)return;let h=[];try{h=e.vfs.readdirSync(a)}catch{return}for(const u of h){const p=a==="/"?"/"+u:a+"/"+u;let g=!1;try{g=e.vfs.statSync(p).isDirectory()}catch(b){N.debug("find statSync skipped.",p,b)}const m=s==="."?"./"+p.replace(d.endsWith("/")?d:d+"/",""):p;let S=!0;r==="f"&&g&&(S=!1),r==="d"&&!g&&(S=!1),f&&!f.test(u)&&(S=!1),S&&y.push(m),g&&l(p,c+1)}}if(e.vfs.existsSync(d)){let a=!1;try{a=e.vfs.statSync(d).isDirectory()}catch(c){N.debug("find root statSync skipped.",d,c)}(!r||r==="d"&&a||r==="f"&&!a)&&(!f||f.test(j.basename(s)))&&y.push(s),a&&l(d,1)}else return{code:1,stdout:"",stderr:`find: '${s}': No such file or directory
305
+ `}}}if(o){const I=v?`${v}:`:"";u+=`${I}${$}
306
+ `}else u+=R}if(d.length===0)m(e.stdin||"","");else{const b=d.length>1;for(const v of d){if(!e.vfs.existsSync(v)){h+=`grep: ${v}: No such file or directory
307
+ `,g=!0;continue}try{const w=e.vfs.readFileSync(v,"utf8"),$=b?j.normalize(v.replace("/workspace/","")):"";m(w,$)}catch(w){h+=`grep: ${v}: ${w.message}
308
+ `,g=!0}}}let S=1;return p>0?S=0:g&&(S=2),{code:S,stdout:u,stderr:h}},async find(n,e){let s=".",t=null,r=null,o=1/0,i=0;for(n[0]&&!n[0].startsWith("-")&&(s=n[0],i=1);i<n.length;){const c=n[i];if(c==="-name"&&i+1<n.length)t=n[++i];else if(c==="-type"&&i+1<n.length)r=n[++i];else if(c==="-maxdepth"&&i+1<n.length){const d=parseInt(n[++i],10);o=isNaN(d)?1/0:d}i++}const f=t?Pe(t,!1):null,a=e.resolvePath(s),y=[];function l(c,d){if(d>o)return;let u=[];try{u=e.vfs.readdirSync(c)}catch{return}for(const h of u){const p=c==="/"?"/"+h:c+"/"+h;let g=!1;try{g=e.vfs.statSync(p).isDirectory()}catch(b){_.debug("find statSync skipped.",p,b)}const m=s==="."?"./"+p.replace(a.endsWith("/")?a:a+"/",""):p;let S=!0;r==="f"&&g&&(S=!1),r==="d"&&!g&&(S=!1),f&&!f.test(h)&&(S=!1),S&&y.push(m),g&&l(p,d+1)}}if(e.vfs.existsSync(a)){let c=!1;try{c=e.vfs.statSync(a).isDirectory()}catch(d){_.debug("find root statSync skipped.",a,d)}(!r||r==="d"&&c||r==="f"&&!c)&&(!f||f.test(j.basename(s)))&&y.push(s),c&&l(a,1)}else return{code:1,stdout:"",stderr:`find: '${s}': No such file or directory
317
309
  `};return y.sort(),{code:0,stdout:y.join(`
318
310
  `)+(y.length>0?`
319
- `:""),stderr:""}},async wc(n,e){let s=!1,t=!1,r=!1;const o=[];for(const c of n)c==="-l"?s=!0:c==="-w"?t=!0:c==="-c"||c==="-m"?r=!0:o.push(c);!s&&!t&&!r&&(s=!0,t=!0,r=!0);function i(c){const h=c.length===0?0:(c.match(/\n/g)||[]).length,u=(c.trim().match(/\S+/g)||[]).length,p=typeof Buffer<"u"?Buffer.byteLength(c,"utf8"):typeof TextEncoder<"u"?new TextEncoder().encode(c).length:c.length;return{lines:h,words:u,bytes:p}}function f(c,h){let u=[];return s&&u.push(String(c.lines).padStart(4," ")),t&&u.push(String(c.words).padStart(4," ")),r&&u.push(String(c.bytes).padStart(4," ")),h&&u.push(h),u.join(" ")+`
320
- `}if(o.length===0){const c=i(e.stdin||"");return{code:0,stdout:f(c,""),stderr:""}}let d="",y="",l=0,a={lines:0,words:0,bytes:0};for(const c of o){const h=e.resolvePath(c);if(!e.vfs.existsSync(h)){y+=`wc: ${c}: No such file or directory
321
- `,l=1;continue}try{if(e.vfs.statSync(h).isDirectory()){y+=`wc: ${c}: Is a directory
322
- `,l=1;continue}const p=e.vfs.readFileSync(h,"utf8"),g=i(p);a.lines+=g.lines,a.words+=g.words,a.bytes+=g.bytes,d+=f(g,c)}catch(u){y+=`wc: ${c}: ${u.message}
323
- `,l=1}}return o.length>1&&(d+=f(a,"total")),{code:l,stdout:d,stderr:y}},async sort(n,e){let s=!1,t=!1,r=!1,o=!1,i=null,f=null;const d=[];for(let a=0;a<n.length;a++){const c=n[a];if(c==="-k"&&a+1<n.length)i=parseInt(n[++a],10)-1;else if(c==="-t"&&a+1<n.length)f=n[++a];else if(c.startsWith("-")&&c.length>1&&!c.startsWith("--"))for(let h=1;h<c.length;h++){const u=c[h];if(u==="r")s=!0;else if(u==="n")t=!0;else if(u==="u")r=!0;else if(u==="f")o=!0;else{d.push(c);break}}else d.push(c)}let y="";if(d.length===0)y=e.stdin||"";else for(const a of d){const c=e.resolvePath(a);if(!e.vfs.existsSync(c))return{code:1,stdout:"",stderr:`sort: cannot read '${a}': No such file or directory
324
- `};try{if(e.vfs.statSync(c).isDirectory())return{code:1,stdout:"",stderr:`sort: read failed: ${a}: Is a directory
325
- `};y+=e.vfs.readFileSync(c,"utf8")}catch(h){return{code:1,stdout:"",stderr:`sort: cannot read '${a}': ${h.message}
311
+ `:""),stderr:""}},async wc(n,e){let s=!1,t=!1,r=!1;const o=[];for(const d of n)d==="-l"?s=!0:d==="-w"?t=!0:d==="-c"||d==="-m"?r=!0:o.push(d);!s&&!t&&!r&&(s=!0,t=!0,r=!0);function i(d){const u=d.length===0?0:(d.match(/\n/g)||[]).length,h=(d.trim().match(/\S+/g)||[]).length,p=typeof Buffer<"u"?Buffer.byteLength(d,"utf8"):typeof TextEncoder<"u"?new TextEncoder().encode(d).length:d.length;return{lines:u,words:h,bytes:p}}function f(d,u){let h=[];return s&&h.push(String(d.lines).padStart(4," ")),t&&h.push(String(d.words).padStart(4," ")),r&&h.push(String(d.bytes).padStart(4," ")),u&&h.push(u),h.join(" ")+`
312
+ `}if(o.length===0){const d=i(e.stdin||"");return{code:0,stdout:f(d,""),stderr:""}}let a="",y="",l=0,c={lines:0,words:0,bytes:0};for(const d of o){const u=e.resolvePath(d);if(!e.vfs.existsSync(u)){y+=`wc: ${d}: No such file or directory
313
+ `,l=1;continue}try{if(e.vfs.statSync(u).isDirectory()){y+=`wc: ${d}: Is a directory
314
+ `,l=1;continue}const p=e.vfs.readFileSync(u,"utf8"),g=i(p);c.lines+=g.lines,c.words+=g.words,c.bytes+=g.bytes,a+=f(g,d)}catch(h){y+=`wc: ${d}: ${h.message}
315
+ `,l=1}}return o.length>1&&(a+=f(c,"total")),{code:l,stdout:a,stderr:y}},async sort(n,e){let s=!1,t=!1,r=!1,o=!1,i=null,f=null;const a=[];for(let c=0;c<n.length;c++){const d=n[c];if(d==="-k"&&c+1<n.length)i=parseInt(n[++c],10)-1;else if(d==="-t"&&c+1<n.length)f=n[++c];else if(d.startsWith("-")&&d.length>1&&!d.startsWith("--"))for(let u=1;u<d.length;u++){const h=d[u];if(h==="r")s=!0;else if(h==="n")t=!0;else if(h==="u")r=!0;else if(h==="f")o=!0;else{a.push(d);break}}else a.push(d)}let y="";if(a.length===0)y=e.stdin||"";else for(const c of a){const d=e.resolvePath(c);if(!e.vfs.existsSync(d))return{code:1,stdout:"",stderr:`sort: cannot read '${c}': No such file or directory
316
+ `};try{if(e.vfs.statSync(d).isDirectory())return{code:1,stdout:"",stderr:`sort: read failed: ${c}: Is a directory
317
+ `};y+=e.vfs.readFileSync(d,"utf8")}catch(u){return{code:1,stdout:"",stderr:`sort: cannot read '${c}': ${u.message}
326
318
  `}}}let l=y.split(`
327
- `);return l.length>0&&l[l.length-1]===""&&l.pop(),l.sort((a,c)=>{let h=a,u=c;if(i!==null){const p=f?a.split(f):a.trim().split(/\s+/),g=f?c.split(f):c.trim().split(/\s+/);h=p[i]||"",u=g[i]||""}if(t){const p=parseFloat(h)||0,g=parseFloat(u)||0;return p-g}return o?h.toLowerCase().localeCompare(u.toLowerCase()):h.localeCompare(u)}),s&&l.reverse(),r&&(l=Array.from(new Set(l))),{code:0,stdout:l.join(`
319
+ `);return l.length>0&&l[l.length-1]===""&&l.pop(),l.sort((c,d)=>{let u=c,h=d;if(i!==null){const p=f?c.split(f):c.trim().split(/\s+/),g=f?d.split(f):d.trim().split(/\s+/);u=p[i]||"",h=g[i]||""}if(t){const p=parseFloat(u)||0,g=parseFloat(h)||0;return p-g}return o?u.toLowerCase().localeCompare(h.toLowerCase()):u.localeCompare(h)}),s&&l.reverse(),r&&(l=Array.from(new Set(l))),{code:0,stdout:l.join(`
328
320
  `)+(l.length>0?`
329
- `:""),stderr:""}},async uniq(n,e){let s=!1,t=!1,r=!1,o=!1;const i=[];for(const h of n)if(h.startsWith("-")&&h.length>1&&!h.startsWith("--"))for(let u=1;u<h.length;u++){const p=h[u];if(p==="c")s=!0;else if(p==="d")t=!0;else if(p==="u")r=!0;else if(p==="i")o=!0;else{i.push(h);break}}else i.push(h);let f=e.stdin||"";if(i.length>0){const h=e.resolvePath(i[0]);if(!e.vfs.existsSync(h))return{code:1,stdout:"",stderr:`uniq: ${i[0]}: No such file or directory
330
- `};try{if(e.vfs.statSync(h).isDirectory())return{code:1,stdout:"",stderr:`uniq: error reading '${i[0]}': Is a directory
331
- `};f=e.vfs.readFileSync(h,"utf8")}catch(u){return{code:1,stdout:"",stderr:`uniq: error reading '${i[0]}': ${u.message}
332
- `}}}const d=f.split(`
333
- `);d.length>0&&d[d.length-1]===""&&d.pop();const y=[];let l=null,a=0;for(const h of d){const u=o?h.toLowerCase():h,p=o&&l!==null?l.toLowerCase():l;u===p?a++:(l!==null&&y.push({line:l,count:a}),l=h,a=1)}l!==null&&y.push({line:l,count:a});let c="";for(const h of y)t&&h.count===1||r&&h.count>1||(s?c+=`${String(h.count).padStart(4," ")} ${h.line}
334
- `:c+=`${h.line}
335
- `);return{code:0,stdout:c,stderr:""}},async sed(n,e){let s=!1,t=null;const r=[];for(let l=0;l<n.length;l++){const a=n[l];a==="-i"?s=!0:a==="-e"&&l+1<n.length?t=n[++l]:t?r.push(a):t=a}if(!t)return{code:1,stdout:"",stderr:`sed: missing expression
336
- `};function o(l,a){const c=[];let h="",u=!1;for(let p=0;p<l.length;p++){const g=l[p];u?(g===a?h+=a:h+="\\"+g,u=!1):g==="\\"?u=!0:g===a?(c.push(h),h=""):h+=g}return c.push(h),c}function i(l){if(t.startsWith("s")){const a=t[1],c=o(t.slice(2),a);if(c.length>=2){const h=c[0],u=c[1],p=c[2]||"",g=new RegExp(h,p.includes("g")?"g":"");return l.split(`
337
- `).map(m=>m.replace(g,u)).join(`
338
- `)}}if(t.endsWith("d")){const a=t.slice(0,-1);if(/^\d+$/.test(a)){const c=parseInt(a,10);return l.split(`
339
- `).filter((h,u)=>u+1!==c).join(`
340
- `)}if(a.startsWith("/")&&a.endsWith("/")){const c=a.slice(1,-1),h=new RegExp(c);return l.split(`
341
- `).filter(u=>!h.test(u)).join(`
321
+ `:""),stderr:""}},async uniq(n,e){let s=!1,t=!1,r=!1,o=!1;const i=[];for(const u of n)if(u.startsWith("-")&&u.length>1&&!u.startsWith("--"))for(let h=1;h<u.length;h++){const p=u[h];if(p==="c")s=!0;else if(p==="d")t=!0;else if(p==="u")r=!0;else if(p==="i")o=!0;else{i.push(u);break}}else i.push(u);let f=e.stdin||"";if(i.length>0){const u=e.resolvePath(i[0]);if(!e.vfs.existsSync(u))return{code:1,stdout:"",stderr:`uniq: ${i[0]}: No such file or directory
322
+ `};try{if(e.vfs.statSync(u).isDirectory())return{code:1,stdout:"",stderr:`uniq: error reading '${i[0]}': Is a directory
323
+ `};f=e.vfs.readFileSync(u,"utf8")}catch(h){return{code:1,stdout:"",stderr:`uniq: error reading '${i[0]}': ${h.message}
324
+ `}}}const a=f.split(`
325
+ `);a.length>0&&a[a.length-1]===""&&a.pop();const y=[];let l=null,c=0;for(const u of a){const h=o?u.toLowerCase():u,p=o&&l!==null?l.toLowerCase():l;h===p?c++:(l!==null&&y.push({line:l,count:c}),l=u,c=1)}l!==null&&y.push({line:l,count:c});let d="";for(const u of y)t&&u.count===1||r&&u.count>1||(s?d+=`${String(u.count).padStart(4," ")} ${u.line}
326
+ `:d+=`${u.line}
327
+ `);return{code:0,stdout:d,stderr:""}},async sed(n,e){let s=!1,t=null;const r=[];for(let l=0;l<n.length;l++){const c=n[l];c==="-i"?s=!0:c==="-e"&&l+1<n.length?t=n[++l]:t?r.push(c):t=c}if(!t)return{code:1,stdout:"",stderr:`sed: missing expression
328
+ `};function o(l,c){const d=[];let u="",h=!1;for(let p=0;p<l.length;p++){const g=l[p];h?(g===c?u+=c:u+="\\"+g,h=!1):g==="\\"?h=!0:g===c?(d.push(u),u=""):u+=g}return d.push(u),d}function i(l){if(t.startsWith("s")){const c=t[1],d=o(t.slice(2),c);if(d.length>=2){const u=d[0],h=d[1],p=d[2]||"",g=new RegExp(u,p.includes("g")?"g":"");return l.split(`
329
+ `).map(m=>m.replace(g,h)).join(`
330
+ `)}}if(t.endsWith("d")){const c=t.slice(0,-1);if(/^\d+$/.test(c)){const d=parseInt(c,10);return l.split(`
331
+ `).filter((u,h)=>h+1!==d).join(`
332
+ `)}if(c.startsWith("/")&&c.endsWith("/")){const d=c.slice(1,-1),u=new RegExp(d);return l.split(`
333
+ `).filter(h=>!u.test(h)).join(`
342
334
  `)}}return l}if(r.length===0)try{return{code:0,stdout:i(e.stdin||""),stderr:""}}catch(l){return{code:1,stdout:"",stderr:`sed: ${l.message}
343
- `}}let f="",d="",y=0;for(const l of r){const a=e.resolvePath(l);if(!e.vfs.existsSync(a)){d+=`sed: can't read ${l}: No such file or directory
344
- `,y=1;continue}try{if(e.vfs.statSync(a).isDirectory()){d+=`sed: couldn't edit ${l}: is a directory
345
- `,y=1;continue}const h=e.vfs.readFileSync(a,"utf8"),u=i(h);s?(e.vfs.writeFileSync(a,u),e.emitMutation("change",a)):f+=u}catch(c){d+=`sed: ${c.message}
346
- `,y=1}}return{code:y,stdout:f,stderr:d}},async awk(n,e){let s=null,t=null;const r=[];for(let d=0;d<n.length;d++){const y=n[d];y==="-F"&&d+1<n.length?s=n[++d]:y.startsWith("-F")&&y.length>2?s=y.slice(2):t?r.push(y):t=y}if(!t)return{code:1,stdout:"",stderr:`awk: missing script
347
- `};let o=e.stdin||"";if(r.length>0){o="";for(const d of r){const y=e.resolvePath(d);if(!e.vfs.existsSync(y))return{code:1,stdout:"",stderr:`awk: cannot open ${d} (No such file or directory)
348
- `};try{if(e.vfs.statSync(y).isDirectory())return{code:1,stdout:"",stderr:`awk: ${d}: Is a directory
349
- `};o+=e.vfs.readFileSync(y,"utf8")}catch(l){return{code:1,stdout:"",stderr:`awk: ${d}: ${l.message}
335
+ `}}let f="",a="",y=0;for(const l of r){const c=e.resolvePath(l);if(!e.vfs.existsSync(c)){a+=`sed: can't read ${l}: No such file or directory
336
+ `,y=1;continue}try{if(e.vfs.statSync(c).isDirectory()){a+=`sed: couldn't edit ${l}: is a directory
337
+ `,y=1;continue}const u=e.vfs.readFileSync(c,"utf8"),h=i(u);s?(e.vfs.writeFileSync(c,h),e.emitMutation("change",c)):f+=h}catch(d){a+=`sed: ${d.message}
338
+ `,y=1}}return{code:y,stdout:f,stderr:a}},async awk(n,e){let s=null,t=null;const r=[];for(let a=0;a<n.length;a++){const y=n[a];y==="-F"&&a+1<n.length?s=n[++a]:y.startsWith("-F")&&y.length>2?s=y.slice(2):t?r.push(y):t=y}if(!t)return{code:1,stdout:"",stderr:`awk: missing script
339
+ `};let o=e.stdin||"";if(r.length>0){o="";for(const a of r){const y=e.resolvePath(a);if(!e.vfs.existsSync(y))return{code:1,stdout:"",stderr:`awk: cannot open ${a} (No such file or directory)
340
+ `};try{if(e.vfs.statSync(y).isDirectory())return{code:1,stdout:"",stderr:`awk: ${a}: Is a directory
341
+ `};o+=e.vfs.readFileSync(y,"utf8")}catch(l){return{code:1,stdout:"",stderr:`awk: ${a}: ${l.message}
350
342
  `}}}}const i=o.split(`
351
- `);i.length>0&&i[i.length-1]===""&&i.pop();let f="";for(let d=0;d<i.length;d++){const y=i[d],l=s?s.length===1?y.split(s):y.split(new RegExp(s)):y.trim().split(/\s+/),a=d+1,c=l.length,h=t.match(/print\s+(.+)}/);if(h){const p=h[1].split(",").map(g=>g.trim()).map(g=>{if(g==="$0")return y;if(g==="$NF")return l[l.length-1]||"";if(g.startsWith("$")){const m=parseInt(g.slice(1),10)-1;return l[m]||""}return g==="NR"?String(a):g==="NF"?String(c):g.startsWith('"')&&g.endsWith('"')?g.slice(1,-1):g});f+=p.join(" ")+`
343
+ `);i.length>0&&i[i.length-1]===""&&i.pop();let f="";for(let a=0;a<i.length;a++){const y=i[a],l=s?s.length===1?y.split(s):y.split(new RegExp(s)):y.trim().split(/\s+/),c=a+1,d=l.length,u=t.match(/print\s+(.+)}/);if(u){const p=u[1].split(",").map(g=>g.trim()).map(g=>{if(g==="$0")return y;if(g==="$NF")return l[l.length-1]||"";if(g.startsWith("$")){const m=parseInt(g.slice(1),10)-1;return l[m]||""}return g==="NR"?String(c):g==="NF"?String(d):g.startsWith('"')&&g.endsWith('"')?g.slice(1,-1):g});f+=p.join(" ")+`
352
344
  `}else f+=y+`
353
- `}return{code:0,stdout:f,stderr:""}},async cut(n,e){let s=" ",t=null,r=null;const o=[];for(let a=0;a<n.length;a++){const c=n[a];c==="-d"&&a+1<n.length?s=n[++a]:c.startsWith("-d")?s=c.slice(2):c==="-f"&&a+1<n.length?t=n[++a]:c.startsWith("-f")?t=c.slice(2):c==="-c"&&a+1<n.length?r=n[++a]:c.startsWith("-c")?r=c.slice(2):o.push(c)}function i(a){return a.split(",").map(c=>{if(c.includes("-")){const[u,p]=c.split("-"),g=u?Math.max(1,parseInt(u,10))-1:0,m=p?parseInt(p,10):1/0;return{start:g,end:m}}const h=Math.max(1,parseInt(c,10))-1;return{start:h,end:h+1}})}let f=e.stdin||"";if(o.length>0){f="";for(const a of o){const c=e.resolvePath(a);if(!e.vfs.existsSync(c))return{code:1,stdout:"",stderr:`cut: ${a}: No such file or directory
354
- `};try{if(e.vfs.statSync(c).isDirectory())return{code:1,stdout:"",stderr:`cut: ${a}: Is a directory
355
- `};f+=e.vfs.readFileSync(c,"utf8")}catch(h){return{code:1,stdout:"",stderr:`cut: ${a}: ${h.message}
356
- `}}}}const d=f.split(`
357
- `);if(d.length>0&&d[d.length-1]===""&&d.pop(),r){const a=i(r),c=d.map(h=>{let u="";for(const p of a)u+=h.slice(p.start,p.end===1/0?void 0:p.end);return u});return{code:0,stdout:c.join(`
358
- `)+(c.length>0?`
359
- `:""),stderr:""}}const y=t?i(t):[],l=d.map(a=>{if(y.length===0)return a;const c=a.split(s),h=[];for(const u of y){const p=Math.min(c.length,u.end);for(let g=u.start;g<p;g++)h.push(c[g]!==void 0?c[g]:"")}return h.join(s)});return{code:0,stdout:l.join(`
345
+ `}return{code:0,stdout:f,stderr:""}},async cut(n,e){let s=" ",t=null,r=null;const o=[];for(let c=0;c<n.length;c++){const d=n[c];d==="-d"&&c+1<n.length?s=n[++c]:d.startsWith("-d")?s=d.slice(2):d==="-f"&&c+1<n.length?t=n[++c]:d.startsWith("-f")?t=d.slice(2):d==="-c"&&c+1<n.length?r=n[++c]:d.startsWith("-c")?r=d.slice(2):o.push(d)}function i(c){return c.split(",").map(d=>{if(d.includes("-")){const[h,p]=d.split("-"),g=h?Math.max(1,parseInt(h,10))-1:0,m=p?parseInt(p,10):1/0;return{start:g,end:m}}const u=Math.max(1,parseInt(d,10))-1;return{start:u,end:u+1}})}let f=e.stdin||"";if(o.length>0){f="";for(const c of o){const d=e.resolvePath(c);if(!e.vfs.existsSync(d))return{code:1,stdout:"",stderr:`cut: ${c}: No such file or directory
346
+ `};try{if(e.vfs.statSync(d).isDirectory())return{code:1,stdout:"",stderr:`cut: ${c}: Is a directory
347
+ `};f+=e.vfs.readFileSync(d,"utf8")}catch(u){return{code:1,stdout:"",stderr:`cut: ${c}: ${u.message}
348
+ `}}}}const a=f.split(`
349
+ `);if(a.length>0&&a[a.length-1]===""&&a.pop(),r){const c=i(r),d=a.map(u=>{let h="";for(const p of c)h+=u.slice(p.start,p.end===1/0?void 0:p.end);return h});return{code:0,stdout:d.join(`
350
+ `)+(d.length>0?`
351
+ `:""),stderr:""}}const y=t?i(t):[],l=a.map(c=>{if(y.length===0)return c;const d=c.split(s),u=[];for(const h of y){const p=Math.min(d.length,h.end);for(let g=h.start;g<p;g++)u.push(d[g]!==void 0?d[g]:"")}return u.join(s)});return{code:0,stdout:l.join(`
360
352
  `)+(l.length>0?`
361
- `:""),stderr:""}},async tr(n,e){let s=!1,t=!1,r="",o="";for(const h of n)h==="-d"?s=!0:h==="-s"?t=!0:h==="-ds"||h==="-sd"?(s=!0,t=!0):r?o||(o=h):r=h;function i(h){if(!h)return"";if(h==="[:lower:]")return"abcdefghijklmnopqrstuvwxyz";if(h==="[:upper:]")return"ABCDEFGHIJKLMNOPQRSTUVWXYZ";if(h==="[:digit:]")return"0123456789";if(h==="[:space:]")return`
362
- \r\f\v`;let u=h.replace(/\\n/g,`
363
- `).replace(/\\t/g," ").replace(/\\r/g,"\r");return u=u.replace(/(.)-(.)/g,(p,g,m)=>{const S=g.charCodeAt(0),b=m.charCodeAt(0);if(S>b)return g+"-"+m;let v="";for(let w=S;w<=b;w++)v+=String.fromCharCode(w);return v}),u}const f=i(r),d=i(o),y=t?d||f:"",l=e.stdin||"";let a="",c="";for(let h=0;h<l.length;h++){const u=l[h],p=f.indexOf(u);let g=u;if(p!==-1){if(s)continue;d.length>0&&(g=d[p]||d[d.length-1])}t&&y.includes(g)&&g===c||(a+=g,c=g)}return{code:0,stdout:a,stderr:""}},async diff(n,e){let s=!1;const t=[];for(const a of n)a==="-u"?s=!0:t.push(a);if(t.length<2)return{code:2,stdout:"",stderr:`diff: missing operand
353
+ `:""),stderr:""}},async tr(n,e){let s=!1,t=!1,r="",o="";for(const u of n)u==="-d"?s=!0:u==="-s"?t=!0:u==="-ds"||u==="-sd"?(s=!0,t=!0):r?o||(o=u):r=u;function i(u){if(!u)return"";if(u==="[:lower:]")return"abcdefghijklmnopqrstuvwxyz";if(u==="[:upper:]")return"ABCDEFGHIJKLMNOPQRSTUVWXYZ";if(u==="[:digit:]")return"0123456789";if(u==="[:space:]")return`
354
+ \r\f\v`;let h=u.replace(/\\n/g,`
355
+ `).replace(/\\t/g," ").replace(/\\r/g,"\r");return h=h.replace(/(.)-(.)/g,(p,g,m)=>{const S=g.charCodeAt(0),b=m.charCodeAt(0);if(S>b)return g+"-"+m;let v="";for(let w=S;w<=b;w++)v+=String.fromCharCode(w);return v}),h}const f=i(r),a=i(o),y=t?a||f:"",l=e.stdin||"";let c="",d="";for(let u=0;u<l.length;u++){const h=l[u],p=f.indexOf(h);let g=h;if(p!==-1){if(s)continue;a.length>0&&(g=a[p]||a[a.length-1])}t&&y.includes(g)&&g===d||(c+=g,d=g)}return{code:0,stdout:c,stderr:""}},async diff(n,e){let s=!1;const t=[];for(const c of n)c==="-u"?s=!0:t.push(c);if(t.length<2)return{code:2,stdout:"",stderr:`diff: missing operand
364
356
  `};const r=e.resolvePath(t[0]),o=e.resolvePath(t[1]);if(!e.vfs.existsSync(r))return{code:2,stdout:"",stderr:`diff: ${t[0]}: No such file or directory
365
357
  `};if(!e.vfs.existsSync(o))return{code:2,stdout:"",stderr:`diff: ${t[1]}: No such file or directory
366
358
  `};if(e.vfs.statSync(r).isDirectory())return{code:2,stdout:"",stderr:`diff: ${t[0]}: Is a directory
367
359
  `};if(e.vfs.statSync(o).isDirectory())return{code:2,stdout:"",stderr:`diff: ${t[1]}: Is a directory
368
- `};const d=e.vfs.readFileSync(r,"utf8"),y=e.vfs.readFileSync(o,"utf8");return d===y?{code:0,stdout:"",stderr:""}:{code:1,stdout:de(t[0],t[1],d,y),stderr:""}},async mkdir(n,e){let s=!1;const t=[];for(const i of n)i==="-p"?s=!0:t.push(i);if(t.length===0)return{code:1,stdout:"",stderr:`mkdir: missing operand
369
- `};let r=0,o="";for(const i of t){const f=e.resolvePath(i);try{if(s){const d=f.split("/").filter(Boolean);let y="";for(const l of d)y+="/"+l,e.vfs.existsSync(y)||(e.vfs.mkdirSync(y,{recursive:!0}),e.emitMutation("create",y))}else e.vfs.mkdirSync(f,{recursive:s}),e.emitMutation("create",f)}catch(d){o+=`mkdir: cannot create directory '${i}': ${d.message}
360
+ `};const a=e.vfs.readFileSync(r,"utf8"),y=e.vfs.readFileSync(o,"utf8");return a===y?{code:0,stdout:"",stderr:""}:{code:1,stdout:de(t[0],t[1],a,y),stderr:""}},async mkdir(n,e){let s=!1;const t=[];for(const i of n)i==="-p"?s=!0:t.push(i);if(t.length===0)return{code:1,stdout:"",stderr:`mkdir: missing operand
361
+ `};let r=0,o="";for(const i of t){const f=e.resolvePath(i);try{if(s){const a=f.split("/").filter(Boolean);let y="";for(const l of a)y+="/"+l,e.vfs.existsSync(y)||(e.vfs.mkdirSync(y,{recursive:!0}),e.emitMutation("create",y))}else e.vfs.mkdirSync(f,{recursive:s}),e.emitMutation("create",f)}catch(a){o+=`mkdir: cannot create directory '${i}': ${a.message}
370
362
  `,r=1}}return{code:r,stdout:"",stderr:o}},async touch(n,e){if(n.length===0)return{code:1,stdout:"",stderr:`touch: missing file operand
371
363
  `};let s=0,t="";for(const r of n){if(r.startsWith("-"))continue;const o=e.resolvePath(r);try{if(!e.vfs.existsSync(o))e.vfs.writeFileSync(o,""),e.emitMutation("create",o);else{const i=e.vfs.readFileSync(o,"utf8");e.vfs.writeFileSync(o,i),e.emitMutation("change",o)}}catch(i){t+=`touch: cannot touch '${r}': ${i.message}
372
364
  `,s=1}}return{code:s,stdout:"",stderr:t}},async rm(n,e){let s=!1,t=!1;const r=[];for(const f of n)(f==="-r"||f==="-R"||f==="-rf"||f==="-fr")&&(s=!0),(f==="-f"||f==="-rf"||f==="-fr")&&(t=!0),f.startsWith("-")||r.push(f);if(r.length===0)return t?{code:0,stdout:"",stderr:""}:{code:1,stdout:"",stderr:`rm: missing operand
373
- `};let o=0,i="";for(const f of r){const d=e.resolvePath(f);if(!e.vfs.existsSync(d)){t||(i+=`rm: cannot remove '${f}': No such file or directory
374
- `,o=1);continue}const y=e.vfs.statSync(d);if(y.isDirectory()&&!s){i+=`rm: cannot remove '${f}': Is a directory
375
- `,o=1;continue}try{typeof e.vfs.rmSync=="function"?e.vfs.rmSync(d,{recursive:s,force:t}):y.isDirectory()?e.vfs.rmdirSync(d,{recursive:s}):e.vfs.unlinkSync(d),e.emitMutation("delete",d)}catch(l){t||(i+=`rm: cannot remove '${f}': ${l.message}
365
+ `};let o=0,i="";for(const f of r){const a=e.resolvePath(f);if(!e.vfs.existsSync(a)){t||(i+=`rm: cannot remove '${f}': No such file or directory
366
+ `,o=1);continue}const y=e.vfs.statSync(a);if(y.isDirectory()&&!s){i+=`rm: cannot remove '${f}': Is a directory
367
+ `,o=1;continue}try{typeof e.vfs.rmSync=="function"?e.vfs.rmSync(a,{recursive:s,force:t}):y.isDirectory()?e.vfs.rmdirSync(a,{recursive:s}):e.vfs.unlinkSync(a),e.emitMutation("delete",a)}catch(l){t||(i+=`rm: cannot remove '${f}': ${l.message}
376
368
  `,o=1)}}return{code:o,stdout:"",stderr:i}},async cp(n,e){let s=!1;const t=[];for(const f of n)f==="-r"||f==="-R"?s=!0:f.startsWith("-")||t.push(f);if(t.length<2)return{code:1,stdout:"",stderr:`cp: missing destination file operand
377
- `};const r=e.resolvePath(t[t.length-1]),o=t.slice(0,-1);function i(f,d){if(e.vfs.statSync(f).isDirectory()){e.vfs.mkdirSync(d,{recursive:!0});const l=e.vfs.readdirSync(f);for(const a of l)i(f+"/"+a,d+"/"+a)}else{if(typeof e.vfs.copyFileSync=="function")e.vfs.copyFileSync(f,d);else{const l=e.vfs.readFileSync(f);e.vfs.writeFileSync(d,l)}e.emitMutation("create",d)}}for(const f of o){const d=e.resolvePath(f);if(!e.vfs.existsSync(d))return{code:1,stdout:"",stderr:`cp: cannot stat '${f}': No such file or directory
378
- `};if(e.vfs.statSync(d).isDirectory()&&!s)return{code:1,stdout:"",stderr:`cp: -r not specified; omitting directory '${f}'
379
- `};try{let l=r;e.vfs.existsSync(r)&&e.vfs.statSync(r).isDirectory()&&(l=r==="/"?"/"+j.basename(d):r+"/"+j.basename(d)),i(d,l)}catch(l){return{code:1,stdout:"",stderr:`cp: ${l.message}
369
+ `};const r=e.resolvePath(t[t.length-1]),o=t.slice(0,-1);function i(f,a){if(e.vfs.statSync(f).isDirectory()){e.vfs.mkdirSync(a,{recursive:!0});const l=e.vfs.readdirSync(f);for(const c of l)i(f+"/"+c,a+"/"+c)}else{if(typeof e.vfs.copyFileSync=="function")e.vfs.copyFileSync(f,a);else{const l=e.vfs.readFileSync(f);e.vfs.writeFileSync(a,l)}e.emitMutation("create",a)}}for(const f of o){const a=e.resolvePath(f);if(!e.vfs.existsSync(a))return{code:1,stdout:"",stderr:`cp: cannot stat '${f}': No such file or directory
370
+ `};if(e.vfs.statSync(a).isDirectory()&&!s)return{code:1,stdout:"",stderr:`cp: -r not specified; omitting directory '${f}'
371
+ `};try{let l=r;e.vfs.existsSync(r)&&e.vfs.statSync(r).isDirectory()&&(l=r==="/"?"/"+j.basename(a):r+"/"+j.basename(a)),i(a,l)}catch(l){return{code:1,stdout:"",stderr:`cp: ${l.message}
380
372
  `}}}return{code:0,stdout:"",stderr:""}},async mv(n,e){const s=n.filter(o=>!o.startsWith("-"));if(s.length<2)return{code:1,stdout:"",stderr:`mv: missing destination file operand
381
373
  `};const t=e.resolvePath(s[0]);let r=e.resolvePath(s[1]);if(!e.vfs.existsSync(t))return{code:1,stdout:"",stderr:`mv: cannot stat '${s[0]}': No such file or directory
382
374
  `};try{if(e.vfs.existsSync(r)&&e.vfs.statSync(r).isDirectory()&&(r=r==="/"?"/"+j.basename(t):r+"/"+j.basename(t)),typeof e.vfs.renameSync=="function")e.vfs.renameSync(t,r);else{const o=e.vfs.readFileSync(t);e.vfs.writeFileSync(r,o),e.vfs.unlinkSync(t)}e.emitMutation("rename",r)}catch(o){return{code:1,stdout:"",stderr:`mv: ${o.message}
383
375
  `}}return{code:0,stdout:"",stderr:""}},async chmod(n,e){if(n.length<2)return{code:1,stdout:"",stderr:`chmod: missing operand
384
376
  `};const s=n[0];for(let t=1;t<n.length;t++){const r=n[t],o=e.resolvePath(r);if(!e.vfs.existsSync(o))return{code:1,stdout:"",stderr:`chmod: cannot access '${r}': No such file or directory
385
377
  `};if(typeof e.vfs.chmodSync=="function")try{e.vfs.chmodSync(o,s)}catch(i){return{code:1,stdout:"",stderr:`chmod: ${i.message}
386
- `}}}return{code:0,stdout:"",stderr:""}},async tree(n,e){let s=!1,t=1/0,r=".";for(let l=0;l<n.length;l++){const a=n[l];a==="-a"?s=!0:a==="-L"&&l+1<n.length?t=parseInt(n[++l],10)||1/0:a.startsWith("-")||(r=a)}const o=e.resolvePath(r);if(!e.vfs.existsSync(o))return{code:1,stdout:"",stderr:`tree: '${r}': No such file or directory
378
+ `}}}return{code:0,stdout:"",stderr:""}},async tree(n,e){let s=!1,t=1/0,r=".";for(let l=0;l<n.length;l++){const c=n[l];c==="-a"?s=!0:c==="-L"&&l+1<n.length?t=parseInt(n[++l],10)||1/0:c.startsWith("-")||(r=c)}const o=e.resolvePath(r);if(!e.vfs.existsSync(o))return{code:1,stdout:"",stderr:`tree: '${r}': No such file or directory
387
379
  `};let i=`${r}
388
- `,f=0,d=0;function y(l,a,c){if(c>t)return;let h=[];try{h=e.vfs.readdirSync(l)}catch{return}s||(h=h.filter(u=>!u.startsWith("."))),h.sort();for(let u=0;u<h.length;u++){const p=h[u],g=u===h.length-1,m=l==="/"?"/"+p:l+"/"+p;let S=!1;try{S=e.vfs.statSync(m).isDirectory()}catch(b){N.debug("tree statSync skipped.",m,b)}i+=`${a}${g?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 "}${p}
389
- `,S?(f++,y(m,a+(g?" ":"\u2502 "),c+1)):d++}}return y(o,"",1),i+=`
390
- ${f} directories, ${d} files
380
+ `,f=0,a=0;function y(l,c,d){if(d>t)return;let u=[];try{u=e.vfs.readdirSync(l)}catch{return}s||(u=u.filter(h=>!h.startsWith("."))),u.sort();for(let h=0;h<u.length;h++){const p=u[h],g=h===u.length-1,m=l==="/"?"/"+p:l+"/"+p;let S=!1;try{S=e.vfs.statSync(m).isDirectory()}catch(b){_.debug("tree statSync skipped.",m,b)}i+=`${c}${g?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 "}${p}
381
+ `,S?(f++,y(m,c+(g?" ":"\u2502 "),d+1)):a++}}return y(o,"",1),i+=`
382
+ ${f} directories, ${a} files
391
383
  `,{code:0,stdout:i,stderr:""}},async env(n,e){const s=Object.keys(e.env).sort();let t="";for(const r of s)r!=="?"&&!r.startsWith("__")&&(t+=`${r}=${e.env[r]}
392
384
  `);return{code:0,stdout:t,stderr:""}},async export(n,e){const s=e.shell?e.shell.env:e.env;if(n.length===0){const t=Object.keys(s).filter(o=>o!=="?"&&!o.startsWith("__")).sort();let r="";for(const o of t)r+=`declare -x ${o}="${s[o]}"
393
385
  `;return{code:0,stdout:r,stderr:""}}for(const t of n){const r=t.indexOf("=");if(r!==-1){const o=t.slice(0,r),i=t.slice(r+1);e.env[o]=i,e.shell&&(e.shell.env[o]=i)}else{const o=e.shell&&e.shell.env[t]!==void 0?e.shell.env[t]:e.env[t]||"";e.env[t]=o,e.shell&&(e.shell.env[t]=o)}}return{code:0,stdout:"",stderr:""}},async unset(n,e){for(const s of n)delete e.env[s],e.shell&&delete e.shell.env[s];return{code:0,stdout:"",stderr:""}},async which(n,e){if(n.length===0)return{code:1,stdout:"",stderr:""};let s="",t=0;for(const r of n)V[r]?s+=`/usr/bin/${r}
@@ -403,7 +395,7 @@ ${f} directories, ${d} files
403
395
  `);return{code:0,stdout:s,stderr:""}},async jobs(n,e){let s="";for(const[t,r]of e.shell.jobs.entries()){const o=String(r.command||"").replace(/\s*&\s*$/,"");s+=`[${t}]+ ${r.status} ${o} &
404
396
  `}return{code:0,stdout:s,stderr:""}},async kill(n,e){if(n.length===0)return{code:1,stdout:"",stderr:`kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ...
405
397
  `};const s=n[n.length-1],t=parseInt(s.replace("%",""),10);if(isNaN(t))return{code:1,stdout:"",stderr:`kill: ${s}: arguments must be process or job IDs
406
- `};let r=!1;for(const[i,f]of e.shell.jobs.entries())if(f.pid===t||i===t){f.status="Terminated",typeof f.abort=="function"&&f.abort(),r=!0;break}let o=!1;if(e.shell.portTable&&(typeof e.shell.portTable.killProcess=="function"&&(o=e.shell.portTable.killProcess(t)||o),typeof e.shell.portTable.unregisterByPid=="function"&&(o=e.shell.portTable.unregisterByPid(t)||o),typeof e.shell.portTable.listServers=="function"&&typeof e.shell.portTable.unregisterServer=="function")){for(const i of e.shell.portTable.listServers())if(i.pid!==void 0&&String(i.pid)===String(t)){if(i.server&&typeof i.server.close=="function")try{i.server.close()}catch(f){N.debug("kill server.close failed.",f)}if(typeof i.stop=="function")try{i.stop()}catch(f){N.debug("kill server.stop failed.",f)}e.shell.portTable.unregisterServer(i.port),o=!0}}return r||o?{code:0,stdout:"",stderr:""}:{code:1,stdout:"",stderr:`kill: (${s}) - No such process
398
+ `};let r=!1;for(const[i,f]of e.shell.jobs.entries())if(f.pid===t||i===t){f.status="Terminated",typeof f.abort=="function"&&f.abort(),r=!0;break}let o=!1;if(e.shell.portTable&&(typeof e.shell.portTable.killProcess=="function"&&(o=e.shell.portTable.killProcess(t)||o),typeof e.shell.portTable.unregisterByPid=="function"&&(o=e.shell.portTable.unregisterByPid(t)||o),typeof e.shell.portTable.listServers=="function"&&typeof e.shell.portTable.unregisterServer=="function")){for(const i of e.shell.portTable.listServers())if(i.pid!==void 0&&String(i.pid)===String(t)){if(i.server&&typeof i.server.close=="function")try{i.server.close()}catch(f){_.debug("kill server.close failed.",f)}if(typeof i.stop=="function")try{i.stop()}catch(f){_.debug("kill server.stop failed.",f)}e.shell.portTable.unregisterServer(i.port),o=!0}}return r||o?{code:0,stdout:"",stderr:""}:{code:1,stdout:"",stderr:`kill: (${s}) - No such process
407
399
  `}},async dirname(n){const e=n[0]||".";return{code:0,stdout:j.dirname(e)+`
408
400
  `,stderr:""}},async basename(n){const e=n[0]||"",s=n[1]||"";return{code:0,stdout:j.basename(e,s)+`
409
401
  `,stderr:""}},async seq(n){let e=1,s=1,t=1;n.length===1?t=parseFloat(n[0])||1:n.length===2?(e=parseFloat(n[0])||1,t=parseFloat(n[1])||1):n.length>=3&&(e=parseFloat(n[0])||1,s=parseFloat(n[1])||1,t=parseFloat(n[2])||1);let r="";for(let o=e;s>0?o<=t:o>=t;o+=s)r+=`${o}
@@ -412,11 +404,11 @@ ${f} directories, ${d} files
412
404
  `,stderr:""};if(s==="help"||s==="--help"||s==="-h")return{code:0,stdout:`usage: git <command> [<args>]
413
405
 
414
406
  Common commands: init, clone, status, add, diff, commit, restore, reset, rm, branch, checkout, switch, merge, stash, tag, show, blame, remote, fetch, pull, push, log
415
- `,stderr:""};const t=e.shell.gitState;t.branches instanceof Set||(t.branches=new Set(Array.isArray(t.branches)?t.branches:[t.branch||"main"])),t.remotes||(t.remotes=t.remoteUrl?{origin:t.remoteUrl}:{});let r=j.normalize(t.repoRoot||e.cwd);const o=Xe(t,e.vfs,r),i=l=>{const a=e.resolvePath(l),c=r==="/"?"/":r+"/";return a===r?".":a.startsWith(c)?ee(a.slice(c.length),r):""};if(s!=="init"&&s!=="clone"){const l=!!(e.vfs&&typeof e.vfs.existsSync=="function"&&(e.vfs.existsSync(j.join(r,".git"))||e.vfs.existsSync(j.join(e.cwd,".git"))));if(!t.initialized&&!l)return{code:128,stdout:"",stderr:`fatal: not a git repository (or any of the parent directories): .git
416
- `};l&&!t.initialized&&(t.initialized=!0)}if(s==="clone"){let l=null;const a=[];for(let w=1;w<n.length;w++){const $=n[w];($==="-b"||$==="--branch")&&w+1<n.length?l=n[++w]:$.startsWith("--branch=")?l=$.slice(9):($==="--depth"||$==="-o"||$==="--origin")&&w+1<n.length?w++:$.startsWith("-")||a.push($)}const c=a[0],h=a[1];if(!c)return{code:128,stdout:"",stderr:`fatal: You must specify a repository to clone.
417
- `};const u=fe(c);if(!u)return{code:128,stdout:"",stderr:`fatal: repository '${c}' does not exist or is not a valid GitHub repository URL
418
- `};let p,g;h==="."?(p=e.cwd,g="."):h?(p=e.resolvePath(h),g=h):(p=j.join(e.cwd,u.repo),g=u.repo);const m=typeof e.onStdout=="function",S=w=>{m&&w&&e.onStdout(w)};S(`Cloning into '${g}'...
419
- `);let b=!1,v=-1;try{const w=await he(c,e.vfs,{targetDir:p,branch:l,fetchImpl:e.shell&&e.shell.options?e.shell.options.fetchImpl:void 0,signal:e.signal,onFile:E=>e.emitMutation("create",E),onProgress:E=>{if(E){if(E.phase==="downloading"&&!b&&typeof E.total=="number"&&E.total>0&&(b=!0,S(`remote: Enumerating objects: ${E.total}, done.
407
+ `,stderr:""};const t=e.shell.gitState;t.branches instanceof Set||(t.branches=new Set(Array.isArray(t.branches)?t.branches:[t.branch||"main"])),t.remotes||(t.remotes=t.remoteUrl?{origin:t.remoteUrl}:{});let r=j.normalize(t.repoRoot||e.cwd);const o=Ke(t,e.vfs,r),i=l=>{const c=e.resolvePath(l),d=r==="/"?"/":r+"/";return c===r?".":c.startsWith(d)?ee(c.slice(d.length),r):""};if(s!=="init"&&s!=="clone"){const l=!!(e.vfs&&typeof e.vfs.existsSync=="function"&&(e.vfs.existsSync(j.join(r,".git"))||e.vfs.existsSync(j.join(e.cwd,".git"))));if(!t.initialized&&!l)return{code:128,stdout:"",stderr:`fatal: not a git repository (or any of the parent directories): .git
408
+ `};l&&!t.initialized&&(t.initialized=!0)}if(s==="clone"){let l=null;const c=[];for(let w=1;w<n.length;w++){const $=n[w];($==="-b"||$==="--branch")&&w+1<n.length?l=n[++w]:$.startsWith("--branch=")?l=$.slice(9):($==="--depth"||$==="-o"||$==="--origin")&&w+1<n.length?w++:$.startsWith("-")||c.push($)}const d=c[0],u=c[1];if(!d)return{code:128,stdout:"",stderr:`fatal: You must specify a repository to clone.
409
+ `};const h=fe(d);if(!h)return{code:128,stdout:"",stderr:`fatal: repository '${d}' does not exist or is not a valid GitHub repository URL
410
+ `};let p,g;u==="."?(p=e.cwd,g="."):u?(p=e.resolvePath(u),g=u):(p=j.join(e.cwd,h.repo),g=h.repo);const m=typeof e.onStdout=="function",S=w=>{m&&w&&e.onStdout(w)};S(`Cloning into '${g}'...
411
+ `);let b=!1,v=-1;try{const w=await he(d,e.vfs,{targetDir:p,branch:l,fetchImpl:e.shell&&e.shell.options?e.shell.options.fetchImpl:void 0,signal:e.signal,onFile:E=>e.emitMutation("create",E),onProgress:E=>{if(E){if(E.phase==="downloading"&&!b&&typeof E.total=="number"&&E.total>0&&(b=!0,S(`remote: Enumerating objects: ${E.total}, done.
420
412
  `),S(`remote: Counting objects: 100% (${E.total}/${E.total}), done.
421
413
  `)),E.phase==="downloading"&&typeof E.total=="number"&&E.total>0&&typeof E.loaded=="number"&&E.loaded<E.total){const T=Math.min(100,Math.max(0,Math.floor(E.loaded/E.total*100)));T>=v+10&&(v=T,S(`Receiving objects: ${T}% (${E.loaded}/${E.total})
422
414
  `))}E.phase==="mounting"&&S(`Resolving deltas: 100% (${E.total||0}/${E.total||0}), done.
@@ -431,14 +423,14 @@ Receiving objects: 100% (${R}/${R}), ${I} KiB, done.
431
423
  `)?$:$+`
432
424
  `),{code:128,stdout:"",stderr:$.endsWith(`
433
425
  `)?$:$+`
434
- `}}}if(s==="init"){let l=t.branch||"main",a=!1,c=null;for(let m=1;m<n.length;m++){const S=n[m];(S==="-b"||S==="--initial-branch")&&m+1<n.length?l=n[++m]:S.startsWith("--initial-branch=")?l=S.slice(17)||l:S==="--empty-head"?a=!0:!S.startsWith("-")&&!c&&(c=S)}const h=j.normalize(c?e.resolvePath(c):e.cwd),u=j.join(h,".git"),p=!!t.initialized&&j.normalize(t.repoRoot||e.cwd)===h&&!a;if(G(e.vfs,u,e.emitMutation),(!p||!e.vfs.existsSync(j.join(u,"HEAD")))&&e.vfs.writeFileSync(j.join(u,"HEAD"),`ref: refs/heads/${l}
435
- `),e.vfs.writeFileSync(j.join(u,"config"),`[core]
426
+ `}}}if(s==="init"){let l=t.branch||"main",c=!1,d=null;for(let m=1;m<n.length;m++){const S=n[m];(S==="-b"||S==="--initial-branch")&&m+1<n.length?l=n[++m]:S.startsWith("--initial-branch=")?l=S.slice(17)||l:S==="--empty-head"?c=!0:!S.startsWith("-")&&!d&&(d=S)}const u=j.normalize(d?e.resolvePath(d):e.cwd),h=j.join(u,".git"),p=!!t.initialized&&j.normalize(t.repoRoot||e.cwd)===u&&!c;if(G(e.vfs,h,e.emitMutation),(!p||!e.vfs.existsSync(j.join(h,"HEAD")))&&e.vfs.writeFileSync(j.join(h,"HEAD"),`ref: refs/heads/${l}
427
+ `),e.vfs.writeFileSync(j.join(h,"config"),`[core]
436
428
  repositoryformatversion = 0
437
429
  filemode = true
438
430
  bare = false
439
- `),e.emitMutation("create",j.join(u,"HEAD")),p&&!oe(t))return t.branches.add(t.branch||l),{code:0,stdout:`Reinitialized existing Git repository in ${u}/
440
- `,stderr:""};const g={};if(!a){const m=L(e.vfs,h),S=Ke(e.shell,h);for(const[b,v]of Object.entries(m))Object.prototype.hasOwnProperty.call(S,b)&&S[b]===v&&(g[b]=v)}return t.initialized=!0,t.branch=l,t.branches.add(l),t.repoRoot=h,t.headSnapshot=g,t.headFiles=g,t.commits=[],t.headCommit="",o.clear(),{code:0,stdout:`${p?"Reinitialized existing":"Initialized empty"} Git repository in ${u}/
441
- `,stderr:""}}r=j.normalize(t.repoRoot||e.cwd);const f=je(),d=l=>{const a=l&&typeof l[".gitignore"]=="string"?l[".gitignore"]:t.headSnapshot&&typeof t.headSnapshot[".gitignore"]=="string"?t.headSnapshot[".gitignore"]:"";if(!a)return()=>!1;if(f&&typeof f.parseGitignoreRules=="function"&&typeof f.isIgnoredByRules=="function"){const c=f.parseGitignoreRules(a);return h=>f.isIgnoredByRules(h,c)}return()=>!1},y=()=>{if(f&&typeof f.saveBranchTip=="function"){f.saveBranchTip(t);return}(!t.branchHeads||typeof t.branchHeads!="object")&&(t.branchHeads={});const l=t.branch||"main";t.branchHeads[l]={headCommit:t.headCommit||"",headSnapshot:Object.assign({},t.headSnapshot||t.headFiles||{}),commits:Array.isArray(t.commits)?t.commits.map(a=>Object.assign({},a)):[]}};if(s==="status"){const l=n.includes("-s")||n.includes("--short")||n.includes("--porcelain"),a=L(e.vfs,r),c=t.headSnapshot||t.headFiles||{},h=d(a);Y(t,o,c);const u=oe(t),p=[],g=[],m=[],S=Array.from(o.keys()).sort();for(const v of S){const w=o.get(v),$=Object.prototype.hasOwnProperty.call(c,v),R=Object.prototype.hasOwnProperty.call(a,v);w===null?($&&p.push({status:"deleted",code:"D",path:v}),R&&!h(v)&&m.push(v)):(!$||u?p.push({status:"new file",code:"A",path:v}):w!==c[v]&&p.push({status:"modified",code:"M",path:v}),R?a[v]!==w&&g.push({status:"modified",code:"M",path:v}):g.push({status:"deleted",code:"D",path:v}))}for(const v of Object.keys(c).sort())o.has(v)||(Object.prototype.hasOwnProperty.call(a,v)?a[v]!==c[v]&&g.push({status:"modified",code:"M",path:v}):g.push({status:"deleted",code:"D",path:v}));for(const v of Object.keys(a).sort())!Object.prototype.hasOwnProperty.call(c,v)&&!o.has(v)&&(h(v)||m.push(v));if(g.sort((v,w)=>v.path.localeCompare(w.path)),m.sort(),l){const v=new Map;for(const $ of p)v.set($.path,{idx:$.code,wt:" "});for(const $ of g){const R=v.get($.path);R?R.wt=$.code:v.set($.path,{idx:" ",wt:$.code})}let w="";for(const $ of Array.from(v.keys()).sort()){const R=v.get($);w+=`${R.idx}${R.wt} ${$}
431
+ `),e.emitMutation("create",j.join(h,"HEAD")),p&&!oe(t))return t.branches.add(t.branch||l),{code:0,stdout:`Reinitialized existing Git repository in ${h}/
432
+ `,stderr:""};const g={};if(!c){const m=L(e.vfs,u),S=Ze(e.shell,u);for(const[b,v]of Object.entries(m))Object.prototype.hasOwnProperty.call(S,b)&&S[b]===v&&(g[b]=v)}return t.initialized=!0,t.branch=l,t.branches.add(l),t.repoRoot=u,t.headSnapshot=g,t.headFiles=g,t.commits=[],t.headCommit="",o.clear(),{code:0,stdout:`${p?"Reinitialized existing":"Initialized empty"} Git repository in ${h}/
433
+ `,stderr:""}}r=j.normalize(t.repoRoot||e.cwd);const f=je(),a=l=>{const c=l&&typeof l[".gitignore"]=="string"?l[".gitignore"]:t.headSnapshot&&typeof t.headSnapshot[".gitignore"]=="string"?t.headSnapshot[".gitignore"]:"";if(!c)return()=>!1;if(f&&typeof f.parseGitignoreRules=="function"&&typeof f.isIgnoredByRules=="function"){const d=f.parseGitignoreRules(c);return u=>f.isIgnoredByRules(u,d)}return()=>!1},y=()=>{if(f&&typeof f.saveBranchTip=="function"){f.saveBranchTip(t);return}(!t.branchHeads||typeof t.branchHeads!="object")&&(t.branchHeads={});const l=t.branch||"main";t.branchHeads[l]={headCommit:t.headCommit||"",headSnapshot:Object.assign({},t.headSnapshot||t.headFiles||{}),commits:Array.isArray(t.commits)?t.commits.map(c=>Object.assign({},c)):[]}};if(s==="status"){const l=n.includes("-s")||n.includes("--short")||n.includes("--porcelain"),c=L(e.vfs,r),d=t.headSnapshot||t.headFiles||{},u=a(c);Y(t,o,d);const h=oe(t),p=[],g=[],m=[],S=Array.from(o.keys()).sort();for(const v of S){const w=o.get(v),$=Object.prototype.hasOwnProperty.call(d,v),R=Object.prototype.hasOwnProperty.call(c,v);w===null?($&&p.push({status:"deleted",code:"D",path:v}),R&&!u(v)&&m.push(v)):(!$||h?p.push({status:"new file",code:"A",path:v}):w!==d[v]&&p.push({status:"modified",code:"M",path:v}),R?c[v]!==w&&g.push({status:"modified",code:"M",path:v}):g.push({status:"deleted",code:"D",path:v}))}for(const v of Object.keys(d).sort())o.has(v)||(Object.prototype.hasOwnProperty.call(c,v)?c[v]!==d[v]&&g.push({status:"modified",code:"M",path:v}):g.push({status:"deleted",code:"D",path:v}));for(const v of Object.keys(c).sort())!Object.prototype.hasOwnProperty.call(d,v)&&!o.has(v)&&(u(v)||m.push(v));if(g.sort((v,w)=>v.path.localeCompare(w.path)),m.sort(),l){const v=new Map;for(const $ of p)v.set($.path,{idx:$.code,wt:" "});for(const $ of g){const R=v.get($.path);R?R.wt=$.code:v.set($.path,{idx:" ",wt:$.code})}let w="";for(const $ of Array.from(v.keys()).sort()){const R=v.get($);w+=`${R.idx}${R.wt} ${$}
442
434
  `}for(const $ of m)w+=`?? ${$}
443
435
  `;return{code:0,stdout:w,stderr:""}}let b=`On branch ${t.branch}
444
436
  `;if(t.remoteUrl&&(b+=`Your branch is up to date with 'origin/${t.branch}'.
@@ -453,91 +445,91 @@ Receiving objects: 100% (${R}/${R}), ${I} KiB, done.
453
445
  `;for(const v of m)b+=` ${v}
454
446
  `;b+=`
455
447
  `}return p.length===0&&g.length===0&&m.length===0&&(b+=`nothing to commit, working tree clean
456
- `),{code:0,stdout:b,stderr:""}}if(s==="diff"){const l=n.includes("--staged")||n.includes("--cached"),c=n.slice(1).filter(b=>!b.startsWith("-")).map(i),h=c.length===0||c.includes("."),u=L(e.vfs,r),p=t.headSnapshot||t.headFiles||{};Y(t,o,p);const g=oe(t),m=Array.from(new Set([...Object.keys(p),...Object.keys(u),...Array.from(o.keys())])).sort();let S="";for(const b of m)if(!(!h&&!c.includes(b)))if(l){if(!o.has(b))continue;const v=o.get(b);if(!ue(t,b,v,p))continue;const w=!g&&Object.prototype.hasOwnProperty.call(p,b)?p[b]:"",$=v===null?"":String(v);if(w!==$){const R=de(`a/${b}`,`b/${b}`,w,$);R&&(S+=`diff --git a/${b} b/${b}
457
- ${R}`)}}else{if(!(Object.prototype.hasOwnProperty.call(p,b)||o.has(b)))continue;const w=o.has(b)?o.get(b):p[b],$=w==null?"":String(w),R=Object.prototype.hasOwnProperty.call(u,b)?u[b]:"";if($!==R){const I=de(`a/${b}`,`b/${b}`,$,R);I&&(S+=`diff --git a/${b} b/${b}
458
- ${I}`)}}return{code:0,stdout:S,stderr:""}}if(s==="add"){const l=n.slice(1),a=l.includes("-f")||l.includes("--force"),c=L(e.vfs,r),h=t.headSnapshot||t.headFiles||{},u=a?()=>!1:d(c),p=(g,m=!1)=>{const S=ee(g,r);if(!S)return;const b=Object.prototype.hasOwnProperty.call(c,S),v=Object.prototype.hasOwnProperty.call(h,S);!v&&!o.has(S)&&!m&&u(S)||(b?K(t,o,S,c[S],h):v?K(t,o,S,null,h):o.delete(S))};if(l.includes(".")||l.includes("-A")||l.includes("--all")||l.includes("-u")){const g=!l.includes("-u");for(const m of Object.keys(c)){const S=Object.prototype.hasOwnProperty.call(h,m);(!S&&g||S)&&p(m,!1)}for(const m of Object.keys(h))Object.prototype.hasOwnProperty.call(c,m)||p(m,!1);for(const m of Array.from(o.keys()))!Object.prototype.hasOwnProperty.call(c,m)&&!Object.prototype.hasOwnProperty.call(h,m)&&o.delete(m)}else for(const g of l){if(g.startsWith("-"))continue;const m=i(g);if(m)if(m==="."){for(const S of Object.keys(c))p(S,!1);for(const S of Object.keys(h))Object.prototype.hasOwnProperty.call(c,S)||p(S,!1);for(const S of Array.from(o.keys()))!Object.prototype.hasOwnProperty.call(c,S)&&!Object.prototype.hasOwnProperty.call(h,S)&&o.delete(S)}else{const S=m.replace(/\/+$/,"")+"/",b=Array.from(new Set([...Object.keys(c).filter(v=>v.startsWith(S)),...Object.keys(h).filter(v=>v.startsWith(S)),...Array.from(o.keys()).filter(v=>v.startsWith(S))]));if(b.length>0)for(const v of b)p(v,!1);else{if(!Object.prototype.hasOwnProperty.call(h,m)&&!o.has(m)&&u(m))return{code:1,stdout:"",stderr:`The following paths are ignored by one of your .gitignore files:
448
+ `),{code:0,stdout:b,stderr:""}}if(s==="diff"){const l=n.includes("--staged")||n.includes("--cached"),d=n.slice(1).filter(b=>!b.startsWith("-")).map(i),u=d.length===0||d.includes("."),h=L(e.vfs,r),p=t.headSnapshot||t.headFiles||{};Y(t,o,p);const g=oe(t),m=Array.from(new Set([...Object.keys(p),...Object.keys(h),...Array.from(o.keys())])).sort();let S="";for(const b of m)if(!(!u&&!d.includes(b)))if(l){if(!o.has(b))continue;const v=o.get(b);if(!ue(t,b,v,p))continue;const w=!g&&Object.prototype.hasOwnProperty.call(p,b)?p[b]:"",$=v===null?"":String(v);if(w!==$){const R=de(`a/${b}`,`b/${b}`,w,$);R&&(S+=`diff --git a/${b} b/${b}
449
+ ${R}`)}}else{if(!(Object.prototype.hasOwnProperty.call(p,b)||o.has(b)))continue;const w=o.has(b)?o.get(b):p[b],$=w==null?"":String(w),R=Object.prototype.hasOwnProperty.call(h,b)?h[b]:"";if($!==R){const I=de(`a/${b}`,`b/${b}`,$,R);I&&(S+=`diff --git a/${b} b/${b}
450
+ ${I}`)}}return{code:0,stdout:S,stderr:""}}if(s==="add"){const l=n.slice(1),c=l.includes("-f")||l.includes("--force"),d=L(e.vfs,r),u=t.headSnapshot||t.headFiles||{},h=c?()=>!1:a(d),p=(g,m=!1)=>{const S=ee(g,r);if(!S)return;const b=Object.prototype.hasOwnProperty.call(d,S),v=Object.prototype.hasOwnProperty.call(u,S);!v&&!o.has(S)&&!m&&h(S)||(b?K(t,o,S,d[S],u):v?K(t,o,S,null,u):o.delete(S))};if(l.includes(".")||l.includes("-A")||l.includes("--all")||l.includes("-u")){const g=!l.includes("-u");for(const m of Object.keys(d)){const S=Object.prototype.hasOwnProperty.call(u,m);(!S&&g||S)&&p(m,!1)}for(const m of Object.keys(u))Object.prototype.hasOwnProperty.call(d,m)||p(m,!1);for(const m of Array.from(o.keys()))!Object.prototype.hasOwnProperty.call(d,m)&&!Object.prototype.hasOwnProperty.call(u,m)&&o.delete(m)}else for(const g of l){if(g.startsWith("-"))continue;const m=i(g);if(m)if(m==="."){for(const S of Object.keys(d))p(S,!1);for(const S of Object.keys(u))Object.prototype.hasOwnProperty.call(d,S)||p(S,!1);for(const S of Array.from(o.keys()))!Object.prototype.hasOwnProperty.call(d,S)&&!Object.prototype.hasOwnProperty.call(u,S)&&o.delete(S)}else{const S=m.replace(/\/+$/,"")+"/",b=Array.from(new Set([...Object.keys(d).filter(v=>v.startsWith(S)),...Object.keys(u).filter(v=>v.startsWith(S)),...Array.from(o.keys()).filter(v=>v.startsWith(S))]));if(b.length>0)for(const v of b)p(v,!1);else{if(!Object.prototype.hasOwnProperty.call(u,m)&&!o.has(m)&&h(m))return{code:1,stdout:"",stderr:`The following paths are ignored by one of your .gitignore files:
459
451
  ${m}
460
452
  hint: Use -f if you really want to add them.
461
- `};p(m,!0)}}}return{code:0,stdout:"",stderr:""}}if(s==="commit"){const l=L(e.vfs,r),a=t.headSnapshot||t.headFiles||{};if(n.some(v=>v==="-a"||v==="--all"||v.startsWith("-")&&!v.startsWith("--")&&v!=="-m"&&v.includes("a")))for(const v of Object.keys(a))Object.prototype.hasOwnProperty.call(l,v)?K(t,o,v,l[v],a):K(t,o,v,null,a);if(Y(t,o,a),o.size===0)return{code:1,stdout:`On branch ${t.branch}
453
+ `};p(m,!0)}}}return{code:0,stdout:"",stderr:""}}if(s==="commit"){const l=L(e.vfs,r),c=t.headSnapshot||t.headFiles||{};if(n.some(v=>v==="-a"||v==="--all"||v.startsWith("-")&&!v.startsWith("--")&&v!=="-m"&&v.includes("a")))for(const v of Object.keys(c))Object.prototype.hasOwnProperty.call(l,v)?K(t,o,v,l[v],c):K(t,o,v,null,c);if(Y(t,o,c),o.size===0)return{code:1,stdout:`On branch ${t.branch}
462
454
  nothing to commit, working tree clean
463
- `,stderr:""};let h="Commit changes";const u=n.findIndex(v=>v==="-m"||v==="-am"||v==="-ma");u!==-1&&u+1<n.length&&(h=n[u+1]);const p=Object.assign({},a),g=[];for(const[v,w]of o.entries())g.push(`${v}:${w===null?"<DEL>":w}`),w===null?delete p[v]:p[v]=String(w);const m=Date.now(),S=re(`${t.headCommit||""}:${h}:${m}:${t.commits.length}:${g.join("|")}`),b=o.size;return t.headSnapshot=p,t.headFiles=p,t.commits.unshift({hash:S,author:`${e.env.USER||"CodeLab Developer"} <dev@codelab.internal>`,date:new Date(m).toUTCString(),timestamp:m,message:h,files:Object.assign({},p)}),t.headCommit=S,o.clear(),y(),{code:0,stdout:`[${t.branch} ${S}] ${h}
455
+ `,stderr:""};let u="Commit changes";const h=n.findIndex(v=>v==="-m"||v==="-am"||v==="-ma");h!==-1&&h+1<n.length&&(u=n[h+1]);const p=Object.assign({},c),g=[];for(const[v,w]of o.entries())g.push(`${v}:${w===null?"<DEL>":w}`),w===null?delete p[v]:p[v]=String(w);const m=Date.now(),S=re(`${t.headCommit||""}:${u}:${m}:${t.commits.length}:${g.join("|")}`),b=o.size;return t.headSnapshot=p,t.headFiles=p,t.commits.unshift({hash:S,author:`${e.env.USER||"CodeLab Developer"} <dev@codelab.internal>`,date:new Date(m).toUTCString(),timestamp:m,message:u,files:Object.assign({},p)}),t.headCommit=S,o.clear(),y(),{code:0,stdout:`[${t.branch} ${S}] ${u}
464
456
  ${b} file${b===1?"":"s"} changed
465
457
  `,stderr:""}}if(s==="branch"){y();const l=n.findIndex(p=>p==="-d"||p==="-D");if(l!==-1&&l+1<n.length){const p=n[l+1];return p===t.branch?{code:1,stdout:"",stderr:`error: Cannot delete branch '${p}' checked out
466
458
  `}:(t.branches.delete(p),t.branchHeads&&delete t.branchHeads[p],{code:0,stdout:`Deleted branch ${p}.
467
- `,stderr:""})}const a=n.findIndex(p=>p==="-m"||p==="-M");if(a!==-1&&a+1<n.length){const p=t.branch,g=n[a+1];return t.branches.delete(p),t.branch=g,t.branches.add(g),t.branchHeads&&t.branchHeads[p]&&(t.branchHeads[g]=t.branchHeads[p],delete t.branchHeads[p]),{code:0,stdout:"",stderr:""}}const c=n.slice(1).filter(p=>!p.startsWith("-"));if(c.length>0){for(const p of c)t.branches.add(p),t.branchHeads||(t.branchHeads={}),t.branchHeads[p]||(t.branchHeads[p]={headCommit:t.headCommit||"",headSnapshot:Object.assign({},t.headSnapshot||t.headFiles||{}),commits:Array.isArray(t.commits)?t.commits.map(g=>Object.assign({},g)):[]});return{code:0,stdout:"",stderr:""}}const h=n.includes("-a")||n.includes("--all");let u="";for(const p of t.branches)u+=p===t.branch?`* ${p}
459
+ `,stderr:""})}const c=n.findIndex(p=>p==="-m"||p==="-M");if(c!==-1&&c+1<n.length){const p=t.branch,g=n[c+1];return t.branches.delete(p),t.branch=g,t.branches.add(g),t.branchHeads&&t.branchHeads[p]&&(t.branchHeads[g]=t.branchHeads[p],delete t.branchHeads[p]),{code:0,stdout:"",stderr:""}}const d=n.slice(1).filter(p=>!p.startsWith("-"));if(d.length>0){for(const p of d)t.branches.add(p),t.branchHeads||(t.branchHeads={}),t.branchHeads[p]||(t.branchHeads[p]={headCommit:t.headCommit||"",headSnapshot:Object.assign({},t.headSnapshot||t.headFiles||{}),commits:Array.isArray(t.commits)?t.commits.map(g=>Object.assign({},g)):[]});return{code:0,stdout:"",stderr:""}}const u=n.includes("-a")||n.includes("--all");let h="";for(const p of t.branches)h+=p===t.branch?`* ${p}
468
460
  `:` ${p}
469
- `;return h&&t.remoteUrl&&(u+=` remotes/origin/${t.branch}
470
- `),{code:0,stdout:u,stderr:""}}if(s==="checkout"||s==="switch"){const l=n.includes("-f")||n.includes("--force"),a=n.findIndex(p=>p==="-b"||p==="-B"||p==="-c"||p==="-C");if(a!==-1&&a+1<n.length){const p=n[a+1];y(),t.branches.add(p),t.branch=p,y();const g=j.join(r,".git/HEAD");return e.vfs.existsSync(j.join(r,".git"))&&e.vfs.writeFileSync(g,`ref: refs/heads/${p}
461
+ `;return u&&t.remoteUrl&&(h+=` remotes/origin/${t.branch}
462
+ `),{code:0,stdout:h,stderr:""}}if(s==="checkout"||s==="switch"){const l=n.includes("-f")||n.includes("--force"),c=n.findIndex(p=>p==="-b"||p==="-B"||p==="-c"||p==="-C");if(c!==-1&&c+1<n.length){const p=n[c+1];y(),t.branches.add(p),t.branch=p,y();const g=j.join(r,".git/HEAD");return e.vfs.existsSync(j.join(r,".git"))&&e.vfs.writeFileSync(g,`ref: refs/heads/${p}
471
463
  `),{code:0,stdout:`Switched to a new branch '${p}'
472
- `,stderr:""}}const c=n.slice(1).find(p=>p!=="--"&&!p.startsWith("-"));if(!c)return{code:1,stdout:"",stderr:`error: branch or path required
473
- `};if(t.branches.has(c)&&!n.includes("--")){if(f&&typeof f.checkoutBranch=="function"){const p=f.checkoutBranch(e.shell,c,void 0,{force:l});if(!p.ok)return{code:1,stdout:"",stderr:(p.error||`error: cannot checkout '${c}'`)+`
474
- `};const g=j.join(r,".git/HEAD");return e.vfs.existsSync(j.join(r,".git"))&&e.vfs.writeFileSync(g,`ref: refs/heads/${c}
475
- `),{code:0,stdout:`Switched to branch '${c}'
476
- `,stderr:""}}return y(),t.branch=c,{code:0,stdout:`Switched to branch '${c}'
477
- `,stderr:""}}const h=i(c),u=t.headSnapshot||t.headFiles||{};if(h&&Object.prototype.hasOwnProperty.call(u,h)){const p=j.join(r,h);return G(e.vfs,j.dirname(p),e.emitMutation),e.vfs.writeFileSync(p,u[h]),e.emitMutation("change",p),{code:0,stdout:`Updated 1 path from the index
478
- `,stderr:""}}return{code:1,stdout:"",stderr:`error: pathspec '${c}' did not match any file(s) known to git
479
- `}}if(s==="restore"){const l=n.includes("--staged")||n.includes("-S"),a=n.includes("--worktree")||n.includes("-W")||!l,c=n.slice(1).filter(u=>!u.startsWith("-")&&u!=="--"),h=t.headSnapshot||t.headFiles||{};for(const u of c){const p=i(u);if(p){if(l)if(p===".")o.clear();else{const g=p.replace(/\/+$/,""),m=g+"/";o.delete(g);for(const S of Array.from(o.keys()))S.startsWith(m)&&o.delete(S)}if(a)if(p===".")for(const[g,m]of Object.entries(h)){const S=j.join(r,g);G(e.vfs,j.dirname(S),e.emitMutation),e.vfs.writeFileSync(S,m),e.emitMutation("change",S)}else{const g=p.replace(/\/+$/,""),m=g+"/",S=Object.keys(h).filter(b=>b.startsWith(m));if(S.length>0&&!Object.prototype.hasOwnProperty.call(h,g))for(const b of S){const v=!l&&o.has(b)&&o.get(b)!==null?o.get(b):h[b],w=j.join(r,b);G(e.vfs,j.dirname(w),e.emitMutation),e.vfs.writeFileSync(w,String(v)),e.emitMutation("change",w)}else{const b=!l&&o.has(g)&&o.get(g)!==null?o.get(g):Object.prototype.hasOwnProperty.call(h,g)?h[g]:void 0;if(b!==void 0){const v=j.join(r,g);G(e.vfs,j.dirname(v),e.emitMutation),e.vfs.writeFileSync(v,String(b)),e.emitMutation("change",v)}}}}}return{code:0,stdout:"",stderr:""}}if(s==="reset"){const l=n.includes("--hard"),a=n.includes("--soft"),c=l?"hard":a?"soft":"mixed",h=n.slice(1).filter(m=>!m.startsWith("-")&&m!=="--"),u=h[0];if(u&&(u==="HEAD"||/^HEAD(?:~\d*|\^+)$/i.test(u)||f&&typeof f.resolveCommitRef=="function"&&f.resolveCommitRef(t,u)!==null)&&h.length===1&&u!=="HEAD"&&f&&typeof f.resetToRef=="function"){const m=f.resetToRef(e.shell,u,c);return m.ok?{code:0,stdout:l&&m.commit?`HEAD is now at ${m.commit.hash} ${m.commit.message}
480
- `:"",stderr:""}:{code:128,stdout:"",stderr:(m.error||`fatal: ambiguous argument '${u}'`)+`
481
- `}}const g=h.filter(m=>m!=="HEAD");if(g.length>0&&!l&&!a){for(const m of g){const S=i(m);if(S)if(S===".")o.clear();else{const b=S.replace(/\/+$/,""),v=b+"/";o.delete(b);for(const w of Array.from(o.keys()))w.startsWith(v)&&o.delete(w)}}return{code:0,stdout:"",stderr:""}}if(a||o.clear(),l){const m=t.headSnapshot||t.headFiles||{},S=L(e.vfs,r);for(const b of Object.keys(S))if(!Object.prototype.hasOwnProperty.call(m,b)){const v=j.join(r,b);typeof e.vfs.rmSync=="function"?e.vfs.rmSync(v,{force:!0}):typeof e.vfs.unlinkSync=="function"&&e.vfs.existsSync(v)&&e.vfs.unlinkSync(v),e.emitMutation("delete",v)}for(const[b,v]of Object.entries(m)){const w=j.join(r,b);G(e.vfs,j.dirname(w),e.emitMutation),e.vfs.writeFileSync(w,v),e.emitMutation("change",w)}}return y(),{code:0,stdout:"",stderr:""}}if(s==="rm"){const l=n.includes("--cached"),a=n.some(g=>g==="-r"||g==="-rf"||g==="-fr"),c=n.slice(1).filter(g=>!g.startsWith("-")&&g!=="--"),h=t.headSnapshot||t.headFiles||{},u=L(e.vfs,r);if(c.length===0)return{code:128,stdout:"",stderr:`usage: git rm [--cached] [-r] [-f] <file>...
482
- `};const p=g=>{if(!g)return;const m=j.join(r,g);!l&&e.vfs.existsSync(m)&&(typeof e.vfs.rmSync=="function"?e.vfs.rmSync(m,{force:!0,recursive:a}):typeof e.vfs.unlinkSync=="function"&&e.vfs.unlinkSync(m),e.emitMutation("delete",m)),Object.prototype.hasOwnProperty.call(h,g)?o.set(g,null):o.delete(g)};for(const g of c){const m=i(g);if(!m)continue;if(m==="."){if(a){const v=Array.from(new Set([...Object.keys(h),...Object.keys(u),...Array.from(o.keys())]));for(const w of v)p(w)}continue}const S=m.replace(/\/+$/,"")+"/",b=a?Array.from(new Set([...Object.keys(h).filter(v=>v.startsWith(S)),...Object.keys(u).filter(v=>v.startsWith(S)),...Array.from(o.keys()).filter(v=>v.startsWith(S))])):[];if(b.length>0){for(const v of b)p(v);l||pe(e.vfs,j.join(r,m),e.emitMutation)}else{const v=j.join(r,m);if(!a&&e.vfs&&typeof e.vfs.existsSync=="function"&&e.vfs.existsSync(v)&&typeof e.vfs.statSync=="function")try{if(e.vfs.statSync(v).isDirectory())return{code:128,stdout:"",stderr:`fatal: not removing '${g}' recursively without -r
483
- `}}catch(w){N.debug("Failed statting path in git rm.",v,w)}p(m)}}return{code:0,stdout:"",stderr:""}}if(s==="remote"){const l=n[1];if(!l){const a=Object.keys(t.remotes);return{code:0,stdout:a.length>0?a.join(`
464
+ `,stderr:""}}const d=n.slice(1).find(p=>p!=="--"&&!p.startsWith("-"));if(!d)return{code:1,stdout:"",stderr:`error: branch or path required
465
+ `};if(t.branches.has(d)&&!n.includes("--")){if(f&&typeof f.checkoutBranch=="function"){const p=f.checkoutBranch(e.shell,d,void 0,{force:l});if(!p.ok)return{code:1,stdout:"",stderr:(p.error||`error: cannot checkout '${d}'`)+`
466
+ `};const g=j.join(r,".git/HEAD");return e.vfs.existsSync(j.join(r,".git"))&&e.vfs.writeFileSync(g,`ref: refs/heads/${d}
467
+ `),{code:0,stdout:`Switched to branch '${d}'
468
+ `,stderr:""}}return y(),t.branch=d,{code:0,stdout:`Switched to branch '${d}'
469
+ `,stderr:""}}const u=i(d),h=t.headSnapshot||t.headFiles||{};if(u&&Object.prototype.hasOwnProperty.call(h,u)){const p=j.join(r,u);return G(e.vfs,j.dirname(p),e.emitMutation),e.vfs.writeFileSync(p,h[u]),e.emitMutation("change",p),{code:0,stdout:`Updated 1 path from the index
470
+ `,stderr:""}}return{code:1,stdout:"",stderr:`error: pathspec '${d}' did not match any file(s) known to git
471
+ `}}if(s==="restore"){const l=n.includes("--staged")||n.includes("-S"),c=n.includes("--worktree")||n.includes("-W")||!l,d=n.slice(1).filter(h=>!h.startsWith("-")&&h!=="--"),u=t.headSnapshot||t.headFiles||{};for(const h of d){const p=i(h);if(p){if(l)if(p===".")o.clear();else{const g=p.replace(/\/+$/,""),m=g+"/";o.delete(g);for(const S of Array.from(o.keys()))S.startsWith(m)&&o.delete(S)}if(c)if(p===".")for(const[g,m]of Object.entries(u)){const S=j.join(r,g);G(e.vfs,j.dirname(S),e.emitMutation),e.vfs.writeFileSync(S,m),e.emitMutation("change",S)}else{const g=p.replace(/\/+$/,""),m=g+"/",S=Object.keys(u).filter(b=>b.startsWith(m));if(S.length>0&&!Object.prototype.hasOwnProperty.call(u,g))for(const b of S){const v=!l&&o.has(b)&&o.get(b)!==null?o.get(b):u[b],w=j.join(r,b);G(e.vfs,j.dirname(w),e.emitMutation),e.vfs.writeFileSync(w,String(v)),e.emitMutation("change",w)}else{const b=!l&&o.has(g)&&o.get(g)!==null?o.get(g):Object.prototype.hasOwnProperty.call(u,g)?u[g]:void 0;if(b!==void 0){const v=j.join(r,g);G(e.vfs,j.dirname(v),e.emitMutation),e.vfs.writeFileSync(v,String(b)),e.emitMutation("change",v)}}}}}return{code:0,stdout:"",stderr:""}}if(s==="reset"){const l=n.includes("--hard"),c=n.includes("--soft"),d=l?"hard":c?"soft":"mixed",u=n.slice(1).filter(m=>!m.startsWith("-")&&m!=="--"),h=u[0];if(h&&(h==="HEAD"||/^HEAD(?:~\d*|\^+)$/i.test(h)||f&&typeof f.resolveCommitRef=="function"&&f.resolveCommitRef(t,h)!==null)&&u.length===1&&h!=="HEAD"&&f&&typeof f.resetToRef=="function"){const m=f.resetToRef(e.shell,h,d);return m.ok?{code:0,stdout:l&&m.commit?`HEAD is now at ${m.commit.hash} ${m.commit.message}
472
+ `:"",stderr:""}:{code:128,stdout:"",stderr:(m.error||`fatal: ambiguous argument '${h}'`)+`
473
+ `}}const g=u.filter(m=>m!=="HEAD");if(g.length>0&&!l&&!c){for(const m of g){const S=i(m);if(S)if(S===".")o.clear();else{const b=S.replace(/\/+$/,""),v=b+"/";o.delete(b);for(const w of Array.from(o.keys()))w.startsWith(v)&&o.delete(w)}}return{code:0,stdout:"",stderr:""}}if(c||o.clear(),l){const m=t.headSnapshot||t.headFiles||{},S=L(e.vfs,r);for(const b of Object.keys(S))if(!Object.prototype.hasOwnProperty.call(m,b)){const v=j.join(r,b);typeof e.vfs.rmSync=="function"?e.vfs.rmSync(v,{force:!0}):typeof e.vfs.unlinkSync=="function"&&e.vfs.existsSync(v)&&e.vfs.unlinkSync(v),e.emitMutation("delete",v)}for(const[b,v]of Object.entries(m)){const w=j.join(r,b);G(e.vfs,j.dirname(w),e.emitMutation),e.vfs.writeFileSync(w,v),e.emitMutation("change",w)}}return y(),{code:0,stdout:"",stderr:""}}if(s==="rm"){const l=n.includes("--cached"),c=n.some(g=>g==="-r"||g==="-rf"||g==="-fr"),d=n.slice(1).filter(g=>!g.startsWith("-")&&g!=="--"),u=t.headSnapshot||t.headFiles||{},h=L(e.vfs,r);if(d.length===0)return{code:128,stdout:"",stderr:`usage: git rm [--cached] [-r] [-f] <file>...
474
+ `};const p=g=>{if(!g)return;const m=j.join(r,g);!l&&e.vfs.existsSync(m)&&(typeof e.vfs.rmSync=="function"?e.vfs.rmSync(m,{force:!0,recursive:c}):typeof e.vfs.unlinkSync=="function"&&e.vfs.unlinkSync(m),e.emitMutation("delete",m)),Object.prototype.hasOwnProperty.call(u,g)?o.set(g,null):o.delete(g)};for(const g of d){const m=i(g);if(!m)continue;if(m==="."){if(c){const v=Array.from(new Set([...Object.keys(u),...Object.keys(h),...Array.from(o.keys())]));for(const w of v)p(w)}continue}const S=m.replace(/\/+$/,"")+"/",b=c?Array.from(new Set([...Object.keys(u).filter(v=>v.startsWith(S)),...Object.keys(h).filter(v=>v.startsWith(S)),...Array.from(o.keys()).filter(v=>v.startsWith(S))])):[];if(b.length>0){for(const v of b)p(v);l||pe(e.vfs,j.join(r,m),e.emitMutation)}else{const v=j.join(r,m);if(!c&&e.vfs&&typeof e.vfs.existsSync=="function"&&e.vfs.existsSync(v)&&typeof e.vfs.statSync=="function")try{if(e.vfs.statSync(v).isDirectory())return{code:128,stdout:"",stderr:`fatal: not removing '${g}' recursively without -r
475
+ `}}catch(w){_.debug("Failed statting path in git rm.",v,w)}p(m)}}return{code:0,stdout:"",stderr:""}}if(s==="remote"){const l=n[1];if(!l){const c=Object.keys(t.remotes);return{code:0,stdout:c.length>0?c.join(`
484
476
  `)+`
485
- `:"",stderr:""}}if(l==="-v"||l==="--verbose"){let a="";for(const[c,h]of Object.entries(t.remotes))a+=`${c} ${h} (fetch)
486
- ${c} ${h} (push)
487
- `;return{code:0,stdout:a,stderr:""}}if((l==="add"||l==="set-url")&&n[2]&&n[3])return t.remotes[n[2]]=n[3],n[2]==="origin"&&(t.remoteUrl=n[3]),{code:0,stdout:"",stderr:""};if(l==="get-url"&&n[2]){const a=t.remotes[n[2]];return a?{code:0,stdout:`${a}
477
+ `:"",stderr:""}}if(l==="-v"||l==="--verbose"){let c="";for(const[d,u]of Object.entries(t.remotes))c+=`${d} ${u} (fetch)
478
+ ${d} ${u} (push)
479
+ `;return{code:0,stdout:c,stderr:""}}if((l==="add"||l==="set-url")&&n[2]&&n[3])return t.remotes[n[2]]=n[3],n[2]==="origin"&&(t.remoteUrl=n[3]),{code:0,stdout:"",stderr:""};if(l==="get-url"&&n[2]){const c=t.remotes[n[2]];return c?{code:0,stdout:`${c}
488
480
  `,stderr:""}:{code:2,stdout:"",stderr:`fatal: No such remote '${n[2]}'
489
481
  `}}return(l==="remove"||l==="rm")&&n[2]?(delete t.remotes[n[2]],n[2]==="origin"&&(t.remoteUrl=null),{code:0,stdout:"",stderr:""}):{code:0,stdout:"",stderr:""}}if(s==="pull"||s==="fetch"){const l=t.remoteUrl||t.remotes.origin;if(!l)return{code:1,stdout:"",stderr:`fatal: No remote repository specified.
490
482
  `};if(s==="fetch")return{code:0,stdout:`From ${l.replace(/\.git$/,"")}
491
483
  * branch ${t.branch} -> FETCH_HEAD
492
- `,stderr:""};try{const a=await he(l,e.vfs,{targetDir:r,branch:t.branch,fetchImpl:e.shell&&e.shell.options?e.shell.options.fetchImpl:void 0,signal:e.signal,onFile:h=>e.emitMutation("change",h)}),c=Object.assign({},a.headSnapshot);return t.headSnapshot=c,t.headFiles=c,{code:0,stdout:`From ${l.replace(/\.git$/,"")}
493
- * branch ${a.branch} -> FETCH_HEAD
484
+ `,stderr:""};try{const c=await he(l,e.vfs,{targetDir:r,branch:t.branch,fetchImpl:e.shell&&e.shell.options?e.shell.options.fetchImpl:void 0,signal:e.signal,onFile:u=>e.emitMutation("change",u)}),d=Object.assign({},c.headSnapshot);return t.headSnapshot=d,t.headFiles=d,{code:0,stdout:`From ${l.replace(/\.git$/,"")}
485
+ * branch ${c.branch} -> FETCH_HEAD
494
486
  Already up to date.
495
- `,stderr:""}}catch(a){if(e.signal&&e.signal.aborted)return{code:130,stdout:"",stderr:"",aborted:!0};const c=a&&a.message?a.message:String(a);return{code:1,stdout:"",stderr:c.endsWith(`
496
- `)?c:c+`
497
- `}}}if(s==="stash"){Array.isArray(t.stashes)||(t.stashes=[]);const l=n[1]&&!n[1].startsWith("-")?n[1]:"push";if(l==="list"){const a=t.stashes.map((c,h)=>`stash@{${h}}: ${c.message}`);return{code:0,stdout:a.length?a.join(`
487
+ `,stderr:""}}catch(c){if(e.signal&&e.signal.aborted)return{code:130,stdout:"",stderr:"",aborted:!0};const d=c&&c.message?c.message:String(c);return{code:1,stdout:"",stderr:d.endsWith(`
488
+ `)?d:d+`
489
+ `}}}if(s==="stash"){Array.isArray(t.stashes)||(t.stashes=[]);const l=n[1]&&!n[1].startsWith("-")?n[1]:"push";if(l==="list"){const c=t.stashes.map((d,u)=>`stash@{${u}}: ${d.message}`);return{code:0,stdout:c.length?c.join(`
498
490
  `)+`
499
- `:"",stderr:""}}if(l==="clear")return t.stashes=[],{code:0,stdout:"",stderr:""};if(l==="drop"){const a=(n[2]||"stash@{0}").match(/(\d+)/),c=a?parseInt(a[1],10):0;return c<0||c>=t.stashes.length?{code:1,stdout:"",stderr:`error: stash@{${c}} is not a valid reference
500
- `}:(t.stashes.splice(c,1),{code:0,stdout:`Dropped stash@{${c}}
501
- `,stderr:""})}if(l==="pop"||l==="apply"){const a=(n[2]||"stash@{0}").match(/(\d+)/),c=a?parseInt(a[1],10):0;if(f&&typeof f.stashApply=="function"){const h=f.stashApply(e.shell,c,l==="pop");return h.ok?{code:0,stdout:`Restored working directory from stash@{${c}}
502
- `,stderr:""}:{code:1,stdout:"",stderr:(h.error||"No stash entries found.")+`
491
+ `:"",stderr:""}}if(l==="clear")return t.stashes=[],{code:0,stdout:"",stderr:""};if(l==="drop"){const c=(n[2]||"stash@{0}").match(/(\d+)/),d=c?parseInt(c[1],10):0;return d<0||d>=t.stashes.length?{code:1,stdout:"",stderr:`error: stash@{${d}} is not a valid reference
492
+ `}:(t.stashes.splice(d,1),{code:0,stdout:`Dropped stash@{${d}}
493
+ `,stderr:""})}if(l==="pop"||l==="apply"){const c=(n[2]||"stash@{0}").match(/(\d+)/),d=c?parseInt(c[1],10):0;if(f&&typeof f.stashApply=="function"){const u=f.stashApply(e.shell,d,l==="pop");return u.ok?{code:0,stdout:`Restored working directory from stash@{${d}}
494
+ `,stderr:""}:{code:1,stdout:"",stderr:(u.error||"No stash entries found.")+`
503
495
  `}}return{code:1,stdout:"",stderr:`No stash entries found.
504
- `}}if(l==="push"||l==="save"){let a;const c=n.findIndex(u=>u==="-m"||u==="--message");c!==-1&&n[c+1]?a=n[c+1]:l==="save"&&n[2]&&(a=n.slice(2).join(" "));const h=n.includes("-u")||n.includes("--include-untracked");if(f&&typeof f.stashPush=="function"){const u=f.stashPush(e.shell,a,h);return u.ok?{code:0,stdout:(u.label||"No local changes to save")+`
505
- `,stderr:""}:{code:1,stdout:"",stderr:(u.label||"not a git repository")+`
496
+ `}}if(l==="push"||l==="save"){let c;const d=n.findIndex(h=>h==="-m"||h==="--message");d!==-1&&n[d+1]?c=n[d+1]:l==="save"&&n[2]&&(c=n.slice(2).join(" "));const u=n.includes("-u")||n.includes("--include-untracked");if(f&&typeof f.stashPush=="function"){const h=f.stashPush(e.shell,c,u);return h.ok?{code:0,stdout:(h.label||"No local changes to save")+`
497
+ `,stderr:""}:{code:1,stdout:"",stderr:(h.label||"not a git repository")+`
506
498
  `}}}return{code:1,stdout:"",stderr:`git stash: unknown subcommand '${l}'
507
- `}}if(s==="merge"){const l=n.includes("--no-ff"),a=n.slice(1).find(c=>!c.startsWith("-"));if(!a)return{code:1,stdout:"",stderr:`fatal: No branch specified to merge.
508
- `};if(f&&typeof f.mergeBranch=="function"){const c=f.mergeBranch(e.shell,a,void 0,{noFf:l});return!c.ok&&(!c.conflicts||c.conflicts.length===0)?{code:1,stdout:"",stderr:(c.error||`merge: ${a} - not something we can merge`)+`
509
- `}:c.conflicts&&c.conflicts.length>0?{code:1,stdout:c.conflicts.map(h=>`CONFLICT (content): Merge conflict in ${h}`).join(`
499
+ `}}if(s==="merge"){const l=n.includes("--no-ff"),c=n.slice(1).find(d=>!d.startsWith("-"));if(!c)return{code:1,stdout:"",stderr:`fatal: No branch specified to merge.
500
+ `};if(f&&typeof f.mergeBranch=="function"){const d=f.mergeBranch(e.shell,c,void 0,{noFf:l});return!d.ok&&(!d.conflicts||d.conflicts.length===0)?{code:1,stdout:"",stderr:(d.error||`merge: ${c} - not something we can merge`)+`
501
+ `}:d.conflicts&&d.conflicts.length>0?{code:1,stdout:d.conflicts.map(u=>`CONFLICT (content): Merge conflict in ${u}`).join(`
510
502
  `)+`
511
503
  Automatic merge failed; fix conflicts and then commit the result.
512
- `,stderr:""}:c.fastForward&&c.commit?{code:0,stdout:`Updating ..${c.commit.hash}
504
+ `,stderr:""}:d.fastForward&&d.commit?{code:0,stdout:`Updating ..${d.commit.hash}
513
505
  Fast-forward
514
- `,stderr:""}:c.commit?{code:0,stdout:`Merge made by the 'ort' strategy.
515
- [${t.branch} ${c.commit.hash}] ${c.commit.message}
506
+ `,stderr:""}:d.commit?{code:0,stdout:`Merge made by the 'ort' strategy.
507
+ [${t.branch} ${d.commit.hash}] ${d.commit.message}
516
508
  `,stderr:""}:{code:0,stdout:`Already up to date.
517
509
  `,stderr:""}}return{code:1,stdout:"",stderr:`git merge: SCM module unavailable
518
510
  `}}if(s==="tag"){if((!t.tags||typeof t.tags!="object")&&(t.tags={}),n[1]==="-d"&&n[2])return t.tags[n[2]]?(delete t.tags[n[2]],{code:0,stdout:`Deleted tag '${n[2]}'
519
511
  `,stderr:""}):{code:1,stdout:"",stderr:`error: tag '${n[2]}' not found.
520
- `};const l=n.slice(1).find(a=>!a.startsWith("-"));if(!l){const a=Object.keys(t.tags).sort();return{code:0,stdout:a.length?a.join(`
512
+ `};const l=n.slice(1).find(c=>!c.startsWith("-"));if(!l){const c=Object.keys(t.tags).sort();return{code:0,stdout:c.length?c.join(`
521
513
  `)+`
522
514
  `:"",stderr:""}}return t.headCommit?(t.tags[l]=t.headCommit,{code:0,stdout:"",stderr:""}):{code:128,stdout:"",stderr:`fatal: Failed to resolve 'HEAD' as a valid ref.
523
- `}}if(s==="show"){const l=n.slice(1).find(a=>!a.startsWith("-"))||"HEAD";if(f&&typeof f.showCommit=="function"){const a=f.showCommit(t,l);return a?{code:0,stdout:a,stderr:""}:{code:128,stdout:"",stderr:`fatal: bad object ${l}
515
+ `}}if(s==="show"){const l=n.slice(1).find(c=>!c.startsWith("-"))||"HEAD";if(f&&typeof f.showCommit=="function"){const c=f.showCommit(t,l);return c?{code:0,stdout:c,stderr:""}:{code:128,stdout:"",stderr:`fatal: bad object ${l}
524
516
  `}}return{code:128,stdout:"",stderr:`fatal: bad object ${l}
525
- `}}if(s==="blame"){const l=n.slice(1).find(h=>!h.startsWith("-"));if(!l)return{code:128,stdout:"",stderr:`usage: git blame <file>
526
- `};const a=i(l),c=L(e.vfs,r);if(f&&typeof f.blameFile=="function"){const h=f.blameFile(t,a,c);return!h&&!Object.prototype.hasOwnProperty.call(c,a)?{code:128,stdout:"",stderr:`fatal: no such path '${l}' in HEAD
527
- `}:{code:0,stdout:h,stderr:""}}return{code:128,stdout:"",stderr:`fatal: no such path '${l}' in HEAD
517
+ `}}if(s==="blame"){const l=n.slice(1).find(u=>!u.startsWith("-"));if(!l)return{code:128,stdout:"",stderr:`usage: git blame <file>
518
+ `};const c=i(l),d=L(e.vfs,r);if(f&&typeof f.blameFile=="function"){const u=f.blameFile(t,c,d);return!u&&!Object.prototype.hasOwnProperty.call(d,c)?{code:128,stdout:"",stderr:`fatal: no such path '${l}' in HEAD
519
+ `}:{code:0,stdout:u,stderr:""}}return{code:128,stdout:"",stderr:`fatal: no such path '${l}' in HEAD
528
520
  `}}if(s==="push"){const l=t.remoteUrl||t.remotes&&t.remotes.origin;return l?{code:128,stdout:"",stderr:`fatal: Authentication required to push to '${l}' from browser sandbox.
529
521
  `}:{code:128,stdout:"",stderr:`fatal: No configured push destination.
530
522
  Either specify the URL from the command-line or configure a remote repository using
531
523
 
532
524
  git remote add <name> <url>
533
- `}}if(s==="log"){const l=n.includes("--oneline");let a=t.commits.length;for(let h=1;h<n.length;h++)n[h]==="-n"&&n[h+1]?a=parseInt(n[++h],10)||a:/^-\d+$/.test(n[h])&&(a=parseInt(n[h].slice(1),10)||a);let c="";for(const h of t.commits.slice(0,a))if(l)c+=`${h.hash} ${h.message}
534
- `;else{const u=h.author||"CodeLab Developer <dev@codelab.internal>",p=h.date||(h.timestamp?new Date(h.timestamp).toUTCString():new Date(0).toUTCString());c+=`commit ${h.hash}
535
- `,c+=`Author: ${u}
536
- `,c+=`Date: ${p}
525
+ `}}if(s==="log"){const l=n.includes("--oneline");let c=t.commits.length;for(let u=1;u<n.length;u++)n[u]==="-n"&&n[u+1]?c=parseInt(n[++u],10)||c:/^-\d+$/.test(n[u])&&(c=parseInt(n[u].slice(1),10)||c);let d="";for(const u of t.commits.slice(0,c))if(l)d+=`${u.hash} ${u.message}
526
+ `;else{const h=u.author||"CodeLab Developer <dev@codelab.internal>",p=u.date||(u.timestamp?new Date(u.timestamp).toUTCString():new Date(0).toUTCString());d+=`commit ${u.hash}
527
+ `,d+=`Author: ${h}
528
+ `,d+=`Date: ${p}
537
529
 
538
- `,c+=` ${h.message}
530
+ `,d+=` ${u.message}
539
531
 
540
- `}return{code:0,stdout:c,stderr:""}}return{code:1,stdout:"",stderr:`git: '${s}' is not a git command. See 'git --help'.
532
+ `}return{code:0,stdout:d,stderr:""}}return{code:1,stdout:"",stderr:`git: '${s}' is not a git command. See 'git --help'.
541
533
  `}},async help(n,e){let s=`CodeLab POSIX Shell & UNIX Coreutils (Pure-JS Engine)
542
534
 
543
535
  `;return s+=`Filesystem:
@@ -587,13 +579,13 @@ Either specify the URL from the command-line or configure a remote repository us
587
579
  `};if(n[0]==="-v"||n[0]==="--version")return{code:0,stdout:`v22.0.0
588
580
  `,stderr:""};if(n.length===0||n[0]==="-i"||n[0]==="--interactive"){const o=(typeof e.onRequestStdin=="function"?e.onRequestStdin:null)||(e.shell&&e.shell.options&&typeof e.shell.options.onRequestStdin=="function"?e.shell.options.onRequestStdin:null);if(e.stdin&&!o){const i=await q({mode:"repl",replCode:e.stdin,printReplResult:!0,stdin:"",env:e.env,cwd:e.cwd,vfs:e.vfs,pid:e.pid,isBackground:e.isBackground,onStdout:e.onStdout,onStderr:e.onStderr,signal:e.signal},e);return{code:i.ok?0:i.exitCode||1,stdout:i.stdout,stderr:i.stderr}}if(o&&!e.stdin){const i=`Welcome to Node.js v22.0.0.
589
581
  Type ".help" for more information.
590
- `;let f=i,d="";e.onStdout&&e.onStdout(i);const y="node_repl_"+Date.now()+"_"+Math.random().toString(36).slice(2,7),l=U();try{for(;!(e.signal&&e.signal.aborted);){const a=await o("> ");if(a==null)break;const c=String(a).trim();if(c===".exit")break;if(c===".help"){const u=`.break Sometimes you get stuck, this gets you out
582
+ `;let f=i,a="";e.onStdout&&e.onStdout(i);const y="node_repl_"+Date.now()+"_"+Math.random().toString(36).slice(2,7),l=U();try{for(;!(e.signal&&e.signal.aborted);){const c=await o("> ");if(c==null)break;const d=String(c).trim();if(d===".exit")break;if(d===".help"){const h=`.break Sometimes you get stuck, this gets you out
591
583
  .clear Break, and also clear the local context
592
584
  .exit Exit the REPL
593
585
  .help Print this help message
594
- `;f+=u,e.onStdout&&e.onStdout(u);continue}if(c===".clear"||c===".break"){c===".clear"&&l&&typeof l.clearReplSession=="function"&&l.clearReplSession(y);continue}if(!c)continue;const h=await Oe({mode:"repl",replSessionId:y,replCode:String(a),printReplResult:!0,env:e.env,cwd:e.cwd,vfs:e.vfs,activePortTable:e.shell?e.shell.portTable:null,pid:e.pid,onRequestStdin:o,onStdout:u=>{f+=u,e.onStdout&&e.onStdout(u)},onStderr:u=>{d+=u,e.onStderr&&e.onStderr(u)},signal:e.signal})}}finally{l&&typeof l.clearReplSession=="function"&&l.clearReplSession(y)}return{code:0,stdout:f,stderr:d,alreadyStreamed:!0}}return{code:0,stdout:`Welcome to Node.js v22.0.0.
586
+ `;f+=h,e.onStdout&&e.onStdout(h);continue}if(d===".clear"||d===".break"){d===".clear"&&l&&typeof l.clearReplSession=="function"&&l.clearReplSession(y);continue}if(!d)continue;const u=await Oe({mode:"repl",replSessionId:y,replCode:String(c),printReplResult:!0,env:e.env,cwd:e.cwd,vfs:e.vfs,activePortTable:e.shell?e.shell.portTable:null,pid:e.pid,onRequestStdin:o,onStdout:h=>{f+=h,e.onStdout&&e.onStdout(h)},onStderr:h=>{a+=h,e.onStderr&&e.onStderr(h)},signal:e.signal})}}finally{l&&typeof l.clearReplSession=="function"&&l.clearReplSession(y)}return{code:0,stdout:f,stderr:a,alreadyStreamed:!0}}return{code:0,stdout:`Welcome to Node.js v22.0.0.
595
587
  Type ".help" for more information.
596
- `,stderr:""}}if(n[0]==="-e"||n[0]==="--eval"){const o=n[1]||"",i=await q({mode:"repl",replCode:o,printReplResult:!1,stdin:e.stdin||"",env:e.env,cwd:e.cwd,vfs:e.vfs,pid:e.pid,isBackground:e.isBackground,onStdout:e.onStdout,onStderr:e.onStderr,signal:e.signal},e);return{code:i.ok?0:i.exitCode||1,stdout:i.stdout,stderr:i.stderr}}if(n[0]==="-p"||n[0]==="--print"){const o=n[1]||"",i=await q({mode:"repl",replCode:o,printReplResult:!0,stdin:e.stdin||"",env:e.env,cwd:e.cwd,vfs:e.vfs,pid:e.pid,isBackground:e.isBackground,onStdout:e.onStdout,onStderr:e.onStderr,signal:e.signal},e);return{code:i.ok?0:i.exitCode||1,stdout:i.stdout,stderr:i.stderr}}if(n[0]==="--test"){const o=n[1]?e.resolvePath(n[1]):null;let i=[];if(o)i.push(o);else{const l=a=>{if(e.vfs.existsSync(a))for(const c of e.vfs.readdirSync(a)){const h=j.join(a,c);e.vfs.statSync(h).isDirectory()&&c!=="node_modules"&&c!==".git"?l(h):(c.endsWith(".test.js")||c.endsWith(".test.ts")||c==="test.js")&&i.push(h)}};l(e.cwd)}let f="",d="",y=!0;for(const l of i){const a=await q({mode:"test",entry:l,stdin:e.stdin||"",env:e.env,cwd:e.cwd,vfs:e.vfs,pid:e.pid,isBackground:e.isBackground,onStdout:e.onStdout,onStderr:e.onStderr,signal:e.signal},e);f+=a.stdout,d+=a.stderr,a.ok||(y=!1)}return{code:y?0:1,stdout:f,stderr:d}}const s=e.resolvePath(n[0]);if(!e.vfs.existsSync(s))return{code:1,stdout:"",stderr:`node: cannot find module '${n[0]}'
588
+ `,stderr:""}}if(n[0]==="-e"||n[0]==="--eval"){const o=n[1]||"",i=await q({mode:"repl",replCode:o,printReplResult:!1,stdin:e.stdin||"",env:e.env,cwd:e.cwd,vfs:e.vfs,pid:e.pid,isBackground:e.isBackground,onStdout:e.onStdout,onStderr:e.onStderr,signal:e.signal},e);return{code:i.ok?0:i.exitCode||1,stdout:i.stdout,stderr:i.stderr}}if(n[0]==="-p"||n[0]==="--print"){const o=n[1]||"",i=await q({mode:"repl",replCode:o,printReplResult:!0,stdin:e.stdin||"",env:e.env,cwd:e.cwd,vfs:e.vfs,pid:e.pid,isBackground:e.isBackground,onStdout:e.onStdout,onStderr:e.onStderr,signal:e.signal},e);return{code:i.ok?0:i.exitCode||1,stdout:i.stdout,stderr:i.stderr}}if(n[0]==="--test"){const o=n[1]?e.resolvePath(n[1]):null;let i=[];if(o)i.push(o);else{const l=c=>{if(e.vfs.existsSync(c))for(const d of e.vfs.readdirSync(c)){const u=j.join(c,d);e.vfs.statSync(u).isDirectory()&&d!=="node_modules"&&d!==".git"?l(u):(d.endsWith(".test.js")||d.endsWith(".test.ts")||d==="test.js")&&i.push(u)}};l(e.cwd)}let f="",a="",y=!0;for(const l of i){const c=await q({mode:"test",entry:l,stdin:e.stdin||"",env:e.env,cwd:e.cwd,vfs:e.vfs,pid:e.pid,isBackground:e.isBackground,onStdout:e.onStdout,onStderr:e.onStderr,signal:e.signal},e);f+=c.stdout,a+=c.stderr,c.ok||(y=!1)}return{code:y?0:1,stdout:f,stderr:a}}const s=e.resolvePath(n[0]);if(!e.vfs.existsSync(s))return{code:1,stdout:"",stderr:`node: cannot find module '${n[0]}'
597
589
  `};const t=n.slice(1),r=await q({mode:"run",entry:s,argv:["node",s,...t],stdin:e.stdin||"",env:e.env,cwd:e.cwd,vfs:e.vfs,pid:e.pid,isBackground:e.isBackground,onStdout:e.onStdout,onStderr:e.onStderr,signal:e.signal},e);return{code:r.ok?0:r.exitCode||1,stdout:r.stdout,stderr:r.stderr}},async"g++"(n,e){if(n.includes("--version")||n.includes("-v"))return{code:0,stdout:`clang version 18.1.8 (Target: wasm32-unknown-wasi)
598
590
  Target: wasm32-unknown-wasi
599
591
  Thread model: posix
@@ -604,21 +596,21 @@ Options:
604
596
  -O0, -O1, -O2, -O3 Optimization level
605
597
  -o <file> Write output to <file> (default: a.out)
606
598
  -I <dir> Add directory to include search path
607
- `,stderr:""};const s=[],t=[];let r=j.join(e.cwd,"a.out"),o="c++20",i="-O2";for(let a=0;a<n.length;a++){const c=n[a];if(c==="-o"&&a+1<n.length)r=e.resolvePath(n[++a]);else if(c.startsWith("-o")&&c.length>2)r=e.resolvePath(c.slice(2));else if(c.startsWith("-std=")){const h=c.slice(5);h==="c++17"||h==="gnu++17"?o="c++17":h==="c++23"||h==="c++2b"||h==="gnu++23"?o="c++23":o="c++20"}else c==="-O0"||c==="-O1"||c==="-O2"||c==="-O3"?i=c:c.startsWith("-I")||c.startsWith("-D")||c.startsWith("-W")?t.push(c):c.startsWith("-")||s.push(e.resolvePath(c))}if(s.length===0)return{code:1,stdout:"",stderr:`g++: fatal error: no input files
599
+ `,stderr:""};const s=[],t=[];let r=j.join(e.cwd,"a.out"),o="c++20",i="-O2";for(let c=0;c<n.length;c++){const d=n[c];if(d==="-o"&&c+1<n.length)r=e.resolvePath(n[++c]);else if(d.startsWith("-o")&&d.length>2)r=e.resolvePath(d.slice(2));else if(d.startsWith("-std=")){const u=d.slice(5);u==="c++17"||u==="gnu++17"?o="c++17":u==="c++23"||u==="c++2b"||u==="gnu++23"?o="c++23":o="c++20"}else d==="-O0"||d==="-O1"||d==="-O2"||d==="-O3"?i=d:d.startsWith("-I")||d.startsWith("-D")||d.startsWith("-W")?t.push(d):d.startsWith("-")||s.push(e.resolvePath(d))}if(s.length===0)return{code:1,stdout:"",stderr:`g++: fatal error: no input files
608
600
  compilation terminated.
609
- `};for(const a of s)if(!e.vfs.existsSync(a))return{code:1,stdout:"",stderr:`g++: error: ${a}: No such file or directory
601
+ `};for(const c of s)if(!e.vfs.existsSync(c))return{code:1,stdout:"",stderr:`g++: error: ${c}: No such file or directory
610
602
  `};const f=e.shell&&e.shell.options&&e.shell.options.cppCompiler||typeof globalThis<"u"&&globalThis.__codelabCppCompiler||typeof window<"u"&&window.__codelabCppCompiler;if(typeof f!="function")return{code:1,stdout:"",stderr:`g++: C++ toolchain is not enabled. Enable cppExtension from "@innovatorved/code-lab/extensions/cpp" to compile C++ files.
611
- `};let d="",y="";const l=await f({entry:s[0],sourceFiles:s,outputPath:r,std:o,optLevel:i,extraFlags:t,vfs:e.vfs,onStdout:a=>{d+=a,e.onStdout&&e.onStdout(a)},onStderr:a=>{y+=a,e.onStderr&&e.onStderr(a)}});if(!l||l.exitCode!==0)return{code:l&&l.exitCode||1,stdout:d,stderr:y||`g++: error: linker command failed with exit code 1
612
- `};if(l.wasmBinary){if(e.vfs.writeFileSync(r,l.wasmBinary),typeof e.vfs.chmodSync=="function")try{e.vfs.chmodSync(r,493)}catch(a){N.debug("chmodSync failed on compiled binary",a)}typeof e.emitMutation=="function"&&e.emitMutation("create",r)}return{code:0,stdout:d,stderr:y}},async"clang++"(n,e){return V["g++"](n,e)},async"c++"(n,e){return V["g++"](n,e)},async python3(n,e){if(n[0]==="--version"||n[0]==="-V")return{code:0,stdout:`Python 3.12.8 (CPython WebAssembly via Pyodide)
613
- `,stderr:""};if(n[0]==="-m"&&n[1]==="http.server"){let y=8e3,l=".";for(let u=2;u<n.length;u++){const p=n[u];(p==="-d"||p==="--directory")&&n[u+1]?l=n[++u]:p.startsWith("--directory=")?l=p.slice(12)||".":p==="-b"||p==="--bind"?u++:/^\d+$/.test(p)&&(y=Number(p))}const a=e.resolvePath(l);if(!e.vfs.existsSync(a))return{code:1,stdout:"",stderr:`python3: http.server: ${l}: No such file or directory
614
- `};const c=we(e,a,y);if(!c)return{code:1,stdout:"",stderr:`python3: http.server: no virtual port table available
615
- `};const h=`Serving HTTP on 127.0.0.1 port ${c.port} (http://127.0.0.1:${c.port}/) ...
616
- `;return await $e(c,e,h)}const s=e.shell&&e.shell.options&&e.shell.options.pythonCompiler||typeof globalThis<"u"&&globalThis.__codelabPythonCompiler||typeof window<"u"&&window.__codelabPythonCompiler,t=(typeof e.onRequestStdin=="function"?e.onRequestStdin:null)||(e.shell&&e.shell.options&&typeof e.shell.options.onRequestStdin=="function"?e.shell.options.onRequestStdin:void 0);if(n.length===0||n[0]==="-i"){if(!e.stdin&&!t)return{code:0,stdout:`Python 3.12.8 (CPython WebAssembly via Pyodide)
603
+ `};let a="",y="";const l=await f({entry:s[0],sourceFiles:s,outputPath:r,std:o,optLevel:i,extraFlags:t,vfs:e.vfs,onStdout:c=>{a+=c,e.onStdout&&e.onStdout(c)},onStderr:c=>{y+=c,e.onStderr&&e.onStderr(c)}});if(!l||l.exitCode!==0)return{code:l&&l.exitCode||1,stdout:a,stderr:y||`g++: error: linker command failed with exit code 1
604
+ `};if(l.wasmBinary){if(e.vfs.writeFileSync(r,l.wasmBinary),typeof e.vfs.chmodSync=="function")try{e.vfs.chmodSync(r,493)}catch(c){_.debug("chmodSync failed on compiled binary",c)}typeof e.emitMutation=="function"&&e.emitMutation("create",r)}return{code:0,stdout:a,stderr:y}},async"clang++"(n,e){return V["g++"](n,e)},async"c++"(n,e){return V["g++"](n,e)},async python3(n,e){if(n[0]==="--version"||n[0]==="-V")return{code:0,stdout:`Python 3.12.8 (CPython WebAssembly via Pyodide)
605
+ `,stderr:""};if(n[0]==="-m"&&n[1]==="http.server"){let y=8e3,l=".";for(let h=2;h<n.length;h++){const p=n[h];(p==="-d"||p==="--directory")&&n[h+1]?l=n[++h]:p.startsWith("--directory=")?l=p.slice(12)||".":p==="-b"||p==="--bind"?h++:/^\d+$/.test(p)&&(y=Number(p))}const c=e.resolvePath(l);if(!e.vfs.existsSync(c))return{code:1,stdout:"",stderr:`python3: http.server: ${l}: No such file or directory
606
+ `};const d=we(e,c,y);if(!d)return{code:1,stdout:"",stderr:`python3: http.server: no virtual port table available
607
+ `};const u=`Serving HTTP on 127.0.0.1 port ${d.port} (http://127.0.0.1:${d.port}/) ...
608
+ `;return await $e(d,e,u)}const s=e.shell&&e.shell.options&&e.shell.options.pythonCompiler||typeof globalThis<"u"&&globalThis.__codelabPythonCompiler||typeof window<"u"&&window.__codelabPythonCompiler,t=(typeof e.onRequestStdin=="function"?e.onRequestStdin:null)||(e.shell&&e.shell.options&&typeof e.shell.options.onRequestStdin=="function"?e.shell.options.onRequestStdin:void 0);if(n.length===0||n[0]==="-i"){if(!e.stdin&&!t)return{code:0,stdout:`Python 3.12.8 (CPython WebAssembly via Pyodide)
617
609
  `,stderr:""};if(typeof s!="function")return{code:1,stdout:"",stderr:`python3: Python WebAssembly toolchain is not enabled. Enable pythonExtension from "@innovatorved/code-lab/extensions/python".
618
- `};if(e.stdin&&!t){let c="",h="";const u=await s({source:e.stdin,stdin:"",env:e.env,cwd:e.cwd,vfs:e.vfs,signal:e.signal,onStdout:p=>{c+=p,e.onStdout&&e.onStdout(p)},onStderr:p=>{h+=p,e.onStderr&&e.onStderr(p)}});return{code:u&&u.ok?0:u&&u.exitCode||1,stdout:c,stderr:h}}const y=`Python 3.12.8 (CPython WebAssembly via Pyodide)
610
+ `};if(e.stdin&&!t){let d="",u="";const h=await s({source:e.stdin,stdin:"",env:e.env,cwd:e.cwd,vfs:e.vfs,signal:e.signal,onStdout:p=>{d+=p,e.onStdout&&e.onStdout(p)},onStderr:p=>{u+=p,e.onStderr&&e.onStderr(p)}});return{code:h&&h.ok?0:h&&h.exitCode||1,stdout:d,stderr:u}}const y=`Python 3.12.8 (CPython WebAssembly via Pyodide)
619
611
  Type "exit()" or Ctrl+D to exit.
620
- `;let l=y,a="";for(e.onStdout&&e.onStdout(y);!(e.signal&&e.signal.aborted);){const c=await t(">>> ");if(c==null)break;const h=String(c).trim();if(h==="exit()"||h==="quit()")break;h&&await s({source:String(c),repl:!0,stdin:"",env:e.env,cwd:e.cwd,vfs:e.vfs,signal:e.signal,onRequestStdin:t,onStdout:u=>{l+=u,e.onStdout&&e.onStdout(u)},onStderr:u=>{a+=u,e.onStderr&&e.onStderr(u)}})}return{code:0,stdout:l,stderr:a,alreadyStreamed:!0}}let r,o;if(n[0]==="-c"&&n.length>1?r=n[1]:n[0].startsWith("-")||(o=e.resolvePath(n[0])),typeof s!="function")return{code:1,stdout:"",stderr:`python3: Python WebAssembly toolchain is not enabled. Enable pythonExtension from "@innovatorved/code-lab/extensions/python".
621
- `};let i="",f="";const d=await s({entry:o,source:r,stdin:e.stdin||"",env:e.env,cwd:e.cwd,vfs:e.vfs,signal:e.signal,onRequestStdin:t,onStdout:y=>{i+=y,e.onStdout&&e.onStdout(y)},onStderr:y=>{f+=y,e.onStderr&&e.onStderr(y)}});return{code:d&&d.ok?0:d&&d.exitCode||1,stdout:i,stderr:f}},async python(n,e){return V.python3(n,e)},async pytest(n,e){if(n.length>0&&(n[0]==="--version"||n[0]==="-V"))return{code:0,stdout:`pytest 8.3.4 (Python 3.12 WebAssembly)
612
+ `;let l=y,c="";for(e.onStdout&&e.onStdout(y);!(e.signal&&e.signal.aborted);){const d=await t(">>> ");if(d==null)break;const u=String(d).trim();if(u==="exit()"||u==="quit()")break;u&&await s({source:String(d),repl:!0,stdin:"",env:e.env,cwd:e.cwd,vfs:e.vfs,signal:e.signal,onRequestStdin:t,onStdout:h=>{l+=h,e.onStdout&&e.onStdout(h)},onStderr:h=>{c+=h,e.onStderr&&e.onStderr(h)}})}return{code:0,stdout:l,stderr:c,alreadyStreamed:!0}}let r,o;if(n[0]==="-c"&&n.length>1?r=n[1]:n[0].startsWith("-")||(o=e.resolvePath(n[0])),typeof s!="function")return{code:1,stdout:"",stderr:`python3: Python WebAssembly toolchain is not enabled. Enable pythonExtension from "@innovatorved/code-lab/extensions/python".
613
+ `};let i="",f="";const a=await s({entry:o,source:r,stdin:e.stdin||"",env:e.env,cwd:e.cwd,vfs:e.vfs,signal:e.signal,onRequestStdin:t,onStdout:y=>{i+=y,e.onStdout&&e.onStdout(y)},onStderr:y=>{f+=y,e.onStderr&&e.onStderr(y)}});return{code:a&&a.ok?0:a&&a.exitCode||1,stdout:i,stderr:f}},async python(n,e){return V.python3(n,e)},async pytest(n,e){if(n.length>0&&(n[0]==="--version"||n[0]==="-V"))return{code:0,stdout:`pytest 8.3.4 (Python 3.12 WebAssembly)
622
614
  `,stderr:""};let t=n.filter(r=>!r.startsWith("-"))[0];if(!t&&e.vfs)try{t=Object.keys(typeof e.vfs.toSnapshot=="function"?e.vfs.toSnapshot("/workspace"):e.vfs.files||{}).find(o=>/(?:^|\/)(?:test_.*|.*_test|test)\.py$/i.test(o))}catch(r){}return t=t||"test.py",V.python3([t],e)},async pip(n,e){if(n.length===0||n[0]==="--version"||n[0]==="-V")return{code:0,stdout:`pip 24.0 from /usr/lib/python/pip (python 3.12)
623
615
  `,stderr:""};if(n[0]==="install"){const s=n.slice(1).filter(r=>!r.startsWith("-")),t=e.shell&&e.shell.options&&e.shell.options.pythonToolchain||typeof globalThis<"u"&&globalThis.__codelabPythonToolchain||typeof window<"u"&&window.__codelabPythonToolchain;if(t&&typeof t.installPackages=="function"){const r=await t.installPackages(s);return r.ok?{code:0,stdout:`Successfully installed ${r.installed.join(", ")||"packages"}
624
616
  `,stderr:""}:{code:1,stdout:"",stderr:`ERROR: Could not find a version that satisfies the requirement ${r.error||s.join(", ")}
@@ -638,12 +630,12 @@ Commands:
638
630
  -e <code> Evaluate JavaScript
639
631
  `,stderr:""};if(s==="init"){const o=j.join(e.cwd,"package.json"),i=j.basename(e.cwd)||"app";e.vfs.existsSync(o)||(e.vfs.writeFileSync(o,JSON.stringify({name:i,module:"index.ts",type:"module",devDependencies:{"@types/bun":"latest"},peerDependencies:{typescript:"^5.0.0"}},null,2)+`
640
632
  `),typeof e.emitMutation=="function"&&e.emitMutation("create",o));const f=j.join(e.cwd,"index.ts");e.vfs.existsSync(f)||(e.vfs.writeFileSync(f,`console.log("Hello via Bun!");
641
- `),typeof e.emitMutation=="function"&&e.emitMutation("create",f));const d=j.join(e.cwd,"tsconfig.json");return e.vfs.existsSync(d)||(e.vfs.writeFileSync(d,JSON.stringify({compilerOptions:{lib:["ESNext"],module:"esnext",target:"esnext",moduleResolution:"bundler",moduleDetection:"force",allowImportingTsExtensions:!0,noEmit:!0,composite:!0,strict:!0,downlevelIteration:!0,skipLibCheck:!0,jsx:"react-jsx",allowSyntheticDefaultImports:!0,forceConsistentCasingInFileNames:!0,allowJs:!0,types:["bun-types"]}},null,2)+`
642
- `),typeof e.emitMutation=="function"&&e.emitMutation("create",d)),{code:0,stdout:"Done! A package.json file was created in "+e.cwd+`
643
- `,stderr:""}}if(s==="install"||s==="i"||s==="ci"){const o=n.slice(1).filter(f=>!f.startsWith("-")),i=n.some(f=>f==="-D"||f==="--dev"||f==="--save-dev"||f==="-d");if(o.length===0){const{data:f}=H(e.vfs,e.cwd),d=Object.keys(Object.assign({},f.dependencies||{},f.devDependencies||{}));return d.length===0?{code:0,stdout:`up to date
644
- `,stderr:""}:await ne(d,e,{manager:"bun",header:"bun install v1.1.20 (1.1.20)"})}return await ne(o,e,{manager:"bun",dev:i,header:"bun add v1.1.20 (1.1.20)"})}if(s==="add"){let o=n.slice(1).filter(f=>!f.startsWith("-"));const i=n.some(f=>f==="-D"||f==="--dev"||f==="--save-dev"||f==="-d");if(o.length===0){const{data:f}=H(e.vfs,e.cwd);o=Object.keys(f.dependencies||{})}return o.length===0?{code:0,stdout:`up to date
633
+ `),typeof e.emitMutation=="function"&&e.emitMutation("create",f));const a=j.join(e.cwd,"tsconfig.json");return e.vfs.existsSync(a)||(e.vfs.writeFileSync(a,JSON.stringify({compilerOptions:{lib:["ESNext"],module:"esnext",target:"esnext",moduleResolution:"bundler",moduleDetection:"force",allowImportingTsExtensions:!0,noEmit:!0,composite:!0,strict:!0,downlevelIteration:!0,skipLibCheck:!0,jsx:"react-jsx",allowSyntheticDefaultImports:!0,forceConsistentCasingInFileNames:!0,allowJs:!0,types:["bun-types"]}},null,2)+`
634
+ `),typeof e.emitMutation=="function"&&e.emitMutation("create",a)),{code:0,stdout:"Done! A package.json file was created in "+e.cwd+`
635
+ `,stderr:""}}if(s==="install"||s==="i"||s==="ci"){const o=n.slice(1).filter(f=>!f.startsWith("-")),i=n.some(f=>f==="-D"||f==="--dev"||f==="--save-dev"||f==="-d");if(o.length===0){const{data:f}=H(e.vfs,e.cwd),a=Object.keys(Object.assign({},f.dependencies||{},f.devDependencies||{}));return a.length===0?{code:0,stdout:`up to date
636
+ `,stderr:""}:await ne(a,e,{manager:"bun",header:"bun install v1.1.20 (1.1.20)"})}return await ne(o,e,{manager:"bun",dev:i,header:"bun add v1.1.20 (1.1.20)"})}if(s==="add"){let o=n.slice(1).filter(f=>!f.startsWith("-"));const i=n.some(f=>f==="-D"||f==="--dev"||f==="--save-dev"||f==="-d");if(o.length===0){const{data:f}=H(e.vfs,e.cwd);o=Object.keys(f.dependencies||{})}return o.length===0?{code:0,stdout:`up to date
645
637
  `,stderr:""}:await ne(o,e,{manager:"bun",dev:i,header:"bun add v1.1.20 (1.1.20)"})}if(s==="remove"||s==="rm"){const o=n.slice(1).filter(i=>!i.startsWith("-"));for(const i of o)be(i,e);return{code:0,stdout:`removed ${o.length} package(s)
646
- `,stderr:""}}if(s==="pm")return n[1]==="ls"?{code:0,stdout:ie(e),stderr:""}:{code:0,stdout:"",stderr:""};if(s==="-e"){const o=n[1]||"",i=await q({mode:"repl",replCode:o,printReplResult:!1,stdin:e.stdin||"",env:e.env,cwd:e.cwd,vfs:e.vfs,pid:e.pid,isBackground:e.isBackground,onStdout:e.onStdout,onStderr:e.onStderr,signal:e.signal},e);return{code:i.ok?0:i.exitCode||1,stdout:i.stdout,stderr:i.stderr}}if(s==="test"){const o=n[1]?e.resolvePath(n[1]):null;let i=[];if(o)i.push(o);else{const l=a=>{if(e.vfs.existsSync(a))for(const c of e.vfs.readdirSync(a)){const h=j.join(a,c);e.vfs.statSync(h).isDirectory()&&c!=="node_modules"&&c!==".git"?l(h):(c.endsWith(".test.js")||c.endsWith(".test.ts"))&&i.push(h)}};l(e.cwd)}let f="",d="",y=!0;for(const l of i){const a=await q({mode:"test",entry:l,stdin:e.stdin||"",env:e.env,cwd:e.cwd,vfs:e.vfs,pid:e.pid,isBackground:e.isBackground,onStdout:e.onStdout,onStderr:e.onStderr,signal:e.signal},e);f+=a.stdout,d+=a.stderr,a.ok||(y=!1)}return{code:y?0:1,stdout:f,stderr:d}}if(s==="run"){const o=n[1];if(!o)return{code:0,stdout:ie(e),stderr:""};const i=e.resolvePath(o);if(e.vfs.existsSync(i)){const d=n.slice(2),y=await q({mode:"run",entry:i,argv:["bun",i,...d],stdin:e.stdin||"",env:e.env,cwd:e.cwd,vfs:e.vfs,pid:e.pid,isBackground:e.isBackground,onStdout:e.onStdout,onStderr:e.onStderr,signal:e.signal},e);return{code:y.ok?0:y.exitCode||1,stdout:y.stdout,stderr:y.stderr}}const{data:f}=H(e.vfs,e.cwd);return f.scripts&&f.scripts[o]?await Z(o,n.slice(2),e):{code:1,stdout:"",stderr:`error: Script or file not found "${o}"
638
+ `,stderr:""}}if(s==="pm")return n[1]==="ls"?{code:0,stdout:ie(e),stderr:""}:{code:0,stdout:"",stderr:""};if(s==="-e"){const o=n[1]||"",i=await q({mode:"repl",replCode:o,printReplResult:!1,stdin:e.stdin||"",env:e.env,cwd:e.cwd,vfs:e.vfs,pid:e.pid,isBackground:e.isBackground,onStdout:e.onStdout,onStderr:e.onStderr,signal:e.signal},e);return{code:i.ok?0:i.exitCode||1,stdout:i.stdout,stderr:i.stderr}}if(s==="test"){const o=n[1]?e.resolvePath(n[1]):null;let i=[];if(o)i.push(o);else{const l=c=>{if(e.vfs.existsSync(c))for(const d of e.vfs.readdirSync(c)){const u=j.join(c,d);e.vfs.statSync(u).isDirectory()&&d!=="node_modules"&&d!==".git"?l(u):(d.endsWith(".test.js")||d.endsWith(".test.ts"))&&i.push(u)}};l(e.cwd)}let f="",a="",y=!0;for(const l of i){const c=await q({mode:"test",entry:l,stdin:e.stdin||"",env:e.env,cwd:e.cwd,vfs:e.vfs,pid:e.pid,isBackground:e.isBackground,onStdout:e.onStdout,onStderr:e.onStderr,signal:e.signal},e);f+=c.stdout,a+=c.stderr,c.ok||(y=!1)}return{code:y?0:1,stdout:f,stderr:a}}if(s==="run"){const o=n[1];if(!o)return{code:0,stdout:ie(e),stderr:""};const i=e.resolvePath(o);if(e.vfs.existsSync(i)){const a=n.slice(2),y=await q({mode:"run",entry:i,argv:["bun",i,...a],stdin:e.stdin||"",env:e.env,cwd:e.cwd,vfs:e.vfs,pid:e.pid,isBackground:e.isBackground,onStdout:e.onStdout,onStderr:e.onStderr,signal:e.signal},e);return{code:y.ok?0:y.exitCode||1,stdout:y.stdout,stderr:y.stderr}}const{data:f}=H(e.vfs,e.cwd);return f.scripts&&f.scripts[o]?await Z(o,n.slice(2),e):{code:1,stdout:"",stderr:`error: Script or file not found "${o}"
647
639
  `}}const t=e.resolvePath(s);if(e.vfs.existsSync(t)){const o=n.slice(1),i=await q({mode:"run",entry:t,argv:["bun",t,...o],stdin:e.stdin||"",env:e.env,cwd:e.cwd,vfs:e.vfs,pid:e.pid,isBackground:e.isBackground,onStdout:e.onStdout,onStderr:e.onStderr,signal:e.signal},e);return{code:i.ok?0:i.exitCode||1,stdout:i.stdout,stderr:i.stderr}}const{data:r}=H(e.vfs,e.cwd);return r.scripts&&r.scripts[s]?await Z(s,n.slice(1),e):{code:1,stdout:"",stderr:`bun: file or command not found: ${s}
648
640
  `}},async npm(n,e){if(n.length===0)return{code:0,stdout:`npm v10.2.0
649
641
  `,stderr:""};const s=n[0];if(s==="--version"||s==="-v"||s==="version")return{code:0,stdout:`10.2.0
@@ -658,7 +650,7 @@ Commands: init, install, uninstall, list, run, start, test
658
650
  `,stderr:""}}if(s==="list"||s==="ls")return{code:0,stdout:ie(e),stderr:""};if(s==="run"||s==="run-script"){const r=n[1];return r?await Z(r,n.slice(2),e):{code:1,stdout:"",stderr:`npm ERR! missing script name
659
651
  `}}if(s==="test")return await Z("test",n.slice(1),e);if(s==="start")return await Z("start",n.slice(1),e);const{data:t}=H(e.vfs,e.cwd);return t.scripts&&t.scripts[s]?await Z(s,n.slice(1),e):{code:1,stdout:"",stderr:`npm ERR! Unknown command: "${s}"
660
652
  `}},async npx(n,e){const s=[];for(let y=0;y<n.length;y++)n[y]==="-y"||n[y]==="--yes"||n[y]==="--no-install"||s.push(n[y]);if(s.length===0)return{code:1,stdout:"",stderr:`npx: missing command
661
- `};const t=s[0],r=s.slice(1),o=j.join(e.cwd||"/workspace","node_modules/.bin",t),i=j.join("/workspace/node_modules/.bin",t),f=e.vfs.existsSync(o)?o:e.vfs.existsSync(i)?i:null;if(f){const l=String(e.vfs.readFileSync(f,"utf8")||"").match(/exec\s+node\s+"([^"]+)"/);return l&&l[1]?await e.shell.commands.node([l[1],...r],e):await e.shell.commands.node([f,...r],e)}const d=[t,...r].map(We).join(" ");return await e.shell.execute(d,{cwd:e.cwd,env:e.env,stdin:e.stdin,signal:e.signal,onStdout:e.onStdout,onStderr:e.onStderr,onRequestStdin:e.onRequestStdin})},async bunx(n,e){return await this.npx(n,e)},async pnpm(n,e){if(n.length===0||n[0]==="--help"||n[0]==="-h")return{code:0,stdout:`pnpm v9.0.0
653
+ `};const t=s[0],r=s.slice(1),o=j.join(e.cwd||"/workspace","node_modules/.bin",t),i=j.join("/workspace/node_modules/.bin",t),f=e.vfs.existsSync(o)?o:e.vfs.existsSync(i)?i:null;if(f){const l=String(e.vfs.readFileSync(f,"utf8")||"").match(/exec\s+node\s+"([^"]+)"/);return l&&l[1]?await e.shell.commands.node([l[1],...r],e):await e.shell.commands.node([f,...r],e)}const a=[t,...r].map(We).join(" ");return await e.shell.execute(a,{cwd:e.cwd,env:e.env,stdin:e.stdin,signal:e.signal,onStdout:e.onStdout,onStderr:e.onStderr,onRequestStdin:e.onRequestStdin})},async bunx(n,e){return await this.npx(n,e)},async pnpm(n,e){if(n.length===0||n[0]==="--help"||n[0]==="-h")return{code:0,stdout:`pnpm v9.0.0
662
654
  Usage: pnpm <command>
663
655
 
664
656
  Commands:
@@ -685,7 +677,7 @@ Commands:
685
677
  browser-native ESM on the fly, and bare imports resolve to jsDelivr ESM.
686
678
 
687
679
  Open the Web Preview drawer (or http://127.0.0.1:<port>/) to view it.
688
- `,stderr:""};const s=(()=>{const f=[];for(let d=0;d<n.length;d++){const y=n[d];if(y==="--port"||y==="-p"){d++;continue}y.startsWith("-")||f.push(y)}return f[0]})();let t=3e3;for(let f=0;f<n.length;f++)(n[f]==="--port"||n[f]==="-p")&&n[f+1]?(t=Number(n[f+1])||t,f++):n[f].startsWith("--port=")&&(t=Number(n[f].split("=")[1])||t);const r=e.resolvePath(s||".");if(!e.vfs.existsSync(r))return{code:1,stdout:"",stderr:`serve: ${s}: No such file or directory
680
+ `,stderr:""};const s=(()=>{const f=[];for(let a=0;a<n.length;a++){const y=n[a];if(y==="--port"||y==="-p"){a++;continue}y.startsWith("-")||f.push(y)}return f[0]})();let t=3e3;for(let f=0;f<n.length;f++)(n[f]==="--port"||n[f]==="-p")&&n[f+1]?(t=Number(n[f+1])||t,f++):n[f].startsWith("--port=")&&(t=Number(n[f].split("=")[1])||t);const r=e.resolvePath(s||".");if(!e.vfs.existsSync(r))return{code:1,stdout:"",stderr:`serve: ${s}: No such file or directory
689
681
  `};const o=we(e,r,t);if(!o)return{code:1,stdout:"",stderr:`serve: no virtual port table available
690
682
  `};const i=`
691
683
  \u26A1 CodeLab preview server
@@ -696,19 +688,19 @@ Commands:
696
688
 
697
689
  `;return await $e(o,e,i)},async ports(n,e){const s=e.shell&&e.shell.portTable;if(!s||typeof s.listServers!="function")return{code:0,stdout:`PORT PID NAME
698
690
  `,stderr:""};const t=s.listServers();let r=`PORT PID NAME
699
- `;for(const o of t){const i=String(o.port||"").padEnd(8," "),f=String(o.pid!==void 0?o.pid:"-").padEnd(8," "),d=o.name||o.type||"server";r+=`${i} ${f} ${d}
691
+ `;for(const o of t){const i=String(o.port||"").padEnd(8," "),f=String(o.pid!==void 0?o.pid:"-").padEnd(8," "),a=o.name||o.type||"server";r+=`${i} ${f} ${a}
700
692
  `}return{code:0,stdout:r,stderr:""}},async curl(n,e){let s=null;const t={};let r=null,o=!1,i=null;for(let p=0;p<n.length;p++){const g=n[p];if(g==="-X"||g==="--request")s=n[++p];else if(g==="-H"||g==="--header"){const m=n[++p]||"",S=m.indexOf(":");S!==-1&&(t[m.slice(0,S).trim().toLowerCase()]=m.slice(S+1).trim())}else g==="-d"||g==="--data"||g==="--data-raw"?(r=n[++p],s||(s="POST")):g==="-i"||g==="--include"||g==="-v"||g==="--verbose"?o=!0:g==="-s"||g==="--silent"||g.startsWith("-")||(i=g)}if(!i)return{code:1,stdout:"",stderr:`curl: no URL specified!
701
- `};!i.startsWith("http://")&&!i.startsWith("https://")&&(i="http://"+i),s||(s="GET");const f=e.shell&&e.shell.portTable||null,d=e.shell&&e.shell.options&&typeof(e.shell.options.fetch||e.shell.options.fetchImpl)=="function"?e.shell.options.fetch||e.shell.options.fetchImpl:fetch;let y=!1;try{const g=new URL(i).hostname.toLowerCase();y=g==="localhost"||g==="127.0.0.1"||g==="0.0.0.0"||g==="::1"||g==="[::1]"}catch(p){N.debug("curl URL parse fallback",i,p)}let l=null,a=null;const c=f&&y?25:1;for(let p=0;p<c;p++)try{if(f&&y){l=await f.dispatchRequest(i,{method:s,headers:t,body:r}),a=null;break}else{l=await d(i,{method:s,headers:t,body:r}),a=null;break}}catch(g){if(a=g,g&&g.chaosEffect)break;p+1<c&&await new Promise(m=>setTimeout(m,15))}if(!l)return{code:7,stdout:"",stderr:`curl: (7) Failed to connect to host: ${a?a.message:"Connection refused"}
702
- `};const h=typeof l.text=="function"?await l.text():String(l.body||"");let u="";if(o){if(u+=`HTTP/1.1 ${l.status||200} ${l.statusText||"OK"}\r
703
- `,l.headers)if(typeof l.headers.forEach=="function")l.headers.forEach((p,g)=>{u+=`${g}: ${p}\r
704
- `});else if(typeof l.headers.entries=="function")for(const[p,g]of l.headers.entries())u+=`${p}: ${g}\r
705
- `;else for(const[p,g]of Object.entries(l.headers))u+=`${p}: ${g}\r
706
- `;u+=`\r
707
- `}return u+=h,{code:0,stdout:u,stderr:""}},async hey(n,e){let s=50,t=10,r="GET";const o={};let i=null,f=!1,d="";for(let D=0;D<n.length;D++){const _=n[D];if((_==="-n"||_==="--requests")&&D+1<n.length)s=Math.max(1,Math.min(2e3,parseInt(n[++D],10)||50));else if((_==="-c"||_==="--concurrency")&&D+1<n.length)t=Math.max(1,Math.min(200,parseInt(n[++D],10)||10));else if((_==="-m"||_==="-X"||_==="--method")&&D+1<n.length)r=String(n[++D]).toUpperCase();else if((_==="-H"||_==="--header")&&D+1<n.length){const B=n[++D],z=B.indexOf(":");z!==-1&&(o[B.slice(0,z).trim()]=B.slice(z+1).trim())}else(_==="-d"||_==="--body"||_==="--data")&&D+1<n.length?(i=n[++D],r==="GET"&&(r="POST")):_==="--json"?f=!0:_.startsWith("-")||(d=_)}if(!d)return{code:1,stdout:"",stderr:`Usage: hey [-n requests] [-c concurrency] [-m METHOD] [-H "Header: val"] [-d body] [--json] <url>
708
- `};!d.startsWith("http://")&&!d.startsWith("https://")&&(d="http://"+d),t=Math.min(t,s);const y=e.shell&&e.shell.portTable||null,l=e.shell&&e.shell.options&&typeof(e.shell.options.fetch||e.shell.options.fetchImpl)=="function"?e.shell.options.fetch||e.shell.options.fetchImpl:fetch;let a=!1;try{const _=new URL(d).hostname.toLowerCase();a=_==="localhost"||_==="127.0.0.1"||_==="0.0.0.0"||_==="::1"||_==="[::1]"}catch(D){N.debug("hey URL parse fallback",d,D)}const c=[],h={},u={};let p=0,g=0;const m=typeof performance<"u"&&performance.now?performance.now():Date.now(),S=async()=>{for(;!(g++>=s);){const _=typeof performance<"u"&&performance.now?performance.now():Date.now();try{let B;y&&a?B=await y.dispatchRequest(d,{method:r,headers:{...o},body:i}):B=await l(d,{method:r,headers:{...o},body:i});const z=typeof performance<"u"&&performance.now?performance.now():Date.now(),X=Math.max(.05,z-_);c.push(X);const J=B&&B.status||200;h[J]=(h[J]||0)+1;const se=B&&typeof B.text=="function"?await B.text():String(B&&B.body||"");p+=se.length}catch(B){const z=typeof performance<"u"&&performance.now?performance.now():Date.now();c.push(Math.max(.05,z-_));const X=B&&(B.chaosEffect||B.code)||"ERROR";u[X]=(u[X]||0)+1}}},b=[];for(let D=0;D<t;D++)b.push(S());await Promise.all(b);const v=typeof performance<"u"&&performance.now?performance.now():Date.now(),w=Math.max(.001,(v-m)/1e3);c.sort((D,_)=>D-_);const $=D=>{if(c.length===0)return 0;const _=Math.min(c.length-1,Math.floor(D/100*c.length));return Number(c[_].toFixed(2))},R=c.length?Number(c[0].toFixed(2)):0,I=c.length?Number(c[c.length-1].toFixed(2)):0,C=c.length?Number((c.reduce((D,_)=>D+_,0)/c.length).toFixed(2)):0,E=Number((s/w).toFixed(2)),T=$(50),k=$(90),O=$(95),F=$(99);if(f)return{code:0,stdout:JSON.stringify({url:d,method:r,requests:s,concurrency:t,durationSec:Number(w.toFixed(4)),rps:E,totalBytes:p,latencyMs:{min:R,avg:C,p50:T,p90:k,p95:O,p99:F,max:I},statusCodes:h,errors:u},null,2)+`
709
- `,stderr:""};let P="";if(c.length>0){const B=Math.max(.5,I-R)/5,z=new Array(5).fill(0);for(const J of c){const se=Math.min(4,Math.floor((J-R)/B));z[se]++}const X=Math.max(1,...z);for(let J=0;J<5;J++){const se=(R+B*(J+1)).toFixed(2).padStart(7),Rt=`[${z[J]}]`.padStart(6),Ot=Math.round(z[J]/X*28);P+=` ${se} ms ${Rt} |${"\u25A0".repeat(Ot)}
710
- `}}let A="";for(const[D,_]of Object.entries(h))A+=` [${D}] ${_} responses
711
- `;for(const[D,_]of Object.entries(u))A+=` [${D}] ${_} failed
693
+ `};!i.startsWith("http://")&&!i.startsWith("https://")&&(i="http://"+i),s||(s="GET");const f=e.shell&&e.shell.portTable||null,a=e.shell&&e.shell.options&&typeof(e.shell.options.fetch||e.shell.options.fetchImpl)=="function"?e.shell.options.fetch||e.shell.options.fetchImpl:fetch;let y=!1;try{const g=new URL(i).hostname.toLowerCase();y=g==="localhost"||g==="127.0.0.1"||g==="0.0.0.0"||g==="::1"||g==="[::1]"}catch(p){_.debug("curl URL parse fallback",i,p)}let l=null,c=null;const d=f&&y?25:1;for(let p=0;p<d;p++)try{if(f&&y){l=await f.dispatchRequest(i,{method:s,headers:t,body:r}),c=null;break}else{l=await a(i,{method:s,headers:t,body:r}),c=null;break}}catch(g){if(c=g,g&&g.chaosEffect)break;p+1<d&&await new Promise(m=>setTimeout(m,15))}if(!l)return{code:7,stdout:"",stderr:`curl: (7) Failed to connect to host: ${c?c.message:"Connection refused"}
694
+ `};const u=typeof l.text=="function"?await l.text():String(l.body||"");let h="";if(o){if(h+=`HTTP/1.1 ${l.status||200} ${l.statusText||"OK"}\r
695
+ `,l.headers)if(typeof l.headers.forEach=="function")l.headers.forEach((p,g)=>{h+=`${g}: ${p}\r
696
+ `});else if(typeof l.headers.entries=="function")for(const[p,g]of l.headers.entries())h+=`${p}: ${g}\r
697
+ `;else for(const[p,g]of Object.entries(l.headers))h+=`${p}: ${g}\r
698
+ `;h+=`\r
699
+ `}return h+=u,{code:0,stdout:h,stderr:""}},async hey(n,e){let s=50,t=10,r="GET";const o={};let i=null,f=!1,a="";for(let D=0;D<n.length;D++){const N=n[D];if((N==="-n"||N==="--requests")&&D+1<n.length)s=Math.max(1,Math.min(2e3,parseInt(n[++D],10)||50));else if((N==="-c"||N==="--concurrency")&&D+1<n.length)t=Math.max(1,Math.min(200,parseInt(n[++D],10)||10));else if((N==="-m"||N==="-X"||N==="--method")&&D+1<n.length)r=String(n[++D]).toUpperCase();else if((N==="-H"||N==="--header")&&D+1<n.length){const B=n[++D],z=B.indexOf(":");z!==-1&&(o[B.slice(0,z).trim()]=B.slice(z+1).trim())}else(N==="-d"||N==="--body"||N==="--data")&&D+1<n.length?(i=n[++D],r==="GET"&&(r="POST")):N==="--json"?f=!0:N.startsWith("-")||(a=N)}if(!a)return{code:1,stdout:"",stderr:`Usage: hey [-n requests] [-c concurrency] [-m METHOD] [-H "Header: val"] [-d body] [--json] <url>
700
+ `};!a.startsWith("http://")&&!a.startsWith("https://")&&(a="http://"+a),t=Math.min(t,s);const y=e.shell&&e.shell.portTable||null,l=e.shell&&e.shell.options&&typeof(e.shell.options.fetch||e.shell.options.fetchImpl)=="function"?e.shell.options.fetch||e.shell.options.fetchImpl:fetch;let c=!1;try{const N=new URL(a).hostname.toLowerCase();c=N==="localhost"||N==="127.0.0.1"||N==="0.0.0.0"||N==="::1"||N==="[::1]"}catch(D){_.debug("hey URL parse fallback",a,D)}const d=[],u={},h={};let p=0,g=0;const m=typeof performance<"u"&&performance.now?performance.now():Date.now(),S=async()=>{for(;!(g++>=s);){const N=typeof performance<"u"&&performance.now?performance.now():Date.now();try{let B;y&&c?B=await y.dispatchRequest(a,{method:r,headers:{...o},body:i}):B=await l(a,{method:r,headers:{...o},body:i});const z=typeof performance<"u"&&performance.now?performance.now():Date.now(),X=Math.max(.05,z-N);d.push(X);const J=B&&B.status||200;u[J]=(u[J]||0)+1;const se=B&&typeof B.text=="function"?await B.text():String(B&&B.body||"");p+=se.length}catch(B){const z=typeof performance<"u"&&performance.now?performance.now():Date.now();d.push(Math.max(.05,z-N));const X=B&&(B.chaosEffect||B.code)||"ERROR";h[X]=(h[X]||0)+1}}},b=[];for(let D=0;D<t;D++)b.push(S());await Promise.all(b);const v=typeof performance<"u"&&performance.now?performance.now():Date.now(),w=Math.max(.001,(v-m)/1e3);d.sort((D,N)=>D-N);const $=D=>{if(d.length===0)return 0;const N=Math.min(d.length-1,Math.floor(D/100*d.length));return Number(d[N].toFixed(2))},R=d.length?Number(d[0].toFixed(2)):0,I=d.length?Number(d[d.length-1].toFixed(2)):0,C=d.length?Number((d.reduce((D,N)=>D+N,0)/d.length).toFixed(2)):0,E=Number((s/w).toFixed(2)),T=$(50),k=$(90),O=$(95),F=$(99);if(f)return{code:0,stdout:JSON.stringify({url:a,method:r,requests:s,concurrency:t,durationSec:Number(w.toFixed(4)),rps:E,totalBytes:p,latencyMs:{min:R,avg:C,p50:T,p90:k,p95:O,p99:F,max:I},statusCodes:u,errors:h},null,2)+`
701
+ `,stderr:""};let P="";if(d.length>0){const B=Math.max(.5,I-R)/5,z=new Array(5).fill(0);for(const J of d){const se=Math.min(4,Math.floor((J-R)/B));z[se]++}const X=Math.max(1,...z);for(let J=0;J<5;J++){const se=(R+B*(J+1)).toFixed(2).padStart(7),Rt=`[${z[J]}]`.padStart(6),Ot=Math.round(z[J]/X*28);P+=` ${se} ms ${Rt} |${"\u25A0".repeat(Ot)}
702
+ `}}let A="";for(const[D,N]of Object.entries(u))A+=` [${D}] ${N} responses
703
+ `;for(const[D,N]of Object.entries(h))A+=` [${D}] ${N} failed
712
704
  `;return{code:0,stdout:`
713
705
  Summary:
714
706
  Total: ${w.toFixed(4)} secs
@@ -736,7 +728,7 @@ Status code distribution:
736
728
  `,stderr:""}):{code:1,stdout:"",stderr:`Usage: chaos latency <port> <ms> [--jitter <ms>]
737
729
  `}}if(t==="drop"||t==="loss"){const r=parseInt(n[1],10),o=parseFloat(n[2]);if(!r||isNaN(o))return{code:1,stdout:"",stderr:`Usage: chaos drop <port> <rate 0..1 or 0..100>
738
730
  `};const i=o>1?o/100:o;return s.setChaosRule(r,{dropRate:i}),{code:0,stdout:`Injected ${Math.round(i*100)}% packet drop (ETIMEDOUT) on port :${r}
739
- `,stderr:""}}if(t==="error"||t==="fail"||t==="503"){const r=parseInt(n[1],10),o=n[2]!==void 0?parseFloat(n[2]):.25;let i=503;for(let d=3;d<n.length;d++)(n[d]==="--status"||n[d]==="-s")&&n[d+1]&&(i=parseInt(n[++d],10)||503);if(!r||isNaN(o))return{code:1,stdout:"",stderr:`Usage: chaos error <port> <rate> [--status 503]
731
+ `,stderr:""}}if(t==="error"||t==="fail"||t==="503"){const r=parseInt(n[1],10),o=n[2]!==void 0?parseFloat(n[2]):.25;let i=503;for(let a=3;a<n.length;a++)(n[a]==="--status"||n[a]==="-s")&&n[a+1]&&(i=parseInt(n[++a],10)||503);if(!r||isNaN(o))return{code:1,stdout:"",stderr:`Usage: chaos error <port> <rate> [--status 503]
740
732
  `};const f=o>1?o/100:o;return s.setChaosRule(r,{errorRate:f,errorStatus:i}),{code:0,stdout:`Injected ${Math.round(f*100)}% HTTP ${i} error rate on port :${r}
741
733
  `,stderr:""}}if(t==="crash"||t==="kill"||t==="down"){const r=parseInt(n[1],10);return r?(s.setChaosRule(r,{crashed:!0}),{code:0,stdout:`Port :${r} marked CRASHED (all connections will fail with ECONNREFUSED)
742
734
  `,stderr:""}):{code:1,stdout:"",stderr:`Usage: chaos crash <port>
@@ -754,26 +746,26 @@ Commands:
754
746
  chaos partition <fromPort> <toPort> Block traffic between two ports
755
747
  chaos heal [port] Heal a port (or all ports)
756
748
  chaos reset Remove all chaos rules
757
- `}},async sqlite3(n,e){let s="pipe",t=!1;const r=[];for(let a=0;a<n.length;a++){const c=n[a];c==="-header"||c==="--header"?t=!0:c==="-column"||c==="--column"||c==="-table"||c==="--table"?(s="column",t=!0):c==="-json"||c==="--json"?s="json":c==="-csv"||c==="--csv"?s="csv":c.startsWith("-")||r.push(c)}let o=":memory:",i="";r.length===1?/^\s*(SELECT|INSERT|UPDATE|DELETE|CREATE|DROP|ALTER|PRAGMA|EXPLAIN|BEGIN|COMMIT|WITH|\.)/i.test(r[0])?i=r[0]:o=r[0]:r.length>=2&&(o=r[0],i=r.slice(1).join(" ")),!i&&e.stdin&&(i=String(e.stdin).trim());const f=(typeof e.onRequestStdin=="function"?e.onRequestStdin:null)||(e.shell&&e.shell.options&&typeof e.shell.options.onRequestStdin=="function"?e.shell.options.onRequestStdin:null);if(!i&&!f)return{code:0,stdout:`SQLite 3.45.0 (CodeLab VFS Engine)
749
+ `}},async sqlite3(n,e){let s="pipe",t=!1;const r=[];for(let c=0;c<n.length;c++){const d=n[c];d==="-header"||d==="--header"?t=!0:d==="-column"||d==="--column"||d==="-table"||d==="--table"?(s="column",t=!0):d==="-json"||d==="--json"?s="json":d==="-csv"||d==="--csv"?s="csv":d.startsWith("-")||r.push(d)}let o=":memory:",i="";r.length===1?/^\s*(SELECT|INSERT|UPDATE|DELETE|CREATE|DROP|ALTER|PRAGMA|EXPLAIN|BEGIN|COMMIT|WITH|\.)/i.test(r[0])?i=r[0]:o=r[0]:r.length>=2&&(o=r[0],i=r.slice(1).join(" ")),!i&&e.stdin&&(i=String(e.stdin).trim());const f=(typeof e.onRequestStdin=="function"?e.onRequestStdin:null)||(e.shell&&e.shell.options&&typeof e.shell.options.onRequestStdin=="function"?e.shell.options.onRequestStdin:null);if(!i&&!f)return{code:0,stdout:`SQLite 3.45.0 (CodeLab VFS Engine)
758
750
  Usage: sqlite3 [-column] [-header] [-json] [dbfile] "SQL"
759
- `,stderr:""};const d=U(),y=(d&&typeof d.createSqliteDatabase=="function"?d.createSqliteDatabase:null)||typeof _hostRuntime<"u"&&_hostRuntime&&_hostRuntime.createSqliteDatabase||typeof globalThis<"u"&&globalThis._codeLabCreateSqliteDatabase;if(typeof y!="function")return{code:1,stdout:"",stderr:`sqlite3: SQLite engine not initialized in runtime
760
- `};const l=(a,c)=>{const h=String(c||"").trim();if(!h)return"";if(h===".tables"){const g=Array.from(a.tables.keys());return g.length?g.join(" ")+`
761
- `:""}if(h.startsWith(".schema")){const g=[];for(const[m,S]of a.tables.entries()){const b=S.columns.map(v=>`${v.name} ${v.type||"TEXT"}`).join(", ");g.push(`CREATE TABLE ${m} (${b});`)}for(const m of a.indexes.values())g.push(`CREATE ${m.unique?"UNIQUE ":""}INDEX ${m.name} ON ${m.table} (${m.columns.join(", ")});`);return g.join(`
751
+ `,stderr:""};const a=U(),y=(a&&typeof a.createSqliteDatabase=="function"?a.createSqliteDatabase:null)||typeof _hostRuntime<"u"&&_hostRuntime&&_hostRuntime.createSqliteDatabase||typeof globalThis<"u"&&globalThis._codeLabCreateSqliteDatabase;if(typeof y!="function")return{code:1,stdout:"",stderr:`sqlite3: SQLite engine not initialized in runtime
752
+ `};const l=(c,d)=>{const u=String(d||"").trim();if(!u)return"";if(u===".tables"){const g=Array.from(c.tables.keys());return g.length?g.join(" ")+`
753
+ `:""}if(u.startsWith(".schema")){const g=[];for(const[m,S]of c.tables.entries()){const b=S.columns.map(v=>`${v.name} ${v.type||"TEXT"}`).join(", ");g.push(`CREATE TABLE ${m} (${b});`)}for(const m of c.indexes.values())g.push(`CREATE ${m.unique?"UNIQUE ":""}INDEX ${m.name} ON ${m.table} (${m.columns.join(", ")});`);return g.join(`
762
754
  `)+(g.length?`
763
- `:"")}if(h===".indexes"||h===".indices"){const g=Array.from(a.indexes.keys());return g.length?g.join(" ")+`
764
- `:""}const u=h.split(";").map(g=>g.trim()).filter(Boolean),p=[];for(const g of u){const S=/^(SELECT|EXPLAIN|PRAGMA)\b/i.test(g)?a.query(g).all():(a.run(g),[]);if(Array.isArray(S)&&S.length>0)if(s==="json")p.push(JSON.stringify(S,null,2));else if(s==="column"){const b=Object.keys(S[0]),v=b.map(w=>Math.max(w.length,...S.map($=>String($[w]??"").length)));t&&(p.push(b.map((w,$)=>w.padEnd(v[$])).join(" ")),p.push(v.map(w=>"-".repeat(w)).join(" ")));for(const w of S)p.push(b.map(($,R)=>String(w[$]??"").padEnd(v[R])).join(" "))}else{const b=Object.keys(S[0]),v=s==="csv"?",":"|";t&&p.push(b.join(v));for(const w of S)p.push(b.map($=>String(w[$]??"")).join(v))}}return p.length?p.join(`
755
+ `:"")}if(u===".indexes"||u===".indices"){const g=Array.from(c.indexes.keys());return g.length?g.join(" ")+`
756
+ `:""}const h=u.split(";").map(g=>g.trim()).filter(Boolean),p=[];for(const g of h){const S=/^(SELECT|EXPLAIN|PRAGMA)\b/i.test(g)?c.query(g).all():(c.run(g),[]);if(Array.isArray(S)&&S.length>0)if(s==="json")p.push(JSON.stringify(S,null,2));else if(s==="column"){const b=Object.keys(S[0]),v=b.map(w=>Math.max(w.length,...S.map($=>String($[w]??"").length)));t&&(p.push(b.map((w,$)=>w.padEnd(v[$])).join(" ")),p.push(v.map(w=>"-".repeat(w)).join(" ")));for(const w of S)p.push(b.map(($,R)=>String(w[$]??"").padEnd(v[R])).join(" "))}else{const b=Object.keys(S[0]),v=s==="csv"?",":"|";t&&p.push(b.join(v));for(const w of S)p.push(b.map($=>String(w[$]??"")).join(v))}}return p.length?p.join(`
765
757
  `)+`
766
- `:""};try{const a=y(e.vfs,()=>e.shell.cwd),c=new a(o);if(!i&&f){const u=`SQLite version 3.45.0 (CodeLab VFS Engine)
758
+ `:""};try{const c=y(e.vfs,()=>e.shell.cwd),d=new c(o);if(!i&&f){const h=`SQLite version 3.45.0 (CodeLab VFS Engine)
767
759
  Enter ".help" for usage hints, ".quit" to exit.
768
- `;let p=u,g="";for(e.onStdout&&e.onStdout(u);!(e.signal&&e.signal.aborted);){const m=await f("sqlite> ");if(m==null)break;const S=String(m).trim();if(S===".quit"||S===".exit")break;if(S===".help"){const b=`.tables List names of tables
760
+ `;let p=h,g="";for(e.onStdout&&e.onStdout(h);!(e.signal&&e.signal.aborted);){const m=await f("sqlite> ");if(m==null)break;const S=String(m).trim();if(S===".quit"||S===".exit")break;if(S===".help"){const b=`.tables List names of tables
769
761
  .schema Show CREATE statements
770
762
  .indexes Show names of indexes
771
763
  .quit Exit this program
772
- `;p+=b,e.onStdout&&e.onStdout(b);continue}if(S)try{const b=l(c,S);b&&(p+=b,e.onStdout&&e.onStdout(b))}catch(b){const v=`Error: ${b.message||String(b)}
773
- `;g+=v,e.onStderr&&e.onStderr(v)}}return{code:0,stdout:p,stderr:g,alreadyStreamed:!0}}return{code:0,stdout:l(c,i),stderr:""}}catch(a){return{code:1,stdout:"",stderr:`Error: ${a.message||String(a)}
774
- `}}},async read(n,e){let s="",t=!1;const r=[];for(let d=0;d<n.length;d++){const y=n[d];y==="-r"?t=!0:y==="-p"&&d+1<n.length?s=String(n[++d]):y.startsWith("-")&&y.length>1?y.includes("r")&&(t=!0):r.push(y)}r.length===0&&r.push("REPLY");let o=null;if(e.stdin&&String(e.stdin).length>0){const d=String(e.stdin),y=d.indexOf(`
775
- `);o=y===-1?d:d.slice(0,y),o.endsWith("\r")&&(o=o.slice(0,-1))}else{const d=(typeof e.onRequestStdin=="function"?e.onRequestStdin:null)||(e.shell&&e.shell.options&&typeof e.shell.options.onRequestStdin=="function"?e.shell.options.onRequestStdin:null);d&&(o=await d(s))}if(o==null)return{code:1,stdout:"",stderr:""};let i=String(o).replace(/\r?\n$/,"");t||(i=i.replace(/\\(.)/g,"$1"));const f=e.env&&e.env.IFS!==void 0?String(e.env.IFS):`
776
- `;if(r.length===1){const d=f.includes(" ")?i.trim():i;e.env[r[0]]=d,e.shell&&(e.shell.env[r[0]]=d)}else{const d=f.length>0?new RegExp("["+f.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")+"]+"):null,y=d?i.trim().split(d):[i];for(let l=0;l<r.length;l++){const a=r[l],c=l===r.length-1?y.slice(l).join(" "):y[l]||"";e.env[a]=c,e.shell&&(e.shell.env[a]=c)}}return{code:0,stdout:"",stderr:""}},async tsc(n,e){if(n.includes("--version")||n.includes("-v"))return{code:0,stdout:`Version 5.6.3
764
+ `;p+=b,e.onStdout&&e.onStdout(b);continue}if(S)try{const b=l(d,S);b&&(p+=b,e.onStdout&&e.onStdout(b))}catch(b){const v=`Error: ${b.message||String(b)}
765
+ `;g+=v,e.onStderr&&e.onStderr(v)}}return{code:0,stdout:p,stderr:g,alreadyStreamed:!0}}return{code:0,stdout:l(d,i),stderr:""}}catch(c){return{code:1,stdout:"",stderr:`Error: ${c.message||String(c)}
766
+ `}}},async read(n,e){let s="",t=!1;const r=[];for(let a=0;a<n.length;a++){const y=n[a];y==="-r"?t=!0:y==="-p"&&a+1<n.length?s=String(n[++a]):y.startsWith("-")&&y.length>1?y.includes("r")&&(t=!0):r.push(y)}r.length===0&&r.push("REPLY");let o=null;if(e.stdin&&String(e.stdin).length>0){const a=String(e.stdin),y=a.indexOf(`
767
+ `);o=y===-1?a:a.slice(0,y),o.endsWith("\r")&&(o=o.slice(0,-1))}else{const a=(typeof e.onRequestStdin=="function"?e.onRequestStdin:null)||(e.shell&&e.shell.options&&typeof e.shell.options.onRequestStdin=="function"?e.shell.options.onRequestStdin:null);a&&(o=await a(s))}if(o==null)return{code:1,stdout:"",stderr:""};let i=String(o).replace(/\r?\n$/,"");t||(i=i.replace(/\\(.)/g,"$1"));const f=e.env&&e.env.IFS!==void 0?String(e.env.IFS):`
768
+ `;if(r.length===1){const a=f.includes(" ")?i.trim():i;e.env[r[0]]=a,e.shell&&(e.shell.env[r[0]]=a)}else{const a=f.length>0?new RegExp("["+f.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")+"]+"):null,y=a?i.trim().split(a):[i];for(let l=0;l<r.length;l++){const c=r[l],d=l===r.length-1?y.slice(l).join(" "):y[l]||"";e.env[c]=d,e.shell&&(e.shell.env[c]=d)}}return{code:0,stdout:"",stderr:""}},async tsc(n,e){if(n.includes("--version")||n.includes("-v"))return{code:0,stdout:`Version 5.6.3
777
769
  `,stderr:""};if(n.includes("--help")||n.includes("-h"))return{code:0,stdout:`Version 5.6.3
778
770
  Syntax: tsc [options] [file...]
779
771
 
@@ -782,55 +774,55 @@ Options:
782
774
  --noEmit Do not emit outputs.
783
775
  --outDir <dir> Redirect output structure to the directory.
784
776
  -v, --version Print the compiler's version.
785
- `,stderr:""};if(n.includes("--init")){const d=j.join(e.cwd,"tsconfig.json");return e.vfs.existsSync(d)||(e.vfs.writeFileSync(d,JSON.stringify({compilerOptions:{target:"ES2022",module:"ESNext",moduleResolution:"bundler",strict:!0,esModuleInterop:!0,skipLibCheck:!0,jsx:"react-jsx"}},null,2)+`
786
- `),typeof e.emitMutation=="function"&&e.emitMutation("create",d)),{code:0,stdout:`Created a new tsconfig.json
787
- `,stderr:""}}const s=n.includes("--noEmit");let t=null;const r=[];for(let d=0;d<n.length;d++){const y=n[d];y==="--outDir"&&d+1<n.length?t=e.resolvePath(n[++d]):y==="-p"||y==="--project"?d++:y.startsWith("-")||r.push(e.resolvePath(y))}const o=[];if(r.length>0)o.push(...r);else{const d=y=>{if(e.vfs.existsSync(y))for(const l of e.vfs.readdirSync(y)){if(l==="node_modules"||l===".git"||l==="dist")continue;const a=j.join(y,l);e.vfs.statSync(a).isDirectory()?d(a):/\.(ts|tsx)$/i.test(l)&&!l.endsWith(".d.ts")&&o.push(a)}};d(e.cwd)}let i="",f=0;for(const d of o){if(!e.vfs.existsSync(d)){i+=`error TS6053: File '${d}' not found.
788
- `,f=2;continue}const y=String(e.vfs.readFileSync(d,"utf8")||"");try{const l=typeof globalThis<"u"&&globalThis.ts?globalThis.ts:null;let a="";if(l&&typeof l.transpileModule=="function"){const c=l.transpileModule(y,{fileName:d,reportDiagnostics:!0,compilerOptions:{target:l.ScriptTarget?l.ScriptTarget.ES2022:9,module:l.ModuleKind?l.ModuleKind.ESNext:99}});if(Array.isArray(c.diagnostics)&&c.diagnostics.length>0){for(const h of c.diagnostics){const u=typeof h.messageText=="string"?h.messageText:h.messageText&&h.messageText.messageText||"Syntax error";i+=`${j.relative(e.cwd,d)}(1,1): error TS${h.code||1005}: ${u}
789
- `}f=2;continue}a=c.outputText}else{let c=null,h=!1,u=!1,p=0,g=0,m=1;for(let S=0;S<y.length;S++){const b=y[S],v=y[S+1];if(b===`
790
- `){if(m++,c==='"'||c==="'")throw new Error(`Line ${m-1}: Unterminated string literal.`);h=!1;continue}if(!h){if(u){b==="*"&&v==="/"&&(u=!1,S++);continue}if(c){if(b==="\\"){S++;continue}b===c&&(c=null);continue}if(b==="/"&&v==="/"){h=!0,S++;continue}if(b==="/"&&v==="*"){u=!0,S++;continue}if(b==='"'||b==="'"||b==="`"){c=b;continue}if(b==="{"?p++:b==="}"?p--:b==="("?g++:b===")"&&g--,p<0||g<0)throw new Error(`Line ${m}: Unexpected closing token '${b}'.`)}}if(c)throw new Error(`Line ${m}: Unterminated string literal.`);if(p!==0||g!==0)throw new Error(`Line ${m}: Unexpected end of file (unclosed '${p!==0?"{":"("}').`);a=Je(y,d)}if(!s){const c=j.relative(e.cwd,d).replace(/\.(tsx|ts)$/i,".js"),h=t?j.join(t,c):d.replace(/\.(tsx|ts)$/i,".js"),u=j.dirname(h);e.vfs.existsSync(u)||e.vfs.mkdirSync(u,{recursive:!0}),e.vfs.writeFileSync(h,a),typeof e.emitMutation=="function"&&e.emitMutation("create",h)}}catch(l){i+=`${j.relative(e.cwd,d)}(1,1): error TS1005: ${l.message||String(l)}
791
- `,f=2}}return{code:f,stdout:"",stderr:i}}};V["redis-cli"]=async function(e,s){const t="/workspace/.codelab-redis.json",r=()=>{try{if(s.vfs.existsSync(t)){const u=JSON.parse(s.vfs.readFileSync(t,"utf8"));if(u&&typeof u=="object")return u}}catch(u){N.debug("redis-cli state read fallback:",u)}return{kv:{},hashes:{},lists:{},sets:{},zsets:{},expires:{}}},o=u=>{try{s.vfs.writeFileSync(t,JSON.stringify(u))}catch(p){N.debug("redis-cli state write failed:",p)}},i=r(),f=Date.now();for(const[u,p]of Object.entries(i.expires||{}))typeof p=="number"&&p<=f&&(delete i.kv[u],delete i.hashes[u],delete i.lists[u],delete i.sets[u],delete i.zsets[u],delete i.expires[u]);const d=[];for(let u=0;u<e.length;u++){if((e[u]==="-h"||e[u]==="-p"||e[u]==="-n")&&u+1<e.length){u++;continue}d.push(e[u])}if(d.length===0&&s.stdin){const u=String(s.stdin).trim().split(/\r?\n/)[0];u&&d.push(...u.split(/\s+/))}if(d.length===0)return{code:0,stdout:`redis-cli 7.2.4 (CodeLab VFS Store)
777
+ `,stderr:""};if(n.includes("--init")){const a=j.join(e.cwd,"tsconfig.json");return e.vfs.existsSync(a)||(e.vfs.writeFileSync(a,JSON.stringify({compilerOptions:{target:"ES2022",module:"ESNext",moduleResolution:"bundler",strict:!0,esModuleInterop:!0,skipLibCheck:!0,jsx:"react-jsx"}},null,2)+`
778
+ `),typeof e.emitMutation=="function"&&e.emitMutation("create",a)),{code:0,stdout:`Created a new tsconfig.json
779
+ `,stderr:""}}const s=n.includes("--noEmit");let t=null;const r=[];for(let a=0;a<n.length;a++){const y=n[a];y==="--outDir"&&a+1<n.length?t=e.resolvePath(n[++a]):y==="-p"||y==="--project"?a++:y.startsWith("-")||r.push(e.resolvePath(y))}const o=[];if(r.length>0)o.push(...r);else{const a=y=>{if(e.vfs.existsSync(y))for(const l of e.vfs.readdirSync(y)){if(l==="node_modules"||l===".git"||l==="dist")continue;const c=j.join(y,l);e.vfs.statSync(c).isDirectory()?a(c):/\.(ts|tsx)$/i.test(l)&&!l.endsWith(".d.ts")&&o.push(c)}};a(e.cwd)}let i="",f=0;for(const a of o){if(!e.vfs.existsSync(a)){i+=`error TS6053: File '${a}' not found.
780
+ `,f=2;continue}const y=String(e.vfs.readFileSync(a,"utf8")||"");try{const l=typeof globalThis<"u"&&globalThis.ts?globalThis.ts:null;let c="";if(l&&typeof l.transpileModule=="function"){const d=l.transpileModule(y,{fileName:a,reportDiagnostics:!0,compilerOptions:{target:l.ScriptTarget?l.ScriptTarget.ES2022:9,module:l.ModuleKind?l.ModuleKind.ESNext:99}});if(Array.isArray(d.diagnostics)&&d.diagnostics.length>0){for(const u of d.diagnostics){const h=typeof u.messageText=="string"?u.messageText:u.messageText&&u.messageText.messageText||"Syntax error";i+=`${j.relative(e.cwd,a)}(1,1): error TS${u.code||1005}: ${h}
781
+ `}f=2;continue}c=d.outputText}else{let d=null,u=!1,h=!1,p=0,g=0,m=1;for(let S=0;S<y.length;S++){const b=y[S],v=y[S+1];if(b===`
782
+ `){if(m++,d==='"'||d==="'")throw new Error(`Line ${m-1}: Unterminated string literal.`);u=!1;continue}if(!u){if(h){b==="*"&&v==="/"&&(h=!1,S++);continue}if(d){if(b==="\\"){S++;continue}b===d&&(d=null);continue}if(b==="/"&&v==="/"){u=!0,S++;continue}if(b==="/"&&v==="*"){h=!0,S++;continue}if(b==='"'||b==="'"||b==="`"){d=b;continue}if(b==="{"?p++:b==="}"?p--:b==="("?g++:b===")"&&g--,p<0||g<0)throw new Error(`Line ${m}: Unexpected closing token '${b}'.`)}}if(d)throw new Error(`Line ${m}: Unterminated string literal.`);if(p!==0||g!==0)throw new Error(`Line ${m}: Unexpected end of file (unclosed '${p!==0?"{":"("}').`);c=Ve(y,a)}if(!s){const d=j.relative(e.cwd,a).replace(/\.(tsx|ts)$/i,".js"),u=t?j.join(t,d):a.replace(/\.(tsx|ts)$/i,".js"),h=j.dirname(u);e.vfs.existsSync(h)||e.vfs.mkdirSync(h,{recursive:!0}),e.vfs.writeFileSync(u,c),typeof e.emitMutation=="function"&&e.emitMutation("create",u)}}catch(l){i+=`${j.relative(e.cwd,a)}(1,1): error TS1005: ${l.message||String(l)}
783
+ `,f=2}}return{code:f,stdout:"",stderr:i}}};V["redis-cli"]=async function(e,s){const t="/workspace/.codelab-redis.json",r=()=>{try{if(s.vfs.existsSync(t)){const h=JSON.parse(s.vfs.readFileSync(t,"utf8"));if(h&&typeof h=="object")return h}}catch(h){_.debug("redis-cli state read fallback:",h)}return{kv:{},hashes:{},lists:{},sets:{},zsets:{},expires:{}}},o=h=>{try{s.vfs.writeFileSync(t,JSON.stringify(h))}catch(p){_.debug("redis-cli state write failed:",p)}},i=r(),f=Date.now();for(const[h,p]of Object.entries(i.expires||{}))typeof p=="number"&&p<=f&&(delete i.kv[h],delete i.hashes[h],delete i.lists[h],delete i.sets[h],delete i.zsets[h],delete i.expires[h]);const a=[];for(let h=0;h<e.length;h++){if((e[h]==="-h"||e[h]==="-p"||e[h]==="-n")&&h+1<e.length){h++;continue}a.push(e[h])}if(a.length===0&&s.stdin){const h=String(s.stdin).trim().split(/\r?\n/)[0];h&&a.push(...h.split(/\s+/))}if(a.length===0)return{code:0,stdout:`redis-cli 7.2.4 (CodeLab VFS Store)
792
784
  Usage: redis-cli <COMMAND> [args...]
793
- `,stderr:""};const y=String(d[0]).toUpperCase(),l=d.slice(1),a=u=>`(integer) ${u}
794
- `,c=u=>u==null?`(nil)
795
- `:`"${u}"
796
- `,h=u=>!u||u.length===0?`(empty array)
797
- `:u.map((p,g)=>`${g+1}) "${p}"`).join(`
785
+ `,stderr:""};const y=String(a[0]).toUpperCase(),l=a.slice(1),c=h=>`(integer) ${h}
786
+ `,d=h=>h==null?`(nil)
787
+ `:`"${h}"
788
+ `,u=h=>!h||h.length===0?`(empty array)
789
+ `:h.map((p,g)=>`${g+1}) "${p}"`).join(`
798
790
  `)+`
799
- `;if(y==="PING")return{code:0,stdout:l[0]?c(l[0]):`PONG
791
+ `;if(y==="PING")return{code:0,stdout:l[0]?d(l[0]):`PONG
800
792
  `,stderr:""};if(y==="FLUSHALL"||y==="FLUSHDB")return o({kv:{},hashes:{},lists:{},sets:{},zsets:{},expires:{}}),{code:0,stdout:`OK
801
- `,stderr:""};if(y==="DBSIZE"){const u=new Set([...Object.keys(i.kv),...Object.keys(i.hashes),...Object.keys(i.lists),...Object.keys(i.sets),...Object.keys(i.zsets)]);return{code:0,stdout:a(u.size),stderr:""}}if(y==="INFO")return{code:0,stdout:`# Server
793
+ `,stderr:""};if(y==="DBSIZE"){const h=new Set([...Object.keys(i.kv),...Object.keys(i.hashes),...Object.keys(i.lists),...Object.keys(i.sets),...Object.keys(i.zsets)]);return{code:0,stdout:c(h.size),stderr:""}}if(y==="INFO")return{code:0,stdout:`# Server
802
794
  redis_version:7.2.4-codelab
803
795
  # Keyspace
804
796
  db0:keys=${new Set([...Object.keys(i.kv),...Object.keys(i.hashes),...Object.keys(i.lists),...Object.keys(i.sets),...Object.keys(i.zsets)]).size},expires=${Object.keys(i.expires).length}
805
- `,stderr:""};if(y==="SET"){const[u,p,...g]=l;if(!u||p===void 0)return{code:1,stdout:"",stderr:`ERR wrong number of arguments for SET
806
- `};let m=!1,S=!1,b=null;for(let w=0;w<g.length;w++){const $=String(g[w]).toUpperCase();$==="NX"?m=!0:$==="XX"?S=!0:$==="EX"&&g[w+1]?b=parseInt(g[++w],10)*1e3:$==="PX"&&g[w+1]&&(b=parseInt(g[++w],10))}const v=Object.prototype.hasOwnProperty.call(i.kv,u);return m&&v?{code:0,stdout:`(nil)
797
+ `,stderr:""};if(y==="SET"){const[h,p,...g]=l;if(!h||p===void 0)return{code:1,stdout:"",stderr:`ERR wrong number of arguments for SET
798
+ `};let m=!1,S=!1,b=null;for(let w=0;w<g.length;w++){const $=String(g[w]).toUpperCase();$==="NX"?m=!0:$==="XX"?S=!0:$==="EX"&&g[w+1]?b=parseInt(g[++w],10)*1e3:$==="PX"&&g[w+1]&&(b=parseInt(g[++w],10))}const v=Object.prototype.hasOwnProperty.call(i.kv,h);return m&&v?{code:0,stdout:`(nil)
807
799
  `,stderr:""}:S&&!v?{code:0,stdout:`(nil)
808
- `,stderr:""}:(i.kv[u]=String(p),b&&b>0?i.expires[u]=f+b:delete i.expires[u],o(i),{code:0,stdout:`OK
809
- `,stderr:""})}if(y==="GET"){const u=l[0],p=Object.prototype.hasOwnProperty.call(i.kv,u)?i.kv[u]:null;return o(i),{code:0,stdout:c(p),stderr:""}}if(y==="MSET"){for(let u=0;u+1<l.length;u+=2)i.kv[l[u]]=String(l[u+1]);return o(i),{code:0,stdout:`OK
800
+ `,stderr:""}:(i.kv[h]=String(p),b&&b>0?i.expires[h]=f+b:delete i.expires[h],o(i),{code:0,stdout:`OK
801
+ `,stderr:""})}if(y==="GET"){const h=l[0],p=Object.prototype.hasOwnProperty.call(i.kv,h)?i.kv[h]:null;return o(i),{code:0,stdout:d(p),stderr:""}}if(y==="MSET"){for(let h=0;h+1<l.length;h+=2)i.kv[l[h]]=String(l[h+1]);return o(i),{code:0,stdout:`OK
810
802
  `,stderr:""}}if(y==="MGET")return{code:0,stdout:l.map((p,g)=>`${g+1}) ${Object.prototype.hasOwnProperty.call(i.kv,p)?`"${i.kv[p]}"`:"(nil)"}`).join(`
811
803
  `)+`
812
- `,stderr:""};if(y==="DEL"){let u=0;for(const p of l)(Object.prototype.hasOwnProperty.call(i.kv,p)||Object.prototype.hasOwnProperty.call(i.hashes,p)||Object.prototype.hasOwnProperty.call(i.lists,p)||Object.prototype.hasOwnProperty.call(i.sets,p)||Object.prototype.hasOwnProperty.call(i.zsets,p))&&(delete i.kv[p],delete i.hashes[p],delete i.lists[p],delete i.sets[p],delete i.zsets[p],delete i.expires[p],u++);return o(i),{code:0,stdout:a(u),stderr:""}}if(y==="EXISTS"){let u=0;for(const p of l)(Object.prototype.hasOwnProperty.call(i.kv,p)||Object.prototype.hasOwnProperty.call(i.hashes,p)||Object.prototype.hasOwnProperty.call(i.lists,p)||Object.prototype.hasOwnProperty.call(i.sets,p)||Object.prototype.hasOwnProperty.call(i.zsets,p))&&u++;return{code:0,stdout:a(u),stderr:""}}if(y==="INCR"||y==="DECR"||y==="INCRBY"||y==="DECRBY"){const u=l[0],p=y==="INCR"?1:y==="DECR"?-1:(parseInt(l[1],10)||0)*(y==="DECRBY"?-1:1),m=(parseInt(i.kv[u]||"0",10)||0)+p;return i.kv[u]=String(m),o(i),{code:0,stdout:a(m),stderr:""}}if(y==="EXPIRE"){const[u,p]=l;return Object.prototype.hasOwnProperty.call(i.kv,u)||Object.prototype.hasOwnProperty.call(i.hashes,u)||Object.prototype.hasOwnProperty.call(i.lists,u)||Object.prototype.hasOwnProperty.call(i.sets,u)||Object.prototype.hasOwnProperty.call(i.zsets,u)?(i.expires[u]=f+(parseInt(p,10)||0)*1e3,o(i),{code:0,stdout:a(1),stderr:""}):{code:0,stdout:a(0),stderr:""}}if(y==="TTL"){const u=l[0];if(!(Object.prototype.hasOwnProperty.call(i.kv,u)||Object.prototype.hasOwnProperty.call(i.hashes,u)||Object.prototype.hasOwnProperty.call(i.lists,u)||Object.prototype.hasOwnProperty.call(i.sets,u)||Object.prototype.hasOwnProperty.call(i.zsets,u)))return{code:0,stdout:a(-2),stderr:""};if(!i.expires[u])return{code:0,stdout:a(-1),stderr:""};const g=Math.max(0,Math.ceil((i.expires[u]-f)/1e3));return{code:0,stdout:a(g),stderr:""}}if(y==="KEYS"){const u=l[0]||"*",p=new RegExp("^"+u.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*").replace(/\?/g,".")+"$"),g=Array.from(new Set([...Object.keys(i.kv),...Object.keys(i.hashes),...Object.keys(i.lists),...Object.keys(i.sets),...Object.keys(i.zsets)])).filter(m=>p.test(m));return{code:0,stdout:h(g),stderr:""}}if(y==="HSET"){const u=l[0];i.hashes[u]=i.hashes[u]||{};let p=0;for(let g=1;g+1<l.length;g+=2)Object.prototype.hasOwnProperty.call(i.hashes[u],l[g])||p++,i.hashes[u][l[g]]=String(l[g+1]);return o(i),{code:0,stdout:a(p),stderr:""}}if(y==="HGET"){const[u,p]=l,g=i.hashes[u]&&Object.prototype.hasOwnProperty.call(i.hashes[u],p)?i.hashes[u][p]:null;return{code:0,stdout:c(g),stderr:""}}if(y==="HGETALL"){const u=l[0],p=i.hashes[u]||{},g=[];for(const[m,S]of Object.entries(p))g.push(m,S);return{code:0,stdout:h(g),stderr:""}}if(y==="HDEL"){const[u,...p]=l,g=i.hashes[u]||{};let m=0;for(const S of p)Object.prototype.hasOwnProperty.call(g,S)&&(delete g[S],m++);return o(i),{code:0,stdout:a(m),stderr:""}}if(y==="LPUSH"||y==="RPUSH"){const[u,...p]=l;i.lists[u]=i.lists[u]||[];for(const g of p)y==="LPUSH"?i.lists[u].unshift(String(g)):i.lists[u].push(String(g));return o(i),{code:0,stdout:a(i.lists[u].length),stderr:""}}if(y==="LPOP"||y==="RPOP"){const u=l[0],p=i.lists[u]||[],g=p.length===0?null:y==="LPOP"?p.shift():p.pop();return o(i),{code:0,stdout:c(g),stderr:""}}if(y==="LRANGE"){const[u,p,g]=l,m=i.lists[u]||[];let S=parseInt(p,10)||0,b=parseInt(g,10);return isNaN(b)&&(b=-1),S<0&&(S=Math.max(0,m.length+S)),b<0&&(b=m.length+b),{code:0,stdout:h(m.slice(S,b+1)),stderr:""}}if(y==="LLEN"){const u=i.lists[l[0]]||[];return{code:0,stdout:a(u.length),stderr:""}}if(y==="SADD"){const[u,...p]=l,g=new Set(i.sets[u]||[]);let m=0;for(const S of p)g.has(String(S))||(g.add(String(S)),m++);return i.sets[u]=Array.from(g),o(i),{code:0,stdout:a(m),stderr:""}}if(y==="SMEMBERS")return{code:0,stdout:h(i.sets[l[0]]||[]),stderr:""};if(y==="SISMEMBER"){const[u,p]=l,g=new Set(i.sets[u]||[]);return{code:0,stdout:a(g.has(String(p))?1:0),stderr:""}}if(y==="SREM"){const[u,...p]=l,g=new Set(i.sets[u]||[]);let m=0;for(const S of p)g.delete(String(S))&&m++;return i.sets[u]=Array.from(g),o(i),{code:0,stdout:a(m),stderr:""}}if(y==="ZADD"){const[u,...p]=l;i.zsets[u]=i.zsets[u]||{};let g=0;for(let m=0;m+1<p.length;m+=2){const S=parseFloat(p[m]),b=String(p[m+1]);Object.prototype.hasOwnProperty.call(i.zsets[u],b)||g++,i.zsets[u][b]=isNaN(S)?0:S}return o(i),{code:0,stdout:a(g),stderr:""}}if(y==="ZSCORE"){const[u,p]=l,g=i.zsets[u]||{};return{code:0,stdout:Object.prototype.hasOwnProperty.call(g,p)?c(String(g[p])):`(nil)
813
- `,stderr:""}}if(y==="ZRANGE"||y==="ZREVRANGE"){const[u,p,g,m]=l,S=i.zsets[u]||{},b=Object.entries(S).sort((C,E)=>y==="ZREVRANGE"?E[1]-C[1]||E[0].localeCompare(C[0]):C[1]-E[1]||C[0].localeCompare(E[0]));let v=parseInt(p,10)||0,w=parseInt(g,10);isNaN(w)&&(w=-1),v<0&&(v=Math.max(0,b.length+v)),w<0&&(w=b.length+w);const $=b.slice(v,w+1),R=m&&String(m).toUpperCase()==="WITHSCORES",I=[];for(const[C,E]of $)I.push(C),R&&I.push(String(E));return{code:0,stdout:h(I),stderr:""}}if(y==="ZCARD"){const u=i.zsets[l[0]]||{};return{code:0,stdout:a(Object.keys(u).length),stderr:""}}if(y==="ZREM"){const[u,...p]=l,g=i.zsets[u]||{};let m=0;for(const S of p)Object.prototype.hasOwnProperty.call(g,S)&&(delete g[S],m++);return o(i),{code:0,stdout:a(m),stderr:""}}if(y==="EVAL"){const u=String(l[0]||""),p=Math.max(0,parseInt(l[1],10)||0),g=l.slice(2,2+p),m=l.slice(2+p),S=g[0]||"bucket:default";if(/token_bucket|tokens/i.test(u)){const b=Math.max(1,parseInt(m[0],10)||10),v=i.kv[S]!==void 0?parseInt(i.kv[S],10):b;if(v>0){const w=v-1;return i.kv[S]=String(w),o(i),{code:0,stdout:`1) (integer) 1
804
+ `,stderr:""};if(y==="DEL"){let h=0;for(const p of l)(Object.prototype.hasOwnProperty.call(i.kv,p)||Object.prototype.hasOwnProperty.call(i.hashes,p)||Object.prototype.hasOwnProperty.call(i.lists,p)||Object.prototype.hasOwnProperty.call(i.sets,p)||Object.prototype.hasOwnProperty.call(i.zsets,p))&&(delete i.kv[p],delete i.hashes[p],delete i.lists[p],delete i.sets[p],delete i.zsets[p],delete i.expires[p],h++);return o(i),{code:0,stdout:c(h),stderr:""}}if(y==="EXISTS"){let h=0;for(const p of l)(Object.prototype.hasOwnProperty.call(i.kv,p)||Object.prototype.hasOwnProperty.call(i.hashes,p)||Object.prototype.hasOwnProperty.call(i.lists,p)||Object.prototype.hasOwnProperty.call(i.sets,p)||Object.prototype.hasOwnProperty.call(i.zsets,p))&&h++;return{code:0,stdout:c(h),stderr:""}}if(y==="INCR"||y==="DECR"||y==="INCRBY"||y==="DECRBY"){const h=l[0],p=y==="INCR"?1:y==="DECR"?-1:(parseInt(l[1],10)||0)*(y==="DECRBY"?-1:1),m=(parseInt(i.kv[h]||"0",10)||0)+p;return i.kv[h]=String(m),o(i),{code:0,stdout:c(m),stderr:""}}if(y==="EXPIRE"){const[h,p]=l;return Object.prototype.hasOwnProperty.call(i.kv,h)||Object.prototype.hasOwnProperty.call(i.hashes,h)||Object.prototype.hasOwnProperty.call(i.lists,h)||Object.prototype.hasOwnProperty.call(i.sets,h)||Object.prototype.hasOwnProperty.call(i.zsets,h)?(i.expires[h]=f+(parseInt(p,10)||0)*1e3,o(i),{code:0,stdout:c(1),stderr:""}):{code:0,stdout:c(0),stderr:""}}if(y==="TTL"){const h=l[0];if(!(Object.prototype.hasOwnProperty.call(i.kv,h)||Object.prototype.hasOwnProperty.call(i.hashes,h)||Object.prototype.hasOwnProperty.call(i.lists,h)||Object.prototype.hasOwnProperty.call(i.sets,h)||Object.prototype.hasOwnProperty.call(i.zsets,h)))return{code:0,stdout:c(-2),stderr:""};if(!i.expires[h])return{code:0,stdout:c(-1),stderr:""};const g=Math.max(0,Math.ceil((i.expires[h]-f)/1e3));return{code:0,stdout:c(g),stderr:""}}if(y==="KEYS"){const h=l[0]||"*",p=new RegExp("^"+h.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*").replace(/\?/g,".")+"$"),g=Array.from(new Set([...Object.keys(i.kv),...Object.keys(i.hashes),...Object.keys(i.lists),...Object.keys(i.sets),...Object.keys(i.zsets)])).filter(m=>p.test(m));return{code:0,stdout:u(g),stderr:""}}if(y==="HSET"){const h=l[0];i.hashes[h]=i.hashes[h]||{};let p=0;for(let g=1;g+1<l.length;g+=2)Object.prototype.hasOwnProperty.call(i.hashes[h],l[g])||p++,i.hashes[h][l[g]]=String(l[g+1]);return o(i),{code:0,stdout:c(p),stderr:""}}if(y==="HGET"){const[h,p]=l,g=i.hashes[h]&&Object.prototype.hasOwnProperty.call(i.hashes[h],p)?i.hashes[h][p]:null;return{code:0,stdout:d(g),stderr:""}}if(y==="HGETALL"){const h=l[0],p=i.hashes[h]||{},g=[];for(const[m,S]of Object.entries(p))g.push(m,S);return{code:0,stdout:u(g),stderr:""}}if(y==="HDEL"){const[h,...p]=l,g=i.hashes[h]||{};let m=0;for(const S of p)Object.prototype.hasOwnProperty.call(g,S)&&(delete g[S],m++);return o(i),{code:0,stdout:c(m),stderr:""}}if(y==="LPUSH"||y==="RPUSH"){const[h,...p]=l;i.lists[h]=i.lists[h]||[];for(const g of p)y==="LPUSH"?i.lists[h].unshift(String(g)):i.lists[h].push(String(g));return o(i),{code:0,stdout:c(i.lists[h].length),stderr:""}}if(y==="LPOP"||y==="RPOP"){const h=l[0],p=i.lists[h]||[],g=p.length===0?null:y==="LPOP"?p.shift():p.pop();return o(i),{code:0,stdout:d(g),stderr:""}}if(y==="LRANGE"){const[h,p,g]=l,m=i.lists[h]||[];let S=parseInt(p,10)||0,b=parseInt(g,10);return isNaN(b)&&(b=-1),S<0&&(S=Math.max(0,m.length+S)),b<0&&(b=m.length+b),{code:0,stdout:u(m.slice(S,b+1)),stderr:""}}if(y==="LLEN"){const h=i.lists[l[0]]||[];return{code:0,stdout:c(h.length),stderr:""}}if(y==="SADD"){const[h,...p]=l,g=new Set(i.sets[h]||[]);let m=0;for(const S of p)g.has(String(S))||(g.add(String(S)),m++);return i.sets[h]=Array.from(g),o(i),{code:0,stdout:c(m),stderr:""}}if(y==="SMEMBERS")return{code:0,stdout:u(i.sets[l[0]]||[]),stderr:""};if(y==="SISMEMBER"){const[h,p]=l,g=new Set(i.sets[h]||[]);return{code:0,stdout:c(g.has(String(p))?1:0),stderr:""}}if(y==="SREM"){const[h,...p]=l,g=new Set(i.sets[h]||[]);let m=0;for(const S of p)g.delete(String(S))&&m++;return i.sets[h]=Array.from(g),o(i),{code:0,stdout:c(m),stderr:""}}if(y==="ZADD"){const[h,...p]=l;i.zsets[h]=i.zsets[h]||{};let g=0;for(let m=0;m+1<p.length;m+=2){const S=parseFloat(p[m]),b=String(p[m+1]);Object.prototype.hasOwnProperty.call(i.zsets[h],b)||g++,i.zsets[h][b]=isNaN(S)?0:S}return o(i),{code:0,stdout:c(g),stderr:""}}if(y==="ZSCORE"){const[h,p]=l,g=i.zsets[h]||{};return{code:0,stdout:Object.prototype.hasOwnProperty.call(g,p)?d(String(g[p])):`(nil)
805
+ `,stderr:""}}if(y==="ZRANGE"||y==="ZREVRANGE"){const[h,p,g,m]=l,S=i.zsets[h]||{},b=Object.entries(S).sort((C,E)=>y==="ZREVRANGE"?E[1]-C[1]||E[0].localeCompare(C[0]):C[1]-E[1]||C[0].localeCompare(E[0]));let v=parseInt(p,10)||0,w=parseInt(g,10);isNaN(w)&&(w=-1),v<0&&(v=Math.max(0,b.length+v)),w<0&&(w=b.length+w);const $=b.slice(v,w+1),R=m&&String(m).toUpperCase()==="WITHSCORES",I=[];for(const[C,E]of $)I.push(C),R&&I.push(String(E));return{code:0,stdout:u(I),stderr:""}}if(y==="ZCARD"){const h=i.zsets[l[0]]||{};return{code:0,stdout:c(Object.keys(h).length),stderr:""}}if(y==="ZREM"){const[h,...p]=l,g=i.zsets[h]||{};let m=0;for(const S of p)Object.prototype.hasOwnProperty.call(g,S)&&(delete g[S],m++);return o(i),{code:0,stdout:c(m),stderr:""}}if(y==="EVAL"){const h=String(l[0]||""),p=Math.max(0,parseInt(l[1],10)||0),g=l.slice(2,2+p),m=l.slice(2+p),S=g[0]||"bucket:default";if(/token_bucket|tokens/i.test(h)){const b=Math.max(1,parseInt(m[0],10)||10),v=i.kv[S]!==void 0?parseInt(i.kv[S],10):b;if(v>0){const w=v-1;return i.kv[S]=String(w),o(i),{code:0,stdout:`1) (integer) 1
814
806
  2) (integer) ${w}
815
807
  `,stderr:""}}return{code:0,stdout:`1) (integer) 0
816
808
  2) (integer) 0
817
- `,stderr:""}}return{code:0,stdout:c("OK"),stderr:""}}return{code:1,stdout:"",stderr:`ERR unknown command '${y}'
818
- `}};class x{constructor(e={}){if(this.options=e,this.portTable=e.portTable||(typeof le=="function"?le():null),this.vfs=e.vfs||Ze(),this.env=Object.assign({PATH:"/workspace/node_modules/.bin:/usr/local/bin:/usr/bin:/bin",PWD:"/workspace",HOME:"/home/codelab",USER:"codelab",SHELL:"/bin/sh",TERM:"xterm-256color","?":"0"},e.env||{}),j._homeDir=this.env.HOME||"/home/codelab",this.cwd=this.env.PWD||"/workspace",this.vfs&&typeof this.vfs._setCwd=="function"&&this.vfs._setCwd(this.cwd),this.vfs&&typeof this.vfs.mkdirSync=="function"&&typeof this.vfs.existsSync=="function"&&this.env.HOME&&!this.vfs.existsSync(this.env.HOME))try{this.vfs.mkdirSync(this.env.HOME,{recursive:!0})}catch(s){}if(e.files&&typeof e.files=="object")for(const[s,t]of Object.entries(e.files)){const r=j.resolve(this.cwd,s);if(typeof this.vfs.mkdirSync=="function"){const o=j.dirname(r);o&&o!=="/"&&(typeof this.vfs.existsSync!="function"||!this.vfs.existsSync(o))&&this.vfs.mkdirSync(o,{recursive:!0})}typeof this.vfs.writeFileSync=="function"&&this.vfs.writeFileSync(r,String(t??""))}this.history=[],this.jobs=new Map,this.nextJobId=1,this.nextPid=100,this.commands=Object.assign({},V,e.commands||{}),this._initialBootRoot=e._initialBootRoot?j.normalize(e._initialBootRoot):j.normalize(this.cwd||"/workspace"),this._initialBootSnapshot=e._initialBootSnapshot&&typeof e._initialBootSnapshot=="object"?e._initialBootSnapshot:L(this.vfs,this._initialBootRoot),e.gitState&&typeof e.gitState=="object"?this.gitState=e.gitState:this.gitState=Qe(this.vfs,this.cwd,e)}resolvePath(e){return j._homeDir=this.env&&this.env.HOME||"/home/codelab",e?j.resolve(this.cwd,e):this.cwd}_resolvePathBinary(e){if(!e||!this.vfs||typeof this.vfs.existsSync!="function")return null;const s=String(e);if(s.includes("/"))return null;const t=j.join(this.cwd||"/workspace","node_modules/.bin",s);if(this.vfs.existsSync(t))return t;const r=String(this.env&&this.env.PATH||"/workspace/node_modules/.bin:/usr/local/bin:/usr/bin:/bin").split(":").filter(Boolean);for(const i of r){const f=j.join(i,s);if(this.vfs.existsSync(f))return f}const o=j.join("/workspace/node_modules/.bin",s);return this.vfs.existsSync(o)?o:null}hasCommand(e){if(!e)return!1;const s=String(e);return this.functions&&Object.prototype.hasOwnProperty.call(this.functions,s)||this.commands&&Object.prototype.hasOwnProperty.call(this.commands,s)?!0:!!this._resolvePathBinary(s)}_emitVfsMutation(e,s){if(!this.vfs)return;const t={type:e,path:s,timestamp:Date.now()};typeof this.vfs.emit=="function"?(this.vfs.emit("mutation",t),this.vfs.emit("change",t)):typeof this.vfs._emit=="function"&&(this.vfs._emit("mutation",t),this.vfs._emit("change",t)),typeof this.options.onFsChange=="function"&&this.options.onFsChange(t)}async evaluateWord(e,s){if(!e)return"";if(typeof e=="string")return e;let t="";for(const r of e.segments)if(r.type==="literal"||r.type==="single_quoted")t+=r.value;else if(r.type==="variable")t+=this._expandVariable(r.name,s);else if(r.type==="arith")t+=ce(r.expr,s,this.env);else if(r.type==="subshell")t+=await this._executeSubshell(r.command,s);else if(r.type==="double_quoted")for(const o of r.parts)o.type==="literal"?t+=o.value:o.type==="variable"?t+=this._expandVariable(o.name,s):o.type==="arith"?t+=ce(o.expr,s,this.env):o.type==="subshell"&&(t+=await this._executeSubshell(o.command,s));return t}async evaluateWordToArgs(e,s){const t=await this.evaluateWord(e,s);return e.hasWildcard?Fe(t,this.cwd,this.vfs):[t]}_expandVariable(e,s){if(e==="?")return s["?"]!==void 0?String(s["?"]):"0";if(e==="$")return"1";if(e==="PWD")return this.cwd;if(e==="OLDPWD")return s.OLDPWD||this.cwd;if(e.startsWith("#")&&e.length>1){const t=e.slice(1),r=s[t]!==void 0?String(s[t]):"";return String(r.length)}if(e.includes(":=")){const t=e.indexOf(":="),r=e.slice(0,t),o=e.slice(t+2);return(s[r]===void 0||s[r]==="")&&(s[r]=o,this.env[r]=o),String(s[r])}if(e.includes(":-")){const t=e.indexOf(":-"),r=e.slice(0,t),o=e.slice(t+2);return s[r]!==void 0&&s[r]!==""?String(s[r]):o}if(e.includes(":+")){const t=e.indexOf(":+"),r=e.slice(0,t),o=e.slice(t+2);return s[r]!==void 0&&s[r]!==""?o:""}if(e.includes("=")){const t=e.indexOf("="),r=e.slice(0,t),o=e.slice(t+1);return s[r]===void 0&&(s[r]=o,this.env[r]=o),String(s[r])}if(e.includes("-")){const t=e.indexOf("-"),r=e.slice(0,t),o=e.slice(t+1);return s[r]!==void 0?String(s[r]):o}return s[e]!==void 0?String(s[e]):""}async _executeSubshell(e,s){const t=new x({...this.options,vfs:this.vfs,portTable:this.portTable,gitState:this.gitState,_initialBootRoot:this._initialBootRoot,_initialBootSnapshot:this._initialBootSnapshot,env:{...s,PWD:this.cwd}});return t.cwd=this.cwd,(await t.execute(e)).stdout.replace(/\r?\n+$/,"")}async execute(e,s={}){const t=(e||"").trim();if(!t||t.startsWith("#"))return{code:0,exitCode:0,stdout:"",stderr:"",ok:!0};if(this.history.push(t),this.history.length>1e3&&this.history.splice(0,this.history.length-1e3),this.jobs.size>256)for(const[l,a]of this.jobs.entries()){if(this.jobs.size<=256)break;a&&a.status!=="Running"&&this.jobs.delete(l)}const r=s.cwd?this.resolvePath(s.cwd):this.cwd;this.cwd=r,this.env.PWD=r;let o=Object.assign({},this.env,s.env||{});const i=Ce(t);let f="",d="",y=0;for(const l of i.items){if(s.signal&&s.signal.aborted)return{code:130,exitCode:130,stdout:f,stderr:d,aborted:!0};if(l.background){const a=this.nextPid++,c=this.nextJobId++,h=typeof AbortController<"u"?new AbortController:null,u={id:c,pid:a,command:t,status:"Running",startTime:Date.now(),abort:()=>{h&&h.abort()}};this.jobs.set(c,u),typeof this.options.onJobStart=="function"&&this.options.onJobStart(u),this._executeAstNode(l.node,{...s,signal:h?h.signal:void 0,env:Object.assign({},this.env,o),cwd:this.cwd,pid:a,isBackground:!0}).then(g=>{u.status!=="Terminated"&&(u.status="Done",u.exitCode=g.code,typeof this.options.onJobEnd=="function"&&this.options.onJobEnd(u))}).catch(g=>{u.status!=="Terminated"&&(u.status="Failed",u.error=g,typeof this.options.onJobEnd=="function"&&this.options.onJobEnd(u))});const p=`[${c}] ${a}
819
- `;f+=p,y=0,s.onStdout&&s.onStdout(p)}else{const a={...s,env:Object.assign({},this.env,o),cwd:this.cwd},c=await this._executeAstNode(l.node,a);if(f+=c.stdout||"",d+=c.stderr||"",y=c.code!==void 0?c.code:0,this.env["?"]=String(y),Object.assign(o,this.env),c.aborted||s.signal&&s.signal.aborted)return{code:130,exitCode:130,stdout:f,stderr:d,aborted:!0};if(c.controlFlow&&c.controlFlow.type==="exit"){y=c.controlFlow.code!==void 0?c.controlFlow.code:y;break}}}return{code:y,exitCode:y,stdout:f,stderr:d,ok:y===0}}async executeCommand(e,s={}){return this.execute(e,s)}async _expandHeredocBody(e,s){const t=String(e||"");let r="",o=0;for(;o<t.length;){const i=t[o];if(i==="\\"&&o+1<t.length&&"$`\\\n".includes(t[o+1])){if(t[o+1]===`
820
- `){o+=2;continue}r+=t[o+1],o+=2;continue}if(i==="$"&&t[o+1]==="("&&t[o+2]==="("){o+=3;let f=2,d="";for(;o<t.length&&f>0;)if(t[o]==="(")f++,d+="(",o++;else if(t[o]===")"){if(f===2&&t[o+1]===")"){f=0,o+=2;break}f--,f>0&&(d+=")"),o++}else d+=t[o++];r+=ce(d,s,this.env);continue}if(i==="$"&&t[o+1]==="("){o+=2;let f=1,d="";for(;o<t.length&&f>0;)t[o]==="("?f++:t[o]===")"&&f--,f>0&&(d+=t[o]),o++;r+=await this._executeSubshell(d,s);continue}if(i==="`"){o++;let f="";for(;o<t.length&&t[o]!=="`";)f+=t[o++];o<t.length&&t[o]==="`"&&o++,r+=await this._executeSubshell(f,s);continue}if(i==="$"){if(o++,t[o]==="{"){o++;let f="",d=1;for(;o<t.length&&d>0;)t[o]==="{"?d++:t[o]==="}"&&d--,d>0&&(f+=t[o]),o++;r+=this._expandVariable(f,s)}else if(o<t.length&&/[0-9?!$#@*]/.test(t[o]))r+=this._expandVariable(t[o++],s);else if(o<t.length&&/[a-zA-Z_]/.test(t[o])){let f="";for(;o<t.length&&/[a-zA-Z0-9_]/.test(t[o]);)f+=t[o++];r+=this._expandVariable(f,s)}else r+="$";continue}r+=i,o++}return r}async _resolveInputRedirect(e,s){if(e.type==="<"){const t=await this.evaluateWord(e.target,s),r=this.resolvePath(t);if(!this.vfs.existsSync(r))return{ok:!1,error:{code:1,stdout:"",stderr:`shell: ${t}: No such file or directory
809
+ `,stderr:""}}return{code:0,stdout:d("OK"),stderr:""}}return{code:1,stdout:"",stderr:`ERR unknown command '${y}'
810
+ `}};class x{constructor(e={}){if(this.options=e,this.portTable=e.portTable||(typeof le=="function"?le():null),this.vfs=e.vfs||Ge(),this.env=Object.assign({PATH:"/workspace/node_modules/.bin:/usr/local/bin:/usr/bin:/bin",PWD:"/workspace",HOME:"/home/codelab",USER:"codelab",SHELL:"/bin/sh",TERM:"xterm-256color","?":"0"},e.env||{}),j._homeDir=this.env.HOME||"/home/codelab",this.cwd=this.env.PWD||"/workspace",this.vfs&&typeof this.vfs._setCwd=="function"&&this.vfs._setCwd(this.cwd),this.vfs&&typeof this.vfs.mkdirSync=="function"&&typeof this.vfs.existsSync=="function"&&this.env.HOME&&!this.vfs.existsSync(this.env.HOME))try{this.vfs.mkdirSync(this.env.HOME,{recursive:!0})}catch(s){}if(e.files&&typeof e.files=="object")for(const[s,t]of Object.entries(e.files)){const r=j.resolve(this.cwd,s);if(typeof this.vfs.mkdirSync=="function"){const o=j.dirname(r);o&&o!=="/"&&(typeof this.vfs.existsSync!="function"||!this.vfs.existsSync(o))&&this.vfs.mkdirSync(o,{recursive:!0})}typeof this.vfs.writeFileSync=="function"&&this.vfs.writeFileSync(r,String(t??""))}this.history=[],this.jobs=new Map,this.nextJobId=1,this.nextPid=100,this.commands=Object.assign({},V,e.commands||{}),this._initialBootRoot=e._initialBootRoot?j.normalize(e._initialBootRoot):j.normalize(this.cwd||"/workspace"),this._initialBootSnapshot=e._initialBootSnapshot&&typeof e._initialBootSnapshot=="object"?e._initialBootSnapshot:L(this.vfs,this._initialBootRoot),e.gitState&&typeof e.gitState=="object"?this.gitState=e.gitState:this.gitState=Ye(this.vfs,this.cwd,e)}resolvePath(e){return j._homeDir=this.env&&this.env.HOME||"/home/codelab",e?j.resolve(this.cwd,e):this.cwd}_resolvePathBinary(e){if(!e||!this.vfs||typeof this.vfs.existsSync!="function")return null;const s=String(e);if(s.includes("/"))return null;const t=j.join(this.cwd||"/workspace","node_modules/.bin",s);if(this.vfs.existsSync(t))return t;const r=String(this.env&&this.env.PATH||"/workspace/node_modules/.bin:/usr/local/bin:/usr/bin:/bin").split(":").filter(Boolean);for(const i of r){const f=j.join(i,s);if(this.vfs.existsSync(f))return f}const o=j.join("/workspace/node_modules/.bin",s);return this.vfs.existsSync(o)?o:null}hasCommand(e){if(!e)return!1;const s=String(e);return this.functions&&Object.prototype.hasOwnProperty.call(this.functions,s)||this.commands&&Object.prototype.hasOwnProperty.call(this.commands,s)?!0:!!this._resolvePathBinary(s)}_emitVfsMutation(e,s){if(!this.vfs)return;const t={type:e,path:s,timestamp:Date.now()};typeof this.vfs.emit=="function"?(this.vfs.emit("mutation",t),this.vfs.emit("change",t)):typeof this.vfs._emit=="function"&&(this.vfs._emit("mutation",t),this.vfs._emit("change",t)),typeof this.options.onFsChange=="function"&&this.options.onFsChange(t)}async evaluateWord(e,s){if(!e)return"";if(typeof e=="string")return e;let t="";for(const r of e.segments)if(r.type==="literal"||r.type==="single_quoted")t+=r.value;else if(r.type==="variable")t+=this._expandVariable(r.name,s);else if(r.type==="arith")t+=ce(r.expr,s,this.env);else if(r.type==="subshell")t+=await this._executeSubshell(r.command,s);else if(r.type==="double_quoted")for(const o of r.parts)o.type==="literal"?t+=o.value:o.type==="variable"?t+=this._expandVariable(o.name,s):o.type==="arith"?t+=ce(o.expr,s,this.env):o.type==="subshell"&&(t+=await this._executeSubshell(o.command,s));return t}async evaluateWordToArgs(e,s){const t=await this.evaluateWord(e,s);return e.hasWildcard?Fe(t,this.cwd,this.vfs):[t]}_expandVariable(e,s){if(e==="?")return s["?"]!==void 0?String(s["?"]):"0";if(e==="$")return"1";if(e==="PWD")return this.cwd;if(e==="OLDPWD")return s.OLDPWD||this.cwd;if(e.startsWith("#")&&e.length>1){const t=e.slice(1),r=s[t]!==void 0?String(s[t]):"";return String(r.length)}if(e.includes(":=")){const t=e.indexOf(":="),r=e.slice(0,t),o=e.slice(t+2);return(s[r]===void 0||s[r]==="")&&(s[r]=o,this.env[r]=o),String(s[r])}if(e.includes(":-")){const t=e.indexOf(":-"),r=e.slice(0,t),o=e.slice(t+2);return s[r]!==void 0&&s[r]!==""?String(s[r]):o}if(e.includes(":+")){const t=e.indexOf(":+"),r=e.slice(0,t),o=e.slice(t+2);return s[r]!==void 0&&s[r]!==""?o:""}if(e.includes("=")){const t=e.indexOf("="),r=e.slice(0,t),o=e.slice(t+1);return s[r]===void 0&&(s[r]=o,this.env[r]=o),String(s[r])}if(e.includes("-")){const t=e.indexOf("-"),r=e.slice(0,t),o=e.slice(t+1);return s[r]!==void 0?String(s[r]):o}return s[e]!==void 0?String(s[e]):""}async _executeSubshell(e,s){const t=new x({...this.options,vfs:this.vfs,portTable:this.portTable,gitState:this.gitState,_initialBootRoot:this._initialBootRoot,_initialBootSnapshot:this._initialBootSnapshot,env:{...s,PWD:this.cwd}});return t.cwd=this.cwd,(await t.execute(e)).stdout.replace(/\r?\n+$/,"")}async execute(e,s={}){const t=(e||"").trim();if(!t||t.startsWith("#"))return{code:0,exitCode:0,stdout:"",stderr:"",ok:!0};if(this.history.push(t),this.history.length>1e3&&this.history.splice(0,this.history.length-1e3),this.jobs.size>256)for(const[l,c]of this.jobs.entries()){if(this.jobs.size<=256)break;c&&c.status!=="Running"&&this.jobs.delete(l)}const r=s.cwd?this.resolvePath(s.cwd):this.cwd;this.cwd=r,this.env.PWD=r;let o=Object.assign({},this.env,s.env||{});const i=Ce(t);let f="",a="",y=0;for(const l of i.items){if(s.signal&&s.signal.aborted)return{code:130,exitCode:130,stdout:f,stderr:a,aborted:!0};if(l.background){const c=this.nextPid++,d=this.nextJobId++,u=typeof AbortController<"u"?new AbortController:null,h={id:d,pid:c,command:t,status:"Running",startTime:Date.now(),abort:()=>{u&&u.abort()}};this.jobs.set(d,h),typeof this.options.onJobStart=="function"&&this.options.onJobStart(h),this._executeAstNode(l.node,{...s,signal:u?u.signal:void 0,env:Object.assign({},this.env,o),cwd:this.cwd,pid:c,isBackground:!0}).then(g=>{h.status!=="Terminated"&&(h.status="Done",h.exitCode=g.code,typeof this.options.onJobEnd=="function"&&this.options.onJobEnd(h))}).catch(g=>{h.status!=="Terminated"&&(h.status="Failed",h.error=g,typeof this.options.onJobEnd=="function"&&this.options.onJobEnd(h))});const p=`[${d}] ${c}
811
+ `;f+=p,y=0,s.onStdout&&s.onStdout(p)}else{const c={...s,env:Object.assign({},this.env,o),cwd:this.cwd},d=await this._executeAstNode(l.node,c);if(f+=d.stdout||"",a+=d.stderr||"",y=d.code!==void 0?d.code:0,this.env["?"]=String(y),Object.assign(o,this.env),d.aborted||s.signal&&s.signal.aborted)return{code:130,exitCode:130,stdout:f,stderr:a,aborted:!0};if(d.controlFlow&&d.controlFlow.type==="exit"){y=d.controlFlow.code!==void 0?d.controlFlow.code:y;break}}}return{code:y,exitCode:y,stdout:f,stderr:a,ok:y===0}}async executeCommand(e,s={}){return this.execute(e,s)}async _expandHeredocBody(e,s){const t=String(e||"");let r="",o=0;for(;o<t.length;){const i=t[o];if(i==="\\"&&o+1<t.length&&"$`\\\n".includes(t[o+1])){if(t[o+1]===`
812
+ `){o+=2;continue}r+=t[o+1],o+=2;continue}if(i==="$"&&t[o+1]==="("&&t[o+2]==="("){o+=3;let f=2,a="";for(;o<t.length&&f>0;)if(t[o]==="(")f++,a+="(",o++;else if(t[o]===")"){if(f===2&&t[o+1]===")"){f=0,o+=2;break}f--,f>0&&(a+=")"),o++}else a+=t[o++];r+=ce(a,s,this.env);continue}if(i==="$"&&t[o+1]==="("){o+=2;let f=1,a="";for(;o<t.length&&f>0;)t[o]==="("?f++:t[o]===")"&&f--,f>0&&(a+=t[o]),o++;r+=await this._executeSubshell(a,s);continue}if(i==="`"){o++;let f="";for(;o<t.length&&t[o]!=="`";)f+=t[o++];o<t.length&&t[o]==="`"&&o++,r+=await this._executeSubshell(f,s);continue}if(i==="$"){if(o++,t[o]==="{"){o++;let f="",a=1;for(;o<t.length&&a>0;)t[o]==="{"?a++:t[o]==="}"&&a--,a>0&&(f+=t[o]),o++;r+=this._expandVariable(f,s)}else if(o<t.length&&/[0-9?!$#@*]/.test(t[o]))r+=this._expandVariable(t[o++],s);else if(o<t.length&&/[a-zA-Z_]/.test(t[o])){let f="";for(;o<t.length&&/[a-zA-Z0-9_]/.test(t[o]);)f+=t[o++];r+=this._expandVariable(f,s)}else r+="$";continue}r+=i,o++}return r}async _resolveInputRedirect(e,s){if(e.type==="<"){const t=await this.evaluateWord(e.target,s),r=this.resolvePath(t);if(!this.vfs.existsSync(r))return{ok:!1,error:{code:1,stdout:"",stderr:`shell: ${t}: No such file or directory
821
813
  `}};try{return{ok:!0,stdin:this.vfs.readFileSync(r,"utf8")}}catch(o){return{ok:!1,error:{code:1,stdout:"",stderr:`shell: ${t}: ${o.message}
822
814
  `}}}}if(e.type==="<<<")return{ok:!0,stdin:await this.evaluateWord(e.target,s)+`
823
- `};if(e.type==="<<"){let t=String(e.body||"");return e.stripTabs&&(t=t.replace(/^\t+/gm,"")),e.quoted||(t=await this._expandHeredocBody(t,s)),{ok:!0,stdin:t}}return null}_evaluateDoubleBracket(e){const s=e.lastIndexOf("]]");if(s===-1)return{code:2,stdout:"",stderr:"shell: [[: missing `]]`\n"};const t=e.slice(0,s);let r=0;const o=a=>{let c="^";for(let h=0;h<a.length;h++){const u=a[h];u==="*"?c+=".*":u==="?"?c+=".":c+=u.replace(/[.+^${}()|[\]\\]/g,"\\$&")}return new RegExp(c+"$")},i=()=>{let a=f();for(;t[r]==="||";){r++;const c=f();a=a||c}return a},f=()=>{let a=d();for(;t[r]==="&&";){r++;const c=d();a=a&&c}return a},d=()=>t[r]==="!"?(r++,!d()):y(),y=()=>{if(r>=t.length)return!1;if(t[r]==="("){r++;const u=i();return t[r]===")"&&r++,u}const a=t[r];if(/^-(?:z|n|e|f|d|s)$/.test(a)&&r+1<t.length){r++;const u=String(t[r++]??"");if(a==="-z")return u.length===0;if(a==="-n")return u.length>0;const p=this.resolvePath(u),g=this.vfs.existsSync(p);if(a==="-e")return g;if(!g)return!1;const m=this.vfs.statSync(p);if(a==="-d")return!!(m&&m.isDirectory());if(a==="-f")return!!(m&&!m.isDirectory());if(a==="-s")return!!(m&&!m.isDirectory()&&m.size>0)}const c=String(t[r++]??""),h=t[r];if(h&&/^(?:==|=|!=|=~|<|>|-eq|-ne|-lt|-le|-gt|-ge)$/.test(h)&&r+1<t.length){r++;const u=String(t[r++]??"");if(h==="=="||h==="=")return o(u).test(c);if(h==="!=")return!o(u).test(c);if(h==="=~")try{return new RegExp(u).test(c)}catch(m){return N.debug("[[ =~ invalid regex",u,m),!1}if(h==="<")return c<u;if(h===">")return c>u;const p=Number(c)||0,g=Number(u)||0;if(h==="-eq")return p===g;if(h==="-ne")return p!==g;if(h==="-lt")return p<g;if(h==="-le")return p<=g;if(h==="-gt")return p>g;if(h==="-ge")return p>=g}return c.length>0};return{code:i()?0:1,stdout:"",stderr:""}}async _executeWithRedirects(e,s,t){if(!e||e.length===0)return t(s);const r=Object.assign({},this.env,s.env);let o={type:"stdout"},i={type:"stderr"},f=s.stdin||"";for(const h of e)if(h.type==="<"||h.type==="<<"||h.type==="<<<"){const u=await this._resolveInputRedirect(h,r);if(u&&!u.ok)return u.error;u&&u.ok&&(f=u.stdin)}for(const h of e)if(!(h.type==="<"||h.type==="<<"||h.type==="<<<"))if(h.type===">"||h.type===">>"||h.type==="&>"){const u=await this.evaluateWord(h.target,r),p=this.resolvePath(u),g=j.dirname(p);if(!this.vfs.existsSync(g))return{code:1,stdout:"",stderr:`shell: ${u}: No such file or directory
824
- `};if(h.type===">"){this.vfs.writeFileSync(p,""),this._emitVfsMutation("create",p);const m={type:"file",path:p,append:!0};h.sourceFd===2?i=m:o=m}else if(h.type===">>"){this.vfs.existsSync(p)||(this.vfs.writeFileSync(p,""),this._emitVfsMutation("create",p));const m={type:"file",path:p,append:!0};h.sourceFd===2?i=m:o=m}else if(h.type==="&>"){this.vfs.writeFileSync(p,""),this._emitVfsMutation("create",p);const m={type:"file",path:p,append:!0};o=m,i=m}}else h.type===">&"&&(h.sourceFd===2&&h.targetFd===1?i={...o}:h.sourceFd===1&&h.targetFd===2&&(o={...i}));let d="",y="";const l=(h,u)=>{u&&(h.type==="stdout"?(d+=u,s.onStdout&&s.onStdout(u)):h.type==="stderr"?(y+=u,s.onStderr&&s.onStderr(u)):h.type==="file"&&(this.vfs.appendFileSync(h.path,u),this._emitVfsMutation("change",h.path)))},a={...s,stdin:f,onStdout:h=>l(o,h),onStderr:h=>l(i,h)};return{...await t(a),stdout:d,stderr:y}}async _executeAstNode(e,s){if(!e)return{code:0,stdout:"",stderr:""};if(s.signal&&s.signal.aborted)return{code:130,stdout:"",stderr:"",aborted:!0};if(e.type==="Sequence"){let t="",r="",o=0,i=null;for(const f of e.items||[]){if(s.signal&&s.signal.aborted)return{code:130,stdout:t,stderr:r,aborted:!0};if(f.background){const d=this.nextPid++,y=this.nextJobId++,l=typeof AbortController<"u"?new AbortController:null,a={id:y,pid:d,command:"background",status:"Running",startTime:Date.now(),abort:()=>{l&&l.abort()}};this.jobs.set(y,a),typeof this.options.onJobStart=="function"&&this.options.onJobStart(a),this._executeAstNode(f.node,{...s,signal:l?l.signal:void 0,pid:d,isBackground:!0}).then(h=>{a.status!=="Terminated"&&(a.status="Done",a.exitCode=h.code,typeof this.options.onJobEnd=="function"&&this.options.onJobEnd(a))}).catch(h=>{a.status!=="Terminated"&&(a.status="Failed",a.error=h,typeof this.options.onJobEnd=="function"&&this.options.onJobEnd(a))});const c=`[${y}] ${d}
825
- `;t+=c,o=0,s.onStdout&&s.onStdout(c)}else{const d=await this._executeAstNode(f.node,s);if(t+=d.stdout||"",r+=d.stderr||"",o=d.code!==void 0?d.code:0,this.env["?"]=String(o),s.env&&(s.env["?"]=String(o)),d.controlFlow){i=d.controlFlow;break}if(d.aborted||s.signal&&s.signal.aborted)return{code:130,stdout:t,stderr:r,aborted:!0}}}return{code:o,stdout:t,stderr:r,controlFlow:i}}if(e.type==="Logical"){const t=await this._executeAstNode(e.left,s);if(t.aborted||s.signal&&s.signal.aborted)return{...t,code:130,aborted:!0};if(t.controlFlow)return t;if(e.op==="&&"){if(t.code===0){const r={...s,cwd:this.cwd,env:Object.assign({},this.env)},o=await this._executeAstNode(e.right,r);return{code:o.code,stdout:(t.stdout||"")+(o.stdout||""),stderr:(t.stderr||"")+(o.stderr||""),controlFlow:o.controlFlow,aborted:o.aborted}}return t}else if(e.op==="||"){if(t.code!==0){const r={...s,cwd:this.cwd,env:Object.assign({},this.env)},o=await this._executeAstNode(e.right,r);return{code:o.code,stdout:(t.stdout||"")+(o.stdout||""),stderr:(t.stderr||"")+(o.stderr||""),controlFlow:o.controlFlow,aborted:o.aborted}}return t}}return e.type==="Pipeline"?this._executePipeline(e,s):e.type==="Command"?this._executeSimpleCommand(e,s):e.type==="FunctionDef"?(this.functions||(this.functions={}),this.functions[e.name]=e,{code:0,stdout:"",stderr:""}):e.type==="For"?this._executeWithRedirects(e.redirects,s,async t=>{let r="",o="",i=0;const f=[];if(e.items)for(const y of e.items){const l=await this.evaluateWordToArgs(y,t.env);f.push(...l)}else f.push(...t.positionalArgs||[]);let d=0;for(const y of f){if(++d%250===0&&typeof setTimeout=="function"&&await new Promise(a=>setTimeout(a,0)),t.signal&&t.signal.aborted)return{code:130,stdout:r,stderr:o,aborted:!0};t.env[e.varName]=y,this.env[e.varName]=y;const l=await this._executeAstNode(e.body,t);if(r+=l.stdout||"",o+=l.stderr||"",i=l.code!==void 0?l.code:0,this.env["?"]=String(i),t.env&&(t.env["?"]=String(i)),l.aborted||t.signal&&t.signal.aborted)return{code:130,stdout:r,stderr:o,aborted:!0};if(l.controlFlow)if(l.controlFlow.type==="break"){const a=l.controlFlow.count||1;if(a>1)return{code:i,stdout:r,stderr:o,controlFlow:{type:"break",count:a-1}};break}else if(l.controlFlow.type==="continue"){const a=l.controlFlow.count||1;if(a>1)return{code:i,stdout:r,stderr:o,controlFlow:{type:"continue",count:a-1}};continue}else return{code:i,stdout:r,stderr:o,controlFlow:l.controlFlow}}return{code:i,stdout:r,stderr:o}}):e.type==="While"||e.type==="Until"?this._executeWithRedirects(e.redirects,s,async t=>{const r=e.type==="While";let o="",i="",f=0,d=0;for(;;){if(++d%250===0&&typeof setTimeout=="function"&&await new Promise(c=>setTimeout(c,0)),t.signal&&t.signal.aborted)return{code:130,stdout:o,stderr:i,aborted:!0};const y=await this._executeAstNode(e.cond,t);if(o+=y.stdout||"",i+=y.stderr||"",y.aborted||t.signal&&t.signal.aborted)return{code:130,stdout:o,stderr:i,aborted:!0};if(y.controlFlow)return{code:y.code,stdout:o,stderr:i,controlFlow:y.controlFlow};const l=y.code===0;if(r?!l:l)break;if(t.signal&&t.signal.aborted)return{code:130,stdout:o,stderr:i,aborted:!0};const a=await this._executeAstNode(e.body,t);if(o+=a.stdout||"",i+=a.stderr||"",f=a.code!==void 0?a.code:0,this.env["?"]=String(f),t.env&&(t.env["?"]=String(f)),a.aborted||t.signal&&t.signal.aborted)return{code:130,stdout:o,stderr:i,aborted:!0};if(a.controlFlow)if(a.controlFlow.type==="break"){const c=a.controlFlow.count||1;if(c>1)return{code:f,stdout:o,stderr:i,controlFlow:{type:"break",count:c-1}};break}else if(a.controlFlow.type==="continue"){const c=a.controlFlow.count||1;if(c>1)return{code:f,stdout:o,stderr:i,controlFlow:{type:"continue",count:c-1}};continue}else return{code:f,stdout:o,stderr:i,controlFlow:a.controlFlow}}return{code:f,stdout:o,stderr:i}}):e.type==="If"?this._executeWithRedirects(e.redirects,s,async t=>{let r="",o="";for(const i of e.branches||[]){if(t.signal&&t.signal.aborted)return{code:130,stdout:r,stderr:o,aborted:!0};const f=await this._executeAstNode(i.cond,t);if(r+=f.stdout||"",o+=f.stderr||"",f.aborted||t.signal&&t.signal.aborted)return{code:130,stdout:r,stderr:o,aborted:!0};if(f.code===0){const d=await this._executeAstNode(i.body,t);return r+=d.stdout||"",o+=d.stderr||"",{code:d.code,stdout:r,stderr:o,controlFlow:d.controlFlow,aborted:d.aborted}}}if(e.elseBody){const i=await this._executeAstNode(e.elseBody,t);return r+=i.stdout||"",o+=i.stderr||"",{code:i.code,stdout:r,stderr:o,controlFlow:i.controlFlow,aborted:i.aborted}}return{code:0,stdout:r,stderr:o}}):e.type==="BraceGroup"?this._executeWithRedirects(e.redirects,s,t=>this._executeAstNode(e.body,t)):e.type==="Subshell"?this._executeWithRedirects(e.redirects,s,async t=>{const r=new x({...this.options,vfs:this.vfs,portTable:this.portTable,gitState:this.gitState,_initialBootRoot:this._initialBootRoot,_initialBootSnapshot:this._initialBootSnapshot,env:Object.assign({},this.env,t.env||{})});r.cwd=t.cwd||this.cwd;const o={...t,env:Object.assign({},this.env,t.env||{}),cwd:r.cwd};return r._executeAstNode(e.body,o)}):e.type==="Case"?this._executeWithRedirects(e.redirects,s,async t=>{const r=await this.evaluateWord(e.word,t.env);for(const o of e.clauses||[]){let i=!1;for(const f of o.patterns||[]){const d=await this.evaluateWord(f,t.env);if(d==="*"||d===r){i=!0;break}if(new RegExp("^"+d.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*").replace(/\?/g,".")+"$").test(r)){i=!0;break}}if(i)return this._executeAstNode(o.body,t)}return{code:0,stdout:"",stderr:""}}):{code:0,stdout:"",stderr:""}}async _executePipeline(e,s){const t=e.commands||[];let r=s.stdin||"",o="",i={code:0,stdout:"",stderr:""};const f=t.length>1,d=this.cwd;for(let l=0;l<t.length;l++){if(s.signal&&s.signal.aborted)return{code:130,stdout:i.stdout||"",stderr:o,aborted:!0};const a=t[l],c=l===t.length-1,h={...s,stdin:r,onStdout:c?s.onStdout:null,onStderr:s.onStderr};let u;if(f){const p=Object.assign({},this.env,s.env||{}),g=new x({...this.options,vfs:this.vfs,portTable:this.portTable,gitState:this.gitState,_initialBootRoot:this._initialBootRoot,_initialBootSnapshot:this._initialBootSnapshot,env:p});g.cwd=s.cwd||d,g.functions=Object.assign({},this.functions||{}),u=await g._executeAstNode(a,{...h,cwd:g.cwd,env:Object.assign({},p)}),this.vfs&&typeof this.vfs._setCwd=="function"&&this.vfs._setCwd(d)}else u=await this._executeAstNode(a,h);if(r=u.stdout||"",o+=u.stderr||"",i=u,u.aborted||s.signal&&s.signal.aborted)return{code:130,stdout:i.stdout||"",stderr:o,aborted:!0}}let y=i.code!==void 0?i.code:0;return e.negated&&!i.aborted&&(y=y===0?1:0),{code:y,stdout:i.stdout||"",stderr:o,controlFlow:i.controlFlow,aborted:!!(i.aborted||s.signal&&s.signal.aborted)}}async _executeSimpleCommand(e,s){const t=Object.assign({},this.env,s.env);for(const m of e.envVars){const S=await this.evaluateWord(m.token,t),b=S.indexOf("=");if(b!==-1){const v=S.slice(0,b),w=S.slice(b+1);t[v]=w,e.name||(this.env[v]=w,s.env[v]=w)}}if(!e.name)return Object.assign(s.env,this.env),{code:0,stdout:"",stderr:""};const r=await this.evaluateWord(e.name,t),o=[];for(const m of e.args){const S=await this.evaluateWordToArgs(m,t);o.push(...S)}if(r===":")return Object.assign(this.env,t),Object.assign(s.env,t),{code:0,stdout:"",stderr:""};if(r==="exit"){const m=o.length>0?parseInt(o[0],10):parseInt(this.env["?"]||"0",10),S=Number.isNaN(m)?2:(m%256+256)%256;return{code:S,stdout:"",stderr:"",controlFlow:{type:"exit",code:S}}}if(r==="[[")return this._evaluateDoubleBracket(o);if(r==="break")return{code:0,stdout:"",stderr:"",controlFlow:{type:"break",count:parseInt(o[0],10)||1}};if(r==="continue")return{code:0,stdout:"",stderr:"",controlFlow:{type:"continue",count:parseInt(o[0],10)||1}};if(r==="return"){const m=parseInt(o[0],10)||0;return{code:m,stdout:"",stderr:"",controlFlow:{type:"return",code:m}}}if(s.signal&&s.signal.aborted)return{code:130,stdout:"",stderr:"",aborted:!0};let i=s.stdin||"";for(const m of e.redirects)if(m.type==="<"||m.type==="<<"||m.type==="<<<"){const S=await this._resolveInputRedirect(m,t);if(S&&!S.ok)return S.error;S&&S.ok&&(i=S.stdin)}let f={type:"stdout"},d={type:"stderr"};for(const m of e.redirects)if(!(m.type==="<"||m.type==="<<"||m.type==="<<<"))if(m.type===">"||m.type===">>"||m.type==="&>"){const S=await this.evaluateWord(m.target,t),b=this.resolvePath(S),v=j.dirname(b);if(!this.vfs.existsSync(v))return{code:1,stdout:"",stderr:`shell: ${S}: No such file or directory
815
+ `};if(e.type==="<<"){let t=String(e.body||"");return e.stripTabs&&(t=t.replace(/^\t+/gm,"")),e.quoted||(t=await this._expandHeredocBody(t,s)),{ok:!0,stdin:t}}return null}_evaluateDoubleBracket(e){const s=e.lastIndexOf("]]");if(s===-1)return{code:2,stdout:"",stderr:"shell: [[: missing `]]`\n"};const t=e.slice(0,s);let r=0;const o=c=>{let d="^";for(let u=0;u<c.length;u++){const h=c[u];h==="*"?d+=".*":h==="?"?d+=".":d+=h.replace(/[.+^${}()|[\]\\]/g,"\\$&")}return new RegExp(d+"$")},i=()=>{let c=f();for(;t[r]==="||";){r++;const d=f();c=c||d}return c},f=()=>{let c=a();for(;t[r]==="&&";){r++;const d=a();c=c&&d}return c},a=()=>t[r]==="!"?(r++,!a()):y(),y=()=>{if(r>=t.length)return!1;if(t[r]==="("){r++;const h=i();return t[r]===")"&&r++,h}const c=t[r];if(/^-(?:z|n|e|f|d|s)$/.test(c)&&r+1<t.length){r++;const h=String(t[r++]??"");if(c==="-z")return h.length===0;if(c==="-n")return h.length>0;const p=this.resolvePath(h),g=this.vfs.existsSync(p);if(c==="-e")return g;if(!g)return!1;const m=this.vfs.statSync(p);if(c==="-d")return!!(m&&m.isDirectory());if(c==="-f")return!!(m&&!m.isDirectory());if(c==="-s")return!!(m&&!m.isDirectory()&&m.size>0)}const d=String(t[r++]??""),u=t[r];if(u&&/^(?:==|=|!=|=~|<|>|-eq|-ne|-lt|-le|-gt|-ge)$/.test(u)&&r+1<t.length){r++;const h=String(t[r++]??"");if(u==="=="||u==="=")return o(h).test(d);if(u==="!=")return!o(h).test(d);if(u==="=~")try{return new RegExp(h).test(d)}catch(m){return _.debug("[[ =~ invalid regex",h,m),!1}if(u==="<")return d<h;if(u===">")return d>h;const p=Number(d)||0,g=Number(h)||0;if(u==="-eq")return p===g;if(u==="-ne")return p!==g;if(u==="-lt")return p<g;if(u==="-le")return p<=g;if(u==="-gt")return p>g;if(u==="-ge")return p>=g}return d.length>0};return{code:i()?0:1,stdout:"",stderr:""}}async _executeWithRedirects(e,s,t){if(!e||e.length===0)return t(s);const r=Object.assign({},this.env,s.env);let o={type:"stdout"},i={type:"stderr"},f=s.stdin||"";for(const u of e)if(u.type==="<"||u.type==="<<"||u.type==="<<<"){const h=await this._resolveInputRedirect(u,r);if(h&&!h.ok)return h.error;h&&h.ok&&(f=h.stdin)}for(const u of e)if(!(u.type==="<"||u.type==="<<"||u.type==="<<<"))if(u.type===">"||u.type===">>"||u.type==="&>"){const h=await this.evaluateWord(u.target,r),p=this.resolvePath(h),g=j.dirname(p);if(!this.vfs.existsSync(g))return{code:1,stdout:"",stderr:`shell: ${h}: No such file or directory
816
+ `};if(u.type===">"){this.vfs.writeFileSync(p,""),this._emitVfsMutation("create",p);const m={type:"file",path:p,append:!0};u.sourceFd===2?i=m:o=m}else if(u.type===">>"){this.vfs.existsSync(p)||(this.vfs.writeFileSync(p,""),this._emitVfsMutation("create",p));const m={type:"file",path:p,append:!0};u.sourceFd===2?i=m:o=m}else if(u.type==="&>"){this.vfs.writeFileSync(p,""),this._emitVfsMutation("create",p);const m={type:"file",path:p,append:!0};o=m,i=m}}else u.type===">&"&&(u.sourceFd===2&&u.targetFd===1?i={...o}:u.sourceFd===1&&u.targetFd===2&&(o={...i}));let a="",y="";const l=(u,h)=>{h&&(u.type==="stdout"?(a+=h,s.onStdout&&s.onStdout(h)):u.type==="stderr"?(y+=h,s.onStderr&&s.onStderr(h)):u.type==="file"&&(this.vfs.appendFileSync(u.path,h),this._emitVfsMutation("change",u.path)))},c={...s,stdin:f,onStdout:u=>l(o,u),onStderr:u=>l(i,u)};return{...await t(c),stdout:a,stderr:y}}async _executeAstNode(e,s){if(!e)return{code:0,stdout:"",stderr:""};if(s.signal&&s.signal.aborted)return{code:130,stdout:"",stderr:"",aborted:!0};if(e.type==="Sequence"){let t="",r="",o=0,i=null;for(const f of e.items||[]){if(s.signal&&s.signal.aborted)return{code:130,stdout:t,stderr:r,aborted:!0};if(f.background){const a=this.nextPid++,y=this.nextJobId++,l=typeof AbortController<"u"?new AbortController:null,c={id:y,pid:a,command:"background",status:"Running",startTime:Date.now(),abort:()=>{l&&l.abort()}};this.jobs.set(y,c),typeof this.options.onJobStart=="function"&&this.options.onJobStart(c),this._executeAstNode(f.node,{...s,signal:l?l.signal:void 0,pid:a,isBackground:!0}).then(u=>{c.status!=="Terminated"&&(c.status="Done",c.exitCode=u.code,typeof this.options.onJobEnd=="function"&&this.options.onJobEnd(c))}).catch(u=>{c.status!=="Terminated"&&(c.status="Failed",c.error=u,typeof this.options.onJobEnd=="function"&&this.options.onJobEnd(c))});const d=`[${y}] ${a}
817
+ `;t+=d,o=0,s.onStdout&&s.onStdout(d)}else{const a=await this._executeAstNode(f.node,s);if(t+=a.stdout||"",r+=a.stderr||"",o=a.code!==void 0?a.code:0,this.env["?"]=String(o),s.env&&(s.env["?"]=String(o)),a.controlFlow){i=a.controlFlow;break}if(a.aborted||s.signal&&s.signal.aborted)return{code:130,stdout:t,stderr:r,aborted:!0}}}return{code:o,stdout:t,stderr:r,controlFlow:i}}if(e.type==="Logical"){const t=await this._executeAstNode(e.left,s);if(t.aborted||s.signal&&s.signal.aborted)return{...t,code:130,aborted:!0};if(t.controlFlow)return t;if(e.op==="&&"){if(t.code===0){const r={...s,cwd:this.cwd,env:Object.assign({},this.env)},o=await this._executeAstNode(e.right,r);return{code:o.code,stdout:(t.stdout||"")+(o.stdout||""),stderr:(t.stderr||"")+(o.stderr||""),controlFlow:o.controlFlow,aborted:o.aborted}}return t}else if(e.op==="||"){if(t.code!==0){const r={...s,cwd:this.cwd,env:Object.assign({},this.env)},o=await this._executeAstNode(e.right,r);return{code:o.code,stdout:(t.stdout||"")+(o.stdout||""),stderr:(t.stderr||"")+(o.stderr||""),controlFlow:o.controlFlow,aborted:o.aborted}}return t}}return e.type==="Pipeline"?this._executePipeline(e,s):e.type==="Command"?this._executeSimpleCommand(e,s):e.type==="FunctionDef"?(this.functions||(this.functions={}),this.functions[e.name]=e,{code:0,stdout:"",stderr:""}):e.type==="For"?this._executeWithRedirects(e.redirects,s,async t=>{let r="",o="",i=0;const f=[];if(e.items)for(const y of e.items){const l=await this.evaluateWordToArgs(y,t.env);f.push(...l)}else f.push(...t.positionalArgs||[]);let a=0;for(const y of f){if(++a%250===0&&typeof setTimeout=="function"&&await new Promise(c=>setTimeout(c,0)),t.signal&&t.signal.aborted)return{code:130,stdout:r,stderr:o,aborted:!0};t.env[e.varName]=y,this.env[e.varName]=y;const l=await this._executeAstNode(e.body,t);if(r+=l.stdout||"",o+=l.stderr||"",i=l.code!==void 0?l.code:0,this.env["?"]=String(i),t.env&&(t.env["?"]=String(i)),l.aborted||t.signal&&t.signal.aborted)return{code:130,stdout:r,stderr:o,aborted:!0};if(l.controlFlow)if(l.controlFlow.type==="break"){const c=l.controlFlow.count||1;if(c>1)return{code:i,stdout:r,stderr:o,controlFlow:{type:"break",count:c-1}};break}else if(l.controlFlow.type==="continue"){const c=l.controlFlow.count||1;if(c>1)return{code:i,stdout:r,stderr:o,controlFlow:{type:"continue",count:c-1}};continue}else return{code:i,stdout:r,stderr:o,controlFlow:l.controlFlow}}return{code:i,stdout:r,stderr:o}}):e.type==="While"||e.type==="Until"?this._executeWithRedirects(e.redirects,s,async t=>{const r=e.type==="While";let o="",i="",f=0,a=0;for(;;){if(++a%250===0&&typeof setTimeout=="function"&&await new Promise(d=>setTimeout(d,0)),t.signal&&t.signal.aborted)return{code:130,stdout:o,stderr:i,aborted:!0};const y=await this._executeAstNode(e.cond,t);if(o+=y.stdout||"",i+=y.stderr||"",y.aborted||t.signal&&t.signal.aborted)return{code:130,stdout:o,stderr:i,aborted:!0};if(y.controlFlow)return{code:y.code,stdout:o,stderr:i,controlFlow:y.controlFlow};const l=y.code===0;if(r?!l:l)break;if(t.signal&&t.signal.aborted)return{code:130,stdout:o,stderr:i,aborted:!0};const c=await this._executeAstNode(e.body,t);if(o+=c.stdout||"",i+=c.stderr||"",f=c.code!==void 0?c.code:0,this.env["?"]=String(f),t.env&&(t.env["?"]=String(f)),c.aborted||t.signal&&t.signal.aborted)return{code:130,stdout:o,stderr:i,aborted:!0};if(c.controlFlow)if(c.controlFlow.type==="break"){const d=c.controlFlow.count||1;if(d>1)return{code:f,stdout:o,stderr:i,controlFlow:{type:"break",count:d-1}};break}else if(c.controlFlow.type==="continue"){const d=c.controlFlow.count||1;if(d>1)return{code:f,stdout:o,stderr:i,controlFlow:{type:"continue",count:d-1}};continue}else return{code:f,stdout:o,stderr:i,controlFlow:c.controlFlow}}return{code:f,stdout:o,stderr:i}}):e.type==="If"?this._executeWithRedirects(e.redirects,s,async t=>{let r="",o="";for(const i of e.branches||[]){if(t.signal&&t.signal.aborted)return{code:130,stdout:r,stderr:o,aborted:!0};const f=await this._executeAstNode(i.cond,t);if(r+=f.stdout||"",o+=f.stderr||"",f.aborted||t.signal&&t.signal.aborted)return{code:130,stdout:r,stderr:o,aborted:!0};if(f.code===0){const a=await this._executeAstNode(i.body,t);return r+=a.stdout||"",o+=a.stderr||"",{code:a.code,stdout:r,stderr:o,controlFlow:a.controlFlow,aborted:a.aborted}}}if(e.elseBody){const i=await this._executeAstNode(e.elseBody,t);return r+=i.stdout||"",o+=i.stderr||"",{code:i.code,stdout:r,stderr:o,controlFlow:i.controlFlow,aborted:i.aborted}}return{code:0,stdout:r,stderr:o}}):e.type==="BraceGroup"?this._executeWithRedirects(e.redirects,s,t=>this._executeAstNode(e.body,t)):e.type==="Subshell"?this._executeWithRedirects(e.redirects,s,async t=>{const r=new x({...this.options,vfs:this.vfs,portTable:this.portTable,gitState:this.gitState,_initialBootRoot:this._initialBootRoot,_initialBootSnapshot:this._initialBootSnapshot,env:Object.assign({},this.env,t.env||{})});r.cwd=t.cwd||this.cwd;const o={...t,env:Object.assign({},this.env,t.env||{}),cwd:r.cwd};return r._executeAstNode(e.body,o)}):e.type==="Case"?this._executeWithRedirects(e.redirects,s,async t=>{const r=await this.evaluateWord(e.word,t.env);for(const o of e.clauses||[]){let i=!1;for(const f of o.patterns||[]){const a=await this.evaluateWord(f,t.env);if(a==="*"||a===r){i=!0;break}if(new RegExp("^"+a.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*").replace(/\?/g,".")+"$").test(r)){i=!0;break}}if(i)return this._executeAstNode(o.body,t)}return{code:0,stdout:"",stderr:""}}):{code:0,stdout:"",stderr:""}}async _executePipeline(e,s){const t=e.commands||[];let r=s.stdin||"",o="",i={code:0,stdout:"",stderr:""};const f=t.length>1,a=this.cwd;for(let l=0;l<t.length;l++){if(s.signal&&s.signal.aborted)return{code:130,stdout:i.stdout||"",stderr:o,aborted:!0};const c=t[l],d=l===t.length-1,u={...s,stdin:r,onStdout:d?s.onStdout:null,onStderr:s.onStderr};let h;if(f){const p=Object.assign({},this.env,s.env||{}),g=new x({...this.options,vfs:this.vfs,portTable:this.portTable,gitState:this.gitState,_initialBootRoot:this._initialBootRoot,_initialBootSnapshot:this._initialBootSnapshot,env:p});g.cwd=s.cwd||a,g.functions=Object.assign({},this.functions||{}),h=await g._executeAstNode(c,{...u,cwd:g.cwd,env:Object.assign({},p)}),this.vfs&&typeof this.vfs._setCwd=="function"&&this.vfs._setCwd(a)}else h=await this._executeAstNode(c,u);if(r=h.stdout||"",o+=h.stderr||"",i=h,h.aborted||s.signal&&s.signal.aborted)return{code:130,stdout:i.stdout||"",stderr:o,aborted:!0}}let y=i.code!==void 0?i.code:0;return e.negated&&!i.aborted&&(y=y===0?1:0),{code:y,stdout:i.stdout||"",stderr:o,controlFlow:i.controlFlow,aborted:!!(i.aborted||s.signal&&s.signal.aborted)}}async _executeSimpleCommand(e,s){const t=Object.assign({},this.env,s.env);for(const m of e.envVars){const S=await this.evaluateWord(m.token,t),b=S.indexOf("=");if(b!==-1){const v=S.slice(0,b),w=S.slice(b+1);t[v]=w,e.name||(this.env[v]=w,s.env[v]=w)}}if(!e.name)return Object.assign(s.env,this.env),{code:0,stdout:"",stderr:""};const r=await this.evaluateWord(e.name,t),o=[];for(const m of e.args){const S=await this.evaluateWordToArgs(m,t);o.push(...S)}if(r===":")return Object.assign(this.env,t),Object.assign(s.env,t),{code:0,stdout:"",stderr:""};if(r==="exit"){const m=o.length>0?parseInt(o[0],10):parseInt(this.env["?"]||"0",10),S=Number.isNaN(m)?2:(m%256+256)%256;return{code:S,stdout:"",stderr:"",controlFlow:{type:"exit",code:S}}}if(r==="[[")return this._evaluateDoubleBracket(o);if(r==="break")return{code:0,stdout:"",stderr:"",controlFlow:{type:"break",count:parseInt(o[0],10)||1}};if(r==="continue")return{code:0,stdout:"",stderr:"",controlFlow:{type:"continue",count:parseInt(o[0],10)||1}};if(r==="return"){const m=parseInt(o[0],10)||0;return{code:m,stdout:"",stderr:"",controlFlow:{type:"return",code:m}}}if(s.signal&&s.signal.aborted)return{code:130,stdout:"",stderr:"",aborted:!0};let i=s.stdin||"";for(const m of e.redirects)if(m.type==="<"||m.type==="<<"||m.type==="<<<"){const S=await this._resolveInputRedirect(m,t);if(S&&!S.ok)return S.error;S&&S.ok&&(i=S.stdin)}let f={type:"stdout"},a={type:"stderr"};for(const m of e.redirects)if(!(m.type==="<"||m.type==="<<"||m.type==="<<<"))if(m.type===">"||m.type===">>"||m.type==="&>"){const S=await this.evaluateWord(m.target,t),b=this.resolvePath(S),v=j.dirname(b);if(!this.vfs.existsSync(v))return{code:1,stdout:"",stderr:`shell: ${S}: No such file or directory
826
818
  `};if(!this.vfs.statSync(v).isDirectory())return{code:1,stdout:"",stderr:`shell: ${S}: Not a directory
827
819
  `};if(this.vfs.existsSync(b)&&this.vfs.statSync(b).isDirectory())return{code:1,stdout:"",stderr:`shell: ${S}: Is a directory
828
- `};if(m.type===">"){this.vfs.writeFileSync(b,""),this._emitVfsMutation("create",b);const $={type:"file",path:b,append:!0};m.sourceFd===2?d=$:f=$}else if(m.type===">>"){this.vfs.existsSync(b)||(this.vfs.writeFileSync(b,""),this._emitVfsMutation("create",b));const $={type:"file",path:b,append:!0};m.sourceFd===2?d=$:f=$}else if(m.type==="&>"){this.vfs.writeFileSync(b,""),this._emitVfsMutation("create",b);const $={type:"file",path:b,append:!0};f=$,d=$}}else m.type===">&"&&(m.sourceFd===2&&m.targetFd===1?d={...f}:m.sourceFd===1&&m.targetFd===2&&(f={...d}));let y="",l="",a=0,c=0;const h=(m,S,b=!1)=>{S&&(m.type==="stdout"?(y+=S,b&&s.onStdout&&s.onStdout(S)):m.type==="stderr"?(l+=S,b&&s.onStderr&&s.onStderr(S)):m.type==="file"&&(this.vfs.appendFileSync(m.path,S),this._emitVfsMutation("change",m.path)))},u={vfs:this.vfs,shell:this,portTable:this.portTable,cwd:this.cwd,env:t,stdin:i,pid:s.pid||1e3,isBackground:!!s.isBackground,resolvePath:m=>this.resolvePath(m),emitMutation:(m,S)=>this._emitVfsMutation(m,S),signal:s.signal,onRequestStdin:(typeof s.onRequestStdin=="function"?s.onRequestStdin:null)||(this.options&&typeof this.options.onRequestStdin=="function"?this.options.onRequestStdin:void 0),onStdout:m=>{m&&(a+=m.length,h(f,m,!0))},onStderr:m=>{m&&(c+=m.length,h(d,m,!0))}};let p;const g=!(this.functions&&this.functions[r])&&!this.commands[r]?this._resolvePathBinary(r):null;if(this.functions&&this.functions[r]){const m=this.functions[r],S=Object.assign({},t);o.forEach((v,w)=>{S[String(w+1)]=v}),S["#"]=String(o.length),S["@"]=o.join(" "),S["*"]=o.join(" ");const b=await this._executeAstNode(m.body,{...s,env:S,positionalArgs:o});p={code:b.controlFlow?.type==="return"?b.controlFlow.code:b.code||0,stdout:b.stdout||"",stderr:b.stderr||""}}else if(this.commands[r]){if(p=await this.commands[r](o,u),r==="export"||r==="unset"||r==="cd"||r==="read"){for(const m of Object.keys(s.env))/^(\d+|#|@|\*)$/.test(m)||m in this.env||delete s.env[m];Object.assign(s.env,this.env),s.cwd=this.cwd}}else if(g){const S=String(this.vfs.readFileSync(g,"utf8")||"").match(/exec\s+node\s+"([^"]+)"/);S&&S[1]?p=await this.commands.node([S[1],...o],u):p=await this.commands.node([g,...o],u)}else if((r.startsWith("./")||r.startsWith("../")||r.startsWith("/"))&&this.vfs.existsSync(this.resolvePath(r))){const m=this.resolvePath(r),S=this.vfs.statSync(m);if(S&&S.isDirectory())p={code:126,stdout:"",stderr:`shell: ${r}: Is a directory
829
- `};else if(Re()){let b=null;try{b=typeof this.vfs._getRawFileBytes=="function"?this.vfs._getRawFileBytes(m)||this.vfs.readFileSync(m):this.vfs.readFileSync(m)}catch(R){N.debug("Failed to read binary",R)}const v=b instanceof Uint8Array&&b.length>=4&&b[0]===0&&b[1]===97&&b[2]===115&&b[3]===109||typeof b=="string"&&b.startsWith("\0asm"),$=await(v?Oe:R=>q(R,u))({mode:"run",entry:m,wasmBinary:v&&b instanceof Uint8Array?b:void 0,argv:[r,...o],stdin:i,env:t,cwd:this.cwd,vfs:this.vfs,activePortTable:this.portTable,pid:u.pid,isBackground:u.isBackground,onRequestStdin:u.onRequestStdin,onStdout:u.onStdout,onStderr:u.onStderr,signal:s.signal});p={code:$.ok?0:$.exitCode||1,stdout:$.stdout||"",stderr:$.stderr||""}}else p={code:126,stdout:"",stderr:`shell: ${r}: cannot execute binary file
830
- `}}else if(kt.test(r))p=await Ve(r,[r,...o].join(" "),u,{force:!0})||{code:127,stdout:"",stderr:`shell: ${r}: command not found
831
- `};else if(typeof this.options.onProcessSpawn=="function"){const m=await this.options.onProcessSpawn(r,o,{cwd:this.cwd,env:t,stdin:i,onStdout:u.onStdout,onStderr:u.onStderr,signal:s.signal});m!=null?p=m:p={code:127,stdout:"",stderr:`shell: ${r}: command not found
820
+ `};if(m.type===">"){this.vfs.writeFileSync(b,""),this._emitVfsMutation("create",b);const $={type:"file",path:b,append:!0};m.sourceFd===2?a=$:f=$}else if(m.type===">>"){this.vfs.existsSync(b)||(this.vfs.writeFileSync(b,""),this._emitVfsMutation("create",b));const $={type:"file",path:b,append:!0};m.sourceFd===2?a=$:f=$}else if(m.type==="&>"){this.vfs.writeFileSync(b,""),this._emitVfsMutation("create",b);const $={type:"file",path:b,append:!0};f=$,a=$}}else m.type===">&"&&(m.sourceFd===2&&m.targetFd===1?a={...f}:m.sourceFd===1&&m.targetFd===2&&(f={...a}));let y="",l="",c=0,d=0;const u=(m,S,b=!1)=>{S&&(m.type==="stdout"?(y+=S,b&&s.onStdout&&s.onStdout(S)):m.type==="stderr"?(l+=S,b&&s.onStderr&&s.onStderr(S)):m.type==="file"&&(this.vfs.appendFileSync(m.path,S),this._emitVfsMutation("change",m.path)))},h={vfs:this.vfs,shell:this,portTable:this.portTable,cwd:this.cwd,env:t,stdin:i,pid:s.pid||1e3,isBackground:!!s.isBackground,resolvePath:m=>this.resolvePath(m),emitMutation:(m,S)=>this._emitVfsMutation(m,S),signal:s.signal,onRequestStdin:(typeof s.onRequestStdin=="function"?s.onRequestStdin:null)||(this.options&&typeof this.options.onRequestStdin=="function"?this.options.onRequestStdin:void 0),onStdout:m=>{m&&(c+=m.length,u(f,m,!0))},onStderr:m=>{m&&(d+=m.length,u(a,m,!0))}};let p;const g=!(this.functions&&this.functions[r])&&!this.commands[r]?this._resolvePathBinary(r):null;if(this.functions&&this.functions[r]){const m=this.functions[r],S=Object.assign({},t);o.forEach((v,w)=>{S[String(w+1)]=v}),S["#"]=String(o.length),S["@"]=o.join(" "),S["*"]=o.join(" ");const b=await this._executeAstNode(m.body,{...s,env:S,positionalArgs:o});p={code:b.controlFlow?.type==="return"?b.controlFlow.code:b.code||0,stdout:b.stdout||"",stderr:b.stderr||""}}else if(this.commands[r]){if(p=await this.commands[r](o,h),r==="export"||r==="unset"||r==="cd"||r==="read"){for(const m of Object.keys(s.env))/^(\d+|#|@|\*)$/.test(m)||m in this.env||delete s.env[m];Object.assign(s.env,this.env),s.cwd=this.cwd}}else if(g){const S=String(this.vfs.readFileSync(g,"utf8")||"").match(/exec\s+node\s+"([^"]+)"/);S&&S[1]?p=await this.commands.node([S[1],...o],h):p=await this.commands.node([g,...o],h)}else if((r.startsWith("./")||r.startsWith("../")||r.startsWith("/"))&&this.vfs.existsSync(this.resolvePath(r))){const m=this.resolvePath(r),S=this.vfs.statSync(m);if(S&&S.isDirectory())p={code:126,stdout:"",stderr:`shell: ${r}: Is a directory
821
+ `};else if(Re()){let b=null;try{b=typeof this.vfs._getRawFileBytes=="function"?this.vfs._getRawFileBytes(m)||this.vfs.readFileSync(m):this.vfs.readFileSync(m)}catch(R){_.debug("Failed to read binary",R)}const v=b instanceof Uint8Array&&b.length>=4&&b[0]===0&&b[1]===97&&b[2]===115&&b[3]===109||typeof b=="string"&&b.startsWith("\0asm"),$=await(v?Oe:R=>q(R,h))({mode:"run",entry:m,wasmBinary:v&&b instanceof Uint8Array?b:void 0,argv:[r,...o],stdin:i,env:t,cwd:this.cwd,vfs:this.vfs,activePortTable:this.portTable,pid:h.pid,isBackground:h.isBackground,onRequestStdin:h.onRequestStdin,onStdout:h.onStdout,onStderr:h.onStderr,signal:s.signal});p={code:$.ok?0:$.exitCode||1,stdout:$.stdout||"",stderr:$.stderr||""}}else p={code:126,stdout:"",stderr:`shell: ${r}: cannot execute binary file
822
+ `}}else if(kt.test(r))p=await Le(r,[r,...o].join(" "),h,{force:!0})||{code:127,stdout:"",stderr:`shell: ${r}: command not found
823
+ `};else if(typeof this.options.onProcessSpawn=="function"){const m=await this.options.onProcessSpawn(r,o,{cwd:this.cwd,env:t,stdin:i,onStdout:h.onStdout,onStderr:h.onStderr,signal:s.signal});m!=null?p=m:p={code:127,stdout:"",stderr:`shell: ${r}: command not found
832
824
  `}}else p={code:127,stdout:"",stderr:`shell: ${r}: command not found
833
- `};return p||(p={code:0,stdout:"",stderr:""}),p.stdout&&(p.alreadyStreamed?y=p.stdout:a>0?p.stdout.length>a&&h(f,p.stdout.slice(a),!0):(h(f,p.stdout,!1),s.onStdout&&y&&s.onStdout(y))),p.stderr&&(c>0?p.stderr.length>c&&h(d,p.stderr.slice(c),!0):(h(d,p.stderr,!1),s.onStderr&&l&&s.onStderr(l))),{code:p.code!==void 0?p.code:0,stdout:y,stderr:l,controlFlow:p.controlFlow,aborted:p.aborted||s.signal&&s.signal.aborted}}}function jt(n={}){return new x(n)}return{createPosixShell:jt,parseShellCommand:Ce,tokenizeShell:Te,PosixShell:x,COREUTILS:V,PosixPath:j,expandGlob:Fe,createVirtualPortTable:le,parseGitHubRepoUrl:fe,cloneGitHubRepository:he}});
825
+ `};return p||(p={code:0,stdout:"",stderr:""}),p.stdout&&(p.alreadyStreamed?y=p.stdout:c>0?p.stdout.length>c&&u(f,p.stdout.slice(c),!0):(u(f,p.stdout,!1),s.onStdout&&y&&s.onStdout(y))),p.stderr&&(d>0?p.stderr.length>d&&u(a,p.stderr.slice(d),!0):(u(a,p.stderr,!1),s.onStderr&&l&&s.onStderr(l))),{code:p.code!==void 0?p.code:0,stdout:y,stderr:l,controlFlow:p.controlFlow,aborted:p.aborted||s.signal&&s.signal.aborted}}}function jt(n={}){return new x(n)}return{createPosixShell:jt,parseShellCommand:Ce,tokenizeShell:Te,PosixShell:x,COREUTILS:V,PosixPath:j,expandGlob:Fe,createVirtualPortTable:le,parseGitHubRepoUrl:fe,cloneGitHubRepository:he}});
834
826
 
835
827
  })();
836
828