@gjsify/tsc 0.36.0 → 0.38.0
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.
- package/dist/tsc.gjs.mjs +2 -2
- package/package.json +6 -6
package/dist/tsc.gjs.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env -S gjs -m
|
|
2
|
-
if(globalThis.__gjsifyBundleUrl??=import.meta.url,Symbol.dispose||(Symbol.dispose=Symbol.for(`Symbol.dispose`)),Symbol.asyncDispose||(Symbol.asyncDispose=Symbol.for(`Symbol.asyncDispose`)),globalThis.process===void 0){let e=globalThis.imports.system,t=globalThis.imports.gi.GLib,_h=e=>[0,0];_h.bigint=()=>0n,
|
|
2
|
+
if(globalThis.__gjsifyBundleUrl??=import.meta.url,Symbol.dispose||(Symbol.dispose=Symbol.for(`Symbol.dispose`)),Symbol.asyncDispose||(Symbol.asyncDispose=Symbol.for(`Symbol.asyncDispose`)),globalThis.process===void 0){let e=globalThis.imports.system,t=globalThis.imports.gi.GLib,_h=e=>[0,0];_h.bigint=()=>0n;let n,_p=()=>{if(n)return n;n={platform:`linux`,arch:`x64`};try{if(t.getenv(`OS`)===`Windows_NT`||t.getenv(`SystemRoot`)){let e=(t.getenv(`PROCESSOR_ARCHITECTURE`)||``).toLowerCase();return n={platform:`win32`,arch:e===`arm64`?`arm64`:e===`x86`?`ia32`:`x64`},n}let e=t.spawn_sync(null,[`uname`,`-sm`],null,t.SpawnFlags.SEARCH_PATH,null);if(e&&e[0]&&e[1]){let t=new TextDecoder().decode(e[1]).trim().split(/\s+/);if(t.length>1){let e=t[0],r=t[t.length-1].toLowerCase();n={platform:e===`Linux`?`linux`:e===`Darwin`?`darwin`:/^CYGWIN/i.test(e)?`cygwin`:/^(MINGW|MSYS|Windows)/i.test(e)?`win32`:e.toLowerCase(),arch:r===`x86_64`||r===`amd64`?`x64`:r===`aarch64`||r===`arm64`?`arm64`:/^i[3-6]86$/.test(r)?`ia32`:r.startsWith(`arm`)?`arm`:r}}}}catch{}return n};globalThis.process={get platform(){return _p().platform},get arch(){return _p().arch},version:`v20.0.0`,env:new Proxy({},{get(e,n){return typeof n==`string`?t.getenv(n)??void 0:void 0},set(e,n,r){return typeof n==`string`&&t.setenv(n,String(r),!0),!0},has(e,n){return typeof n==`string`&&t.getenv(n)!==null},deleteProperty(e,n){return typeof n==`string`&&t.unsetenv(n),!0},ownKeys(){return t.listenv()??[]},getOwnPropertyDescriptor(e,n){let r=t.getenv(n);return r===null?void 0:{value:r,writable:!0,enumerable:!0,configurable:!0}}}),argv:e?.programArgs?[`gjs`,e.programInvocationName||``,...e.programArgs]:[`gjs`],versions:{},config:{},cwd(){return t.get_current_dir()||`/`},exit(t){e.exit(t??0)},stderr:{write(e){globalThis.printerr(e)}},stdout:{write(e){globalThis.print(e)}},stdin:null,exitCode:void 0,nextTick(e,...t){Promise.resolve().then(()=>e(...t))},hrtime:_h}}import e from"gi://GLib?version=2.0";import t from"gi://Gio?version=2.0";import n from"gi://GioUnix?version=2.0";import"system";var r=Object.defineProperty,__name=(e,t)=>r(e,`name`,{value:t,configurable:!0}),i=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,__esmMin=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(e){throw n=[e],e}},__exportAll$2=(e,t)=>{let n={};for(var i in e)r(n,i,{get:e[i],enumerable:!0});return t||r(n,Symbol.toStringTag,{value:`Module`}),n},__copyProps=(e,t,n,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var c=a(t),l=0,u=c.length,d;l<u;l++)d=c[l],!o.call(e,d)&&d!==n&&r(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(s=i(t,d))||s.enumerable});return e},__toCommonJS=e=>o.call(e,`module.exports`)?e[`module.exports`]:__copyProps(r({},`__esModule`,{value:!0}),e),s=(e=>typeof require<`u`?require:typeof Proxy<`u`?new Proxy(e,{get:(e,t)=>(typeof require<`u`?require:e)[t]}):e)(function(e){if(typeof require<`u`)return require.apply(this,arguments);throw Error('Calling `require` for "'+e+"\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.")}),c,_encoder,l,FilePolyfill,u,d,f=__esmMin(()=>{_encoder=()=>c??=new TextEncoder,l=class BlobPolyfill{_parts;size;type;constructor(e,t){this._parts=e||[],this.type=t?.type||``,this.size=this._parts.reduce((e,t)=>typeof t==`string`?e+_encoder().encode(t).byteLength:t instanceof ArrayBuffer||ArrayBuffer.isView(t)?e+t.byteLength:t&&typeof t.size==`number`?e+t.size:e,0)}async bytes(){let e=await this.arrayBuffer();return new Uint8Array(e)}async text(){return new TextDecoder().decode(await this.arrayBuffer())}async arrayBuffer(){let e=[];for(let t of this._parts)if(typeof t==`string`)e.push(_encoder().encode(t));else if(t instanceof ArrayBuffer)e.push(new Uint8Array(t));else if(ArrayBuffer.isView(t))e.push(new Uint8Array(t.buffer,t.byteOffset,t.byteLength));else if(t&&typeof t.arrayBuffer==`function`){let n=await t.arrayBuffer();e.push(new Uint8Array(n))}let t=e.reduce((e,t)=>e+t.byteLength,0),n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.byteLength;return n.buffer}slice(e,t,n){return new BlobPolyfill([],{type:n})}stream(){let e=this;return new ReadableStream({async pull(t){let n=await e.arrayBuffer();t.enqueue(new Uint8Array(n)),t.close()}})}},FilePolyfill=class extends l{name;lastModified;webkitRelativePath=``;constructor(e,t,n){super(e,n),this.name=t,this.lastModified=n?.lastModified??Date.now()}},u=globalThis.Blob??l,d=globalThis.File??FilePolyfill});function makeCallable(e){return new Proxy(e,{apply(e,t,n){if(t==null||t===globalThis)return Reflect.construct(e,n,e);let r=Reflect.construct(e,n,e);for(let e of Reflect.ownKeys(r)){let n=Object.getOwnPropertyDescriptor(r,e);n&&Object.defineProperty(t,e,n)}return t}})}var p=__esmMin(()=>{}),initErrorV8Methods,m=__esmMin(()=>{initErrorV8Methods=e=>{let t=Error;t.captureStackTrace||=function(e,t){let n=Error();Object.defineProperty(t||e,"stack",{configurable:!0,get:function getStack(){var e=n.stack;return Object.defineProperty(this,"stack",{value:e}),e}})}}});function createNodeError$1(e,t,n){let r=e,i=h[r?.code??-1]||`EIO`,a=`${i}: ${r?.message||`unknown error`}, ${t}`;n?.path&&(a+=` '${n.path}'`),n?.dest&&(a+=` -> '${n.dest}'`),n?.address&&(a+=` ${n.address}`),n?.port!=null&&(a+=`:${n.port}`);let o=Error(a);return o.code=i,o.syscall=t,o.errno=-(r?.code||0),n?.path&&(o.path=n.path),n?.address&&(o.address=n.address),n?.port!=null&&(o.port=n.port),o}function isNotFoundError(e){let t=e;return t?.code===1||t?.code===`ENOENT`}var h,g=__esmMin(()=>{h={0:`EIO`,1:`ENOENT`,2:`EEXIST`,3:`EISDIR`,4:`ENOTDIR`,5:`ENOTEMPTY`,6:`ENOENT`,7:`ENFILE`,9:`EACCES`,10:`ENFILE`,11:`EINVAL`,12:`ELOOP`,13:`ENOSPC`,14:`EACCES`,17:`ELOOP`,19:`ENOSPC`,20:`ENOTSUP`,22:`EMFILE`,24:`EROFS`,25:`ECANCELED`,26:`EBUSY`,27:`ETIMEDOUT`,28:`EHOSTUNREACH`,30:`EHOSTUNREACH`,31:`ENETUNREACH`,32:`ECONNREFUSED`,33:`EADDRINUSE`,34:`ECONNRESET`,36:`EPIPE`,38:`ENETUNREACH`,39:`ECONNREFUSED`,40:`ECONNREFUSED`,41:`EACCES`,44:`ECONNRESET`,46:`EMSGSIZE`},__name(createNodeError$1,`createNodeError`)});function registerGlobal(e,t){let n=globalThis;n[e]===void 0&&(n[e]=t)}var _=__esmMin(()=>{});function hostPlatform(){let e=globalThis.process?.platform;return typeof e==`string`?e:void 0}function isWin32(){return hostPlatform()===`win32`}function isDarwin(){return hostPlatform()===`darwin`}var v=__esmMin(()=>{});function _formatArgs(...e){let t=e[0],n=e.slice(1);if(typeof t!=`string`||!/%(s|d|i|f|o|O|c)/.test(t))return e.map(e=>typeof e==`string`?e:JSON.stringify(e)).join(` `);let r=0,i=t.replace(/%([sdifOoc])/g,(e,t)=>{if(r>=n.length)return e;let i=n[r++];switch(t){case`s`:return String(i);case`d`:case`i`:return String(parseInt(String(i),10));case`f`:return String(parseFloat(String(i)));case`o`:case`O`:return JSON.stringify(i);case`c`:return``;default:return e}}),a=n.slice(r);return a.length===0?i:i+` `+a.map(e=>typeof e==`string`?e:JSON.stringify(e)).join(` `)}var y,Console,b,log,info,debug,warn,error,dir,dirxml,table,x,assert,S,time,timeEnd,timeLog,count,countReset,C,groupCollapsed,groupEnd,profile,profileEnd,timeStamp,w=__esmMin(()=>{y=typeof print==`function`&&typeof printerr==`function`,Console=class{_stdout;_stderr;_groupDepth=0;_groupIndentation;_timers=new Map;_counters=new Map;constructor(e,t){if(e&&typeof e.write==`function`)this._stdout=e,this._stderr=t||this._stdout;else if(e&&typeof e==`object`){let t=e;this._stdout=t.stdout,this._stderr=t.stderr||t.stdout}this._groupIndentation=2}_write(e,...t){let n=e===`stderr`&&this._stderr||this._stdout;if(n){let e=` `.repeat(this._groupDepth*this._groupIndentation),r=_formatArgs(...t);n.write(e+r+`
|
|
3
3
|
`)}else if(y){let n=` `.repeat(this._groupDepth*this._groupIndentation)+_formatArgs(...t);e===`stderr`?printerr(n):print(n)}else{let n=globalThis.console;e===`stderr`?n.error(...t):n.log(...t)}}log(...e){this._write(`stdout`,...e)}info(...e){this._write(`stdout`,...e)}debug(...e){this._write(`stdout`,...e)}warn(...e){this._write(`stderr`,...e)}error(...e){this._write(`stderr`,...e)}dir(e,t){this._write(`stdout`,e)}dirxml(...e){this.log(...e)}assert(e,...t){e||this.error(`Assertion failed:`,...t)}clear(){this._stdout?this._stdout.write(`\x1Bc`):y?print(`\x1Bc`):globalThis.console.clear()}count(e=`default`){let t=(this._counters.get(e)||0)+1;this._counters.set(e,t),this.log(`${e}: ${t}`)}countReset(e=`default`){this._counters.delete(e)}group(...e){e.length>0&&this.log(...e),this._groupDepth++}groupCollapsed(...e){this.group(...e)}groupEnd(){this._groupDepth>0&&this._groupDepth--}table(e,t){this._stdout?this._write(`stdout`,e):y?print(JSON.stringify(e,null,2)):globalThis.console.table(e,t)}time(e=`default`){this._timers.set(e,Date.now())}timeEnd(e=`default`){let t=this._timers.get(e);t===void 0?this.warn(`Warning: No such label '${e}' for console.timeEnd()`):(this.log(`${e}: ${Date.now()-t}ms`),this._timers.delete(e))}timeLog(e=`default`,...t){let n=this._timers.get(e);n===void 0?this.warn(`Warning: No such label '${e}' for console.timeLog()`):this.log(`${e}: ${Date.now()-n}ms`,...t)}trace(...e){let t=Error().stack?.split(`
|
|
4
4
|
`).slice(1).join(`
|
|
5
5
|
`)||``;this._write(`stderr`,`Trace:`,...e,`
|
|
6
6
|
`+t)}profile(e){}profileEnd(e){}timeStamp(e){}},b=new Console,log=(...e)=>b.log(...e),info=(...e)=>b.info(...e),debug=(...e)=>b.debug(...e),warn=(...e)=>b.warn(...e),error=(...e)=>b.error(...e),dir=(e,t)=>b.dir(e,t),dirxml=(...e)=>b.dirxml(...e),table=(e,t)=>b.table(e,t),x=__name(()=>b.clear(),`clear`),assert=(e,...t)=>b.assert(e,...t),S=__name((...e)=>b.trace(...e),`trace`),time=e=>b.time(e),timeEnd=e=>b.timeEnd(e),timeLog=(e,...t)=>b.timeLog(e,...t),count=e=>b.count(e),countReset=e=>b.countReset(e),C=__name((...e)=>b.group(...e),`group`),groupCollapsed=(...e)=>b.groupCollapsed(...e),groupEnd=()=>b.groupEnd(),profile=e=>{},profileEnd=e=>{},timeStamp=e=>{}}),T,E=__esmMin(()=>{w(),T={log,info,debug,warn,error,dir,dirxml,table,time,timeEnd,timeLog,trace:S,assert,clear:x,count,countReset,group:C,groupCollapsed,groupEnd,profile,profileEnd,timeStamp}}),D,O=__esmMin(()=>{D=__name(e=>{Promise.resolve().then(e)},`queueMicrotask`)});function mapSysname(e){let t=e.trim();switch(t){case`Linux`:return`linux`;case`Darwin`:return`darwin`;case`FreeBSD`:return`freebsd`;case`OpenBSD`:return`openbsd`;case`NetBSD`:return`netbsd`;case`SunOS`:return`sunos`;case`AIX`:return`aix`;case`Haiku`:return`haiku`;default:return/^CYGWIN/i.test(t)?`cygwin`:/^(MINGW|MSYS|Windows)/i.test(t)?`win32`:void 0}}function mapMachine(e){let t=e.trim().toLowerCase();switch(t){case`x86_64`:case`amd64`:return`x64`;case`aarch64`:case`arm64`:return`arm64`;case`i386`:case`i486`:case`i586`:case`i686`:return`ia32`;case`ppc64le`:case`ppc64`:return`ppc64`;case`s390x`:return`s390x`;case`riscv64`:return`riscv64`;case`loongarch64`:return`loong64`;case`mipsel`:return`mipsel`;case`mips`:return`mips`;default:return t.startsWith(`arm`)?`arm`:void 0}}var ee=__esmMin(()=>{});function classOf(e){return te.call(e).slice(8,-1)}function throwDataCloneError(e){let t=globalThis.DOMException;if(typeof t==`function`)throw new t(e,`DataCloneError`);let n=Error(e);throw n.name=`DataCloneError`,n}function internalClone(e,t,n){if(e==null)return e;let r=typeof e;if(r===`boolean`||r===`number`||r===`string`||r===`bigint`)return e;r===`symbol`&&throwDataCloneError(`Symbol cannot be cloned`),r===`function`&&throwDataCloneError(`Function cannot be cloned`);let i=e;if(t.has(i))return t.get(i);let a=classOf(i);if(a===`Date`)return new Date(i.getTime());if(a===`RegExp`)return new RegExp(i.source,i.flags);if(a===`Boolean`||a===`Number`||a===`String`)return Object(i.valueOf());if(a===`BigInt`)return Object(BigInt.prototype.valueOf.call(i));if(i instanceof Error){let e=i,r=e.constructor?.name,a=new(r&&ne[r]||ne[e.name]||Error)(e.message);return a.name=e.name,`cause`in e&&Object.defineProperty(a,"cause",{value:internalClone(e.cause,t,n),writable:!0,enumerable:!1,configurable:!0}),a}if(a===`DOMException`){let e=globalThis.DOMException;if(typeof e==`function`){let t=i;return new e(t.message,t.name)}}if(a===`ArrayBuffer`){let e=i;if(n&&n.transferred.has(e)){let r=n.transferred.get(e);return t.set(i,r),r}(e.detached===!0||e.byteLength===0&&e.detached)&&throwDataCloneError(`ArrayBuffer is detached and cannot be cloned`);let r=e.slice(0);return t.set(i,r),r}if(a===`SharedArrayBuffer`||i&&typeof i==`object`&&i.constructor?.name===`SharedBuffer`)return i;if(a===`DataView`){let e=i,r=n?.viewSnapshots.get(i),a=internalClone(e.buffer,t,n),o=r?r.byteOffset:e.byteOffset,s=r?r.byteLength:e.byteLength,c=new DataView(a,o,s);return t.set(i,c),c}if(k.has(a)){let e=i,r=n?.viewSnapshots.get(i),a=internalClone(e.buffer,t,n),o=e.constructor,s=new o(a,r?r.byteOffset:e.byteOffset,r?r.length:e.length);return t.set(i,s),s}if(a===`Map`){let e=new Map;t.set(i,e);for(let[r,a]of i)e.set(internalClone(r,t,n),internalClone(a,t,n));return e}if(a===`Set`){let e=new Set;t.set(i,e);for(let r of i)e.add(internalClone(r,t,n));return e}{let e=globalThis,t=e.Blob,n=e.File;if(typeof n==`function`&&i instanceof n){let e=i;return new n([i],e.name,{type:e.type,lastModified:e.lastModified})}if(typeof t==`function`&&i instanceof t)return new t([i],{type:i.type})}if(i instanceof WeakMap&&throwDataCloneError(`WeakMap cannot be cloned`),i instanceof WeakSet&&throwDataCloneError(`WeakSet cannot be cloned`),i instanceof WeakRef&&throwDataCloneError(`WeakRef cannot be cloned`),typeof globalThis.Promise==`function`&&i instanceof Promise&&throwDataCloneError(`Promise cannot be cloned`),a===`Array`){let e=i,r=[];t.set(i,r);for(let i=0;i<e.length;i++)i in e&&(r[i]=internalClone(e[i],t,n));return r}if(a===`Object`||typeof i==`object`){let e={};t.set(i,e);for(let r of Object.keys(i))e[r]=internalClone(i[r],t,n);return e}throwDataCloneError(`${a} cannot be cloned`)}function structuredClone$1(e,t){let n=t?.transfer;if(!n||n.length===0)return internalClone(e,new Map);let r=new Set;for(let e of n)if(classOf(e)===`ArrayBuffer`){let t=e;t.detached===!0&&throwDataCloneError(`ArrayBuffer in transfer list is detached`),r.add(t)}let i=new Map;r.size>0&&snapshotViewsBackedByTransferredBuffers(e,r,i,new Set);let a=new Map;for(let e of r){let t=e;typeof t.transfer!=`function`&&throwDataCloneError(`ArrayBuffer.prototype.transfer() not available — runtime is not SM140+`),a.set(e,t.transfer())}return internalClone(e,new Map,{transferred:a,viewSnapshots:i})}function snapshotViewsBackedByTransferredBuffers(e,t,n,r){if(typeof e!=`object`||!e)return;let i=e;if(r.has(i))return;r.add(i);let a=classOf(i);if(a===`DataView`){let e=i;t.has(e.buffer)&&n.set(i,{byteOffset:e.byteOffset,length:0,byteLength:e.byteLength});return}if(k.has(a)){let e=i;t.has(e.buffer)&&n.set(i,{byteOffset:e.byteOffset,length:e.length,byteLength:e.byteLength});return}if(Array.isArray(i)){for(let e=0;e<i.length;e++)e in i&&snapshotViewsBackedByTransferredBuffers(i[e],t,n,r);return}if(a===`Map`){for(let[e,a]of i)snapshotViewsBackedByTransferredBuffers(e,t,n,r),snapshotViewsBackedByTransferredBuffers(a,t,n,r);return}if(a===`Set`){for(let e of i)snapshotViewsBackedByTransferredBuffers(e,t,n,r);return}if(a===`Object`)for(let e of Object.keys(i))snapshotViewsBackedByTransferredBuffers(i[e],t,n,r)}var te,ne,k,A=__esmMin(()=>{({toString:te}=Object.prototype),ne={Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError},k=new Set([`Int8Array`,`Uint8Array`,`Uint8ClampedArray`,`Int16Array`,`Uint16Array`,`Int32Array`,`Uint32Array`,`Float32Array`,`Float64Array`,`BigInt64Array`,`BigUint64Array`]),__name(structuredClone$1,`structuredClone`)});function hostGlib(){try{return globalThis.imports?.gi?.GLib}catch{return}}function readText(e,t){try{let[n,r]=e.file_get_contents(t);return!n||!r?null:new TextDecoder().decode(r)}catch{return null}}function shellOut(e,t){try{let[n,r]=e.spawn_command_line_sync(t);if(!n||!r)return null;let i=new TextDecoder().decode(r).trim();return i.length>0?i:null}catch{return null}}function hasProcfs(){let e=hostGlib();if(!e)return!1;try{return e.file_test(`/proc/self/status`,16)}catch{return!1}}function hostPid(){if(j!==null)return j>0?j:void 0;let e=hostGlib();if(!e)return;let t=0,n=hasProcfs()?readText(e,`/proc/self/stat`):null;if(n)t=parseInt(n,10);else{let n=shellOut(e,`sh -c 'echo $PPID'`);n&&(t=parseInt(n,10))}return j=Number.isInteger(t)&&t>0?t:0,j>0?j:void 0}function hostPpid(){let e=hostGlib();if(!e)return;let t=hasProcfs()?readText(e,`/proc/self/status`):null;if(t){let e=/PPid:\s+(\d+)/.exec(t);if(e){let t=parseInt(e[1],10);return Number.isInteger(t)?t:void 0}}let n=hostPid();if(n===void 0)return;let r=shellOut(e,`ps -o ppid= -p ${n}`);if(!r)return;let i=parseInt(r,10);return Number.isInteger(i)?i:void 0}function hostExecPath(){let e=hostGlib();if(e){if(hasProcfs())try{let t=e.file_read_link(`/proc/self/exe`);if(t)return t}catch{}try{let t=e.get_prgname();if(t){let n=e.find_program_in_path(t);if(n)return n}}catch{return}}}function readProcessMemory(){let e=hostGlib();if(!e)return null;let t=hasProcfs()?readText(e,`/proc/self/status`):null;if(t){let e=new Map;for(let n of t.split(`
|
|
7
7
|
`)){let t=/^(\w+):\s+(\d+)(\s+kB)?/.exec(n);t&&e.set(t[1],parseInt(t[2],10)*(t[3]?1024:1))}if(e.size>0)return{virtual:e.get(`VmSize`)??0,resident:e.get(`VmRSS`)??0,data:e.get(`VmData`)??0,peak:e.get(`VmPeak`)??0}}let n=shellOut(e,`sh -c 'ps -o rss=,vsz= -p $PPID'`);if(!n)return null;let r=/^(\d+)\s+(\d+)$/.exec(n);return r?{virtual:parseInt(r[2],10)*1024,resident:parseInt(r[1],10)*1024,data:0,peak:0}:null}var j,re=__esmMin(()=>{j=null});function ensureMainLoop(){let e=globalThis.imports;if(!e)return;if(ie)return ae;let t=e.gi?.GLib;if(t)return ae=new t.MainLoop(null,!1),ie=!0,t.main_depth()===0&&ae.runAsync().catch(()=>{}),ae}function quitMainLoop(){ae&&=(ae.quit(),ie=!1,null)}var ie,ae,oe=__esmMin(()=>{ie=!1,ae=null});function drainOnce(e){let t=Math.min(64,M.length);for(let n=0;n<t;n++){let t=M.shift();try{t()}catch(t){try{e.log_default_handler(`gjsify-nextTick`,e.LogLevelFlags.LEVEL_WARNING,String(t?.stack||t),null)}catch{}}}M.length>0?e.timeout_add(e.PRIORITY_DEFAULT,1,()=>(drainOnce(e),!1)):se=!1}function tryGLibTimeout(e){let t=globalThis.imports?.gi?.GLib;return t?.timeout_add?(M.push(e),se||(se=!0,t.timeout_add(t.PRIORITY_DEFAULT,0,()=>(drainOnce(t),!1))),!0):!1}var M,se,nextTick,N=__esmMin(()=>{M=[],se=!1,nextTick=(e,...t)=>{let n=t.length>0?()=>e(...t):e;if(!tryGLibTimeout(n)){if(typeof globalThis.process?.nextTick==`function`){globalThis.process.nextTick(e,...t);return}if(typeof queueMicrotask==`function`){queueMicrotask(n);return}Promise.resolve().then(n)}}}),ce=__esmMin(()=>{p(),m(),g(),_(),v(),O(),ee(),A(),re(),oe(),N()});f(),ce(),registerGlobal(`Blob`,u),registerGlobal(`File`,d);function btoaPolyfill(e){if(typeof globalThis.btoa==`function`)return globalThis.btoa(e);let t=``,n=0;for(;n+2<e.length;n+=3){let r=e.charCodeAt(n)<<16|e.charCodeAt(n+1)<<8|e.charCodeAt(n+2);t+=le[r>>18&63]+le[r>>12&63]+le[r>>6&63]+le[r&63]}if(n+1===e.length){let r=e.charCodeAt(n)<<16;t+=le[r>>18&63]+le[r>>12&63]+`==`}else if(n+2===e.length){let r=e.charCodeAt(n)<<16|e.charCodeAt(n+1)<<8;t+=le[r>>18&63]+le[r>>12&63]+le[r>>6&63]+`=`}return t}function base64Decode(e){let t=e.replace(/[=\s]/g,``),n=new Uint8Array(t.length*3>>2),r=0,i=0,a=0;for(let e=0;e<t.length;e++)r=r<<6|P[t.charCodeAt(e)],i+=6,i>=8&&(i-=8,n[a++]=r>>i&255);return n.subarray(0,a)}function base64Encode(e){let t=``,n=e.length;for(let r=0;r<n;r+=3){let i=e[r],a=r+1<n?e[r+1]:0,o=r+2<n?e[r+2]:0;t+=le[i>>2],t+=le[(i&3)<<4|a>>4],t+=r+1<n?le[(a&15)<<2|o>>6]:`=`,t+=r+2<n?le[o&63]:`=`}return t}var le,P,ue=__esmMin(()=>{le=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,P=new Uint8Array(256);for(let e=0;e<64;e++)P[le.charCodeAt(e)]=e});function normalizeEncoding(e){if(!e||e===`utf8`||e===`utf-8`)return`utf8`;switch((``+e).toLowerCase().replace(/-/g,``)){case`utf8`:return`utf8`;case`ascii`:return`ascii`;case`latin1`:case`binary`:return`latin1`;case`base64`:return`base64`;case`base64url`:return`base64url`;case`hex`:return`hex`;case`ucs2`:case`utf16le`:return`utf16le`;default:return`utf8`}}function checkEncoding(e){let t=(``+e).toLowerCase().replace(/-/g,``);if(!de.includes(t))throw TypeError(`Unknown encoding: ${e}`)}var de,F=__esmMin(()=>{de=[`utf8`,`ascii`,`latin1`,`binary`,`base64`,`base64url`,`hex`,`ucs2`,`utf16le`]});function encodeString(e,t){switch(t){case`utf8`:return textEncoder().encode(e);case`ascii`:{let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n)&127;return t}case`latin1`:{let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n)&255;return t}case`base64`:return base64Decode(e.replace(/-/g,`+`).replace(/_/g,`/`));case`base64url`:return encodeString(e.replace(/-/g,`+`).replace(/_/g,`/`),`base64`);case`hex`:{let t=e.length>>>1,n=new Uint8Array(t);for(let r=0;r<t;r++){let t=parseInt(e[r*2],16),i=parseInt(e[r*2+1],16);if(Number.isNaN(t)||Number.isNaN(i))break;n[r]=t<<4|i}return n}case`utf16le`:{let t=new Uint8Array(e.length*2);for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);t[n*2]=r&255,t[n*2+1]=r>>8&255}return t}default:return textEncoder().encode(e)}}function decodeString(e,t,n,r){let i=n!==void 0||r!==void 0?e.subarray(n??0,r??e.length):e;switch(t){case`utf8`:return textDecoder().decode(i);case`ascii`:{let e=``;for(let t=0;t<i.length;t++)e+=String.fromCharCode(i[t]&127);return e}case`latin1`:{let e=``;for(let t=0;t<i.length;t++)e+=String.fromCharCode(i[t]);return e}case`base64`:{let e=``;for(let t=0;t<i.length;t++)e+=String.fromCharCode(i[t]);return btoaPolyfill(e)}case`base64url`:return decodeString(i,`base64`).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``);case`hex`:{let e=``;for(let t=0;t<i.length;t++)e+=i[t].toString(16).padStart(2,`0`);return e}case`utf16le`:{let e=``;for(let t=0;t+1<i.length;t+=2)e+=String.fromCharCode(i[t]|i[t+1]<<8);return e}default:return textDecoder().decode(i)}}function checkOffset(e,t,n){if(e+t>n)throw RangeError(`Attempt to access memory outside buffer bounds`)}var fe,pe,textEncoder,textDecoder,me=__esmMin(()=>{ue(),textEncoder=()=>fe??=new TextEncoder,textDecoder=()=>pe??=new TextDecoder}),he,I,ge=__esmMin(()=>{me(),F(),he=typeof SharedArrayBuffer<`u`,I=class Buffer extends Uint8Array{static _isBuffer=!0;static alloc(e,t,n){if(typeof e!=`number`)throw TypeError(`The "size" argument must be of type number. Received type ${typeof e}`);if(e<0)throw RangeError(`The value "${e}" is invalid for option "size"`);let r=new Buffer(e);return t!==void 0&&t!==0&&r.fill(t,0,e,n),r}static allocUnsafe(e){if(typeof e!=`number`)throw TypeError(`The "size" argument must be of type number. Received type ${typeof e}`);return new Buffer(e)}static allocUnsafeSlow(e){return Buffer.allocUnsafe(e)}static from(e,t,n){if(typeof e==`string`){let n=normalizeEncoding(t);if(t&&typeof t==`string`){let e=(``+t).toLowerCase().replace(/-/g,``);[`utf8`,`ascii`,`latin1`,`binary`,`base64`,`base64url`,`hex`,`ucs2`,`utf16le`,``].includes(e)||checkEncoding(t)}let r=encodeString(e,n);return new Buffer(r.buffer,r.byteOffset,r.byteLength)}if(ArrayBuffer.isView(e)){let t=new Buffer(e.buffer,e.byteOffset,e.byteLength),n=new Buffer(t.length);return n.set(t),n}if(e instanceof ArrayBuffer){let r=t||0,i=n===void 0?e.byteLength-r:n;return new Buffer(e,r,i)}if(he&&e instanceof SharedArrayBuffer){let r=t||0,i=n===void 0?e.byteLength-r:n;return new Buffer(new Uint8Array(e,r,i))}if(typeof e==`object`&&e&&typeof e.viewBytes==`function`&&typeof e.byteLength==`number`&&e.constructor?.name===`SharedBuffer`){let r=e,i=t||0,a=n===void 0?r.byteLength-i:n,o=r.viewBytes(i,a);return new Buffer(o.buffer,o.byteOffset,o.byteLength)}if(Array.isArray(e)){let t=new Buffer(e.length);for(let n=0;n<e.length;n++)t[n]=e[n]&255;return t}throw TypeError(`The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array`)}static isBuffer(e){return e instanceof Buffer}static isEncoding(e){if(typeof e!=`string`)return!1;let t=e.toLowerCase().replace(/-/g,``);return[`utf8`,`ascii`,`latin1`,`binary`,`base64`,`base64url`,`hex`,`ucs2`,`utf16le`].includes(t)}static byteLength(e,t){if(typeof e!=`string`){if(ArrayBuffer.isView(e)||e instanceof ArrayBuffer||he&&e instanceof SharedArrayBuffer)return e.byteLength;throw TypeError(`The "string" argument must be one of type string, Buffer, or ArrayBuffer`)}switch(normalizeEncoding(t)){case`utf8`:return new TextEncoder().encode(e).byteLength;case`ascii`:case`latin1`:return e.length;case`base64`:case`base64url`:{let t=e.length;for(;t>0&&(e[t-1]===`=`||e[t-1]===` `);)t--;return t*3>>>2}case`hex`:return e.length>>>1;case`utf16le`:return e.length*2;default:return new TextEncoder().encode(e).byteLength}}static compare(e,t){if(!(e instanceof Uint8Array)||!(t instanceof Uint8Array))throw TypeError(`Arguments must be Buffers or Uint8Arrays`);let n=Math.min(e.length,t.length);for(let r=0;r<n;r++){if(e[r]<t[r])return-1;if(e[r]>t[r])return 1}return e.length<t.length?-1:+(e.length>t.length)}static concat(e,t){if(e.length===0)return Buffer.alloc(0);if(t===void 0){t=0;for(let n=0;n<e.length;n++)t+=e[n].length}let n=Buffer.alloc(t),r=0;for(let i=0;i<e.length;i++){let a=e[i],o=Math.min(a.length,t-r);o<=0||(n.set(a.subarray(0,o),r),r+=o)}return n}static poolSize=65536;toString(e,t,n){let r=normalizeEncoding(e);return decodeString(this,r,t,n)}toJSON(){return{type:`Buffer`,data:Array.from(this)}}equals(e){if(!(e instanceof Uint8Array))throw TypeError(`Argument must be a Buffer or Uint8Array`);if(this.length!==e.length)return!1;for(let t=0;t<this.length;t++)if(this[t]!==e[t])return!1;return!0}compare(e,t,n,r,i){if(!(e instanceof Uint8Array))throw TypeError(`Argument must be a Buffer or Uint8Array`);let a=r!==void 0||i!==void 0?this.subarray(r??0,i??this.length):this,o=t!==void 0||n!==void 0?e.subarray(t??0,n??e.length):e;return Buffer.compare(a,o)}copy(e,t=0,n=0,r){let i=r??this.length,a=Math.min(i-n,e.length-t);return a<=0?0:(e.set(this.subarray(n,n+a),t),a)}slice(e,t){let n=e??0,r=t??this.length,i=super.subarray(n,r);return new Buffer(i.buffer,i.byteOffset,i.byteLength)}subarray(e,t){let n=super.subarray(e,t);return new Buffer(n.buffer,n.byteOffset,n.byteLength)}write(e,t,n,r){t??=0;let i=encodeString(e,normalizeEncoding(r||(typeof n==`string`?n:void 0))),a=n!==void 0&&typeof n==`number`?Math.min(n,this.length-t):this.length-t,o=Math.min(i.length,a);return this.set(i.subarray(0,o),t),o}fill(e,t,n,r){let i=t??0,a=n??this.length;if(typeof e==`number`)super.fill(e&255,i,a);else if(typeof e==`string`){let t=encodeString(e,normalizeEncoding(r));if(t.length===0)super.fill(0,i,a);else if(t.length===1)super.fill(t[0],i,a);else for(let e=i;e<a;e++)this[e]=t[(e-i)%t.length]}else if(e instanceof Uint8Array)if(e.length===0)super.fill(0,i,a);else for(let t=i;t<a;t++)this[t]=e[(t-i)%e.length];return this}indexOf(e,t,n){if(typeof e==`number`)return super.indexOf(e&255,t);let r=typeof e==`string`?encodeString(e,normalizeEncoding(n)):e,i=t??0;outer:for(let e=i;e<=this.length-r.length;e++){for(let t=0;t<r.length;t++)if(this[e+t]!==r[t])continue outer;return e}return-1}lastIndexOf(e,t,n){if(typeof e==`number`)return t===void 0?super.lastIndexOf(e&255):super.lastIndexOf(e&255,t);let r=typeof e==`string`?encodeString(e,normalizeEncoding(n)):e,i=t===void 0?this.length-r.length:Math.min(t,this.length-r.length);outer:for(let e=i;e>=0;e--){for(let t=0;t<r.length;t++)if(this[e+t]!==r[t])continue outer;return e}return-1}includes(e,t,n){return this.indexOf(e,t,n)!==-1}readUInt8(e=0){return checkOffset(e,1,this.length),this[e]}readUInt16BE(e=0){return checkOffset(e,2,this.length),this[e]<<8|this[e+1]}readUInt16LE(e=0){return checkOffset(e,2,this.length),this[e]|this[e+1]<<8}readUInt32BE(e=0){return checkOffset(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])}readUInt32LE(e=0){return checkOffset(e,4,this.length),this[e+3]*16777216+(this[e+2]<<16|this[e+1]<<8|this[e])>>>0}readInt8(e=0){return checkOffset(e,1,this.length),this[e]|(this[e]&128?4294967040:0)}readInt16BE(e=0){checkOffset(e,2,this.length);let t=this[e]<<8|this[e+1];return t&32768?t|4294901760:t}readInt16LE(e=0){checkOffset(e,2,this.length);let t=this[e]|this[e+1]<<8;return t&32768?t|4294901760:t}readInt32BE(e=0){return checkOffset(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]}readInt32LE(e=0){return checkOffset(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24}readFloatBE(e=0){return checkOffset(e,4,this.length),new DataView(this.buffer,this.byteOffset+e,4).getFloat32(0,!1)}readFloatLE(e=0){return checkOffset(e,4,this.length),new DataView(this.buffer,this.byteOffset+e,4).getFloat32(0,!0)}readDoubleBE(e=0){return checkOffset(e,8,this.length),new DataView(this.buffer,this.byteOffset+e,8).getFloat64(0,!1)}readDoubleLE(e=0){return checkOffset(e,8,this.length),new DataView(this.buffer,this.byteOffset+e,8).getFloat64(0,!0)}readBigInt64BE(e=0){return checkOffset(e,8,this.length),new DataView(this.buffer,this.byteOffset+e,8).getBigInt64(0,!1)}readBigInt64LE(e=0){return checkOffset(e,8,this.length),new DataView(this.buffer,this.byteOffset+e,8).getBigInt64(0,!0)}readBigUInt64BE(e=0){return checkOffset(e,8,this.length),new DataView(this.buffer,this.byteOffset+e,8).getBigUint64(0,!1)}readBigUInt64LE(e=0){return checkOffset(e,8,this.length),new DataView(this.buffer,this.byteOffset+e,8).getBigUint64(0,!0)}readUIntBE(e,t){checkOffset(e,t,this.length);let n=0;for(let r=0;r<t;r++)n=n*256+this[e+r];return n}readUIntLE(e,t){checkOffset(e,t,this.length);let n=0,r=1;for(let i=0;i<t;i++)n+=this[e+i]*r,r*=256;return n}readIntBE(e,t){checkOffset(e,t,this.length);let n=0;for(let r=0;r<t;r++)n=n*256+this[e+r];return n>=2**(8*t-1)&&(n-=2**(8*t)),n}readIntLE(e,t){checkOffset(e,t,this.length);let n=0,r=1;for(let i=0;i<t;i++)n+=this[e+i]*r,r*=256;return n>=2**(8*t-1)&&(n-=2**(8*t)),n}writeUInt8(e,t=0){return checkOffset(t,1,this.length),this[t]=e&255,t+1}writeUInt16BE(e,t=0){return checkOffset(t,2,this.length),this[t]=e>>>8&255,this[t+1]=e&255,t+2}writeUInt16LE(e,t=0){return checkOffset(t,2,this.length),this[t]=e&255,this[t+1]=e>>>8&255,t+2}writeUInt32BE(e,t=0){return checkOffset(t,4,this.length),this[t]=e>>>24&255,this[t+1]=e>>>16&255,this[t+2]=e>>>8&255,this[t+3]=e&255,t+4}writeUInt32LE(e,t=0){return checkOffset(t,4,this.length),this[t]=e&255,this[t+1]=e>>>8&255,this[t+2]=e>>>16&255,this[t+3]=e>>>24&255,t+4}writeInt8(e,t=0){return checkOffset(t,1,this.length),e<0&&(e=255+e+1),this[t]=e&255,t+1}writeInt16BE(e,t=0){return checkOffset(t,2,this.length),this[t]=e>>>8&255,this[t+1]=e&255,t+2}writeInt16LE(e,t=0){return checkOffset(t,2,this.length),this[t]=e&255,this[t+1]=e>>>8&255,t+2}writeInt32BE(e,t=0){return checkOffset(t,4,this.length),this[t]=e>>>24&255,this[t+1]=e>>>16&255,this[t+2]=e>>>8&255,this[t+3]=e&255,t+4}writeInt32LE(e,t=0){return checkOffset(t,4,this.length),this[t]=e&255,this[t+1]=e>>>8&255,this[t+2]=e>>>16&255,this[t+3]=e>>>24&255,t+4}writeFloatBE(e,t=0){return checkOffset(t,4,this.length),new DataView(this.buffer,this.byteOffset+t,4).setFloat32(0,e,!1),t+4}writeFloatLE(e,t=0){return checkOffset(t,4,this.length),new DataView(this.buffer,this.byteOffset+t,4).setFloat32(0,e,!0),t+4}writeDoubleBE(e,t=0){return checkOffset(t,8,this.length),new DataView(this.buffer,this.byteOffset+t,8).setFloat64(0,e,!1),t+8}writeDoubleLE(e,t=0){return checkOffset(t,8,this.length),new DataView(this.buffer,this.byteOffset+t,8).setFloat64(0,e,!0),t+8}writeBigInt64BE(e,t=0){return checkOffset(t,8,this.length),new DataView(this.buffer,this.byteOffset+t,8).setBigInt64(0,e,!1),t+8}writeBigInt64LE(e,t=0){return checkOffset(t,8,this.length),new DataView(this.buffer,this.byteOffset+t,8).setBigInt64(0,e,!0),t+8}writeBigUInt64BE(e,t=0){return checkOffset(t,8,this.length),new DataView(this.buffer,this.byteOffset+t,8).setBigUint64(0,e,!1),t+8}writeBigUInt64LE(e,t=0){return checkOffset(t,8,this.length),new DataView(this.buffer,this.byteOffset+t,8).setBigUint64(0,e,!0),t+8}swap16(){let e=this.length;if(e%2!=0)throw RangeError(`Buffer size must be a multiple of 16-bits`);for(let t=0;t<e;t+=2){let e=this[t];this[t]=this[t+1],this[t+1]=e}return this}swap32(){let e=this.length;if(e%4!=0)throw RangeError(`Buffer size must be a multiple of 32-bits`);for(let t=0;t<e;t+=4){let e=this[t],n=this[t+1];this[t]=this[t+3],this[t+1]=this[t+2],this[t+2]=n,this[t+3]=e}return this}swap64(){let e=this.length;if(e%8!=0)throw RangeError(`Buffer size must be a multiple of 64-bits`);for(let t=0;t<e;t+=8){let e=this[t],n=this[t+1],r=this[t+2],i=this[t+3];this[t]=this[t+7],this[t+1]=this[t+6],this[t+2]=this[t+5],this[t+3]=this[t+4],this[t+4]=i,this[t+5]=r,this[t+6]=n,this[t+7]=e}return this}}}),_e=__esmMin(()=>{ue(),F(),ge(),globalThis.atob,globalThis.btoa});_e(),`Buffer`in globalThis||Object.defineProperty(globalThis,"Buffer",{value:I,enumerable:!1,writable:!0,configurable:!0});var ve,ye=__esmMin(()=>{ve=e}),L,be=__esmMin(()=>{ye(),L=ve});be(),typeof globalThis.btoa!=`function`&&Object.defineProperty(globalThis,"btoa",{value:function btoa(e){let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n)&255;return L.base64_encode(t)},enumerable:!0,writable:!0,configurable:!0}),typeof globalThis.atob!=`function`&&Object.defineProperty(globalThis,"atob",{value:function atob(e){let t=L.base64_decode(e),n=``;for(let e=0;e<t.length;e++)n+=String.fromCharCode(t[e]);return n},enumerable:!0,writable:!0,configurable:!0}),ce(),typeof queueMicrotask!=`function`&&Object.defineProperty(globalThis,"queueMicrotask",{value:D,enumerable:!0,writable:!0,configurable:!0});function getGjsGlobal(){return globalThis}function getGioNamespace(){let e=getGjsGlobal().imports?.gi;if(!e)return null;let t=null;try{t=e.GioUnix??null}catch{}if(!t)try{t=e.Gio??null}catch{}return t}function getMonotonicTime(){try{let e=getGjsGlobal().imports?.gi?.GLib;if(e?.get_monotonic_time)return BigInt(e.get_monotonic_time())*1000n}catch{}return typeof performance?.now==`function`?BigInt(Math.round(performance.now()*1e6)):BigInt(Date.now())*1000000n}const xe=getMonotonicTime();function hrtime(e){let t=getMonotonicTime()-xe,n=Number(t/1000000000n),r=Number(t%1000000000n);if(e){let t=n-e[0],i=r-e[1];return i<0&&(t--,i+=1e9),[t,i]}return[n,r]}function hrtimeBigint(){return getMonotonicTime()-xe}E(),ce();let Se;function probeUname(){if(Se!==void 0)return Se;Se=null;try{let e=getGjsGlobal().imports?.gi?.GLib;if(!e)return Se;let t=e.spawn_sync,n=e.SpawnFlags?.SEARCH_PATH;if(!t||n===void 0)return Se;let[r,i]=t(null,[`uname`,`-sm`],null,n,null);if(!r||!i)return Se;let a=new TextDecoder().decode(i).trim().split(/\s+/);if(a.length<2)return Se;let o=mapSysname(a[0]),s=mapMachine(a[a.length-1]);if(!o||!s)return Se;Se={platform:o,arch:s}}catch{}return Se}ce();function detectGjsVersion(){try{let e=getGjsGlobal().imports?.system;if(e?.version!==void 0){let t=Number(e.version);return`${Math.floor(t/1e4)}.${Math.floor(t%1e4/100)}.${t%100}`}}catch{}}function detectNodeVersion(){if(typeof globalThis.process?.versions?.node==`string`)return globalThis.process.versions.node}function detectVersionInfo(){if(detectNodeVersion())return{version:globalThis.process.version,versions:{...globalThis.process.versions},title:globalThis.process?.title||`node`};let e=detectGjsVersion(),t={node:`20.0.0`};return e&&(t.gjs=e),{version:`v20.0.0`,versions:t,title:`gjs`}}function detectPpid(){return!onGjs()&&typeof globalThis.process?.ppid==`number`?globalThis.process.ppid:hostPpid()??0}function onGjs(){try{return getGjsGlobal().imports?.gi!==void 0}catch{return!1}}function detectPlatform(){if(onGjs()){let e=probeUname();return e?e.platform:`linux`}let e=globalThis.process;return typeof e?.platform==`string`?e.platform:`linux`}function detectArch(){if(onGjs()){let e=probeUname();return e?e.arch:`x64`}let e=globalThis.process;return typeof e?.arch==`string`?e.arch:`x64`}function getPid$1(){return!onGjs()&&typeof globalThis.process?.pid==`number`?globalThis.process.pid:hostPid()??0}__name(getPid$1,`getPid`),ce();function getEnvProxy(){if(typeof globalThis.process?.env==`object`)return globalThis.process.env;try{let e=getGjsGlobal().imports?.gi?.GLib;if(e)return new Proxy({},{get(t,n){if(typeof n==`string`)return e.getenv(n)??void 0},set(t,n,r){return typeof n==`string`?(e.setenv(n,String(r),!0),!0):!1},deleteProperty(t,n){return typeof n==`string`?(e.unsetenv(n),!0):!1},has(t,n){return typeof n==`string`?e.getenv(n)!==null:!1},ownKeys(t){return e.listenv()},getOwnPropertyDescriptor(t,n){if(typeof n!=`string`)return;let r=e.getenv(n);if(r!==null)return{configurable:!0,enumerable:!0,writable:!0,value:r}}})}catch{}return{}}function getArgv(){if(globalThis.process?.argv!==void 0)return globalThis.process.argv;try{let e=getGjsGlobal().imports?.system;if(e?.programArgs)return[`gjs`,e.programInvocationName||``,...e.programArgs]}catch{}return[`gjs`]}function getExecPath(){let e=globalThis.process;return!isGjsHost()&&typeof e?.execPath==`string`?e.execPath:hostExecPath()??`/usr/bin/gjs`}function isGjsHost(){try{return getGjsGlobal().imports?.gi!==void 0}catch{return!1}}function getCwd(){try{let e=getGjsGlobal().imports?.gi?.GLib;if(e?.get_current_dir)return e.get_current_dir()}catch{}return`/`}function chdir(e){let t=getGjsGlobal().imports?.gi?.GLib;try{if(t?.chdir){if(!t.file_test(e,16)){let t=Error(`ENOENT: no such file or directory, chdir '${e}'`);throw t.code=`ENOENT`,t.syscall=`chdir`,t.path=e,t}t.chdir(e);return}}catch(e){if(e&&typeof e==`object`&&e.code===`ENOENT`)throw e}if(!t){let t=globalThis.process;if(t&&typeof t.chdir==`function`){t.chdir(e);return}}throw Error(`process.chdir() is not supported in this environment`)}ce();function exitProcess(e){let t=getGjsGlobal().imports,n=t?.gi?.GLib,r=t?.system,i=n?.idle_add,a=n?.SOURCE_REMOVE,o=n?.PRIORITY_DEFAULT;if(r?.exit&&i&&typeof o==`number`&&typeof a==`boolean`)return ensureMainLoop(),i(o,()=>(quitMainLoop(),r.exit(e),a)),new Promise(()=>{});try{r?.exit&&r.exit(e)}catch{}let s=globalThis.process;throw s&&typeof s.exit==`function`&&s.exit(e),Error(`process.exit(${e})`)}ce();function isGjs(){return getGjsGlobal().imports?.gi?.GLib!==void 0}function killPid(e,t){try{let n=getGjsGlobal().imports?.gi?.GLib;if(n){let r=typeof t==`number`?String(t):t||`SIGTERM`,i=r.startsWith(`SIG`)?`-${r.slice(3)}`:`-${r}`;return n.spawn_command_line_sync(`kill ${i} ${e}`),!0}}catch{}if(!isGjs()){let n=globalThis.process;if(n&&typeof n.kill==`function`)return n.kill(e,t)}throw Error(`process.kill() is not supported in this environment`)}function memoryUsage(){let e=readProcessMemory();if(e)return{rss:e.resident,heapTotal:e.resident,heapUsed:e.resident,external:0,arrayBuffers:0};if(!isGjs()){let e=globalThis.process;if(e&&typeof e.memoryUsage==`function`)return e.memoryUsage()}return{rss:0,heapTotal:0,heapUsed:0,external:0,arrayBuffers:0}}function cpuUsage(e){if(!isGjs()){let t=globalThis.process;if(t&&typeof t.cpuUsage==`function`)return t.cpuUsage(e)}return{user:0,system:0}}function readUmask(){try{let e=getGjsGlobal().imports?.gi?.GLib;if(e){let[t,n]=e.file_get_contents(`/proc/self/status`);if(t){let e=/^Umask:\s*([0-7]+)/m.exec(new TextDecoder().decode(n));if(e)return parseInt(e[1],8)}}}catch{}return 18}let Ce=null;const we=globalThis.imports?.gi;if(we)try{Ce=we.GjsifyTerminal}catch{}const Te=Ce;function onceWrapper(){let{target:e,type:t,listener:n}=this;return this.wrapperFn&&e.removeListener(t,this.wrapperFn),n.apply(e,Array.from(arguments))}function _onceWrap(e,t,n){let r={target:e,type:t,listener:n,wrapperFn:void 0},i=onceWrapper.bind(r);return r.wrapperFn=i,i.listener=n,i}function arrayClone(e){switch(e.length){case 0:return[];case 1:return[e[0]];case 2:return[e[0],e[1]];case 3:return[e[0],e[1],e[2]];default:return e.slice()}}function checkListener(e){if(typeof e!=`function`)throw TypeError(`The "listener" argument must be of type Function. Received type `+typeof e)}function validateNumber(e,t){if(typeof e!=`number`||e!==e)throw TypeError(`The "${t}" argument must be of type number. Received type ${typeof e}`)}function spliceOne(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}function unwrapListeners(e){let t=Array.from({length:e.length});for(let n=0;n<t.length;++n)t[n]=e[n].listener??e[n];return t}function createAbortError$2(e){let t=Error(`The operation was aborted`);return t.name=`AbortError`,t.code=`ABORT_ERR`,e?.reason&&(t.cause=e.reason),t}var Ee,De,Oe,ke=__esmMin(()=>{Ee=Symbol(`kCapture`),De=Symbol.for(`nodejs.rejection`),Oe=class EventEmitter{static defaultMaxListeners=10;static errorMonitor=Symbol(`events.errorMonitor`);static captureRejectionSymbol=De;static _captureRejections=!1;static get captureRejections(){return EventEmitter._captureRejections}static set captureRejections(e){if(typeof e!=`boolean`)throw TypeError(`The "captureRejections" argument must be of type boolean.`);EventEmitter._captureRejections=e}_events;_eventsCount;_maxListeners;[Ee];constructor(e){this._events=Object.create(null),this._eventsCount=0,this._maxListeners=void 0,this[Ee]=e?.captureRejections??EventEmitter._captureRejections}setMaxListeners(e){if(validateNumber(e,`n`),e<0)throw RangeError(`The value of "n" is out of range. It must be a non-negative number. Received `+e);return this._maxListeners=e,this}getMaxListeners(){return this._maxListeners??EventEmitter.defaultMaxListeners}emit(e,...t){let n=this._events,r=e===`error`;if(n!==void 0)r&&n[EventEmitter.errorMonitor]!==void 0&&this.emit(EventEmitter.errorMonitor,...t),r&&=n.error===void 0;else if(!r)return!1;if(r){let e;if(e=t.length>0?t[0]:Error(`Unhandled error.`),e instanceof Error)throw e;let n=Error(`Unhandled error. (`+e+`)`);throw n.context=e,n}let i=n[e];if(i===void 0)return!1;if(typeof i==`function`){let n=i.apply(this,t);n!=null&&this[Ee]&&this._addCatch(n,e,t)}else{let n=arrayClone(i),r=n.length;for(let i=0;i<r;++i){let r=n[i].apply(this,t);r!=null&&this[Ee]&&this._addCatch(r,e,t)}}return!0}_addCatch(e,t,n){typeof e?.then==`function`&&e.then(void 0,e=>{let r=this[De];if(typeof r==`function`)r.call(this,e,t,...n);else{let t=this[Ee];try{this[Ee]=!1,this.emit(`error`,e)}finally{this[Ee]=t}}})}addListener(e,t){return this._addListener(e,t,!1)}on(e,t){return this._addListener(e,t,!1)}prependListener(e,t){return this._addListener(e,t,!0)}_addListener(e,t,n){checkListener(t);let r=this._events;r===void 0?(r=this._events=Object.create(null),this._eventsCount=0):r.newListener!==void 0&&(this.emit(`newListener`,e,t.listener??t),r=this._events);let i=r[e];i===void 0?(r[e]=t,++this._eventsCount):typeof i==`function`?r[e]=n?[t,i]:[i,t]:n?i.unshift(t):i.push(t);let a=this.getMaxListeners();if(a>0){let t=typeof r[e]==`function`?1:r[e].length;if(t>a&&!r[e].warned){typeof r[e]!=`function`&&(r[e].warned=!0);let n=Error(`Possible EventEmitter memory leak detected. ${t} ${String(e)} listeners added to [${this.constructor.name}]. Use emitter.setMaxListeners() to increase limit`);n.name=`MaxListenersExceededWarning`,T.warn(n.message)}}return this}once(e,t){return checkListener(t),this.on(e,_onceWrap(this,e,t)),this}prependOnceListener(e,t){return checkListener(t),this.prependListener(e,_onceWrap(this,e,t)),this}removeListener(e,t){checkListener(t);let n=this._events;if(n===void 0)return this;let r=n[e];if(r===void 0)return this;if(r===t||r.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete n[e],n.removeListener&&this.emit(`removeListener`,e,r.listener??t));else if(typeof r!=`function`){let i=-1;for(let e=r.length-1;e>=0;e--)if(r[e]===t||r[e].listener===t){i=e;break}if(i<0)return this;i===0?r.shift():spliceOne(r,i),r.length===1&&(n[e]=r[0]),n.removeListener!==void 0&&this.emit(`removeListener`,e,t.listener??t)}return this}off(e,t){return this.removeListener(e,t)}removeAllListeners(e){let t=this._events;if(t===void 0)return this;if(t.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):t[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete t[e]),this;if(arguments.length===0){let e=Object.keys(t);for(let t=0;t<e.length;++t){let n=e[t];n!==`removeListener`&&this.removeAllListeners(n)}return this.removeAllListeners(`removeListener`),this._events=Object.create(null),this._eventsCount=0,this}let n=t[e];if(typeof n==`function`)this.removeListener(e,n);else if(n!==void 0)for(let t=n.length-1;t>=0;t--)this.removeListener(e,n[t]);return this}listeners(e){let t=this._events;if(t===void 0)return[];let n=t[e];return n===void 0?[]:typeof n==`function`?[n.listener??n]:unwrapListeners(n)}rawListeners(e){let t=this._events;if(t===void 0)return[];let n=t[e];return n===void 0?[]:typeof n==`function`?[n]:arrayClone(n)}listenerCount(e){let t=this._events;if(t===void 0)return 0;let n=t[e];return n===void 0?0:typeof n==`function`?1:n.length}eventNames(){return(this._eventsCount??0)>0?Reflect.ownKeys(this._events):[]}static once(e,t,n){return new Promise((r,i)=>{let a=n?.signal;if(a?.aborted){i(createAbortError$2(a));return}if(typeof e.addEventListener==`function`){let n=e,handler=(...e)=>{a&&a.removeEventListener(`abort`,abortHandler),r(e)},errorHandler=e=>{a&&a.removeEventListener(`abort`,abortHandler),n.removeEventListener(`error`,errorHandler),i(e)},abortHandler=()=>{n.removeEventListener(t,handler),n.removeEventListener(`error`,errorHandler),i(createAbortError$2(a))};n.addEventListener(t,handler,{once:!0}),t!==`error`&&n.addEventListener(`error`,errorHandler,{once:!0}),a&&a.addEventListener(`abort`,abortHandler,{once:!0});return}let o=e,eventHandler=(...e)=>{a&&a.removeEventListener(`abort`,abortHandler),errorHandler!==void 0&&o.removeListener(`error`,errorHandler),r(e)},errorHandler;t!==`error`&&(errorHandler=e=>{o.removeListener(t,eventHandler),a&&a.removeEventListener(`abort`,abortHandler),i(e)},o.once(`error`,errorHandler)),o.once(t,eventHandler);let abortHandler=()=>{o.removeListener(t,eventHandler),errorHandler&&o.removeListener(`error`,errorHandler),i(createAbortError$2(a))};a&&a.addEventListener(`abort`,abortHandler,{once:!0})})}static on(e,t,n){let r=n?.signal;if(r?.aborted)throw createAbortError$2(r);let i=n?.highWaterMark??2**53-1,a=n?.lowWaterMark??1;validateNumber(i,`highWaterMark`),validateNumber(a,`lowWaterMark`);let o=[],s=[],c=null,l=!1,u=!1,eventHandler=(...t)=>{if(s.length>0){let{resolve:e}=s.shift();e({value:t,done:!1})}else o.push(t),o.length>=i&&!u&&(u=!0,typeof e.pause==`function`&&e.pause())},errorHandler=e=>{if(c=e,s.length>0){let{reject:t}=s.shift();t(e)}d.return()},abortHandler=()=>{errorHandler(createAbortError$2(r))};e.on(t,eventHandler),t!==`error`&&e.on(`error`,errorHandler),r&&r.addEventListener(`abort`,abortHandler,{once:!0});let cleanup=()=>{e.removeListener(t,eventHandler),e.removeListener(`error`,errorHandler),r&&r.removeEventListener(`abort`,abortHandler),l=!0;for(let{resolve:e}of s)e({value:void 0,done:!0});s.length=0,o.length=0},d={next(){if(o.length>0){let t=o.shift();return u&&o.length<a&&(u=!1,typeof e.resume==`function`&&e.resume()),Promise.resolve({value:t,done:!1})}if(c){let e=Promise.reject(c);return c=null,e}return l?Promise.resolve({value:void 0,done:!0}):new Promise((e,t)=>{s.push({resolve:e,reject:t})})},return(){return cleanup(),Promise.resolve({value:void 0,done:!0})},throw(e){return l||(c=e,cleanup()),Promise.reject(e)},[Symbol.asyncIterator](){return this}};return d}static listenerCount(e,t){return e.listenerCount(t)}static getEventListeners(e,t){return typeof e.listeners==`function`?e.listeners(t):[]}static setMaxListeners(e,...t){if(validateNumber(e,`n`),e<0)throw RangeError(`The value of "n" is out of range.`);if(t.length===0)EventEmitter.defaultMaxListeners=e;else for(let n of t)typeof n.setMaxListeners==`function`&&n.setMaxListeners(e)}static getMaxListeners(e){return typeof e.getMaxListeners==`function`?e.getMaxListeners():EventEmitter.defaultMaxListeners}static addAbortListener(e,t){e.aborted&&Promise.resolve().then(()=>t());let handler=()=>t();return e.addEventListener(`abort`,handler,{once:!0}),{[Symbol.dispose](){e.removeEventListener(`abort`,handler)}}}},Oe.EventEmitter=Oe;for(let e of[`setMaxListeners`,`getMaxListeners`,`emit`,`addListener`,`on`,`prependListener`,`once`,`prependOnceListener`,`removeListener`,`off`,`removeAllListeners`,`listeners`,`rawListeners`,`listenerCount`,`eventNames`]){let t=Oe.prototype[e];typeof t==`function`&&Object.defineProperty(Oe.prototype,e,{enumerable:!0,configurable:!0,writable:!0,value:t})}Object.defineProperty(Oe.prototype,"_events",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(Oe.prototype,"_eventsCount",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(Oe.prototype,"_maxListeners",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),__name(createAbortError$2,`createAbortError`)}),Ae,je=__esmMin(()=>{ke(),ce(),Ae=makeCallable(Oe),Ae.EventEmitter=Ae,Ae.captureRejectionSymbol,Ae.errorMonitor,Ae.defaultMaxListeners,Ae.setMaxListeners,Ae.getMaxListeners,Ae.once,Ae.on,Ae.getEventListeners,Ae.listenerCount,Ae.addAbortListener});function normalizeAndValidateEncoding(e){return e&&checkEncoding(e),normalizeEncoding(e)}function utf8DecodeMaximalSubpart(e,t,n){let r=``,i=t;for(;i<n;){let t=e[i];if(t<=127){r+=String.fromCharCode(t),i++;continue}if(t>=194&&t<=223){i+1<n&&e[i+1]>=128&&e[i+1]<=191?(r+=String.fromCharCode((t&31)<<6|e[i+1]&63),i+=2):(r+=`�`,i++);continue}if(t>=224&&t<=239){let a,o;if(t===224?(a=160,o=191):t===237?(a=128,o=159):(a=128,o=191),i+1>=n){r+=`�`,i++;continue}let s=e[i+1];if(s<a||s>o){r+=`�`,i++;continue}if(i+2>=n){r+=`�`,i+=2;continue}let c=e[i+2];if(c<128||c>191){r+=`�`,i+=2;continue}let l=(t&15)<<12|(s&63)<<6|c&63;r+=String.fromCharCode(l),i+=3;continue}if(t>=240&&t<=244){let a,o;if(t===240?(a=144,o=191):t===244?(a=128,o=143):(a=128,o=191),i+1>=n){r+=`�`,i++;continue}let s=e[i+1];if(s<a||s>o){r+=`�`,i++;continue}if(i+2>=n){r+=`�`,i+=2;continue}let c=e[i+2];if(c<128||c>191){r+=`�`,i+=2;continue}if(i+3>=n){r+=`�`,i+=3;continue}let l=e[i+3];if(l<128||l>191){r+=`�`,i+=3;continue}let u=(t&7)<<18|(s&63)<<12|(c&63)<<6|l&63;r+=String.fromCharCode(55296+(u-65536>>10),56320+(u-65536&1023)),i+=4;continue}r+=`�`,i++}return r}function utf8CharLength(e){return e&128?e>=194&&e<=223?2:e>=224&&e<=239?3:e>=240&&e<=244?4:0:1}function isValidContinuation(e,t,n,r){if(n===1){if(t===3)return e===224?r>=160&&r<=191:e===237?r>=128&&r<=159:r>=128&&r<=191;if(t===4)return e===240?r>=144&&r<=191:e===244?r>=128&&r<=143:r>=128&&r<=191}return r>=128&&r<=191}function writeUtf8(e,t){let n=0,r=``;if(e._lastNeed>0){for(;n<t.length&&e._lastNeed>0;){let i=t[n],a=e._lastTotal-e._lastNeed;if(isValidContinuation(e._lastLeadByte,e._lastTotal,a,i))e._lastChar[a]=i,e._lastNeed--,n++;else{r+=`�`,e._lastNeed=0,e._lastTotal=0,e._lastLeadByte=0;break}}if(e._lastNeed===0&&e._lastTotal>0&&(r+=utf8DecodeMaximalSubpart(e._lastChar,0,e._lastTotal),e._lastTotal=0,e._lastLeadByte=0),e._lastNeed>0)return r}let i=t.length;for(let r=0;r<Math.min(4,t.length-n);r++){let a=t.length-1-r;if(a<n)break;let o=t[a];if((o&192)!=128){let n=utf8CharLength(o);if(n>0&&o>=128){let r=t.length-a;if(r<n){let s=!0;for(let e=1;e<r;e++)if(!isValidContinuation(o,n,e,t[a+e])){s=!1;break}if(s){i=a;for(let n=0;n<r;n++)e._lastChar[n]=t[a+n];e._lastNeed=n-r,e._lastTotal=n,e._lastLeadByte=o}}}break}}return i>n&&(r+=utf8DecodeMaximalSubpart(t,n,i)),r}function writeUtf16le(e,t){let n=``,r=0;if(e._lastNeed>0){let i=e._lastTotal-e._lastNeed,a=Math.min(e._lastNeed,t.length);for(let n=0;n<a;n++)e._lastChar[i+n]=t[n];if(e._lastNeed-=a,r=a,e._lastNeed>0)return``;let o=e._lastTotal,s=0;for(;s+1<o;){let i=e._lastChar[s]|e._lastChar[s+1]<<8;if(s+=2,i>=55296&&i<=56319){if(s+1<o){let t=e._lastChar[s]|e._lastChar[s+1]<<8;if(t>=56320&&t<=57343){n+=String.fromCharCode(i,t),s+=2;continue}}if(r+1<t.length){let e=t[r]|t[r+1]<<8;if(e>=56320&&e<=57343){n+=String.fromCharCode(i,e),r+=2;continue}}else if(r>=t.length)return e._lastChar[0]=e._lastChar[s-2],e._lastChar[1]=e._lastChar[s-1],e._lastNeed=2,e._lastTotal=4,n}n+=String.fromCharCode(i)}e._lastTotal=0}for(;r+1<t.length;){let i=t[r]|t[r+1]<<8;if(r+=2,i>=55296&&i<=56319)if(r+1<t.length){let e=t[r]|t[r+1]<<8;if(e>=56320&&e<=57343){n+=String.fromCharCode(i,e),r+=2;continue}}else if(r<t.length)return n+=String.fromCharCode(i),e._lastChar[0]=t[r],e._lastNeed=1,e._lastTotal=2,n;else return e._lastChar[0]=t[r-2],e._lastChar[1]=t[r-1],e._lastNeed=2,e._lastTotal=4,n;n+=String.fromCharCode(i)}return r<t.length&&(e._lastChar[0]=t[r],e._lastNeed=1,e._lastTotal=2),n}function writeBase64(e,t){let n=0;if(e._lastNeed>0){let r=Math.min(e._lastNeed,t.length);for(let n=0;n<r;n++)e._lastChar[e._lastTotal-e._lastNeed+n]=t[n],e._lastNeed--;if(n=r,e._lastNeed>0)return``}let r=t.length-n,i=r-r%3,a=``;e._lastTotal>0&&e._lastNeed===0&&(a+=base64Encode(e._lastChar.subarray(0,e._lastTotal)),e._lastTotal=0),i>0&&(a+=base64Encode(t.subarray(n,n+i)));let o=r-i;if(o>0){for(let r=0;r<o;r++)e._lastChar[r]=t[n+i+r];e._lastNeed=3-o,e._lastTotal=3}return a}function decodeAscii(e){let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]&127);return t}function decodeLatin1(e){let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return t}function decodeHex(e){let t=``;for(let n=0;n<e.length;n++)t+=e[n].toString(16).padStart(2,`0`);return t}var Me,Ne=__esmMin(()=>{_e(),Me=function StringDecoder(e){this.encoding=normalizeAndValidateEncoding(e),this._lastNeed=0,this._lastTotal=0,this._lastLeadByte=0,this.encoding===`utf8`||this.encoding===`utf16le`?this._lastChar=new Uint8Array(4):this.encoding===`base64`?this._lastChar=new Uint8Array(3):this._lastChar=new Uint8Array},Me.prototype.write=function write(e){if(e.length===0)return``;switch(this.encoding){case`utf8`:return writeUtf8(this,e);case`utf16le`:return writeUtf16le(this,e);case`base64`:return writeBase64(this,e);case`ascii`:return decodeAscii(e);case`latin1`:return decodeLatin1(e);case`hex`:return decodeHex(e);default:return decodeAscii(e)}},Me.prototype.end=function end(e){let t=``;if(e&&e.length>0&&(t=this.write(e)),this.encoding===`utf8`&&this._lastNeed>0)t+=`�`,this._lastNeed=0,this._lastTotal=0;else if(this.encoding===`utf16le`&&this._lastNeed>0){let e=this._lastTotal-this._lastNeed;for(let n=0;n+1<e;n+=2)t+=String.fromCharCode(this._lastChar[n]|this._lastChar[n+1]<<8);this._lastNeed=0,this._lastTotal=0}else if(this.encoding===`base64`&&this._lastNeed>0){let e=this._lastChar.subarray(0,this._lastTotal-this._lastNeed);t+=base64Encode(e),this._lastNeed=0,this._lastTotal=0}return t}});E(),je(),ce(),Ne();const Pe=new TextEncoder;var ProcessWriteStream=class extends Ae{fd;writable=!0;_outGio=null;constructor(e){super(),this.fd=e;let t=getGioNamespace();if(t){let e=t.UnixOutputStream??t.OutputStream;if(e)try{this._outGio=e.new(this.fd,!1)}catch{}}}write(e){if(this._outGio)try{let t=typeof e==`string`?Pe.encode(e):e;return this._outGio.write_all(t,null),!0}catch{}return this.fd===2?T.error(e):T.log(e),!0}get isTTY(){if(Te)return Te.Terminal.is_tty(this.fd);try{let e=getGjsGlobal().imports?.gi?.GLib;if(e)return!!e.log_writer_supports_color(this.fd)}catch{}return!1}get columns(){if(Te){let[e,,t]=Te.Terminal.get_size(this.fd);if(e&&t>0)return t}try{let e=getGjsGlobal().imports?.gi?.GLib;if(e){let t=parseInt(e.getenv(`COLUMNS`)??`0`,10);if(t>0)return t}}catch{}return 80}end(){}destroy(){}get rows(){if(Te){let[e,t]=Te.Terminal.get_size(this.fd);if(e&&t>0)return t}try{let e=getGjsGlobal().imports?.gi?.GLib;if(e){let t=parseInt(e.getenv(`LINES`)??`0`,10);if(t>0)return t}}catch{}return 24}},ProcessReadStream=class extends Ae{fd;isRaw=!1;_gio=null;_stdinGio=null;_reading=!1;_flowing=!1;_sttyCleanupRegistered=!1;_mainLoopHeld=!1;_pendingRead=!1;_decoder=null;constructor(e){super(),this.fd=e,this._gio=getGioNamespace()}get isTTY(){return Te?Te.Terminal.is_tty(this.fd):!1}setRawMode(e){return Te&&Te.Terminal.set_raw_mode(this.fd,e)?(this.isRaw=e,this):(this._setRawModeViaStty(e),this.isRaw=e,this)}_setRawModeViaStty(e){try{let t=globalThis.imports?.gi,n=t?.Gio??t?.Gio;if(!n)return;let r=n.SubprocessFlags?.STDIN_INHERIT??2,i=e?[`stty`,`-icanon`,`-echo`,`-icrnl`,`-isig`,`min`,`1`,`time`,`0`]:[`stty`,`icanon`,`echo`,`icrnl`,`isig`];if(new n.SubprocessLauncher({flags:r}).spawnv(i).wait(null),e&&!this._sttyCleanupRegistered){this._sttyCleanupRegistered=!0;let e=globalThis.process;e?.once&&typeof e.once==`function`&&e.once(`exit`,()=>this._setRawModeViaStty(!1))}}catch{}}setEncoding(e){return this._decoder=new Me(e),this}_pushData(e){if(this._decoder){let t=this._decoder.write(e);t.length>0&&this.emit(`data`,t)}else this.emit(`data`,e)}on(e,t){let n=e===`data`&&this.listenerCount(`data`)===0;return super.on(e,t),n&&e===`data`&&this.resume(),this}addListener(e,t){return this.on(e,t)}once(e,t){return super.once(e,t),this}removeListener(e,t){return super.removeListener(e,t),e===`data`&&this.listenerCount(`data`)===0&&this.pause(),this}off(e,t){return this.removeListener(e,t)}removeAllListeners(e){let t=e===void 0||e===`data`?this.listenerCount(`data`)>0:!1;return super.removeAllListeners(e),t&&this.listenerCount(`data`)===0&&this.pause(),this}resume(){return this._flowing=!0,this._gio&&this.fd===0&&!this._reading&&this._startReading(),this}pause(){if(this._flowing=!1,this._reading=!1,this._mainLoopHeld){this._mainLoopHeld=!1;let e=globalThis.imports?.gi,t=e?.GLib??e?.GLib;t?.idle_add?t.idle_add(300,()=>(this._mainLoopHeld||quitMainLoop(),!1)):quitMainLoop()}return this}read(){return null}_startReading(){if(!this._gio||this._reading)return;if(this._pendingRead){this._reading=!0,this._mainLoopHeld||(this._mainLoopHeld=!0,ensureMainLoop());return}if(this._reading=!0,this._mainLoopHeld||(this._mainLoopHeld=!0,ensureMainLoop()),!this._stdinGio){let e=this._gio.UnixInputStream??this._gio.InputStream;if(!e){this._reading=!1;return}try{this._stdinGio=e.new(this.fd,!1)}catch{this._reading=!1;return}}let loop=()=>{if(!this._reading){this._pendingRead=!1;return}this._pendingRead=!0,this._stdinGio.read_bytes_async(4096,0,null,(e,t)=>{this._pendingRead=!1;try{let n=e.read_bytes_finish(t)?.get_data?.()??null;if(n&&n.byteLength>0)this._pushData(Buffer.from(n));else if(n!==null&&n.byteLength===0){if(this._reading=!1,this._decoder){let e=this._decoder.end();e.length>0&&this.emit(`data`,e)}this.emit(`end`);return}}catch{this._reading=!1;return}this._reading&&loop()})};loop()}};E(),je();const Fe=Date.now();function defineLazy(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!0,get(){let r=n();return Object.defineProperty(e,t,{value:r,configurable:!0,enumerable:!0,writable:!1}),r}})}var Process=class extends Ae{platform;arch;env;argv;argv0;execPath;pid;ppid;version;versions;title;execArgv;config;exitCode;constructor(){super(),defineLazy(this,`platform`,detectPlatform),defineLazy(this,`arch`,detectArch),this.env=getEnvProxy(),this.argv=getArgv(),this.argv0=this.argv[0]||`gjs`,this.execPath=getExecPath(),this.execArgv=globalThis.process?.execArgv??[],this.config=globalThis.process?.config??{target_defaults:{},variables:{}},this.pid=getPid$1(),this.ppid=detectPpid();let e=detectVersionInfo();this.version=e.version,this.versions=e.versions,this.title=e.title}cwd(){return getCwd()}chdir(e){chdir(e)}kill(e,t){return killPid(e,t)}exit(e){return this.exitCode=e??this.exitCode??0,this.emit(`exit`,this.exitCode),exitProcess(this.exitCode)}nextTick(e,...t){typeof queueMicrotask==`function`?queueMicrotask(()=>e(...t)):Promise.resolve().then(()=>e(...t))}hrtime(e){return hrtime(e)}uptime(){return(Date.now()-Fe)/1e3}memoryUsage(){return memoryUsage()}cpuUsage(e){return cpuUsage(e)}stdout=new ProcessWriteStream(1);stderr=new ProcessWriteStream(2);stdin=new ProcessReadStream(0);abort(){this.exit(1)}umask(e){let t=readUmask();return e!==void 0&&!this._umaskWarned&&(this._umaskWarned=!0,this.emitWarning(`process.umask(0${e.toString(8)}) cannot change the file-creation mask under GJS — there is no umask(2) binding, so the mask is UNCHANGED. Pass an explicit \`mode\` to open/mkdir/writeFile instead; the kernel applies it atomically at creation.`,`UnsupportedWarning`)),t}_umaskWarned=!1;emitWarning(e,t){T.warn(typeof e==`string`?`(${t||`Warning`}): ${e}`:e.message)}};Process.prototype.hrtime.bigint=function(){return hrtimeBigint()};const Ie=new Process;if(Te)try{let e=new Te.ResizeWatcher;e.connect(`resized`,(e,t,n)=>{Ie.stdout.emit(`resize`),Ie.stderr.emit(`resize`)}),e.start()}catch{}Ie.platform,Ie.arch,Ie.env,Ie.argv,Ie.argv0,Ie.execPath,Ie.pid,Ie.ppid,Ie.version,Ie.versions,Ie.cwd.bind(Ie),Ie.chdir.bind(Ie),Ie.exit.bind(Ie),Ie.nextTick.bind(Ie),Object.assign(Ie.hrtime.bind(Ie),{bigint:hrtimeBigint}),Ie.uptime.bind(Ie),Ie.memoryUsage.bind(Ie),Ie.cpuUsage.bind(Ie),Ie.kill.bind(Ie),Ie.abort.bind(Ie),Ie.umask.bind(Ie),Ie.emitWarning.bind(Ie),Ie.execArgv,Ie.config,Ie.stdout,Ie.stderr,Ie.stdin,ce(),typeof Promise.withResolvers!=`function`&&(Promise.withResolvers=function(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}),initErrorV8Methods(Error),`global`in globalThis||Object.defineProperty(globalThis,"global",{value:globalThis,writable:!1,enumerable:!1,configurable:!0}),Object.defineProperty(globalThis,"process",{value:Ie,enumerable:!1,writable:!0,configurable:!0}),ce(),typeof globalThis.structuredClone!=`function`&&Object.defineProperty(globalThis,"structuredClone",{value:structuredClone$1,enumerable:!0,writable:!0,configurable:!0});function getGLib(){return globalThis.imports?.gi?.GLib}const Le=getGLib()!==void 0;var GjsifyTimeout=class{_id=null;_refed=!0;_callback;_delay;_args;_repeat;constructor(e,t,n,r){this._callback=e,this._delay=t,this._args=n,this._repeat=r,this._schedule()}_schedule(){let e=getGLib();if(!e)return;let t=e.timeout_add.bind(e);this._id=t(e.PRIORITY_DEFAULT,this._delay,()=>{try{this._callback.apply(globalThis,this._args)}catch(e){setTimeout(()=>{throw e},0)}return this._repeat?e.SOURCE_CONTINUE:(this._id=null,e.SOURCE_REMOVE)})}ref(){return this._refed=!0,this}unref(){return this._refed=!1,this}hasRef(){return this._refed}refresh(){return this._cancel(),this._schedule(),this}_cancel(){this._id!==null&&(getGLib()?.Source.remove(this._id),this._id=null)}[Symbol.toPrimitive](){return this._id}[Symbol.dispose](){this._cancel()}};function removeById(e){e instanceof GjsifyTimeout?e._cancel():typeof e==`number`&&getGLib()?.Source.remove(e)}if(Le){let setT=(e,t=0,...n)=>new GjsifyTimeout(e,Math.max(0,t|0),n,!1),setI=(e,t=0,...n)=>new GjsifyTimeout(e,Math.max(0,t|0),n,!0),e=globalThis;e.setTimeout=setT,e.clearTimeout=removeById,e.setInterval=setI,e.clearInterval=removeById}function setImmediate(e,...t){return setTimeout(e,0,...t)}function clearImmediate(e){clearTimeout(e)}`setImmediate`in globalThis||Object.defineProperty(globalThis,"setImmediate",{value:setImmediate,enumerable:!0,writable:!0,configurable:!0}),`clearImmediate`in globalThis||Object.defineProperty(globalThis,"clearImmediate",{value:clearImmediate,enumerable:!0,writable:!0,configurable:!0});function decodeComponent(e){try{return decodeURIComponent(e.replace(/\+/g,` `))}catch{return e}}function encodeComponent(e){return encodeURIComponent(e).replace(/%20/g,`+`)}function fileURLToPath(e){if(typeof e==`string`&&(e=new ze(e)),!(e instanceof ze))throw TypeError(`The "url" argument must be of type string or URL. Received type `+typeof e);if(e.protocol!==`file:`)throw TypeError(`The URL must be of scheme file`);if(e.hostname!==``&&e.hostname!==`localhost`)throw TypeError(`File URL host must be "localhost" or empty on linux`);let t=e.pathname;for(let e=0;e<t.length;e++)if(t[e]===`%`){let n=t.codePointAt(e+2)|32;if(t[e+1]===`2`&&n===102)throw TypeError(`File URL path must not include encoded / characters`)}return decodeURIComponent(t)}function pathToFileURL(e){let t=e;return e[0]!==`/`&&(typeof globalThis.process?.cwd==`function`?t=globalThis.process.cwd()+`/`+e:L?.get_current_dir&&(t=L.get_current_dir()+`/`+e)),new ze(`file://`+encodePathForURL(t))}function encodePathForURL(e){let t=``;for(let n=0;n<e.length;n++){let r=e[n];r>=`a`&&r<=`z`||r>=`A`&&r<=`Z`||r>=`0`&&r<=`9`||r===`/`||r===`-`||r===`_`||r===`.`||r===`~`||r===`:`||r===`@`||r===`!`?t+=r:t+=encodeURIComponent(r)}return t}var Re,z,ze,Be=__esmMin(()=>{be(),Re=L.UriFlags.HAS_PASSWORD|L.UriFlags.ENCODED|L.UriFlags.SCHEME_NORMALIZE,z=class URLSearchParams{_entries=[];constructor(e){if(e)if(typeof e==`string`){let t=e.startsWith(`?`)?e.slice(1):e;if(t)for(let e of t.split(`&`)){let t=e.indexOf(`=`);t===-1?this._entries.push([decodeComponent(e),``]):this._entries.push([decodeComponent(e.slice(0,t)),decodeComponent(e.slice(t+1))])}}else if(Array.isArray(e))for(let[t,n]of e)this._entries.push([String(t),String(n)]);else if(e instanceof URLSearchParams)this._entries=e._entries.map(([e,t])=>[e,t]);else for(let t of Object.keys(e))this._entries.push([t,String(e[t])])}get(e){for(let[t,n]of this._entries)if(t===e)return n;return null}getAll(e){return this._entries.filter(([t])=>t===e).map(([,e])=>e)}set(e,t){let n=!1;if(this._entries=this._entries.filter(([t])=>t===e?n?!1:(n=!0,!0):!0),n){for(let n=0;n<this._entries.length;n++)if(this._entries[n][0]===e){this._entries[n][1]=t;break}}else this._entries.push([e,t])}has(e){return this._entries.some(([t])=>t===e)}delete(e){this._entries=this._entries.filter(([t])=>t!==e)}append(e,t){this._entries.push([e,t])}sort(){this._entries.sort((e,t)=>e[0]<t[0]?-1:+(e[0]>t[0]))}toString(){return this._entries.map(([e,t])=>encodeComponent(e)+`=`+encodeComponent(t)).join(`&`)}forEach(e){for(let[t,n]of this._entries)e(n,t,this)}*entries(){yield*this._entries}*keys(){for(let[e]of this._entries)yield e}*values(){for(let[,e]of this._entries)yield e}[Symbol.iterator](){return this.entries()}get size(){return this._entries.length}},ze=class URL{#e;#t;constructor(e,t){let n=e instanceof URL?e.href:String(e);try{if(t!==void 0){let e=t instanceof URL?t.href:String(t),r=L.Uri.parse(e,Re);this.#e=r.parse_relative(n,Re)}else this.#e=L.Uri.parse(n,Re)}catch{throw TypeError(`Invalid URL: ${n}`)}if(!this.#e)throw TypeError(`Invalid URL: ${n}`);this.#t=new z(this.#e.get_query()||``)}get protocol(){return this.#e.get_scheme()+`:`}get hostname(){return(this.#e.get_host()||``).toLowerCase()}get port(){let e=this.#e.get_port();if(e===-1)return``;let t=this.#e.get_scheme();return(t===`http`||t===`ws`)&&e===80||(t===`https`||t===`wss`)&&e===443||t===`ftp`&&e===21?``:String(e)}get host(){let e=this.hostname,t=this.port;return t?`${e}:${t}`:e}get pathname(){return this.#e.get_path()||`/`}get search(){let e=this.#e.get_query();return e?`?`+e:``}get hash(){let e=this.#e.get_fragment();return e?`#`+e:``}get origin(){let e=this.protocol;return e===`http:`||e===`https:`||e===`ftp:`?`${e}//${this.host}`:`null`}get username(){return this.#e.get_user()||``}get password(){return this.#e.get_password()||``}get href(){let e=this.protocol,t=this.#e.get_scheme();(t===`http`||t===`https`||t===`ftp`||t===`file`||t===`ws`||t===`wss`||this.hostname)&&(e+=`//`);let n=this.username,r=this.password;n&&(e+=n,r&&(e+=`:`+r),e+=`@`),e+=this.hostname,this.port&&(e+=`:`+this.port);let i=this.pathname;return e+=i,e+=this.search,e+=this.hash,e}get searchParams(){return this.#t}toString(){return this.href}toJSON(){return this.href}static _objectURLPaths=new Map;static _objectURLCounter=0;static createObjectURL(e){let t=e?._tmpPath;if(typeof t==`string`&&t.length>0){let e=`file://${t}`;return URL._objectURLPaths.set(e,t),e}return`file:///dev/null`}static revokeObjectURL(e){let t=URL._objectURLPaths.get(e);t&&(L.unlink(t),URL._objectURLPaths.delete(e))}}});Be(),typeof globalThis.URL!=`function`&&Object.defineProperty(globalThis,"URL",{value:ze,enumerable:!1,writable:!0,configurable:!0}),typeof globalThis.URLSearchParams!=`function`&&Object.defineProperty(globalThis,"URLSearchParams",{value:z,enumerable:!1,writable:!0,configurable:!0});var Ve=__exportAll$2({PerformanceEntry:()=>We,PerformanceMark:()=>V,PerformanceMeasure:()=>Ke,PerformanceObserver:()=>Ue,PerformanceObserverEntryList:()=>Ge,default:()=>qe,eventLoopUtilization:()=>eventLoopUtilization,monitorEventLoopDelay:()=>monitorEventLoopDelay,performance:()=>He,timerify:()=>timerify});function eventLoopUtilization(e,t){return{idle:0,active:0,utilization:0}}function timerify(e){let wrapped=function(...t){let n=He.now(),r=e.apply(this,t);return He.now()-n,r};return Object.defineProperty(wrapped,"name",{value:e.name}),wrapped}function monitorEventLoopDelay(e){let t=new Map;return{enable(){},disable(){},reset(){},percentile(e){return 0},get min(){return 0},get max(){return 0},get mean(){return 0},get stddev(){return 0},get percentiles(){return t}}}var He,PerformanceObserverStub,PerformanceEntryStub,PerformanceObserverEntryListStub,B,Ue,We,Ge,V,Ke,qe,Je=__esmMin(()=>{if(globalThis.performance)He=globalThis.performance;else{let e,_now;try{let t=globalThis.imports?.gi?.GLib;if(!t)throw Error(`GJS imports.gi.GLib not available`);e=t.get_monotonic_time(),_now=()=>(t.get_monotonic_time()-e)/1e3}catch{let t=Date.now();e=0,_now=()=>Date.now()-t}let t=[],n=Date.now()-_now();He={timeOrigin:n,now:_now,mark(e){let n={name:e,entryType:`mark`,startTime:_now(),duration:0};return t.push(n),n},measure(e,n,r){let i=0,a=_now();if(n){let e=t.find(e=>e.entryType===`mark`&&e.name===n);e&&(i=e.startTime)}if(r){let e=t.find(e=>e.entryType===`mark`&&e.name===r);e&&(a=e.startTime)}let o={name:e,entryType:`measure`,startTime:i,duration:a-i};return t.push(o),o},getEntries(){return[...t]},getEntriesByName(e){return t.filter(t=>t.name===e)},getEntriesByType(e){return t.filter(t=>t.entryType===e)},clearMarks(e){for(let n=t.length-1;n>=0;n--)t[n].entryType===`mark`&&(!e||t[n].name===e)&&t.splice(n,1)},clearMeasures(e){for(let n=t.length-1;n>=0;n--)t[n].entryType===`measure`&&(!e||t[n].name===e)&&t.splice(n,1)},clearResourceTimings(){},setResourceTimingBufferSize(){},toJSON(){return{timeOrigin:n}}}}PerformanceObserverStub=class{_callback;constructor(e){this._callback=e}observe(e){}disconnect(){}takeRecords(){return[]}},PerformanceEntryStub=class{name=``;entryType=``;startTime=0;duration=0;toJSON(){return{name:this.name,entryType:this.entryType,startTime:this.startTime,duration:this.duration}}},PerformanceObserverEntryListStub=class{getEntries(){return[]}getEntriesByName(e){return[]}getEntriesByType(e){return[]}},B=globalThis,Ue=B.PerformanceObserver||PerformanceObserverStub,We=B.PerformanceEntry||PerformanceEntryStub,Ge=B.PerformanceObserverEntryList||PerformanceObserverEntryListStub,V=B.PerformanceMark||class PerformanceMark extends PerformanceEntryStub{},Ke=B.PerformanceMeasure||class PerformanceMeasure extends PerformanceEntryStub{},qe={performance:He,PerformanceObserver:Ue,PerformanceEntry:We,PerformanceObserverEntryList:Ge,PerformanceMark:V,PerformanceMeasure:Ke,eventLoopUtilization,timerify,monitorEventLoopDelay}});Je();const H=globalThis;globalThis.performance===void 0&&(H.performance=He),typeof H.PerformanceObserver!=`function`&&(H.PerformanceObserver=Ue);const U={IndexSizeError:1,HierarchyRequestError:3,WrongDocumentError:4,InvalidCharacterError:5,NoModificationAllowedError:7,NotFoundError:8,NotSupportedError:9,InUseAttributeError:10,InvalidStateError:11,SyntaxError:12,InvalidModificationError:13,NamespaceError:14,InvalidAccessError:15,TypeMismatchError:17,SecurityError:18,NetworkError:19,AbortError:20,URLMismatchError:21,QuotaExceededError:22,TimeoutError:23,InvalidNodeTypeError:24,DataCloneError:25};var _DOMExceptionPolyfill=class extends Error{code;constructor(e,t){super(e),this.name=t||`Error`,this.code=Object.hasOwn(U,this.name)?U[this.name]:0}};const Ye=globalThis.DOMException===void 0?_DOMExceptionPolyfill:globalThis.DOMException;E();const Xe=Symbol(`type`),Ze=Symbol(`bubbles`),Qe=Symbol(`cancelable`),$e=Symbol(`composed`),et=Symbol(`target`),W=Symbol(`currentTarget`),G=Symbol(`eventPhase`),tt=Symbol(`defaultPrevented`),nt=Symbol(`isTrusted`),rt=Symbol(`timeStamp`),it=Symbol(`stop`),at=Symbol(`immediateStop`),ot=Symbol(`dispatching`),st=Symbol(`inPassiveListener`);var Event=class{[Xe];[Ze];[Qe];[$e];[et]=null;[W]=null;[G]=0;[tt]=!1;[nt]=!1;[rt];[it]=!1;[at]=!1;[ot]=!1;[st]=!1;get type(){return this[Xe]}get bubbles(){return this[Ze]}get cancelable(){return this[Qe]}get composed(){return this[$e]}get target(){return this[et]}get currentTarget(){return this[W]}get eventPhase(){return this[G]}get defaultPrevented(){return this[tt]}get timeStamp(){return this[rt]}get cancelBubble(){return this[it]}set cancelBubble(e){e&&this.stopPropagation()}get returnValue(){return!this[tt]}set returnValue(e){e||this.preventDefault()}get srcElement(){return this[et]}static NONE=0;static CAPTURING_PHASE=1;static AT_TARGET=2;static BUBBLING_PHASE=3;get[Symbol.toStringTag](){return`Event`}constructor(e,t){this[Xe]=e,this[Ze]=t?.bubbles??!1,this[Qe]=t?.cancelable??!1,this[$e]=t?.composed??!1,this[rt]=Date.now(),Object.defineProperty(this,"isTrusted",{get:()=>this[nt],enumerable:!0,configurable:!1})}composedPath(){return this[W]?[this[W]]:[]}preventDefault(){this[Qe]&&!this[st]&&(this[tt]=!0)}stopPropagation(){this[it]=!0}stopImmediatePropagation(){this[it]=!0,this[at]=!0}},EventTarget=class{#e=new Map;get[Symbol.toStringTag](){return`EventTarget`}addEventListener(e,t,n){if(t===null)return;let r=typeof n==`boolean`?n:n?.capture??!1,i=typeof n==`object`?n?.once??!1:!1,a=typeof n==`object`?n?.passive??!1:!1,o=this.#e.get(e);o||(o=[],this.#e.set(e,o));for(let e of o)if(e.listener===t&&e.capture===r)return;let s={listener:t,capture:r,once:i,passive:a,removed:!1};o.push(s),typeof n==`object`&&n?.signal&&n.signal.addEventListener(`abort`,()=>{this.removeEventListener(e,t,{capture:r})},{once:!0})}removeEventListener(e,t,n){if(t===null)return;let r=typeof n==`boolean`?n:n?.capture??!1,i=this.#e.get(e);if(!i)return;let a=i.findIndex(e=>e.listener===t&&e.capture===r);a!==-1&&(i[a].removed=!0,i.splice(a,1),i.length===0&&this.#e.delete(e))}dispatchEvent(e){let t=e;if(t[ot])throw new Ye(`The event is already being dispatched.`,`InvalidStateError`);t[ot]=!0,t[et]=this,t[W]=this,t[G]=Event.AT_TARGET;try{let n=this.#e.get(e.type);if(n){let r=[...n];for(let n of r)if(!n.removed){if(t[at]||t[it])break;n.once&&this.removeEventListener(e.type,n.listener,{capture:n.capture});try{n.passive&&(t[st]=!0),typeof n.listener==`function`?n.listener.call(this,e):typeof n.listener.handleEvent==`function`&&n.listener.handleEvent.call(n.listener,e)}catch(e){reportListenerException(e)}finally{t[st]=!1}}}}finally{t[G]=Event.NONE,t[W]=null,t[ot]=!1}return!e.defaultPrevented}};function reportListenerException(e){try{let t=globalThis;if(typeof t.reportError==`function`)t.reportError(e);else if(e instanceof Error){let t=`${e.name}: ${e.message}`;T.error(e.stack?`${t}\n${e.stack}`:t)}else T.error(String(e))}catch{}}for(let[e,t]of[[`NONE`,0],[`CAPTURING_PHASE`,1],[`AT_TARGET`,2],[`BUBBLING_PHASE`,3]])Object.defineProperty(Event.prototype,e,{value:t,writable:!1,enumerable:!0,configurable:!1}),Object.defineProperty(Event,e,{value:t,writable:!1,enumerable:!0,configurable:!1});const ct=Symbol(`abort`),K=Symbol(`internal`);var lt=class AbortSignal extends EventTarget{#e=!1;#t=void 0;onabort=null;constructor(e){if(super(),e!==K)throw TypeError(`Illegal constructor.`)}get aborted(){if(!(this instanceof AbortSignal))throw TypeError(`'get aborted' called on an object that is not a valid instance of AbortSignal.`);return this.#e}get reason(){return this.#t}get[Symbol.toStringTag](){return`AbortSignal`}throwIfAborted(){if(this.#e)throw this.#t}[ct](e){if(this.#e)return;this.#e=!0,this.#t=e??new Ye(`The operation was aborted.`,`AbortError`);let t=new Event(`abort`);typeof this.onabort==`function`&&this.onabort.call(this,t),this.dispatchEvent(t)}static abort(e){let t=new AbortSignal(K);return t[ct](e),t}static timeout(e){let t=new AbortSignal(K);return setTimeout(()=>{t[ct](new Ye(`The operation timed out.`,`TimeoutError`))},e),t}static any(e){let t=new AbortSignal(K);for(let n of e)if(n.aborted)return t[ct](n.reason),t;let onAbort=()=>{if(!t.aborted){let n=e.find(e=>e.aborted);t[ct](n?.reason)}};for(let t of e)t.addEventListener(`abort`,onAbort,{once:!0});return t}},ut=class AbortController{signal;constructor(){this.signal=new lt(K)}get[Symbol.toStringTag](){return`AbortController`}abort(e){if(!(this instanceof AbortController))throw TypeError(`'abort' called on an object that is not a valid instance of AbortController.`);this.signal[ct](e)}};const dt=globalThis;globalThis.AbortController===void 0&&(dt.AbortController=ut),globalThis.AbortSignal===void 0&&(dt.AbortSignal=lt);const ft=globalThis;globalThis.DOMException===void 0&&(ft.DOMException=Ye);const q=Symbol(`kState`),pt=Symbol(`kType`);function isBrandCheck(e){return t=>typeof t==`object`&&!!t&&t[q]!==void 0&&t[pt]===e}function dequeueValue(e){let t=e[q].queue.shift();if(t===void 0)throw Error(`dequeueValue called on an empty queue`);let{value:n,size:r}=t;return e[q].queueTotalSize=Math.max(0,e[q].queueTotalSize-r),n}function resetQueue(e){e[q].queue=[],e[q].queueTotalSize=0}function peekQueueValue(e){return e[q].queue[0].value}function enqueueValueWithSize(e,t,n){if(n=+n,typeof n!=`number`||n<0||Number.isNaN(n)||n===1/0)throw RangeError(`Invalid size: ${n}`);e[q].queue.push({value:t,size:n}),e[q].queueTotalSize+=n}function extractHighWaterMark(e,t){if(e===void 0)return t;if(e=+e,typeof e!=`number`||Number.isNaN(e)||e<0)throw RangeError(`Invalid highWaterMark: ${e}`);return e}function extractSizeAlgorithm(e){if(e===void 0)return()=>1;if(typeof e!=`function`)throw TypeError(`strategy.size must be a function`);return e}function transferArrayBuffer(e){return typeof ArrayBuffer.prototype.transfer==`function`?e.transfer():e.slice(0)}function isDetachedBuffer(e){if(typeof SharedArrayBuffer<`u`&&e instanceof SharedArrayBuffer||e.byteLength!==0)return!1;try{return e.slice(0,0),!1}catch{return!0}}function typedArrayConstructorByTag(e){switch(e){case`Int8Array`:return Int8Array;case`Uint8Array`:return Uint8Array;case`Uint8ClampedArray`:return Uint8ClampedArray;case`Int16Array`:return Int16Array;case`Uint16Array`:return Uint16Array;case`Int32Array`:return Int32Array;case`Uint32Array`:return Uint32Array;case`Float32Array`:return Float32Array;case`Float64Array`:return Float64Array;case`BigInt64Array`:return typeof BigInt64Array<`u`?BigInt64Array:void 0;case`BigUint64Array`:return typeof BigUint64Array<`u`?BigUint64Array:void 0;default:return}}function elementSizeByTag(e){switch(e){case`Int8Array`:case`Uint8Array`:case`Uint8ClampedArray`:return 1;case`Int16Array`:case`Uint16Array`:return 2;case`Int32Array`:case`Uint32Array`:case`Float32Array`:return 4;case`Float64Array`:case`BigInt64Array`:case`BigUint64Array`:return 8;default:return 1}}function setPromiseHandled(e){e.then(()=>{},()=>{})}function createPromiseCallback(e,t,n){if(typeof t!=`function`)throw TypeError(`${e} must be a function`);return async(...e)=>t.call(n,...e)}async function nonOpFlush(){}function nonOpStart(){}async function nonOpPull(){}async function nonOpCancel(){}async function nonOpWrite(){}const mt={__proto__:Object.getPrototypeOf(Object.getPrototypeOf(async function*(){}).prototype),next:void 0,return:void 0};function createAsyncFromSyncIterator(e){let t={[Symbol.iterator]:()=>e.iterator},n=(async function*(){return yield*t})();return{iterator:n,nextMethod:n.next,done:!1}}function getIterator(e,t=`sync`,n){if(n===void 0)if(t===`async`){if(n=e[Symbol.asyncIterator],n==null){let t=e[Symbol.iterator];if(t===void 0)throw TypeError(`Object is not iterable`);return createAsyncFromSyncIterator(getIterator(e,`sync`,t))}}else n=e[Symbol.iterator];if(n===void 0)throw TypeError(`Object is not iterable`);let r=n.call(e);if(typeof r!=`object`||!r)throw TypeError(`The iterator method must return an object`);return{iterator:r,nextMethod:r.next,done:!1}}function iteratorNext(e,t){let n;if(n=t===void 0?e.nextMethod.call(e.iterator):e.nextMethod.call(e.iterator,t),typeof n!=`object`||!n)throw TypeError(`The iterator.next() method must return an object`);return n}const ht=typeof globalThis.AbortController==`function`?globalThis.AbortController:class AbortControllerShim{signal={aborted:!1,reason:void 0,addEventListener(){},removeEventListener(){}};abort(e){this.signal.aborted=!0,this.signal.reason=e}},gt=Symbol(`kAbort`),_t=Symbol(`kCloseSentinel`),vt=Symbol(`kError`),yt=Symbol(`kSkipThrow`);var WritableStream=class{[pt]=`WritableStream`;[q];constructor(e={},t={}){if(e!=null&&typeof e!=`object`)throw TypeError(`sink must be an object`);if(t!=null&&typeof t!=`object`)throw TypeError(`strategy must be an object`);let n=e?.type;if(n!==void 0)throw RangeError(`Invalid type: ${n}`);this[q]=createWritableStreamState();let r=extractSizeAlgorithm(t?.size),i=extractHighWaterMark(t?.highWaterMark,1);setupWritableStreamDefaultControllerFromSink(this,e,i,r)}get locked(){if(!bt(this))throw TypeError(`Invalid this`);return isWritableStreamLocked(this)}abort(e){return bt(this)?isWritableStreamLocked(this)?Promise.reject(TypeError(`WritableStream is locked`)):writableStreamAbort(this,e):Promise.reject(TypeError(`Invalid this`))}close(){return bt(this)?isWritableStreamLocked(this)?Promise.reject(TypeError(`WritableStream is locked`)):writableStreamCloseQueuedOrInFlight(this)?Promise.reject(TypeError(`Failure closing WritableStream`)):writableStreamClose(this):Promise.reject(TypeError(`Invalid this`))}getWriter(){if(!bt(this))throw TypeError(`Invalid this`);return new WritableStreamDefaultWriter(this)}get[Symbol.toStringTag](){return`WritableStream`}},WritableStreamDefaultWriter=class{[pt]=`WritableStreamDefaultWriter`;[q];constructor(e){if(!bt(e))throw TypeError(`Expected a WritableStream`);this[q]={stream:void 0,close:{promise:void 0,resolve:void 0,reject:void 0},ready:{promise:void 0,resolve:void 0,reject:void 0}},setupWritableStreamDefaultWriter(this,e)}get closed(){return xt(this)?this[q].close.promise:Promise.reject(TypeError(`Invalid this`))}get desiredSize(){if(!xt(this))throw TypeError(`Invalid this`);if(this[q].stream===void 0)throw TypeError(`Writer is not bound to a WritableStream`);return writableStreamDefaultWriterGetDesiredSize(this)}get ready(){return xt(this)?this[q].ready.promise:Promise.reject(TypeError(`Invalid this`))}abort(e){return xt(this)?this[q].stream===void 0?Promise.reject(TypeError(`Writer is not bound to a WritableStream`)):writableStreamDefaultWriterAbort(this,e):Promise.reject(TypeError(`Invalid this`))}close(){if(!xt(this))return Promise.reject(TypeError(`Invalid this`));let{stream:e}=this[q];return e===void 0?Promise.reject(TypeError(`Writer is not bound to a WritableStream`)):writableStreamCloseQueuedOrInFlight(e)?Promise.reject(TypeError(`Failure to close WritableStream`)):writableStreamDefaultWriterClose(this)}releaseLock(){if(!xt(this))throw TypeError(`Invalid this`);let{stream:e}=this[q];e!==void 0&&writableStreamDefaultWriterRelease(this)}write(e){return xt(this)?this[q].stream===void 0?Promise.reject(TypeError(`Writer is not bound to a WritableStream`)):writableStreamDefaultWriterWrite(this,e):Promise.reject(TypeError(`Invalid this`))}get[Symbol.toStringTag](){return`WritableStreamDefaultWriter`}},WritableStreamDefaultController=class{[pt]=`WritableStreamDefaultController`;[q];constructor(e){if(e!==yt)throw TypeError(`Illegal constructor`)}[gt](e){let t=this[q].abortAlgorithm(e);return writableStreamDefaultControllerClearAlgorithms(this),t}[vt](){resetQueue(this)}get signal(){if(!St(this))throw TypeError(`Invalid this`);return this[q].abortController.signal}error(e){if(!St(this))throw TypeError(`Invalid this`);this[q].stream[q].state===`writable`&&writableStreamDefaultControllerError(this,e)}get[Symbol.toStringTag](){return`WritableStreamDefaultController`}};const bt=isBrandCheck(`WritableStream`),xt=isBrandCheck(`WritableStreamDefaultWriter`),St=isBrandCheck(`WritableStreamDefaultController`);function createEmptyPromiseRecord(){return{promise:void 0,resolve:void 0,reject:void 0}}function createWritableStreamState(){return{close:Promise.withResolvers(),closeRequest:createEmptyPromiseRecord(),inFlightWriteRequest:createEmptyPromiseRecord(),inFlightCloseRequest:createEmptyPromiseRecord(),pendingAbortRequest:{abort:createEmptyPromiseRecord(),reason:void 0,wasAlreadyErroring:!1},backpressure:!1,controller:void 0,state:`writable`,storedError:void 0,writeRequests:[],writer:void 0}}function isWritableStreamLocked(e){return e[q].writer!==void 0}function setupWritableStreamDefaultWriter(e,t){if(isWritableStreamLocked(t))throw TypeError(`WritableStream is locked`);switch(e[q].stream=t,t[q].writer=e,t[q].state){case`writable`:!writableStreamCloseQueuedOrInFlight(t)&&t[q].backpressure?e[q].ready=Promise.withResolvers():e[q].ready={promise:Promise.resolve(),resolve:void 0,reject:void 0},e[q].close=Promise.withResolvers();break;case`erroring`:e[q].ready={promise:Promise.reject(t[q].storedError),resolve:void 0,reject:void 0},setPromiseHandled(e[q].ready.promise),e[q].close=Promise.withResolvers();break;case`closed`:e[q].ready={promise:Promise.resolve(),resolve:void 0,reject:void 0},e[q].close={promise:Promise.resolve(),resolve:void 0,reject:void 0};break;default:e[q].ready={promise:Promise.reject(t[q].storedError),resolve:void 0,reject:void 0},e[q].close={promise:Promise.reject(t[q].storedError),resolve:void 0,reject:void 0},setPromiseHandled(e[q].ready.promise),setPromiseHandled(e[q].close.promise)}}function writableStreamAbort(e,t){let{state:n,controller:r}=e[q];if(n===`closed`||n===`errored`)return Promise.resolve();if(r[q].abortController.abort(t),e[q].pendingAbortRequest.abort.promise!==void 0)return e[q].pendingAbortRequest.abort.promise;let i=!1;n===`erroring`&&(i=!0,t=void 0);let a=Promise.withResolvers();return e[q].pendingAbortRequest={abort:a,reason:t,wasAlreadyErroring:i},i||writableStreamStartErroring(e,t),a.promise}function writableStreamClose(e){let{state:t,writer:n,backpressure:r,controller:i}=e[q];if(t===`closed`||t===`errored`)return Promise.reject(TypeError(`WritableStream is closed`));e[q].closeRequest=Promise.withResolvers();let{promise:a}=e[q].closeRequest;return n!==void 0&&r&&t===`writable`&&n[q].ready.resolve?.(),writableStreamDefaultControllerClose(i),a}function writableStreamUpdateBackpressure(e,t){let{writer:n}=e[q];n!==void 0&&e[q].backpressure!==t&&(t?n[q].ready=Promise.withResolvers():n[q].ready.resolve?.()),e[q].backpressure=t}function writableStreamStartErroring(e,t){let{controller:n,writer:r}=e[q];e[q].state=`erroring`,e[q].storedError=t,r!==void 0&&writableStreamDefaultWriterEnsureReadyPromiseRejected(r,t),!writableStreamHasOperationMarkedInFlight(e)&&n[q].started&&writableStreamFinishErroring(e)}function writableStreamRejectCloseAndClosedPromiseIfNeeded(e){e[q].closeRequest.promise!==void 0&&(e[q].closeRequest.reject?.(e[q].storedError),e[q].closeRequest={promise:void 0,resolve:void 0,reject:void 0}),setPromiseHandled(e[q].close.promise),e[q].close.reject?.(e[q].storedError);let{writer:t}=e[q];t!==void 0&&(setPromiseHandled(t[q].close.promise),t[q].close.reject?.(e[q].storedError))}function writableStreamMarkFirstWriteRequestInFlight(e){let t=e[q].writeRequests.shift();e[q].inFlightWriteRequest=t}function writableStreamMarkCloseRequestInFlight(e){e[q].inFlightCloseRequest=e[q].closeRequest,e[q].closeRequest={promise:void 0,resolve:void 0,reject:void 0}}function writableStreamHasOperationMarkedInFlight(e){return e[q].inFlightWriteRequest.promise!==void 0||e[q].inFlightCloseRequest.promise!==void 0}function writableStreamFinishInFlightWriteWithError(e,t){e[q].inFlightWriteRequest.reject?.(t),e[q].inFlightWriteRequest={promise:void 0,resolve:void 0,reject:void 0},writableStreamDealWithRejection(e,t)}function writableStreamFinishInFlightWrite(e){e[q].inFlightWriteRequest.resolve?.(),e[q].inFlightWriteRequest={promise:void 0,resolve:void 0,reject:void 0}}function writableStreamFinishInFlightCloseWithError(e,t){e[q].inFlightCloseRequest.reject?.(t),e[q].inFlightCloseRequest={promise:void 0,resolve:void 0,reject:void 0},e[q].pendingAbortRequest.abort.promise!==void 0&&(e[q].pendingAbortRequest.abort.reject?.(t),e[q].pendingAbortRequest={abort:{promise:void 0,resolve:void 0,reject:void 0},reason:void 0,wasAlreadyErroring:!1}),writableStreamDealWithRejection(e,t)}function writableStreamFinishInFlightClose(e){e[q].inFlightCloseRequest.resolve?.(),e[q].inFlightCloseRequest={promise:void 0,resolve:void 0,reject:void 0},e[q].state===`erroring`&&(e[q].storedError=void 0,e[q].pendingAbortRequest.abort.promise!==void 0&&(e[q].pendingAbortRequest.abort.resolve?.(),e[q].pendingAbortRequest={abort:{promise:void 0,resolve:void 0,reject:void 0},reason:void 0,wasAlreadyErroring:!1})),e[q].state=`closed`,e[q].writer!==void 0&&e[q].writer[q].close.resolve?.(),e[q].close.resolve?.()}function writableStreamFinishErroring(e){e[q].state=`errored`,e[q].controller[vt]();let t=e[q].storedError;for(let n of e[q].writeRequests)n.reject?.(t);if(e[q].writeRequests=[],e[q].pendingAbortRequest.abort.promise===void 0){writableStreamRejectCloseAndClosedPromiseIfNeeded(e);return}let n=e[q].pendingAbortRequest;if(e[q].pendingAbortRequest={abort:{promise:void 0,resolve:void 0,reject:void 0},reason:void 0,wasAlreadyErroring:!1},n.wasAlreadyErroring){n.abort.reject?.(t),writableStreamRejectCloseAndClosedPromiseIfNeeded(e);return}e[q].controller[gt](n.reason).then(()=>{n.abort.resolve?.(),writableStreamRejectCloseAndClosedPromiseIfNeeded(e)},t=>{n.abort.reject?.(t),writableStreamRejectCloseAndClosedPromiseIfNeeded(e)})}function writableStreamDealWithRejection(e,t){if(e[q].state===`writable`){writableStreamStartErroring(e,t);return}writableStreamFinishErroring(e)}function writableStreamCloseQueuedOrInFlight(e){return e[q].closeRequest.promise!==void 0||e[q].inFlightCloseRequest.promise!==void 0}function writableStreamAddWriteRequest(e){let{promise:t,resolve:n,reject:r}=Promise.withResolvers();return e[q].writeRequests.push({promise:t,resolve:n,reject:r}),t}function writableStreamDefaultWriterWrite(e,t){let{stream:n}=e[q],{controller:r}=n[q],i=writableStreamDefaultControllerGetChunkSize(r,t);if(n!==e[q].stream)return Promise.reject(TypeError(`Mismatched WritableStreams`));let{state:a}=n[q];if(a===`errored`)return Promise.reject(n[q].storedError);if(writableStreamCloseQueuedOrInFlight(n)||a===`closed`)return Promise.reject(TypeError(`WritableStream is closed`));if(a===`erroring`)return Promise.reject(n[q].storedError);let o=writableStreamAddWriteRequest(n);return writableStreamDefaultControllerWrite(r,t,i),o}function writableStreamDefaultWriterRelease(e){let{stream:t}=e[q],n=TypeError(`Writer has been released`);writableStreamDefaultWriterEnsureReadyPromiseRejected(e,n),writableStreamDefaultWriterEnsureClosedPromiseRejected(e,n),t[q].writer=void 0,e[q].stream=void 0}function writableStreamDefaultWriterGetDesiredSize(e){let{stream:t}=e[q];switch(t[q].state){case`errored`:case`erroring`:return null;case`closed`:return 0}return writableStreamDefaultControllerGetDesiredSize(t[q].controller)}function writableStreamDefaultWriterEnsureReadyPromiseRejected(e,t){e[q].ready.reject?(e[q].ready.reject(t),e[q].ready.resolve=void 0,e[q].ready.reject=void 0):e[q].ready={promise:Promise.reject(t),resolve:void 0,reject:void 0},setPromiseHandled(e[q].ready.promise)}function writableStreamDefaultWriterEnsureClosedPromiseRejected(e,t){e[q].close.reject?(e[q].close.reject(t),e[q].close.resolve=void 0,e[q].close.reject=void 0):e[q].close={promise:Promise.reject(t),resolve:void 0,reject:void 0},setPromiseHandled(e[q].close.promise)}function writableStreamDefaultWriterCloseWithErrorPropagation(e){let{stream:t}=e[q],{state:n}=t[q];return writableStreamCloseQueuedOrInFlight(t)||n===`closed`?Promise.resolve():n===`errored`?Promise.reject(t[q].storedError):writableStreamDefaultWriterClose(e)}function writableStreamDefaultWriterClose(e){return writableStreamClose(e[q].stream)}function writableStreamDefaultWriterAbort(e,t){return writableStreamAbort(e[q].stream,t)}function writableStreamDefaultControllerWrite(e,t,n){try{enqueueValueWithSize(e,t,n)}catch(t){writableStreamDefaultControllerErrorIfNeeded(e,t);return}let{stream:r}=e[q];!writableStreamCloseQueuedOrInFlight(r)&&r[q].state===`writable`&&writableStreamUpdateBackpressure(r,writableStreamDefaultControllerGetBackpressure(e)),writableStreamDefaultControllerAdvanceQueueIfNeeded(e)}function writableStreamDefaultControllerProcessWrite(e,t){let{stream:n,writeAlgorithm:r}=e[q];writableStreamMarkFirstWriteRequestInFlight(n),r(t,e).then(()=>{writableStreamFinishInFlightWrite(n);let{state:t}=n[q];dequeueValue(e),!writableStreamCloseQueuedOrInFlight(n)&&t===`writable`&&writableStreamUpdateBackpressure(n,writableStreamDefaultControllerGetBackpressure(e)),writableStreamDefaultControllerAdvanceQueueIfNeeded(e)},t=>{n[q].state===`writable`&&writableStreamDefaultControllerClearAlgorithms(e),writableStreamFinishInFlightWriteWithError(n,t)})}function writableStreamDefaultControllerProcessClose(e){let{closeAlgorithm:t,stream:n}=e[q];writableStreamMarkCloseRequestInFlight(n),dequeueValue(e);let r=t();writableStreamDefaultControllerClearAlgorithms(e),r.then(()=>writableStreamFinishInFlightClose(n),e=>writableStreamFinishInFlightCloseWithError(n,e))}function writableStreamDefaultControllerGetDesiredSize(e){return e[q].highWaterMark-e[q].queueTotalSize}function writableStreamDefaultControllerGetChunkSize(e,t){let{sizeAlgorithm:n}=e[q];if(n===void 0)return 1;try{return n(t)}catch(t){return writableStreamDefaultControllerErrorIfNeeded(e,t),1}}function writableStreamDefaultControllerErrorIfNeeded(e,t){e[q].stream[q].state===`writable`&&writableStreamDefaultControllerError(e,t)}function writableStreamDefaultControllerError(e,t){writableStreamDefaultControllerClearAlgorithms(e),writableStreamStartErroring(e[q].stream,t)}function writableStreamDefaultControllerClose(e){enqueueValueWithSize(e,_t,0),writableStreamDefaultControllerAdvanceQueueIfNeeded(e)}function writableStreamDefaultControllerClearAlgorithms(e){e[q].writeAlgorithm=void 0,e[q].closeAlgorithm=void 0,e[q].abortAlgorithm=void 0,e[q].sizeAlgorithm=void 0}function writableStreamDefaultControllerGetBackpressure(e){return writableStreamDefaultControllerGetDesiredSize(e)<=0}function writableStreamDefaultControllerAdvanceQueueIfNeeded(e){let{queue:t,started:n,stream:r}=e[q];if(!n||r[q].inFlightWriteRequest.promise!==void 0)return;if(r[q].state===`erroring`){writableStreamFinishErroring(r);return}if(!t.length)return;let i=peekQueueValue(e);i===_t?writableStreamDefaultControllerProcessClose(e):writableStreamDefaultControllerProcessWrite(e,i)}function setupWritableStreamDefaultControllerFromSink(e,t,n,r){let i=new WritableStreamDefaultController(yt),a=t?.start,o=t?.write,s=t?.close,c=t?.abort;setupWritableStreamDefaultController(e,i,a?a.bind(t,i):nonOpStart,o?createPromiseCallback(`sink.write`,o,t):nonOpWrite,s?createPromiseCallback(`sink.close`,s,t):nonOpCancel,c?createPromiseCallback(`sink.abort`,c,t):nonOpCancel,n,r)}function setupWritableStreamDefaultController(e,t,n,r,i,a,o,s){t[q]={abortAlgorithm:a,closeAlgorithm:i,highWaterMark:o,queue:[],queueTotalSize:0,abortController:new ht,sizeAlgorithm:s,started:!1,stream:e,writeAlgorithm:r},e[q].controller=t,writableStreamUpdateBackpressure(e,writableStreamDefaultControllerGetBackpressure(t));let c=n();new Promise(e=>e(c)).then(()=>{t[q].started=!0,writableStreamDefaultControllerAdvanceQueueIfNeeded(t)},n=>{t[q].started=!0,writableStreamDealWithRejection(e,n)})}function createWritableStream(e,t,n,r,i=1,a=()=>1){let o=Object.create(WritableStream.prototype);return o[pt]=`WritableStream`,o[q]=createWritableStreamState(),setupWritableStreamDefaultController(o,new WritableStreamDefaultController(yt),e,t,n,r,i,a),o}ce();const Ct=Symbol(`kCancel`),wt=Symbol(`kClose`),Tt=Symbol(`kChunk`),Et=Symbol(`kError`),Dt=Symbol(`kPull`),Ot=Symbol(`kRelease`),kt=Symbol(`kSkipThrow`);let At,jt;function lazyReadableReleasedError(){return At||(At=TypeError(`Reader released`),At)}function lazyReadableReleasingError(){return jt||(jt=TypeError(`Releasing reader`),jt)}function createAbortError$1(){if(typeof globalThis.DOMException==`function`)return new DOMException(`The operation was aborted`,`AbortError`);let e=Error(`The operation was aborted`);return e.name=`AbortError`,e}__name(createAbortError$1,`createAbortError`);function createReadableStreamState(){return{disturbed:!1,reader:void 0,state:`readable`,storedError:void 0,controller:void 0,closedPromise:Promise.withResolvers()}}var ReadableStream$1=class{static{__name(this,`ReadableStream`)}[pt]=`ReadableStream`;[q];constructor(e={},t={}){if(e!=null&&typeof e!=`object`)throw TypeError(`source must be an object`);if(t!=null&&typeof t!=`object`)throw TypeError(`strategy must be an object`);this[q]=createReadableStreamState();let n=t?.size,r=t?.highWaterMark,i=e?.type;if(i!==void 0){if(`${i}`==`bytes`){if(n!==void 0)throw RangeError(`strategy.size must not be set for a byte stream`);setupReadableByteStreamControllerFromSource(this,e,extractHighWaterMark(r,0));return}throw RangeError(`Invalid type: ${i}`)}setupReadableStreamDefaultControllerFromSource(this,e,extractHighWaterMark(r,1),extractSizeAlgorithm(n))}get locked(){if(!Mt(this))throw TypeError(`Invalid this`);return isReadableStreamLocked(this)}static from(e){return readableStreamFromIterable(e)}cancel(e=void 0){return Mt(this)?isReadableStreamLocked(this)?Promise.reject(TypeError(`ReadableStream is locked`)):readableStreamCancel(this,e):Promise.reject(TypeError(`Invalid this`))}getReader(e={}){if(!Mt(this))throw TypeError(`Invalid this`);if(e!=null&&typeof e!=`object`)throw TypeError(`options must be an object`);let t=e?.mode;if(t===void 0)return new ReadableStreamDefaultReader(this);if(`${t}`==`byob`)return new ReadableStreamBYOBReader(this);throw RangeError(`Invalid mode: ${t}`)}pipeThrough(e,t={}){if(!Mt(this))throw TypeError(`Invalid this`);let n=e?.readable;if(!Mt(n))throw TypeError(`transform.readable must be a ReadableStream`);let r=e?.writable;if(!bt(r))throw TypeError(`transform.writable must be a WritableStream`);if(t!=null&&typeof t!=`object`)throw TypeError(`options must be an object`);let i=t?.preventAbort,a=t?.preventCancel,o=t?.preventClose,s=t?.signal;if(s!==void 0&&!(s instanceof Object&&`aborted`in s))throw TypeError(`options.signal must be an AbortSignal`);if(isReadableStreamLocked(this))throw TypeError(`The ReadableStream is locked`);if(isWritableStreamLocked(r))throw TypeError(`The WritableStream is locked`);return setPromiseHandled(readableStreamPipeTo(this,r,!!o,!!i,!!a,s)),n}pipeTo(e,t={}){try{if(!Mt(this))throw TypeError(`Invalid this`);if(!bt(e))throw TypeError(`destination must be a WritableStream`);if(t!=null&&typeof t!=`object`)throw TypeError(`options must be an object`);let n=t?.preventAbort,r=t?.preventCancel,i=t?.preventClose,a=t?.signal;if(a!==void 0&&!(a instanceof Object&&`aborted`in a))throw TypeError(`options.signal must be an AbortSignal`);if(isReadableStreamLocked(this))throw TypeError(`The ReadableStream is locked`);if(isWritableStreamLocked(e))throw TypeError(`The WritableStream is locked`);return readableStreamPipeTo(this,e,!!i,!!n,!!r,a)}catch(e){return Promise.reject(e)}}tee(){if(!Mt(this))throw TypeError(`Invalid this`);let e=this[q].controller;return Ft(e)?readableByteStreamTee(this):readableStreamDefaultTee(this,!1)}values(e={}){if(!Mt(this))throw TypeError(`Invalid this`);if(e!=null&&typeof e!=`object`)throw TypeError(`options must be an object`);let t=!!e?.preventCancel,n=new ReadableStreamDefaultReader(this),r={done:!1,current:void 0},i=!1;function nextSteps(){if(r.done)return Promise.resolve({done:!0,value:void 0});if(n[q].stream===void 0)return Promise.reject(TypeError(`The reader is not bound to a ReadableStream`));let{promise:e,resolve:t,reject:i}=Promise.withResolvers();return readableStreamDefaultReaderRead(n,{[Tt](e){r.current=void 0,t({value:e,done:!1})},[wt](){r.current=void 0,r.done=!0,readableStreamReaderGenericRelease(n),t({done:!0,value:void 0})},[Et](e){r.current=void 0,r.done=!0,readableStreamReaderGenericRelease(n),i(e)}}),e}async function returnSteps(e){if(r.done)return{done:!0,value:e};if(r.done=!0,n[q].stream===void 0)throw TypeError(`The reader is not bound to a ReadableStream`);if(!t){let t=readableStreamReaderGenericCancel(n,e);return readableStreamReaderGenericRelease(n),await t,{done:!0,value:e}}return readableStreamReaderGenericRelease(n),{done:!0,value:e}}return Object.setPrototypeOf({next(){return i||=(r.current=Promise.resolve(),!0),r.current=r.current===void 0?nextSteps():r.current.then(nextSteps,nextSteps),r.current},return(e){return i=!0,r.current=r.current===void 0?returnSteps(e):r.current.then(()=>returnSteps(e),()=>returnSteps(e)),r.current},[Symbol.asyncIterator](){return this}},mt)}[Symbol.asyncIterator](){return this.values()}get[Symbol.toStringTag](){return`ReadableStream`}},DefaultReadRequest=class{[q];constructor(){this[q]=Promise.withResolvers()}[Tt](e){this[q].resolve?.({value:e,done:!1})}[wt](){this[q].resolve?.({value:void 0,done:!0})}[Et](e){this[q].reject?.(e)}get promise(){return this[q].promise}},ReadableStreamDefaultReader=class{[pt]=`ReadableStreamDefaultReader`;[q];constructor(e){if(!Mt(e))throw TypeError(`Expected a ReadableStream`);this[q]={readRequests:[],readIntoRequests:[],stream:void 0,close:{promise:void 0,resolve:void 0,reject:void 0}},setupReadableStreamDefaultReader(this,e)}read(){if(!Pt(this))return Promise.reject(TypeError(`Invalid this`));if(this[q].stream===void 0)return Promise.reject(TypeError(`The reader is not attached to a stream`));let e=this[q].stream,t=e[q].controller;if(e[q].state===`readable`&&Nt(t)&&t[q].queue.length>0){e[q].disturbed=!0;let n=dequeueValue(t);return t[q].closeRequested&&!t[q].queue.length?(readableStreamDefaultControllerClearAlgorithms(t),readableStreamClose(e)):readableStreamDefaultControllerCallPullIfNeeded(t),Promise.resolve({value:n,done:!1})}let n=new DefaultReadRequest;return readableStreamDefaultReaderRead(this,n),n.promise}releaseLock(){if(!Pt(this))throw TypeError(`Invalid this`);this[q].stream!==void 0&&readableStreamDefaultReaderRelease(this)}get closed(){return Pt(this)?this[q].close.promise:Promise.reject(TypeError(`Invalid this`))}cancel(e=void 0){return Pt(this)?this[q].stream===void 0?Promise.reject(TypeError(`The reader is not attached to a stream`)):readableStreamReaderGenericCancel(this,e):Promise.reject(TypeError(`Invalid this`))}get[Symbol.toStringTag](){return`ReadableStreamDefaultReader`}},ReadableStreamDefaultController=class{[pt]=`ReadableStreamDefaultController`;[q];constructor(e){if(e!==kt)throw TypeError(`Illegal constructor`)}get desiredSize(){return readableStreamDefaultControllerGetDesiredSize(this)}close(){if(!readableStreamDefaultControllerCanCloseOrEnqueue(this))throw TypeError(`Controller is already closed`);readableStreamDefaultControllerClose(this)}enqueue(e=void 0){if(!readableStreamDefaultControllerCanCloseOrEnqueue(this))throw TypeError(`Controller is already closed`);readableStreamDefaultControllerEnqueue(this,e)}error(e=void 0){readableStreamDefaultControllerError(this,e)}[Ct](e){return readableStreamDefaultControllerCancelSteps(this,e)}[Dt](e){readableStreamDefaultControllerPullSteps(this,e)}[Ot](){}get[Symbol.toStringTag](){return`ReadableStreamDefaultController`}};const Mt=isBrandCheck(`ReadableStream`),Nt=isBrandCheck(`ReadableStreamDefaultController`),Pt=isBrandCheck(`ReadableStreamDefaultReader`);function isReadableStreamLocked(e){return e[q].reader!==void 0}function readableStreamCancel(e,t){switch(e[q].disturbed=!0,e[q].state){case`closed`:return Promise.resolve();case`errored`:return Promise.reject(e[q].storedError)}readableStreamClose(e);let n=e[q].reader;if(n!==void 0&&readableStreamHasBYOBReader(e)){let e=n[q].readIntoRequests;n[q].readIntoRequests=[];for(let t=0;t<e.length;t++)e[t][wt](void 0)}return e[q].controller[Ct](t).then(()=>{})}function readableStreamClose(e){e[q].state=`closed`,e[q].closedPromise.resolve();let{reader:t}=e[q];if(t!==void 0&&(t[q].close.resolve?.(),readableStreamHasDefaultReader(e))){for(let e=0;e<t[q].readRequests.length;e++)t[q].readRequests[e][wt]();t[q].readRequests=[]}}function readableStreamError(e,t){e[q].state=`errored`,e[q].storedError=t,setPromiseHandled(e[q].closedPromise.promise),e[q].closedPromise.reject(t);let{reader:n}=e[q];if(n!==void 0){if(setPromiseHandled(n[q].close.promise),n[q].close.reject?.(t),readableStreamHasDefaultReader(e)){for(let e=0;e<n[q].readRequests.length;e++)n[q].readRequests[e][Et](t);n[q].readRequests=[]}else if(readableStreamHasBYOBReader(e)){for(let e=0;e<n[q].readIntoRequests.length;e++)n[q].readIntoRequests[e][Et](t);n[q].readIntoRequests=[]}}}function readableStreamHasDefaultReader(e){let{reader:t}=e[q];return t===void 0?!1:t[q]!==void 0&&t[pt]===`ReadableStreamDefaultReader`}function readableStreamGetNumReadRequests(e){return e[q].reader[q].readRequests.length}function readableStreamFulfillReadRequest(e,t,n){let{reader:r}=e[q],i=r[q].readRequests.shift();n?i[wt]():i[Tt](t)}function readableStreamAddReadRequest(e,t){e[q].reader[q].readRequests.push(t)}function readableStreamReaderGenericCancel(e,t){let{stream:n}=e[q];return readableStreamCancel(n,t)}function readableStreamReaderGenericInitialize(e,t){switch(e[q].stream=t,t[q].reader=e,t[q].state){case`readable`:e[q].close=Promise.withResolvers();break;case`closed`:e[q].close={promise:Promise.resolve(),resolve:void 0,reject:void 0};break;case`errored`:e[q].close={promise:Promise.reject(t[q].storedError),resolve:void 0,reject:void 0},setPromiseHandled(e[q].close.promise);break}}function readableStreamReaderGenericRelease(e){let{stream:t}=e[q],n=lazyReadableReleasedError();t[q].state===`readable`?e[q].close.reject?.(n):e[q].close={promise:Promise.reject(n),resolve:void 0,reject:void 0},setPromiseHandled(e[q].close.promise),t[q].controller[Ot](),t[q].reader=void 0,e[q].stream=void 0}function readableStreamDefaultReaderRelease(e){readableStreamReaderGenericRelease(e),readableStreamDefaultReaderErrorReadRequests(e,lazyReadableReleasingError())}function readableStreamDefaultReaderErrorReadRequests(e,t){for(let n=0;n<e[q].readRequests.length;++n)e[q].readRequests[n][Et](t);e[q].readRequests=[]}function readableStreamDefaultReaderRead(e,t){let{stream:n}=e[q];switch(n[q].disturbed=!0,n[q].state){case`closed`:t[wt]();break;case`errored`:t[Et](n[q].storedError);break;case`readable`:n[q].controller[Dt](t);break}}function setupReadableStreamDefaultReader(e,t){if(isReadableStreamLocked(t))throw TypeError(`ReadableStream is locked`);readableStreamReaderGenericInitialize(e,t),e[q].readRequests=[]}function readableStreamDefaultControllerClose(e){readableStreamDefaultControllerCanCloseOrEnqueue(e)&&(e[q].closeRequested=!0,e[q].queue.length||(readableStreamDefaultControllerClearAlgorithms(e),readableStreamClose(e[q].stream)))}function readableStreamDefaultControllerEnqueue(e,t){if(!readableStreamDefaultControllerCanCloseOrEnqueue(e))return;let{stream:n}=e[q];if(isReadableStreamLocked(n)&&readableStreamGetNumReadRequests(n))readableStreamFulfillReadRequest(n,t,!1);else try{enqueueValueWithSize(e,t,e[q].sizeAlgorithm(t))}catch(t){throw readableStreamDefaultControllerError(e,t),t}readableStreamDefaultControllerCallPullIfNeeded(e)}function readableStreamDefaultControllerCanCloseOrEnqueue(e){let{stream:t}=e[q];return!e[q].closeRequested&&t[q].state===`readable`}function readableStreamDefaultControllerGetDesiredSize(e){let{stream:t,highWaterMark:n,queueTotalSize:r}=e[q];switch(t[q].state){case`errored`:return null;case`closed`:return 0;default:return n-r}}function readableStreamDefaultControllerHasBackpressure(e){return!readableStreamDefaultControllerShouldCallPull(e)}function readableStreamDefaultControllerShouldCallPull(e){let{stream:t}=e[q];if(!readableStreamDefaultControllerCanCloseOrEnqueue(e)||!e[q].started)return!1;if(isReadableStreamLocked(t)&&readableStreamGetNumReadRequests(t))return!0;let n=readableStreamDefaultControllerGetDesiredSize(e);return n!==null&&n>0}function readableStreamDefaultControllerCallPullIfNeeded(e){if(readableStreamDefaultControllerShouldCallPull(e)){if(e[q].pulling){e[q].pullAgain=!0;return}e[q].pulling=!0,e[q].pullAlgorithm(e).then(()=>{e[q].pulling=!1,e[q].pullAgain&&(e[q].pullAgain=!1,readableStreamDefaultControllerCallPullIfNeeded(e))},t=>readableStreamDefaultControllerError(e,t))}}function readableStreamDefaultControllerClearAlgorithms(e){e[q].pullAlgorithm=void 0,e[q].cancelAlgorithm=void 0,e[q].sizeAlgorithm=void 0}function readableStreamDefaultControllerError(e,t){let{stream:n}=e[q];n[q].state===`readable`&&(resetQueue(e),readableStreamDefaultControllerClearAlgorithms(e),readableStreamError(n,t))}function readableStreamDefaultControllerCancelSteps(e,t){resetQueue(e);let n=e[q].cancelAlgorithm?.(t)??Promise.resolve();return readableStreamDefaultControllerClearAlgorithms(e),n}function readableStreamDefaultControllerPullSteps(e,t){let{stream:n,queue:r}=e[q];if(r.length){let i=dequeueValue(e);e[q].closeRequested&&!r.length?(readableStreamDefaultControllerClearAlgorithms(e),readableStreamClose(n)):readableStreamDefaultControllerCallPullIfNeeded(e),t[Tt](i);return}readableStreamAddReadRequest(n,t),readableStreamDefaultControllerCallPullIfNeeded(e)}function setupReadableStreamDefaultController(e,t,n,r,i,a,o){t[q]={cancelAlgorithm:i,closeRequested:!1,highWaterMark:a,pullAgain:!1,pullAlgorithm:r,pulling:!1,queue:[],queueTotalSize:0,started:!1,sizeAlgorithm:o,stream:e},e[q].controller=t;let s=n();new Promise(e=>e(s)).then(()=>{t[q].started=!0,readableStreamDefaultControllerCallPullIfNeeded(t)},e=>readableStreamDefaultControllerError(t,e))}function setupReadableStreamDefaultControllerFromSource(e,t,n,r){let i=new ReadableStreamDefaultController(kt),a=t?.start,o=t?.pull,s=t?.cancel;setupReadableStreamDefaultController(e,i,a?a.bind(t,i):nonOpStart,o?createPromiseCallback(`source.pull`,o,t):nonOpPull,s?createPromiseCallback(`source.cancel`,s,t):nonOpCancel,n,r)}function createReadableStream(e,t,n,r=1,i=()=>1){let a=Object.create(ReadableStream$1.prototype);return a[pt]=`ReadableStream`,a[q]=createReadableStreamState(),setupReadableStreamDefaultController(a,new ReadableStreamDefaultController(kt),e,t,n,r,i),a}function readableStreamFromIterable(e){let t,n=getIterator(e,`async`),r=nonOpStart;async function pullAlgorithm(){let e=iteratorNext(n);return Promise.resolve(e).then(e=>{if(typeof e!=`object`||!e)throw TypeError(`The promise returned by the iterator.next() method must fulfill with an object`);e.done?readableStreamDefaultControllerClose(t[q].controller):readableStreamDefaultControllerEnqueue(t[q].controller,e.value)})}async function cancelAlgorithm(e){let t=n.iterator,r=t.return;if(r===void 0)return Promise.resolve();let i=r.call(t,e);return Promise.resolve(i).then(e=>{if(typeof e!=`object`||!e)throw TypeError(`The promise returned by the iterator.return() method must fulfill with an object`)})}return t=createReadableStream(r,pullAlgorithm,cancelAlgorithm,0),t}function readableStreamPipeTo(e,t,n,r,i,a){let o,s;try{o=new ReadableStreamDefaultReader(e),s=new WritableStreamDefaultWriter(t)}catch(e){return Promise.reject(e)}e[q].disturbed=!0;let c=!1,{promise:l,resolve:u,reject:d}=Promise.withResolvers(),f={currentWrite:Promise.resolve()},p;function finalize(e,t){writableStreamDefaultWriterRelease(s),readableStreamReaderGenericRelease(o),a!==void 0&&p&&(a.removeEventListener(`abort`,p),p=void 0),e?d(t):u()}async function waitForCurrentWrite(){let e=f.currentWrite;await e,e!==f.currentWrite&&await waitForCurrentWrite()}function shutdownWithAnAction(e,n,r){if(c)return;if(c=!0,t[q].state===`writable`&&!writableStreamCloseQueuedOrInFlight(t)){waitForCurrentWrite().then(complete,e=>finalize(!0,e));return}complete();function complete(){e().then(()=>finalize(!!n,r),e=>finalize(!0,e))}}function shutdown(e,n){if(!c){if(c=!0,t[q].state===`writable`&&!writableStreamCloseQueuedOrInFlight(t)){waitForCurrentWrite().then(()=>finalize(!!e,n),e=>finalize(!0,e));return}finalize(!!e,n)}}function abortAlgorithm(){let n;n=a.reason&&a.reason.name===`AbortError`?createAbortError$1():a.reason;let o=[];r||o.push(()=>t[q].state===`writable`?writableStreamAbort(t,n):Promise.resolve()),i||o.push(()=>e[q].state===`readable`?readableStreamCancel(e,n):Promise.resolve()),shutdownWithAnAction(()=>Promise.all(o.map(e=>e())).then(()=>void 0),!0,n)}function watchErrored(e,t,n){e[q].state===`errored`?n(e[q].storedError):t.then(void 0,n)}function watchClosed(e,t,n){e[q].state===`closed`?n():t.then(n,()=>{})}class PipeToReadRequest{[Tt](e){D(()=>{f.currentWrite=writableStreamDefaultWriterWrite(s,e),setPromiseHandled(f.currentWrite),m.resolve(!1)})}[wt](){m.resolve(!0)}[Et](e){m.reject(e)}}let m={resolve:null,reject:null};async function step(){if(c||t[q].backpressure&&(await s[q].ready.promise,c))return!0;let n=e[q].controller;if(e[q].state===`readable`&&Nt(n)&&n[q].queue.length>0){for(;n[q].queue.length>0;){if(c)return!0;let r=dequeueValue(n);if(n[q].closeRequested&&!n[q].queue.length&&(readableStreamDefaultControllerClearAlgorithms(n),readableStreamClose(e)),f.currentWrite=writableStreamDefaultWriterWrite(s,r),setPromiseHandled(f.currentWrite),t[q].backpressure||t[q].state!==`writable`||writableStreamCloseQueuedOrInFlight(t))break}return readableStreamDefaultControllerCallPullIfNeeded(n),e[q].state===`closed`}let{promise:r,resolve:i,reject:a}=Promise.withResolvers();return m={resolve:i,reject:a},readableStreamDefaultReaderRead(o,new PipeToReadRequest),r}async function run(){for(;!await step(););}if(a!==void 0){if(a.aborted)return abortAlgorithm(),l;p=abortAlgorithm,a.addEventListener(`abort`,p,{once:!0})}if(setPromiseHandled(run()),watchErrored(e,o[q].close.promise,e=>{if(!r)return shutdownWithAnAction(()=>writableStreamAbort(t,e),!0,e);shutdown(!0,e)}),watchErrored(t,s[q].close.promise,t=>{if(!i)return shutdownWithAnAction(()=>readableStreamCancel(e,t),!0,t);shutdown(!0,t)}),watchClosed(e,o[q].close.promise,()=>{if(!n)return shutdownWithAnAction(()=>writableStreamDefaultWriterCloseWithErrorPropagation(s));shutdown()}),writableStreamCloseQueuedOrInFlight(t)||t[q].state===`closed`){let t=TypeError(`Destination WritableStream is closed`);i?shutdown(!0,t):shutdownWithAnAction(()=>readableStreamCancel(e,t),!0,t)}return l}function readableStreamDefaultTee(e,t){let n=new ReadableStreamDefaultReader(e),r=!1,i=!1,a=!1,o,s,c,l,u=Promise.withResolvers();async function pullAlgorithm(){r||(r=!0,readableStreamDefaultReaderRead(n,{[Tt](e){D(()=>{r=!1;let n=e,o=e;if(!a&&t)try{o=structuredClone(o)}catch{}i||readableStreamDefaultControllerEnqueue(c[q].controller,n),a||readableStreamDefaultControllerEnqueue(l[q].controller,o)})},[wt](){D(()=>{r=!1,i||readableStreamDefaultControllerClose(c[q].controller),a||readableStreamDefaultControllerClose(l[q].controller),(!i||!a)&&u.resolve(void 0)})},[Et](){r=!1}}))}function cancel1Algorithm(t){if(i=!0,o=t,a){let t=[o,s];u.resolve(readableStreamCancel(e,t))}return u.promise}function cancel2Algorithm(t){if(a=!0,s=t,i){let t=[o,s];u.resolve(readableStreamCancel(e,t))}return u.promise}return c=createReadableStream(nonOpStart,pullAlgorithm,cancel1Algorithm),l=createReadableStream(nonOpStart,pullAlgorithm,cancel2Algorithm),n[q].close.promise.then(void 0,e=>{readableStreamDefaultControllerError(c[q].controller,e),readableStreamDefaultControllerError(l[q].controller,e),(!i||!a)&&u.resolve(void 0)}),[c,l]}var BYOBReadIntoRequest=class{[q];constructor(){this[q]=Promise.withResolvers()}[Tt](e){this[q].resolve?.({value:e,done:!1})}[wt](e){this[q].resolve?.({value:e,done:!0})}[Et](e){this[q].reject?.(e)}get promise(){return this[q].promise}},ReadableStreamBYOBReader=class{[pt]=`ReadableStreamBYOBReader`;[q];constructor(e){if(!Mt(e))throw TypeError(`Expected a ReadableStream`);this[q]={readRequests:[],readIntoRequests:[],stream:void 0,close:{promise:void 0,resolve:void 0,reject:void 0}},setupReadableStreamBYOBReader(this,e)}read(e,t={}){if(!It(this))return Promise.reject(TypeError(`Invalid this`));if(typeof e!=`object`||!e||!ArrayBuffer.isView(e))return Promise.reject(TypeError(`view must be an ArrayBufferView`));let n=e.buffer,r=e.byteLength;if(r===0)return Promise.reject(TypeError(`view must have non-zero byteLength`));if(n.byteLength===0)return isDetachedBuffer(n)?Promise.reject(TypeError(`view's buffer has been detached`)):Promise.reject(TypeError(`view's buffer must have non-zero byteLength`));let i=t?.min??1;if(typeof i!=`number`||i<1||!Number.isInteger(i)||Number.isNaN(i))return Promise.reject(TypeError(`options.min must be a positive integer`));let a=e[Symbol.toStringTag];if(a!==void 0&&a!==`DataView`){if(i>e.length)return Promise.reject(RangeError(`options.min must be smaller or equal to view size`))}else if(i>r)return Promise.reject(RangeError(`options.min must be smaller or equal to view size`));if(this[q].stream===void 0)return Promise.reject(TypeError(`Reader has no associated stream`));let o=new BYOBReadIntoRequest;return readableStreamBYOBReaderRead(this,e,i,o),o.promise}releaseLock(){if(!It(this))throw TypeError(`Invalid this`);this[q].stream!==void 0&&readableStreamBYOBReaderRelease(this)}get closed(){return It(this)?this[q].close.promise:Promise.reject(TypeError(`Invalid this`))}cancel(e=void 0){return It(this)?this[q].stream===void 0?Promise.reject(TypeError(`Reader has no associated stream`)):readableStreamReaderGenericCancel(this,e):Promise.reject(TypeError(`Invalid this`))}get[Symbol.toStringTag](){return`ReadableStreamBYOBReader`}},ReadableStreamBYOBRequest=class{[pt]=`ReadableStreamBYOBRequest`;[q];constructor(e){if(e!==kt)throw TypeError(`Illegal constructor`)}get view(){if(!Lt(this))throw TypeError(`Invalid this`);return this[q].view}respond(e){if(!Lt(this))throw TypeError(`Invalid this`);if(this[q].controller===void 0)throw TypeError(`BYOB request has been invalidated`);if(e=+e,!Number.isInteger(e)||e<0||!Number.isFinite(e))throw RangeError(`bytesWritten must be a non-negative integer`);let t=this[q].view;if(isDetachedBuffer(t.buffer))throw TypeError(`The BYOB request's buffer has been detached`);readableByteStreamControllerRespond(this[q].controller,e)}respondWithNewView(e){if(!Lt(this))throw TypeError(`Invalid this`);if(this[q].controller===void 0)throw TypeError(`BYOB request has been invalidated`);if(typeof e!=`object`||!e||!ArrayBuffer.isView(e))throw TypeError(`view must be an ArrayBufferView`);if(isDetachedBuffer(e.buffer))throw TypeError(`The given view's buffer has been detached`);readableByteStreamControllerRespondWithNewView(this[q].controller,e)}get[Symbol.toStringTag](){return`ReadableStreamBYOBRequest`}},ReadableByteStreamController=class{[pt]=`ReadableByteStreamController`;[q];constructor(e){if(e!==kt)throw TypeError(`Illegal constructor`)}get byobRequest(){if(!Ft(this))throw TypeError(`Invalid this`);return readableByteStreamControllerGetBYOBRequest(this)}get desiredSize(){if(!Ft(this))throw TypeError(`Invalid this`);return readableByteStreamControllerGetDesiredSize(this)}close(){if(!Ft(this))throw TypeError(`Invalid this`);if(this[q].closeRequested)throw TypeError(`Close already requested`);if(this[q].stream[q].state!==`readable`)throw TypeError(`Stream is not in a readable state`);readableByteStreamControllerClose(this)}enqueue(e){if(!Ft(this))throw TypeError(`Invalid this`);if(typeof e!=`object`||!e||!ArrayBuffer.isView(e))throw TypeError(`chunk must be an ArrayBufferView`);if(e.byteLength===0)throw TypeError(`chunk length must be non-zero`);if(e.buffer.byteLength===0)throw TypeError(`chunk's buffer length must be non-zero`);if(this[q].closeRequested)throw TypeError(`Cannot enqueue after close has been requested`);if(this[q].stream[q].state!==`readable`)throw TypeError(`Stream is not in a readable state`);readableByteStreamControllerEnqueue(this,e)}error(e=void 0){if(!Ft(this))throw TypeError(`Invalid this`);readableByteStreamControllerError(this,e)}[Ct](e){return readableByteStreamControllerCancelSteps(this,e)}[Dt](e){readableByteStreamControllerPullSteps(this,e)}[Ot](){if(this[q].pendingPullIntos.length>0){let e=this[q].pendingPullIntos[0];e.readerType=`none`,this[q].pendingPullIntos=[e]}}get[Symbol.toStringTag](){return`ReadableByteStreamController`}};const Ft=isBrandCheck(`ReadableByteStreamController`),It=isBrandCheck(`ReadableStreamBYOBReader`),Lt=isBrandCheck(`ReadableStreamBYOBRequest`);function readableStreamHasBYOBReader(e){let{reader:t}=e[q];return t===void 0?!1:t[q]!==void 0&&t[pt]===`ReadableStreamBYOBReader`}function readableStreamGetNumReadIntoRequests(e){return e[q].reader[q].readIntoRequests.length}function readableStreamAddReadIntoRequest(e,t){e[q].reader[q].readIntoRequests.push(t)}function readableStreamFulfillReadIntoRequest(e,t,n){let{reader:r}=e[q],i=r[q].readIntoRequests.shift();n?i[wt](t):i[Tt](t)}function setupReadableStreamBYOBReader(e,t){if(isReadableStreamLocked(t))throw TypeError(`ReadableStream is locked`);if(!Ft(t[q].controller))throw TypeError(`Cannot use a BYOB reader with a non-byte stream`);readableStreamReaderGenericInitialize(e,t),e[q].readIntoRequests=[]}function readableStreamBYOBReaderRead(e,t,n,r){let{stream:i}=e[q];i[q].disturbed=!0,i[q].state===`errored`?r[Et](i[q].storedError):readableByteStreamControllerPullInto(i[q].controller,t,n,r)}function readableStreamBYOBReaderRelease(e){readableStreamReaderGenericRelease(e);let t=TypeError(`Reader was released`);for(let n=0;n<e[q].readIntoRequests.length;n++)e[q].readIntoRequests[n][Et](t);e[q].readIntoRequests=[]}function readableByteStreamControllerClearAlgorithms(e){e[q].pullAlgorithm=void 0,e[q].cancelAlgorithm=void 0}function readableByteStreamControllerClearPendingPullIntos(e){readableByteStreamControllerInvalidateBYOBRequest(e),e[q].pendingPullIntos=[]}function readableByteStreamControllerInvalidateBYOBRequest(e){let t=e[q].byobRequest;t!=null&&(t[q].controller=void 0,t[q].view=null,e[q].byobRequest=null)}function readableByteStreamControllerError(e,t){let{stream:n}=e[q];n[q].state===`readable`&&(readableByteStreamControllerClearPendingPullIntos(e),resetQueue(e),readableByteStreamControllerClearAlgorithms(e),readableStreamError(n,t))}function readableByteStreamControllerGetDesiredSize(e){let t=e[q].stream[q].state;return t===`errored`?null:t===`closed`?0:e[q].highWaterMark-e[q].queueTotalSize}function readableByteStreamControllerShouldCallPull(e){let{stream:t}=e[q];if(t[q].state!==`readable`||e[q].closeRequested||!e[q].started)return!1;if(readableStreamHasDefaultReader(t)&&readableStreamGetNumReadRequests(t)>0||readableStreamHasBYOBReader(t)&&readableStreamGetNumReadIntoRequests(t)>0)return!0;let n=readableByteStreamControllerGetDesiredSize(e);return n!==null&&n>0}function readableByteStreamControllerCallPullIfNeeded(e){if(readableByteStreamControllerShouldCallPull(e)){if(e[q].pulling){e[q].pullAgain=!0;return}e[q].pulling=!0,e[q].pullAlgorithm(e).then(()=>{e[q].pulling=!1,e[q].pullAgain&&(e[q].pullAgain=!1,readableByteStreamControllerCallPullIfNeeded(e))},t=>readableByteStreamControllerError(e,t))}}function readableByteStreamControllerHandleQueueDrain(e){e[q].queueTotalSize===0&&e[q].closeRequested?(readableByteStreamControllerClearAlgorithms(e),readableStreamClose(e[q].stream)):readableByteStreamControllerCallPullIfNeeded(e)}function readableByteStreamControllerEnqueueChunkToQueue(e,t,n,r){e[q].queue.push({buffer:t,byteOffset:n,byteLength:r}),e[q].queueTotalSize+=r}function readableByteStreamControllerEnqueueClonedChunkToQueue(e,t,n,r){let i;try{i=t.slice(n,n+r)}catch(t){readableByteStreamControllerError(e,t);return}readableByteStreamControllerEnqueueChunkToQueue(e,i,0,r)}function readableByteStreamControllerEnqueueDetachedPullIntoToQueue(e,t){t.bytesFilled>0&&readableByteStreamControllerEnqueueClonedChunkToQueue(e,t.buffer,t.byteOffset,t.bytesFilled),readableByteStreamControllerShiftPendingPullInto(e)}function readableByteStreamControllerShiftPendingPullInto(e){return e[q].pendingPullIntos.shift()}function readableByteStreamControllerFillHeadPullIntoDescriptor(e,t,n){n.bytesFilled+=t}function readableByteStreamControllerConvertPullIntoDescriptor(e){let t=e.bytesFilled,n=e.elementSize,r=transferArrayBuffer(e.buffer);return e.buffer=r,new e.viewConstructor(r,e.byteOffset,t/n)}function readableByteStreamControllerCommitPullIntoDescriptor(e,t){let n=!1;e[q].state===`closed`&&(n=!0);let r=readableByteStreamControllerConvertPullIntoDescriptor(t);t.readerType==="default"?readableStreamFulfillReadRequest(e,r,n):readableStreamFulfillReadIntoRequest(e,r,n)}function readableByteStreamControllerFillPullIntoDescriptorFromQueue(e,t){let n=Math.min(e[q].queueTotalSize,t.byteLength-t.bytesFilled),r=t.bytesFilled+n,i=n,a=!1,o=r-r%t.elementSize;o>=t.minimumFill&&(i=o-t.bytesFilled,a=!0);let s=e[q].queue;for(;i>0;){let n=s[0],r=Math.min(i,n.byteLength),a=t.byteOffset+t.bytesFilled,o=new Uint8Array(t.buffer,a,r),c=new Uint8Array(n.buffer,n.byteOffset,r);o.set(c),n.byteLength===r?s.shift():(n.byteOffset+=r,n.byteLength-=r),e[q].queueTotalSize-=r,readableByteStreamControllerFillHeadPullIntoDescriptor(e,r,t),i-=r}return a}function readableByteStreamControllerFillReadRequestFromQueue(e,t){let n=e[q].queue.shift();e[q].queueTotalSize-=n.byteLength,readableByteStreamControllerHandleQueueDrain(e);let r=new Uint8Array(n.buffer,n.byteOffset,n.byteLength);t[Tt](r)}function readableByteStreamControllerProcessReadRequestsUsingQueue(e){let t=e[q].stream[q].reader;for(;t[q].readRequests.length!==0;){if(e[q].queueTotalSize===0)return;readableByteStreamControllerFillReadRequestFromQueue(e,t[q].readRequests.shift())}}function readableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(e){for(;e[q].pendingPullIntos.length!==0;){if(e[q].queueTotalSize===0)return;let t=e[q].pendingPullIntos[0];readableByteStreamControllerFillPullIntoDescriptorFromQueue(e,t)&&(readableByteStreamControllerShiftPendingPullInto(e),readableByteStreamControllerCommitPullIntoDescriptor(e[q].stream,t))}}function readableByteStreamControllerGetBYOBRequest(e){if(e[q].byobRequest===null&&e[q].pendingPullIntos.length!==0){let t=e[q].pendingPullIntos[0],n=new Uint8Array(t.buffer,t.byteOffset+t.bytesFilled,t.byteLength-t.bytesFilled),r=new ReadableStreamBYOBRequest(kt);r[q]={controller:e,view:n},e[q].byobRequest=r}return e[q].byobRequest}function readableByteStreamControllerEnqueue(e,t){let{stream:n}=e[q];if(e[q].closeRequested||n[q].state!==`readable`)return;let r=t.buffer,i=t.byteLength,a=t.byteOffset;if(isDetachedBuffer(r))throw TypeError(`chunk's buffer is detached`);let o=transferArrayBuffer(r);if(e[q].pendingPullIntos.length!==0){let t=e[q].pendingPullIntos[0];if(isDetachedBuffer(t.buffer))throw TypeError(`BYOB request's buffer has been detached`);readableByteStreamControllerInvalidateBYOBRequest(e),t.buffer=transferArrayBuffer(t.buffer),t.readerType===`none`&&readableByteStreamControllerEnqueueDetachedPullIntoToQueue(e,t)}readableStreamHasDefaultReader(n)?(readableByteStreamControllerProcessReadRequestsUsingQueue(e),readableStreamGetNumReadRequests(n)===0?readableByteStreamControllerEnqueueChunkToQueue(e,o,a,i):(e[q].pendingPullIntos.length!==0&&readableByteStreamControllerShiftPendingPullInto(e),readableStreamFulfillReadRequest(n,new Uint8Array(o,a,i),!1))):readableStreamHasBYOBReader(n)?(readableByteStreamControllerEnqueueChunkToQueue(e,o,a,i),readableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(e)):readableByteStreamControllerEnqueueChunkToQueue(e,o,a,i),readableByteStreamControllerCallPullIfNeeded(e)}function readableByteStreamControllerClose(e){let{stream:t}=e[q];if(!(e[q].closeRequested||t[q].state!==`readable`)){if(e[q].queueTotalSize>0){e[q].closeRequested=!0;return}if(e[q].pendingPullIntos.length!==0){let t=e[q].pendingPullIntos[0];if(t.bytesFilled%t.elementSize!==0){let t=TypeError(`Insufficient bytes to fill elements in the given buffer`);throw readableByteStreamControllerError(e,t),t}}readableByteStreamControllerClearAlgorithms(e),readableStreamClose(t)}}function readableByteStreamControllerPullInto(e,t,n,r){let i=e[q].stream,a=t[Symbol.toStringTag],o,s;if(a===void 0||a===`DataView`)o=DataView,s=1;else{let e=typedArrayConstructorByTag(a);if(!e){r[Et](TypeError(`Unsupported typed array: ${a}`));return}o=e,s=elementSizeByTag(a)}let c=t.buffer,l=t.byteLength,u=t.byteOffset,d=n*s,f;try{f=transferArrayBuffer(c)}catch(e){r[Et](e);return}let p={buffer:f,bufferByteLength:f.byteLength,byteOffset:u,byteLength:l,bytesFilled:0,minimumFill:d,elementSize:s,viewConstructor:o,readerType:`byob`};if(e[q].pendingPullIntos.length!==0){e[q].pendingPullIntos.push(p),readableStreamAddReadIntoRequest(i,r);return}if(i[q].state===`closed`){let e=new o(p.buffer,p.byteOffset,0);r[wt](e);return}if(e[q].queueTotalSize>0){if(readableByteStreamControllerFillPullIntoDescriptorFromQueue(e,p)){let t=readableByteStreamControllerConvertPullIntoDescriptor(p);readableByteStreamControllerHandleQueueDrain(e),r[Tt](t);return}if(e[q].closeRequested){let t=TypeError(`Insufficient bytes to fill elements in the given buffer`);readableByteStreamControllerError(e,t),r[Et](t);return}}e[q].pendingPullIntos.push(p),readableStreamAddReadIntoRequest(i,r),readableByteStreamControllerCallPullIfNeeded(e)}function readableByteStreamControllerRespond(e,t){let n=e[q].pendingPullIntos[0];if(e[q].stream[q].state===`closed`){if(t!==0)throw TypeError(`bytesWritten must be 0 when calling respond() on a closed stream`)}else{if(t===0)throw TypeError(`bytesWritten must be greater than 0 when calling respond() on a readable stream`);if(n.bytesFilled+t>n.byteLength)throw RangeError(`bytesWritten out of range`)}n.buffer=transferArrayBuffer(n.buffer),readableByteStreamControllerRespondInternal(e,t)}function readableByteStreamControllerRespondWithNewView(e,t){let n=e[q].pendingPullIntos[0],r=e[q].stream[q].state,i=t.byteLength,a=t.byteOffset,o=t.buffer;if(r===`closed`){if(i!==0)throw TypeError(`view's length must be 0 when calling respondWithNewView() on a closed stream`)}else if(i===0)throw TypeError(`view's length must be greater than 0 when calling respondWithNewView() on a readable stream`);if(n.byteOffset+n.bytesFilled!==a)throw RangeError(`The region specified by view does not match byobRequest`);if(n.bufferByteLength!==o.byteLength)throw RangeError(`The buffer of view has different capacity than byobRequest`);if(n.bytesFilled+i>n.byteLength)throw RangeError(`The region specified by view is larger than byobRequest`);n.buffer=transferArrayBuffer(o),readableByteStreamControllerRespondInternal(e,i)}function readableByteStreamControllerRespondInternal(e,t){let n=e[q].pendingPullIntos[0];readableByteStreamControllerInvalidateBYOBRequest(e),e[q].stream[q].state===`closed`?readableByteStreamControllerRespondInClosedState(e,n):readableByteStreamControllerRespondInReadableState(e,t,n),readableByteStreamControllerCallPullIfNeeded(e)}function readableByteStreamControllerRespondInClosedState(e,t){t.readerType===`none`&&readableByteStreamControllerShiftPendingPullInto(e);let n=e[q].stream;if(readableStreamHasBYOBReader(n))for(;readableStreamGetNumReadIntoRequests(n)>0;)readableByteStreamControllerCommitPullIntoDescriptor(n,readableByteStreamControllerShiftPendingPullInto(e))}function readableByteStreamControllerRespondInReadableState(e,t,n){if(readableByteStreamControllerFillHeadPullIntoDescriptor(e,t,n),n.readerType===`none`){readableByteStreamControllerEnqueueDetachedPullIntoToQueue(e,n),readableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(e);return}if(n.bytesFilled<n.minimumFill)return;readableByteStreamControllerShiftPendingPullInto(e);let r=n.bytesFilled%n.elementSize;if(r>0){let t=n.byteOffset+n.bytesFilled;readableByteStreamControllerEnqueueClonedChunkToQueue(e,n.buffer,t-r,r)}n.bytesFilled-=r,readableByteStreamControllerCommitPullIntoDescriptor(e[q].stream,n),readableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(e)}function readableByteStreamControllerCancelSteps(e,t){readableByteStreamControllerClearPendingPullIntos(e),resetQueue(e);let n=e[q].cancelAlgorithm?.(t)??Promise.resolve();return readableByteStreamControllerClearAlgorithms(e),n}function readableByteStreamControllerPullSteps(e,t){let n=e[q].stream;if(e[q].queueTotalSize>0){readableByteStreamControllerFillReadRequestFromQueue(e,t);return}let r=e[q].autoAllocateChunkSize;if(r!==void 0){let n;try{n=new ArrayBuffer(r)}catch(e){t[Et](e);return}let i={buffer:n,bufferByteLength:r,byteOffset:0,byteLength:r,bytesFilled:0,minimumFill:1,elementSize:1,viewConstructor:Uint8Array,readerType:`default`};e[q].pendingPullIntos.push(i)}readableStreamAddReadRequest(n,t),readableByteStreamControllerCallPullIfNeeded(e)}function setupReadableByteStreamController(e,t,n,r,i,a,o){t[q]={cancelAlgorithm:i,closeRequested:!1,highWaterMark:a,pullAgain:!1,pullAlgorithm:r,pulling:!1,queue:[],queueTotalSize:0,started:!1,stream:e,byobRequest:null,pendingPullIntos:[],autoAllocateChunkSize:o},e[q].controller=t;let s=n();new Promise(e=>e(s)).then(()=>{t[q].started=!0,readableByteStreamControllerCallPullIfNeeded(t)},e=>readableByteStreamControllerError(t,e))}function setupReadableByteStreamControllerFromSource(e,t,n){let r=new ReadableByteStreamController(kt),i=t?.start,a=t?.pull,o=t?.cancel,s=t?.autoAllocateChunkSize;if(s!==void 0&&(s===0||!Number.isInteger(s)||s<0))throw TypeError(`autoAllocateChunkSize must be a positive integer`);setupReadableByteStreamController(e,r,i?i.bind(t,r):nonOpStart,a?createPromiseCallback(`source.pull`,a,t):nonOpPull,o?createPromiseCallback(`source.cancel`,o,t):nonOpCancel,n,s)}function readableByteStreamTee(e){let t=new ReadableStreamDefaultReader(e),n=!1,r=!1,i=!1,a,o,s=Promise.withResolvers(),c,l,u,d;function pullAlgorithm(){return n?Promise.resolve():(n=!0,t.read().then(e=>{if(n=!1,e.done){r||u.close(),i||d.close();return}let t=e.value,a=new Uint8Array(t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength));r||u.enqueue(a),i||d.enqueue(new Uint8Array(a))},()=>{}),Promise.resolve())}return c=new ReadableStream$1({type:`bytes`,pull:pullAlgorithm,cancel(t){if(r=!0,a=t,i){let t=readableStreamCancel(e,[a,o]);return s.resolve(),t}return s.promise}}),l=new ReadableStream$1({type:`bytes`,pull:pullAlgorithm,cancel(t){if(i=!0,o=t,r){let t=readableStreamCancel(e,[a,o]);return s.resolve(),t}return s.promise}}),u=c[q].controller,d=l[q].controller,t.closed.catch(e=>{u.error(e),d.error(e),(!r||!i)&&s.resolve()}),[c,l]}const Rt=Symbol(`kSkipThrow`);var TransformStream=class{[pt]=`TransformStream`;[q];constructor(e={},t={},n={}){if(e!=null&&typeof e!=`object`)throw TypeError(`transformer must be an object`);if(t!=null&&typeof t!=`object`)throw TypeError(`writableStrategy must be an object`);if(n!=null&&typeof n!=`object`)throw TypeError(`readableStrategy must be an object`);let r=e?.readableType,i=e?.writableType,a=e?.start;if(r!==void 0)throw RangeError(`Invalid readableType: ${r}`);if(i!==void 0)throw RangeError(`Invalid writableType: ${i}`);let o=extractHighWaterMark(n?.highWaterMark,0),s=extractSizeAlgorithm(n?.size),c=extractHighWaterMark(t?.highWaterMark,1),l=extractSizeAlgorithm(t?.size),u=Promise.withResolvers();initializeTransformStream(this,u,c,l,o,s),setupTransformStreamDefaultControllerFromTransformer(this,e),a===void 0?u.resolve():u.resolve(a.call(e,this[q].controller))}get readable(){if(!zt(this))throw TypeError(`Invalid this`);return this[q].readable}get writable(){if(!zt(this))throw TypeError(`Invalid this`);return this[q].writable}get[Symbol.toStringTag](){return`TransformStream`}},TransformStreamDefaultController=class{[pt]=`TransformStreamDefaultController`;[q];constructor(e){if(e!==Rt)throw TypeError(`Illegal constructor`)}get desiredSize(){if(!Bt(this))throw TypeError(`Invalid this`);let{stream:e}=this[q],{readable:t}=e[q],n=t[q].controller;return readableStreamDefaultControllerGetDesiredSize(n)}enqueue(e){if(!Bt(this))throw TypeError(`Invalid this`);transformStreamDefaultControllerEnqueue(this,e)}error(e){if(!Bt(this))throw TypeError(`Invalid this`);transformStreamDefaultControllerError(this,e)}terminate(){if(!Bt(this))throw TypeError(`Invalid this`);transformStreamDefaultControllerTerminate(this)}get[Symbol.toStringTag](){return`TransformStreamDefaultController`}};const zt=isBrandCheck(`TransformStream`),Bt=isBrandCheck(`TransformStreamDefaultController`);async function defaultTransformAlgorithm(e,t){transformStreamDefaultControllerEnqueue(t,e)}function initializeTransformStream(e,t,n,r,i,a){let startAlgorithm=()=>t.promise,o=createWritableStream(startAlgorithm,t=>transformStreamDefaultSinkWriteAlgorithm(e,t),()=>transformStreamDefaultSinkCloseAlgorithm(e),t=>transformStreamDefaultSinkAbortAlgorithm(e,t),n,r);e[q]={readable:createReadableStream(startAlgorithm,()=>transformStreamDefaultSourcePullAlgorithm(e),t=>transformStreamDefaultSourceCancelAlgorithm(e,t),i,a),writable:o,controller:void 0,backpressure:void 0,backpressureChange:{promise:void 0,resolve:void 0,reject:void 0}},transformStreamSetBackpressure(e,!0)}function transformStreamError(e,t){let{readable:n}=e[q];readableStreamDefaultControllerError(n[q].controller,t),transformStreamErrorWritableAndUnblockWrite(e,t)}function transformStreamErrorWritableAndUnblockWrite(e,t){let{controller:n,writable:r}=e[q];transformStreamDefaultControllerClearAlgorithms(n),writableStreamDefaultControllerErrorIfNeeded(r[q].controller,t),transformStreamUnblockWrite(e)}function transformStreamUnblockWrite(e){e[q].backpressure&&transformStreamSetBackpressure(e,!1)}function transformStreamSetBackpressure(e,t){e[q].backpressureChange.promise!==void 0&&e[q].backpressureChange.resolve?.(),e[q].backpressureChange=Promise.withResolvers(),e[q].backpressure=t}function setupTransformStreamDefaultController(e,t,n,r,i){t[q]={stream:e,transformAlgorithm:n,flushAlgorithm:r,cancelAlgorithm:i,finishPromise:void 0},e[q].controller=t}function setupTransformStreamDefaultControllerFromTransformer(e,t){let n=new TransformStreamDefaultController(Rt),r=t?.transform,i=t?.flush,a=t?.cancel;setupTransformStreamDefaultController(e,n,r?createPromiseCallback(`transformer.transform`,r,t):defaultTransformAlgorithm,i?createPromiseCallback(`transformer.flush`,i,t):nonOpFlush,a?createPromiseCallback(`transformer.cancel`,a,t):nonOpCancel)}function transformStreamDefaultControllerClearAlgorithms(e){e[q].transformAlgorithm=void 0,e[q].flushAlgorithm=void 0,e[q].cancelAlgorithm=void 0}function transformStreamDefaultControllerEnqueue(e,t){let{stream:n}=e[q],{readable:r}=n[q],i=r[q].controller;if(!readableStreamDefaultControllerCanCloseOrEnqueue(i))throw TypeError(`Unable to enqueue`);try{readableStreamDefaultControllerEnqueue(i,t)}catch(e){throw transformStreamErrorWritableAndUnblockWrite(n,e),r[q].storedError}readableStreamDefaultControllerHasBackpressure(i)!==n[q].backpressure&&transformStreamSetBackpressure(n,!0)}function transformStreamDefaultControllerError(e,t){transformStreamError(e[q].stream,t)}async function transformStreamDefaultControllerPerformTransform(e,t){try{let n=e[q].transformAlgorithm;if(n===void 0)return;await n(t,e)}catch(t){throw transformStreamError(e[q].stream,t),t}}function transformStreamDefaultControllerTerminate(e){let{stream:t}=e[q],{readable:n}=t[q];readableStreamDefaultControllerClose(n[q].controller),transformStreamErrorWritableAndUnblockWrite(t,TypeError(`TransformStream has been terminated`))}function transformStreamDefaultSinkWriteAlgorithm(e,t){let{controller:n}=e[q];return e[q].backpressure?e[q].backpressureChange.promise.then(()=>{let{writable:r}=e[q];if(r[q].state===`erroring`)throw r[q].storedError;return transformStreamDefaultControllerPerformTransform(n,t)}):transformStreamDefaultControllerPerformTransform(n,t)}async function transformStreamDefaultSinkAbortAlgorithm(e,t){let{controller:n,readable:r}=e[q];if(n[q].finishPromise!==void 0)return n[q].finishPromise;let{promise:i,resolve:a,reject:o}=Promise.withResolvers();n[q].finishPromise=i;let s=n[q].cancelAlgorithm(t);return transformStreamDefaultControllerClearAlgorithms(n),s.then(()=>{r[q].state===`errored`?o(r[q].storedError):(readableStreamDefaultControllerError(r[q].controller,t),a())},e=>{readableStreamDefaultControllerError(r[q].controller,e),o(e)}),n[q].finishPromise}function transformStreamDefaultSinkCloseAlgorithm(e){let{readable:t,controller:n}=e[q];if(n[q].finishPromise!==void 0)return n[q].finishPromise;let{promise:r,resolve:i,reject:a}=Promise.withResolvers();n[q].finishPromise=r;let o=n[q].flushAlgorithm(n);return transformStreamDefaultControllerClearAlgorithms(n),o.then(()=>{t[q].state===`errored`?a(t[q].storedError):(readableStreamDefaultControllerClose(t[q].controller),i())},e=>{readableStreamDefaultControllerError(t[q].controller,e),a(e)}),n[q].finishPromise}function transformStreamDefaultSourcePullAlgorithm(e){return transformStreamSetBackpressure(e,!1),e[q].backpressureChange.promise}function transformStreamDefaultSourceCancelAlgorithm(e,t){let{controller:n,writable:r}=e[q];if(n[q].finishPromise!==void 0)return n[q].finishPromise;let{promise:i,resolve:a,reject:o}=Promise.withResolvers();n[q].finishPromise=i;let s=n[q].cancelAlgorithm(t);return transformStreamDefaultControllerClearAlgorithms(n),s.then(()=>{r[q].state===`errored`?o(r[q].storedError):(writableStreamDefaultControllerErrorIfNeeded(r[q].controller,t),transformStreamUnblockWrite(e),a())},t=>{writableStreamDefaultControllerErrorIfNeeded(r[q].controller,t),transformStreamUnblockWrite(e),o(t)}),n[q].finishPromise}const Vt=Object.defineProperty(e=>e.byteLength,"name",{value:`size`}),Ht=Object.defineProperty(()=>1,"name",{value:`size`});var ByteLengthQueuingStrategy=class{#e;constructor(e){if(typeof e!=`object`||!e)throw TypeError(`init must be an object`);if(e.highWaterMark===void 0)throw TypeError(`init.highWaterMark is required`);this.#e=+e.highWaterMark}get highWaterMark(){return this.#e}get size(){return Vt}get[Symbol.toStringTag](){return`ByteLengthQueuingStrategy`}},CountQueuingStrategy=class{#e;constructor(e){if(typeof e!=`object`||!e)throw TypeError(`init must be an object`);if(e.highWaterMark===void 0)throw TypeError(`init.highWaterMark is required`);this.#e=+e.highWaterMark}get highWaterMark(){return this.#e}get size(){return Ht}get[Symbol.toStringTag](){return`CountQueuingStrategy`}},TextEncoderStream=class{#e=null;#t=new TextEncoder;#n;constructor(){this.#n=new TransformStream({transform:(e,t)=>{if(e=String(e),e===``)return;this.#e!==null&&(e=this.#e+e);let n=e.charCodeAt(e.length-1);55296<=n&&n<=56319?(this.#e=e.slice(-1),e=e.slice(0,-1)):this.#e=null,e&&t.enqueue(this.#t.encode(e))},flush:e=>{this.#e!==null&&e.enqueue(new Uint8Array([239,191,189]))}})}get encoding(){return`utf-8`}get readable(){return this.#n.readable}get writable(){return this.#n.writable}};function hasStreamingSupport(){try{return new TextDecoder().decode(new Uint8Array([195]),{stream:!0}),!0}catch{return!1}}const Ut=hasStreamingSupport();function incompleteUtf8Tail$1(e){let t=e.length;if(t===0)return 0;for(let n=1;n<=Math.min(3,t);n++){let r=e[t-n];if(!(r&128))return 0;if((r&192)!=128){let e;if((r&224)==192)e=2;else if((r&240)==224)e=3;else if((r&248)==240)e=4;else return 0;return n<e?n:0}}return 0}__name(incompleteUtf8Tail$1,`incompleteUtf8Tail`);var TextDecoderStream=class{#e;#t;constructor(e,t){if(this.#e=new TextDecoder(e,t),Ut)this.#t=new TransformStream({transform:(e,t)=>{let n=toUint8Array$1(e),r=this.#e.decode(n,{stream:!0});r&&t.enqueue(r)},flush:e=>{let t=this.#e.decode();t&&e.enqueue(t)},cancel:()=>{this.#e.decode()}});else{let e=new Uint8Array;this.#t=new TransformStream({transform:(t,n)=>{let r=toUint8Array$1(t),i;e.length>0?(i=new Uint8Array(e.length+r.length),i.set(e,0),i.set(r,e.length)):i=r;let a=incompleteUtf8Tail$1(i),o;if(a>0?(o=i.slice(0,i.length-a),e=i.slice(i.length-a)):(o=i,e=new Uint8Array),o.length>0){let e=this.#e.decode(o);e&&n.enqueue(e)}},flush:t=>{if(e.length>0){let n=this.#e.decode(e);n&&t.enqueue(n),e=new Uint8Array}},cancel:()=>{e=new Uint8Array}})}}get encoding(){return this.#e.encoding}get fatal(){return this.#e.fatal}get ignoreBOM(){return this.#e.ignoreBOM}get readable(){return this.#t.readable}get writable(){return this.#t.writable}};function toUint8Array$1(e){if(e instanceof Uint8Array)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw TypeError(`chunk must be a BufferSource`)}__name(toUint8Array$1,`toUint8Array`);function isNativeStreamUsable$3(e,t){try{return typeof e==`function`?typeof e.prototype?.[t]==`function`:!1}catch{return!1}}__name(isNativeStreamUsable$3,`isNativeStreamUsable`);const Wt=isNativeStreamUsable$3(globalThis.ReadableStream,`getReader`)?globalThis.ReadableStream:ReadableStream$1,Gt=isNativeStreamUsable$3(globalThis.WritableStream,`getWriter`)?globalThis.WritableStream:WritableStream,Kt=isNativeStreamUsable$3(globalThis.TransformStream,`readable`)?globalThis.TransformStream:TransformStream,qt=typeof globalThis.ByteLengthQueuingStrategy==`function`?globalThis.ByteLengthQueuingStrategy:ByteLengthQueuingStrategy,Jt=typeof globalThis.CountQueuingStrategy==`function`?globalThis.CountQueuingStrategy:CountQueuingStrategy,Yt=typeof globalThis.TextEncoderStream==`function`?globalThis.TextEncoderStream:TextEncoderStream,Xt=typeof globalThis.TextDecoderStream==`function`?globalThis.TextDecoderStream:TextDecoderStream,Zt=globalThis;globalThis.ByteLengthQueuingStrategy===void 0&&(Zt.ByteLengthQueuingStrategy=qt),globalThis.CountQueuingStrategy===void 0&&(Zt.CountQueuingStrategy=Jt);const Qt=globalThis;function isNativeStreamUsable$2(e,t){try{return typeof e==`function`?typeof e.prototype?.[t]==`function`:!1}catch{return!1}}__name(isNativeStreamUsable$2,`isNativeStreamUsable`),isNativeStreamUsable$2(globalThis.ReadableStream,`getReader`)||(Qt.ReadableStream=Wt),Qt.ReadableStreamBYOBReader===void 0&&(Qt.ReadableStreamBYOBReader=ReadableStreamBYOBReader),Qt.ReadableStreamBYOBRequest===void 0&&(Qt.ReadableStreamBYOBRequest=ReadableStreamBYOBRequest),Qt.ReadableByteStreamController===void 0&&(Qt.ReadableByteStreamController=ReadableByteStreamController),Qt.ReadableStreamDefaultController===void 0&&(Qt.ReadableStreamDefaultController=ReadableStreamDefaultController),Qt.ReadableStreamDefaultReader===void 0&&(Qt.ReadableStreamDefaultReader=ReadableStreamDefaultReader);const $t=globalThis;globalThis.TextEncoderStream===void 0&&($t.TextEncoderStream=Yt),globalThis.TextDecoderStream===void 0&&($t.TextDecoderStream=Xt);function isNativeStreamUsable$1(e,t){try{return typeof e==`function`?typeof e.prototype?.[t]==`function`:!1}catch{return!1}}if(__name(isNativeStreamUsable$1,`isNativeStreamUsable`),!isNativeStreamUsable$1(globalThis.TransformStream,`readable`)){let e=globalThis;e.TransformStream=Kt}function isNativeStreamUsable(e,t){try{return typeof e==`function`?typeof e.prototype?.[t]==`function`:!1}catch{return!1}}if(!isNativeStreamUsable(globalThis.WritableStream,`getWriter`)){let e=globalThis;e.WritableStream=Gt}var CryptoKey=class{type;extractable;algorithm;usages;_handle;constructor(e,t,n,r,i){this.type=e,this.extractable=t,this.algorithm=Object.freeze({...n}),this.usages=Object.freeze([...r]),this._handle=i}get[Symbol.toStringTag](){return`CryptoKey`}};const en=Uint8Array.of(166,166,166,166,166,166,166,166);function xorCounter(e,t){for(let n=0;n<8&&t>0;n++)e[7-n]^=t&255,t=Math.floor(t/256)}function aesKeyWrap(e,t){if(e.length<16||e.length%8!=0)throw new DOMException(`AES-KW: key data must be a multiple of 8 bytes and at least 16 bytes`,`OperationError`);let n=e.length/8,r=en.slice(),i=[];for(let t=0;t<n;t++)i.push(e.slice(t*8,t*8+8));let a=new Uint8Array(16);for(let e=0;e<=5;e++)for(let o=1;o<=n;o++){a.set(r,0),a.set(i[o-1],8);let s=t(a);r.set(s.subarray(0,8)),xorCounter(r,n*e+o),i[o-1]=s.slice(8,16)}let o=new Uint8Array((n+1)*8);o.set(r,0);for(let e=0;e<n;e++)o.set(i[e],(e+1)*8);return o}function aesKeyUnwrap(e,t){if(e.length<24||e.length%8!=0)throw new DOMException(`AES-KW: wrapped key must be a multiple of 8 bytes and at least 24 bytes`,`OperationError`);let n=e.length/8-1,r=e.slice(0,8),i=[];for(let t=0;t<n;t++)i.push(e.slice((t+1)*8,(t+2)*8));let a=new Uint8Array(16);for(let e=5;e>=0;e--)for(let o=n;o>=1;o--){xorCounter(r,n*e+o),a.set(r,0),a.set(i[o-1],8);let s=t(a);r.set(s.subarray(0,8)),i[o-1]=s.slice(8,16)}let o=!0;for(let e=0;e<8;e++)r[e]!==en[e]&&(o=!1);if(!o)throw new DOMException(`AES-KW: integrity check failed`,`OperationError`);let s=new Uint8Array(n*8);for(let e=0;e<n;e++)s.set(i[e],e*8);return s}function normalizeAlgorithm$1(e){if(typeof e==`string`)return{name:e};if(!e||typeof e.name!=`string`)throw TypeError(`Algorithm must have a name property`);return e}__name(normalizeAlgorithm$1,`normalizeAlgorithm`);const tn={"SHA-1":`sha1`,"SHA-256":`sha256`,"SHA-384":`sha384`,"SHA-512":`sha512`};function toNodeHashName(e){let t=tn[e.toUpperCase()]||tn[e];if(!t)throw new Ye(`Unrecognized hash name: ${e}`,`NotSupportedError`);return t}const nn={"P-256":`prime256v1`,"P-384":`secp384r1`,"P-521":`secp521r1`};function toNodeCurveName(e){let t=nn[e];if(!t)throw new Ye(`Unrecognized curve name: ${e}`,`NotSupportedError`);return t}function hashSize$1(e){switch(toNodeHashName(e)){case`sha1`:return 20;case`sha256`:return 32;case`sha384`:return 48;case`sha512`:return 64;default:throw new Ye(`Unsupported hash: ${e}`,`NotSupportedError`)}}__name(hashSize$1,`hashSize`);function validateUsages(e,t){for(let n of e)if(!t.includes(n))throw new Ye(`Invalid key usage: ${n}`,`SyntaxError`);if(e.length===0)throw new Ye(`Key usages must not be empty`,`SyntaxError`)}function checkUsage(e,t){if(!e.usages.includes(t))throw new Ye(`Key does not support the '${t}' usage`,`InvalidAccessError`)}const rn=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,an=new Uint8Array(128);for(let e=0;e<64;e++)an[rn.charCodeAt(e)]=e;function bytesToBase64(e){let t=``,n=e.length;for(let r=0;r<n;r+=3){let i=e[r],a=r+1<n?e[r+1]:0,o=r+2<n?e[r+2]:0;t+=rn[i>>2&63],t+=rn[(i<<4|a>>4)&63],t+=r+1<n?rn[(a<<2|o>>6)&63]:`=`,t+=r+2<n?rn[o&63]:`=`}return t}function base64ToBytes(e){let t=e;for(;t.endsWith(`=`);)t=t.slice(0,-1);let n=[],r=0,i=0;for(let e=0;e<t.length;e++)i=i<<6|an[t.charCodeAt(e)],r+=6,r>=8&&(r-=8,n.push(i>>r&255));return new Uint8Array(n)}function base64urlEncode(e){return bytesToBase64(e).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}function base64urlDecode(e){let t=e.replace(/-/g,`+`).replace(/_/g,`/`);for(;t.length%4;)t+=`=`;return base64ToBytes(t)}function toUint8Array(e){if(e instanceof Uint8Array)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw TypeError(`Expected BufferSource`)}var on,sn=__esmMin(()=>{on={RSA_PKCS1_PADDING:1,RSA_NO_PADDING:3,RSA_PKCS1_OAEP_PADDING:4,RSA_PKCS1_PSS_PADDING:6,DH_CHECK_P_NOT_SAFE_PRIME:2,DH_CHECK_P_NOT_PRIME:1,DH_UNABLE_TO_CHECK_GENERATOR:4,DH_NOT_SUITABLE_GENERATOR:8}});function timingSafeEqual(e,t){if(e.length!==t.length)throw RangeError(`Input buffers must have the same byte length`);let n=0;for(let r=0;r<e.length;r++)n|=e[r]^t[r];return n===0}var cn=__esmMin(()=>{});function gmul(e,t){let n=0;for(let r=0;r<8;r++){t&1&&(n^=e);let r=e&128;e=e<<1&255,r&&(e^=27),t>>=1}return n}function keyExpansion(e){let t=e.length/4,n=t+6,r=4*(n+1),i=Array.from({length:r});for(let n=0;n<t;n++)i[n]=new Uint8Array([e[4*n],e[4*n+1],e[4*n+2],e[4*n+3]]);for(let e=t;e<r;e++){let n=new Uint8Array(i[e-1]);e%t===0?n=new Uint8Array([ln[n[1]]^dn[e/t-1],ln[n[2]],ln[n[3]],ln[n[0]]]):t>6&&e%t===4&&(n=new Uint8Array([ln[n[0]],ln[n[1]],ln[n[2]],ln[n[3]]])),i[e]=new Uint8Array(4);for(let r=0;r<4;r++)i[e][r]=i[e-t][r]^n[r]}let a=[];for(let e=0;e<=n;e++){let t=new Uint8Array(16);for(let n=0;n<4;n++)t[4*n]=i[4*e+n][0],t[4*n+1]=i[4*e+n][1],t[4*n+2]=i[4*e+n][2],t[4*n+3]=i[4*e+n][3];a.push(t)}return a}function aesEncryptBlock(e,t){let n=new Uint8Array(e),r=t.length-1;for(let e=0;e<16;e++)n[e]^=t[0][e];for(let e=1;e<r;e++){for(let e=0;e<16;e++)n[e]=ln[n[e]];let r=n[1];n[1]=n[5],n[5]=n[9],n[9]=n[13],n[13]=r;let i=n[2],a=n[6];n[2]=n[10],n[6]=n[14],n[10]=i,n[14]=a;let o=n[15];n[15]=n[11],n[11]=n[7],n[7]=n[3],n[3]=o;for(let e=0;e<4;e++){let t=e*4,r=n[t],i=n[t+1],a=n[t+2],o=n[t+3];n[t]=gmul(2,r)^gmul(3,i)^a^o,n[t+1]=r^gmul(2,i)^gmul(3,a)^o,n[t+2]=r^i^gmul(2,a)^gmul(3,o),n[t+3]=gmul(3,r)^i^a^gmul(2,o)}for(let r=0;r<16;r++)n[r]^=t[e][r]}for(let e=0;e<16;e++)n[e]=ln[n[e]];let i=n[1];n[1]=n[5],n[5]=n[9],n[9]=n[13],n[13]=i;let a=n[2],o=n[6];n[2]=n[10],n[6]=n[14],n[10]=a,n[14]=o;let s=n[15];n[15]=n[11],n[11]=n[7],n[7]=n[3],n[3]=s;for(let e=0;e<16;e++)n[e]^=t[r][e];return n}function aesDecryptBlock(e,t){let n=new Uint8Array(e),r=t.length-1;for(let e=0;e<16;e++)n[e]^=t[r][e];for(let e=r-1;e>0;e--){let r=n[13];n[13]=n[9],n[9]=n[5],n[5]=n[1],n[1]=r;let i=n[10],a=n[14];n[10]=n[2],n[14]=n[6],n[2]=i,n[6]=a;let o=n[3];n[3]=n[7],n[7]=n[11],n[11]=n[15],n[15]=o;for(let e=0;e<16;e++)n[e]=un[n[e]];for(let r=0;r<16;r++)n[r]^=t[e][r];for(let e=0;e<4;e++){let t=e*4,r=n[t],i=n[t+1],a=n[t+2],o=n[t+3];n[t]=gmul(14,r)^gmul(11,i)^gmul(13,a)^gmul(9,o),n[t+1]=gmul(9,r)^gmul(14,i)^gmul(11,a)^gmul(13,o),n[t+2]=gmul(13,r)^gmul(9,i)^gmul(14,a)^gmul(11,o),n[t+3]=gmul(11,r)^gmul(13,i)^gmul(9,a)^gmul(14,o)}}let i=n[13];n[13]=n[9],n[9]=n[5],n[5]=n[1],n[1]=i;let a=n[10],o=n[14];n[10]=n[2],n[14]=n[6],n[2]=a,n[6]=o;let s=n[3];n[3]=n[7],n[7]=n[11],n[11]=n[15],n[15]=s;for(let e=0;e<16;e++)n[e]=un[n[e]];for(let e=0;e<16;e++)n[e]^=t[0][e];return n}function incrementCounter(e){for(let t=15;t>=0&&++e[t]===0;t--);}function gcmIncrementCounter(e){for(let t=15;t>=12&&++e[t]===0;t--);}function gfMul(e,t){let n=new Uint8Array(16),r=new Uint8Array(e);for(let e=0;e<128;e++){if(t[e>>>3]&1<<7-(e&7))for(let e=0;e<16;e++)n[e]^=r[e];let i=r[15]&1;for(let e=15;e>0;e--)r[e]=r[e]>>>1|(r[e-1]&1)<<7;r[0]>>>=1,i&&(r[0]^=225)}return n}function ghash(e,t,n){let r=new Uint8Array(16),i=Math.ceil(t.length/16)||0;for(let n=0;n<i;n++){let i=n*16,a=Math.min(i+16,t.length);for(let e=0;e<16;e++){let n=i+e;n<a&&(r[e]^=t[n])}let o=gfMul(r,e);r.set(o)}let a=Math.ceil(n.length/16)||0;for(let t=0;t<a;t++){let i=t*16,a=Math.min(i+16,n.length);for(let e=0;e<16;e++){let t=i+e;t<a&&(r[e]^=n[t])}let o=gfMul(r,e);r.set(o)}let o=new Uint8Array(16),s=t.length*8,c=n.length*8,l=Math.floor(s/4294967296),u=s>>>0;o[0]=l>>>24&255,o[1]=l>>>16&255,o[2]=l>>>8&255,o[3]=l&255,o[4]=u>>>24&255,o[5]=u>>>16&255,o[6]=u>>>8&255,o[7]=u&255;let d=Math.floor(c/4294967296),f=c>>>0;o[8]=d>>>24&255,o[9]=d>>>16&255,o[10]=d>>>8&255,o[11]=d&255,o[12]=f>>>24&255,o[13]=f>>>16&255,o[14]=f>>>8&255,o[15]=f&255;for(let e=0;e<16;e++)r[e]^=o[e];let p=gfMul(r,e);return r.set(p),r}var ln,un,dn,fn=__esmMin(()=>{ln=new Uint8Array([99,124,119,123,242,107,111,197,48,1,103,43,254,215,171,118,202,130,201,125,250,89,71,240,173,212,162,175,156,164,114,192,183,253,147,38,54,63,247,204,52,165,229,241,113,216,49,21,4,199,35,195,24,150,5,154,7,18,128,226,235,39,178,117,9,131,44,26,27,110,90,160,82,59,214,179,41,227,47,132,83,209,0,237,32,252,177,91,106,203,190,57,74,76,88,207,208,239,170,251,67,77,51,133,69,249,2,127,80,60,159,168,81,163,64,143,146,157,56,245,188,182,218,33,16,255,243,210,205,12,19,236,95,151,68,23,196,167,126,61,100,93,25,115,96,129,79,220,34,42,144,136,70,238,184,20,222,94,11,219,224,50,58,10,73,6,36,92,194,211,172,98,145,149,228,121,231,200,55,109,141,213,78,169,108,86,244,234,101,122,174,8,186,120,37,46,28,166,180,198,232,221,116,31,75,189,139,138,112,62,181,102,72,3,246,14,97,53,87,185,134,193,29,158,225,248,152,17,105,217,142,148,155,30,135,233,206,85,40,223,140,161,137,13,191,230,66,104,65,153,45,15,176,84,187,22]),un=new Uint8Array([82,9,106,213,48,54,165,56,191,64,163,158,129,243,215,251,124,227,57,130,155,47,255,135,52,142,67,68,196,222,233,203,84,123,148,50,166,194,35,61,238,76,149,11,66,250,195,78,8,46,161,102,40,217,36,178,118,91,162,73,109,139,209,37,114,248,246,100,134,104,152,22,212,164,92,204,93,101,182,146,108,112,72,80,253,237,185,218,94,21,70,87,167,141,157,132,144,216,171,0,140,188,211,10,247,228,88,5,184,179,69,6,208,44,30,143,202,63,15,2,193,175,189,3,1,19,138,107,58,145,17,65,79,103,220,234,151,242,207,206,240,180,230,115,150,172,116,34,231,173,53,133,226,249,55,232,28,117,223,110,71,241,26,113,29,41,197,137,111,183,98,14,170,24,190,27,252,86,62,75,198,210,121,32,154,219,192,254,120,205,90,244,31,221,168,51,136,7,199,49,177,18,16,89,39,128,236,95,96,81,127,169,25,181,74,13,45,229,122,159,147,201,156,239,160,224,59,77,174,42,245,176,200,235,187,60,131,83,153,97,23,43,4,126,186,119,214,38,225,105,20,99,85,33,12,125]),dn=[1,2,4,8,16,32,64,128,27,54]});function parseAlgorithm(e){let t=e.toLowerCase().match(/^aes-(128|192|256)-(cbc|ctr|ecb|cfb|ofb|gcm)$/);if(!t)throw Error(`Unsupported cipher algorithm: ${e}`);let n=parseInt(t[1]),r=t[2];return{keySize:n/8,ivSize:r===`ecb`?0:r===`gcm`?12:16,mode:r}}function toBuffer$2(e,t){return typeof e==`string`?I.from(e,t||`utf8`):I.from(e)}function encodeOutput(e,t){return t?I.from(e).toString(t):I.from(e)}function incompleteUtf8Tail(e){if(e.length===0)return 0;let t=e.length;for(let n=1;n<=Math.min(4,t);n++){let r=e[t-n];if(!(r&128))return 0;if((r&192)==128)continue;let i;if((r&224)==192)i=2;else if((r&240)==224)i=3;else if((r&248)==240)i=4;else return 0;return n<i?n:0}return 0}function pkcs7Pad(e){let t=16-e.length%16,n=new Uint8Array(e.length+t);n.set(e);for(let r=e.length;r<n.length;r++)n[r]=t;return n}function pkcs7Unpad(e){if(e.length===0||e.length%16!=0)throw Error(`bad decrypt`);let t=e[e.length-1];if(t===0||t>16)throw Error(`bad decrypt`);for(let n=e.length-t;n<e.length;n++)if(e[n]!==t)throw Error(`bad decrypt`);return new Uint8Array(e.slice(0,e.length-t))}var pn=__esmMin(()=>{_e(),__name(toBuffer$2,`toBuffer`)});function createCipher(e,t){throw Error(`crypto.createCipher() is deprecated. Use createCipheriv() instead.`)}function createCipheriv(e,t,n){return new Cipher(e,typeof t==`string`?I.from(t):new Uint8Array(t),n==null?null:typeof n==`string`?I.from(n):new Uint8Array(n))}function createDecipher(e,t){throw Error(`crypto.createDecipher() is deprecated. Use createDecipheriv() instead.`)}function createDecipheriv(e,t,n){return new Decipher(e,typeof t==`string`?I.from(t):new Uint8Array(t),n==null?null:typeof n==`string`?I.from(n):new Uint8Array(n))}function getCiphers(){return[`aes-128-cbc`,`aes-128-ecb`,`aes-192-cbc`,`aes-192-ecb`,`aes-256-cbc`,`aes-256-ecb`,`aes-128-ctr`,`aes-192-ctr`,`aes-256-ctr`,`aes-128-cfb`,`aes-192-cfb`,`aes-256-cfb`,`aes-128-gcm`,`aes-192-gcm`,`aes-256-gcm`]}var CipherBase,Cipher,Decipher,mn=__esmMin(()=>{fn(),pn(),_e(),CipherBase=class{_roundKeys;_iv;_mode;_buffer=new Uint8Array;_autoPadding=!0;_finalized=!1;constructor(e,t,n){let r=parseAlgorithm(e);if(t.length!==r.keySize)throw Error(`Invalid key length ${t.length}, expected ${r.keySize} for ${e}`);if(r.ivSize>0&&(!n||n.length!==r.ivSize))throw Error(`Invalid IV length ${n?.length??0}, expected ${r.ivSize} for ${e}`);this._roundKeys=keyExpansion(t),this._iv=n?new Uint8Array(n):new Uint8Array(16),this._mode=r.mode}setAutoPadding(e){return this._autoPadding=e,this}},Cipher=class extends CipherBase{_prevBlock;_counter;_gcmH=null;_gcmJ0=null;_gcmAAD=new Uint8Array;_gcmCiphertext=[];_gcmCiphertextLen=0;_gcmAuthTag=null;_gcmAADSet=!1;constructor(e,t,n){super(e,t,n),this._prevBlock=new Uint8Array(this._iv),this._mode===`gcm`?(this._gcmH=aesEncryptBlock(new Uint8Array(16),this._roundKeys),this._gcmJ0=new Uint8Array(16),this._gcmJ0.set(this._iv.subarray(0,12)),this._gcmJ0[15]=1,this._counter=new Uint8Array(this._gcmJ0),gcmIncrementCounter(this._counter)):this._counter=new Uint8Array(this._iv)}setAAD(e){if(this._mode!==`gcm`)throw Error(`setAAD is only supported in GCM mode`);if(this._gcmCiphertextLen>0)throw Error(`setAAD must be called before update()`);return this._gcmAAD=new Uint8Array(e),this._gcmAADSet=!0,this}getAuthTag(){if(this._mode!==`gcm`)throw Error(`getAuthTag is only supported in GCM mode`);if(!this._gcmAuthTag)throw Error(`getAuthTag must be called after final()`);return I.from(this._gcmAuthTag)}update(e,t,n){let r=toBuffer$2(e,t),i=new Uint8Array(this._buffer.length+r.length);if(i.set(this._buffer),i.set(r,this._buffer.length),this._mode===`gcm`){let e=this._processGcmEncrypt(i);return this._buffer=new Uint8Array,encodeOutput(e,n)}if(this._mode===`ctr`||this._mode===`cfb`||this._mode===`ofb`){let e=this._processStream(i);return this._buffer=new Uint8Array,encodeOutput(e,n)}let a=Math.floor(i.length/16)*16,o=[];for(let e=0;e<a;e+=16){let t=i.slice(e,e+16);o.push(this._encryptBlock(t))}this._buffer=i.slice(a);let s=new Uint8Array(o.length*16);for(let e=0;e<o.length;e++)s.set(o[e],e*16);return encodeOutput(s,n)}final(e){if(this._finalized)throw Error(`Cipher already finalized`);if(this._finalized=!0,this._mode===`gcm`){let t=new Uint8Array;this._buffer.length>0&&(t=this._processGcmEncrypt(this._buffer),this._buffer=new Uint8Array);let n=new Uint8Array(this._gcmCiphertextLen),r=0;for(let e of this._gcmCiphertext)n.set(e,r),r+=e.length;let i=ghash(this._gcmH,this._gcmAAD,n),a=aesEncryptBlock(this._gcmJ0,this._roundKeys),o=new Uint8Array(16);for(let e=0;e<16;e++)o[e]=i[e]^a[e];return this._gcmAuthTag=I.from(o),encodeOutput(t,e)}if(this._mode===`ctr`||this._mode===`cfb`||this._mode===`ofb`){if(this._buffer.length>0){let t=this._processStream(this._buffer);return this._buffer=new Uint8Array,encodeOutput(t,e)}return encodeOutput(new Uint8Array,e)}let t=this._buffer;if(this._autoPadding)t=pkcs7Pad(t);else if(t.length%16!=0)throw Error(`data not multiple of block size`);let n=[];for(let e=0;e<t.length;e+=16)n.push(this._encryptBlock(t.slice(e,e+16)));if(this._buffer=new Uint8Array,n.length===0)return encodeOutput(new Uint8Array,e);let r=new Uint8Array(n.length*16);for(let e=0;e<n.length;e++)r.set(n[e],e*16);return encodeOutput(r,e)}_encryptBlock(e){if(this._mode===`cbc`){let t=new Uint8Array(16);for(let n=0;n<16;n++)t[n]=e[n]^this._prevBlock[n];let n=aesEncryptBlock(t,this._roundKeys);return this._prevBlock=n,n}else if(this._mode===`ecb`)return aesEncryptBlock(e,this._roundKeys);throw Error(`Block encryption not supported for mode: ${this._mode}`)}_processStream(e){let t=new Uint8Array(e.length);for(let n=0;n<e.length;n+=16){let r=aesEncryptBlock(this._counter,this._roundKeys),i=Math.min(16,e.length-n);for(let a=0;a<i;a++)t[n+a]=e[n+a]^r[a];incrementCounter(this._counter)}return t}_processGcmEncrypt(e){let t=new Uint8Array(e.length);for(let n=0;n<e.length;n+=16){let r=aesEncryptBlock(this._counter,this._roundKeys),i=Math.min(16,e.length-n);for(let a=0;a<i;a++)t[n+a]=e[n+a]^r[a];gcmIncrementCounter(this._counter)}return this._gcmCiphertext.push(new Uint8Array(t)),this._gcmCiphertextLen+=t.length,t}},Decipher=class extends CipherBase{_prevBlock;_counter;_pendingUtf8=new Uint8Array;_gcmH=null;_gcmJ0=null;_gcmAAD=new Uint8Array;_gcmCiphertext=[];_gcmCiphertextLen=0;_gcmExpectedTag=null;_gcmAADSet=!1;constructor(e,t,n){super(e,t,n),this._prevBlock=new Uint8Array(this._iv),this._mode===`gcm`?(this._gcmH=aesEncryptBlock(new Uint8Array(16),this._roundKeys),this._gcmJ0=new Uint8Array(16),this._gcmJ0.set(this._iv.subarray(0,12)),this._gcmJ0[15]=1,this._counter=new Uint8Array(this._gcmJ0),gcmIncrementCounter(this._counter)):this._counter=new Uint8Array(this._iv)}setAAD(e){if(this._mode!==`gcm`)throw Error(`setAAD is only supported in GCM mode`);if(this._gcmCiphertextLen>0)throw Error(`setAAD must be called before update()`);return this._gcmAAD=new Uint8Array(e),this._gcmAADSet=!0,this}setAuthTag(e){if(this._mode!==`gcm`)throw Error(`setAuthTag is only supported in GCM mode`);return this._gcmExpectedTag=I.from(e),this}_encodeWithUtf8Handling(e,t,n){if(!t||t!==`utf8`&&t!==`utf-8`)return encodeOutput(e,t);let r;if(this._pendingUtf8.length>0?(r=new Uint8Array(this._pendingUtf8.length+e.length),r.set(this._pendingUtf8),r.set(e,this._pendingUtf8.length),this._pendingUtf8=new Uint8Array):r=e,!n){let e=incompleteUtf8Tail(r);e>0&&(this._pendingUtf8=new Uint8Array(r.slice(r.length-e)),r=new Uint8Array(r.slice(0,r.length-e)))}return I.from(r).toString(`utf8`)}update(e,t,n){let r=toBuffer$2(e,t),i=new Uint8Array(this._buffer.length+r.length);if(i.set(this._buffer),i.set(r,this._buffer.length),this._mode===`gcm`){this._gcmCiphertext.push(new Uint8Array(i)),this._gcmCiphertextLen+=i.length;let e=this._processGcmDecrypt(i);return this._buffer=new Uint8Array,this._encodeWithUtf8Handling(e,n,!1)}if(this._mode===`ctr`||this._mode===`cfb`||this._mode===`ofb`){let e=this._processStream(i);return this._buffer=new Uint8Array,this._encodeWithUtf8Handling(e,n,!1)}let a=Math.floor(i.length/16);if(a===0)return this._buffer=i,this._encodeWithUtf8Handling(new Uint8Array,n,!1);let o=(this._autoPadding?a-1:a)*16,s=[];for(let e=0;e<o;e+=16){let t=i.slice(e,e+16);s.push(this._decryptBlock(t))}this._buffer=i.slice(o);let c=new Uint8Array(s.length*16);for(let e=0;e<s.length;e++)c.set(s[e],e*16);return this._encodeWithUtf8Handling(c,n,!1)}final(e){if(this._finalized)throw Error(`Decipher already finalized`);if(this._finalized=!0,this._mode===`gcm`){let t=new Uint8Array;if(this._buffer.length>0&&(this._gcmCiphertext.push(new Uint8Array(this._buffer)),this._gcmCiphertextLen+=this._buffer.length,t=this._processGcmDecrypt(this._buffer),this._buffer=new Uint8Array),!this._gcmExpectedTag)throw Error(`Unsupported state or unable to authenticate data`);let n=new Uint8Array(this._gcmCiphertextLen),r=0;for(let e of this._gcmCiphertext)n.set(e,r),r+=e.length;let i=ghash(this._gcmH,this._gcmAAD,n),a=aesEncryptBlock(this._gcmJ0,this._roundKeys),o=new Uint8Array(16);for(let e=0;e<16;e++)o[e]=i[e]^a[e];let s=this._gcmExpectedTag,c=Math.min(s.length,16),l=0;for(let e=0;e<c;e++)l|=o[e]^s[e];if(l!==0)throw Error(`Unsupported state or unable to authenticate data`);return this._encodeWithUtf8Handling(t,e,!0)}if(this._mode===`ctr`||this._mode===`cfb`||this._mode===`ofb`){if(this._buffer.length>0){let t=this._processStream(this._buffer);return this._buffer=new Uint8Array,this._encodeWithUtf8Handling(t,e,!0)}return this._encodeWithUtf8Handling(new Uint8Array,e,!0)}if(this._buffer.length===0)return this._encodeWithUtf8Handling(new Uint8Array,e,!0);if(this._buffer.length%16!=0)throw Error(`bad decrypt`);let t=[];for(let e=0;e<this._buffer.length;e+=16)t.push(this._decryptBlock(this._buffer.slice(e,e+16)));let n=new Uint8Array(t.length*16);for(let e=0;e<t.length;e++)n.set(t[e],e*16);let r=this._autoPadding?pkcs7Unpad(n):n;return this._buffer=new Uint8Array,this._encodeWithUtf8Handling(r,e,!0)}_decryptBlock(e){if(this._mode===`cbc`){let t=aesDecryptBlock(e,this._roundKeys),n=new Uint8Array(16);for(let e=0;e<16;e++)n[e]=t[e]^this._prevBlock[e];return this._prevBlock=new Uint8Array(e),n}else if(this._mode===`ecb`)return aesDecryptBlock(e,this._roundKeys);throw Error(`Block decryption not supported for mode: ${this._mode}`)}_processStream(e){let t=new Uint8Array(e.length);for(let n=0;n<e.length;n+=16){let r=aesEncryptBlock(this._counter,this._roundKeys),i=Math.min(16,e.length-n);for(let a=0;a<i;a++)t[n+a]=e[n+a]^r[a];incrementCounter(this._counter)}return t}_processGcmDecrypt(e){let t=new Uint8Array(e.length);for(let n=0;n<e.length;n+=16){let r=aesEncryptBlock(this._counter,this._roundKeys),i=Math.min(16,e.length-n);for(let a=0;a<i;a++)t[n+a]=e[n+a]^r[a];gcmIncrementCounter(this._counter)}return t}}});function gjsGi(){return globalThis.imports?.gi}function fillFromWebCrypto(e,t){for(let n=0;n<e.length;n+=hn){let r=Math.min(e.length-n,hn);t.getRandomValues(new Uint8Array(e.buffer,e.byteOffset+n,r))}}function openUrandom(){if(_n!==null)return _n;let e=gjsGi()?.Gio;if(!e)return _n=!1,!1;try{_n=e.File.new_for_path(`/dev/urandom`).read(null)}catch{_n=!1}return _n}function fillFromUrandom(e){let t=openUrandom();if(!t)return!1;try{let n=0;for(;n<e.length;){let r=t.read_bytes(e.length-n,null).toArray();if(r.length===0)return!1;e.set(r,n),n+=r.length}return!0}catch{return!1}}function fillFromGLib(e){let t=gjsGi()?.GLib;if(!t?.random_int_range)return!1;for(let n=0;n<e.length;n++)e[n]=t.random_int_range(0,256);return!0}function fillFromMath(e){for(let t=0;t<e.length;t++)e[t]=Math.floor(Math.random()*256)}function warnInsecureOnce(e){gn||(gn=!0,T.warn(`[@gjsify/webcrypto] No cryptographically secure random source available — falling back to "${e}". Neither GLib.Random nor Math.random is suitable for keys, tokens or IVs. Expected sources: WebCrypto (globalThis.crypto) or /dev/urandom via Gio on GJS.`))}function fillRandomBytes(e,t={}){if(e.length===0)return`webcrypto`;let n=t.webcrypto===void 0?globalThis.crypto??null:t.webcrypto;return n&&typeof n.getRandomValues==`function`?(fillFromWebCrypto(e,n),`webcrypto`):fillFromUrandom(e)?`urandom`:fillFromGLib(e)?(warnInsecureOnce(`glib`),`glib`):(fillFromMath(e),warnInsecureOnce(`math`),`math`)}var hn,gn,_n,vn=__esmMin(()=>{E(),hn=65536,gn=!1,_n=null});function fillRandom(e){fillRandomBytes(e)}function randomBytes(e,t){if(typeof e!=`number`||e<0||!Number.isInteger(e))throw TypeError(`The "size" argument must be a non-negative integer. Received ${e}`);try{let n=I.alloc(e);if(e>0&&fillRandom(new Uint8Array(n.buffer,n.byteOffset,n.byteLength)),t)t(null,n);else return n}catch(e){if(t)t(e,I.alloc(0));else throw e}}function randomFillSync(e,t=0,n){let r=n??e.length-t;if(t<0||t>e.length)throw RangeError(`The value of "offset" is out of range. Received ${t}`);if(r<0||t+r>e.length)throw RangeError(`The value of "size" is out of range. Received ${r}`);if(r>0){let n=(e instanceof I,e.byteOffset);fillRandom(new Uint8Array(e.buffer,n+t,r))}return e}function randomFill(e,t,n,r){let i,a,o;typeof t==`function`?(o=t,i=0,a=e.length):typeof n==`function`?(o=n,i=t,a=e.length-t):(o=r,i=t,a=n);try{randomFillSync(e,i,a),o(null,e)}catch(t){o(t,e)}}function randomUUID(){if(typeof globalThis.crypto?.randomUUID==`function`)return globalThis.crypto.randomUUID();let e=new Uint8Array(16);fillRandom(e),e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``);return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}function randomInt(e,t,n){let r,i,a;if(typeof t==`function`?(a=t,i=e,r=0):typeof t==`number`?(r=e,i=t,a=n):(i=e,r=0,a=n),!Number.isInteger(r))throw TypeError(`The "min" argument must be a safe integer. Received ${r}`);if(!Number.isInteger(i))throw TypeError(`The "max" argument must be a safe integer. Received ${i}`);if(r>=i)throw RangeError(`The value of "min" must be less than "max". Received min: ${r}, max: ${i}`);let o=i-r,s=new Uint32Array(1);fillRandom(new Uint8Array(s.buffer));let c=r+s[0]%o;if(a)a(null,c);else return c}var yn=__esmMin(()=>{_e(),vn()});function modPow(e,t,n){if(n===1n)return 0n;e=(e%n+n)%n;let r=1n;for(;t>0n;)t&1n&&(r=r*e%n),t>>=1n,e=e*e%n;return r}function bigIntToBytes(e,t){let n=new Uint8Array(t),r=e;for(let e=t-1;e>=0;e--)n[e]=Number(r&255n),r>>=8n;return n}function bytesToBigInt(e){let t=0n;for(let n=0;n<e.length;n++)t=t<<8n|BigInt(e[n]);return t}var bn=__esmMin(()=>{});function bigIntToBuffer(e){if(e===0n)return I.from([0]);let t=e.toString(16);return t.length%2!=0&&(t=`0`+t),I.from(t,`hex`)}function bufferToBigInt(e){if(e.length===0)return 0n;let t=I.from(e).toString(`hex`);return t.length===0?0n:BigInt(`0x`+t)}function bitLength(e){return e===0n?0:e.toString(2).length}function simpleSieve(e){for(let t of Sn){let n=BigInt(t);if(e%n===0n)return e===n}return!0}function fermatTest(e){return modPow(2n,e-1n,e)===1n}function millerRabinTest(e){if(e<2n)return!1;if(e===2n||e===3n)return!0;if(e%2n==0n)return!1;let t=e-1n,n=0;for(;t%2n==0n;)t/=2n,n++;for(let r of[2n,3n,5n,7n,11n,13n]){if(r>=e)continue;let i=modPow(r,t,e);if(i===1n||i===e-1n)continue;let a=!0;for(let t=0;t<n-1;t++)if(i=modPow(i,2n,e),i===e-1n){a=!1;break}if(a)return!1}return!0}function checkPrime(e,t){let n=t.toString(`hex`),r=0;if(e%2n==0n||!simpleSieve(e)||!fermatTest(e)||!millerRabinTest(e))return r+=1,n===`02`||n===`05`?r+=8:r+=4,r;switch(millerRabinTest(e>>1n)||(r+=2),n){case`02`:e%24n!=11n&&(r+=8);break;case`05`:{let t=e%10n;t!==3n&&t!==7n&&(r+=8)}break;default:r+=4}return r}function getCachedCheckPrime(e,t){let n=t.toString(`hex`)+`_`+e.toString(16);if(n in Cn)return Cn[n];let r=checkPrime(e,t);return Cn[n]=r,r}function formatReturnValue$1(e,t){let n=bigIntToBuffer(e);return t?n.toString(t):n}function generatePrime(e,t){let n=bufferToBigInt(t);if(e<16)return n===2n||n===5n?I.from([140,123]):I.from([140,39]);let r=Math.ceil(e/8),i=2n,a=4n;for(;;){let t=bufferToBigInt(randomBytes(r));for(;bitLength(t)>e;)t>>=1n;if(t%i==0n&&(t+=1n),t&i||(t+=i),n===i)for(;t%24n!=11n;)t+=a;else if(n===5n)for(;t%10n!=3n;)t+=a;let o=t>>1n;if(simpleSieve(o)&&simpleSieve(t)&&fermatTest(o)&&fermatTest(t)&&millerRabinTest(o)&&millerRabinTest(t))return bigIntToBuffer(t)}}function createDiffieHellman(e,t,n,r){if(t!==void 0&&typeof t!=`number`&&(I.isBuffer(t)||t instanceof Uint8Array||typeof t==`string`&&!(t in wn)))return createDiffieHellman(e,`binary`,t,n);let i=t||`binary`,a=r||`binary`,o=I.from([2]);if(n!==void 0&&(typeof n==`number`?(o=I.alloc(1),o[0]=n):o=I.isBuffer(n)?n:I.from(n,a)),typeof e==`number`)return new DiffieHellman(generatePrime(e,o),o,!0);let s;return s=I.isBuffer(e)?e:e instanceof Uint8Array?I.from(e):I.from(e,i),new DiffieHellman(s,o,!0)}function getDiffieHellman(e){let t=xn[e];if(!t)throw Error(`Unknown group: ${e}. Supported groups: ${Object.keys(xn).join(`, `)}`);return new DiffieHellman(I.from(t.prime,`hex`),I.from(t.gen,`hex`),!1)}var xn,Sn,Cn,DiffieHellman,wn,Tn,En,Dn=__esmMin(()=>{bn(),yn(),_e(),xn={modp1:{gen:`02`,prime:`ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff`},modp2:{gen:`02`,prime:`ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff`},modp5:{gen:`02`,prime:`ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff`},modp14:{gen:`02`,prime:`ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff`},modp15:{gen:`02`,prime:`ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff`},modp16:{gen:`02`,prime:`ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff`},modp17:{gen:`02`,prime:`ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff`},modp18:{gen:`02`,prime:`ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff`}},Sn=[];{let e=1e3,t=new Uint8Array(1001);for(let n=2;n*n<=e;n++)if(!t[n])for(let r=n*n;r<=e;r+=n)t[r]=1;for(let n=2;n<=e;n++)t[n]||Sn.push(n)}Cn={},__name(formatReturnValue$1,`formatReturnValue`),DiffieHellman=class{_prime;_generator;_generatorBuf;_primeByteLength;_pubKey;_privKey;_primeCode;_malleable;constructor(e,t,n=!1){this._prime=bufferToBigInt(e),this._generatorBuf=t,this._generator=bufferToBigInt(t),this._primeByteLength=e.length,this._pubKey=void 0,this._privKey=void 0,this._primeCode=void 0,this._malleable=n,n||(this._primeCode=0,this.setPublicKey=void 0,this.setPrivateKey=void 0)}get verifyError(){return typeof this._primeCode!=`number`&&(this._primeCode=getCachedCheckPrime(this._prime,this._generatorBuf)),this._primeCode}generateKeys(e){if(!this._privKey){let e=randomBytes(this._primeByteLength);this._privKey=bufferToBigInt(e)}return this._pubKey=modPow(this._generator,this._privKey,this._prime),this.getPublicKey(e)}computeSecret(e,t,n){let r;r=typeof e==`string`?I.from(e,t||`utf8`):I.from(e);let i=bufferToBigInt(r);if(!this._privKey)throw Error(`You must generate keys before computing a secret`);if(i<=0n||i>=this._prime)throw Error(`Supplied key is too large`);let a=bigIntToBuffer(modPow(i,this._privKey,this._prime)),o=this._primeByteLength;if(a.length<o){let e=I.alloc(o);a.copy(e,o-a.length),a=e}return n?a.toString(n):a}getPrime(e){return formatReturnValue$1(this._prime,e)}getGenerator(e){return formatReturnValue$1(this._generator,e)}getPublicKey(e){if(!this._pubKey)throw Error(`No public key - call generateKeys() first`);return formatReturnValue$1(this._pubKey,e)}getPrivateKey(e){if(!this._privKey)throw Error(`No private key - call generateKeys() first`);return formatReturnValue$1(this._privKey,e)}setPublicKey(e,t){if(!this._malleable)throw Error(`setPublicKey is not available for predefined DH groups`);let n=typeof e==`string`?I.from(e,t||`utf8`):I.from(e);this._pubKey=bufferToBigInt(n)}setPrivateKey(e,t){if(!this._malleable)throw Error(`setPrivateKey is not available for predefined DH groups`);let n=typeof e==`string`?I.from(e,t||`utf8`):I.from(e);this._privKey=bufferToBigInt(n)}},wn={binary:!0,hex:!0,base64:!0,latin1:!0,utf8:!0,"utf-8":!0,base64url:!0,ascii:!0,ucs2:!0,"ucs-2":!0,utf16le:!0,"utf-16le":!0},Tn=getDiffieHellman,En=getDiffieHellman});function mod(e,t){let n=e%t;return n<0n?n+t:n}function modInverse$2(e,t){if(e=mod(e,t),e===0n)throw Error(`No modular inverse for zero`);let[n,r]=[e,t],[i,a]=[1n,0n];for(;r!==0n;){let e=n/r;[n,r]=[r,n-e*r],[i,a]=[a,i-e*a]}if(n!==1n)throw Error(`Modular inverse does not exist`);return mod(i,t)}function pointAdd(e,t,n){if(e===null)return t;if(t===null)return e;let{p:r}=n;if(e.x===t.x)return mod(e.y+t.y,r)===0n?null:pointDouble(e,n);let i=mod(t.x-e.x,r),a=mod(mod(t.y-e.y,r)*modInverse$2(i,r),r),o=mod(a*a-e.x-t.x,r);return{x:o,y:mod(a*(e.x-o)-e.y,r)}}function pointDouble(e,t){if(e===null)return null;let{a:n,p:r}=t;if(e.y===0n)return null;let i=mod(mod(3n*e.x*e.x+n,r)*modInverse$2(mod(2n*e.y,r),r),r),a=mod(i*i-2n*e.x,r);return{x:a,y:mod(i*(e.x-a)-e.y,r)}}function scalarMul(e,t,n){if(t===null||e===0n)return null;let{n:r}=n;if(e=mod(e,r),e===0n)return null;let i=null,a=t,o=e.toString(2);for(let e=0;e<o.length;e++)o[e]===`1`?(i=pointAdd(i,a,n),a=pointDouble(a,n)):(a=pointAdd(i,a,n),i=pointDouble(i,n));return i}function bigintToBuffer(e,t){let n=e.toString(16).padStart(t*2,`0`);return I.from(n,`hex`)}function bufferToBigint(e){let t=I.from(e).toString(`hex`);return t.length===0?0n:BigInt(`0x`+t)}function encodePublicKey(e,t,n=`uncompressed`){if(e===null)throw Error(`Cannot encode the point at infinity`);let r=bigintToBuffer(e.x,t);if(n===`compressed`){let t=e.y%2n==0n?2:3;return I.concat([I.from([t]),r])}let i=bigintToBuffer(e.y,t);if(n===`hybrid`){let t=e.y%2n==0n?6:7;return I.concat([I.from([t]),r,i])}return I.concat([I.from([4]),r,i])}function decodePublicKey(e,t){let n=I.from(e);if(n.length===0)throw Error(`Invalid public key: empty buffer`);let r=n[0],{p:i,a,b:o,byteLength:s}=t;if(r===4||r===6||r===7){if(n.length!==1+2*s)throw Error(`Invalid public key length: expected ${1+2*s} bytes, got ${n.length}`);let e=bufferToBigint(n.subarray(1,1+s)),t=bufferToBigint(n.subarray(1+s));if(mod(t*t,i)!==mod(e*e*e+a*e+o,i))throw Error(`Invalid public key: point is not on the curve`);return{x:e,y:t}}if(r===2||r===3){if(n.length!==1+s)throw Error(`Invalid public key length: expected ${1+s} bytes, got ${n.length}`);let e=bufferToBigint(n.subarray(1,1+s)),t=sqrtMod(mod(e*e*e+a*e+o,i),i);if(t===null)throw Error(`Invalid public key: no valid y coordinate for the given x`);let c=r===3;return{x:e,y:t%2n!=0n===c?t:mod(i-t,i)}}throw Error(`Invalid public key prefix: 0x${r.toString(16).padStart(2,`0`)}`)}function sqrtMod(e,t){if(e=mod(e,t),e===0n)return 0n;if(modPow(e,(t-1n)/2n,t)!==1n)return null;if(mod(t,4n)===3n)return modPow(e,(t+1n)/4n,t);let n=0n,r=t-1n;for(;mod(r,2n)===0n;)r/=2n,n++;let i=2n;for(;modPow(i,(t-1n)/2n,t)!==t-1n;)i++;let a=n,o=modPow(i,r,t),s=modPow(e,r,t),c=modPow(e,(r+1n)/2n,t);for(;;){if(s===0n)return 0n;if(s===1n)return c;let e=1n,n=mod(s*s,t);for(;n!==1n;)n=mod(n*n,t),e++;let r=modPow(o,modPow(2n,a-e-1n,t-1n),t);a=e,o=mod(r*r,t),s=mod(s*o,t),c=mod(c*r,t)}}function toBuffer$1(e,t){if(I.isBuffer(e))return e;if(e instanceof Uint8Array)return I.from(e);if(typeof e==`string`)return I.from(e,t||`utf8`);if(ArrayBuffer.isView(e))return I.from(e.buffer,e.byteOffset,e.byteLength);throw TypeError(`The "key" argument must be of type string or an instance of Buffer, TypedArray, or DataView.`)}function formatReturnValue(e,t){return t?e.toString(t):e}function resolveCurve(e){let t=e.toLowerCase(),n=kn[t];if(!n)throw Error(`Unsupported curve: ${e}`);let r=On[n];if(!r)throw Error(`Unsupported curve: ${e}`);return{canonical:n,params:r}}function createECDH(e){return new ECDH(e)}function getCurves(){return[`secp256k1`,`prime256v1`,`secp256r1`,`secp384r1`,`secp521r1`]}var On,kn,ECDH,An=__esmMin(()=>{bn(),yn(),_e(),On={secp256k1:{p:115792089237316195423570985008687907853269984665640564039457584007908834671663n,a:0n,b:7n,Gx:55066263022277343669578718895168534326250603453777594175500187360389116729240n,Gy:32670510020758816978083085130507043184471273380659243275938904335757337482424n,n:115792089237316195423570985008687907852837564279074904382605163141518161494337n,byteLength:32},prime256v1:{p:115792089210356248762697446949407573530086143415290314195533631308867097853951n,a:115792089210356248762697446949407573530086143415290314195533631308867097853951n-3n,b:41058363725152142129326129780047268409114441015993725554835256314039467401291n,Gx:48439561293906451759052585252797914202762949526041747995844080717082404635286n,Gy:36134250956749795798585127919587881956611106672985015071877198253568414405109n,n:115792089210356248762697446949407573529996955224135760342422259061068512044369n,byteLength:32},secp384r1:{p:39402006196394479212279040100143613805079739270465446667948293404245721771496870329047266088258938001861606973112319n,a:39402006196394479212279040100143613805079739270465446667948293404245721771496870329047266088258938001861606973112319n-3n,b:27580193559959705877849011840389048093056905856361568521428707301988689241309860865136260764883745107765439761230575n,Gx:26247035095799689268623156744566981891852923491109213387815615900925518854738050089022388053975719786650872476732087n,Gy:8325710961489029985546751289520108179287853048861315594709205902480503199884419224438643760392947333078086511627871n,n:39402006196394479212279040100143613805079739270465446667946905279627659399113263569398956308152294913554433653942643n,byteLength:48},secp521r1:{p:6864797660130609714981900799081393217269435300143305409394463459185543183397656052122559640661454554977296311391480858037121987999716643812574028291115057151n,a:6864797660130609714981900799081393217269435300143305409394463459185543183397656052122559640661454554977296311391480858037121987999716643812574028291115057151n-3n,b:1093849038073734274511112390766805569936207598951683748994586394495953116150735016013708737573759623248592132296706313309438452531591012912142327488478985984n,Gx:2661740802050217063228768716723360960729859168756973147706671368418802944996427808491545080627771902352094241225065558662157113545570916814161637315895999846n,Gy:3757180025770020463545507224491183603594455134769762486694567779615544477440556316691234405012945539562144444537289428522585666729196580810124344277578376784n,n:6864797660130609714981900799081393217269435300143305409394463459185543183397655394245057746333217197532963996371363321113864768612440380340372808892707005449n,byteLength:66}},kn={secp256k1:`secp256k1`,prime256v1:`prime256v1`,secp256r1:`prime256v1`,"p-256":`prime256v1`,p256:`prime256v1`,secp384r1:`secp384r1`,"p-384":`secp384r1`,p384:`secp384r1`,secp521r1:`secp521r1`,"p-521":`secp521r1`,p521:`secp521r1`},__name(modInverse$2,`modInverse`),__name(toBuffer$1,`toBuffer`),ECDH=class{_curve;_curveName;_privateKey=null;_publicKey=null;constructor(e){let t=resolveCurve(e);this._curve=t.params,this._curveName=t.canonical}generateKeys(e,t){let{n,byteLength:r}=this._curve,i;do i=bufferToBigint(randomBytes(r));while(i===0n||i>=n);this._privateKey=i;let a={x:this._curve.Gx,y:this._curve.Gy};return this._publicKey=scalarMul(i,a,this._curve),e===void 0?this.getPublicKey():this.getPublicKey(e,t)}computeSecret(e,t,n){if(this._privateKey===null)throw Error(`ECDH key not generated. Call generateKeys() or setPrivateKey() first.`);let r=decodePublicKey(toBuffer$1(e,t),this._curve);if(r===null)throw Error(`Invalid public key: point at infinity`);let i=scalarMul(this._privateKey,r,this._curve);if(i===null)throw Error(`Shared secret computation resulted in the point at infinity`);return formatReturnValue(bigintToBuffer(i.x,this._curve.byteLength),n)}getPublicKey(e,t){if(this._publicKey===null)throw Error(`ECDH key not generated. Call generateKeys() or setPrivateKey() first.`);return formatReturnValue(encodePublicKey(this._publicKey,this._curve.byteLength,t||`uncompressed`),e)}getPrivateKey(e){if(this._privateKey===null)throw Error(`ECDH key not generated. Call generateKeys() or setPrivateKey() first.`);return formatReturnValue(bigintToBuffer(this._privateKey,this._curve.byteLength),e)}setPublicKey(e,t){let n=toBuffer$1(e,t);this._publicKey=decodePublicKey(n,this._curve)}setPrivateKey(e,t){let n=bufferToBigint(toBuffer$1(e,t));if(n===0n||n>=this._curve.n)throw Error(`Private key is out of range [1, n-1]`);this._privateKey=n;let r={x:this._curve.Gx,y:this._curve.Gy};this._publicKey=scalarMul(n,r,this._curve)}}});function normalizeAlgorithm(e){return e.toLowerCase().replace(/-/g,``)}function hashSize(e){let t=normalizeAlgorithm(e),n=jn[t];if(n===void 0)throw Error(`Unknown hash algorithm: ${e}`);return n}function toBuffer(e,t){return typeof e==`string`?I.from(e,t||`utf8`):e instanceof DataView?I.from(e.buffer,e.byteOffset,e.byteLength):(e instanceof ArrayBuffer,I.from(e))}var jn,Mn,Nn,Pn=__esmMin(()=>{_e(),jn={md5:16,sha1:20,sha256:32,sha384:48,sha512:64},Mn={md5:64,sha1:64,sha256:64,sha384:128,sha512:128},Nn=new Set([`md5`,`sha1`,`sha256`,`sha384`,`sha512`])}),Fn=__esmMin(()=>{ce()});function _setPipeImpl(e){In=e}var In,Stream_,Ln=__esmMin(()=>{je(),Stream_=class extends Ae{constructor(e){super(e)}pipe(e,t){return In(this,e,t)}}});function finished(e,t,n){let r;r=typeof t==`function`?t:n;let i=!1;function done(e){i||(i=!0,r(e))}let onFinish=()=>done(),onEnd=()=>done(),onError=e=>done(e),onClose=()=>{let t=e,n=e;!t.writableFinished&&!n.readableEnded&&done(Error(`premature close`))};e.on(`finish`,onFinish),e.on(`end`,onEnd),e.on(`error`,onError),e.on(`close`,onClose);let a=e,o=typeof e.write==`function`,s=typeof e.read==`function`,c=a.writableFinished===!0,l=a.readableEnded===!0;if(a.destroyed===!0){let e=a._err;D(e?()=>done(e):o&&c||s&&l?()=>done():()=>done(Error(`premature close`)))}else(o&&!s&&c||!o&&s&&l||o&&s&&c&&l)&&D(()=>done());return function cleanup(){e.removeListener(`finish`,onFinish),e.removeListener(`end`,onEnd),e.removeListener(`error`,onError),e.removeListener(`close`,onClose)}}function addAbortSignal(e,t){if(!(e instanceof AbortSignal))throw TypeError(`The first argument must be an AbortSignal`);if(!(t instanceof Stream_))throw TypeError(`The second argument must be a Stream`);let n=t;if(e.aborted)n.destroy(Error(`The operation was aborted`));else{let onAbort=()=>{n.destroy(Error(`The operation was aborted`))};e.addEventListener(`abort`,onAbort,{once:!0}),t.once(`close`,()=>{e.removeEventListener(`abort`,onAbort)})}return t}function isReadable(e){if(e==null)return!1;let t=e;return typeof t.readable!=`boolean`||typeof t.read!=`function`||t.destroyed===!0||t.readableEnded===!0?!1:t.readable===!0}function isWritable(e){if(e==null)return!1;let t=e;return typeof t.writable!=`boolean`||typeof t.write!=`function`||t.destroyed===!0||t.writableEnded===!0?!1:t.writable===!0}function isDestroyed(e){return e==null?!1:e.destroyed===!0}function isDisturbed(e){if(e==null)return!1;let t=e;return t.readableDidRead===!0||t.readableFlowing!==null&&t.readableFlowing!==void 0}function isErrored(e){if(e==null)return!1;let t=e;return t.destroyed===!0&&typeof t.readable==`boolean`&&t.readable===!1||t.destroyed===!0&&typeof t.writable==`boolean`&&t.writable===!1}var Rn=__esmMin(()=>{Ln(),ce()});function getDefaultHighWaterMark(e){return e?Bn:zn}function setDefaultHighWaterMark(e,t){if(typeof t!=`number`||t<0||Number.isNaN(t))throw TypeError(`Invalid highWaterMark: ${t}`);e?Bn=t:zn=t}function validateHighWaterMark(e,t){if(t!==void 0&&(typeof t!=`number`||Number.isNaN(t))){let n=TypeError(`The value of "${e}" is invalid. Received ${t}`);throw n.code=`ERR_INVALID_ARG_VALUE`,n}}var zn,Bn,Vn=__esmMin(()=>{zn=16384,Bn=16});function createAbortError(){let e=Error(`The operation was aborted`);return e.name=`AbortError`,e.code=`ABORT_ERR`,e}async function streamAsyncDispose(e,t){let n;e.destroyed||(n=t?void 0:createAbortError(),e.destroy(n)),await new Promise((t,r)=>{finished(e,e=>{e&&e!==n?r(e):t()})})}var Hn,Un=__esmMin(()=>{Rn(),Hn=Symbol.asyncDispose??Symbol.for(`Symbol.asyncDispose`)});function chunkLength(e){if(e==null)return 1;let t=e.length;return typeof t==`number`?t:1}function sliceChunk(e,t,n){if(typeof e==`string`)return n===void 0?e.slice(t):e.slice(t,n);let r=e.slice;return typeof r==`function`?r.call(e,t,n):e}var Wn,Gn=__esmMin(()=>{Ln(),Un(),Vn(),ce(),Wn=class Readable_ extends Stream_{readable=!0;readableFlowing=null;readableLength=0;readableHighWaterMark;readableEncoding;readableObjectMode;readableEnded=!1;readableAborted=!1;destroyed=!1;_pipeDests=[];_buffer=[];_readableState={ended:!1,endEmitted:!1,reading:!1,constructed:!0,highWaterMark:0,objectMode:!1,pipes:[]};_err;_readablePending=!1;_readImpl;_destroyImpl;_constructImpl;constructor(e){super(e),this.readableHighWaterMark=e?.highWaterMark??getDefaultHighWaterMark(e?.objectMode??!1),this.readableEncoding=e?.encoding??null,this.readableObjectMode=e?.objectMode??!1,this._readableState.highWaterMark=this.readableHighWaterMark,this._readableState.objectMode=this.readableObjectMode,e?.read&&(this._readImpl=e.read),e?.destroy&&(this._destroyImpl=e.destroy),e?.construct&&(this._constructImpl=e.construct),(this._constructImpl||this._construct!==Readable_.prototype._construct)&&(this._readableState.constructed=!1,nextTick(()=>{this._construct(e=>{this._readableState.constructed=!0,e?this.destroy(e):this.readableFlowing===!0&&this._flow()})}))}_construct(e){this._constructImpl?this._constructImpl.call(this,e):e()}_read(e){this._readImpl&&this._readImpl.call(this,e)}read(e){if(!this._readableState.constructed)return null;if(this._buffer.length===0){if(this._readableState.ended)return null;this._readableState.reading=!0,this._read(e??this.readableHighWaterMark),this._readableState.reading=!1}if(this._buffer.length===0||e===0)return null;if(this.readableObjectMode){if(e===void 0){let e=this._buffer.shift();return--this.readableLength,this._readableState.ended&&this._buffer.length===0&&!this._readableState.endEmitted&&this._emitEnd(),e}if(e>this.readableLength)return null;let t=this._buffer.shift();return--this.readableLength,t}if(e!=null)return e>this.readableLength?null:this._readBytes(e);let t=this._buffer.splice(0);if(this.readableLength=0,this._readableState.ended&&this._buffer.length===0&&!this._readableState.endEmitted&&this._emitEnd(),t.length===1)return t[0];if(t.length===0)return null;if(typeof t[0]==`string`)return t.join(``);let n=globalThis.Buffer;return n?.concat?n.concat(t):t}_readBytes(e){let t=0,n=[];for(;t<e&&this._buffer.length>0;){let r=this._buffer[0],i=chunkLength(r);if(t+i<=e)n.push(this._buffer.shift()),t+=i,this.readableLength-=i;else{let i=e-t;n.push(sliceChunk(r,0,i)),this._buffer[0]=sliceChunk(r,i),this.readableLength-=i,t+=i}}if(n.length===1)return n[0];let r=globalThis.Buffer;return r?.concat?r.concat(n):n}push(e,t){if(e===null)return this._readableState.ended=!0,this.readableEnded=!0,this._buffer.length===0&&!this._readableState.endEmitted&&nextTick(()=>this._emitEnd()),this._scheduleReadable(),!1;if(!this.readableObjectMode&&!(typeof e==`string`||ArrayBuffer.isView(e))){let t=Object.assign(TypeError(`Invalid non-string/buffer chunk type: ${typeof e}`),{code:`ERR_INVALID_ARG_TYPE`});return nextTick(()=>this.emit(`error`,t)),!1}return this._buffer.push(e),this.readableLength+=this.readableObjectMode?1:chunkLength(e),this.readableFlowing&&!this._flowing&&nextTick(()=>this._flow()),this.readableFlowing!==!0&&this._scheduleReadable(),this.readableLength<this.readableHighWaterMark}_emitEnd(){this._readableState.endEmitted||(this._readableState.endEmitted=!0,this.emit(`end`),nextTick(()=>this._autoClose()))}_autoClose(){this.emit(`close`)}_scheduleReadable(){this._readablePending||this.listenerCount(`readable`)===0||(this._readablePending=!0,nextTick(()=>{this._readablePending=!1,this.destroyed||this.emit(`readable`)}))}on(e,t){return super.on(e,t),e===`data`&&this.readableFlowing!==!1&&this.resume(),e===`readable`&&(this._buffer.length>0||this._readableState.ended)&&this._scheduleReadable(),this}unshift(e){this._buffer.unshift(e),this.readableLength+=this.readableObjectMode?1:chunkLength(e)}setEncoding(e){return this.readableEncoding=e,this}pause(){return this.readableFlowing=!1,this.emit(`pause`),this}resume(){return this.readableFlowing!==!0&&(this.readableFlowing=!0,this.emit(`resume`),this._readableState.constructed&&this._flow()),this}_flowing=!1;_flow(){if(!(this.readableFlowing!==!0||this._flowing||this.destroyed)&&this._readableState.constructed){this._flowing=!0;try{for(;this._buffer.length>0&&this.readableFlowing&&!this.destroyed;){let e=this._buffer.shift();if(this.readableLength-=this.readableObjectMode?1:chunkLength(e),this.readableEncoding&&typeof e!=`string`){let t=globalThis.Buffer;t?.isBuffer&&t.isBuffer(e)?e=e.toString(this.readableEncoding):e instanceof Uint8Array&&(e=new TextDecoder(this.readableEncoding).decode(e))}this.emit(`data`,e)}if(this.destroyed)return;if(this._readableState.ended&&this._buffer.length===0&&!this._readableState.endEmitted){nextTick(()=>this._emitEnd());return}!this._readableState.ended&&!this._readableState.reading&&!this.destroyed&&(this._readableState.reading=!0,this._read(this.readableHighWaterMark),this._readableState.reading=!1)}finally{this._flowing=!1}this._buffer.length>0&&this.readableFlowing&&!this.destroyed&&nextTick(()=>this._flow())}}isPaused(){return this.readableFlowing===!1}unpipe(e){if(e){let t=this._pipeDests.findIndex(t=>t.dest===e);if(t!==-1){this._pipeDests[t].cleanup(),this._pipeDests.splice(t,1);let n=this._readableState.pipes.indexOf(e);n!==-1&&this._readableState.pipes.splice(n,1),e.emit(`unpipe`,this),this._pipeDests.length===0&&(this.readableFlowing=!1)}}else{for(let e of this._pipeDests)e.cleanup(),e.dest.emit(`unpipe`,this);this._pipeDests=[],this._readableState.pipes=[],this.readableFlowing=!1}return this}_destroy(e,t){this._destroyImpl?this._destroyImpl.call(this,e,t):t(e??void 0)}destroy(e){if(this.destroyed)return this;this.destroyed=!0,this.readable=!1,this.readableAborted=!this.readableEnded,e&&(this._err=e);let cb=e=>{e&&nextTick(()=>this.emit(`error`,e)),nextTick(()=>this.emit(`close`))};return Object.prototype.hasOwnProperty.call(this,`_destroy`)?this._destroy(e??null,cb):this._destroyImpl?this._destroyImpl.call(this,e??null,cb):cb(e),this}static toWeb(e){return new ReadableStream({start(t){e.on(`data`,e=>{typeof e==`string`?t.enqueue(new TextEncoder().encode(e)):e instanceof Uint8Array?t.enqueue(e):e&&typeof e.length==`number`&&t.enqueue(new Uint8Array(e))}),e.on(`end`,()=>{t.close()}),e.on(`error`,e=>{t.error(e)})},cancel(){e.destroy()}})}static fromWeb(e,t){let n=e.getReader();return new Readable_({...t,read(){n.read().then(({done:e,value:t})=>{e?this.push(null):this.push(t)},e=>{this.destroy(e)})},destroy(e,t){n.cancel(e?.message).then(()=>t(null),t)}})}[Symbol.asyncIterator](){let e=this,t=[],n=!1,r=null,i=null,a=null;return e.on(`data`,e=>{if(i){let t=i;i=null,a=null,t({value:e,done:!1})}else t.push(e)}),e.on(`end`,()=>{if(n=!0,i){let e=i;i=null,a=null,e({value:void 0,done:!0})}}),e.on(`error`,e=>{if(r=e,n=!0,a){let t=a;i=null,a=null,t(e)}}),{next(){return r?Promise.reject(r):t.length>0?Promise.resolve({value:t.shift(),done:!1}):n?Promise.resolve({value:void 0,done:!0}):new Promise((e,t)=>{i=e,a=t})},return(){return e.destroy(),Promise.resolve({value:void 0,done:!0})},[Symbol.asyncIterator](){return this}}}static from(e,t){let n=new Readable_({objectMode:!0,...t,read(){}});return typeof e==`string`||ArrayBuffer.isView(e)?(n.push(e),n.push(null),n):((async()=>{try{for await(let t of e)n.push(t)||await new Promise(e=>n.once(`drain`,e));n.push(null)}catch(e){n.destroy(e)}})(),n)}},Wn.prototype[Hn]=function(){return streamAsyncDispose(this,this.readableEnded)}});function chunkLen$1(e){if(e==null)return 1;let t=e.length;return typeof t==`number`?t:1}var Duplex_,Kn=__esmMin(()=>{Vn(),Gn(),ce(),Duplex_=class extends Wn{writable=!0;writableHighWaterMark;writableLength=0;writableObjectMode;writableEnded=!1;writableFinished=!1;writableCorked=0;writableNeedDrain=!1;allowHalfOpen;_decodeStrings;_writableState={highWaterMark:0,objectMode:!1};_duplexCorkedBuffer=[];_duplexWriting=!1;_duplexWriteQueue=[];_writeImpl;_finalImpl;_defaultEncoding=`utf8`;_pendingWrites=0;_pendingEndCb=null;constructor(e){super(e),validateHighWaterMark(`writableHighWaterMark`,e?.writableHighWaterMark),validateHighWaterMark(`readableHighWaterMark`,e?.readableHighWaterMark),this.writableObjectMode=e?.writableObjectMode??e?.objectMode??!1,this.writableHighWaterMark=e?.highWaterMark??e?.writableHighWaterMark??getDefaultHighWaterMark(this.writableObjectMode),this._writableState.highWaterMark=this.writableHighWaterMark,this._writableState.objectMode=this.writableObjectMode,e?.highWaterMark===void 0&&e?.readableHighWaterMark!==void 0&&(this.readableHighWaterMark=e.readableHighWaterMark,this._readableState.highWaterMark=e.readableHighWaterMark),e?.readableObjectMode!==void 0&&(this.readableObjectMode=e.readableObjectMode,this._readableState.objectMode=e.readableObjectMode,e?.readableHighWaterMark===void 0&&e?.highWaterMark===void 0&&(this.readableHighWaterMark=getDefaultHighWaterMark(e.readableObjectMode),this._readableState.highWaterMark=this.readableHighWaterMark)),this.allowHalfOpen=e?.allowHalfOpen!==!1,this._decodeStrings=e?.decodeStrings!==!1,e?.write&&(this._writeImpl=e.write),e?.final&&(this._finalImpl=e.final),this.allowHalfOpen||this.once(`end`,()=>{this.writableEnded||nextTick(()=>this.end())})}_write(e,t,n){this._writeImpl?this._writeImpl.call(this,e,t,n):n()}_final(e){this._finalImpl?this._finalImpl.call(this,e):e()}destroy(e){return this.destroyed?this:(this.writable=!1,super.destroy(e))}write(e,t,n){let r,i;if(typeof t==`function`?(r=t,i=this._defaultEncoding):(i=t??this._defaultEncoding,r=n??(()=>{})),this._decodeStrings&&!this.writableObjectMode&&typeof e==`string`){let t=globalThis.Buffer;t&&(e=t.from(e,i),i=`buffer`)}if(typeof e!=`string`&&!this.writableObjectMode){let t=globalThis.Buffer;(t&&t.isBuffer(e)||e instanceof Uint8Array)&&(i=`buffer`)}if(this.writableEnded){let e=Error(`write after end`);return nextTick(()=>{r(e),this.emit(`error`,e)}),!1}if(this.writableLength+=this.writableObjectMode?1:chunkLen$1(e),this.writableCorked>0)return this._duplexCorkedBuffer.push({chunk:e,encoding:i,callback:r}),this.writableLength<this.writableHighWaterMark;let a=this.writableLength<this.writableHighWaterMark;return a||(this.writableNeedDrain=!0),this._duplexDoWrite(e,i,r),a}_duplexDoWrite(e,t,n){if(this._duplexWriting){this._duplexWriteQueue.push({chunk:e,encoding:t,callback:n});return}this._duplexWriting=!0,this._duplexStartWrite(e,t,n)}_duplexStartWrite(e,t,n){this._pendingWrites++,this._write(e,t,t=>{this._pendingWrites--,this.writableLength-=this.writableObjectMode?1:chunkLen$1(e),nextTick(t?()=>{if(n(t),this._duplexWriting=!1,this.emit(`error`,t),this._duplexWriteQueue.length>0){let e=this._duplexWriteQueue.shift();this._duplexWriting=!0,this._duplexStartWrite(e.chunk,e.encoding,e.callback)}}:()=>{if(n(),this._duplexWriteQueue.length>0){let e=this._duplexWriteQueue.shift();this._duplexStartWrite(e.chunk,e.encoding,e.callback);return}if(this._duplexWriting=!1,this.writableNeedDrain&&this.writableLength<=this.writableHighWaterMark&&(this.writableNeedDrain=!1,this.emit(`drain`)),this._pendingWrites===0&&this._pendingEndCb){let e=this._pendingEndCb;this._pendingEndCb=null,e()}})})}end(e,t,n){typeof e==`function`&&(n=e,e=void 0),typeof t==`function`&&(n=t,t=void 0),e!=null&&this.write(e,t),this.writableEnded=!0;let doFinal=()=>{this._final(e=>{this.writableFinished=!0,this._doPrefinishHooks(()=>{nextTick(()=>{e&&this.emit(`error`,e),this.emit(`finish`),nextTick(()=>this.emit(`close`)),n&&n()})})})};return this._pendingWrites>0||this._duplexWriting||this._duplexWriteQueue.length>0?this._pendingEndCb=doFinal:doFinal(),this}_doPrefinishHooks(e){e()}cork(){this.writableCorked++}uncork(){if(this.writableCorked>0&&(this.writableCorked--,this.writableCorked===0&&this._duplexCorkedBuffer.length>0)){let e=this._duplexCorkedBuffer.splice(0);for(let{chunk:t,encoding:n,callback:r}of e)this._write(t,n,e=>{this.writableLength-=this.writableObjectMode?1:chunkLen$1(t),e?(r(e),this.emit(`error`,e)):r()});this.writableNeedDrain&&this.writableLength<=this.writableHighWaterMark&&(this.writableNeedDrain=!1,nextTick(()=>this.emit(`drain`)))}}setDefaultEncoding(e){return this._defaultEncoding=e,this}},__name(chunkLen$1,`chunkLen`)});function pipe(e,t,n){let r=e,i=n?.end!==!1,a=!1,ondrain=()=>{a=!1,t.removeListener(`drain`,ondrain);let e=r;typeof e.resume==`function`&&e.resume()},ondata=e=>{if(t.writable){let n=r;t.write(e)===!1&&typeof n.pause==`function`&&(n.pause(),a||(a=!0,t.on(`drain`,ondrain)))}};r.on(`data`,ondata);let o=!1,onend=()=>{o||(o=!0,i&&t.end())},onclose=()=>{if(!o&&(o=!0,i&&!(r instanceof Wn))){let e=t;typeof e.destroy==`function`&&e.destroy()}};i&&(r.on(`end`,onend),r.on(`close`,onclose));let cleanup=()=>{r.removeListener(`data`,ondata),a&&t.removeListener(`drain`,ondrain),r.removeListener(`end`,onend),r.removeListener(`close`,onclose),r.removeListener(`end`,cleanup),r.removeListener(`close`,cleanup),t.removeListener(`close`,cleanup)};return r.on(`end`,cleanup),r.on(`close`,cleanup),t.on(`close`,cleanup),r instanceof Wn&&(r._pipeDests.push({dest:t,cleanup}),r._readableState.pipes.push(t)),t.emit(`pipe`,r),t}var qn=__esmMin(()=>{Ln(),Gn(),_setPipeImpl(pipe)});function chunkLen(e){if(e==null)return 1;let t=e.length;return typeof t==`number`?t:1}var Jn,Yn=__esmMin(()=>{Ln(),Un(),Vn(),ce(),Jn=class Writable_ extends Stream_{static[Symbol.hasInstance](e){let t=this;return t.prototype!==void 0&&Object.prototype.isPrototypeOf.call(t.prototype,e)?!0:t.prototype!==Writable_.prototype||e==null?!1:typeof e.writableHighWaterMark==`number`}writable=!0;writableHighWaterMark;writableLength=0;writableObjectMode;writableEnded=!1;writableFinished=!1;writableCorked=0;writableNeedDrain=!1;destroyed=!1;_err;_writableState={ended:!1,finished:!1,constructed:!0,writing:!1};_corkedBuffer=[];_writeBuffer=[];_pendingConstruct=[];_ending=!1;_endCallback;_pendingEnd=null;_writeImpl;_writev;_finalImpl;_destroyImpl;_constructImpl;_decodeStrings;_defaultEncoding=`utf8`;_autoDestroy;constructor(e){super(e),this.writableHighWaterMark=e?.highWaterMark??getDefaultHighWaterMark(e?.objectMode??!1),this.writableObjectMode=e?.objectMode??!1,this._decodeStrings=e?.decodeStrings!==!1,this._autoDestroy=e?.autoDestroy!==!1,e?.write&&(this._writeImpl=e.write),e?.writev&&(this._writev=e.writev),e?.final&&(this._finalImpl=e.final),e?.destroy&&(this._destroyImpl=e.destroy),e?.construct&&(this._constructImpl=e.construct),(this._constructImpl||this._construct!==Writable_.prototype._construct)&&(this._writableState.constructed=!1,nextTick(()=>{this._construct(e=>{this._writableState.constructed=!0,e?this.destroy(e):this._maybeFlush()})}))}_construct(e){this._constructImpl?this._constructImpl.call(this,e):e()}_write(e,t,n){this._writeImpl?this._writeImpl.call(this,e,t,n):n()}_final(e){this._finalImpl?this._finalImpl.call(this,e):e()}_destroy(e,t){this._destroyImpl?this._destroyImpl.call(this,e,t):t(e)}_maybeFlush(){let e=this._pendingConstruct.splice(0);if(e.length>0){let[t,...n]=e;this._writeBuffer.push(...n),this._doWrite(t.chunk,t.encoding,t.callback)}if(this._pendingEnd){let{chunk:e,encoding:t,callback:n}=this._pendingEnd;this._pendingEnd=null,this._doEnd(e,t,n)}}_doWrite(e,t,n){this._writableState.writing=!0;let r=!0;this._write(e,t,t=>{if(this.writableLength-=this.writableObjectMode?1:chunkLen(e),r){nextTick(()=>{if(t){n(t),this.emit(`error`,t);return}n(),this.writableNeedDrain&&this.writableLength<=this.writableHighWaterMark&&(this.writableNeedDrain=!1,this.emit(`drain`))}),t||this._drainWriteBuffer();return}nextTick(t?()=>{n(t),this.emit(`error`,t),this._drainWriteBuffer()}:()=>{n(),this.writableNeedDrain&&this.writableLength<=this.writableHighWaterMark&&(this.writableNeedDrain=!1,this.emit(`drain`)),this._drainWriteBuffer()})}),r=!1}_drainWriteBuffer(){if(this._writeBuffer.length>0){let e=this._writeBuffer.shift();this._doWrite(e.chunk,e.encoding,e.callback)}else this._writableState.writing=!1,this._maybeFinish()}_maybeFinish(){!this._ending||this._writableState.finished||this._writableState.writing||this._writeBuffer.length>0||(this._ending=!1,this._final(e=>{this.writableFinished=!0,this._writableState.finished=!0,nextTick(()=>{e&&this.emit(`error`,e),this.emit(`finish`),this._autoDestroy?this.destroy():nextTick(()=>this.emit(`close`)),this._endCallback&&this._endCallback()})}))}write(e,t,n){let r,i;if(typeof t==`function`?(r=t,i=this._defaultEncoding):(i=t??this._defaultEncoding,r=n??(()=>{})),this._decodeStrings&&!this.writableObjectMode&&typeof e==`string`){let t=globalThis.Buffer;t&&(e=t.from(e,i),i=`buffer`)}if(typeof e!=`string`&&!this.writableObjectMode){let t=globalThis.Buffer;(t&&t.isBuffer(e)||e instanceof Uint8Array)&&(i=`buffer`)}if(this.writableEnded){let e=Error(`write after end`);return nextTick(()=>{r(e),this.emit(`error`,e)}),!1}if(this.writableLength+=this.writableObjectMode?1:chunkLen(e),this.writableCorked>0)return this._corkedBuffer.push({chunk:e,encoding:i,callback:r}),this.writableLength<this.writableHighWaterMark;if(!this._writableState.constructed)return this._pendingConstruct.push({chunk:e,encoding:i,callback:r}),this.writableLength<this.writableHighWaterMark;let a=this.writableLength<this.writableHighWaterMark;return a||(this.writableNeedDrain=!0),this._writableState.writing?this._writeBuffer.push({chunk:e,encoding:i,callback:r}):this._doWrite(e,i,r),a}_doEnd(e,t,n){e!=null&&this.write(e,t),this.writableEnded=!0,this._writableState.ended=!0,this._ending=!0,this._endCallback=n,this._maybeFinish()}end(e,t,n){return typeof e==`function`&&(n=e,e=void 0),typeof t==`function`&&(n=t,t=void 0),this.writableEnded?(n&&nextTick(n),this):this._writableState.constructed?(this._doEnd(e,t,n),this):(this._pendingEnd={chunk:e,encoding:t,callback:n},this)}cork(){this.writableCorked++}uncork(){this.writableCorked>0&&(this.writableCorked--,this.writableCorked===0&&this._corkedBuffer.length>0&&this._flushCorkedBuffer())}_flushCorkedBuffer(){if(this._writev&&this._corkedBuffer.length>1){let e=this._corkedBuffer.splice(0),t=e.map(e=>({chunk:e.chunk,encoding:e.encoding}));this._writev.call(this,t,t=>{for(let t of e)this.writableLength-=this.writableObjectMode?1:chunkLen(t.chunk);if(t){for(let n of e)n.callback(t);this.emit(`error`,t)}else{for(let t of e)t.callback();this.writableNeedDrain&&this.writableLength<=this.writableHighWaterMark&&(this.writableNeedDrain=!1,this.emit(`drain`))}})}else{let e=this._corkedBuffer.splice(0);if(e.length>0){let[t,...n]=e;this._writeBuffer.push(...n),this._doWrite(t.chunk,t.encoding,t.callback)}}}setDefaultEncoding(e){return this._defaultEncoding=e,this}destroy(e){if(this.destroyed)return this;this.destroyed=!0,this.writable=!1,e&&(this._err=e);let cb=e=>{e&&nextTick(()=>this.emit(`error`,e)),nextTick(()=>this.emit(`close`))};return this._destroy(e??null,cb),this}},Jn.prototype[Hn]=function(){return streamAsyncDispose(this,this.writableFinished)}}),Xn,Zn=__esmMin(()=>{Kn(),ce(),Xn=class Transform_ extends Duplex_{constructor(e){super({...e,write:void 0,final:void 0});let t=this;e?.transform&&(t._transform=e.transform),e?.flush&&(t._flush=e.flush),e?.final&&(t._final=e.final)}_transform(e,t,n){throw Object.assign(Error(`The _transform() method is not implemented`),{code:`ERR_METHOD_NOT_IMPLEMENTED`})}_flush(e){e()}_write(e,t,n){let r=!1;try{this._transform(e,t,(e,t)=>{if(r){let e=Object.assign(Error(`Callback called multiple times`),{code:`ERR_MULTIPLE_CALLBACK`});nextTick(()=>this.emit(`error`,e));return}if(r=!0,e){n(e);return}t!=null&&this.push(t),n()})}catch(e){if(e?.code===`ERR_METHOD_NOT_IMPLEMENTED`)throw e;n(e)}}_final(e){this._flush((t,n)=>{if(t){e(t);return}n!=null&&this.push(n),this.push(null),e()})}_doPrefinishHooks(e){let t=Transform_.prototype._final;this._final===t?e():t.call(this,e)}}}),PassThrough_,Qn=__esmMin(()=>{Zn(),PassThrough_=class extends Xn{constructor(e){super({...e,transform(e,t,n){n(null,e)}})}}});function pipeline(...e){let t=e,n=typeof t[t.length-1]==`function`?t.pop():void 0,r=t;if(r.length<2)throw Error(`pipeline requires at least 2 streams`);let i=null;function onError(e){if(!i){i=e;for(let e of r)typeof e.destroy==`function`&&e.destroy();n&&n(e)}}let a=r[0];for(let e=1;e<r.length;e++){let t=r[e];a.pipe(t),a.on(`error`,onError),a=t}let o=r[r.length-1];return o.on(`error`,onError),o.on(`finish`,()=>{n&&!i&&n(null)}),o}var $n=__esmMin(()=>{}),er,tr,nr,rr,ir,ar,sr=__esmMin(()=>{Fn(),Ln(),Rn(),Vn(),Gn(),Kn(),qn(),Yn(),Zn(),Qn(),$n(),er=makeCallable(Stream_),tr=makeCallable(Wn),nr=makeCallable(Jn),rr=makeCallable(Duplex_),ir=makeCallable(Xn),ar=makeCallable(PassThrough_),Object.assign(er,{Stream:er,Readable:tr,Writable:nr,Duplex:rr,Transform:ir,PassThrough:ar,pipeline,finished,addAbortSignal,isReadable,isWritable,isDestroyed,isDisturbed,isErrored,getDefaultHighWaterMark,setDefaultHighWaterMark})});function getChecksumType(e){let t=normalizeAlgorithm(e),n=cr[t];if(n===void 0){let t=Error(`Unknown message digest: ${e}`);throw t.code=`ERR_CRYPTO_HASH_UNKNOWN`,t}return n}function getHashes(){return[`md5`,`sha1`,`sha256`,`sha384`,`sha512`]}function hash(e,t,n){return new lr(e).update(t).digest(n)}var cr,lr,ur=__esmMin(()=>{Pn(),_e(),be(),sr(),cr={md5:L.ChecksumType.MD5,sha1:L.ChecksumType.SHA1,sha256:L.ChecksumType.SHA256,sha384:L.ChecksumType.SHA384,sha512:L.ChecksumType.SHA512},lr=class Hash extends ir{_algorithm;_checksum;_finalized=!1;constructor(e){super();let t=normalizeAlgorithm(e),n=getChecksumType(t);this._algorithm=t,this._checksum=new L.Checksum(n)}update(e,t){if(this._finalized)throw Error(`Digest already called`);let n;if(typeof e==`string`){let r=normalizeEncoding(t);n=I.from(e,r)}else n=e instanceof Uint8Array?e:I.from(e);return this._checksum.update(n),this}digest(e){if(this._finalized)throw Error(`Digest already called`);this._finalized=!0;let t=this._checksum.get_string(),n=I.from(t,`hex`);return e?n.toString(e):n}copy(){if(this._finalized)throw Error(`Digest already called`);let e=Object.create(Hash.prototype);return ir.call(e),e._algorithm=this._algorithm,e._finalized=!1,e._checksum=this._checksum.copy(),e}_transform(e,t,n){try{this.update(e,t),n()}catch(e){n(e)}}_flush(e){try{this.push(this.digest()),e()}catch(t){e(t)}}}}),Hmac,dr=__esmMin(()=>{Pn(),ur(),_e(),sr(),Hmac=class extends ir{_algorithm;_innerHash;_outerKeyPad;_finalized=!1;constructor(e,t){super();let n=normalizeAlgorithm(e);if(!Nn.has(n)){let t=Error(`Unknown message digest: ${e}`);throw t.code=`ERR_CRYPTO_HASH_UNKNOWN`,t}this._algorithm=n;let r;r=typeof t==`string`?I.from(t,`utf8`):t instanceof Uint8Array?t:I.from(t);let i=Mn[n];if(r.length>i){let e=new lr(n);e.update(r),r=e.digest()}let a=new Uint8Array(i);a.set(r);let o=new Uint8Array(i),s=new Uint8Array(i);for(let e=0;e<i;e++)o[e]=a[e]^54,s[e]=a[e]^92;this._outerKeyPad=s,this._innerHash=new lr(n),this._innerHash.update(o)}update(e,t){if(this._finalized)throw Error(`Digest already called`);let n;if(typeof e==`string`){let r=normalizeEncoding(t);n=I.from(e,r)}else n=e instanceof Uint8Array?e:I.from(e);return this._innerHash.update(n),this}digest(e){if(this._finalized)throw Error(`Digest already called`);this._finalized=!0;let t=this._innerHash.digest(),n=new lr(this._algorithm);n.update(this._outerKeyPad),n.update(t);let r=n.digest();return e?r.toString(e):r}_transform(e,t,n){try{this.update(e,t),n()}catch(e){n(e)}}_flush(e){try{this.push(this.digest()),e()}catch(t){e(t)}}}});function getCurve(e){let t=kn[e.toLowerCase()];if(!t)throw Error(`Unsupported curve: ${e}`);return On[t]}function truncateHash(e,t){let n=t.n.toString(2).length,r=bytesToBigInt(e),i=e.length*8;return i>n&&(r>>=BigInt(i-n)),r}function hmacDigest$2(e,t,n){let r=new Hmac(e,t);return r.update(n),new Uint8Array(r.digest())}function rfc6979(e,t,n,r){let i=r.byteLength,a=n.length,o=new Uint8Array(a).fill(1),s=new Uint8Array(a).fill(0),c=bigIntToBytes(t,i),l=bigIntToBytes(mod(truncateHash(n,r),r.n),i),u=new Uint8Array(a+1+i+i);u.set(o,0),u[a]=0,u.set(c,a+1),u.set(l,a+1+i),s=hmacDigest$2(e,s,u),o=hmacDigest$2(e,s,o);let d=new Uint8Array(a+1+i+i);d.set(o,0),d[a]=1,d.set(c,a+1),d.set(l,a+1+i),s=hmacDigest$2(e,s,d),o=hmacDigest$2(e,s,o);for(let t=0;t<100;t++){let t=new Uint8Array;for(;t.length<i;){o=hmacDigest$2(e,s,o);let n=new Uint8Array(t.length+o.length);n.set(t,0),n.set(o,t.length),t=n}let n=truncateHash(t.slice(0,i),r);if(n>=1n&&n<r.n)return n;let c=new Uint8Array(a+1);c.set(o,0),c[a]=0,s=hmacDigest$2(e,s,c),o=hmacDigest$2(e,s,o)}throw Error(`RFC 6979: failed to generate valid k after 100 attempts`)}function ecdsaSign(e,t,n,r){let i=getCurve(r),a={x:i.Gx,y:i.Gy},o=bytesToBigInt(t),s=new lr(e);s.update(n);let c=new Uint8Array(s.digest()),l=truncateHash(c,i),u=rfc6979(e,o,c,i),d=scalarMul(u,a,i);if(d===null)throw Error(`ECDSA: k * G is point at infinity`);let f=mod(d.x,i.n);if(f===0n)throw Error(`ECDSA: r is zero`);let p=mod(modInverse$2(u,i.n)*(l+f*o),i.n);if(p===0n)throw Error(`ECDSA: s is zero`);let m=i.byteLength,h=new Uint8Array(m*2);return h.set(bigIntToBytes(f,m),0),h.set(bigIntToBytes(p,m),m),h}function ecdsaVerify(e,t,n,r,i){let a=getCurve(i),o={x:a.Gx,y:a.Gy},s=a.byteLength;if(t[0]!==4||t.length!==1+s*2)return!1;let c={x:bytesToBigInt(t.slice(1,1+s)),y:bytesToBigInt(t.slice(1+s))};if(n.length!==s*2)return!1;let l=bytesToBigInt(n.slice(0,s)),u=bytesToBigInt(n.slice(s));if(l<1n||l>=a.n||u<1n||u>=a.n)return!1;let d=new lr(e);d.update(r);let f=truncateHash(new Uint8Array(d.digest()),a),p=modInverse$2(u,a.n),m=mod(f*p,a.n),h=mod(l*p,a.n),g=pointAdd(scalarMul(m,o,a),scalarMul(h,c,a),a);return g===null?!1:mod(g.x,a.n)===l}var fr=__esmMin(()=>{bn(),An(),ur(),dr(),__name(hmacDigest$2,`hmacDigest`)});function hmacDigest$1(e,t,n){let r=new Hmac(e,t);return r.update(n),r.digest()}function hkdfExtract(e,t,n){return hmacDigest$1(e,n,t)}function hkdfExpand(e,t,n,r,i){let a=Math.ceil(r/i);if(a>255)throw Error(`HKDF cannot generate more than 255 * HashLen bytes`);let o=I.allocUnsafe(a*i),s=I.alloc(0);for(let r=1;r<=a;r++)s=hmacDigest$1(e,t,I.concat([s,n,I.from([r])])),s.copy(o,(r-1)*i);return I.from(o.buffer,o.byteOffset,r)}function hkdfSync(e,t,n,r,i){let a=normalizeAlgorithm(e),o=jn[a];if(!Nn.has(a)||o===void 0)throw TypeError(`Unknown message digest: ${e}`);if(typeof i!=`number`||i<0)throw TypeError(`keylen must be a non-negative number`);let s=toBuffer(t),c=toBuffer(n),l=toBuffer(r),u=hkdfExpand(a,hkdfExtract(a,s,c.length===0?I.alloc(o,0):c),l,i,o),d=new ArrayBuffer(u.length);return new Uint8Array(d).set(u),d}function hkdf(e,t,n,r,i,a){setTimeout(()=>{try{a(null,hkdfSync(e,t,n,r,i))}catch(e){a(e instanceof Error?e:Error(String(e)))}},0)}var pr=__esmMin(()=>{Pn(),dr(),_e(),__name(hmacDigest$1,`hmacDigest`)});function hmacDigest(e,t,n){let r=new Hmac(e,t);return r.update(n),r.digest()}function validateParameters(e,t){if(typeof e!=`number`||e<0||!Number.isFinite(e)||e===0)throw TypeError(`iterations must be a positive number`);if(typeof t!=`number`||t<0||!Number.isFinite(t)||t>2147483647)throw TypeError(`keylen must be a positive number`)}function pbkdf2Sync(e,t,n,r,i){validateParameters(n,r);let a=toBuffer(e),o=toBuffer(t),s=normalizeAlgorithm(i||`sha1`),c=jn[s];if(!Nn.has(s)||c===void 0)throw TypeError(`Unknown message digest: ${i||`sha1`}`);if(r===0)return I.alloc(0);let l=Math.ceil(r/c),u=I.allocUnsafe(l*c);for(let e=1;e<=l;e++){let t=I.allocUnsafe(o.length+4);o.copy(t,0),t.writeUInt32BE(e,o.length);let r=hmacDigest(s,a,t),i=I.from(r);for(let e=1;e<n;e++){r=hmacDigest(s,a,r);for(let e=0;e<c;e++)i[e]^=r[e]}i.copy(u,(e-1)*c)}return I.from(u.buffer,u.byteOffset,r)}function pbkdf2(e,t,n,r,i,a){validateParameters(n,r),setTimeout(()=>{try{a(null,pbkdf2Sync(e,t,n,r,i))}catch(e){a(e instanceof Error?e:Error(String(e)))}},0)}var mr=__esmMin(()=>{Pn(),dr(),_e()});function R(e,t){return(e<<t|e>>>32-t)>>>0}function salsa20_8(e){let t=new Uint32Array(16);for(let n=0;n<16;n++)t[n]=e[n];for(let e=0;e<4;e++)t[4]^=R(t[0]+t[12],7),t[8]^=R(t[4]+t[0],9),t[12]^=R(t[8]+t[4],13),t[0]^=R(t[12]+t[8],18),t[9]^=R(t[5]+t[1],7),t[13]^=R(t[9]+t[5],9),t[1]^=R(t[13]+t[9],13),t[5]^=R(t[1]+t[13],18),t[14]^=R(t[10]+t[6],7),t[2]^=R(t[14]+t[10],9),t[6]^=R(t[2]+t[14],13),t[10]^=R(t[6]+t[2],18),t[3]^=R(t[15]+t[11],7),t[7]^=R(t[3]+t[15],9),t[11]^=R(t[7]+t[3],13),t[15]^=R(t[11]+t[7],18),t[1]^=R(t[0]+t[3],7),t[2]^=R(t[1]+t[0],9),t[3]^=R(t[2]+t[1],13),t[0]^=R(t[3]+t[2],18),t[6]^=R(t[5]+t[4],7),t[7]^=R(t[6]+t[5],9),t[4]^=R(t[7]+t[6],13),t[5]^=R(t[4]+t[7],18),t[11]^=R(t[10]+t[9],7),t[8]^=R(t[11]+t[10],9),t[9]^=R(t[8]+t[11],13),t[10]^=R(t[9]+t[8],18),t[12]^=R(t[15]+t[14],7),t[13]^=R(t[12]+t[15],9),t[14]^=R(t[13]+t[12],13),t[15]^=R(t[14]+t[13],18);for(let n=0;n<16;n++)e[n]=e[n]+t[n]>>>0}function blockMix(e,t){let n=2*t*16,r=new Uint32Array(16);for(let t=0;t<16;t++)r[t]=e[n-16+t];let i=new Uint32Array(n);for(let n=0;n<2*t;n++){for(let t=0;t<16;t++)r[t]^=e[n*16+t];salsa20_8(r);for(let e=0;e<16;e++)i[n*16+e]=r[e]}for(let n=0;n<t;n++)for(let t=0;t<16;t++)e[n*16+t]=i[2*n*16+t];for(let n=0;n<t;n++)for(let r=0;r<16;r++)e[(t+n)*16+r]=i[(2*n+1)*16+r]}function roMix(e,t,n){let r=2*n*16,i=Array.from({length:t});for(let r=0;r<t;r++)i[r]=new Uint32Array(e),blockMix(e,n);for(let a=0;a<t;a++){let a=e[r-16]&t-1;for(let t=0;t<r;t++)e[t]^=i[a][t];blockMix(e,n)}}function bytesToWords(e){let t=new Uint32Array(e.length/4);for(let n=0;n<t.length;n++)t[n]=e[n*4]|e[n*4+1]<<8|e[n*4+2]<<16|e[n*4+3]<<24;return t}function wordsToBytes(e){let t=new Uint8Array(e.length*4);for(let n=0;n<e.length;n++)t[n*4]=e[n]&255,t[n*4+1]=e[n]>>8&255,t[n*4+2]=e[n]>>16&255,t[n*4+3]=e[n]>>24&255;return t}function scryptCore(e,t,n,r,i,a){let o=128*r,s=pbkdf2Sync(e,t,1,i*o,`sha256`);for(let e=0;e<i;e++){let t=new Uint8Array(s.buffer,s.byteOffset+e*o,o),i=bytesToWords(t);roMix(i,n,r);let a=wordsToBytes(i);t.set(a)}return pbkdf2Sync(e,s,1,a,`sha256`)}function scryptSync(e,t,n,r){let i=I.from(e),a=I.from(t),o=r?.N??16384,s=r?.r??8,c=r?.p??1;if(o<=0||o&o-1)throw Error(`N must be a positive power of 2`);return scryptCore(i,a,o,s,c,n)}function scrypt(e,t,n,r,i){let a={},o;typeof r==`function`?o=r:(a=r,o=i);try{let r=scryptSync(e,t,n,a);setTimeout(()=>o(null,r),0)}catch(e){setTimeout(()=>o(e instanceof Error?e:Error(String(e)),I.alloc(0)),0)}}var hr=__esmMin(()=>{mr(),_e()});function pemToDer(e){let t=e.trim().split(/\r?\n/),n=t.findIndex(e=>e.startsWith(`-----BEGIN `));if(n===-1)throw Error(`Invalid PEM: no BEGIN line found`);let r=t[n].match(/^-----BEGIN (.+)-----$/);if(!r)throw Error(`Invalid PEM header format`);let i=r[1],a=t.findIndex((e,t)=>t>n&&e.startsWith(`-----END `));if(a===-1)throw Error(`Invalid PEM: no END line found`);let o=t.slice(n+1,a).join(``),s=I.from(o,`base64`);return{type:i,der:new Uint8Array(s.buffer,s.byteOffset,s.byteLength)}}function parseTlv(e,t){if(t>=e.length)throw Error(`ASN.1 parse error: unexpected end of data`);let n=e[t++],r,i=e[t++];if(i<128)r=i;else{let n=i&127;if(n===0)throw Error(`ASN.1 parse error: indefinite length not supported`);r=0;for(let i=0;i<n;i++)r=r<<8|e[t++]}let a=e.slice(t,t+r),o=t+r,s={tag:n,data:a};return n===48&&(s.children=parseSequenceChildren(a)),{value:s,next:o}}function parseSequenceChildren(e){let t=[],n=0;for(;n<e.length;){let{value:r,next:i}=parseTlv(e,n);t.push(r),n=i}return t}function parseDer(e){let{value:t}=parseTlv(e,0);return t}function integerToBigInt(e){let t=0;for(;t<e.length-1&&e[t]===0;)t++;let n=0n;for(let r=t;r<e.length;r++)n=n<<8n|BigInt(e[r]);return n}function oidsEqual(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function parseRsaPublicKeyPkcs1(e){let t=e.children;if(!t||t.length<2)throw Error(`Invalid PKCS#1 RSAPublicKey structure`);return{n:integerToBigInt(t[0].data),e:integerToBigInt(t[1].data)}}function parseRsaPrivateKeyPkcs1(e){let t=e.children;if(!t||t.length<6)throw Error(`Invalid PKCS#1 RSAPrivateKey structure`);return{n:integerToBigInt(t[1].data),e:integerToBigInt(t[2].data),d:integerToBigInt(t[3].data),p:integerToBigInt(t[4].data),q:integerToBigInt(t[5].data)}}function parseSubjectPublicKeyInfo(e){let t=e.children;if(!t||t.length<2)throw Error(`Invalid SubjectPublicKeyInfo structure`);let n=t[0];if(!n.children||n.children.length<1)throw Error(`Invalid AlgorithmIdentifier`);let r=n.children[0];if(r.tag!==6||!oidsEqual(r.data,gr))throw Error(`Unsupported algorithm: only RSA is supported`);let i=t[1];if(i.tag!==3)throw Error(`Expected BIT STRING for public key data`);return parseRsaPublicKeyPkcs1(parseDer(i.data.slice(1)))}function parsePrivateKeyInfo(e){let t=e.children;if(!t||t.length<3)throw Error(`Invalid PrivateKeyInfo structure`);let n=t[1];if(!n.children||n.children.length<1)throw Error(`Invalid AlgorithmIdentifier`);let r=n.children[0];if(r.tag!==6||!oidsEqual(r.data,gr))throw Error(`Unsupported algorithm: only RSA is supported`);let i=t[2];if(i.tag!==4)throw Error(`Expected OCTET STRING for private key data`);return parseRsaPrivateKeyPkcs1(parseDer(i.data))}function encodeLength(e){if(e<128)return new Uint8Array([e]);let t=[],n=e;for(;n>0;)t.unshift(n&255),n>>=8;return new Uint8Array([128|t.length,...t])}function encodeTlv(e,t){let n=encodeLength(t.length),r=new Uint8Array(1+n.length+t.length);return r[0]=e,r.set(n,1),r.set(t,1+n.length),r}function bigintToAsn1Integer(e){if(e===0n)return encodeTlv(2,new Uint8Array([0]));let t=e.toString(16),n=t.length%2?`0`+t:t,r=[];for(let e=0;e<n.length;e+=2)r.push(parseInt(n.substring(e,e+2),16));return r[0]&128&&r.unshift(0),encodeTlv(2,new Uint8Array(r))}function encodeSequence(e){let t=0;for(let n of e)t+=n.length;let n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return encodeTlv(48,n)}function encodeBitString(e){let t=new Uint8Array(1+e.length);return t[0]=0,t.set(e,1),encodeTlv(3,t)}function encodeOctetString(e){return encodeTlv(4,e)}function encodeOid(e){return encodeTlv(6,e)}function encodeNull(){return new Uint8Array([5,0])}function encodeRsaPublicKeyPkcs1(e){return encodeSequence([bigintToAsn1Integer(e.n),bigintToAsn1Integer(e.e)])}function encodeSubjectPublicKeyInfo(e){return encodeSequence([encodeSequence([encodeOid(gr),encodeNull()]),encodeBitString(encodeRsaPublicKeyPkcs1(e))])}function encodeRsaPrivateKeyPkcs1(e){let t=e.d%(e.p-1n),n=e.d%(e.q-1n),r=modInverse$1(e.q,e.p);return encodeSequence([bigintToAsn1Integer(0n),bigintToAsn1Integer(e.n),bigintToAsn1Integer(e.e),bigintToAsn1Integer(e.d),bigintToAsn1Integer(e.p),bigintToAsn1Integer(e.q),bigintToAsn1Integer(t),bigintToAsn1Integer(n),bigintToAsn1Integer(r)])}function encodePrivateKeyInfo(e){let t=encodeSequence([encodeOid(gr),encodeNull()]),n=encodeOctetString(encodeRsaPrivateKeyPkcs1(e));return encodeSequence([bigintToAsn1Integer(0n),t,n])}function derToPem(e,t){let n=I.from(e).toString(`base64`),r=[`-----BEGIN ${t}-----`];for(let e=0;e<n.length;e+=64)r.push(n.substring(e,e+64));return r.push(`-----END ${t}-----`),r.join(`
|
|
8
8
|
`)}function modInverse$1(e,t){let[n,r]=[e%t,t],[i,a]=[1n,0n];for(;r!==0n;){let e=n/r;[n,r]=[r,n-e*r],[i,a]=[a,i-e*a]}return(i%t+t)%t}function parseX509(e){let{der:t}=pemToDer(e);return parseX509Der(t)}function parseX509Der(e){let t=parseDer(e);if(t.tag!==48||!t.children||t.children.length<3)throw Error(`Invalid X.509 certificate structure`);let n=t.children[0],r=t.children[1],i=t.children[2];if(!n.children||n.children.length<6)throw Error(`Invalid TBSCertificate structure`);let a=0;n.children[0].tag===160&&a++;let o=integerToBigInt(n.children[a].data);a++,a++;let s=parseDN(n.children[a]);a++;let c=n.children[a],l=parseAsn1Time(c.children[0]),u=parseAsn1Time(c.children[1]);a++;let d=parseDN(n.children[a]);a++;let f=null,p=`unknown`;if(a<n.children.length){let e=n.children[a];try{if(e.children&&e.children.length>=2){let t=e.children[0];if(t.children&&t.children.length>=1){let n=t.children[0];n.tag===6&&oidsEqual(n.data,gr)&&(p=`rsa`,f=parseSubjectPublicKeyInfo(e))}}}catch{}a++}let m,h;for(let e=a;e<n.children.length;e++){let t=n.children[e];if(t.tag===163&&t.data.length>0){let e=parseDer(t.data);if(e.children){h=e.children;let t=new Uint8Array([85,29,17]);for(let n of e.children)if(n.children&&n.children.length>=2){let e=n.children[0];if(e.tag===6&&oidsEqual(e.data,t)){let e=n.children[n.children.length-1];m=parseSAN(e.data)}}}}}let g=`unknown`;r.children&&r.children.length>=1&&(g=oidToName(r.children[0].data));let _=i.tag===3?i.data.slice(1):i.data;return{raw:e,tbsCertificate:n.data,serialNumber:o,issuer:s,subject:d,validFrom:l,validTo:u,publicKey:f,publicKeyAlgorithm:p,signatureAlgorithm:g,signature:_,subjectAltName:m,extensions:h}}function decodeOidString(e){if(e.length===0)return``;let t=[];t.push(Math.floor(e[0]/40)),t.push(e[0]%40);let n=0;for(let r=1;r<e.length;r++)n=n<<7|e[r]&127,e[r]&128||(t.push(n),n=0);return t.join(`.`)}function oidToName(e){let t=decodeOidString(e);return vr[t]||t}function parseDN(e){if(!e.children)return``;let t=[];for(let n of e.children){let e=n.tag===49?parseSequenceChildren(n.data):n.children||[];for(let n of e)if(n.children&&n.children.length>=2){let e=n.children[0].data,r=decodeOidString(e),i=_r[r]||r,a=n.children[1].data,o=new TextDecoder().decode(a);t.push(`${i}=${o}`)}}return t.join(`, `)}function parseAsn1Time(e){let t=new TextDecoder().decode(e.data);if(e.tag===23){let e=parseInt(t.substring(0,2),10);e=e>=50?1900+e:2e3+e;let n=parseInt(t.substring(2,4),10)-1,r=parseInt(t.substring(4,6),10),i=parseInt(t.substring(6,8),10),a=parseInt(t.substring(8,10),10),o=parseInt(t.substring(10,12),10);return new Date(Date.UTC(e,n,r,i,a,o))}if(e.tag===24){let e=parseInt(t.substring(0,4),10),n=parseInt(t.substring(4,6),10)-1,r=parseInt(t.substring(6,8),10),i=parseInt(t.substring(8,10),10),a=parseInt(t.substring(10,12),10),o=parseInt(t.substring(12,14),10);return new Date(Date.UTC(e,n,r,i,a,o))}throw Error(`Unsupported time tag: 0x${e.tag.toString(16)}`)}function parseSAN(e){let t=[];try{let n=parseDer(e);if(n.tag===48&&n.children){for(let e of n.children)if(e.tag===130)t.push(`DNS:`+new TextDecoder().decode(e.data));else if(e.tag===135){if(e.data.length===4)t.push(`IP Address:`+e.data.join(`.`));else if(e.data.length===16){let n=[];for(let t=0;t<16;t+=2)n.push((e.data[t]<<8|e.data[t+1]).toString(16));t.push(`IP Address:`+n.join(`:`))}}}}catch{}return t}function parsePemKey(e){let{type:t,der:n}=pemToDer(e),r=parseDer(n);if(r.tag!==48)throw Error(`Invalid key format: expected top-level SEQUENCE`);switch(t){case`RSA PUBLIC KEY`:return{type:`rsa-public`,components:parseRsaPublicKeyPkcs1(r)};case`PUBLIC KEY`:return{type:`rsa-public`,components:parseSubjectPublicKeyInfo(r)};case`RSA PRIVATE KEY`:return{type:`rsa-private`,components:parseRsaPrivateKeyPkcs1(r)};case`PRIVATE KEY`:return{type:`rsa-private`,components:parsePrivateKeyInfo(r)};default:throw Error(`Unsupported PEM type: ${t}`)}}function rsaKeySize(e){let t=0,n=e;for(;n>0n;)t++,n>>=1n;return Math.ceil(t/8)}var gr,_r,vr,yr=__esmMin(()=>{_e(),gr=new Uint8Array([42,134,72,134,247,13,1,1,1]),__name(modInverse$1,`modInverse`),_r={"2.5.4.3":`CN`,"2.5.4.6":`C`,"2.5.4.7":`L`,"2.5.4.8":`ST`,"2.5.4.10":`O`,"2.5.4.11":`OU`,"1.2.840.113549.1.9.1":`emailAddress`},vr={"1.2.840.113549.1.1.1":`rsaEncryption`,"1.2.840.113549.1.1.5":`sha1WithRSAEncryption`,"1.2.840.113549.1.1.11":`sha256WithRSAEncryption`,"1.2.840.113549.1.1.12":`sha384WithRSAEncryption`,"1.2.840.113549.1.1.13":`sha512WithRSAEncryption`}});function normalizeSignAlgorithm(e){let t=e.toLowerCase().replace(/-/g,``);if(t.startsWith(`rsa`)&&(t=t.slice(3)),!br[t])throw Error(`Unsupported algorithm: ${e}. Supported: RSA-SHA1, RSA-SHA256, RSA-SHA512`);return t}function extractPem$1(e){if(typeof e==`string`)return e;if(I.isBuffer(e)||e instanceof Uint8Array)return I.from(e).toString(`utf8`);if(e&&typeof e==`object`&&`key`in e){let t=e.key;if(typeof t==`string`)return t;if(I.isBuffer(t)||t instanceof Uint8Array)return I.from(t).toString(`utf8`)}throw TypeError(`Invalid key argument`)}function createSign(e){return new Sign(e)}function createVerify(e){return new Verify(e)}var br,Sign,Verify,xr=__esmMin(()=>{yr(),bn(),ur(),_e(),br={sha1:new Uint8Array([48,33,48,9,6,5,43,14,3,2,26,5,0,4,20]),sha256:new Uint8Array([48,49,48,13,6,9,96,134,72,1,101,3,4,2,1,5,0,4,32]),sha512:new Uint8Array([48,81,48,13,6,9,96,134,72,1,101,3,4,2,3,5,0,4,64])},__name(extractPem$1,`extractPem`),Sign=class{_algorithm;_hash;_finalized=!1;constructor(e){this._algorithm=normalizeSignAlgorithm(e),this._hash=new lr(this._algorithm)}update(e,t){if(this._finalized)throw Error(`Sign was already finalized`);return this._hash.update(e,t),this}sign(e,t){if(this._finalized)throw Error(`Sign was already finalized`);this._finalized=!0;let n=this._hash.digest(),r=parsePemKey(extractPem$1(e));if(r.type!==`rsa-private`)throw Error(`privateKey must be an RSA private key`);let{n:i,d:a}=r.components,o=rsaKeySize(i),s=br[this._algorithm],c=new Uint8Array(s.length+n.length);c.set(s,0),c.set(n,s.length);let l=o-c.length-3;if(l<8)throw Error(`Key is too short for the specified hash algorithm`);let u=new Uint8Array(o);u[0]=0,u[1]=1;for(let e=2;e<2+l;e++)u[e]=255;u[2+l]=0,u.set(c,3+l);let d=bigIntToBytes(modPow(bytesToBigInt(u),a,i),o),f=I.from(d);return t?f.toString(t):f}},Verify=class{_algorithm;_hash;_finalized=!1;constructor(e){this._algorithm=normalizeSignAlgorithm(e),this._hash=new lr(this._algorithm)}update(e,t){if(this._finalized)throw Error(`Verify was already finalized`);return this._hash.update(e,t),this}verify(e,t,n){if(this._finalized)throw Error(`Verify was already finalized`);this._finalized=!0;let r=this._hash.digest(),i=parsePemKey(extractPem$1(e)),a,o;if(i.type===`rsa-public`)a=i.components.n,o=i.components.e;else if(i.type===`rsa-private`)a=i.components.n,o=i.components.e;else throw Error(`publicKey must be an RSA public or private key`);let s=rsaKeySize(a),c;if(c=typeof t==`string`?I.from(t,n||`base64`):t instanceof Uint8Array?t:I.from(t),c.length!==s)return!1;let l=bytesToBigInt(c);if(l>=a)return!1;let u=bigIntToBytes(modPow(l,o,a),s);if(u[0]!==0||u[1]!==1)return!1;let d=2;for(;d<u.length&&u[d]===255;)d++;if(d>=u.length||u[d]!==0||d-2<8)return!1;d++;let f=u.slice(d),p=br[this._algorithm],m=new Uint8Array(p.length+r.length);if(m.set(p,0),m.set(r,p.length),f.length!==m.length)return!1;let h=0;for(let e=0;e<f.length;e++)h|=f[e]^m[e];return h===0}}});function extractPem(e){if(typeof e==`string`)return e;if(I.isBuffer(e)||e instanceof Uint8Array)return I.from(e).toString(`utf8`);if(e&&typeof e==`object`&&`key`in e){let t=e.key;if(typeof t==`string`)return t;if(I.isBuffer(t)||t instanceof Uint8Array)return I.from(t).toString(`utf8`)}throw TypeError(`Invalid key argument`)}function pkcs1v15Type2Pad(e,t){let n=t-11;if(e.length>n)throw Error(`Data too long for key size. Max ${n} bytes, got ${e.length}`);let r=t-e.length-3,i=new Uint8Array(t);i[0]=0,i[1]=2;let a=randomBytes(r);for(let e=0;e<r;e++){for(;a[e]===0;)a[e]=randomBytes(1)[0];i[2+e]=a[e]}return i[2+r]=0,i.set(e,3+r),i}function pkcs1v15Type1Pad(e,t){let n=t-11;if(e.length>n)throw Error(`Data too long for key size. Max ${n} bytes, got ${e.length}`);let r=t-e.length-3,i=new Uint8Array(t);i[0]=0,i[1]=1;for(let e=2;e<2+r;e++)i[e]=255;return i[2+r]=0,i.set(e,3+r),i}function pkcs1v15Type2Unpad(e){if(e.length<11)throw Error(`Decryption error: message too short`);if(e[0]!==0||e[1]!==2)throw Error(`Decryption error: invalid padding`);let t=2;for(;t<e.length&&e[t]!==0;)t++;if(t>=e.length||t<10)throw Error(`Decryption error: invalid padding`);return e.slice(t+1)}function pkcs1v15Type1Unpad(e){if(e.length<11)throw Error(`Decryption error: message too short`);if(e[0]!==0||e[1]!==1)throw Error(`Decryption error: invalid padding`);let t=2;for(;t<e.length&&e[t]===255;)t++;if(t>=e.length||e[t]!==0||t<10)throw Error(`Decryption error: invalid padding`);return e.slice(t+1)}function publicEncrypt(e,t){let n=parsePemKey(extractPem(e)),r,i;if(n.type===`rsa-public`)r=n.components.n,i=n.components.e;else if(n.type===`rsa-private`)r=n.components.n,i=n.components.e;else throw Error(`Key must be an RSA public or private key`);let a=rsaKeySize(r),o=modPow(bytesToBigInt(pkcs1v15Type2Pad(t instanceof Uint8Array?t:I.from(t),a)),i,r);return I.from(bigIntToBytes(o,a))}function privateDecrypt(e,t){let n=parsePemKey(extractPem(e));if(n.type!==`rsa-private`)throw Error(`Key must be an RSA private key`);let{n:r,d:i}=n.components,a=rsaKeySize(r),o=t instanceof Uint8Array?t:I.from(t);if(o.length!==a)throw Error(`Data length (${o.length}) does not match key length (${a})`);let s=bytesToBigInt(o);if(s>=r)throw Error(`Decryption error: cipher value out of range`);let c=bigIntToBytes(modPow(s,i,r),a);return I.from(pkcs1v15Type2Unpad(c))}function privateEncrypt(e,t){let n=parsePemKey(extractPem(e));if(n.type!==`rsa-private`)throw Error(`Key must be an RSA private key`);let{n:r,d:i}=n.components,a=rsaKeySize(r),o=modPow(bytesToBigInt(pkcs1v15Type1Pad(t instanceof Uint8Array?t:I.from(t),a)),i,r);return I.from(bigIntToBytes(o,a))}function publicDecrypt(e,t){let n=parsePemKey(extractPem(e)),r,i;if(n.type===`rsa-public`)r=n.components.n,i=n.components.e;else if(n.type===`rsa-private`)r=n.components.n,i=n.components.e;else throw Error(`Key must be an RSA public or private key`);let a=rsaKeySize(r),o=t instanceof Uint8Array?t:I.from(t);if(o.length!==a)throw Error(`Data length (${o.length}) does not match key length (${a})`);let s=bytesToBigInt(o);if(s>=r)throw Error(`Decryption error: cipher value out of range`);let c=bigIntToBytes(modPow(s,i,r),a);return I.from(pkcs1v15Type1Unpad(c))}var Sr=__esmMin(()=>{yr(),bn(),yn(),_e()});function mgf1(e,t,n){let r=new Uint8Array(n),i=0,a=0;for(;i<n;){let o=new Uint8Array(4);o[0]=a>>>24&255,o[1]=a>>>16&255,o[2]=a>>>8&255,o[3]=a&255;let s=new lr(e);s.update(t),s.update(o);let c=new Uint8Array(s.digest()),l=Math.min(c.length,n-i);r.set(c.slice(0,l),i),i+=l,a++}return r}var Cr=__esmMin(()=>{ur()});function hashDigest$1(e,t){let n=new lr(e);return n.update(t),new Uint8Array(n.digest())}function emsaPssEncode(e,t,n,r){let i=hashSize(n),a=Math.ceil(t/8);if(a<i+r+2)throw Error(`RSA-PSS: encoding error — key too short`);let o=r>0?new Uint8Array(randomBytes(r)):new Uint8Array,s=new Uint8Array(8+i+r);s.set(e,8),s.set(o,8+i);let c=hashDigest$1(n,s),l=a-i-1,u=new Uint8Array(l);u[l-r-1]=1,u.set(o,l-r);let d=mgf1(n,c,l),f=new Uint8Array(l);for(let e=0;e<l;e++)f[e]=u[e]^d[e];let p=8*a-t;p>0&&(f[0]&=255>>>p);let m=new Uint8Array(a);return m.set(f,0),m.set(c,l),m[a-1]=188,m}function emsaPssVerify(e,t,n,r,i){let a=hashSize(r),o=Math.ceil(n/8);if(o<a+i+2||t[o-1]!==188)return!1;let s=o-a-1,c=t.slice(0,s),l=t.slice(s,s+a),u=8*o-n;if(u>0&&c[0]&255<<8-u)return!1;let d=mgf1(r,l,s),f=new Uint8Array(s);for(let e=0;e<s;e++)f[e]=c[e]^d[e];u>0&&(f[0]&=255>>>u);for(let e=0;e<s-i-1;e++)if(f[e]!==0)return!1;if(f[s-i-1]!==1)return!1;let p=f.slice(s-i),m=new Uint8Array(8+a+i);m.set(e,8),m.set(p,8+a);let h=hashDigest$1(r,m);if(l.length!==h.length)return!1;let g=0;for(let e=0;e<l.length;e++)g|=l[e]^h[e];return g===0}function rsaPssSign(e,t,n,r){let i=parsePemKey(t);if(i.type!==`rsa-private`)throw Error(`RSA-PSS: expected RSA private key`);let{n:a,d:o}=i.components,s=rsaKeySize(a),c=Math.ceil(s/8);return bigIntToBytes(modPow(bytesToBigInt(emsaPssEncode(hashDigest$1(e,n),s-1,e,r)),o,a),c)}function rsaPssVerify(e,t,n,r,i){let a=parsePemKey(t),o,s;if(a.type===`rsa-public`)({n:o,e:s}=a.components);else if(a.type===`rsa-private`)({n:o,e:s}=a.components);else throw Error(`RSA-PSS: expected RSA key`);let c=rsaKeySize(o),l=Math.ceil(c/8);if(n.length!==l)return!1;let u=bigIntToBytes(modPow(bytesToBigInt(n),s,o),Math.ceil((c-1)/8));return emsaPssVerify(hashDigest$1(e,r),u,c-1,e,i)}var wr=__esmMin(()=>{yr(),bn(),Pn(),yn(),ur(),Cr(),__name(hashDigest$1,`hashDigest`)});function hashDigest(e,t){let n=new lr(e);return n.update(t),new Uint8Array(n.digest())}function rsaOaepEncrypt(e,t,n,r){let i=parsePemKey(t),a,o;if(i.type===`rsa-public`)({n:a,e:o}=i.components);else if(i.type===`rsa-private`)({n:a,e:o}=i.components);else throw Error(`RSA-OAEP: expected RSA key`);let s=Math.ceil(rsaKeySize(a)/8),c=hashSize(e);if(n.length>s-2*c-2)throw Error(`RSA-OAEP: message too long`);let l=hashDigest(e,r||new Uint8Array),u=s-c-1,d=new Uint8Array(u);d.set(l,0),d[u-n.length-1]=1,d.set(n,u-n.length);let f=new Uint8Array(randomBytes(c)),p=mgf1(e,f,u),m=new Uint8Array(u);for(let e=0;e<u;e++)m[e]=d[e]^p[e];let h=mgf1(e,m,c),g=new Uint8Array(c);for(let e=0;e<c;e++)g[e]=f[e]^h[e];let _=new Uint8Array(s);return _[0]=0,_.set(g,1),_.set(m,1+c),bigIntToBytes(modPow(bytesToBigInt(_),o,a),s)}function rsaOaepDecrypt(e,t,n,r){let i=parsePemKey(t);if(i.type!==`rsa-private`)throw Error(`RSA-OAEP: expected RSA private key`);let{n:a,d:o}=i.components,s=Math.ceil(rsaKeySize(a)/8),c=hashSize(e);if(n.length!==s||s<2*c+2)throw Error(`RSA-OAEP: decryption error`);let l=bigIntToBytes(modPow(bytesToBigInt(n),o,a),s),u=l[0],d=l.slice(1,1+c),f=l.slice(1+c),p=s-c-1,m=mgf1(e,f,c),h=new Uint8Array(c);for(let e=0;e<c;e++)h[e]=d[e]^m[e];let g=mgf1(e,h,p),_=new Uint8Array(p);for(let e=0;e<p;e++)_[e]=f[e]^g[e];let v=hashDigest(e,r||new Uint8Array),y=_.slice(0,c),b=+(u===0);for(let e=0;e<c;e++)b&=+(v[e]===y[e]);let x=-1;for(let e=c;e<p;e++)if(_[e]===1){x=e;break}else if(_[e]!==0){b=0;break}if(x===-1&&(b=0),!b)throw Error(`RSA-OAEP: decryption error`);return _.slice(x+1)}var Tr=__esmMin(()=>{yr(),bn(),Pn(),yn(),ur(),Cr()});function bigintToBase64url(e){if(e===0n)return`AA`;let t=e.toString(16),n=t.length%2?`0`+t:t,r=[];for(let e=0;e<n.length;e+=2)r.push(parseInt(n.substring(e,e+2),16));return I.from(r).toString(`base64url`)}function base64urlToBigint(e){let t=I.from(e,`base64url`),n=0n;for(let e=0;e<t.length;e++)n=n<<8n|BigInt(t[e]);return n}function exportJwk(e,t){if(e.type===`rsa-public`)return{kty:`RSA`,n:bigintToBase64url(e.components.n),e:bigintToBase64url(e.components.e)};if(e.type===`rsa-private`){if(t===`public`)return{kty:`RSA`,n:bigintToBase64url(e.components.n),e:bigintToBase64url(e.components.e)};let{n,e:r,d:i,p:a,q:o}=e.components,s=i%(a-1n),c=i%(o-1n),l=modInverse(o,a);return{kty:`RSA`,n:bigintToBase64url(n),e:bigintToBase64url(r),d:bigintToBase64url(i),p:bigintToBase64url(a),q:bigintToBase64url(o),dp:bigintToBase64url(s),dq:bigintToBase64url(c),qi:bigintToBase64url(l)}}throw Error(`Unsupported key type for JWK export`)}function importJwkRsa(e){if(e.d){let t={n:base64urlToBigint(e.n),e:base64urlToBigint(e.e),d:base64urlToBigint(e.d),p:base64urlToBigint(e.p),q:base64urlToBigint(e.q)};return{parsed:{type:`rsa-private`,components:t},pem:derToPem(encodeRsaPrivateKeyPkcs1(t),`RSA PRIVATE KEY`)}}let t={n:base64urlToBigint(e.n),e:base64urlToBigint(e.e)};return{parsed:{type:`rsa-public`,components:t},pem:derToPem(encodeSubjectPublicKeyInfo(t),`PUBLIC KEY`)}}function generatePem(e,t,n){if(e.type===`rsa-public`)return n===`pkcs1`?derToPem(encodeRsaPublicKeyPkcs1(e.components),`RSA PUBLIC KEY`):derToPem(encodeSubjectPublicKeyInfo(e.components),`PUBLIC KEY`);if(e.type===`rsa-private`&&t===`public`){let t={n:e.components.n,e:e.components.e};return n===`pkcs1`?derToPem(encodeRsaPublicKeyPkcs1(t),`RSA PUBLIC KEY`):derToPem(encodeSubjectPublicKeyInfo(t),`PUBLIC KEY`)}if(e.type===`rsa-private`)return n===`pkcs8`?derToPem(encodePrivateKeyInfo(e.components),`PRIVATE KEY`):derToPem(encodeRsaPrivateKeyPkcs1(e.components),`RSA PRIVATE KEY`);throw Error(`Cannot generate PEM for this key type`)}function generateDer(e,t,n){if(e.type===`rsa-public`)return n===`pkcs1`?I.from(encodeRsaPublicKeyPkcs1(e.components)):I.from(encodeSubjectPublicKeyInfo(e.components));if(e.type===`rsa-private`&&t===`public`){let t={n:e.components.n,e:e.components.e};return n===`pkcs1`?I.from(encodeRsaPublicKeyPkcs1(t)):I.from(encodeSubjectPublicKeyInfo(t))}if(e.type===`rsa-private`)return n===`pkcs8`?I.from(encodePrivateKeyInfo(e.components)):I.from(encodeRsaPrivateKeyPkcs1(e.components));throw Error(`Cannot generate DER for this key type`)}function modInverse(e,t){let[n,r]=[e%t,t],[i,a]=[1n,0n];for(;r!==0n;){let e=n/r;[n,r]=[r,n-e*r],[i,a]=[a,i-e*a]}return(i%t+t)%t}function createSecretKey(e,t){let n;return n=typeof e==`string`?I.from(e,t??`utf8`):new Uint8Array(e),new Er(`secret`,n)}function createPublicKey(e){if(e instanceof Er){if(e.type===`public`)return e;if(e.type===`private`){let t=e._handle;if(t.parsed.type===`rsa-private`){let e={n:t.parsed.components.n,e:t.parsed.components.e};return new Er(`public`,{parsed:{type:`rsa-public`,components:e},pem:derToPem(encodeSubjectPublicKeyInfo(e),`PUBLIC KEY`)})}}throw TypeError(`Cannot create public key from secret key`)}if(typeof e==`object`&&!I.isBuffer(e)&&`key`in e){let t=e;if(t.format===`jwk`){let e=t.key;if(e.kty===`RSA`){let{parsed:t,pem:n}=importJwkRsa({n:e.n,e:e.e});return new Er(`public`,{parsed:t,pem:n})}throw Error(`Unsupported JWK key type: ${e.kty}`)}}let t=normalizePem(e),n=parsePemKey(t);if(n.type===`rsa-private`){let e={n:n.components.n,e:n.components.e};return new Er(`public`,{parsed:{type:`rsa-public`,components:e},pem:derToPem(encodeSubjectPublicKeyInfo(e),`PUBLIC KEY`)})}return new Er(`public`,{parsed:n,pem:t})}function createPrivateKey(e){if(typeof e==`object`&&!I.isBuffer(e)&&`key`in e){let t=e;if(t.format===`jwk`){let e=t.key;if(e.kty===`RSA`&&e.d){let{parsed:t,pem:n}=importJwkRsa(e);return new Er(`private`,{parsed:t,pem:n})}throw Error(`JWK does not contain a private key`)}}let t=normalizePem(e),n=parsePemKey(t);if(n.type!==`rsa-private`)throw TypeError(`Key is not a private key`);return new Er(`private`,{parsed:n,pem:t})}function normalizePem(e){if(typeof e==`string`)return e;if(I.isBuffer(e))return e.toString(`utf8`);if(e&&typeof e==`object`&&`key`in e){let t=e;if(typeof t.key==`string`)return t.key;if(I.isBuffer(t.key))return t.key.toString(t.encoding??`utf8`);if(t.key instanceof Er)return t.key.export({format:`pem`})}throw TypeError(`Invalid key input`)}var Er,Dr=__esmMin(()=>{yr(),_e(),Er=class KeyObject{type;_handle;constructor(e,t){if(e!==`secret`&&e!==`public`&&e!==`private`)throw TypeError(`Invalid KeyObject type: ${e}`);this.type=e,this._handle=t}get symmetricKeySize(){if(this.type===`secret`)return this._handle.byteLength}get asymmetricKeyType(){if(this.type===`secret`)return;let e=this._handle;if(e.parsed.type===`rsa-public`||e.parsed.type===`rsa-private`)return`rsa`}get asymmetricKeySize(){if(this.type===`secret`)return;let e=this._handle;if(e.parsed.type===`rsa-public`||e.parsed.type===`rsa-private`)return rsaKeySize(e.parsed.components.n)/8}equals(e){if(!(e instanceof KeyObject)||this.type!==e.type)return!1;if(this.type===`secret`){let t=this._handle,n=e._handle;if(t.byteLength!==n.byteLength)return!1;for(let e=0;e<t.byteLength;e++)if(t[e]!==n[e])return!1;return!0}let t=this._handle,n=e._handle;return t.pem===n.pem}export(e){if(this.type===`secret`){let t=this._handle;return e?.format===`jwk`?{kty:`oct`,k:I.from(t).toString(`base64url`)}:I.from(t)}let t=this._handle,n=e?.format??`pem`,r=e?.type;if(n===`jwk`)return exportJwk(t.parsed,this.type);if(n===`pem`)return t.pem&&!t.pem.startsWith(`[`)?t.pem:generatePem(t.parsed,this.type,r);if(n===`der`){if(t.pem&&!t.pem.startsWith(`[`)){let e=t.pem.trim().split(/\r?\n/),n=e.findIndex(e=>e.startsWith(`-----BEGIN `)),r=e.findIndex((e,t)=>t>n&&e.startsWith(`-----END `)),i=e.slice(n+1,r).join(``);return I.from(i,`base64`)}return generateDer(t.parsed,this.type,r)}throw TypeError(`Unsupported export format: ${n}`)}get[Symbol.toStringTag](){return`KeyObject`}}});function formatFingerprint(e){let t=e.toString(`hex`).toUpperCase(),n=[];for(let e=0;e<t.length;e+=2)n.push(t.substring(e,e+2));return n.join(`:`)}function matchHostname(e,t){let n=e.toLowerCase(),r=t.toLowerCase();if(n===r)return!0;if(n.startsWith(`*.`)){let e=n.substring(2),t=r.split(`.`);if(t.length>=2)return t.slice(1).join(`.`)===e}return!1}function parseDNToObject(e){let t={},n=e.split(`, `);for(let e of n){let n=e.indexOf(`=`);n>0&&(t[e.substring(0,n)]=e.substring(n+1))}return t}var X509Certificate,Or=__esmMin(()=>{yr(),Dr(),jr(),_e(),X509Certificate=class{_components;_pem;constructor(e){if(typeof e==`string`)this._pem=e,this._components=parseX509(e);else{let t=I.isBuffer(e)?e:I.from(e),n=t.toString(`utf8`);n.includes(`-----BEGIN CERTIFICATE-----`)?(this._pem=n,this._components=parseX509(n)):(this._components=parseX509Der(new Uint8Array(t.buffer,t.byteOffset,t.byteLength)),this._pem=derToPem(this._components.raw,`CERTIFICATE`))}}get raw(){return I.from(this._components.raw)}get serialNumber(){return this._components.serialNumber.toString(16).toUpperCase()}get subject(){return this._components.subject}get issuer(){return this._components.issuer}get validFrom(){return this._components.validFrom.toUTCString()}get validTo(){return this._components.validTo.toUTCString()}get fingerprint(){return formatFingerprint(createHash(`sha1`).update(this._components.raw).digest())}get fingerprint256(){return formatFingerprint(createHash(`sha256`).update(this._components.raw).digest())}get fingerprint512(){return formatFingerprint(createHash(`sha512`).update(this._components.raw).digest())}get publicKey(){if(!this._components.publicKey)throw Error(`Certificate does not contain a supported public key type`);let e=derToPem(encodeSubjectPublicKeyInfo(this._components.publicKey),`PUBLIC KEY`);return new Er(`public`,{parsed:{type:`rsa-public`,components:this._components.publicKey},pem:e})}get subjectAltName(){if(!(!this._components.subjectAltName||this._components.subjectAltName.length===0))return this._components.subjectAltName.join(`, `)}get keyUsage(){}get infoAccess(){}get ca(){return!1}checkHost(e){let t=this._components.subject.match(/CN=([^,]+)/);if(t){let n=t[1].trim();if(matchHostname(n,e))return n}if(this._components.subjectAltName){for(let t of this._components.subjectAltName)if(t.startsWith(`DNS:`)){let n=t.substring(4);if(matchHostname(n,e))return n}}}checkEmail(e){let t=e.toLowerCase(),n=this._components.subject.match(/emailAddress=([^,]+)/);if(n&&n[1].toLowerCase()===t)return n[1]}checkIP(e){if(this._components.subjectAltName){for(let t of this._components.subjectAltName)if(t.startsWith(`IP Address:`)&&t.substring(11)===e)return e}}verify(e){return!0}checkIssued(e){return this.issuer===e.subject}toLegacyObject(){return{subject:parseDNToObject(this._components.subject),issuer:parseDNToObject(this._components.issuer),valid_from:this.validFrom,valid_to:this.validTo,serialNumber:this.serialNumber,fingerprint:this.fingerprint,fingerprint256:this.fingerprint256}}toString(){return this._pem}toJSON(){return this._pem}get[Symbol.toStringTag](){return`X509Certificate`}}}),kr=__exportAll$2({DiffieHellman:()=>DiffieHellman,DiffieHellmanGroup:()=>En,Hash:()=>lr,Hmac:()=>Hmac,KeyObject:()=>Er,Sign:()=>Sign,Verify:()=>Verify,X509Certificate:()=>X509Certificate,constants:()=>on,createCipher:()=>createCipher,createCipheriv:()=>createCipheriv,createDecipher:()=>createDecipher,createDecipheriv:()=>createDecipheriv,createDiffieHellman:()=>createDiffieHellman,createDiffieHellmanGroup:()=>Tn,createECDH:()=>createECDH,createHash:()=>createHash,createHmac:()=>createHmac,createPrivateKey:()=>createPrivateKey,createPublicKey:()=>createPublicKey,createSecretKey:()=>createSecretKey,createSign:()=>createSign,createVerify:()=>createVerify,default:()=>Ar,ecdsaSign:()=>ecdsaSign,ecdsaVerify:()=>ecdsaVerify,getCiphers:()=>getCiphers,getCurves:()=>getCurves,getDiffieHellman:()=>getDiffieHellman,getHashes:()=>getHashes,hash:()=>hash,hkdf:()=>hkdf,hkdfSync:()=>hkdfSync,mgf1:()=>mgf1,pbkdf2:()=>pbkdf2,pbkdf2Sync:()=>pbkdf2Sync,privateDecrypt:()=>privateDecrypt,privateEncrypt:()=>privateEncrypt,publicDecrypt:()=>publicDecrypt,publicEncrypt:()=>publicEncrypt,randomBytes:()=>randomBytes,randomFill:()=>randomFill,randomFillSync:()=>randomFillSync,randomInt:()=>randomInt,randomUUID:()=>randomUUID,rsaOaepDecrypt:()=>rsaOaepDecrypt,rsaOaepEncrypt:()=>rsaOaepEncrypt,rsaPssSign:()=>rsaPssSign,rsaPssVerify:()=>rsaPssVerify,scrypt:()=>scrypt,scryptSync:()=>scryptSync,timingSafeEqual:()=>timingSafeEqual});function createHash(e){return new lr(e)}function createHmac(e,t){return new Hmac(e,t)}var Ar,jr=__esmMin(()=>{sn(),cn(),mn(),yn(),Dn(),An(),ur(),dr(),fr(),pr(),mr(),hr(),xr(),Sr(),Cr(),wr(),Tr(),Dr(),Or(),Ar={Hash:lr,getHashes,hash,Hmac,randomBytes,randomFill,randomFillSync,randomUUID,randomInt,timingSafeEqual,constants:on,pbkdf2,pbkdf2Sync,hkdf,hkdfSync,scrypt,scryptSync,createHash,createHmac,createCipher,createCipheriv,createDecipher,createDecipheriv,getCiphers,Sign,Verify,createSign,createVerify,createDiffieHellman,getDiffieHellman,DiffieHellman,DiffieHellmanGroup:En,createDiffieHellmanGroup:Tn,createECDH,getCurves,ecdsaSign,ecdsaVerify,publicEncrypt,privateDecrypt,privateEncrypt,publicDecrypt,rsaPssSign,rsaPssVerify,rsaOaepEncrypt,rsaOaepDecrypt,mgf1,KeyObject:Er,createSecretKey,createPublicKey,createPrivateKey,X509Certificate}});let Mr=!1,Nr,Pr,Fr,Ir,Lr,Rr,zr,Br,Vr,Hr,Ur,Wr,Gr,Kr,qr,Jr;async function loadCrypto(){if(Mr)return;let e=await Promise.resolve().then(()=>(jr(),kr));Nr=e.createHash,Pr=e.createHmac,Fr=e.createCipheriv,Ir=e.createDecipheriv,Lr=e.createSign,Rr=e.createVerify,zr=e.pbkdf2Sync,Br=e.hkdfSync,Vr=e.createECDH,Hr=e.randomBytes,e.publicEncrypt,e.privateDecrypt,e.createPublicKey,e.createPrivateKey,Ur=e.ecdsaSign,Wr=e.ecdsaVerify,Gr=e.rsaPssSign,Kr=e.rsaPssVerify,qr=e.rsaOaepEncrypt,Jr=e.rsaOaepDecrypt,Mr=!0}const Yr=loadCrypto();var SubtleCrypto=class{async digest(e,t){await Yr;let n=toNodeHashName(normalizeAlgorithm$1(e).name),r=toUint8Array(t),i=Nr(n);i.update(r);let a=i.digest();return a.buffer.slice(a.byteOffset,a.byteOffset+a.byteLength)}async generateKey(e,t,n){await Yr;let r=normalizeAlgorithm$1(e);switch(r.name.toUpperCase()){case`AES-CBC`:case`AES-CTR`:case`AES-GCM`:{let i=e.length;if(![128,192,256].includes(i))throw new DOMException(`Invalid AES key length: ${i}`,`OperationError`);validateUsages(n,[`encrypt`,`decrypt`,`wrapKey`,`unwrapKey`]);let a=Hr(i/8);return new CryptoKey(`secret`,t,{name:r.name,length:i},n,new Uint8Array(a))}case`AES-KW`:{let r=e.length;if(![128,192,256].includes(r))throw new DOMException(`Invalid AES key length: ${r}`,`OperationError`);validateUsages(n,[`wrapKey`,`unwrapKey`]);let i=Hr(r/8);return new CryptoKey(`secret`,t,{name:`AES-KW`,length:r},n,new Uint8Array(i))}case`HMAC`:{let r=e,i=normalizeAlgorithm$1(r.hash),a=r.length||hashSize$1(i.name)*8;validateUsages(n,[`sign`,`verify`]);let o=Hr(Math.ceil(a/8));return new CryptoKey(`secret`,t,{name:`HMAC`,hash:{name:i.name},length:a},n,new Uint8Array(o))}case`ECDH`:{let r=e.namedCurve,i=toNodeCurveName(r);validateUsages(n,[`deriveKey`,`deriveBits`]);let a=Vr(i);a.generateKeys();let o=new Uint8Array(a.getPublicKey()),s=new Uint8Array(a.getPrivateKey());return{publicKey:new CryptoKey(`public`,!0,{name:`ECDH`,namedCurve:r},[],o),privateKey:new CryptoKey(`private`,t,{name:`ECDH`,namedCurve:r},n,{pub:o,priv:s})}}case`ECDSA`:{let r=e.namedCurve,i=toNodeCurveName(r);validateUsages(n,[`sign`,`verify`]);let a=Vr(i);a.generateKeys();let o=new Uint8Array(a.getPublicKey()),s=new Uint8Array(a.getPrivateKey());return{publicKey:new CryptoKey(`public`,!0,{name:`ECDSA`,namedCurve:r},[`verify`],o),privateKey:new CryptoKey(`private`,t,{name:`ECDSA`,namedCurve:r},[`sign`],{pub:o,priv:s})}}default:throw new DOMException(`Unsupported algorithm: ${r.name}`,`NotSupportedError`)}}async importKey(e,t,n,r,i){await Yr;let a=normalizeAlgorithm$1(n),o=a.name.toUpperCase();switch(o){case`AES-CBC`:case`AES-CTR`:case`AES-GCM`:if(e===`raw`){let e=toUint8Array(t);if(![16,24,32].includes(e.length))throw new DOMException(`Invalid AES key length: ${e.length*8}`,`DataError`);return validateUsages(i,[`encrypt`,`decrypt`,`wrapKey`,`unwrapKey`]),new CryptoKey(`secret`,r,{name:a.name,length:e.length*8},i,new Uint8Array(e))}if(e===`jwk`){let e=t;if(e.kty!==`oct`)throw new DOMException(`JWK kty must be "oct"`,`DataError`);let n=base64urlDecode(e.k);if(![16,24,32].includes(n.length))throw new DOMException(`Invalid AES key length: ${n.length*8}`,`DataError`);return validateUsages(i,[`encrypt`,`decrypt`,`wrapKey`,`unwrapKey`]),new CryptoKey(`secret`,r,{name:a.name,length:n.length*8},i,n)}throw new DOMException(`Unsupported format: ${e}`,`NotSupportedError`);case`AES-KW`:{let n;if(e===`raw`)n=toUint8Array(t);else if(e===`jwk`){let e=t;if(e.kty!==`oct`)throw new DOMException(`JWK kty must be "oct"`,`DataError`);n=base64urlDecode(e.k)}else throw new DOMException(`Unsupported format: ${e}`,`NotSupportedError`);if(![16,24,32].includes(n.length))throw new DOMException(`Invalid AES key length: ${n.length*8}`,`DataError`);return validateUsages(i,[`wrapKey`,`unwrapKey`]),new CryptoKey(`secret`,r,{name:`AES-KW`,length:n.length*8},i,new Uint8Array(n))}case`HMAC`:{let a=normalizeAlgorithm$1(n.hash);if(e===`raw`){let e=toUint8Array(t);return validateUsages(i,[`sign`,`verify`]),new CryptoKey(`secret`,r,{name:`HMAC`,hash:{name:a.name},length:e.length*8},i,new Uint8Array(e))}if(e===`jwk`){let e=t;if(e.kty!==`oct`)throw new DOMException(`JWK kty must be "oct"`,`DataError`);let n=base64urlDecode(e.k);return validateUsages(i,[`sign`,`verify`]),new CryptoKey(`secret`,r,{name:`HMAC`,hash:{name:a.name},length:n.length*8},i,n)}throw new DOMException(`Unsupported format: ${e}`,`NotSupportedError`)}case`PBKDF2`:if(e===`raw`){let e=toUint8Array(t);return validateUsages(i,[`deriveKey`,`deriveBits`]),new CryptoKey(`secret`,!1,{name:`PBKDF2`},i,new Uint8Array(e))}throw new DOMException(`Unsupported format: ${e}`,`NotSupportedError`);case`HKDF`:if(e===`raw`){let e=toUint8Array(t);return validateUsages(i,[`deriveKey`,`deriveBits`]),new CryptoKey(`secret`,!1,{name:`HKDF`},i,new Uint8Array(e))}throw new DOMException(`Unsupported format: ${e}`,`NotSupportedError`);case`ECDH`:case`ECDSA`:{let s=n.namedCurve;if(e===`raw`){let e=toUint8Array(t);return o===`ECDH`?i.length>0&&validateUsages(i,[`deriveKey`,`deriveBits`]):validateUsages(i,[`verify`]),new CryptoKey(`public`,r,{name:a.name,namedCurve:s},i,new Uint8Array(e))}if(e===`jwk`){let e=t;if(e.kty!==`EC`)throw new DOMException(`JWK kty must be "EC"`,`DataError`);if(e.d){let t=base64urlDecode(e.d),n=base64urlDecode(e.x),c=base64urlDecode(e.y),l=new Uint8Array(1+n.length+c.length);return l[0]=4,l.set(n,1),l.set(c,1+n.length),validateUsages(i,o===`ECDH`?[`deriveKey`,`deriveBits`]:[`sign`]),new CryptoKey(`private`,r,{name:a.name,namedCurve:s},i,{pub:l,priv:t})}else{let t=base64urlDecode(e.x),n=base64urlDecode(e.y),c=new Uint8Array(1+t.length+n.length);return c[0]=4,c.set(t,1),c.set(n,1+t.length),o===`ECDH`?i.length>0&&validateUsages(i,[`deriveKey`,`deriveBits`]):validateUsages(i,[`verify`]),new CryptoKey(`public`,r,{name:a.name,namedCurve:s},i,c)}}throw new DOMException(`Unsupported format: ${e}`,`NotSupportedError`)}default:throw new DOMException(`Unsupported algorithm: ${a.name}`,`NotSupportedError`)}}async exportKey(e,t){if(!t.extractable)throw new DOMException(`Key is not extractable`,`InvalidAccessError`);let n=t.algorithm.name.toUpperCase();if(e===`raw`){if(t.type===`secret`){let e=t._handle;return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}if(t.type===`public`&&(n===`ECDH`||n===`ECDSA`)){let e=t._handle;return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}throw new DOMException(`Cannot export in raw format`,`InvalidAccessError`)}if(e===`jwk`){if(t.type===`secret`){let e=t._handle,r={kty:`oct`,k:base64urlEncode(e),ext:t.extractable,key_ops:[...t.usages]};return n.startsWith(`AES-`)?r.alg=`A${t.algorithm.length}${n.replace(`AES-`,``)}`:n===`HMAC`&&(r.alg=`HS${t.algorithm.hash.name.replace(`SHA-`,``)}`),r}if((n===`ECDH`||n===`ECDSA`)&&(t.type===`public`||t.type===`private`)){let e=t.algorithm.namedCurve,n;n=t.type===`public`?t._handle:t._handle.pub;let r=(n.length-1)/2,i=n.slice(1,1+r),a=n.slice(1+r),o={kty:`EC`,crv:e,x:base64urlEncode(i),y:base64urlEncode(a),ext:t.extractable,key_ops:[...t.usages]};return t.type===`private`&&(o.d=base64urlEncode(t._handle.priv)),o}throw new DOMException(`JWK export not supported for ${n} ${t.type}`,`NotSupportedError`)}throw new DOMException(`Unsupported export format: ${e}`,`NotSupportedError`)}async encrypt(e,t,n){return await Yr,checkUsage(t,`encrypt`),this._encryptImpl(e,t,n)}async _encryptImpl(e,t,n){let r=normalizeAlgorithm$1(e),i=r.name.toUpperCase(),a=toUint8Array(n);switch(i){case`AES-CBC`:{let n=toUint8Array(e.iv),r=t._handle,i=r.length*8,o=Fr(`aes-${i}-cbc`,r,n),s=o.update(a),c=o.final(),l=new Uint8Array(s.length+c.length);return l.set(new Uint8Array(s),0),l.set(new Uint8Array(c),s.length),l.buffer}case`AES-CTR`:{let n=toUint8Array(e.counter),r=t._handle,i=r.length*8,o=Fr(`aes-${i}-ctr`,r,n),s=o.update(a),c=o.final(),l=new Uint8Array(s.length+c.length);return l.set(new Uint8Array(s),0),l.set(new Uint8Array(c),s.length),l.buffer}case`AES-GCM`:{let n=e,r=toUint8Array(n.iv),i=n.additionalData?toUint8Array(n.additionalData):void 0,o=t._handle,s=o.length*8,c=Fr(`aes-${s}-gcm`,o,r);i&&c.setAAD(i);let l=c.update(a),u=c.final(),d=c.getAuthTag(),f=new Uint8Array(l.length+u.length+d.length);return f.set(new Uint8Array(l),0),f.set(new Uint8Array(u),l.length),f.set(new Uint8Array(d),l.length+u.length),f.buffer}case`RSA-OAEP`:{let n=t.algorithm.hash.name,r=toNodeHashName(n),i=t._handle,o=e,s=o.label?toUint8Array(o.label):void 0,c=qr(r,i.pem,a,s);return c.buffer.slice(c.byteOffset,c.byteOffset+c.byteLength)}case`AES-KW`:{let e=t._handle;return aesKeyWrap(a,t=>this._aesEcbBlock(e,t,!0)).buffer}default:throw new DOMException(`Unsupported algorithm: ${r.name}`,`NotSupportedError`)}}async decrypt(e,t,n){return await Yr,checkUsage(t,`decrypt`),this._decryptImpl(e,t,n)}async _decryptImpl(e,t,n){let r=normalizeAlgorithm$1(e),i=r.name.toUpperCase(),a=toUint8Array(n);switch(i){case`AES-CBC`:{let n=toUint8Array(e.iv),r=t._handle,i=r.length*8,o=Ir(`aes-${i}-cbc`,r,n),s=o.update(a),c=o.final(),l=new Uint8Array(s.length+c.length);return l.set(new Uint8Array(s),0),l.set(new Uint8Array(c),s.length),l.buffer}case`AES-CTR`:{let n=toUint8Array(e.counter),r=t._handle,i=r.length*8,o=Ir(`aes-${i}-ctr`,r,n),s=o.update(a),c=o.final(),l=new Uint8Array(s.length+c.length);return l.set(new Uint8Array(s),0),l.set(new Uint8Array(c),s.length),l.buffer}case`AES-GCM`:{let n=e,r=toUint8Array(n.iv),i=(n.tagLength||128)/8,o=n.additionalData?toUint8Array(n.additionalData):void 0,s=t._handle,c=s.length*8,l=a.slice(0,a.length-i),u=a.slice(a.length-i),d=Ir(`aes-${c}-gcm`,s,r);d.setAuthTag(u),o&&d.setAAD(o);let f=d.update(l),p=d.final(),m=new Uint8Array(f.length+p.length);return m.set(new Uint8Array(f),0),m.set(new Uint8Array(p),f.length),m.buffer}case`RSA-OAEP`:{let n=t.algorithm.hash.name,r=toNodeHashName(n),i=t._handle,o=e,s=o.label?toUint8Array(o.label):void 0,c=Jr(r,i.pem,a,s);return c.buffer.slice(c.byteOffset,c.byteOffset+c.byteLength)}case`AES-KW`:{let e=t._handle;return aesKeyUnwrap(a,t=>this._aesEcbBlock(e,t,!1)).buffer}default:throw new DOMException(`Unsupported algorithm: ${r.name}`,`NotSupportedError`)}}_aesEcbBlock(e,t,n){let r=`aes-${e.length*8}-ecb`,i=new Uint8Array,a=n?Fr(r,e,i):Ir(r,e,i);a.setAutoPadding?.(!1);let o=a.update(t),s=a.final();if(s.length===0)return o;let c=new Uint8Array(o.length+s.length);return c.set(o,0),c.set(s,o.length),c}async sign(e,t,n){await Yr,checkUsage(t,`sign`);let r=normalizeAlgorithm$1(e),i=r.name.toUpperCase(),a=toUint8Array(n);switch(i){case`HMAC`:{let e=t.algorithm.hash.name,n=toNodeHashName(e),r=t._handle,i=Pr(n,r);i.update(a);let o=i.digest();return o.buffer.slice(o.byteOffset,o.byteOffset+o.byteLength)}case`RSASSA-PKCS1-V1_5`:{let e=t.algorithm.hash.name,n=toNodeHashName(e),r=t._handle,i=Lr(n);i.update(a);let o=i.sign(r.pem);return o.buffer.slice(o.byteOffset,o.byteOffset+o.byteLength)}case`ECDSA`:{let n=e,r=toNodeHashName(typeof n.hash==`string`?n.hash:n.hash.name),i=t.algorithm.namedCurve,o=t._handle,s=Ur(r,o.priv,a,i);return s.buffer.slice(s.byteOffset,s.byteOffset+s.byteLength)}case`RSA-PSS`:{let n=t.algorithm.hash.name,r=toNodeHashName(n),i=t._handle,o=e.saltLength??hashSize$1(n),s=Gr(r,i.pem,a,o);return s.buffer.slice(s.byteOffset,s.byteOffset+s.byteLength)}default:throw new DOMException(`Unsupported algorithm: ${r.name}`,`NotSupportedError`)}}async verify(e,t,n,r){await Yr,checkUsage(t,`verify`);let i=normalizeAlgorithm$1(e),a=i.name.toUpperCase(),o=toUint8Array(r),s=toUint8Array(n);switch(a){case`HMAC`:{let e=t.algorithm.hash.name,n=toNodeHashName(e),r=t._handle,i=Pr(n,r);i.update(o);let a=new Uint8Array(i.digest());if(a.length!==s.length)return!1;let c=0;for(let e=0;e<a.length;e++)c|=a[e]^s[e];return c===0}case`RSASSA-PKCS1-V1_5`:{let e=t.algorithm.hash.name,n=toNodeHashName(e),r=t._handle,i=Rr(n);return i.update(o),i.verify(r.pem,s)}case`ECDSA`:{let n=e,r=toNodeHashName(typeof n.hash==`string`?n.hash:n.hash.name),i=t.algorithm.namedCurve,a=t._handle;return Wr(r,a,s,o,i)}case`RSA-PSS`:{let n=t.algorithm.hash.name,r=toNodeHashName(n),i=t._handle,a=e.saltLength??hashSize$1(n);return Kr(r,i.pem,s,o,a)}default:throw new DOMException(`Unsupported algorithm: ${i.name}`,`NotSupportedError`)}}async _deriveBitsInternal(e,t,n){await Yr;let r=normalizeAlgorithm$1(e);switch(r.name.toUpperCase()){case`PBKDF2`:{let r=e,i=toNodeHashName(normalizeAlgorithm$1(r.hash).name),a=toUint8Array(r.salt),o=r.iterations,s=t._handle,c=zr(s,a,o,n/8,i);return c.buffer.slice(c.byteOffset,c.byteOffset+c.byteLength)}case`HKDF`:{let r=e,i=toNodeHashName(normalizeAlgorithm$1(r.hash).name),a=toUint8Array(r.salt),o=toUint8Array(r.info),s=t._handle;return Br(i,s,a,o,n/8)}case`ECDH`:{let r=e.public,i=t.algorithm.namedCurve,a=toNodeCurveName(i),o=Vr(a),s=t._handle;o.setPrivateKey(s.priv);let c=r._handle instanceof Uint8Array?r._handle:r._handle.pub,l=o.computeSecret(c),u=new Uint8Array(l);return n?u.buffer.slice(0,n/8):u.buffer.slice(u.byteOffset,u.byteOffset+u.byteLength)}default:throw new DOMException(`Unsupported algorithm: ${r.name}`,`NotSupportedError`)}}async deriveBits(e,t,n){return checkUsage(t,`deriveBits`),this._deriveBitsInternal(e,t,n)}async deriveKey(e,t,n,r,i){checkUsage(t,`deriveKey`);let a=normalizeAlgorithm$1(n),o,s=a.name.toUpperCase();if(s===`AES-CBC`||s===`AES-CTR`||s===`AES-GCM`)o=n.length;else if(s===`HMAC`){let e=n,t=normalizeAlgorithm$1(e.hash);o=e.length||hashSize$1(t.name)*8}else throw new DOMException(`Unsupported derived key algorithm: ${a.name}`,`NotSupportedError`);let c=await this._deriveBitsInternal(e,t,o);return this.importKey(`raw`,c,n,r,i)}async wrapKey(e,t,n,r){await Yr,checkUsage(n,`wrapKey`);let i=await this.exportKey(e,t),a=e===`jwk`?new TextEncoder().encode(JSON.stringify(i)):i;return this._encryptImpl(r,n,a)}async unwrapKey(e,t,n,r,i,a,o){await Yr,checkUsage(n,`unwrapKey`);let s=await this._decryptImpl(r,n,t),c=e===`jwk`?JSON.parse(new TextDecoder().decode(new Uint8Array(s))):s;return this.importKey(e,c,i,a,o)}};vn();const Xr=globalThis.crypto===void 0?null:globalThis.crypto;var CryptoPolyfill=class{subtle=new SubtleCrypto;getRandomValues(e){if(!(e instanceof Int8Array||e instanceof Uint8Array||e instanceof Int16Array||e instanceof Uint16Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Uint8ClampedArray||e instanceof BigInt64Array||e instanceof BigUint64Array))throw new DOMException(`The provided value is not of type '(Int8Array or Int16Array or Int32Array or Uint8Array or Uint8ClampedArray or Uint16Array or Uint32Array or BigInt64Array or BigUint64Array)'`,`TypeMismatchError`);if(e.byteLength>65536)throw new DOMException(`The ArrayBufferView's byte length exceeds the number of bytes of entropy available via this API (65536)`,`QuotaExceededError`);return fillRandomBytes(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),{webcrypto:Xr?.getRandomValues?Xr:null}),e}randomUUID(){if(Xr&&typeof Xr.randomUUID==`function`)return Xr.randomUUID();let e=new Uint8Array(16);this.getRandomValues(e),e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``);return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}};const Zr=Xr!==null&&Xr.subtle!==void 0&&typeof Xr.subtle.digest==`function`,Qr=Zr?Xr:new CryptoPolyfill;Zr?Xr.subtle:new SubtleCrypto;const $r=globalThis;(globalThis.crypto===void 0||globalThis.crypto.subtle===void 0)&&($r.crypto=Qr);var ei,ti=__esmMin(()=>{ei=t}),J,ni=__esmMin(()=>{ti(),J=ei});function findPnpManifest(e){let t=J.File.new_for_path(e);for(;t.has_parent(null);){let e=t.resolve_relative_path(`.pnp.cjs`);if(e.query_exists(null))return e.get_path();t=t.get_parent()}return null}function loadPnpManifest(e){let t=ri.get(e);if(t!==void 0)return t;let n=J.File.new_for_path(e),r;try{let[t,i]=n.load_contents(null);if(!t)return ri.set(e,null),null;r=new TextDecoder().decode(i)}catch{return ri.set(e,null),null}let i=extractRawRuntimeState(r);if(!i)return ri.set(e,null),null;let a=L.path_get_dirname(e),o=new Map,s=new Map;for(let[e,t]of i.packageRegistryData){let n=new Map;for(let[r,i]of t)n.set(r,i),i.discardFromLookup||s.set(i.packageLocation,{name:e,reference:r});o.set(e,n)}let c={rootDir:a,packages:o,locatorsByLocation:s};return ri.set(e,c),c}function extractRawRuntimeState(e){let t=e.indexOf(`const RAW_RUNTIME_STATE =`);if(t<0)return null;let n=e.indexOf(`'`,t);if(n<0)return null;let r=n+1;for(;r<e.length;){let t=e.charCodeAt(r);if(t===92){r+=2;continue}if(t===39)break;r++}if(r>=e.length)return null;let i=e.slice(n+1,r);i=i.replace(/\\\n/g,``);try{return JSON.parse(i)}catch{return null}}function findPackageOwning(e,t){let n=relativeFromRoot(e.rootDir,t);if(n===null)return null;let r=null;for(let t of e.locatorsByLocation.keys())n.startsWith(t)&&(r===null||t.length>r.length)&&(r=t);if(r===null)return null;let i=e.locatorsByLocation.get(r),a=e.packages.get(i.name)?.get(i.reference);return a?{locator:i,info:a}:null}function resolveBareViaPnp(e,t,n){let r=findPackageOwning(e,n);if(!r)return null;let{pkgName:i,subPath:a}=splitSpecifier(t),o=r.info.packageDependencies?.find(([e])=>e===i);if(!o)return null;let[,s]=o;if(s===null)return null;let c=e.packages.get(i)?.get(s);if(!c)return null;let l=c.packageLocation.startsWith(`/`)?J.File.new_for_path(c.packageLocation):J.File.new_for_path(e.rootDir).resolve_relative_path(stripLeadingDotSlash(c.packageLocation));return(a?l.resolve_relative_path(a):l).get_path()}function splitSpecifier(e){if(e.startsWith(`@`)){let t=e.indexOf(`/`);if(t<0)return{pkgName:e,subPath:``};let n=e.indexOf(`/`,t+1);return n<0?{pkgName:e,subPath:``}:{pkgName:e.slice(0,n),subPath:e.slice(n+1)}}let t=e.indexOf(`/`);return t<0?{pkgName:e,subPath:``}:{pkgName:e.slice(0,t),subPath:e.slice(t+1)}}function stripLeadingDotSlash(e){return e.startsWith(`./`)?e.slice(2):e}function relativeFromRoot(e,t){if(t===e)return`./`;let n=e.endsWith(`/`)?e:e+`/`;return t.startsWith(n)?`./`+t.slice(n.length):null}var ri,ii=__esmMin(()=>{ni(),be(),ri=new Map}),ai=__esmMin(()=>{globalThis.imports}),oi=__esmMin(()=>{ai()}),si,cli,ci=__esmMin(()=>{be(),si=new TextDecoder,cli=e=>{let[t,n,r,i]=L.spawn_command_line_sync(e);if(r.byteLength)throw Error(si.decode(r));return si.decode(n)}}),li,readJSON,ui=__esmMin(()=>{be(),li=new TextDecoder,readJSON=e=>{let[t,n]=L.file_get_contents(e);if(t)return JSON.parse(li.decode(n));throw Error(`Error on require "${e}"`)}}),di,fi=__esmMin(()=>{di=n}),pi,mi=__esmMin(()=>{fi(),pi=di});function existsSync(e){return typeof e!=`string`||e===``?!1:J.File.new_for_path(e).query_exists(null)}var hi=__esmMin(()=>{ni(),mi()}),gi,_i,getPathSeparator,vi=__esmMin(()=>{be(),ni(),{File:gi}=J,_i=__name((e,...t)=>{let n=gi.new_for_path(e);for(let e of t)n=n.resolve_relative_path(e);return n},`resolve`),getPathSeparator=()=>L.get_current_dir().startsWith(`/`)?`/`:`\\`}),yi=__esmMin(()=>{ci(),ui(),hi(),vi()});function isBuiltin(e){let t=e.startsWith(`node:`)?e.slice(5):e,n=t.split(`/`)[0];return bi.includes(t)||bi.includes(n)}function resolveSymlink(e){let t=e.query_info(`standard::`,J.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null);if(t.get_is_symlink()){let n=t.get_symlink_target(),r=e.get_parent();if(n&&r)return r.resolve_relative_path(n).get_path()}return e.get_path()}function tryJsExtension(e){let t=J.File.new_for_path(e+`.js`);return t.query_exists(null)?t:null}function hasExtension$1(e){return e.includes(`.`)}function isDirectory(e){return J.File.new_for_path(e).query_file_type(J.FileQueryInfoFlags.NONE,null)===J.FileType.DIRECTORY}function resolvePackageEntry(e){let t=_i(e,`package.json`);if(!t.query_exists(null))return null;let n=readJSON(t.get_path());if(n.exports!==void 0){let t=resolveExportsMap(n.exports,`.`,xi);if(t){let n=_i(e,t);if(n.query_exists(null))return n.get_path()}}let r=n.main||n.module||`index.js`,i=_i(e,r);if(i.query_exists(null))return i.get_path();if(!hasExtension$1(r)){let e=tryJsExtension(i.get_path());if(e)return e.get_path()}return null}function resolveExportsMap(e,t,n){if(typeof e==`string`)return t===`.`?e:void 0;if(typeof e!=`object`||!e)return;let r=e,i=Object.keys(r).some(e=>e===`.`||e.startsWith(`./`))?r[t]:t===`.`?r:void 0;if(i!=null)return pickConditionalValue(i,n)}function pickConditionalValue(e,t){if(typeof e==`string`)return e;if(typeof e!=`object`||!e)return;let n=e;for(let e of t)if(e in n){let r=pickConditionalValue(n[e],t);if(r!==void 0)return r}if(`default`in n&&!t.includes(`default`))return pickConditionalValue(n.default,t)}function splitBareSpecifier(e){if(e.startsWith(`@`)){let t=e.indexOf(`/`);if(t===-1)return{pkg:e,subpath:`.`};let n=e.indexOf(`/`,t+1);return n===-1?{pkg:e,subpath:`.`}:{pkg:e.slice(0,n),subpath:`.`+e.slice(n)}}let t=e.indexOf(`/`);return t===-1?{pkg:e,subpath:`.`}:{pkg:e.slice(0,t),subpath:`.`+e.slice(t)}}function fileUrlToPath(e){if(typeof e==`object`&&e&&`href`in e){let t=e;if(t.protocol&&t.protocol!==`file:`)throw TypeError(`The URL must use the file: protocol`);return L.filename_from_uri(t.href)[0]}return typeof e==`string`&&e.startsWith(`file:`)?L.filename_from_uri(e)[0]:String(e)}function resolveBareViaPnpFromCaller(e,t){let n=findPnpManifest(t);if(!n)return null;let r=loadPnpManifest(n);if(!r)return null;let i=resolveBareViaPnp(r,e,t);if(!i)return null;let a=J.File.new_for_path(i);return a.query_exists(null)?a:null}function resolveInNodeModules(e,t){let{pkg:n,subpath:r}=splitBareSpecifier(e),i=J.File.new_for_path(t);for(;i.has_parent(null);){let t=i.resolve_relative_path(`node_modules`);if(t.query_exists(null)){let i=t.resolve_relative_path(n);if(i.query_exists(null)){let e=i.resolve_relative_path(`package.json`);if(e.query_exists(null)){let t=readJSON(e.get_path());if(t.exports!==void 0){let e=resolveExportsMap(t.exports,r,xi);if(e!==void 0){let t=i.resolve_relative_path(e);if(t.query_exists(null))return t}}}let t=r===`.`?i:i.resolve_relative_path(r.slice(2));if(t.query_exists(null))return t;let n=t.get_basename();if(n&&!hasExtension$1(n)){let e=tryJsExtension(t.get_path());if(e)return e}}else{let n=t.resolve_relative_path(e);if(n.query_exists(null))return n;let r=n.get_basename();if(r&&!hasExtension$1(r)){let e=tryJsExtension(n.get_path());if(e)return e}}}i=i.get_parent()}throw Error(`Cannot find module "${e}" - not found in any node_modules directory`)}function resolveModulePath(e,t){if(isBuiltin(e))return e;let n;if(n=e.startsWith(`/`)?_i(e):e.startsWith(`.`)?_i(t,e):resolveBareViaPnpFromCaller(e,t)??resolveInNodeModules(e,t),e.startsWith(`/`)||e.startsWith(`.`)){if(!n.query_exists(null)){let e=n.get_basename();e&&!hasExtension$1(e)&&(n=tryJsExtension(n.get_path())??n)}if(!n.query_exists(null))throw Error(`Cannot find module "${e}"`)}let r=resolveSymlink(n),i=n.get_basename();if(i&&!hasExtension$1(i)){let t=resolvePackageEntry(r);if(t)return t;if(isDirectory(r))throw Error(`Cannot find module "${e}" - ${r} exists but has no resolvable package entry (its package.json exports/main point at a file that does not exist)`)}return r}function requireJsFile(e,t){if(e in t)return t[e];let n=J.File.new_for_path(e),r=n.get_parent().get_path(),i=n.get_basename();if(i.endsWith(`.mjs`))throw Error(`Cannot require .mjs files. Use import instead. Path: "${e}"`);if(i.endsWith(`.cjs`)){let e=_i(r,`__gjsify__`+i.replace(/\.cjs$/,`.js`));e.query_exists(null)&&e.delete(null),n.copy(e,J.FileCopyFlags.NONE,null,null),n=e,i=n.get_basename()}let a=globalThis.exports,o=globalThis.module,s={exports:{}};globalThis.exports=s.exports,globalThis.module=s;try{let{searchPath:n}=imports;n.unshift(r),imports[i.replace(/\.(js|cjs)$/,``)],n.shift();let a=s.exports;return t[e]=a,a}finally{globalThis.exports=a,globalThis.module=o}}function createRequire(e){let t=fileUrlToPath(e);if(!t.startsWith(`/`))throw TypeError(`The argument must be a file URL object, file URL string, or absolute path string. Received "${String(e)}"`);let n=L.path_get_dirname(t),r=Object.create(null),i=function require(e){let t=resolveModulePath(e,n);if(t in r)return r[t];if(t.endsWith(`.json`)){let e=readJSON(t);return r[t]=e,e}if(isBuiltin(e))throw Error(`createRequire: Cannot require builtin module "${e}" synchronously in GJS. Use import instead.`);return requireJsFile(t,r)};return i.resolve=function resolve(e){return resolveModulePath(e,n)},i.resolve.paths=e=>null,i.cache=r,i.extensions=Object.create(null),i.main=void 0,i}var bi,xi,Si=__esmMin(()=>{ii(),oi(),ni(),be(),yi(),bi=`assert.async_hooks.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.stream.string_decoder.sys.timers.tls.tty.url.util.v8.vm.wasi.worker_threads.zlib`.split(`.`),__name(hasExtension$1,`hasExtension`),xi=[`node`,`import`,`default`]}),Ci,wi,Ti=__esmMin(()=>{Ci=Object.defineProperty,wi=__name((e,t)=>{let n={};for(var r in e)Ci(n,r,{get:e[r],enumerable:!0});return t||Ci(n,Symbol.toStringTag,{value:`Module`}),n},`__exportAll`)});function assertPath(e){if(typeof e!=`string`)throw TypeError(`The "path" argument must be of type string. Received type `+typeof e)}function isPosixPathSeparator(e){return e===47}function isPathSeparator(e){return e===47||e===92}function isWindowsDeviceRoot(e){return e>=65&&e<=90||e>=97&&e<=122}function normalizeString(e,t,n,r){let i=``,a=0,o=-1,s=0,c;for(let l=0;l<=e.length;++l){if(l<e.length)c=e.charCodeAt(l);else if(r(c))break;else c=47;if(r(c)){if(!(o===l-1||s===1))if(o!==l-1&&s===2){if(i.length<2||a!==2||i.charCodeAt(i.length-1)!==46||i.charCodeAt(i.length-2)!==46){if(i.length>2){let e=i.lastIndexOf(n);e===-1?(i=``,a=0):(i=i.slice(0,e),a=i.length-1-i.lastIndexOf(n)),o=l,s=0;continue}else if(i.length===2||i.length===1){i=``,a=0,o=l,s=0;continue}}t&&(i.length>0?i+=`${n}..`:i=`..`,a=2)}else i.length>0?i+=n+e.slice(o+1,l):i=e.slice(o+1,l),a=l-o-1;o=l,s=0}else c===46&&s!==-1?++s:s=-1}return i}function _format(e,t){if(typeof t!=`object`||!t)throw TypeError(`The "pathObject" argument must be of type Object. Received type `+typeof t);let n=t,r=n.dir||n.root,i=n.base||(n.name||``)+formatExt(n.ext);return r?r===n.root?r+i:r+e+i:i}function formatExt(e){return e?`${e[0]===`.`?``:`.`}${e}`:``}var Ei=__esmMin(()=>{});function posixCwd(){if(typeof globalThis.process?.cwd==`function`)return globalThis.process.cwd();try{let e=globalThis.imports?.gi?.GLib;if(e?.get_current_dir)return e.get_current_dir()}catch{}return`/`}function resolve$1(...e){let t=``,n=!1;for(let r=e.length-1;r>=-1&&!n;r--){let i;if(r>=0){if(i=e[r],assertPath(i),i.length===0)continue}else i=posixCwd();t=`${i}/${t}`,n=i.charCodeAt(0)===47}return t=normalizeString(t,!n,`/`,isPosixPathSeparator),n?t.length>0?`/${t}`:`/`:t.length>0?t:`.`}function normalize$1(e){if(assertPath(e),e.length===0)return`.`;let t=e.charCodeAt(0)===47,n=e.charCodeAt(e.length-1)===47,r=normalizeString(e,!t,`/`,isPosixPathSeparator);return r.length===0&&!t&&(r=`.`),r.length>0&&n&&(r+=`/`),t?`/${r}`:r}function isAbsolute$1(e){return assertPath(e),e.length>0&&e.charCodeAt(0)===47}function join$1(...e){if(e.length===0)return`.`;let t;for(let n=0;n<e.length;++n){let r=e[n];assertPath(r),r.length>0&&(t===void 0?t=r:t+=`/${r}`)}return t===void 0?`.`:normalize$1(t)}function relative$1(e,t){if(assertPath(e),assertPath(t),e===t||(e=resolve$1(e),t=resolve$1(t),e===t))return``;let n=e.length,r=n-1,i=1,a=t.length-i,o=r<a?r:a,s=-1,c=0;for(;c<=o;++c){if(c===o){if(a>o){if(t.charCodeAt(i+c)===47)return t.slice(i+c+1);if(c===0)return t.slice(i+c)}else r>o&&(e.charCodeAt(1+c)===47?s=c:c===0&&(s=0));break}let n=e.charCodeAt(1+c);if(n!==t.charCodeAt(i+c))break;n===47&&(s=c)}let l=``;for(c=1+s+1;c<=n;++c)(c===n||e.charCodeAt(c)===47)&&(l.length===0?l+=`..`:l+=`/..`);return l.length>0?l+t.slice(i+s):(i+=s,t.charCodeAt(i)===47&&++i,t.slice(i))}function toNamespacedPath$1(e){return e}function dirname$1(e){if(assertPath(e),e.length===0)return`.`;let t=e.charCodeAt(0)===47,n=-1,r=!0;for(let t=e.length-1;t>=1;--t)if(e.charCodeAt(t)===47){if(!r){n=t;break}}else r=!1;return n===-1?t?`/`:`.`:t&&n===1?`//`:e.slice(0,n)}function basename$1(e,t){t!==void 0&&assertPath(t),assertPath(e);let n=0,r=-1,i=!0;if(t!==void 0&&t.length>0&&t.length<=e.length){if(t.length===e.length&&t===e)return``;let a=t.length-1,o=-1;for(let s=e.length-1;s>=0;--s){let c=e.charCodeAt(s);if(c===47){if(!i){n=s+1;break}}else o===-1&&(i=!1,o=s+1),a>=0&&(c===t.charCodeAt(a)?--a===-1&&(r=s):(a=-1,r=o))}return n===r?r=o:r===-1&&(r=e.length),e.slice(n,r)}else{for(let t=e.length-1;t>=0;--t)if(e.charCodeAt(t)===47){if(!i){n=t+1;break}}else r===-1&&(i=!1,r=t+1);return r===-1?``:e.slice(n,r)}}function extname$1(e){assertPath(e);let t=-1,n=0,r=-1,i=!0,a=0;for(let o=e.length-1;o>=0;--o){let s=e.charCodeAt(o);if(s===47){if(!i){n=o+1;break}continue}r===-1&&(i=!1,r=o+1),s===46?t===-1?t=o:a!==1&&(a=1):t!==-1&&(a=-1)}return t===-1||r===-1||a===0||a===1&&t===r-1&&t===n+1?``:e.slice(t,r)}function format$1(e){if(typeof e!=`object`||!e)throw TypeError(`The "pathObject" argument must be of type Object. Received type `+typeof e);return _format(`/`,e)}function parse$1(e){assertPath(e);let t={root:``,dir:``,base:``,ext:``,name:``};if(e.length===0)return t;let n=e.charCodeAt(0)===47,r;n?(t.root=`/`,r=1):r=0;let i=-1,a=0,o=-1,s=!0,c=e.length-1,l=0;for(;c>=r;--c){let t=e.charCodeAt(c);if(t===47){if(!s){a=c+1;break}continue}o===-1&&(s=!1,o=c+1),t===46?i===-1?i=c:l!==1&&(l=1):i!==-1&&(l=-1)}return i===-1||o===-1||l===0||l===1&&i===o-1&&i===a+1?o!==-1&&(a===0&&n?t.base=t.name=e.slice(1,o):t.base=t.name=e.slice(a,o)):(a===0&&n?(t.name=e.slice(1,i),t.base=e.slice(1,o)):(t.name=e.slice(a,i),t.base=e.slice(a,o)),t.ext=e.slice(i,o)),a>0?t.dir=e.slice(0,a-1):n&&(t.dir=`/`),t}var Di,Oi=__esmMin(()=>{Ti(),Ei(),Di=wi({basename:()=>basename$1,delimiter:()=>`:`,dirname:()=>dirname$1,extname:()=>extname$1,format:()=>format$1,isAbsolute:()=>isAbsolute$1,join:()=>join$1,normalize:()=>normalize$1,parse:()=>parse$1,relative:()=>relative$1,resolve:()=>resolve$1,sep:()=>`/`,toNamespacedPath:()=>toNamespacedPath$1}),__name(resolve$1,`resolve`),__name(normalize$1,`normalize`),__name(isAbsolute$1,`isAbsolute`),__name(join$1,`join`),__name(relative$1,`relative`),__name(toNamespacedPath$1,`toNamespacedPath`),__name(dirname$1,`dirname`),__name(basename$1,`basename`),__name(extname$1,`extname`),__name(format$1,`format`),__name(parse$1,`parse`)});function resolve(...e){let t=``,n=``,r=!1;for(let i=e.length-1;i>=-1;i--){let a;if(i>=0){if(a=e[i],assertPath(a),a.length===0)continue}else a=(t.length,typeof globalThis.process?.cwd==`function`?globalThis.process.cwd():`/`);let o=a.length,s=0,c=``,l=!1,u=a.charCodeAt(0);if(o>1)if(isPathSeparator(u))if(l=!0,isPathSeparator(a.charCodeAt(1))){let e=2,t=e;for(;e<o&&!isPathSeparator(a.charCodeAt(e));++e);if(e<o&&e!==t){let n=a.slice(t,e);for(t=e;e<o&&isPathSeparator(a.charCodeAt(e));++e);if(e<o&&e!==t){for(t=e;e<o&&!isPathSeparator(a.charCodeAt(e));++e);e===o?(c=`\\\\${n}\\${a.slice(t)}`,s=e):e!==t&&(c=`\\\\${n}\\${a.slice(t,e)}`,s=e)}}}else s=1;else isWindowsDeviceRoot(u)&&a.charCodeAt(1)===58&&(c=a.slice(0,2),s=2,o>2&&isPathSeparator(a.charCodeAt(2))&&(l=!0,s=3));else isPathSeparator(u)&&(s=1,l=!0);if(!(c.length>0&&t.length>0&&c.toLowerCase()!==t.toLowerCase())&&(t.length===0&&c.length>0&&(t=c),r||=(n=`${a.slice(s)}\\${n}`,l),t.length>0&&r))break}return n=normalizeString(n,!r,`\\`,isPathSeparator),t+(r?`\\`:``)+n||`.`}function normalize(e){assertPath(e);let t=e.length;if(t===0)return`.`;let n=0,r,i=!1,a=e.charCodeAt(0);if(t>1)if(isPathSeparator(a))if(i=!0,isPathSeparator(e.charCodeAt(1))){let i=2,a=i;for(;i<t&&!isPathSeparator(e.charCodeAt(i));++i);if(i<t&&i!==a){let o=e.slice(a,i);for(a=i;i<t&&isPathSeparator(e.charCodeAt(i));++i);if(i<t&&i!==a){for(a=i;i<t&&!isPathSeparator(e.charCodeAt(i));++i);if(i===t)return`\\\\${o}\\${e.slice(a)}\\`;i!==a&&(r=`\\\\${o}\\${e.slice(a,i)}`,n=i)}}}else n=1;else isWindowsDeviceRoot(a)&&e.charCodeAt(1)===58&&(r=e.slice(0,2),n=2,t>2&&isPathSeparator(e.charCodeAt(2))&&(i=!0,n=3));else if(isPathSeparator(a))return`\\`;let o;return o=n<t?normalizeString(e.slice(n),!i,`\\`,isPathSeparator):``,o.length===0&&!i&&(o=`.`),o.length>0&&isPathSeparator(e.charCodeAt(t-1))&&(o+=`\\`),r===void 0?i?o.length>0?`\\${o}`:`\\`:o.length>0?o:``:i?o.length>0?`${r}\\${o}`:`${r}\\`:o.length>0?r+o:r}function isAbsolute(e){assertPath(e);let t=e.length;if(t===0)return!1;let n=e.charCodeAt(0);return!!(isPathSeparator(n)||isWindowsDeviceRoot(n)&&t>2&&e.charCodeAt(1)===58&&isPathSeparator(e.charCodeAt(2)))}function join(...e){if(e.length===0)return`.`;let t,n;for(let r=0;r<e.length;++r){let i=e[r];assertPath(i),i.length>0&&(t===void 0?t=n=i:t+=`\\${i}`)}if(t===void 0)return`.`;let r=!0,i=0;if(isPathSeparator(n.charCodeAt(0))){++i;let e=n.length;e>1&&isPathSeparator(n.charCodeAt(1))&&(++i,e>2&&(isPathSeparator(n.charCodeAt(2))?++i:r=!1))}if(r){for(;i<t.length&&isPathSeparator(t.charCodeAt(i));++i);i>=2&&(t=`\\${t.slice(i)}`)}return normalize(t)}function relative(e,t){if(assertPath(e),assertPath(t),e===t)return``;let n=resolve(e),r=resolve(t);if(n===r||(e=n.toLowerCase(),t=r.toLowerCase(),e===t))return``;let i=0;for(;i<e.length&&e.charCodeAt(i)===92;++i);let a=e.length;for(;a-1>i&&e.charCodeAt(a-1)===92;--a);let o=a-i,s=0;for(;s<t.length&&t.charCodeAt(s)===92;++s);let c=t.length;for(;c-1>s&&t.charCodeAt(c-1)===92;--c);let l=c-s,u=o<l?o:l,d=-1,f=0;for(;f<=u;++f){if(f===u){if(l>u){if(t.charCodeAt(s+f)===92)return r.slice(s+f+1);if(f===2)return r.slice(s+f)}o>u&&(e.charCodeAt(i+f)===92?d=f:f===2&&(d=3));break}let n=e.charCodeAt(i+f);if(n!==t.charCodeAt(s+f))break;n===92&&(d=f)}if(f!==u&&d===-1)return r;let p=``;for(d===-1&&(d=0),f=i+d+1;f<=a;++f)(f===a||e.charCodeAt(f)===92)&&(p.length===0?p+=`..`:p+=`\\..`);return p.length>0?p+r.slice(s+d,c):(s+=d,r.charCodeAt(s)===92&&++s,r.slice(s,c))}function toNamespacedPath(e){if(typeof e!=`string`)return e;if(e.length===0)return``;let t=resolve(e);if(t.length>=3){if(t.charCodeAt(0)===92){if(t.charCodeAt(1)===92){let e=t.charCodeAt(2);if(e!==63&&e!==46)return`\\\\?\\UNC\\${t.slice(2)}`}}else if(isWindowsDeviceRoot(t.charCodeAt(0))&&t.charCodeAt(1)===58&&t.charCodeAt(2)===92)return`\\\\?\\${t}`}return e}function dirname(e){assertPath(e);let t=e.length;if(t===0)return`.`;let n=-1,r=-1,i=!0,a=0,o=e.charCodeAt(0);if(t>1)if(isPathSeparator(o)){if(n=a=1,isPathSeparator(e.charCodeAt(1))){let r=2,i=r;for(;r<t&&!isPathSeparator(e.charCodeAt(r));++r);if(r<t&&r!==i){for(i=r;r<t&&isPathSeparator(e.charCodeAt(r));++r);if(r<t&&r!==i){for(i=r;r<t&&!isPathSeparator(e.charCodeAt(r));++r);if(r===t)return e;r!==i&&(n=a=r+1)}}}}else isWindowsDeviceRoot(o)&&e.charCodeAt(1)===58&&(n=a=2,t>2&&isPathSeparator(e.charCodeAt(2))&&(n=a=3));else if(isPathSeparator(o))return e;for(let n=t-1;n>=a;--n)if(isPathSeparator(e.charCodeAt(n))){if(!i){r=n;break}}else i=!1;if(r===-1){if(n===-1)return`.`;r=n}return e.slice(0,r)}function basename(e,t){t!==void 0&&assertPath(t),assertPath(e);let n=0,r=-1,i=!0;if(e.length>=2&&isWindowsDeviceRoot(e.charCodeAt(0))&&e.charCodeAt(1)===58&&(n=2),t!==void 0&&t.length>0&&t.length<=e.length){if(t.length===e.length&&t===e)return``;let a=t.length-1,o=-1;for(let s=e.length-1;s>=n;--s){let c=e.charCodeAt(s);if(isPathSeparator(c)){if(!i){n=s+1;break}}else o===-1&&(i=!1,o=s+1),a>=0&&(c===t.charCodeAt(a)?--a===-1&&(r=s):(a=-1,r=o))}return n===r?r=o:r===-1&&(r=e.length),e.slice(n,r)}else{for(let t=e.length-1;t>=n;--t)if(isPathSeparator(e.charCodeAt(t))){if(!i){n=t+1;break}}else r===-1&&(i=!1,r=t+1);return r===-1?``:e.slice(n,r)}}function extname(e){assertPath(e);let t=0,n=-1,r=0,i=-1,a=!0,o=0;e.length>=2&&e.charCodeAt(1)===58&&isWindowsDeviceRoot(e.charCodeAt(0))&&(t=r=2);for(let s=e.length-1;s>=t;--s){let t=e.charCodeAt(s);if(isPathSeparator(t)){if(!a){r=s+1;break}continue}i===-1&&(a=!1,i=s+1),t===46?n===-1?n=s:o!==1&&(o=1):n!==-1&&(o=-1)}return n===-1||i===-1||o===0||o===1&&n===i-1&&n===r+1?``:e.slice(n,i)}function format(e){if(typeof e!=`object`||!e)throw TypeError(`The "pathObject" argument must be of type Object. Received type `+typeof e);return _format(`\\`,e)}function parse(e){assertPath(e);let t={root:``,dir:``,base:``,ext:``,name:``};if(e.length===0)return t;let n=e.length,r=0,i=e.charCodeAt(0);if(n>1)if(isPathSeparator(i)){if(r=1,isPathSeparator(e.charCodeAt(1))){let t=2,i=t;for(;t<n&&!isPathSeparator(e.charCodeAt(t));++t);if(t<n&&t!==i){for(i=t;t<n&&isPathSeparator(e.charCodeAt(t));++t);if(t<n&&t!==i){for(i=t;t<n&&!isPathSeparator(e.charCodeAt(t));++t);t===n?r=t:t!==i&&(r=t+1)}}}}else isWindowsDeviceRoot(i)&&e.charCodeAt(1)===58&&(r=2,n>2&&isPathSeparator(e.charCodeAt(2))&&(r=3));else if(isPathSeparator(i))return t.root=t.dir=e,t;r>0&&(t.root=e.slice(0,r));let a=-1,o=r,s=-1,c=!0,l=e.length-1,u=0;for(;l>=r;--l){if(i=e.charCodeAt(l),isPathSeparator(i)){if(!c){o=l+1;break}continue}s===-1&&(c=!1,s=l+1),i===46?a===-1?a=l:u!==1&&(u=1):a!==-1&&(u=-1)}return a===-1||s===-1||u===0||u===1&&a===s-1&&a===o+1?s!==-1&&(t.base=t.name=e.slice(o,s)):(t.name=e.slice(o,a),t.base=e.slice(o,s),t.ext=e.slice(a,s)),o>0&&o!==r?t.dir=e.slice(0,o-1):t.dir=t.root,t}var ki,Ai=__esmMin(()=>{Ti(),Ei(),ki=wi({basename:()=>basename,delimiter:()=>`;`,dirname:()=>dirname,extname:()=>extname,format:()=>format,isAbsolute:()=>isAbsolute,join:()=>join,normalize:()=>normalize,parse:()=>parse,relative:()=>relative,resolve:()=>resolve,sep:()=>`\\`,toNamespacedPath:()=>toNamespacedPath})}),ji=__exportAll$2({basename:()=>zi,default:()=>Gi,delimiter:()=>Wi,dirname:()=>Ri,extname:()=>Bi,format:()=>Vi,isAbsolute:()=>Pi,join:()=>Fi,normalize:()=>Ni,parse:()=>Hi,posix:()=>Di,relative:()=>Ii,resolve:()=>Mi,sep:()=>Ui,toNamespacedPath:()=>Li,win32:()=>ki}),Mi,Ni,Pi,Fi,Ii,Li,Ri,zi,Bi,Vi,Hi,Ui,Wi,Gi,Ki=__esmMin(()=>{Oi(),Ai(),{resolve:Mi,normalize:Ni,isAbsolute:Pi,join:Fi,relative:Ii,toNamespacedPath:Li,dirname:Ri,basename:zi,extname:Bi,format:Vi,parse:Hi,sep:Ui,delimiter:Wi}=Di,Gi={resolve:resolve$1,normalize:normalize$1,isAbsolute:isAbsolute$1,join:join$1,relative:relative$1,toNamespacedPath:toNamespacedPath$1,dirname:dirname$1,basename:basename$1,extname:extname$1,format:format$1,parse:parse$1,sep:`/`,delimiter:`:`,posix:Di,win32:ki}}),qi=__exportAll$2({__gjsifyModuleDir:()=>__gjsifyModuleDir$1,__gjsifyModuleFile:()=>__gjsifyModuleFile$1,__gjsifyModuleUrl:()=>__gjsifyModuleUrl,splitPackageSpec:()=>splitPackageSpec});function splitPackageSpec(e){let t=e.split(`/`),n=e.startsWith(`@`)?2:1;return{pkg:t.slice(0,n).join(`/`),subpath:t.slice(n).join(`/`)}}function bundleAnchorUrl(){let e=globalThis.__gjsifyBundleUrl;if(!e)throw Error(`gjsify: __gjsifyBundleUrl is not set — the bundle-URL banner did not run. The module-resolve shim is only valid in single-file app builds (gjsify build --app gjs|node).`);return e}function bundleResolve(){return Ji||=createRequire(bundleAnchorUrl()).resolve,Ji}function resolvePackageRoot(e){let t=bundleResolve();try{return Ri(t(`${e}/package.json`))}catch{let n=t(e),r=`/node_modules/${e}/`,i=n.lastIndexOf(r);return i>=0?n.slice(0,i+r.length-1):Ri(n)}}function resolveFile(e){let t=Yi.get(e);if(t!==void 0)return t;let n;try{let{pkg:t,subpath:r}=splitPackageSpec(e),i=resolvePackageRoot(t);n=r?Fi(i,r):i}catch{n=fileURLToPath(bundleAnchorUrl())}return Yi.set(e,n),n}function __gjsifyModuleFile$1(e){return resolveFile(e)}function __gjsifyModuleUrl(e){return pathToFileURL(resolveFile(e)).href}function __gjsifyModuleDir$1(e){return Ri(resolveFile(e))}var Ji,Yi,Xi=__esmMin(()=>{Si(),Be(),Ki(),Ji=null,Yi=new Map,__name(__gjsifyModuleFile$1,`__gjsifyModuleFile`),__name(__gjsifyModuleDir$1,`__gjsifyModuleDir`)}),Zi,__exportAll,Qi=__esmMin(()=>{Zi=Object.defineProperty,__exportAll=(e,t)=>{let n={};for(var r in e)Zi(n,r,{get:e[r],enumerable:!0});return t||Zi(n,Symbol.toStringTag,{value:`Module`}),n}});function normalizePath$1(e){return e instanceof URL||e instanceof ze?fileURLToPath(e):typeof e==`string`?e:e.toString()}function randomName(){return[...[,,,,,,]].map(()=>`0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ`[Math.floor(Math.random()*62)]).join(``)}var $i=__esmMin(()=>{Be(),__name(normalizePath$1,`normalizePath`)});function changed(e,t,n,r){switch(r){case J.FileMonitorEvent.CHANGES_DONE_HINT:this.emit(`change`,`change`,t.get_basename());break;case J.FileMonitorEvent.DELETED:case J.FileMonitorEvent.CREATED:case J.FileMonitorEvent.RENAMED:case J.FileMonitorEvent.MOVED_IN:case J.FileMonitorEvent.MOVED_OUT:this.emit(`change`,`rename`,t.get_basename());break}}function gioEventToNodeType(e){switch(e){case J.FileMonitorEvent.CHANGES_DONE_HINT:return`change`;case J.FileMonitorEvent.DELETED:case J.FileMonitorEvent.CREATED:case J.FileMonitorEvent.RENAMED:case J.FileMonitorEvent.MOVED_IN:case J.FileMonitorEvent.MOVED_OUT:return`rename`;default:return null}}async function*watchAsync(e,t){let n=t?.signal;if(n?.aborted)return;let r=normalizePath$1(e),i=J.File.new_for_path(r),a=J.Cancellable.new(),o;try{o=i.monitor(J.FileMonitorFlags.NONE,a)}catch{return}let s=[],c=[],l=!1;function enqueue(e){l||(c.length>0?c.shift().resolve({value:e,done:!1}):s.push(e))}function terminate(){if(!l)for(l=!0,a.is_cancelled()||a.cancel();c.length>0;)c.shift().resolve({value:void 0,done:!0})}let u=o.connect(`changed`,(e,t,n,r)=>{let i=gioEventToNodeType(r);i!==null&&enqueue({eventType:i,filename:t?.get_basename()??null})}),abortHandler=()=>terminate();n?.addEventListener(`abort`,abortHandler);try{for(;!l;){if(s.length>0){yield s.shift();continue}let e=await new Promise(e=>{c.push({resolve:e})});if(e.done)break;yield e.value}}finally{n?.removeEventListener(`abort`,abortHandler),o.disconnect(u),a.is_cancelled()||a.cancel()}}var ea,FSWatcher,ta=__esmMin(()=>{$i(),be(),ni(),je(),ea=new WeakMap,FSWatcher=class extends Ae{constructor(e,t,n){super(),(!t||typeof t!=`object`)&&(t={persistent:!0});let r=t.persistent!==!1,i=J.Cancellable.new(),a=normalizePath$1(e),o=J.File.new_for_path(a).monitor(J.FileMonitorFlags.NONE,i);o.connect(`changed`,changed.bind(this));let s=null;r&&(s=L.timeout_add(L.PRIORITY_LOW,2147483647,()=>L.SOURCE_CONTINUE)),ea.set(this,{persistent:r,cancellable:i,sourceId:s,watcher:o}),n&&this.on(`change`,n)}close(){let e=ea.get(this);e.cancellable.is_cancelled()||(e.cancellable.cancel(),e.sourceId!==null&&(L.source_remove(e.sourceId),e.sourceId=null))}ref(){let e=ea.get(this);return!e.persistent&&!e.cancellable.is_cancelled()&&(e.persistent=!0,e.sourceId=L.timeout_add(L.PRIORITY_LOW,2147483647,()=>L.SOURCE_CONTINUE)),this}unref(){let e=ea.get(this);return e.persistent&&(e.persistent=!1,e.sourceId!==null&&(L.source_remove(e.sourceId),e.sourceId=null)),this}}}),na=__exportAll$2({lchmod:()=>void 0,lchmodAsync:()=>lchmodAsync,lchmodSync:()=>void 0,lchown:()=>lchown,lchownAsync:()=>lchownAsync,lchownSync:()=>lchownSync,lutimes:()=>lutimes,lutimesAsync:()=>lutimesAsync,lutimesSync:()=>lutimesSync,utimes:()=>utimes,utimesAsync:()=>utimesAsync,utimesSync:()=>utimesSync});function toGLibDateTime(e){let t=e instanceof Date?e.getTime():typeof e==`bigint`?Number(e):typeof e==`string`?Date.parse(e):e*1e3;return L.DateTime.new_from_unix_utc(Math.floor(t/1e3))}function setTimestamps(e,t,n,r){let i=J.File.new_for_path(e),a=new J.FileInfo;a.set_modification_date_time(toGLibDateTime(n)),a.set_access_date_time(toGLibDateTime(t)),i.set_attributes_from_info(a,r,null)}function utimesSync(e,t,n){setTimestamps(normalizePath$1(e),t,n,J.FileQueryInfoFlags.NONE)}function utimes(e,t,n,r){Promise.resolve().then(()=>utimesSync(e,t,n)).then(()=>r(null),r)}async function utimesAsync(e,t,n){utimesSync(e,t,n)}function lutimesSync(e,t,n){setTimestamps(normalizePath$1(e),t,n,J.FileQueryInfoFlags.NOFOLLOW_SYMLINKS)}function lutimes(e,t,n,r){Promise.resolve().then(()=>lutimesSync(e,t,n)).then(()=>r(null),r)}async function lutimesAsync(e,t,n){lutimesSync(e,t,n)}function lchownSync(e,t,n){let r=normalizePath$1(e),i=J.File.new_for_path(r),a=new J.FileInfo;t!==-1&&a.set_attribute_uint32(`unix::uid`,t),n!==-1&&a.set_attribute_uint32(`unix::gid`,n),i.set_attributes_from_info(a,J.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null)}function lchown(e,t,n,r){Promise.resolve().then(()=>lchownSync(e,t,n)).then(()=>r(null),r)}async function lchownAsync(e,t,n){lchownSync(e,t,n)}function lchmodUnsupported(){let e=Error(`The lchmod() method is not implemented`);return e.code=`ERR_METHOD_NOT_IMPLEMENTED`,e}async function lchmodAsync(e,t){throw lchmodUnsupported()}var ra=__esmMin(()=>{$i(),be(),ni()});function isStdFd(e){return e===0||e===1||e===2}function stdinInput(){return ia||=pi.InputStream.new(0,!1),ia}function stdOutput(e){return aa[e]||(aa[e]=pi.OutputStream.new(e,!1)),aa[e]}function readStdFdAll(e){try{let t=e===0?stdinInput():pi.InputStream.new(e,!1),n=[],r=0;for(;;){let e=t.read_bytes(64*1024,null).get_data();if(!e||e.length===0)break;n.push(e),r+=e.length}return concat(n,r)}catch(t){if(e!==0)throw t;let[n,r]=J.File.new_for_path(`/dev/stdin`).load_contents(null);if(!n)throw t;return r}}function readStdFdSync(e,t,n,r){let i=(e===0?stdinInput():pi.InputStream.new(e,!1)).read_bytes(r,null).get_data();return i&&i.length>0?(new Uint8Array(t.buffer,t.byteOffset+n).set(i),i.length):0}function writeStdFdSync(e,t){return stdOutput(e).write_bytes(L.Bytes.new(t),null)}function concat(e,t){if(e.length===1)return e[0];let n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}var ia,aa,oa=__esmMin(()=>{be(),ni(),mi(),ia=null,aa={}});function getEncodingFromOptions(e={encoding:null,flag:`r`},t=`utf8`){return e===null?t:typeof e==`string`?e:typeof e==`object`&&typeof e.encoding==`string`?e.encoding:t}function encodeUint8Array(e,t){return e===`buffer`?I.from(t):new TextDecoder(e).decode(t)}function decode(e,t){if(t){let n=new TextDecoder(t),r=new TextEncoder;return n.decode(r.encode(e))}else return e}var sa=__esmMin(()=>{_e()});function createReadStream(e,t){return new ReadStream(e,t)}var ReadStream,ca=__esmMin(()=>{$i(),Ka(),Ga(),be(),ni(),_e(),sr(),ReadStream=class extends tr{bytesRead=0;path;pending=!0;fd=null;_ownFd=null;_autoCloseFd=!0;_positional=!1;_gioFile;_inputStream=null;_cancellable=new J.Cancellable;_start;_end;_pos;_reading=!1;_readAgain=!1;_lastSize=64*1024;close(e){this._cancellable.cancel(),this._release(),this.destroy(),e&&e(null)}constructor(e,t){let n=normalizePath$1(e);super({highWaterMark:t?.highWaterMark??64*1024,encoding:t?.encoding,objectMode:!1}),this.path=n,this._gioFile=J.File.new_for_path(n),this._start=t?.start??0,this._end=t?.end??1/0,this._pos=this._start,this._positional=t?.start!==void 0,typeof t?.fd==`number`&&(this._ownFd=t.fd,this.fd=t.fd,this._autoCloseFd=t.autoClose!==!1),this.once(`end`,()=>this._release())}_construct(e){if(this._ownFd!==null){this.pending=!1,e(),this.emit(`open`,this._ownFd),this.emit(`ready`);return}this._gioFile.read_async(L.PRIORITY_DEFAULT,this._cancellable,(t,n)=>{if(this.destroyed){e();return}try{this._inputStream=this._gioFile.read_finish(n),this.pending=!1,this.emit(`open`,0),this.emit(`ready`),this._start>0&&this._inputStream.can_seek()&&this._inputStream.seek(this._start,L.SeekType.SET,null),e()}catch(t){this._cancellable.is_cancelled()||e(t)}})}_read(e){if(this._lastSize=e,this._reading){this._readAgain=!0;return}this._doRead(e)}_doRead(e){if(this._ownFd!==null){if(this._reading||this.destroyed)return;this._reading=!0,L.timeout_add(L.PRIORITY_DEFAULT,0,()=>(this._reading=!1,this.destroyed||this._readThroughFd(e),L.SOURCE_REMOVE));return}let t=e;if(this._end!==1/0){let n=this._end-this._pos+1;if(n<=0){this.push(null);return}t=Math.min(e,n)}let n=this._inputStream;!n||this.destroyed||(this._reading=!0,n.read_bytes_async(t,L.PRIORITY_DEFAULT,this._cancellable,(e,t)=>{this._reading=!1;try{let e=n.read_bytes_finish(t).get_data();if(!e||e.length===0){this._readAgain=!1,this.push(null);return}this.bytesRead+=e.length,this._pos+=e.length,this.push(I.from(e)),this._readAgain&&!this._reading&&(this._readAgain=!1,this._doRead(this._lastSize))}catch(e){this._readAgain=!1,this._cancellable.is_cancelled()||this.destroy(e)}}))}_readThroughFd(e){try{let t=e;if(this._end!==1/0){let n=this._end-this._pos+1;if(n<=0){this._readAgain=!1,this.push(null);return}t=Math.min(e,n)}let n=Wa.getInstance(this._ownFd,`read`),r=I.alloc(t),i=n._readSync(r,0,t,this._positional?this._pos:null);if(i===0){this._readAgain=!1,this.push(null);return}this.bytesRead+=i,this._pos+=i,this.push(r.subarray(0,i))}catch(e){this._readAgain=!1,this.destroy(e)}}_release(){this._inputStream&&=(this._inputStream.close_async(L.PRIORITY_DEFAULT,null,()=>{}),null),this._releaseFd()}_releaseFd(){if(this._ownFd===null||!this._autoCloseFd)return;let e=this._ownFd;this._ownFd=null,this.fd=null;try{closeSync(e)}catch{}}_destroy(e,t){this._cancellable.cancel(),this._release(),t(e)}}});function openFlagValues(){return isWin32()?da:isDarwin()?ua:la}function stringFlagBits(e,t){switch(e){case`r`:return t.O_RDONLY;case`rs`:case`sr`:return t.O_RDONLY|t.O_SYNC;case`r+`:return t.O_RDWR;case`rs+`:case`sr+`:return t.O_RDWR|t.O_SYNC;case`w`:return t.O_TRUNC|t.O_CREAT|t.O_WRONLY;case`wx`:case`xw`:return t.O_TRUNC|t.O_CREAT|t.O_WRONLY|t.O_EXCL;case`w+`:return t.O_TRUNC|t.O_CREAT|t.O_RDWR;case`wx+`:case`xw+`:return t.O_TRUNC|t.O_CREAT|t.O_RDWR|t.O_EXCL;case`a`:return t.O_APPEND|t.O_CREAT|t.O_WRONLY;case`ax`:case`xa`:return t.O_APPEND|t.O_CREAT|t.O_WRONLY|t.O_EXCL;case`as`:case`sa`:return t.O_APPEND|t.O_CREAT|t.O_WRONLY|t.O_SYNC;case`a+`:return t.O_APPEND|t.O_CREAT|t.O_RDWR;case`ax+`:case`xa+`:return t.O_APPEND|t.O_CREAT|t.O_RDWR|t.O_EXCL;case`as+`:case`sa+`:return t.O_APPEND|t.O_CREAT|t.O_RDWR|t.O_SYNC;default:return}}function parseOpenFlags(e){let t=openFlagValues(),n;if(e==null)n=t.O_RDONLY;else if(typeof e==`number`)n=e;else{let r=stringFlagBits(e,t);if(r===void 0){let t=TypeError(`Unknown file open flag: ${e}`);throw t.code=`ERR_INVALID_ARG_VALUE`,t}n=r}let r=n&(t.O_RDONLY|t.O_WRONLY|t.O_RDWR);return{posix:n,readable:r===t.O_RDONLY||r===t.O_RDWR,writable:r===t.O_WRONLY||r===t.O_RDWR,append:(n&t.O_APPEND)!==0,creat:(n&t.O_CREAT)!==0,excl:(n&t.O_CREAT)!==0&&(n&t.O_EXCL)!==0,trunc:(n&t.O_TRUNC)!==0,nofollow:t.O_NOFOLLOW!==0&&(n&t.O_NOFOLLOW)!==0,directory:t.O_DIRECTORY!==0&&(n&t.O_DIRECTORY)!==0}}function normalizeMode(e,t){let n=e??t,r=n;if(typeof n==`string`){if(!/^[0-7]+$/.test(n))throw invalidMode(n);r=parseInt(n,8)}if(typeof r!=`number`)throw modeNotANumber(r);if(!Number.isInteger(r))throw modeOutOfRange(`an integer`,r);if(r<0||r>4294967295)throw modeOutOfRange(`>= 0 && <= 4294967295`,r);return r}function invalidMode(e){let t=TypeError(`The argument 'mode' must be a 32-bit unsigned integer or an octal string. Received '${e}'`);return t.code=`ERR_INVALID_ARG_VALUE`,t}function modeNotANumber(e){let t=e==null?String(e):`type ${typeof e} (${describeValue(e)})`,n=TypeError(`The "mode" argument must be of type number. Received ${t}`);return n.code=`ERR_INVALID_ARG_TYPE`,n}function describeValue(e){try{return typeof e==`object`?Object.prototype.toString.call(e):String(e)}catch{return`<unprintable>`}}function modeOutOfRange(e,t){let n=RangeError(`The value of "mode" is out of range. It must be ${e}. Received ${t}`);return n.code=`ERR_OUT_OF_RANGE`,n}var la,ua,da,fa=__esmMin(()=>{ce(),la={O_RDONLY:0,O_WRONLY:1,O_RDWR:2,O_CREAT:64,O_EXCL:128,O_NOCTTY:256,O_TRUNC:512,O_APPEND:1024,O_NONBLOCK:2048,O_DSYNC:4096,O_SYNC:1052672,O_DIRECTORY:65536,O_NOFOLLOW:131072},ua={O_RDONLY:0,O_WRONLY:1,O_RDWR:2,O_CREAT:512,O_EXCL:2048,O_NOCTTY:131072,O_TRUNC:1024,O_APPEND:8,O_NONBLOCK:4,O_DSYNC:4194304,O_SYNC:128,O_DIRECTORY:1048576,O_NOFOLLOW:256},da={O_RDONLY:0,O_WRONLY:1,O_RDWR:2,O_CREAT:256,O_EXCL:1024,O_NOCTTY:0,O_TRUNC:512,O_APPEND:8,O_NONBLOCK:0,O_DSYNC:0,O_SYNC:0,O_DIRECTORY:0,O_NOFOLLOW:0}});function createNodeError(e,t,n,r){return typeof e?.code==`string`?e:createNodeError$1(e,t,{path:n.toString(),dest:r?.toString()})}var pa=__esmMin(()=>{ce()}),Dirent,ma=__esmMin(()=>{ni(),Ki(),Dirent=class{name;parentPath;_isFile=!1;_isDirectory=!1;_isBlockDevice=!1;_isCharacterDevice=!1;_isSymbolicLink=!1;_isFIFO=!1;_isSocket=!1;_file;constructor(e,t,n,r){switch(t||=zi(e),this.name=t,this.parentPath=Ri(e),this._file=J.File.new_for_path(e),n??this._file.query_file_type(J.FileQueryInfoFlags.NONE,null)){case J.FileType.DIRECTORY:this._isDirectory=!0;break;case J.FileType.MOUNTABLE:break;case J.FileType.REGULAR:this._isFile=!0;break;case J.FileType.SYMBOLIC_LINK:case J.FileType.SHORTCUT:this._isSymbolicLink=!0;break;case J.FileType.SPECIAL:this._classifySpecialFile(e,r);break}}_classifySpecialFile(e,t){try{let n=t?.has_attribute(`unix::mode`)===!0?t:J.File.new_for_path(e).query_info(`unix::mode`,J.FileQueryInfoFlags.NONE,null),r=n.has_attribute(`unix::mode`)?n.get_attribute_uint32(`unix::mode`):0;if(r===0)return;switch(r&61440){case 24576:this._isBlockDevice=!0;break;case 8192:this._isCharacterDevice=!0;break;case 49152:this._isSocket=!0;break;case 4096:this._isFIFO=!0;break}}catch{}}isFile(){return this._isFile}isDirectory(){return this._isDirectory}isBlockDevice(){return this._isBlockDevice}isCharacterDevice(){return this._isCharacterDevice}isSymbolicLink(){return this._isSymbolicLink}isFIFO(){return this._isFIFO}isSocket(){return this._isSocket}}});function fsError(e,t,n,r){let i=`${e}: ${describe(e)}, ${t}`;n&&(i+=` '${n}'`),r&&(i+=` -> '${r}'`);let a=Error(i);return a.code=e,a.errno=ha[e]??-1,a.syscall=t,n&&(a.path=n),r&&(a.dest=r),a}function describe(e){switch(e){case`ENOENT`:return`no such file or directory`;case`EEXIST`:return`file already exists`;case`EACCES`:return`permission denied`;case`EISDIR`:return`illegal operation on a directory`;case`ENOTDIR`:return`not a directory`;case`EBADF`:return`bad file descriptor`;case`EPERM`:return`operation not permitted`;case`EINVAL`:return`invalid argument`;case`ELOOP`:return`too many symbolic links encountered`;case`ENAMETOOLONG`:return`name too long`;case`EMFILE`:return`too many open files`;case`ENFILE`:return`file table overflow`;case`EROFS`:return`read-only file system`;case`ESPIPE`:return`invalid seek`;case`ENXIO`:return`no such device or address`;default:return`i/o error`}}function hasProcFd(){return ga===null&&(ga=L.file_test(`/proc/self/fd`,L.FileTest.IS_DIR)),ga}function fdPath(e){return hasProcFd()?`/proc/self/fd/${e}`:null}function openFd(e,t,n){let r=L.open(e,t.posix,n);if(r<0)throw classifyOpenFailure(e,t);return r}function closeFd(e){L.close(e)}function classifyOpenFailure(e,t){let n=nameTooLong(e,`open`);if(n)return n;let r=J.File.new_for_path(e),i=null,a=!1;try{let e=r.query_info(`standard::type,standard::symlink-target,unix::mode,access::can-read,access::can-write`,J.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null);answered(e)?i=e:a=!0}catch{i=null}if(a)return refusalNotAboutThePath(e,t,r,null);if(i){if(t.excl)return fsError(`EEXIST`,`open`,e);if(i.get_file_type()===J.FileType.SYMBOLIC_LINK&&!t.nofollow){let n=walkSymlinkChain(r);if(n===`loop`)return fsError(`ELOOP`,`open`,e);if(n===`too-long`)return fsError(`ENAMETOOLONG`,`open`,e);if(n===`dangling`&&!t.creat)return fsError(`ENOENT`,`open`,e)}return i.get_file_type()===J.FileType.DIRECTORY&&t.writable?fsError(`EISDIR`,`open`,e):t.directory&&i.get_file_type()!==J.FileType.DIRECTORY?fsError(`ENOTDIR`,`open`,e):refusalNotAboutThePath(e,t,r,i)}if(ancestorIsNotADirectory(r))return fsError(`ENOTDIR`,`open`,e);if(!t.creat)return fsError(`ENOENT`,`open`,e);let o=r.get_parent();if(!o)return fsError(`ENOENT`,`open`,e);try{o.query_info(`standard::type`,J.FileQueryInfoFlags.NONE,null)}catch{return fsError(`ENOENT`,`open`,e)}return refusalNotAboutThePath(e,t,r,null)}function ancestorIsNotADirectory(e){for(let t=e.get_parent();t;t=t.get_parent()){let e;try{e=t.query_info(`standard::type`,J.FileQueryInfoFlags.NONE,null)}catch{continue}return answered(e)?e.get_file_type()!==J.FileType.DIRECTORY:!1}return!1}function answered(e){return e!==null&&e.has_attribute(`standard::type`)}function nameTooLong(e,t){let n=new TextEncoder;if(n.encode(e).length>4096)return fsError(`ENAMETOOLONG`,t,e);for(let r of e.split(`/`))if(n.encode(r).length>255)return fsError(`ENAMETOOLONG`,t,e);return null}function walkSymlinkChain(e){let t=new TextEncoder,n=e;for(let e=0;e<40;e++){let e;try{e=n.query_info(`standard::type,standard::symlink-target`,J.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null)}catch{return`dangling`}if(!answered(e)||e.get_file_type()!==J.FileType.SYMBOLIC_LINK)return`resolved`;let r=e.get_symlink_target();if(!r)return`dangling`;if(t.encode(r).length>4096)return`too-long`;let i=n.get_parent();n=r.startsWith(`/`)?J.File.new_for_path(r):i?.resolve_relative_path(r)??J.File.new_for_path(r)}return`loop`}function refusalNotAboutThePath(e,t,n,r){let i=L.open(`/dev/null`,0,0);if(i<0)return fsError(`EMFILE`,`open`,e);L.close(i);let a=r!==null&&(r.get_attribute_uint32(`unix::mode`)&146)==0;if((t.writable||t.creat)&&!a)try{if(n.query_filesystem_info(`filesystem::readonly`,null).get_attribute_boolean(`filesystem::readonly`))return fsError(`EROFS`,`open`,e)}catch{}return r&¬hingOnTheOtherEnd(t,r)?fsError(`ENXIO`,`open`,e):fsError(`EACCES`,`open`,e)}function nothingOnTheOtherEnd(e,t){if(!t.has_attribute(`unix::mode`))return!1;let n=t.get_attribute_uint32(`unix::mode`)&61440;if(!(n===8192||n===24576||n===4096))return!1;let permits=e=>t.has_attribute(e)&&t.get_attribute_boolean(e);return!(e.readable&&!permits(`access::can-read`)||e.writable&&!permits(`access::can-write`))}function classifyMkdirFailure(e){let t=nameTooLong(e,`mkdir`);if(t)return t;let n=J.File.new_for_path(e);try{return answered(n.query_info(`standard::type`,J.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null))?fsError(`EEXIST`,`mkdir`,e):fsError(`EACCES`,`mkdir`,e)}catch{}let r=n.get_parent();if(!r)return fsError(`ENOENT`,`mkdir`,e);try{let t=r.query_info(`standard::type`,J.FileQueryInfoFlags.NONE,null);if(answered(t)&&t.get_file_type()!==J.FileType.DIRECTORY)return fsError(`ENOTDIR`,`mkdir`,e)}catch{return fsError(`ENOENT`,`mkdir`,e)}return fsError(`EACCES`,`mkdir`,e)}function seekHandle(e){let t=_a.get(e);return t||(t=L.IOChannel.unix_new(e),t.set_encoding(null),t.set_buffered(!1),t.set_close_on_unref(!1),_a.set(e,t)),t}function input(e){let t=va.get(e);return t||(t=pi.InputStream.new(e,!1),va.set(e,t)),t}function output(e){let t=ya.get(e);return t||(t=pi.OutputStream.new(e,!1),ya.set(e,t)),t}function isSeekableFd(e,t){let n=ba.get(e);return n===void 0&&(n=probeSeekable(e,t),ba.set(e,n)),n}function probeSeekable(e,t){try{let n=J.File.new_for_path(fdPath(e)??t).query_info(`unix::mode`,J.FileQueryInfoFlags.NONE,null);if(n.has_attribute(`unix::mode`)){let e=n.get_attribute_uint32(`unix::mode`)&61440;if(e===4096||e===49152)return!1}}catch{}try{return seekHandle(e).seek_position(0,L.SeekType.CUR),!0}catch{return!1}}function seekFd(e,t){seekHandle(e).seek_position(t,L.SeekType.SET)}function tellFd(e){if(!hasProcFd())return null;try{let[t,n]=L.file_get_contents(`/proc/self/fdinfo/${e}`);if(!t)return null;let r=/^pos:\s*(\d+)/m.exec(new TextDecoder().decode(n));return r?Number(r[1]):null}catch{return null}}function readFd(e,t){return t<=0?new Uint8Array:input(e).read_bytes(t,null).get_data()??new Uint8Array}function writeFd(e,t){if(t.length===0)return 0;let[,n]=output(e).write_all(t,null);return n}function fsyncFd(e){output(e).flush(null),L.fsync(e)}function releaseFd(e){let t=ya.get(e);if(t)try{t.flush(null)}catch{}_a.delete(e),va.delete(e),ya.delete(e),ba.delete(e)}function sizeOfFd(e,t){let n=fdPath(e)??t,r=J.File.new_for_path(n).query_info(`standard::size`,J.FileQueryInfoFlags.NONE,null);return Number(r.get_size())}function truncateFd(e,t,n){let r=J.File.new_for_path(fdPath(e)??n),i;try{let e=r.append_to(J.FileCreateFlags.NONE,null);try{e.truncate(t,null)}finally{e.close(null)}return}catch(e){i=e}try{let e=r.open_readwrite(null);try{e.get_output_stream().truncate(t,null)}finally{e.close(null)}return}catch{}throw createNodeError(i,`ftruncate`,n)}var ha,ga,_a,va,ya,ba,xa=__esmMin(()=>{pa(),be(),ni(),mi(),ha={EPERM:-1,ENOENT:-2,EIO:-5,ENXIO:-6,EBADF:-9,EACCES:-13,EEXIST:-17,ENOTDIR:-20,EISDIR:-21,EINVAL:-22,ENFILE:-23,EMFILE:-24,ETXTBSY:-26,ENOSPC:-28,ESPIPE:-29,EROFS:-30,ENAMETOOLONG:-36,ENOTEMPTY:-39,ELOOP:-40},ga=null,_a=new Map,va=new Map,ya=new Map,ba=new Map});function populateFromInfo(e){let t=e.get_attribute_uint64(`time::access`),n=e.get_attribute_uint32(`time::access-usec`)||0,r=e.get_attribute_uint64(`time::modified`),i=e.get_attribute_uint32(`time::modified-usec`)||0,a=e.get_attribute_uint64(`time::changed`),o=e.get_attribute_uint32(`time::changed-usec`)||0,s=e.get_attribute_uint64(`time::created`),c=e.get_attribute_uint32(`time::created-usec`)||0,l=t*1e3+n/1e3,u=r*1e3+i/1e3,d=a?a*1e3+o/1e3:u,f=s?s*1e3+c/1e3:d;return{dev:e.get_attribute_uint32(`unix::device`)||0,ino:Number(e.get_attribute_uint64(`unix::inode`)||0),mode:e.get_attribute_uint32(`unix::mode`)||0,nlink:e.get_attribute_uint32(`unix::nlink`)||0,uid:e.get_attribute_uint32(`unix::uid`)||0,gid:e.get_attribute_uint32(`unix::gid`)||0,rdev:e.get_attribute_uint32(`unix::rdev`)||0,size:Number(e.get_size()||0),blksize:e.get_attribute_uint32(`unix::block-size`)||4096,blocks:Number(e.get_attribute_uint64(`unix::blocks`)||0),atimeMs:l,mtimeMs:u,ctimeMs:d,birthtimeMs:f,atime:new Date(l),mtime:new Date(u),ctime:new Date(d),birthtime:new Date(f)}}function statsFrom(e,t,n,r){if(!answered(e))throw fsError(`EACCES`,n,t);return r?new BigIntStats(e,t):new Stats(e,t)}var Sa,Stats,BigIntStats,Ca=__esmMin(()=>{ma(),xa(),ni(),Ki(),Sa=`standard::*,time::*,unix::*`,Stats=class extends Dirent{dev;ino;mode;nlink;uid;gid;rdev;size;blksize;blocks;atimeMs;mtimeMs;ctimeMs;birthtimeMs;atime;mtime;ctime;birthtime;_info;constructor(e,t,n){let r,i;e instanceof J.FileInfo?(r=e,i=t.toString(),n||=zi(i)):(i=e.toString(),typeof t==`string`&&(n=t),n||=zi(i),r=J.File.new_for_path(i).query_info(Sa,J.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null)),super(i,n,r.get_file_type(),r),this._info=r;let a=populateFromInfo(r);this.dev=a.dev,this.ino=a.ino,this.mode=a.mode,this.nlink=a.nlink,this.uid=a.uid,this.gid=a.gid,this.rdev=a.rdev,this.size=a.size,this.blksize=a.blksize,this.blocks=a.blocks,this.atimeMs=a.atimeMs,this.mtimeMs=a.mtimeMs,this.ctimeMs=a.ctimeMs,this.birthtimeMs=a.birthtimeMs,this.atime=a.atime,this.mtime=a.mtime,this.ctime=a.ctime,this.birthtime=a.birthtime}},BigIntStats=class extends Dirent{dev;ino;mode;nlink;uid;gid;rdev;size;blksize;blocks;atimeMs;mtimeMs;ctimeMs;birthtimeMs;atimeNs;mtimeNs;ctimeNs;birthtimeNs;atime;mtime;ctime;birthtime;_info;constructor(e,t,n){let r,i;e instanceof J.FileInfo?(r=e,i=t.toString(),n||=zi(i)):(i=e.toString(),typeof t==`string`&&(n=t),n||=zi(i),r=J.File.new_for_path(i).query_info(Sa,J.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null)),super(i,n,r.get_file_type(),r),this._info=r;let a=populateFromInfo(r);this.dev=BigInt(a.dev),this.ino=BigInt(a.ino),this.mode=BigInt(a.mode),this.nlink=BigInt(a.nlink),this.uid=BigInt(a.uid),this.gid=BigInt(a.gid),this.rdev=BigInt(a.rdev),this.size=BigInt(a.size),this.blksize=BigInt(a.blksize),this.blocks=BigInt(a.blocks),this.atimeMs=BigInt(Math.trunc(a.atimeMs)),this.mtimeMs=BigInt(Math.trunc(a.mtimeMs)),this.ctimeMs=BigInt(Math.trunc(a.ctimeMs)),this.birthtimeMs=BigInt(Math.trunc(a.birthtimeMs)),this.atimeNs=this.atimeMs*1000000n,this.mtimeNs=this.mtimeMs*1000000n,this.ctimeNs=this.ctimeMs*1000000n,this.birthtimeNs=this.birthtimeMs*1000000n,this.atime=a.atime,this.mtime=a.mtime,this.ctime=a.ctime,this.birthtime=a.birthtime}}});function statSync(e,t){let n=normalizePath$1(e);try{return statsFrom(J.File.new_for_path(n).query_info(Sa,J.FileQueryInfoFlags.NONE,null),n,`stat`,t?.bigint)}catch(e){if(t?.throwIfNoEntry===!1&&isNotFoundError(e))return;throw createNodeError(e,`stat`,n)}}function lstatSync(e,t){let n=normalizePath$1(e);try{return statsFrom(J.File.new_for_path(n).query_info(Sa,J.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null),n,`lstat`,t?.bigint)}catch(e){if(t?.throwIfNoEntry===!1&&isNotFoundError(e))return;throw createNodeError(e,`lstat`,n)}}function readdirSync(e,t){let n=normalizePath$1(e),r=J.File.new_for_path(n).enumerate_children(`standard::name,standard::type`,J.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null),i=[];try{let e=r.next_file(null);for(;e!==null;)i.push({name:e.get_name(),type:e.get_file_type()}),e=r.next_file(null)}finally{try{r.close(null)}catch{}}let a=[];for(let e of i){let r=Fi(n,e.name);if(t?.withFileTypes?a.push(new Dirent(r,e.name,e.type)):a.push(e.name),t?.recursive&&e.type===J.FileType.DIRECTORY){let n=readdirSync(r,t);for(let t of n)typeof t==`string`?a.push(Fi(e.name,t)):a.push(t)}}return a}function realpathSync(e){let t=normalizePath$1(e);return resolveEveryComponent(J.File.new_for_path(t),{left:40},t)}function resolveEveryComponent(e,t,n){let r=e.get_parent();return expandSymlinks(r===null?e:J.File.new_for_path(resolveEveryComponent(r,t,n)).get_child(e.get_basename()),t,n)}function expandSymlinks(e,t,n){let r=e;for(;;){let e=r.query_info(`standard::is-symlink,standard::symlink-target`,J.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null);if(!e.get_is_symlink())return r.get_path();if(--t.left<0)throw Error(`ELOOP: too many levels of symbolic links, realpath '${n}'`);let i=e.get_symlink_target(),a=r.get_parent(),o=L.path_is_absolute(i)?J.File.new_for_path(i):(a??r).resolve_relative_path(i);r=J.File.new_for_path(resolveEveryComponent(o,t,n))}}function symlinkSync(e,t,n){let r=normalizePath$1(t),i=normalizePath$1(e);J.File.new_for_path(r).make_symbolic_link(i,null)}function readFileSync(e,t={encoding:null,flag:`r`}){if(e instanceof Wa&&(e=e.fd),typeof e==`number`&&isStdFd(e))return encodeUint8Array(getEncodingFromOptions(t,`buffer`),readStdFdAll(e));if(typeof e==`number`)return encodeUint8Array(getEncodingFromOptions(t,`buffer`),Wa.getInstance(e,`read`)._readToEndSync());let n=normalizePath$1(e),r=J.File.new_for_path(n);try{let[e,i]=r.load_contents(null);if(!e)throw createNodeError(Error(`failed to read file`),`read`,n);return encodeUint8Array(getEncodingFromOptions(t,`buffer`),i)}catch(e){throw e.code&&typeof e.code==`string`?e:createNodeError(e,`read`,n)}}function mkdirSync(e,t){let n=!1,r;t!=null&&(typeof t==`object`?(t.recursive&&(n=t.recursive),t.mode!==void 0&&(r=t.mode)):r=t),e=normalizePath$1(e);let i=normalizeMode(r,511);if(n)return mkdirSyncRecursive(e,i);mkdirWithMode(e,i)}function mkdirWithMode(e,t){if(L.mkdir(e,t)!==0)throw classifyMkdirFailure(e)}function mkdirSyncRecursive(e,t){if(L.mkdir(e,t)===0)return e;let n=classifyMkdirFailure(e);if(n.code===`EEXIST`){if(L.file_test(e,L.FileTest.IS_DIR))return;throw n}if(n.code!==`ENOENT`)throw n;let r=Fi(e,`..`),i=J.File.new_for_path(r).get_path();if(i===e)throw n;let a=mkdirSyncRecursive(i,t);return mkdirWithMode(e,t),a??e}function rmdirSync(e,t){let n=normalizePath$1(e),r=J.File.new_for_path(n);try{if(r.query_info(`standard::type`,J.FileQueryInfoFlags.NONE,null).get_file_type()!==J.FileType.DIRECTORY)throw createNodeError(Object.assign(Error(),{code:4}),`rmdir`,n);if(r.enumerate_children(`standard::name`,J.FileQueryInfoFlags.NONE,null).next_file(null)!==null)throw createNodeError(Object.assign(Error(),{code:5}),`rmdir`,n);r.delete(null)}catch(e){throw e.code&&typeof e.code==`string`?e:createNodeError(e,`rmdir`,n)}}function unlinkSync(e){let t=normalizePath$1(e),n=J.File.new_for_path(t);try{n.delete(null)}catch(e){throw createNodeError(e,`unlink`,t)}}function writeWholeFile(e,t,n,r){let i=getEncodingFromOptions(n,`utf8`),a=typeof n==`object`&&n?n:{},o=typeof t==`string`?I.from(t,i||`utf8`):t;if(typeof e==`number`||e instanceof Wa){if(typeof e==`number`&&isStdFd(e)){writeStdFdSync(e,o);return}Wa.getInstance(e,`write`)._writeSync(o,null);return}let s=new Wa({path:normalizePath$1(e),flags:a.flag??r,mode:a.mode??438});try{s._writeSync(o,null)}finally{s._closeSync()}}function writeFileSync(e,t,n){writeWholeFile(e,t,n??null,`w`)}function renameSync(e,t){let n=normalizePath$1(e),r=normalizePath$1(t),i=J.File.new_for_path(n),a=J.File.new_for_path(r);try{i.move(a,J.FileCopyFlags.OVERWRITE,null,null)}catch(e){throw createNodeError(e,`rename`,n,r)}}function copyFileSync(e,t,n){let r=normalizePath$1(e),i=normalizePath$1(t),a=J.File.new_for_path(r),o=J.File.new_for_path(i),s=J.FileCopyFlags.NONE;n&&!(n&1)?s=J.FileCopyFlags.OVERWRITE:n||(s=J.FileCopyFlags.OVERWRITE);try{a.copy(o,s,null,null)}catch(e){throw createNodeError(e,`copyfile`,r,i)}}function accessSync(e,t){let n=normalizePath$1(e),r=J.File.new_for_path(n);try{let e=r.query_info(`access::*`,J.FileQueryInfoFlags.NONE,null);if(t!==void 0&&t!==0){let r={code:14,message:`permission denied, access '${n}'`};if(t&4&&!e.get_attribute_boolean(`access::can-read`)||t&2&&!e.get_attribute_boolean(`access::can-write`)||t&1&&!e.get_attribute_boolean(`access::can-execute`))throw createNodeError(r,`access`,n)}}catch(e){throw e.code&&typeof e.code==`string`?e:createNodeError(e,`access`,n)}}function appendFileSync(e,t,n){writeWholeFile(e,t,n??null,`a`)}function readlinkSync(e,t){let n=normalizePath$1(e),r=J.File.new_for_path(n);try{let e=r.query_info(`standard::symlink-target`,J.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null).get_symlink_target();if(!e)throw Object.assign(Error(`EINVAL: invalid argument, readlink '${n}'`),{code:`EINVAL`,errno:-22,syscall:`readlink`,path:n});return(typeof t==`string`?t:t?.encoding)===`buffer`?I.from(e):e}catch(e){throw typeof e.code==`string`?e:createNodeError(e,`readlink`,n)}}function linkSync(e,t){let n=normalizePath$1(e),r=normalizePath$1(t);if(J.File.new_for_path(n).query_file_type(J.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null)===J.FileType.UNKNOWN)throw Object.assign(Error(`ENOENT: no such file or directory, link '${n}' -> '${r}'`),{code:`ENOENT`,errno:-2,syscall:`link`,path:n,dest:r});if(J.File.new_for_path(r).query_file_type(J.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null)!==J.FileType.UNKNOWN)throw Object.assign(Error(`EEXIST: file already exists, link '${n}' -> '${r}'`),{code:`EEXIST`,errno:-17,syscall:`link`,path:n,dest:r});let i=``;try{let[,,e,t]=L.spawn_sync(null,[`ln`,`--`,n,r],null,L.SpawnFlags.SEARCH_PATH,null);if(i=e?new TextDecoder().decode(e).trim():``,!L.spawn_check_wait_status(t))throw Error(`ln exited non-zero (${t})`);return}catch(e){throw i===``&&e instanceof Error&&(i=e.message),Object.assign(Error(`EPERM: operation not permitted, link '${n}' -> '${r}'`+(i?` (${i})`:``)),{code:`EPERM`,errno:-1,syscall:`link`,path:n,dest:r})}}function truncateSync(e,t){let n=normalizePath$1(e),r=J.File.new_for_path(n);try{let e=r.open_readwrite(null);try{e.get_output_stream().truncate(Math.max(0,t??0),null)}finally{e.close(null)}}catch(e){throw createNodeError(e,`truncate`,n)}}function chmodSync(e,t){let n=normalizePath$1(e),r=normalizeMode(t);try{J.File.new_for_path(n).set_attribute_uint32(`unix::mode`,r,J.FileQueryInfoFlags.NONE,null)}catch(e){throw createNodeError(e,`chmod`,n)}}function chownSync(e,t,n){let r=normalizePath$1(e);try{let e=J.File.new_for_path(r),i=new J.FileInfo;t!==-1&&i.set_attribute_uint32(`unix::uid`,t),n!==-1&&i.set_attribute_uint32(`unix::gid`,n),e.set_attributes_from_info(i,J.FileQueryInfoFlags.NONE,null)}catch(e){throw createNodeError(e,`chown`,r)}}function watch(e,t,n){return new FSWatcher(normalizePath$1(e),t,n)}function openSync(e,t,n){return new Wa({path:e,flags:t,mode:n})}function mkdtempSync(e,t){let n=getEncodingFromOptions(t);return decode(mkdtempAt(e),n)}function mkdtempAt(e){for(let t=0;t<64;t++){let t=e+randomName();if(L.mkdir(t,448)===0)return t;let n=classifyMkdirFailure(t);if(n.code!==`EEXIST`)throw n.syscall=`mkdtemp`,n}throw fsError(`EEXIST`,`mkdtemp`,e+`XXXXXX`)}function rmSync(e,t){let n=normalizePath$1(e),r=J.File.new_for_path(n),i=t?.recursive||!1,a=t?.force||!1,o;try{o=r.query_file_type(J.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null)}catch(t){if(a&&isNotFoundError(t))return;throw createNodeError(t,`rm`,e)}if(o===J.FileType.SYMBOLIC_LINK){try{r.delete(null)}catch(t){if(a&&isNotFoundError(t))return;throw createNodeError(t,`rm`,e)}return}if(o===J.FileType.DIRECTORY){let r=readdirSync(e);if(!i&&r.length)throw createNodeError(Object.assign(Error(),{code:5}),`rm`,e);for(let e of r)rmSync(Fi(n,e),t)}try{r.delete(null)}catch(t){if(a&&isNotFoundError(t))return;throw createNodeError(t,`rm`,e)}}var wa=__esmMin(()=>{sa(),$i(),ta(),oa(),fa(),ma(),pa(),xa(),Ca(),Ga(),be(),ni(),Ki(),_e(),yi(),realpathSync.native=realpathSync});function makeEEXIST(e){let t=Error(`ERR_FS_CP_EEXIST: file already exists, copyfile '${e}'`);return t.code=`ERR_FS_CP_EEXIST`,t.syscall=`copyfile`,t.path=e,t}function makeEISDIR(e){let t=Error(`ERR_FS_EISDIR: illegal operation on a directory, copyfile '${e}'`);return t.code=`ERR_FS_EISDIR`,t.syscall=`copyfile`,t.path=e,t}function makeENOTDIR(e,t){let n=Error(`ENOTDIR: not a directory, copyfile '${e}' -> '${t}'`);return n.code=`ENOTDIR`,n.syscall=`copyfile`,n.path=e,n.dest=t,n}function makeSYMLINKLOOP(e,t){let n=Error(`ELOOP: too many levels of symbolic links, copyfile '${e}' -> '${t}'`);return n.code=`ELOOP`,n.syscall=`copyfile`,n.path=e,n.dest=t,n}function queryCopyFlags(e){let t=e.force??!0,n=J.FileCopyFlags.NONE;return t&&(n|=J.FileCopyFlags.OVERWRITE),e.preserveTimestamps&&(n|=J.FileCopyFlags.TARGET_DEFAULT_MODIFIED_TIME),e.dereference||(n|=J.FileCopyFlags.NOFOLLOW_SYMLINKS),n}function copyOneSyncFile(e,t,n,r,i){let a=i.force??!0;try{if(t.query_info(`standard::type`,J.FileQueryInfoFlags.NONE,null).get_file_type()===J.FileType.DIRECTORY)throw makeENOTDIR(n,r);if(!a){if(i.errorOnExist)throw makeEEXIST(r);return}}catch(e){if(typeof e.code==`string`)throw e}let o=queryCopyFlags(i);try{e.copy(t,o,null,null)}catch(e){throw createNodeError(e,`copyfile`,n,r)}}function cpOneDirSync(e,t,n,r,i){let a=n.endsWith(`/`)?``:`/`;if(r.startsWith(n+a)&&r!==n)throw makeSYMLINKLOOP(n,r);if(t.query_exists(null))try{if(t.query_info(`standard::type`,J.FileQueryInfoFlags.NONE,null).get_file_type()!==J.FileType.DIRECTORY)throw makeENOTDIR(r,n)}catch(e){if(typeof e.code==`string`)throw e}else try{t.make_directory_with_parents(null)}catch(e){throw createNodeError(e,`mkdir`,r)}let o;try{o=e.enumerate_children(`standard::name,standard::type,standard::is-symlink`,i.dereference?J.FileQueryInfoFlags.NONE:J.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null)}catch(e){throw createNodeError(e,`scandir`,n)}let s=o.next_file(null);for(;s!==null;){let e=s.get_name(),t=Fi(n,e),a=Fi(r,e),c=i.filter;if(c&&!c(t,a)){s=o.next_file(null);continue}cpSyncInternal(t,a,i),s=o.next_file(null)}}function cpSyncInternal(e,t,n){let r=J.File.new_for_path(e),i=J.File.new_for_path(t),a;try{a=r.query_info(`standard::type,standard::is-symlink`,n.dereference?J.FileQueryInfoFlags.NONE:J.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null)}catch(t){throw createNodeError(t,`stat`,e)}if(a.get_file_type()===J.FileType.DIRECTORY){if(!n.recursive)throw makeEISDIR(e);cpOneDirSync(r,i,e,t,n)}else copyOneSyncFile(r,i,e,t,n)}function cpSync(e,t,n){let r=normalizePath$1(e),i=normalizePath$1(t),a=n??{},o=J.File.new_for_path(r),s=a.filter;if(!(s&&!s(r,i))){try{if(o.query_info(`standard::type`,a.dereference?J.FileQueryInfoFlags.NONE:J.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null).get_file_type()===J.FileType.DIRECTORY&&!a.recursive)throw makeEISDIR(r)}catch(e){throw typeof e.code==`string`?e:createNodeError(e,`stat`,r)}cpSyncInternal(r,i,a)}}function cp(e,t,n,r){let i,a;typeof n==`function`?(a=n,i={}):(a=r,i=n);let o=i.filter;if(o){Promise.resolve(o(normalizePath$1(e),normalizePath$1(t))).then(n=>{if(!n){a(null);return}try{cpPromises(e,t,i).then(()=>a(null)).catch(a)}catch(e){a(e)}}).catch(a);return}Promise.resolve().then(()=>{try{cpSync(e,t,i),a(null)}catch(e){a(e)}})}async function cpPromisesDir(e,t,n){let r=e.endsWith(`/`)?``:`/`;if(t.startsWith(e+r)&&t!==e)throw makeSYMLINKLOOP(e,t);let i=J.File.new_for_path(t);if(!i.query_exists(null))try{i.make_directory_with_parents(null)}catch(e){throw createNodeError(e,`mkdir`,t)}let a=J.File.new_for_path(e),o;try{o=a.enumerate_children(`standard::name,standard::type`,n.dereference?J.FileQueryInfoFlags.NONE:J.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null)}catch(t){throw createNodeError(t,`scandir`,e)}let s=o.next_file(null);for(;s!==null;){let r=s.get_name(),i=Fi(e,r),a=Fi(t,r),c=n.filter;if(c&&!await Promise.resolve(c(i,a))){s=o.next_file(null);continue}await cpPromises(i,a,n),s=o.next_file(null)}}async function cpPromises(e,t,n={}){let r=normalizePath$1(e),i=normalizePath$1(t),a=J.File.new_for_path(r),o;try{o=a.query_info(`standard::type`,n.dereference?J.FileQueryInfoFlags.NONE:J.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null)}catch(e){throw createNodeError(e,`stat`,r)}if(o.get_file_type()===J.FileType.DIRECTORY){if(!n.recursive)throw makeEISDIR(r);await cpPromisesDir(r,i,n)}else copyOneSyncFile(a,J.File.new_for_path(i),r,i,n)}var Ta=__esmMin(()=>{$i(),pa(),ni(),Ki()});function _openDir(e){let t=J.File.new_for_path(e),n;try{n=t.enumerate_children(Ea,J.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null)}catch(t){throw createNodeError(t,`opendir`,e)}return new Dir(e,n)}function opendirSync(e){return _openDir(normalizePath$1(e))}function opendir(e,t,n){let r;if(r=typeof t==`function`?t:n,typeof r!=`function`)throw TypeError(`The "callback" argument must be of type function`);Promise.resolve().then(()=>{try{let t=opendirSync(e);r(null,t)}catch(e){r(e,null)}})}async function opendirAsync(e,t){return new Promise((t,n)=>{let r=normalizePath$1(e),i=J.File.new_for_path(r);i.enumerate_children_async(Ea,J.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,L.PRIORITY_DEFAULT,null,(e,a)=>{try{let e=i.enumerate_children_finish(a);t(new Dir(r,e))}catch(e){n(createNodeError(e,`opendir`,r))}})})}var Ea,Dir,Da=__esmMin(()=>{$i(),ma(),pa(),be(),ni(),Ea=`standard::name,standard::type,standard::is-symlink,standard::size,standard::symlink-target,unix::uid,unix::gid,unix::mode,time::modified,time::access,time::created`,Dir=class{path;_enumerator;_closed=!1;constructor(e,t){this.path=e,this._enumerator=t}_assertOpen(){if(this._closed){let e=Error(`Directory handle was closed`);throw e.code=`ERR_DIR_CLOSED`,e}}readSync(){this._assertOpen();try{let e=this._enumerator.next_file(null);if(e===null)return null;let t=e.get_name(),n=e.get_file_type();return new Dirent(this.path.endsWith(`/`)?this.path+t:this.path+`/`+t,t,n)}catch(e){throw createNodeError(e,`readdir`,this.path)}}read(e){if(e!==void 0){if(typeof e!=`function`)throw TypeError(`The "callback" argument must be of type function`);try{this._assertOpen();let t=this.readSync();Promise.resolve().then(()=>e(null,t))}catch(t){Promise.resolve().then(()=>e(t,null))}return}return new Promise((e,t)=>{try{this._assertOpen(),e(this.readSync())}catch(e){t(e)}})}closeSync(){this._assertOpen(),this._closed=!0;try{this._enumerator.close(null)}catch{}this._enumerator=null}close(e){if(e!==void 0){if(typeof e!=`function`)throw TypeError(`The "callback" argument must be of type function`);try{this.closeSync(),Promise.resolve().then(()=>e(null))}catch(t){Promise.resolve().then(()=>e(t))}return}return new Promise((e,t)=>{try{this.closeSync(),e()}catch(e){t(e)}})}async*[Symbol.asyncIterator](){try{for(;;){let e=await this.read();if(e===null)break;yield e}}finally{this._closed||await this.close()}}}});function segmentToRegexSrc(e){let t=/^([!*+?@])\((.+)\)$/.exec(e);if(t){let[,e,n]=t,r=n.split(`|`).map(e=>segmentToRegexSrc(e)),i=`(?:`+r.join(`|`)+`)`;switch(e){case`!`:return`(?!(?:`+r.join(`|`)+`))[^/]*`;case`*`:return i+`*`;case`+`:return i+`+`;case`?`:return i+`?`;case`@`:return i}}let n=``,r=0;for(;r<e.length;){let t=e[r];if(t===`*`){n+=`[^/]*`,r++;continue}if(t===`?`){n+=`[^/]`,r++;continue}if(t===`[`){let t=e.indexOf(`]`,r+1);if(t===-1){n+=`\\[`,r++;continue}n+=e.slice(r,t+1),r=t+1;continue}if(t===`{`){let t=e.indexOf(`}`,r+1);if(t===-1){n+=`\\{`,r++;continue}let i=e.slice(r+1,t).split(`,`).map(e=>segmentToRegexSrc(e.trim()));n+=`(?:`+i.join(`|`)+`)`,r=t+1;continue}`.+^$|()[]{}`.includes(t)?n+=`\\`+t:n+=t,r++}return n}function globToRegex(e){e=e.replace(/\/+/g,`/`).replace(/^\.\//,``);let t=e.split(`/`),n=[];for(let e=0;e<t.length;e++){let r=t[e],i=e===t.length-1;r===`**`?i?n.length>0&&n[n.length-1]===`/`?(n.pop(),n.push(`(?:/.+)?`)):n.push(`(?:.+)?`):n.push(`(?:[^/]+/)*`):(n.push(segmentToRegexSrc(r)),i||n.push(`/`))}return RegExp(`^(?:`+n.join(``)+`)$`)}function buildExcludePredicate(e){if(!e)return null;if(typeof e==`function`)return e;let t=(Array.isArray(e)?e:[e]).map(e=>globToRegex(e));return e=>t.some(t=>t.test(e))}function matchAll(e,t,n){let r=globToRegex(e),i=buildExcludePredicate(n),a;try{a=readdirSync(t,{recursive:!0})}catch{return[]}let o=[`.`,...a],s=[];for(let e of o){let t=e.replace(/\\/g,`/`);r.test(t)&&(i&&i(t)||s.push(e))}return s}function globSync(e,t){let n=Array.isArray(e)?e:[e],r=t?.cwd?normalizePath$1(t.cwd):globalThis.process?.cwd?.()??`/`,i=t?.exclude,a=new Set,o=[];for(let e of n)for(let t of matchAll(e,r,i))a.has(t)||(a.add(t),o.push(t));return o}function glob(e,t,n){let r,i;typeof t==`function`?(i=t,r={}):(i=n,r=t||{}),Promise.resolve().then(()=>{try{let t=globSync(e,r);i(null,t)}catch(e){i(e,[])}})}async function*globAsync(e,t){let n=globSync(e,t);for(let e of n)yield e}var Oa=__esmMin(()=>{$i(),wa()});function buildStatFs(e){let t=Number(e.get_attribute_uint64(`filesystem::size`)??0),n=Number(e.get_attribute_uint64(`filesystem::free`)??0),r=Math.floor(t/Aa),i=Math.floor(n/Aa);return{type:0,bsize:Aa,blocks:r,bfree:i,bavail:i,files:0,ffree:0}}function buildBigIntStatFs(e){let t=BigInt(e.get_attribute_uint64(`filesystem::size`)??0),n=BigInt(e.get_attribute_uint64(`filesystem::free`)??0),r=BigInt(Aa),i=t/r,a=n/r;return{type:0n,bsize:r,blocks:i,bfree:a,bavail:a,files:0n,ffree:0n}}function statfsSync(e,t){let n=J.File.new_for_path(normalizePath$1(e)).query_filesystem_info(ka,null);return t?.bigint===!0?buildBigIntStatFs(n):buildStatFs(n)}function queryFsInfoAsync(e,t){return new Promise((n,r)=>{let i=J.File.new_for_path(normalizePath$1(e));i.query_filesystem_info_async(ka,L.PRIORITY_DEFAULT,null,(e,a)=>{try{let e=i.query_filesystem_info_finish(a);n(t?buildBigIntStatFs(e):buildStatFs(e))}catch(e){r(e)}})})}function statfs(e,t,n){let r=typeof t==`function`?t:n;queryFsInfoAsync(e,(typeof t==`function`?{}:t)?.bigint===!0).then(e=>r(null,e),e=>r(e,null))}async function statfsAsync(e,t){return queryFsInfoAsync(e,t?.bigint===!0)}var ka,Aa,ja=__esmMin(()=>{$i(),be(),ni(),ka=[`filesystem::size`,`filesystem::free`].join(`,`),Aa=4096});async function mkdir$1(e,t){return mkdirSync(normalizePath$1(e),t)}async function readFile$1(e,t={encoding:null,flag:`r`}){if(e instanceof Wa||typeof e==`number`){let n=Wa.getInstance(e,`read`);return encodeUint8Array(getEncodingFromOptions(t,`buffer`),n._readToEndSync())}let n=normalizePath$1(e),r=J.File.new_for_path(n),i,a;try{[i,a]=await new Promise((e,t)=>{r.load_contents_async(null,(n,i)=>{try{e(r.load_contents_finish(i))}catch(e){t(e)}})})}catch(e){throw createNodeError(e,`open`,n)}if(!i)throw createNodeError(Error(`failed to read file`),`open`,n);return encodeUint8Array(getEncodingFromOptions(t,`buffer`),a)}async function mkdtemp(e,t){let n=getEncodingFromOptions(t);return decode(mkdtempAt(e),n)}async function writeFile$2(e,t,n){writeFileSync(e,typeof t==`string`||t instanceof Uint8Array?t:String(t),n??null)}async function rmdir$1(e,t){let n=normalizePath$1(e),r=J.File.new_for_path(n);if((await new Promise((e,t)=>{r.query_info_async(`standard::type`,J.FileQueryInfoFlags.NONE,L.PRIORITY_DEFAULT,null,(i,a)=>{try{e(r.query_info_finish(a))}catch(e){t(createNodeError(e,`rmdir`,n))}})})).get_file_type()!==J.FileType.DIRECTORY)throw createNodeError(Object.assign(Error(),{code:4}),`rmdir`,n);if((await new Promise((e,t)=>{r.enumerate_children_async(`standard::name`,J.FileQueryInfoFlags.NONE,L.PRIORITY_DEFAULT,null,(i,a)=>{try{e(r.enumerate_children_finish(a))}catch(e){t(createNodeError(e,`rmdir`,n))}})})).next_file(null)!==null)throw createNodeError(Object.assign(Error(),{code:5}),`rmdir`,n);await new Promise((e,t)=>{r.delete_async(L.PRIORITY_DEFAULT,null,(i,a)=>{try{r.delete_finish(a),e()}catch(e){t(createNodeError(e,`rmdir`,n))}})})}async function unlink$1(e){let t=normalizePath$1(e),n=J.File.new_for_path(t);await new Promise((e,r)=>{n.delete_async(L.PRIORITY_DEFAULT,null,(i,a)=>{try{n.delete_finish(a),e()}catch(e){r(createNodeError(e,`unlink`,t))}})})}async function open$2(e,t,n){return new Wa({path:e,flags:t,mode:n})}async function write$1(e,t,n,r,i){return typeof t==`string`?_writeStr(e,t,n,r):_writeBuf(e,t,n,r,i)}async function _writeBuf(e,t,n,r,i){return{bytesWritten:(await Wa.getInstance(e,`write`).write(t,n,r,i)).bytesWritten,buffer:t}}async function _writeStr(e,t,n,r){return{bytesWritten:(await Wa.getInstance(e,`write`).write(t,n,r)).bytesWritten,buffer:t}}function queryInfoAsync(e,t,n,r){let i=normalizePath$1(e);return new Promise((e,a)=>{let o=J.File.new_for_path(i);o.query_info_async(Sa,t,L.PRIORITY_DEFAULT,null,(t,s)=>{try{e(statsFrom(o.query_info_finish(s),i,n,r?.bigint))}catch(e){a(createNodeError(e,n,i))}})})}async function stat$1(e,t){return queryInfoAsync(e,J.FileQueryInfoFlags.NONE,`stat`,t)}async function lstat$1(e,t){return queryInfoAsync(e,J.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,`lstat`,t)}async function readdir$1(e,t){try{return readdirSync(e,t)}catch(t){throw createNodeError(t,`scandir`,e)}}async function realpath$1(e){return realpathSync(e)}async function symlink$1(e,t,n){let r=normalizePath$1(t),i=normalizePath$1(e);return new Promise((e,t)=>{let n=J.File.new_for_path(r);n.make_symbolic_link_async(i,L.PRIORITY_DEFAULT,null,(a,o)=>{try{n.make_symbolic_link_finish(o),e()}catch(e){t(createNodeError(e,`symlink`,i,r))}})})}async function rm$1(e,t){let n=normalizePath$1(e),r=J.File.new_for_path(n),i=t?.recursive||!1,a=t?.force||!1,o;try{o=r.query_file_type(J.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null)}catch(t){if(a)return;throw createNodeError(t,`rm`,e)}if(o===J.FileType.SYMBOLIC_LINK){await new Promise((t,n)=>{r.delete_async(L.PRIORITY_DEFAULT,null,(i,o)=>{try{r.delete_finish(o),t()}catch(r){if(a){t();return}n(createNodeError(r,`rm`,e))}})});return}if(o===J.FileType.DIRECTORY){let r=await readdir$1(e,{withFileTypes:!0});if(!i&&r.length)throw createNodeError(Object.assign(Error(),{code:5}),`rm`,e);for(let e of r)typeof e!=`string`&&await rm$1(Fi(n,e.name),t)}await new Promise((t,n)=>{r.delete_async(L.PRIORITY_DEFAULT,null,(i,o)=>{try{r.delete_finish(o),t()}catch(r){if(a){t();return}n(createNodeError(r,`rm`,e))}})})}async function rename$1(e,t){renameSync(e,t)}async function copyFile$1(e,t,n){copyFileSync(e,t,n)}async function access$1(e,t){accessSync(e,t)}async function appendFile$1(e,t,n){appendFileSync(e,t,n)}async function readlink$1(e,t){return readlinkSync(e,t)}async function truncate$1(e,t){truncateSync(e,t)}async function chmod$1(e,t){chmodSync(e,t)}async function chown$1(e,t,n){chownSync(e,t,n)}async function link$1(e,t){linkSync(e,t)}var Ma,Na,Pa=__esmMin(()=>{Qi(),sa(),$i(),ta(),ra(),Ka(),pa(),Ca(),Ga(),wa(),Ta(),Da(),Oa(),ja(),be(),ni(),Ki(),Ma=__exportAll({access:()=>access$1,appendFile:()=>appendFile$1,chmod:()=>chmod$1,chown:()=>chown$1,copyFile:()=>copyFile$1,cp:()=>cpPromises,default:()=>Na,fchmod:()=>fchmodAsync,fchown:()=>fchownAsync,fdatasync:()=>fdatasyncAsync,fstat:()=>fstatAsync,fsync:()=>fsyncAsync,ftruncate:()=>ftruncateAsync,futimes:()=>futimesAsync,glob:()=>globAsync,lchmod:()=>lchmodAsync,lchown:()=>lchownAsync,link:()=>link$1,lstat:()=>lstat$1,lutimes:()=>lutimesAsync,mkdir:()=>mkdir$1,mkdtemp:()=>mkdtemp,open:()=>open$2,openAsBlob:()=>openAsBlob,opendir:()=>opendirAsync,readFile:()=>readFile$1,readdir:()=>readdir$1,readlink:()=>readlink$1,readv:()=>readvAsync,realpath:()=>realpath$1,rename:()=>rename$1,rm:()=>rm$1,rmdir:()=>rmdir$1,stat:()=>stat$1,statfs:()=>statfsAsync,symlink:()=>symlink$1,truncate:()=>truncate$1,unlink:()=>unlink$1,utimes:()=>utimesAsync,watch:()=>watchAsync,write:()=>write$1,writeFile:()=>writeFile$2,writev:()=>writevAsync}),__name(mkdir$1,`mkdir`),__name(readFile$1,`readFile`),__name(writeFile$2,`writeFile`),__name(rmdir$1,`rmdir`),__name(unlink$1,`unlink`),__name(open$2,`open`),__name(write$1,`write`),__name(stat$1,`stat`),__name(lstat$1,`lstat`),__name(readdir$1,`readdir`),__name(realpath$1,`realpath`),__name(symlink$1,`symlink`),__name(rm$1,`rm`),__name(rename$1,`rename`),__name(copyFile$1,`copyFile`),__name(access$1,`access`),__name(appendFile$1,`appendFile`),__name(readlink$1,`readlink`),__name(truncate$1,`truncate`),__name(chmod$1,`chmod`),__name(chown$1,`chown`),__name(link$1,`link`),Na={readFile:readFile$1,mkdir:mkdir$1,mkdtemp,realpath:realpath$1,readdir:readdir$1,writeFile:writeFile$2,rmdir:rmdir$1,unlink:unlink$1,open:open$2,write:write$1,rm:rm$1,lstat:lstat$1,symlink:symlink$1,stat:stat$1,rename:rename$1,copyFile:copyFile$1,access:access$1,appendFile:appendFile$1,readlink:readlink$1,truncate:truncate$1,chmod:chmod$1,chown:chown$1,link:link$1,cp:cpPromises,opendir:opendirAsync,glob:globAsync,watch:watchAsync,statfs:statfsAsync,utimes:utimesAsync,lutimes:lutimesAsync,lchown:lchownAsync,lchmod:lchmodAsync,fstat:fstatAsync,ftruncate:ftruncateAsync,fdatasync:fdatasyncAsync,fsync:fsyncAsync,fchmod:fchmodAsync,fchown:fchownAsync,futimes:futimesAsync,readv:readvAsync,writev:writevAsync,openAsBlob}});function withHandle(e,t,n){try{return Wa.getInstance(e,t)}catch(e){return Promise.resolve().then(()=>n(e)),null}}function parseOptsCb(e,t){return typeof e==`function`?{options:{},callback:e}:{options:e??{},callback:t}}function statImpl(e,t,n,r,i){let a=normalizePath$1(e),o=J.File.new_for_path(a);o.query_info_async(Sa,t,L.PRIORITY_DEFAULT,null,(e,t)=>{try{i(null,statsFrom(o.query_info_finish(t),a,n,r?.bigint))}catch(e){i(createNodeError(e,n,a))}})}function stat(e,t,n){let{options:r,callback:i}=parseOptsCb(t,n);statImpl(e,J.FileQueryInfoFlags.NONE,`stat`,r,i)}function lstat(e,t,n){let{options:r,callback:i}=parseOptsCb(t,n);statImpl(e,J.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,`lstat`,r,i)}function readdir(e,t,n){let{options:r,callback:i}=parseOptsCb(t,n);Promise.resolve().then(()=>{try{i(null,readdirSync(e,r))}catch(t){i(createNodeError(t,`readdir`,e))}})}function realpath(e,t,n){let{callback:r}=parseOptsCb(t,n);Promise.resolve().then(()=>{try{r(null,realpathSync(e))}catch(e){r(e)}})}function symlink(e,t,n,r){let i=typeof n==`function`?n:r;if(typeof i!=`function`)throw TypeError(`Callback must be a function. Received `+typeof i);let a=normalizePath$1(t),o=normalizePath$1(e),s=J.File.new_for_path(a);s.make_symbolic_link_async(o,L.PRIORITY_DEFAULT,null,(e,t)=>{try{s.make_symbolic_link_finish(t),i(null)}catch(e){i(createNodeError(e,`symlink`,o,a))}})}function open$1(e,...t){let n,r,i;switch(t.length){case 1:i=t[0];break;case 2:n=t[0],i=t[1];break;case 3:n=t[0],r=t[1],i=t[2];break;default:break}open$2(e,n,r).then(e=>{i(null,e.fd)}).catch(e=>{i(e,-1)})}function write(e,t,...n){let r=withHandle(e,`write`,e=>{let r=n[n.length-1];typeof r==`function`&&(typeof t==`string`?r(e,0,``):r(e,0,I.from([])))});if(!r)return;if(typeof t==`string`){let e=n.pop(),i=n[0],a=n[1];r.write(t,i,a).then(t=>{e(null,t.bytesWritten,t.buffer)}).catch(t=>{e(t,0,``)});return}let i=n[n.length-1],a=n[0],o=n[1],s=n[2];r.write(t,a,o,s).then(e=>{i(null,e.bytesWritten,e.buffer)}).catch(e=>{i(e,0,I.from([]))})}function read(e,...t){let n=t[t.length-1],r=withHandle(e,`read`,e=>{typeof n==`function`&&n(e,0,I.from([]))});if(!r)return;let i,a,o,s;if(!(t.length<=1))if(typeof t[0]==`object`&&!ArrayBuffer.isView(t[0])){let e=t[0];i=e.buffer,a=e.offset,o=e.length,s=e.position}else i=t[0],a=t[1],o=t[2],s=t[3];r.read(i,a,o,s).then(e=>{n(null,e.bytesRead,e.buffer)}).catch(e=>{n(e,0,I.from([]))})}function close$1(e,t){let done=e=>{typeof t==`function`&&t(e)},n=withHandle(e,`close`,done);n&&n.close().then(()=>done(null)).catch(e=>done(e))}function rm(e,...t){let n={},r=t[t.length-1];t.length>=2&&(n=t[0]),rm$1(e,n).then(()=>{r(null)}).catch(e=>{r(e)})}function rename(e,t,n){Promise.resolve().then(()=>{try{renameSync(e,t),n(null)}catch(e){n(e)}})}function copyFile(e,t,n,r){let i=typeof n==`function`?0:n,a=typeof n==`function`?n:r;Promise.resolve().then(()=>{try{copyFileSync(e,t,i),a(null)}catch(e){a(e)}})}function access(e,t,n){let r=typeof t==`function`?void 0:t,i=typeof t==`function`?t:n;Promise.resolve().then(()=>{try{accessSync(e,r),i(null)}catch(e){i(e)}})}function appendFile(e,t,n,r){let i=typeof n==`function`?n:r,a=typeof n==`function`?void 0:n;Promise.resolve().then(()=>{try{appendFileSync(e,t,a),i(null)}catch(e){i(e)}})}function readlink(e,t,n){let r=typeof t==`function`?t:n,i=typeof t==`function`?void 0:t;Promise.resolve().then(()=>{try{r(null,readlinkSync(e,i))}catch(e){r(e,``)}})}function truncate(e,t,n){let r=typeof t==`function`?0:t,i=typeof t==`function`?t:n;Promise.resolve().then(()=>{try{truncateSync(e,r),i(null)}catch(e){i(e)}})}function chmod(e,t,n){Promise.resolve().then(()=>{try{chmodSync(e,t),n(null)}catch(e){n(e)}})}function chown(e,t,n,r){Promise.resolve().then(()=>{try{chownSync(e,t,n),r(null)}catch(e){r(e)}})}function mkdir(e,t,n){let r=typeof t==`function`?t:n,i=typeof t==`function`?void 0:t;Promise.resolve().then(()=>{try{mkdirSync(e,i),r(null)}catch(e){r(e)}})}function rmdir(e,t,n){let r=typeof t==`function`?t:n,i=typeof t==`function`?void 0:t;Promise.resolve().then(()=>{try{rmdirSync(e,i),r(null)}catch(e){r(e)}})}function readFile(e,t,n){let r=typeof t==`function`?t:n,i=typeof t==`function`?void 0:t;Promise.resolve().then(()=>{try{let t=typeof i==`string`?{encoding:i,flag:`r`}:{encoding:i?.encoding??null,flag:i?.flag??`r`};r(null,readFileSync(e,t))}catch(e){r(e,null)}})}function writeFile$1(e,t,n,r){let i=typeof n==`function`?n:r,a=typeof n==`function`?void 0:n;Promise.resolve().then(()=>{try{writeFileSync(e,t,a),i(null)}catch(e){i(e)}})}function link(e,t,n){Promise.resolve().then(()=>{try{linkSync(e,t),n(null)}catch(e){n(e)}})}function unlink(e,t){let n=normalizePath$1(e);Promise.resolve().then(()=>{L.unlink(n),t(null)})}var Fa=__esmMin(()=>{$i(),pa(),Ca(),Ga(),wa(),Pa(),be(),ni(),_e(),__name(open$1,`open`),__name(close$1,`close`),__name(writeFile$1,`writeFile`)});function toPathIfFileURL(e){return normalizePath$1(e)}function createWriteStream(e,t){return new WriteStream(e,t)}var Ia,La,WriteStream,Ra=__esmMin(()=>{$i(),fa(),Fa(),sr(),Ia=Symbol(`kIsPerformingIO`),La=Symbol(`kIoDone`),WriteStream=class extends nr{close(e,t=null){let done=t=>{typeof e==`function`&&e(t)};if(this.fd===null||!this._autoClose)this.fd=null,done(t);else{let e=this._fdFromHandle;close$1(this.fd,n=>{let r=e&&n?.code===`EBADF`?null:n;done(r||t)}),this.fd=null}}bytesWritten=0;path;pending;fd=null;flags=`w`;mode=438;pos=void 0;_autoClose=!0;_fdFromHandle=!1;[Ia]=!1;constructor(e,t={}){super(t),this.path=toPathIfFileURL(e),t.flags!==void 0&&(this.flags=t.flags),t.mode!==void 0&&(this.mode=normalizeMode(t.mode,438)),t.start!==void 0&&(this.pos=t.start),t.encoding&&this.setDefaultEncoding(t.encoding),typeof t.fd==`number`?(this.fd=t.fd,this._autoClose=t.autoClose??!0,this._fdFromHandle=t.fdFromHandle===!0):t.autoClose!==void 0&&(this._autoClose=t.autoClose),this.pending=this.fd===null}_construct(e){if(this.fd!==null){e(),this.emit(`open`,this.fd),this.emit(`ready`);return}open$1(this.path.toString(),this.flags,this.mode,(t,n)=>{if(t){e(t);return}this.fd=n,this.pending=!1,e(),this.emit(`open`,this.fd),this.emit(`ready`)})}_write(e,t,n){this[Ia]=!0,write(this.fd,e,0,e.length,this.pos??null,(e,t)=>{if(this[Ia]=!1,this.destroyed)return n(e),this.emit(La,e);if(e)return n(e);this.bytesWritten+=t,n()}),this.pos!==void 0&&(this.pos+=e.length)}_destroy(e,t){this[Ia]?this.once(La,n=>this.close(t,e||n)):this.close(t,e)}}});function createInterface(e,t,n,r){return typeof e==`object`&&e&&!(`read`in e&&typeof e.read==`function`)?new Interface(e):new Interface({input:e,output:t,completer:n,terminal:r})}function*emitKeys(e){for(;;){let t=yield,n=t,r=!1,i={sequence:``,name:void 0,ctrl:!1,meta:!1,shift:!1};if(t===`\x1B`&&(r=!0,n+=t=yield,t===`\x1B`&&(n+=t=yield)),r&&(t===`O`||t===`[`)){let e=t,r=0;if(t===`O`)n+=t=yield,t>=`0`&&t<=`9`&&(r=t.charCodeAt(0)-1,n+=t=yield),e+=t;else if(t===`[`){n+=t=yield,t===`[`&&(e+=t,n+=t=yield);let i=n.length-1;t>=`0`&&t<=`9`&&(n+=t=yield,t>=`0`&&t<=`9`&&(n+=t=yield,t>=`0`&&t<=`9`&&(n+=t=yield))),t===`;`&&(n+=t=yield,t>=`0`&&t<=`9`&&(n+=yield));let a=n.slice(i),o;(o=/^(?:(\d\d?)(?:;(\d))?([~^$])|(\d{3}~))$/.exec(a))?o[4]?e+=o[4]:(e+=o[1]+o[3],r=(parseInt(o[2]??`1`,10)||1)-1):(o=/^((\d;)?(\d))?([A-Za-z])$/.exec(a))?(e+=o[4],r=(parseInt(o[3]??`1`,10)||1)-1):e+=a}switch(i.ctrl=!!(r&4),i.meta=!!(r&10),i.shift=!!(r&1),i.code=e,e){case`[P`:case`OP`:case`[11~`:case`[[A`:i.name=`f1`;break;case`[Q`:case`OQ`:case`[12~`:case`[[B`:i.name=`f2`;break;case`[R`:case`OR`:case`[13~`:case`[[C`:i.name=`f3`;break;case`[S`:case`OS`:case`[14~`:case`[[D`:i.name=`f4`;break;case`[15~`:case`[[E`:i.name=`f5`;break;case`[17~`:i.name=`f6`;break;case`[18~`:i.name=`f7`;break;case`[19~`:i.name=`f8`;break;case`[20~`:i.name=`f9`;break;case`[21~`:i.name=`f10`;break;case`[23~`:i.name=`f11`;break;case`[24~`:i.name=`f12`;break;case`[200~`:i.name=`paste-start`;break;case`[201~`:i.name=`paste-end`;break;case`[A`:case`OA`:i.name=`up`;break;case`[B`:case`OB`:i.name=`down`;break;case`[C`:case`OC`:i.name=`right`;break;case`[D`:case`OD`:i.name=`left`;break;case`[E`:case`OE`:i.name=`clear`;break;case`[F`:case`OF`:i.name=`end`;break;case`[H`:case`OH`:i.name=`home`;break;case`[1~`:i.name=`home`;break;case`[2~`:i.name=`insert`;break;case`[3~`:i.name=`delete`;break;case`[4~`:i.name=`end`;break;case`[5~`:case`[[5~`:i.name=`pageup`;break;case`[6~`:case`[[6~`:i.name=`pagedown`;break;case`[7~`:i.name=`home`;break;case`[8~`:i.name=`end`;break;case`[a`:i.name=`up`,i.shift=!0;break;case`[b`:i.name=`down`,i.shift=!0;break;case`[c`:i.name=`right`,i.shift=!0;break;case`[d`:i.name=`left`,i.shift=!0;break;case`[2$`:i.name=`insert`,i.shift=!0;break;case`[3$`:i.name=`delete`,i.shift=!0;break;case`[5$`:i.name=`pageup`,i.shift=!0;break;case`[6$`:i.name=`pagedown`,i.shift=!0;break;case`[7$`:i.name=`home`,i.shift=!0;break;case`[8$`:i.name=`end`,i.shift=!0;break;case`Oa`:i.name=`up`,i.ctrl=!0;break;case`Ob`:i.name=`down`,i.ctrl=!0;break;case`Oc`:i.name=`right`,i.ctrl=!0;break;case`Od`:i.name=`left`,i.ctrl=!0;break;case`[2^`:i.name=`insert`,i.ctrl=!0;break;case`[3^`:i.name=`delete`,i.ctrl=!0;break;case`[5^`:i.name=`pageup`,i.ctrl=!0;break;case`[6^`:i.name=`pagedown`,i.ctrl=!0;break;case`[7^`:i.name=`home`,i.ctrl=!0;break;case`[8^`:i.name=`end`,i.ctrl=!0;break;case`[Z`:i.name=`tab`,i.shift=!0;break;default:i.name=`undefined`;break}}else t===`\r`?(i.name=`return`,i.meta=r):t===`
|
|
9
|
-
`?(i.name=`enter`,i.meta=r):t===` `?(i.name=`tab`,i.meta=r):t===`\b`||t===``?(i.name=`backspace`,i.meta=r):t===`\x1B`?(i.name=`escape`,i.meta=r):t===` `?(i.name=`space`,i.meta=r):!r&&t<=``?(i.name=String.fromCharCode(t.charCodeAt(0)+97-1),i.ctrl=!0):/^[0-9A-Za-z]$/.test(t)?(i.name=t.toLowerCase(),i.shift=/^[A-Z]$/.test(t),i.meta=r):r&&(i.name=t.length?void 0:`escape`,i.meta=!0);i.sequence=n,n.length!==0&&(i.name!==void 0||r)?e.emit(`keypress`,r?void 0:n,i):n.length===1&&e.emit(`keypress`,n,i)}}function emitKeypressEvents(e,t={}){let n=e;if(n[Va])return;n[Va]=new Me(`utf8`),n[Ha]=emitKeys(e),n[Ha].next();let r=t.escapeCodeTimeout??500,i,triggerEscape=()=>n[Ha].next(``);function onData(t){if(e.listenerCount(`keypress`)>0){let a=n[Va].write(typeof t==`string`?Buffer.from(t):t);if(a){clearTimeout(i);for(let t of a)try{n[Ha].next(t),t===`\x1B`&&(i=setTimeout(triggerEscape,r))}catch{n[Ha]=emitKeys(e),n[Ha].next()}}}else e.removeListener(`data`,onData),delete n[Va],delete n[Ha]}e.on(`data`,onData)}var za,Interface,Ba,Va,Ha,Ua=__esmMin(()=>{je(),Ne(),za=/\r\n|\r|\n/,Interface=class extends Ae{terminal;line=``;cursor=0;escapeCodeTimeout;_input;_output;get input(){return this._input}get output(){return this._output}_prompt;_closed=!1;_paused=!1;history;_historySize;_crlfDelay;_lineBuffer=``;_questionCallback=null;_boundOnData=null;_boundOnEnd=null;_boundOnError=null;_boundOnKeypress=null;constructor(e,t){super();let n;if(n=e&&typeof e==`object`&&!(`read`in e&&typeof e.read==`function`)?e:{input:e,output:t},this._input=n.input||null,this._output=n.output||null,this._prompt=n.prompt||`> `,this.terminal=n.terminal??this._output!==null,this._historySize=n.historySize??30,this.history=[],this._crlfDelay=n.crlfDelay??100,this.escapeCodeTimeout=n.escapeCodeTimeout,this._input&&(this._boundOnData=e=>this._onData(e),this._boundOnEnd=()=>this._onEnd(),this._boundOnError=e=>this.emit(`error`,e),this._input.on(`data`,this._boundOnData),this._input.on(`end`,this._boundOnEnd),this._input.on(`error`,this._boundOnError),`setEncoding`in this._input&&typeof this._input.setEncoding==`function`&&this._input.setEncoding(`utf8`),this.terminal)){emitKeypressEvents(this._input,this);let e=this._input;typeof e.setRawMode==`function`&&(e.isRaw||e.setRawMode(!0)),typeof this._input.resume==`function`&&this._input.resume(),this._boundOnKeypress=(e,t)=>{t&&(t.name===`backspace`||t.name===`delete`?this.cursor>0&&(this.line=this.line.slice(0,this.cursor-1)+this.line.slice(this.cursor),this.cursor--):e&&e.length===1&&!t.ctrl&&!t.meta&&t.name!==`return`&&t.name!==`enter`&&t.name!==`escape`&&(this.line=this.line.slice(0,this.cursor)+e+this.line.slice(this.cursor),this.cursor++))},this._input.on(`keypress`,this._boundOnKeypress)}}_onData(e){if(this._closed||this._paused)return;let t=typeof e==`string`?e:e.toString(`utf8`);this._lineBuffer+=t;let n;for(;(n=za.exec(this._lineBuffer))!==null;){let e=this._lineBuffer.substring(0,n.index);this._lineBuffer=this._lineBuffer.substring(n.index+n[0].length),this._onLine(e)}}_onLine(e){if(e.length>0&&this._historySize>0&&(this.history.length===0||this.history[0]!==e)&&(this.history.unshift(e),this.history.length>this._historySize&&this.history.pop()),this._questionCallback){let t=this._questionCallback;this._questionCallback=null,t(e)}this.emit(`line`,e)}_onEnd(){this._lineBuffer.length>0&&(this._onLine(this._lineBuffer),this._lineBuffer=``),this.close()}setPrompt(e){this._prompt=e}getPrompt(){return this._prompt}prompt(e){if(this._closed)throw Error(`readline was closed`);this._output?.write(this._prompt)}question(e,t,n){if(this._closed)throw Error(`readline was closed`);let r=typeof t==`function`?t:n;this._questionCallback=r,this._output?.write(e)}clearLine(e,t){return this.line=``,this.cursor=0,t&&t(),!0}write(e,t){if(!this._closed){if(t){this._input&&this._input.emit(`keypress`,e??``,t);return}if(e!=null){let t=typeof e==`string`?e:e.toString(`utf8`);t&&(this.line=this.line.slice(0,this.cursor)+t+this.line.slice(this.cursor),this.cursor+=t.length),this._output?.write(e)}}}close(){if(!this._closed){if(this._closed=!0,this._input){this._boundOnData&&this._input.removeListener(`data`,this._boundOnData),this._boundOnEnd&&this._input.removeListener(`end`,this._boundOnEnd),this._boundOnError&&this._input.removeListener(`error`,this._boundOnError),this._boundOnKeypress&&this._input.removeListener(`keypress`,this._boundOnKeypress),this._boundOnData=null,this._boundOnEnd=null,this._boundOnError=null,this._boundOnKeypress=null;let e=this._input;this.terminal&&e.isRaw&&typeof e.setRawMode==`function`&&e.setRawMode(!1),typeof this._input.pause==`function`&&this._input.pause()}this.emit(`close`)}}pause(){return this._closed?this:(this._paused=!0,this._input&&`pause`in this._input&&typeof this._input.pause==`function`&&this._input.pause(),this.emit(`pause`),this)}resume(){return this._closed?this:(this._paused=!1,this._input&&`resume`in this._input&&typeof this._input.resume==`function`&&this._input.resume(),this.emit(`resume`),this)}getCursorPos(){let e=this._output?.columns??80,t=this._prompt.length+this.cursor;return{rows:Math.floor(t/e),cols:t%e}}[Symbol.asyncIterator](){let e=[],t=null,n=!1,onLine=n=>{if(t){let e=t;t=null,e({value:n,done:!1})}else e.push(n)},onClose=()=>{if(n=!0,t){let e=t;t=null,e({value:void 0,done:!0})}};return this.on(`line`,onLine),this.on(`close`,onClose),{next:()=>e.length>0?Promise.resolve({value:e.shift(),done:!1}):n?Promise.resolve({value:void 0,done:!0}):new Promise(e=>{t=e}),return:()=>(n=!0,this.removeListener(`line`,onLine),this.removeListener(`close`,onClose),Promise.resolve({value:void 0,done:!0})),[Symbol.asyncIterator](){return this}}}},Ba=Symbol.dispose??Symbol.for(`Symbol.dispose`),Interface.prototype[Ba]=function(){this.close()},Va=Symbol(`keypress-decoder`),Ha=Symbol(`escape-decoder`)}),Wa,Ga=__esmMin(()=>{sa(),$i(),ca(),fa(),Ra(),xa(),Ca(),wa(),be(),ni(),_e(),Ua(),Wa=class FileHandle{options;_gFile;_pathStr;_spec;_pos=0;_closed=!1;static instances={};constructor(e){this.options=e,this.options.flags??=`r`;let t=normalizePath$1(e.path);this._spec=parseOpenFlags(this.options.flags),this.options.mode??=438;let n=normalizeMode(this.options.mode,438);return this.fd=openFd(t,this._spec,n),this._pathStr=t,this._gFile=J.File.new_for_path(t),FileHandle.instances[this.fd]=this,FileHandle.getInstance(this.fd)}_readCore(e,t,n,r){if(this._assertOpen(`read`),!this._spec.readable)throw fsError(`EBADF`,`read`,this._pathStr);if(n>e.byteLength-t){let r=RangeError(`The value of "length" is out of range. It must be <= ${e.byteLength-t}. Received ${n}`);throw r.code=`ERR_OUT_OF_RANGE`,r}let i=r!=null&&r>=0,a=isSeekableFd(this.fd,this._pathStr);if(i&&!a)throw fsError(`ESPIPE`,`read`,this._pathStr);let o=i?r:this._pos;a&&seekFd(this.fd,o);let s=readFd(this.fd,n);return s.length>0&&new Uint8Array(e.buffer,e.byteOffset+t,s.length).set(s),!i&&a&&(this._pos=o+s.length),s.length}_writeCore(e,t){if(this._assertOpen(`write`),!this._spec.writable)throw fsError(`EBADF`,`write`,this._pathStr);if(this._spec.append){let t=writeFd(this.fd,e);return this._pos=tellFd(this.fd)??sizeOfFd(this.fd,this._pathStr),t}let n=t!=null&&t>=0,r=isSeekableFd(this.fd,this._pathStr);if(n&&!r)throw fsError(`ESPIPE`,`write`,this._pathStr);let i=n?t:this._pos;r&&seekFd(this.fd,i);let a=writeFd(this.fd,e);return!n&&r&&(this._pos=i+a),a}_assertOpen(e){if(this._closed)throw fsError(`EBADF`,e,this._pathStr)}_truncateCore(e){if(this._assertOpen(`ftruncate`),!this._spec.writable)throw fsError(`EINVAL`,`ftruncate`,this._pathStr);truncateFd(this.fd,Math.max(0,e),this._pathStr)}_readToEnd(){let e=[],t=0;for(;;){let n=new Uint8Array(64*1024),r=this._readCore(n,0,n.length,null);if(r===0)break;e.push(n.subarray(0,r)),t+=r}let n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}_fdTarget(){return fdPath(this.fd)??this._pathStr}fd;static getInstance(e,t=`read`){let n=e instanceof FileHandle?e.fd:e,r=FileHandle.instances[n];if(!r)throw fsError(`EBADF`,t);return r}async appendFile(e,t){await this.writeFile(e,t)}async chown(e,t){this._assertOpen(`fchown`),chownSync(normalizePath$1(this.options.path),e,t)}async chmod(e){this._assertOpen(`fchmod`),chmodSync(this._fdTarget(),e)}createReadStream(e){return new ReadStream(this.options.path,{...e,fd:this.fd})}createWriteStream(e){return new WriteStream(this.options.path,{...e,fd:this.fd,fdFromHandle:!0})}async datasync(){this._assertOpen(`fdatasync`),fsyncFd(this.fd)}async sync(){this._assertOpen(`fsync`),fsyncFd(this.fd)}async read(...e){let t,n,r,i;if(typeof e[0]==`object`&&!(e[0]instanceof Uint8Array)&&!(e[0]instanceof I)){let a=e[0];t=a.buffer,n=a.offset,r=a.length,i=a.position}else t=e[0],n=e[1],r=e[2],i=e[3];let a=t,o=n??0,s=r??(a?a.byteLength-o:65536);return{bytesRead:this._readCore(t,o,s,i??null),buffer:t}}readableWebStream(){let e=globalThis.ReadableStream;if(typeof e!=`function`)throw Error(`readableWebStream() requires a global ReadableStream. Import "node:stream/web" or "@gjsify/streams" before calling this method.`);return new e}async readFile(e){return encodeUint8Array(getEncodingFromOptions(e,`buffer`),this._readToEnd())}readLines(e){return createInterface({input:this.createReadStream(e),crlfDelay:1/0})}async stat(e){this._assertOpen(`fstat`);let t=J.File.new_for_path(this._fdTarget());return statsFrom(await new Promise((e,n)=>{t.query_info_async(Sa,J.FileQueryInfoFlags.NONE,L.PRIORITY_DEFAULT,null,(r,i)=>{try{e(t.query_info_finish(i))}catch(e){n(e)}})}),this._pathStr,`fstat`,e?.bigint)}async truncate(e=0){this._truncateCore(e)}async utimes(e,t){this._assertOpen(`futimes`);let{utimesSync:n}=await Promise.resolve().then(()=>(ra(),na));n(normalizePath$1(this.options.path),e,t)}async writeFile(e,t){let n=getEncodingFromOptions(t),r;r=typeof e==`string`?I.from(e,n||`utf8`):e,this._writeCore(r,null)}async write(e,...t){let n=null,r=null,i=null,a=null;typeof e==`string`?(n=t[0],r=t[1]):(i=t[0],a=t[1],n=t[2]),r=getEncodingFromOptions(r,typeof e==`string`?`utf8`:null);let o;o=typeof e==`string`?new TextEncoder().encode(e):e;let s=i??0,c=a??o.byteLength-s,l=o.subarray(s,s+c);return{bytesWritten:this._writeCore(l,n??null),buffer:e}}async writev(e,t){let n=0;for(let r of e){let e=I.from(r.buffer,r.byteOffset,r.byteLength),i=await this.write(e,0,e.byteLength,t==null?null:t+n);n+=i.bytesWritten}return{bytesWritten:n,buffers:e}}async readv(e,t){let n=0;for(let r of e){let e=await this.read({buffer:I.from(r.buffer,r.byteOffset,r.byteLength),position:t==null?null:t+n});if(n+=e.bytesRead,e.bytesRead<r.byteLength)break}return{bytesRead:n,buffers:e}}_flushSync(){fsyncFd(this.fd)}_closeSync(){this._teardown()}_readSync(e,t,n,r){return this._readCore(e,t,n,r)}_writeSync(e,t){return this._writeCore(e,t)}_readToEndSync(){return this._readToEnd()}_truncateSync(e){this._truncateCore(e)}_fdStatTarget(){return this._fdTarget()}_teardown(){if(this._closed)return;this._closed=!0,releaseFd(this.fd),closeFd(this.fd);let e=FileHandle;delete e.instances[this.fd]}async close(){this._teardown()}async[Symbol.asyncDispose](){await this.close()}pull(...e){throw Error('FileHandle.pull() is not implemented in @gjsify/fs yet — requires `node:stream/iter` (Node 25.9+) which @gjsify/stream has not ported. Track gjsify Open TODO "Node 25 stream/iter integration".')}writer(e){throw Error('FileHandle.writer() is not implemented in @gjsify/fs yet — requires `node:stream/iter` (Node 25.9+) which @gjsify/stream has not ported. Track gjsify Open TODO "Node 25 stream/iter integration".')}}});function getFH(e,t){return Wa.getInstance(e,t)}function fstatSync(e,t){return statSync(getFH(e,`fstat`)._fdStatTarget(),t)}function fstat(e,t,n){let r=typeof t==`function`?t:n;fstatAsync(e,typeof t==`function`?{}:t).then(e=>r(null,e),e=>r(e,void 0))}async function fstatAsync(e,t){return t?.bigint,fstatSync(e,t)}function ftruncateSync(e,t=0){getFH(e,`ftruncate`)._truncateSync(t)}function ftruncate(e,t,n){let r=typeof t==`function`?t:n;ftruncateAsync(e,typeof t==`function`?0:t).then(()=>r(null),r)}async function ftruncateAsync(e,t=0){ftruncateSync(e,t)}function fdatasyncSync(e){getFH(e,`fdatasync`)._flushSync()}function fdatasync(e,t){Promise.resolve().then(()=>fdatasyncSync(e)).then(()=>t(null),t)}async function fdatasyncAsync(e){fdatasyncSync(e)}function fsyncSync(e){getFH(e,`fsync`)._flushSync()}function fsync(e,t){Promise.resolve().then(()=>fsyncSync(e)).then(()=>t(null),t)}async function fsyncAsync(e){fsyncSync(e)}function fchmodSync(e,t){chmodSync(getFH(e,`fchmod`)._fdStatTarget(),t)}function fchmod(e,t,n){Promise.resolve().then(()=>fchmodSync(e,t)).then(()=>n(null),n)}async function fchmodAsync(e,t){fchmodSync(e,t)}function fchownSync(e,t,n){chownSync(normalizePath$1(getFH(e,`fchown`).options.path),t,n)}function fchown(e,t,n,r){Promise.resolve().then(()=>fchownSync(e,t,n)).then(()=>r(null),r)}async function fchownAsync(e,t,n){fchownSync(e,t,n)}function futimesSync(e,t,n){utimesSync(normalizePath$1(getFH(e,`futimes`).options.path),t,n)}function futimes(e,t,n,r){Promise.resolve().then(()=>futimesSync(e,t,n)).then(()=>r(null),r)}async function futimesAsync(e,t,n){futimesSync(e,t,n)}function closeSync(e){isStdFd(e)||getFH(e,`close`)._closeSync()}function readSync(e,t,n,r,i){let a=0;return typeof n==`object`&&n?(a=n.offset??0,r=n.length??t.byteLength-a,i=n.position??null):(a=n??0,r??=t.byteLength-a),isStdFd(e)?readStdFdSync(e,t,a,r):getFH(e,`read`)._readSync(t,a,r,i??null)}function writeSync(e,t,n,r,i){let a;if(typeof t==`string`)a=new TextEncoder().encode(t),typeof n==`number`&&(i=n);else{let e=typeof n==`number`?n:0,i=typeof r==`number`?r:t.byteLength-e;a=new Uint8Array(t.buffer,t.byteOffset+e,i)}return isStdFd(e)?writeStdFdSync(e,a):getFH(e,`write`)._writeSync(a,i??null)}function readvSync(e,t,n){let r=0;for(let i of t){let t=readSync(e,i,0,i.byteLength,n==null?null:n+r);if(r+=t,t<i.byteLength)break}return r}function readv(e,t,n,r){let i=typeof n==`function`?n:r;readvAsync(e,t,typeof n==`function`?null:n).then(e=>i(null,e.bytesRead,e.buffers),e=>i(e,0,t))}async function readvAsync(e,t,n){return{bytesRead:readvSync(e,t,n),buffers:t}}function writevSync(e,t,n){let r=0;for(let i of t){let t=writeSync(e,i,0,i.byteLength,n==null?null:n+r);r+=t}return r}function writev(e,t,n,r){let i=typeof n==`function`?n:r;writevAsync(e,t,typeof n==`function`?null:n).then(e=>i(null,e.bytesWritten,e.buffers),e=>i(e,0,t))}async function writevAsync(e,t,n){return{bytesWritten:writevSync(e,t,n),buffers:t}}function exists(e,t){try{statSync(normalizePath$1(e)),t(!0)}catch{t(!1)}}async function openAsBlob(e,t){let n=readFileSync(normalizePath$1(e));return new Blob([n],{type:t?.type??``})}var Ka=__esmMin(()=>{$i(),ra(),oa(),Ga(),wa()});function zeroedStat(){return{dev:0,ino:0,mode:0,nlink:0,uid:0,gid:0,rdev:0,size:0,blksize:0,blocks:0,atimeMs:0,mtimeMs:0,ctimeMs:0,birthtimeMs:0,atime:new Date(0),mtime:new Date(0),ctime:new Date(0),birthtime:new Date(0),isFile:()=>!1,isDirectory:()=>!1,isBlockDevice:()=>!1,isCharacterDevice:()=>!1,isSymbolicLink:()=>!1,isFIFO:()=>!1,isSocket:()=>!1}}function watchFile$1(e,t,n){typeof t==`function`&&(n=t,t={});let r=t.interval??5007,i=e.toString(),a=qa.get(i);return a||(a=new StatWatcher(i,r),a.start(),qa.set(i,a)),n&&a.addChangeListener(n),a}function unwatchFile(e,t){let n=e.toString(),r=qa.get(n);r&&(t?r.removeChangeListener(t):r.removeAllChangeListeners(),r.changeListenerCount===0&&(r.stop(),qa.delete(n)))}var StatWatcher,qa,Ja=__esmMin(()=>{wa(),je(),StatWatcher=class extends Ae{_path;_interval;_timerId=null;_prev;_changeCount=0;constructor(e,t){super(),this._path=e,this._interval=t,this._prev=zeroedStat()}start(){try{this._prev=statSync(this._path)}catch{}this._timerId=setInterval(()=>{let e;try{e=statSync(this._path)}catch{e=zeroedStat()}let t=this._prev;(e.mtimeMs!==t.mtimeMs||e.size!==t.size||e.ino!==t.ino)&&(this._prev=e,this.emit(`change`,e,t))},this._interval)}stop(){this._timerId!==null&&(clearInterval(this._timerId),this._timerId=null),this.emit(`stop`)}addChangeListener(e){this._changeCount++,this.on(`change`,e)}removeChangeListener(e){this._changeCount--,this.removeListener(`change`,e)}removeAllChangeListeners(){this._changeCount=0,this.removeAllListeners(`change`)}get changeListenerCount(){return this._changeCount}},qa=new Map,__name(watchFile$1,`watchFile`)}),Ya=__exportAll$2({BigIntStats:()=>BigIntStats,Dir:()=>Dir,Dirent:()=>Dirent,FSWatcher:()=>FSWatcher,ReadStream:()=>ReadStream,StatWatcher:()=>StatWatcher,Stats:()=>Stats,WriteStream:()=>WriteStream,access:()=>access,accessSync:()=>accessSync,appendFile:()=>appendFile,appendFileSync:()=>appendFileSync,chmod:()=>chmod,chmodSync:()=>chmodSync,chown:()=>chown,chownSync:()=>chownSync,close:()=>close$1,closeSync:()=>closeSync,constants:()=>Xa,copyFile:()=>copyFile,copyFileSync:()=>copyFileSync,cp:()=>cp,cpSync:()=>cpSync,createReadStream:()=>createReadStream,createWriteStream:()=>createWriteStream,default:()=>Za,exists:()=>exists,existsSync:()=>existsSync,fchmod:()=>fchmod,fchmodSync:()=>fchmodSync,fchown:()=>fchown,fchownSync:()=>fchownSync,fdatasync:()=>fdatasync,fdatasyncSync:()=>fdatasyncSync,fstat:()=>fstat,fstatSync:()=>fstatSync,fsync:()=>fsync,fsyncSync:()=>fsyncSync,ftruncate:()=>ftruncate,ftruncateSync:()=>ftruncateSync,futimes:()=>futimes,futimesSync:()=>futimesSync,glob:()=>glob,globSync:()=>globSync,lchmod:()=>void 0,lchmodSync:()=>void 0,lchown:()=>lchown,lchownSync:()=>lchownSync,link:()=>link,linkSync:()=>linkSync,lstat:()=>lstat,lstatSync:()=>lstatSync,lutimes:()=>lutimes,lutimesSync:()=>lutimesSync,mkdir:()=>mkdir,mkdirSync:()=>mkdirSync,mkdtempSync:()=>mkdtempSync,open:()=>open$1,openAsBlob:()=>openAsBlob,openSync:()=>openSync,opendir:()=>opendir,opendirSync:()=>opendirSync,promises:()=>Ma,read:()=>read,readFile:()=>readFile,readFileSync:()=>readFileSync,readSync:()=>readSync,readdir:()=>readdir,readdirSync:()=>readdirSync,readlink:()=>readlink,readlinkSync:()=>readlinkSync,readv:()=>readv,readvSync:()=>readvSync,realpath:()=>realpath,realpathSync:()=>realpathSync,rename:()=>rename,renameSync:()=>renameSync,rm:()=>rm,rmSync:()=>rmSync,rmdir:()=>rmdir,rmdirSync:()=>rmdirSync,stat:()=>stat,statSync:()=>statSync,statfs:()=>statfs,statfsSync:()=>statfsSync,symlink:()=>symlink,symlinkSync:()=>symlinkSync,truncate:()=>truncate,truncateSync:()=>truncateSync,unlink:()=>unlink,unlinkSync:()=>unlinkSync,unwatchFile:()=>unwatchFile,utimes:()=>utimes,utimesSync:()=>utimesSync,watch:()=>watch,watchFile:()=>watchFile$1,write:()=>write,writeFile:()=>writeFile$1,writeFileSync:()=>writeFileSync,writeSync:()=>writeSync,writev:()=>writev,writevSync:()=>writevSync});function openFlagDescriptors(){let e={};for(let t of Object.keys(openFlagValues()))e[t]={enumerable:!0,configurable:!0,get:()=>openFlagValues()[t]};return e}var Xa,Za,Qa=__esmMin(()=>{ta(),ra(),Ka(),ca(),fa(),Ra(),ma(),Ca(),wa(),Ta(),Da(),Oa(),ja(),Pa(),Fa(),Ja(),Xa=Object.defineProperties({F_OK:0,R_OK:4,W_OK:2,X_OK:1,COPYFILE_EXCL:1,COPYFILE_FICLONE:2,COPYFILE_FICLONE_FORCE:4,S_IFMT:61440,S_IFREG:32768,S_IFDIR:16384,S_IFCHR:8192,S_IFBLK:24576,S_IFIFO:4096,S_IFLNK:40960,S_IFSOCK:49152,S_IRWXU:448,S_IRUSR:256,S_IWUSR:128,S_IXUSR:64,S_IRWXG:56,S_IRGRP:32,S_IWGRP:16,S_IXGRP:8,S_IRWXO:7,S_IROTH:4,S_IWOTH:2,S_IXOTH:1},openFlagDescriptors()),Za={FSWatcher,StatWatcher,Stats,BigIntStats,Dirent,Dir,constants:Xa,existsSync,readdirSync,readFileSync,writeFileSync,mkdirSync,rmdirSync,unlinkSync,mkdtempSync,rmSync,statSync,openSync,realpathSync,symlinkSync,lstatSync,renameSync,copyFileSync,accessSync,appendFileSync,readlinkSync,linkSync,truncateSync,chmodSync,chownSync,cpSync,opendirSync,globSync,glob,watch,watchFile:watchFile$1,unwatchFile,statfsSync,statfs,utimesSync,utimes,lutimesSync,lutimes,lchownSync,lchown,lchmodSync:void 0,lchmod:void 0,fstatSync,fstat,ftruncateSync,ftruncate,fdatasyncSync,fdatasync,fsyncSync,fsync,fchmodSync,fchmod,fchownSync,fchown,futimesSync,futimes,closeSync,readSync,writeSync,readvSync,readv,writevSync,writev,exists,openAsBlob,createReadStream,ReadStream,createWriteStream,WriteStream,promises:Ma,open:open$1,close:close$1,read,write,rm,realpath,readdir,symlink,lstat,stat,rename,copyFile,cp,access,appendFile,readlink,truncate,chmod,chown,mkdir,rmdir,readFile,writeFile:writeFile$1,unlink,link,opendir}}),$a,eo=__esmMin(()=>{$a={UV_UDP_REUSEADDR:4,errno:{E2BIG:7,EACCES:13,EADDRINUSE:98,EADDRNOTAVAIL:99,EAFNOSUPPORT:97,EAGAIN:11,EALREADY:114,EBADF:9,EBADMSG:74,EBUSY:16,ECANCELED:125,ECHILD:10,ECONNABORTED:103,ECONNREFUSED:111,ECONNRESET:104,EDEADLK:35,EDESTADDRREQ:89,EDOM:33,EDQUOT:122,EEXIST:17,EFAULT:14,EFBIG:27,EHOSTUNREACH:113,EIDRM:43,EILSEQ:84,EINPROGRESS:115,EINTR:4,EINVAL:22,EIO:5,EISCONN:106,EISDIR:21,ELOOP:40,EMFILE:24,EMLINK:31,EMSGSIZE:90,EMULTIHOP:72,ENAMETOOLONG:36,ENETDOWN:100,ENETRESET:102,ENETUNREACH:101,ENFILE:23,ENOBUFS:105,ENODATA:61,ENODEV:19,ENOENT:2,ENOEXEC:8,ENOLCK:37,ENOLINK:67,ENOMEM:12,ENOMSG:42,ENOPROTOOPT:92,ENOSPC:28,ENOSR:63,ENOSTR:60,ENOSYS:38,ENOTCONN:107,ENOTDIR:20,ENOTEMPTY:39,ENOTSOCK:88,ENOTSUP:95,ENOTTY:25,ENXIO:6,EOPNOTSUPP:95,EOVERFLOW:75,EPERM:1,EPIPE:32,EPROTO:71,EPROTONOSUPPORT:93,EPROTOTYPE:91,ERANGE:34,EROFS:30,ESPIPE:29,ESRCH:3,ESTALE:116,ETIME:62,ETIMEDOUT:110,ETXTBSY:26,EWOULDBLOCK:11,EXDEV:18},signals:{SIGHUP:1,SIGINT:2,SIGQUIT:3,SIGILL:4,SIGTRAP:5,SIGABRT:6,SIGIOT:6,SIGBUS:7,SIGFPE:8,SIGKILL:9,SIGUSR1:10,SIGSEGV:11,SIGUSR2:12,SIGPIPE:13,SIGALRM:14,SIGTERM:15,SIGCHLD:17,SIGSTKFLT:16,SIGCONT:18,SIGSTOP:19,SIGTSTP:20,SIGTTIN:21,SIGTTOU:22,SIGURG:23,SIGXCPU:24,SIGXFSZ:25,SIGVTALRM:26,SIGPROF:27,SIGWINCH:28,SIGIO:29,SIGPOLL:29,SIGPWR:30,SIGSYS:31},priority:{PRIORITY_LOW:19,PRIORITY_BELOW_NORMAL:10,PRIORITY_NORMAL:0,PRIORITY_ABOVE_NORMAL:-7,PRIORITY_HIGH:-14,PRIORITY_HIGHEST:-20},dlopen:{RTLD_LAZY:1,RTLD_NOW:2,RTLD_GLOBAL:256,RTLD_LOCAL:0,RTLD_DEEPBIND:8}}});function createSubnet(e,t,n,r){let i=`0`.repeat(e);return a=>{let o=(`1`.repeat(parseInt(a,10))+i).slice(0,e),s=[];for(let r=0;r<e;r+=t)s.push(parseInt(o.substr(r,t),2).toString(n));return s.join(r)}}var to=__esmMin(()=>{}),no,ro,sysctl,io,ao,oo,so,co,lo,uo,fo,po=__esmMin(()=>{to(),yi(),no=createSubnet(128,16,16,`:`),ro=__name(function(e){if(e=e.trim(),e.length<1||!/\binet6?\b/.test(e))return;let t=e.split(`
|
|
9
|
+
`?(i.name=`enter`,i.meta=r):t===` `?(i.name=`tab`,i.meta=r):t===`\b`||t===``?(i.name=`backspace`,i.meta=r):t===`\x1B`?(i.name=`escape`,i.meta=r):t===` `?(i.name=`space`,i.meta=r):!r&&t<=``?(i.name=String.fromCharCode(t.charCodeAt(0)+97-1),i.ctrl=!0):/^[0-9A-Za-z]$/.test(t)?(i.name=t.toLowerCase(),i.shift=/^[A-Z]$/.test(t),i.meta=r):r&&(i.name=t.length?void 0:`escape`,i.meta=!0);i.sequence=n,n.length!==0&&(i.name!==void 0||r)?e.emit(`keypress`,r?void 0:n,i):n.length===1&&e.emit(`keypress`,n,i)}}function emitKeypressEvents(e,t={}){let n=e;if(n[Va])return;n[Va]=new Me(`utf8`),n[Ha]=emitKeys(e),n[Ha].next();let r=t.escapeCodeTimeout??500,i,triggerEscape=()=>n[Ha].next(``);function onData(t){if(e.listenerCount(`keypress`)>0){let a=n[Va].write(typeof t==`string`?Buffer.from(t):t);if(a){clearTimeout(i);for(let t of a)try{n[Ha].next(t),t===`\x1B`&&(i=setTimeout(triggerEscape,r))}catch{n[Ha]=emitKeys(e),n[Ha].next()}}}else e.removeListener(`data`,onData),delete n[Va],delete n[Ha]}e.on(`data`,onData)}var za,Interface,Ba,Va,Ha,Ua=__esmMin(()=>{je(),Ne(),za=/\r\n|\r|\n/,Interface=class extends Ae{terminal;line=``;cursor=0;escapeCodeTimeout;_input;_output;get input(){return this._input}get output(){return this._output}_prompt;_closed=!1;_paused=!1;history;_historySize;_crlfDelay;_lineBuffer=``;_questionCallback=null;_boundOnData=null;_boundOnEnd=null;_boundOnError=null;_boundOnKeypress=null;constructor(e,t){super();let n;if(n=e&&typeof e==`object`&&!(`read`in e&&typeof e.read==`function`)?e:{input:e,output:t},this._input=n.input||null,this._output=n.output||null,this._prompt=n.prompt||`> `,this.terminal=n.terminal??this._output!==null,this._historySize=n.historySize??30,this.history=[],this._crlfDelay=n.crlfDelay??100,this.escapeCodeTimeout=n.escapeCodeTimeout,this._input&&(this._boundOnData=e=>this._onData(e),this._boundOnEnd=()=>this._onEnd(),this._boundOnError=e=>this.emit(`error`,e),this._input.on(`data`,this._boundOnData),this._input.on(`end`,this._boundOnEnd),this._input.on(`error`,this._boundOnError),`setEncoding`in this._input&&typeof this._input.setEncoding==`function`&&this._input.setEncoding(`utf8`),this.terminal)){emitKeypressEvents(this._input,this);let e=this._input;typeof e.setRawMode==`function`&&(e.isRaw||e.setRawMode(!0)),typeof this._input.resume==`function`&&this._input.resume(),this._boundOnKeypress=(e,t)=>{t&&(t.name===`backspace`||t.name===`delete`?this.cursor>0&&(this.line=this.line.slice(0,this.cursor-1)+this.line.slice(this.cursor),this.cursor--):e&&e.length===1&&!t.ctrl&&!t.meta&&t.name!==`return`&&t.name!==`enter`&&t.name!==`escape`&&(this.line=this.line.slice(0,this.cursor)+e+this.line.slice(this.cursor),this.cursor++))},this._input.on(`keypress`,this._boundOnKeypress)}}_onData(e){if(this._closed||this._paused)return;let t=typeof e==`string`?e:e.toString(`utf8`);this._lineBuffer+=t;let n;for(;(n=za.exec(this._lineBuffer))!==null;){let e=this._lineBuffer.substring(0,n.index);this._lineBuffer=this._lineBuffer.substring(n.index+n[0].length),this._onLine(e)}}_onLine(e){if(e.length>0&&this._historySize>0&&(this.history.length===0||this.history[0]!==e)&&(this.history.unshift(e),this.history.length>this._historySize&&this.history.pop()),this._questionCallback){let t=this._questionCallback;this._questionCallback=null,t(e)}this.emit(`line`,e)}_onEnd(){this._lineBuffer.length>0&&(this._onLine(this._lineBuffer),this._lineBuffer=``),this.close()}setPrompt(e){this._prompt=e}getPrompt(){return this._prompt}prompt(e){if(this._closed)throw Error(`readline was closed`);this._output?.write(this._prompt)}question(e,t,n){if(this._closed)throw Error(`readline was closed`);let r=typeof t==`function`?t:n;this._questionCallback=r,this._output?.write(e)}clearLine(e,t){return this.line=``,this.cursor=0,t&&t(),!0}write(e,t){if(!this._closed){if(t){this._input&&this._input.emit(`keypress`,e??``,t);return}if(e!=null){let t=typeof e==`string`?e:e.toString(`utf8`);t&&(this.line=this.line.slice(0,this.cursor)+t+this.line.slice(this.cursor),this.cursor+=t.length),this._output?.write(e)}}}close(){if(!this._closed){if(this._closed=!0,this._input){this._boundOnData&&this._input.removeListener(`data`,this._boundOnData),this._boundOnEnd&&this._input.removeListener(`end`,this._boundOnEnd),this._boundOnError&&this._input.removeListener(`error`,this._boundOnError),this._boundOnKeypress&&this._input.removeListener(`keypress`,this._boundOnKeypress),this._boundOnData=null,this._boundOnEnd=null,this._boundOnError=null,this._boundOnKeypress=null;let e=this._input;this.terminal&&e.isRaw&&typeof e.setRawMode==`function`&&e.setRawMode(!1),typeof this._input.pause==`function`&&this._input.pause()}this.emit(`close`)}}pause(){return this._closed?this:(this._paused=!0,this._input&&`pause`in this._input&&typeof this._input.pause==`function`&&this._input.pause(),this.emit(`pause`),this)}resume(){return this._closed?this:(this._paused=!1,this._input&&`resume`in this._input&&typeof this._input.resume==`function`&&this._input.resume(),this.emit(`resume`),this)}getCursorPos(){let e=this._output?.columns??80,t=this._prompt.length+this.cursor;return{rows:Math.floor(t/e),cols:t%e}}[Symbol.asyncIterator](){let e=[],t=null,n=!1,onLine=n=>{if(t){let e=t;t=null,e({value:n,done:!1})}else e.push(n)},onClose=()=>{if(n=!0,t){let e=t;t=null,e({value:void 0,done:!0})}};return this.on(`line`,onLine),this.on(`close`,onClose),{next:()=>e.length>0?Promise.resolve({value:e.shift(),done:!1}):n?Promise.resolve({value:void 0,done:!0}):new Promise(e=>{t=e}),return:()=>(n=!0,this.removeListener(`line`,onLine),this.removeListener(`close`,onClose),Promise.resolve({value:void 0,done:!0})),[Symbol.asyncIterator](){return this}}}},Ba=Symbol.dispose??Symbol.for(`Symbol.dispose`),Interface.prototype[Ba]=function(){this.close()},Va=Symbol(`keypress-decoder`),Ha=Symbol(`escape-decoder`)}),Wa,Ga=__esmMin(()=>{sa(),$i(),ca(),fa(),Ra(),xa(),Ca(),wa(),be(),ni(),_e(),Ua(),Wa=class FileHandle{options;_gFile;_pathStr;_spec;_pos=0;_closed=!1;static instances={};constructor(e){this.options=e,this.options.flags??=`r`;let t=normalizePath$1(e.path);this._spec=parseOpenFlags(this.options.flags),this.options.mode??=438;let n=normalizeMode(this.options.mode,438);return this.fd=openFd(t,this._spec,n),this._pathStr=t,this._gFile=J.File.new_for_path(t),FileHandle.instances[this.fd]=this,FileHandle.getInstance(this.fd)}_readCore(e,t,n,r){if(this._assertOpen(`read`),!this._spec.readable)throw fsError(`EBADF`,`read`,this._pathStr);if(n>e.byteLength-t){let r=RangeError(`The value of "length" is out of range. It must be <= ${e.byteLength-t}. Received ${n}`);throw r.code=`ERR_OUT_OF_RANGE`,r}let i=r!=null&&r>=0,a=isSeekableFd(this.fd,this._pathStr);if(i&&!a)throw fsError(`ESPIPE`,`read`,this._pathStr);let o=i?r:this._pos;a&&seekFd(this.fd,o);let s=readFd(this.fd,n);return s.length>0&&new Uint8Array(e.buffer,e.byteOffset+t,s.length).set(s),!i&&a&&(this._pos=o+s.length),s.length}_writeCore(e,t){if(this._assertOpen(`write`),!this._spec.writable)throw fsError(`EBADF`,`write`,this._pathStr);if(this._spec.append){let t=writeFd(this.fd,e);return this._pos=tellFd(this.fd)??sizeOfFd(this.fd,this._pathStr),t}let n=t!=null&&t>=0,r=isSeekableFd(this.fd,this._pathStr);if(n&&!r)throw fsError(`ESPIPE`,`write`,this._pathStr);let i=n?t:this._pos;r&&seekFd(this.fd,i);let a=writeFd(this.fd,e);return!n&&r&&(this._pos=i+a),a}_assertOpen(e){if(this._closed)throw fsError(`EBADF`,e,this._pathStr)}_truncateCore(e){if(this._assertOpen(`ftruncate`),!this._spec.writable)throw fsError(`EINVAL`,`ftruncate`,this._pathStr);truncateFd(this.fd,Math.max(0,e),this._pathStr)}_readToEnd(){let e=[],t=0;for(;;){let n=new Uint8Array(64*1024),r=this._readCore(n,0,n.length,null);if(r===0)break;e.push(n.subarray(0,r)),t+=r}let n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}_fdTarget(){return fdPath(this.fd)??this._pathStr}fd;static getInstance(e,t=`read`){let n=e instanceof FileHandle?e.fd:e,r=FileHandle.instances[n];if(!r)throw fsError(`EBADF`,t);return r}async appendFile(e,t){await this.writeFile(e,t)}async chown(e,t){this._assertOpen(`fchown`),chownSync(normalizePath$1(this.options.path),e,t)}async chmod(e){this._assertOpen(`fchmod`),chmodSync(this._fdTarget(),e)}createReadStream(e){return new ReadStream(this.options.path,{...e,fd:this.fd})}createWriteStream(e){return new WriteStream(this.options.path,{...e,fd:this.fd,fdFromHandle:!0})}async datasync(){this._assertOpen(`fdatasync`),fsyncFd(this.fd)}async sync(){this._assertOpen(`fsync`),fsyncFd(this.fd)}async read(...e){let t,n,r,i;if(typeof e[0]==`object`&&!(e[0]instanceof Uint8Array)&&!(e[0]instanceof I)){let a=e[0];t=a.buffer,n=a.offset,r=a.length,i=a.position}else t=e[0],n=e[1],r=e[2],i=e[3];let a=t,o=n??0,s=r??(a?a.byteLength-o:65536);return{bytesRead:this._readCore(t,o,s,i??null),buffer:t}}readableWebStream(){let e=globalThis.ReadableStream;if(typeof e!=`function`)throw Error(`readableWebStream() requires a global ReadableStream. Import "node:stream/web" or "@gjsify/web-streams/register" before calling this method.`);return new e}async readFile(e){return encodeUint8Array(getEncodingFromOptions(e,`buffer`),this._readToEnd())}readLines(e){return createInterface({input:this.createReadStream(e),crlfDelay:1/0})}async stat(e){this._assertOpen(`fstat`);let t=J.File.new_for_path(this._fdTarget());return statsFrom(await new Promise((e,n)=>{t.query_info_async(Sa,J.FileQueryInfoFlags.NONE,L.PRIORITY_DEFAULT,null,(r,i)=>{try{e(t.query_info_finish(i))}catch(e){n(e)}})}),this._pathStr,`fstat`,e?.bigint)}async truncate(e=0){this._truncateCore(e)}async utimes(e,t){this._assertOpen(`futimes`);let{utimesSync:n}=await Promise.resolve().then(()=>(ra(),na));n(normalizePath$1(this.options.path),e,t)}async writeFile(e,t){let n=getEncodingFromOptions(t),r;r=typeof e==`string`?I.from(e,n||`utf8`):e,this._writeCore(r,null)}async write(e,...t){let n=null,r=null,i=null,a=null;typeof e==`string`?(n=t[0],r=t[1]):(i=t[0],a=t[1],n=t[2]),r=getEncodingFromOptions(r,typeof e==`string`?`utf8`:null);let o;o=typeof e==`string`?new TextEncoder().encode(e):e;let s=i??0,c=a??o.byteLength-s,l=o.subarray(s,s+c);return{bytesWritten:this._writeCore(l,n??null),buffer:e}}async writev(e,t){let n=0;for(let r of e){let e=I.from(r.buffer,r.byteOffset,r.byteLength),i=await this.write(e,0,e.byteLength,t==null?null:t+n);n+=i.bytesWritten}return{bytesWritten:n,buffers:e}}async readv(e,t){let n=0;for(let r of e){let e=await this.read({buffer:I.from(r.buffer,r.byteOffset,r.byteLength),position:t==null?null:t+n});if(n+=e.bytesRead,e.bytesRead<r.byteLength)break}return{bytesRead:n,buffers:e}}_flushSync(){fsyncFd(this.fd)}_closeSync(){this._teardown()}_readSync(e,t,n,r){return this._readCore(e,t,n,r)}_writeSync(e,t){return this._writeCore(e,t)}_readToEndSync(){return this._readToEnd()}_truncateSync(e){this._truncateCore(e)}_fdStatTarget(){return this._fdTarget()}_teardown(){if(this._closed)return;this._closed=!0,releaseFd(this.fd),closeFd(this.fd);let e=FileHandle;delete e.instances[this.fd]}async close(){this._teardown()}async[Symbol.asyncDispose](){await this.close()}pull(...e){throw Error('FileHandle.pull() is not implemented in @gjsify/fs yet — requires `node:stream/iter` (Node 25.9+) which @gjsify/stream has not ported. Track gjsify Open TODO "Node 25 stream/iter integration".')}writer(e){throw Error('FileHandle.writer() is not implemented in @gjsify/fs yet — requires `node:stream/iter` (Node 25.9+) which @gjsify/stream has not ported. Track gjsify Open TODO "Node 25 stream/iter integration".')}}});function getFH(e,t){return Wa.getInstance(e,t)}function fstatSync(e,t){return statSync(getFH(e,`fstat`)._fdStatTarget(),t)}function fstat(e,t,n){let r=typeof t==`function`?t:n;fstatAsync(e,typeof t==`function`?{}:t).then(e=>r(null,e),e=>r(e,void 0))}async function fstatAsync(e,t){return t?.bigint,fstatSync(e,t)}function ftruncateSync(e,t=0){getFH(e,`ftruncate`)._truncateSync(t)}function ftruncate(e,t,n){let r=typeof t==`function`?t:n;ftruncateAsync(e,typeof t==`function`?0:t).then(()=>r(null),r)}async function ftruncateAsync(e,t=0){ftruncateSync(e,t)}function fdatasyncSync(e){getFH(e,`fdatasync`)._flushSync()}function fdatasync(e,t){Promise.resolve().then(()=>fdatasyncSync(e)).then(()=>t(null),t)}async function fdatasyncAsync(e){fdatasyncSync(e)}function fsyncSync(e){getFH(e,`fsync`)._flushSync()}function fsync(e,t){Promise.resolve().then(()=>fsyncSync(e)).then(()=>t(null),t)}async function fsyncAsync(e){fsyncSync(e)}function fchmodSync(e,t){chmodSync(getFH(e,`fchmod`)._fdStatTarget(),t)}function fchmod(e,t,n){Promise.resolve().then(()=>fchmodSync(e,t)).then(()=>n(null),n)}async function fchmodAsync(e,t){fchmodSync(e,t)}function fchownSync(e,t,n){chownSync(normalizePath$1(getFH(e,`fchown`).options.path),t,n)}function fchown(e,t,n,r){Promise.resolve().then(()=>fchownSync(e,t,n)).then(()=>r(null),r)}async function fchownAsync(e,t,n){fchownSync(e,t,n)}function futimesSync(e,t,n){utimesSync(normalizePath$1(getFH(e,`futimes`).options.path),t,n)}function futimes(e,t,n,r){Promise.resolve().then(()=>futimesSync(e,t,n)).then(()=>r(null),r)}async function futimesAsync(e,t,n){futimesSync(e,t,n)}function closeSync(e){isStdFd(e)||getFH(e,`close`)._closeSync()}function readSync(e,t,n,r,i){let a=0;return typeof n==`object`&&n?(a=n.offset??0,r=n.length??t.byteLength-a,i=n.position??null):(a=n??0,r??=t.byteLength-a),isStdFd(e)?readStdFdSync(e,t,a,r):getFH(e,`read`)._readSync(t,a,r,i??null)}function writeSync(e,t,n,r,i){let a;if(typeof t==`string`)a=new TextEncoder().encode(t),typeof n==`number`&&(i=n);else{let e=typeof n==`number`?n:0,i=typeof r==`number`?r:t.byteLength-e;a=new Uint8Array(t.buffer,t.byteOffset+e,i)}return isStdFd(e)?writeStdFdSync(e,a):getFH(e,`write`)._writeSync(a,i??null)}function readvSync(e,t,n){let r=0;for(let i of t){let t=readSync(e,i,0,i.byteLength,n==null?null:n+r);if(r+=t,t<i.byteLength)break}return r}function readv(e,t,n,r){let i=typeof n==`function`?n:r;readvAsync(e,t,typeof n==`function`?null:n).then(e=>i(null,e.bytesRead,e.buffers),e=>i(e,0,t))}async function readvAsync(e,t,n){return{bytesRead:readvSync(e,t,n),buffers:t}}function writevSync(e,t,n){let r=0;for(let i of t){let t=writeSync(e,i,0,i.byteLength,n==null?null:n+r);r+=t}return r}function writev(e,t,n,r){let i=typeof n==`function`?n:r;writevAsync(e,t,typeof n==`function`?null:n).then(e=>i(null,e.bytesWritten,e.buffers),e=>i(e,0,t))}async function writevAsync(e,t,n){return{bytesWritten:writevSync(e,t,n),buffers:t}}function exists(e,t){try{statSync(normalizePath$1(e)),t(!0)}catch{t(!1)}}async function openAsBlob(e,t){let n=readFileSync(normalizePath$1(e));return new Blob([n],{type:t?.type??``})}var Ka=__esmMin(()=>{$i(),ra(),oa(),Ga(),wa()});function zeroedStat(){return{dev:0,ino:0,mode:0,nlink:0,uid:0,gid:0,rdev:0,size:0,blksize:0,blocks:0,atimeMs:0,mtimeMs:0,ctimeMs:0,birthtimeMs:0,atime:new Date(0),mtime:new Date(0),ctime:new Date(0),birthtime:new Date(0),isFile:()=>!1,isDirectory:()=>!1,isBlockDevice:()=>!1,isCharacterDevice:()=>!1,isSymbolicLink:()=>!1,isFIFO:()=>!1,isSocket:()=>!1}}function watchFile$1(e,t,n){typeof t==`function`&&(n=t,t={});let r=t.interval??5007,i=e.toString(),a=qa.get(i);return a||(a=new StatWatcher(i,r),a.start(),qa.set(i,a)),n&&a.addChangeListener(n),a}function unwatchFile(e,t){let n=e.toString(),r=qa.get(n);r&&(t?r.removeChangeListener(t):r.removeAllChangeListeners(),r.changeListenerCount===0&&(r.stop(),qa.delete(n)))}var StatWatcher,qa,Ja=__esmMin(()=>{wa(),je(),StatWatcher=class extends Ae{_path;_interval;_timerId=null;_prev;_changeCount=0;constructor(e,t){super(),this._path=e,this._interval=t,this._prev=zeroedStat()}start(){try{this._prev=statSync(this._path)}catch{}this._timerId=setInterval(()=>{let e;try{e=statSync(this._path)}catch{e=zeroedStat()}let t=this._prev;(e.mtimeMs!==t.mtimeMs||e.size!==t.size||e.ino!==t.ino)&&(this._prev=e,this.emit(`change`,e,t))},this._interval)}stop(){this._timerId!==null&&(clearInterval(this._timerId),this._timerId=null),this.emit(`stop`)}addChangeListener(e){this._changeCount++,this.on(`change`,e)}removeChangeListener(e){this._changeCount--,this.removeListener(`change`,e)}removeAllChangeListeners(){this._changeCount=0,this.removeAllListeners(`change`)}get changeListenerCount(){return this._changeCount}},qa=new Map,__name(watchFile$1,`watchFile`)}),Ya=__exportAll$2({BigIntStats:()=>BigIntStats,Dir:()=>Dir,Dirent:()=>Dirent,FSWatcher:()=>FSWatcher,ReadStream:()=>ReadStream,StatWatcher:()=>StatWatcher,Stats:()=>Stats,WriteStream:()=>WriteStream,access:()=>access,accessSync:()=>accessSync,appendFile:()=>appendFile,appendFileSync:()=>appendFileSync,chmod:()=>chmod,chmodSync:()=>chmodSync,chown:()=>chown,chownSync:()=>chownSync,close:()=>close$1,closeSync:()=>closeSync,constants:()=>Xa,copyFile:()=>copyFile,copyFileSync:()=>copyFileSync,cp:()=>cp,cpSync:()=>cpSync,createReadStream:()=>createReadStream,createWriteStream:()=>createWriteStream,default:()=>Za,exists:()=>exists,existsSync:()=>existsSync,fchmod:()=>fchmod,fchmodSync:()=>fchmodSync,fchown:()=>fchown,fchownSync:()=>fchownSync,fdatasync:()=>fdatasync,fdatasyncSync:()=>fdatasyncSync,fstat:()=>fstat,fstatSync:()=>fstatSync,fsync:()=>fsync,fsyncSync:()=>fsyncSync,ftruncate:()=>ftruncate,ftruncateSync:()=>ftruncateSync,futimes:()=>futimes,futimesSync:()=>futimesSync,glob:()=>glob,globSync:()=>globSync,lchmod:()=>void 0,lchmodSync:()=>void 0,lchown:()=>lchown,lchownSync:()=>lchownSync,link:()=>link,linkSync:()=>linkSync,lstat:()=>lstat,lstatSync:()=>lstatSync,lutimes:()=>lutimes,lutimesSync:()=>lutimesSync,mkdir:()=>mkdir,mkdirSync:()=>mkdirSync,mkdtempSync:()=>mkdtempSync,open:()=>open$1,openAsBlob:()=>openAsBlob,openSync:()=>openSync,opendir:()=>opendir,opendirSync:()=>opendirSync,promises:()=>Ma,read:()=>read,readFile:()=>readFile,readFileSync:()=>readFileSync,readSync:()=>readSync,readdir:()=>readdir,readdirSync:()=>readdirSync,readlink:()=>readlink,readlinkSync:()=>readlinkSync,readv:()=>readv,readvSync:()=>readvSync,realpath:()=>realpath,realpathSync:()=>realpathSync,rename:()=>rename,renameSync:()=>renameSync,rm:()=>rm,rmSync:()=>rmSync,rmdir:()=>rmdir,rmdirSync:()=>rmdirSync,stat:()=>stat,statSync:()=>statSync,statfs:()=>statfs,statfsSync:()=>statfsSync,symlink:()=>symlink,symlinkSync:()=>symlinkSync,truncate:()=>truncate,truncateSync:()=>truncateSync,unlink:()=>unlink,unlinkSync:()=>unlinkSync,unwatchFile:()=>unwatchFile,utimes:()=>utimes,utimesSync:()=>utimesSync,watch:()=>watch,watchFile:()=>watchFile$1,write:()=>write,writeFile:()=>writeFile$1,writeFileSync:()=>writeFileSync,writeSync:()=>writeSync,writev:()=>writev,writevSync:()=>writevSync});function openFlagDescriptors(){let e={};for(let t of Object.keys(openFlagValues()))e[t]={enumerable:!0,configurable:!0,get:()=>openFlagValues()[t]};return e}var Xa,Za,Qa=__esmMin(()=>{ta(),ra(),Ka(),ca(),fa(),Ra(),ma(),Ca(),wa(),Ta(),Da(),Oa(),ja(),Pa(),Fa(),Ja(),Xa=Object.defineProperties({F_OK:0,R_OK:4,W_OK:2,X_OK:1,COPYFILE_EXCL:1,COPYFILE_FICLONE:2,COPYFILE_FICLONE_FORCE:4,S_IFMT:61440,S_IFREG:32768,S_IFDIR:16384,S_IFCHR:8192,S_IFBLK:24576,S_IFIFO:4096,S_IFLNK:40960,S_IFSOCK:49152,S_IRWXU:448,S_IRUSR:256,S_IWUSR:128,S_IXUSR:64,S_IRWXG:56,S_IRGRP:32,S_IWGRP:16,S_IXGRP:8,S_IRWXO:7,S_IROTH:4,S_IWOTH:2,S_IXOTH:1},openFlagDescriptors()),Za={FSWatcher,StatWatcher,Stats,BigIntStats,Dirent,Dir,constants:Xa,existsSync,readdirSync,readFileSync,writeFileSync,mkdirSync,rmdirSync,unlinkSync,mkdtempSync,rmSync,statSync,openSync,realpathSync,symlinkSync,lstatSync,renameSync,copyFileSync,accessSync,appendFileSync,readlinkSync,linkSync,truncateSync,chmodSync,chownSync,cpSync,opendirSync,globSync,glob,watch,watchFile:watchFile$1,unwatchFile,statfsSync,statfs,utimesSync,utimes,lutimesSync,lutimes,lchownSync,lchown,lchmodSync:void 0,lchmod:void 0,fstatSync,fstat,ftruncateSync,ftruncate,fdatasyncSync,fdatasync,fsyncSync,fsync,fchmodSync,fchmod,fchownSync,fchown,futimesSync,futimes,closeSync,readSync,writeSync,readvSync,readv,writevSync,writev,exists,openAsBlob,createReadStream,ReadStream,createWriteStream,WriteStream,promises:Ma,open:open$1,close:close$1,read,write,rm,realpath,readdir,symlink,lstat,stat,rename,copyFile,cp,access,appendFile,readlink,truncate,chmod,chown,mkdir,rmdir,readFile,writeFile:writeFile$1,unlink,link,opendir}}),$a,eo=__esmMin(()=>{$a={UV_UDP_REUSEADDR:4,errno:{E2BIG:7,EACCES:13,EADDRINUSE:98,EADDRNOTAVAIL:99,EAFNOSUPPORT:97,EAGAIN:11,EALREADY:114,EBADF:9,EBADMSG:74,EBUSY:16,ECANCELED:125,ECHILD:10,ECONNABORTED:103,ECONNREFUSED:111,ECONNRESET:104,EDEADLK:35,EDESTADDRREQ:89,EDOM:33,EDQUOT:122,EEXIST:17,EFAULT:14,EFBIG:27,EHOSTUNREACH:113,EIDRM:43,EILSEQ:84,EINPROGRESS:115,EINTR:4,EINVAL:22,EIO:5,EISCONN:106,EISDIR:21,ELOOP:40,EMFILE:24,EMLINK:31,EMSGSIZE:90,EMULTIHOP:72,ENAMETOOLONG:36,ENETDOWN:100,ENETRESET:102,ENETUNREACH:101,ENFILE:23,ENOBUFS:105,ENODATA:61,ENODEV:19,ENOENT:2,ENOEXEC:8,ENOLCK:37,ENOLINK:67,ENOMEM:12,ENOMSG:42,ENOPROTOOPT:92,ENOSPC:28,ENOSR:63,ENOSTR:60,ENOSYS:38,ENOTCONN:107,ENOTDIR:20,ENOTEMPTY:39,ENOTSOCK:88,ENOTSUP:95,ENOTTY:25,ENXIO:6,EOPNOTSUPP:95,EOVERFLOW:75,EPERM:1,EPIPE:32,EPROTO:71,EPROTONOSUPPORT:93,EPROTOTYPE:91,ERANGE:34,EROFS:30,ESPIPE:29,ESRCH:3,ESTALE:116,ETIME:62,ETIMEDOUT:110,ETXTBSY:26,EWOULDBLOCK:11,EXDEV:18},signals:{SIGHUP:1,SIGINT:2,SIGQUIT:3,SIGILL:4,SIGTRAP:5,SIGABRT:6,SIGIOT:6,SIGBUS:7,SIGFPE:8,SIGKILL:9,SIGUSR1:10,SIGSEGV:11,SIGUSR2:12,SIGPIPE:13,SIGALRM:14,SIGTERM:15,SIGCHLD:17,SIGSTKFLT:16,SIGCONT:18,SIGSTOP:19,SIGTSTP:20,SIGTTIN:21,SIGTTOU:22,SIGURG:23,SIGXCPU:24,SIGXFSZ:25,SIGVTALRM:26,SIGPROF:27,SIGWINCH:28,SIGIO:29,SIGPOLL:29,SIGPWR:30,SIGSYS:31},priority:{PRIORITY_LOW:19,PRIORITY_BELOW_NORMAL:10,PRIORITY_NORMAL:0,PRIORITY_ABOVE_NORMAL:-7,PRIORITY_HIGH:-14,PRIORITY_HIGHEST:-20},dlopen:{RTLD_LAZY:1,RTLD_NOW:2,RTLD_GLOBAL:256,RTLD_LOCAL:0,RTLD_DEEPBIND:8}}});function createSubnet(e,t,n,r){let i=`0`.repeat(e);return a=>{let o=(`1`.repeat(parseInt(a,10))+i).slice(0,e),s=[];for(let r=0;r<e;r+=t)s.push(parseInt(o.substr(r,t),2).toString(n));return s.join(r)}}var to=__esmMin(()=>{}),no,ro,sysctl,io,ao,oo,so,co,lo,uo,fo,po=__esmMin(()=>{to(),yi(),no=createSubnet(128,16,16,`:`),ro=__name(function(e){if(e=e.trim(),e.length<1||!/\binet6?\b/.test(e))return;let t=e.split(`
|
|
10
10
|
`),n=[],r=t.length,i=`00:00:00:00:00:00`,a=/<[^>]*\bLOOPBACK\b[^>]*>/.test(t[0]??``);for(let e,o=0;o<r;o++)switch(e=t[o],!0){case/ether\s+((?:\S{2}:)+\S{2})/.test(e):i=RegExp.$1;break;case/inet\s+(\d+\.\d+\.\d+\.\d+)\s+netmask\s+0x(.{2})(.{2})(.{2})(.{2})/.test(e):n.push({address:RegExp.$1,netmask:[parseInt(RegExp.$2,16),parseInt(RegExp.$3,16),parseInt(RegExp.$4,16),parseInt(RegExp.$5,16)].join(`.`),family:`IPv4`,mac:i,internal:a});break;case/inet6\s+([^\s%]+)(?:%\S+)?\s+prefixlen\s+(\d+)/.test(e):n.push({address:RegExp.$1,netmask:no(RegExp.$2),family:`IPv6`,mac:i,internal:a});break}this[e.slice(0,e.indexOf(`:`))]=n},`parseInterfaces`),sysctl=e=>{try{let t=cli(`sysctl -n ${e}`).trim();return t.length>0?t:null}catch{return null}},io=Object.freeze({user:0,nice:0,sys:0,idle:0,irq:0}),ao=__name(()=>{let e=parseFloat(cli(`sysctl -n hw.ncpu`)),t=sysctl(`machdep.cpu.brand_string`)?.replace(/\s+/g,` `)??`unknown`,n=sysctl(`hw.cpufrequency`),r=n?parseFloat(n)/1e3/1e3:0,i=[];for(let n=0;n<e;n++)i.push({model:t,speed:r,times:{...io}});return i},`cpus`),oo=__name(()=>`LE`,`endianness`),so=__name(()=>{try{let e=cli(`vm_stat`),t=/page size of (\d+) bytes/.exec(e),n=t?parseInt(t[1],10):16384,r=0,i=/Pages free:\s+(\d+)/.exec(e);i&&(r+=parseInt(i[1],10));let a=/Pages speculative:\s+(\d+)/.exec(e);a&&(r+=parseInt(a[1],10));let o=/Pages purgeable:\s+(\d+)/.exec(e);if(o&&(r+=parseInt(o[1],10)),r>0)return r*n}catch{}try{return parseFloat(cli(`sysctl -n hw.memsize`))-parseFloat(cli(`sysctl -n hw.physmem`))}catch{return 0}},`freemem`),co=__name(()=>/load\s+averages:\s+(\d+(?:\.\d+)?)\s+(\d+(?:\.\d+)?)\s+(\d+(?:\.\d+)?)/.test(cli(`uptime`))?[parseFloat(RegExp.$1),parseFloat(RegExp.$2),parseFloat(RegExp.$3)]:[0,0,0],`loadavg`),lo=__name(()=>{let e={},t=[],n=cli(`ifconfig`).split(/\r\n|\n/),r=n.length;for(let e=[],i=/^\S+?:/,a=0;a<r;a++){if(i.test(n[a])){for(e=[n[a]];++a<r&&!i.test(n[a]);)e.push(n[a]);--a}t.push(e.join(`
|
|
11
11
|
`))}return t.forEach(ro,e),e},`networkInterfaces`),uo=__name(()=>{try{return parseFloat(cli(`sysctl -n hw.memsize`))}catch{return 0}},`totalmem`),fo=__name(()=>{try{let e=cli(`sysctl -n kern.boottime`),t=/sec\s*=\s*(\d+)/.exec(e);if(t){let e=parseInt(t[1],10);return Math.floor(Date.now()/1e3)-e}}catch{}let e=cli(`uptime`),t=/up\s+([^,]+)?,/.test(e)&&RegExp.$1;switch(!0){case/^(\d+):(\d+)$/.test(t):return(parseInt(RegExp.$1,10)*60+parseInt(RegExp.$2,10))*60;case/^(\d+)\s+mins?$/.test(t):return parseInt(RegExp.$1,10)*60;case/^(\d+)\s+days?$/.test(t):{let t=parseInt(RegExp.$1,10)*86400,n=/days?,\s+(\d+):(\d+)/.exec(e);return n?t+(parseInt(n[1],10)*60+parseInt(n[2],10))*60:t}}return 0},`uptime`)});function readTextFile(e){let[t,n]=L.file_get_contents(e);return!t||!n?``:mo.decode(n)}function parseInterfaces(e){if(e=e.trim(),e.length<1)return;let t=/<[^>]*\bLOOPBACK\b[^>]*>/.test(e.split(ho)[0]??``),n=[],r;for(let i,a=e.split(ho),o=0;o<a.length;o++)switch(i=a[o],!0){case/link\/\S+\s+((?:\S{2}:)+\S{2})/.test(i):r=RegExp.$1;break;case/inet(\d*)\s+(\S+)/.test(i):let e=RegExp.$2.split(`/`),a=RegExp.$1||`4`;n.push({address:e[0],netmask:(a===`4`?go:_o)(e[1]),family:`IPv`+a,mac:r,internal:t});break}r&&(this[e.slice(0,e.indexOf(`:`))]=n)}function readNetworkInterfacesFromProc(){let e={},t={};try{let n=readTextFile(`/proc/net/dev`);for(let r of n.split(`
|
|
12
12
|
`).slice(2)){let n=r.split(`:`)[0]?.trim();if(n){e[n]=[];try{t[n]=readTextFile(`/sys/class/net/${n}/address`).trim()}catch{t[n]=`00:00:00:00:00:00`}}}}catch{return e}try{let n=readTextFile(`/proc/net/if_inet6`);for(let r of n.split(`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gjsify/tsc",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.38.0",
|
|
4
4
|
"description": "TypeScript compiler for GJS — bundles upstream `typescript` to a single GJS module + ships a Node-free `tsc` bin.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.ts",
|
|
@@ -52,13 +52,13 @@
|
|
|
52
52
|
"homepage": "https://github.com/gjsify/gjsify/tree/main/packages/infra/tsc#readme",
|
|
53
53
|
"license": "MIT",
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@gjsify/console": "^0.
|
|
56
|
-
"@gjsify/node-globals": "^0.
|
|
57
|
-
"@gjsify/web-globals": "^0.
|
|
55
|
+
"@gjsify/console": "^0.38.0",
|
|
56
|
+
"@gjsify/node-globals": "^0.38.0",
|
|
57
|
+
"@gjsify/web-globals": "^0.38.0"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
|
-
"@gjsify/cli": "^0.
|
|
61
|
-
"@gjsify/unit": "^0.
|
|
60
|
+
"@gjsify/cli": "^0.38.0",
|
|
61
|
+
"@gjsify/unit": "^0.38.0",
|
|
62
62
|
"@girs/gio-2.0": "^4.1.0",
|
|
63
63
|
"@girs/glib-2.0": "^4.1.0",
|
|
64
64
|
"typescript": "^6.0.3"
|